d23cedb422302b19ef8507f0bf9a40d19ef9edab237c3905a39fb864fc14b3ac9d764e67eca8797e6d7904f389b76a04b238d2f562367cfbd24ec4a10880c7 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889
  1. /** @license React v16.14.0
  2. * react-jsx-dev-runtime.development.js
  3. *
  4. * Copyright (c) Facebook, Inc. and its affiliates.
  5. *
  6. * This source code is licensed under the MIT license found in the
  7. * LICENSE file in the root directory of this source tree.
  8. */
  9. 'use strict';
  10. if (process.env.NODE_ENV !== "production") {
  11. (function() {
  12. 'use strict';
  13. var React = require('react');
  14. // ATTENTION
  15. // When adding new symbols to this file,
  16. // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
  17. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  18. // nor polyfill, then a plain number is used for performance.
  19. var REACT_ELEMENT_TYPE = 0xeac7;
  20. var REACT_PORTAL_TYPE = 0xeaca;
  21. exports.Fragment = 0xeacb;
  22. var REACT_STRICT_MODE_TYPE = 0xeacc;
  23. var REACT_PROFILER_TYPE = 0xead2;
  24. var REACT_PROVIDER_TYPE = 0xeacd;
  25. var REACT_CONTEXT_TYPE = 0xeace;
  26. var REACT_FORWARD_REF_TYPE = 0xead0;
  27. var REACT_SUSPENSE_TYPE = 0xead1;
  28. var REACT_SUSPENSE_LIST_TYPE = 0xead8;
  29. var REACT_MEMO_TYPE = 0xead3;
  30. var REACT_LAZY_TYPE = 0xead4;
  31. var REACT_BLOCK_TYPE = 0xead9;
  32. var REACT_SERVER_BLOCK_TYPE = 0xeada;
  33. var REACT_FUNDAMENTAL_TYPE = 0xead5;
  34. var REACT_SCOPE_TYPE = 0xead7;
  35. var REACT_OPAQUE_ID_TYPE = 0xeae0;
  36. var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
  37. var REACT_OFFSCREEN_TYPE = 0xeae2;
  38. var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
  39. if (typeof Symbol === 'function' && Symbol.for) {
  40. var symbolFor = Symbol.for;
  41. REACT_ELEMENT_TYPE = symbolFor('react.element');
  42. REACT_PORTAL_TYPE = symbolFor('react.portal');
  43. exports.Fragment = symbolFor('react.fragment');
  44. REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
  45. REACT_PROFILER_TYPE = symbolFor('react.profiler');
  46. REACT_PROVIDER_TYPE = symbolFor('react.provider');
  47. REACT_CONTEXT_TYPE = symbolFor('react.context');
  48. REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
  49. REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
  50. REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
  51. REACT_MEMO_TYPE = symbolFor('react.memo');
  52. REACT_LAZY_TYPE = symbolFor('react.lazy');
  53. REACT_BLOCK_TYPE = symbolFor('react.block');
  54. REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
  55. REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
  56. REACT_SCOPE_TYPE = symbolFor('react.scope');
  57. REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
  58. REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
  59. REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
  60. REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
  61. }
  62. var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  63. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  64. function getIteratorFn(maybeIterable) {
  65. if (maybeIterable === null || typeof maybeIterable !== 'object') {
  66. return null;
  67. }
  68. var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
  69. if (typeof maybeIterator === 'function') {
  70. return maybeIterator;
  71. }
  72. return null;
  73. }
  74. var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
  75. function error(format) {
  76. {
  77. for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  78. args[_key2 - 1] = arguments[_key2];
  79. }
  80. printWarning('error', format, args);
  81. }
  82. }
  83. function printWarning(level, format, args) {
  84. // When changing this logic, you might want to also
  85. // update consoleWithStackDev.www.js as well.
  86. {
  87. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  88. var stack = '';
  89. if (currentlyValidatingElement) {
  90. var name = getComponentName(currentlyValidatingElement.type);
  91. var owner = currentlyValidatingElement._owner;
  92. stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
  93. }
  94. stack += ReactDebugCurrentFrame.getStackAddendum();
  95. if (stack !== '') {
  96. format += '%s';
  97. args = args.concat([stack]);
  98. }
  99. var argsWithFormat = args.map(function (item) {
  100. return '' + item;
  101. }); // Careful: RN currently depends on this prefix
  102. argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
  103. // breaks IE9: https://github.com/facebook/react/issues/13610
  104. // eslint-disable-next-line react-internal/no-production-logging
  105. Function.prototype.apply.call(console[level], console, argsWithFormat);
  106. }
  107. }
  108. // Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
  109. var enableScopeAPI = false; // Experimental Create Event Handle API.
  110. function isValidElementType(type) {
  111. if (typeof type === 'string' || typeof type === 'function') {
  112. return true;
  113. } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
  114. if (type === exports.Fragment || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
  115. return true;
  116. }
  117. if (typeof type === 'object' && type !== null) {
  118. 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 || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
  119. return true;
  120. }
  121. }
  122. return false;
  123. }
  124. var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
  125. function describeComponentFrame (name, source, ownerName) {
  126. var sourceInfo = '';
  127. if (source) {
  128. var path = source.fileName;
  129. var fileName = path.replace(BEFORE_SLASH_RE, '');
  130. {
  131. // In DEV, include code for a common special case:
  132. // prefer "folder/index.js" instead of just "index.js".
  133. if (/^index\./.test(fileName)) {
  134. var match = path.match(BEFORE_SLASH_RE);
  135. if (match) {
  136. var pathBeforeSlash = match[1];
  137. if (pathBeforeSlash) {
  138. var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
  139. fileName = folderName + '/' + fileName;
  140. }
  141. }
  142. }
  143. }
  144. sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
  145. } else if (ownerName) {
  146. sourceInfo = ' (created by ' + ownerName + ')';
  147. }
  148. return '\n in ' + (name || 'Unknown') + sourceInfo;
  149. }
  150. var Resolved = 1;
  151. function refineResolvedLazyComponent(lazyComponent) {
  152. return lazyComponent._status === Resolved ? lazyComponent._result : null;
  153. }
  154. function getWrappedName(outerType, innerType, wrapperName) {
  155. var functionName = innerType.displayName || innerType.name || '';
  156. return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
  157. }
  158. function getComponentName(type) {
  159. if (type == null) {
  160. // Host root, text node or just invalid type.
  161. return null;
  162. }
  163. {
  164. if (typeof type.tag === 'number') {
  165. error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
  166. }
  167. }
  168. if (typeof type === 'function') {
  169. return type.displayName || type.name || null;
  170. }
  171. if (typeof type === 'string') {
  172. return type;
  173. }
  174. switch (type) {
  175. case exports.Fragment:
  176. return 'Fragment';
  177. case REACT_PORTAL_TYPE:
  178. return 'Portal';
  179. case REACT_PROFILER_TYPE:
  180. return "Profiler";
  181. case REACT_STRICT_MODE_TYPE:
  182. return 'StrictMode';
  183. case REACT_SUSPENSE_TYPE:
  184. return 'Suspense';
  185. case REACT_SUSPENSE_LIST_TYPE:
  186. return 'SuspenseList';
  187. }
  188. if (typeof type === 'object') {
  189. switch (type.$$typeof) {
  190. case REACT_CONTEXT_TYPE:
  191. return 'Context.Consumer';
  192. case REACT_PROVIDER_TYPE:
  193. return 'Context.Provider';
  194. case REACT_FORWARD_REF_TYPE:
  195. return getWrappedName(type, type.render, 'ForwardRef');
  196. case REACT_MEMO_TYPE:
  197. return getComponentName(type.type);
  198. case REACT_BLOCK_TYPE:
  199. return getComponentName(type.render);
  200. case REACT_LAZY_TYPE:
  201. {
  202. var thenable = type;
  203. var resolvedThenable = refineResolvedLazyComponent(thenable);
  204. if (resolvedThenable) {
  205. return getComponentName(resolvedThenable);
  206. }
  207. break;
  208. }
  209. }
  210. }
  211. return null;
  212. }
  213. var loggedTypeFailures = {};
  214. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  215. var currentlyValidatingElement = null;
  216. function setCurrentlyValidatingElement(element) {
  217. currentlyValidatingElement = element;
  218. }
  219. function checkPropTypes(typeSpecs, values, location, componentName, element) {
  220. {
  221. // $FlowFixMe This is okay but Flow doesn't know it.
  222. var has = Function.call.bind(Object.prototype.hasOwnProperty);
  223. for (var typeSpecName in typeSpecs) {
  224. if (has(typeSpecs, typeSpecName)) {
  225. var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
  226. // fail the render phase where it didn't fail before. So we log it.
  227. // After these have been cleaned up, we'll let them throw.
  228. try {
  229. // This is intentionally an invariant that gets caught. It's the same
  230. // behavior as without this statement except with a better message.
  231. if (typeof typeSpecs[typeSpecName] !== 'function') {
  232. 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`.');
  233. err.name = 'Invariant Violation';
  234. throw err;
  235. }
  236. error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
  237. } catch (ex) {
  238. error$1 = ex;
  239. }
  240. if (error$1 && !(error$1 instanceof Error)) {
  241. setCurrentlyValidatingElement(element);
  242. 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);
  243. setCurrentlyValidatingElement(null);
  244. }
  245. if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
  246. // Only monitor this failure once because there tends to be a lot of the
  247. // same error.
  248. loggedTypeFailures[error$1.message] = true;
  249. setCurrentlyValidatingElement(element);
  250. error('Failed %s type: %s', location, error$1.message);
  251. setCurrentlyValidatingElement(null);
  252. }
  253. }
  254. }
  255. }
  256. }
  257. var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
  258. var hasOwnProperty = Object.prototype.hasOwnProperty;
  259. var RESERVED_PROPS = {
  260. key: true,
  261. ref: true,
  262. __self: true,
  263. __source: true
  264. };
  265. var specialPropKeyWarningShown;
  266. var specialPropRefWarningShown;
  267. var didWarnAboutStringRefs;
  268. {
  269. didWarnAboutStringRefs = {};
  270. }
  271. function hasValidRef(config) {
  272. {
  273. if (hasOwnProperty.call(config, 'ref')) {
  274. var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
  275. if (getter && getter.isReactWarning) {
  276. return false;
  277. }
  278. }
  279. }
  280. return config.ref !== undefined;
  281. }
  282. function hasValidKey(config) {
  283. {
  284. if (hasOwnProperty.call(config, 'key')) {
  285. var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
  286. if (getter && getter.isReactWarning) {
  287. return false;
  288. }
  289. }
  290. }
  291. return config.key !== undefined;
  292. }
  293. function warnIfStringRefCannotBeAutoConverted(config, self) {
  294. {
  295. if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
  296. var componentName = getComponentName(ReactCurrentOwner.current.type);
  297. if (!didWarnAboutStringRefs[componentName]) {
  298. 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', getComponentName(ReactCurrentOwner.current.type), config.ref);
  299. didWarnAboutStringRefs[componentName] = true;
  300. }
  301. }
  302. }
  303. }
  304. function defineKeyPropWarningGetter(props, displayName) {
  305. {
  306. var warnAboutAccessingKey = function () {
  307. if (!specialPropKeyWarningShown) {
  308. specialPropKeyWarningShown = true;
  309. 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);
  310. }
  311. };
  312. warnAboutAccessingKey.isReactWarning = true;
  313. Object.defineProperty(props, 'key', {
  314. get: warnAboutAccessingKey,
  315. configurable: true
  316. });
  317. }
  318. }
  319. function defineRefPropWarningGetter(props, displayName) {
  320. {
  321. var warnAboutAccessingRef = function () {
  322. if (!specialPropRefWarningShown) {
  323. specialPropRefWarningShown = true;
  324. 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);
  325. }
  326. };
  327. warnAboutAccessingRef.isReactWarning = true;
  328. Object.defineProperty(props, 'ref', {
  329. get: warnAboutAccessingRef,
  330. configurable: true
  331. });
  332. }
  333. }
  334. /**
  335. * Factory method to create a new React element. This no longer adheres to
  336. * the class pattern, so do not use new to call it. Also, instanceof check
  337. * will not work. Instead test $$typeof field against Symbol.for('react.element') to check
  338. * if something is a React Element.
  339. *
  340. * @param {*} type
  341. * @param {*} props
  342. * @param {*} key
  343. * @param {string|object} ref
  344. * @param {*} owner
  345. * @param {*} self A *temporary* helper to detect places where `this` is
  346. * different from the `owner` when React.createElement is called, so that we
  347. * can warn. We want to get rid of owner and replace string `ref`s with arrow
  348. * functions, and as long as `this` and owner are the same, there will be no
  349. * change in behavior.
  350. * @param {*} source An annotation object (added by a transpiler or otherwise)
  351. * indicating filename, line number, and/or other information.
  352. * @internal
  353. */
  354. var ReactElement = function (type, key, ref, self, source, owner, props) {
  355. var element = {
  356. // This tag allows us to uniquely identify this as a React Element
  357. $$typeof: REACT_ELEMENT_TYPE,
  358. // Built-in properties that belong on the element
  359. type: type,
  360. key: key,
  361. ref: ref,
  362. props: props,
  363. // Record the component responsible for creating this element.
  364. _owner: owner
  365. };
  366. {
  367. // The validation flag is currently mutative. We put it on
  368. // an external backing store so that we can freeze the whole object.
  369. // This can be replaced with a WeakMap once they are implemented in
  370. // commonly used development environments.
  371. element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
  372. // the validation flag non-enumerable (where possible, which should
  373. // include every environment we run tests in), so the test framework
  374. // ignores it.
  375. Object.defineProperty(element._store, 'validated', {
  376. configurable: false,
  377. enumerable: false,
  378. writable: true,
  379. value: false
  380. }); // self and source are DEV only properties.
  381. Object.defineProperty(element, '_self', {
  382. configurable: false,
  383. enumerable: false,
  384. writable: false,
  385. value: self
  386. }); // Two elements created in two different places should be considered
  387. // equal for testing purposes and therefore we hide it from enumeration.
  388. Object.defineProperty(element, '_source', {
  389. configurable: false,
  390. enumerable: false,
  391. writable: false,
  392. value: source
  393. });
  394. if (Object.freeze) {
  395. Object.freeze(element.props);
  396. Object.freeze(element);
  397. }
  398. }
  399. return element;
  400. };
  401. /**
  402. * https://github.com/reactjs/rfcs/pull/107
  403. * @param {*} type
  404. * @param {object} props
  405. * @param {string} key
  406. */
  407. function jsxDEV(type, config, maybeKey, source, self) {
  408. {
  409. var propName; // Reserved names are extracted
  410. var props = {};
  411. var key = null;
  412. var ref = null; // Currently, key can be spread in as a prop. This causes a potential
  413. // issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
  414. // or <div key="Hi" {...props} /> ). We want to deprecate key spread,
  415. // but as an intermediary step, we will use jsxDEV for everything except
  416. // <div {...props} key="Hi" />, because we aren't currently able to tell if
  417. // key is explicitly declared to be undefined or not.
  418. if (maybeKey !== undefined) {
  419. key = '' + maybeKey;
  420. }
  421. if (hasValidKey(config)) {
  422. key = '' + config.key;
  423. }
  424. if (hasValidRef(config)) {
  425. ref = config.ref;
  426. warnIfStringRefCannotBeAutoConverted(config, self);
  427. } // Remaining properties are added to a new props object
  428. for (propName in config) {
  429. if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
  430. props[propName] = config[propName];
  431. }
  432. } // Resolve default props
  433. if (type && type.defaultProps) {
  434. var defaultProps = type.defaultProps;
  435. for (propName in defaultProps) {
  436. if (props[propName] === undefined) {
  437. props[propName] = defaultProps[propName];
  438. }
  439. }
  440. }
  441. if (key || ref) {
  442. var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
  443. if (key) {
  444. defineKeyPropWarningGetter(props, displayName);
  445. }
  446. if (ref) {
  447. defineRefPropWarningGetter(props, displayName);
  448. }
  449. }
  450. return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
  451. }
  452. }
  453. var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
  454. var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
  455. function setCurrentlyValidatingElement$1(element) {
  456. currentlyValidatingElement = element;
  457. }
  458. var propTypesMisspellWarningShown;
  459. {
  460. propTypesMisspellWarningShown = false;
  461. }
  462. /**
  463. * Verifies the object is a ReactElement.
  464. * See https://reactjs.org/docs/react-api.html#isvalidelement
  465. * @param {?object} object
  466. * @return {boolean} True if `object` is a ReactElement.
  467. * @final
  468. */
  469. function isValidElement(object) {
  470. {
  471. return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
  472. }
  473. }
  474. function getDeclarationErrorAddendum() {
  475. {
  476. if (ReactCurrentOwner$1.current) {
  477. var name = getComponentName(ReactCurrentOwner$1.current.type);
  478. if (name) {
  479. return '\n\nCheck the render method of `' + name + '`.';
  480. }
  481. }
  482. return '';
  483. }
  484. }
  485. function getSourceInfoErrorAddendum(source) {
  486. {
  487. if (source !== undefined) {
  488. var fileName = source.fileName.replace(/^.*[\\\/]/, '');
  489. var lineNumber = source.lineNumber;
  490. return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
  491. }
  492. return '';
  493. }
  494. }
  495. /**
  496. * Warn if there's no key explicitly set on dynamic arrays of children or
  497. * object keys are not valid. This allows us to keep track of children between
  498. * updates.
  499. */
  500. var ownerHasKeyUseWarning = {};
  501. function getCurrentComponentErrorInfo(parentType) {
  502. {
  503. var info = getDeclarationErrorAddendum();
  504. if (!info) {
  505. var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
  506. if (parentName) {
  507. info = "\n\nCheck the top-level render call using <" + parentName + ">.";
  508. }
  509. }
  510. return info;
  511. }
  512. }
  513. /**
  514. * Warn if the element doesn't have an explicit key assigned to it.
  515. * This element is in an array. The array could grow and shrink or be
  516. * reordered. All children that haven't already been validated are required to
  517. * have a "key" property assigned to it. Error statuses are cached so a warning
  518. * will only be shown once.
  519. *
  520. * @internal
  521. * @param {ReactElement} element Element that requires a key.
  522. * @param {*} parentType element's parent's type.
  523. */
  524. function validateExplicitKey(element, parentType) {
  525. {
  526. if (!element._store || element._store.validated || element.key != null) {
  527. return;
  528. }
  529. element._store.validated = true;
  530. var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
  531. if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
  532. return;
  533. }
  534. ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
  535. // property, it may be the creator of the child that's responsible for
  536. // assigning it a key.
  537. var childOwner = '';
  538. if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
  539. // Give the component that originally created this child.
  540. childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
  541. }
  542. setCurrentlyValidatingElement$1(element);
  543. 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);
  544. setCurrentlyValidatingElement$1(null);
  545. }
  546. }
  547. /**
  548. * Ensure that every element either is passed in a static location, in an
  549. * array with an explicit keys property defined, or in an object literal
  550. * with valid key property.
  551. *
  552. * @internal
  553. * @param {ReactNode} node Statically passed child of any type.
  554. * @param {*} parentType node's parent's type.
  555. */
  556. function validateChildKeys(node, parentType) {
  557. {
  558. if (typeof node !== 'object') {
  559. return;
  560. }
  561. if (Array.isArray(node)) {
  562. for (var i = 0; i < node.length; i++) {
  563. var child = node[i];
  564. if (isValidElement(child)) {
  565. validateExplicitKey(child, parentType);
  566. }
  567. }
  568. } else if (isValidElement(node)) {
  569. // This element was passed in a valid location.
  570. if (node._store) {
  571. node._store.validated = true;
  572. }
  573. } else if (node) {
  574. var iteratorFn = getIteratorFn(node);
  575. if (typeof iteratorFn === 'function') {
  576. // Entry iterators used to provide implicit keys,
  577. // but now we print a separate warning for them later.
  578. if (iteratorFn !== node.entries) {
  579. var iterator = iteratorFn.call(node);
  580. var step;
  581. while (!(step = iterator.next()).done) {
  582. if (isValidElement(step.value)) {
  583. validateExplicitKey(step.value, parentType);
  584. }
  585. }
  586. }
  587. }
  588. }
  589. }
  590. }
  591. /**
  592. * Given an element, validate that its props follow the propTypes definition,
  593. * provided by the type.
  594. *
  595. * @param {ReactElement} element
  596. */
  597. function validatePropTypes(element) {
  598. {
  599. var type = element.type;
  600. if (type === null || type === undefined || typeof type === 'string') {
  601. return;
  602. }
  603. var propTypes;
  604. if (typeof type === 'function') {
  605. propTypes = type.propTypes;
  606. } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
  607. // Inner props are checked in the reconciler.
  608. type.$$typeof === REACT_MEMO_TYPE)) {
  609. propTypes = type.propTypes;
  610. } else {
  611. return;
  612. }
  613. if (propTypes) {
  614. // Intentionally inside to avoid triggering lazy initializers:
  615. var name = getComponentName(type);
  616. checkPropTypes(propTypes, element.props, 'prop', name, element);
  617. } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
  618. propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
  619. var _name = getComponentName(type);
  620. error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
  621. }
  622. if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
  623. error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
  624. }
  625. }
  626. }
  627. /**
  628. * Given a fragment, validate that it can only be provided with fragment props
  629. * @param {ReactElement} fragment
  630. */
  631. function validateFragmentProps(fragment) {
  632. {
  633. var keys = Object.keys(fragment.props);
  634. for (var i = 0; i < keys.length; i++) {
  635. var key = keys[i];
  636. if (key !== 'children' && key !== 'key') {
  637. setCurrentlyValidatingElement$1(fragment);
  638. error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
  639. setCurrentlyValidatingElement$1(null);
  640. break;
  641. }
  642. }
  643. if (fragment.ref !== null) {
  644. setCurrentlyValidatingElement$1(fragment);
  645. error('Invalid attribute `ref` supplied to `React.Fragment`.');
  646. setCurrentlyValidatingElement$1(null);
  647. }
  648. }
  649. }
  650. function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
  651. {
  652. var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
  653. // succeed and there will likely be errors in render.
  654. if (!validType) {
  655. var info = '';
  656. if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
  657. 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.";
  658. }
  659. var sourceInfo = getSourceInfoErrorAddendum(source);
  660. if (sourceInfo) {
  661. info += sourceInfo;
  662. } else {
  663. info += getDeclarationErrorAddendum();
  664. }
  665. var typeString;
  666. if (type === null) {
  667. typeString = 'null';
  668. } else if (Array.isArray(type)) {
  669. typeString = 'array';
  670. } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
  671. typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
  672. info = ' Did you accidentally export a JSX literal instead of a component?';
  673. } else {
  674. typeString = typeof type;
  675. }
  676. error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
  677. }
  678. var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
  679. // TODO: Drop this when these are no longer allowed as the type argument.
  680. if (element == null) {
  681. return element;
  682. } // Skip key warning if the type isn't valid since our key validation logic
  683. // doesn't expect a non-string/function type and can throw confusing errors.
  684. // We don't want exception behavior to differ between dev and prod.
  685. // (Rendering will throw with a helpful message and as soon as the type is
  686. // fixed, the key warnings will appear.)
  687. if (validType) {
  688. var children = props.children;
  689. if (children !== undefined) {
  690. if (isStaticChildren) {
  691. if (Array.isArray(children)) {
  692. for (var i = 0; i < children.length; i++) {
  693. validateChildKeys(children[i], type);
  694. }
  695. if (Object.freeze) {
  696. Object.freeze(children);
  697. }
  698. } else {
  699. error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
  700. }
  701. } else {
  702. validateChildKeys(children, type);
  703. }
  704. }
  705. }
  706. if (type === exports.Fragment) {
  707. validateFragmentProps(element);
  708. } else {
  709. validatePropTypes(element);
  710. }
  711. return element;
  712. }
  713. } // These two functions exist to still get child warnings in dev
  714. var jsxDEV$1 = jsxWithValidation ;
  715. exports.jsxDEV = jsxDEV$1;
  716. })();
  717. }