react-jsx-dev-runtime.development.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203
  1. /** @license React v17.0.2
  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. var _assign = require('object-assign');
  15. // ATTENTION
  16. // When adding new symbols to this file,
  17. // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
  18. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  19. // nor polyfill, then a plain number is used for performance.
  20. var REACT_ELEMENT_TYPE = 0xeac7;
  21. var REACT_PORTAL_TYPE = 0xeaca;
  22. exports.Fragment = 0xeacb;
  23. var REACT_STRICT_MODE_TYPE = 0xeacc;
  24. var REACT_PROFILER_TYPE = 0xead2;
  25. var REACT_PROVIDER_TYPE = 0xeacd;
  26. var REACT_CONTEXT_TYPE = 0xeace;
  27. var REACT_FORWARD_REF_TYPE = 0xead0;
  28. var REACT_SUSPENSE_TYPE = 0xead1;
  29. var REACT_SUSPENSE_LIST_TYPE = 0xead8;
  30. var REACT_MEMO_TYPE = 0xead3;
  31. var REACT_LAZY_TYPE = 0xead4;
  32. var REACT_BLOCK_TYPE = 0xead9;
  33. var REACT_SERVER_BLOCK_TYPE = 0xeada;
  34. var REACT_FUNDAMENTAL_TYPE = 0xead5;
  35. var REACT_SCOPE_TYPE = 0xead7;
  36. var REACT_OPAQUE_ID_TYPE = 0xeae0;
  37. var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
  38. var REACT_OFFSCREEN_TYPE = 0xeae2;
  39. var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
  40. if (typeof Symbol === 'function' && Symbol.for) {
  41. var symbolFor = Symbol.for;
  42. REACT_ELEMENT_TYPE = symbolFor('react.element');
  43. REACT_PORTAL_TYPE = symbolFor('react.portal');
  44. exports.Fragment = symbolFor('react.fragment');
  45. REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
  46. REACT_PROFILER_TYPE = symbolFor('react.profiler');
  47. REACT_PROVIDER_TYPE = symbolFor('react.provider');
  48. REACT_CONTEXT_TYPE = symbolFor('react.context');
  49. REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
  50. REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
  51. REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
  52. REACT_MEMO_TYPE = symbolFor('react.memo');
  53. REACT_LAZY_TYPE = symbolFor('react.lazy');
  54. REACT_BLOCK_TYPE = symbolFor('react.block');
  55. REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
  56. REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
  57. REACT_SCOPE_TYPE = symbolFor('react.scope');
  58. REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
  59. REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
  60. REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
  61. REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
  62. }
  63. var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  64. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  65. function getIteratorFn(maybeIterable) {
  66. if (maybeIterable === null || typeof maybeIterable !== 'object') {
  67. return null;
  68. }
  69. var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
  70. if (typeof maybeIterator === 'function') {
  71. return maybeIterator;
  72. }
  73. return null;
  74. }
  75. var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
  76. function error(format) {
  77. {
  78. for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  79. args[_key2 - 1] = arguments[_key2];
  80. }
  81. printWarning('error', format, args);
  82. }
  83. }
  84. function printWarning(level, format, args) {
  85. // When changing this logic, you might want to also
  86. // update consoleWithStackDev.www.js as well.
  87. {
  88. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  89. var stack = ReactDebugCurrentFrame.getStackAddendum();
  90. if (stack !== '') {
  91. format += '%s';
  92. args = args.concat([stack]);
  93. }
  94. var argsWithFormat = args.map(function (item) {
  95. return '' + item;
  96. }); // Careful: RN currently depends on this prefix
  97. argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
  98. // breaks IE9: https://github.com/facebook/react/issues/13610
  99. // eslint-disable-next-line react-internal/no-production-logging
  100. Function.prototype.apply.call(console[level], console, argsWithFormat);
  101. }
  102. }
  103. // Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
  104. var enableScopeAPI = false; // Experimental Create Event Handle API.
  105. function isValidElementType(type) {
  106. if (typeof type === 'string' || typeof type === 'function') {
  107. return true;
  108. } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
  109. 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 ) {
  110. return true;
  111. }
  112. if (typeof type === 'object' && type !== null) {
  113. 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) {
  114. return true;
  115. }
  116. }
  117. return false;
  118. }
  119. function getWrappedName(outerType, innerType, wrapperName) {
  120. var functionName = innerType.displayName || innerType.name || '';
  121. return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
  122. }
  123. function getContextName(type) {
  124. return type.displayName || 'Context';
  125. }
  126. function getComponentName(type) {
  127. if (type == null) {
  128. // Host root, text node or just invalid type.
  129. return null;
  130. }
  131. {
  132. if (typeof type.tag === 'number') {
  133. error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
  134. }
  135. }
  136. if (typeof type === 'function') {
  137. return type.displayName || type.name || null;
  138. }
  139. if (typeof type === 'string') {
  140. return type;
  141. }
  142. switch (type) {
  143. case exports.Fragment:
  144. return 'Fragment';
  145. case REACT_PORTAL_TYPE:
  146. return 'Portal';
  147. case REACT_PROFILER_TYPE:
  148. return 'Profiler';
  149. case REACT_STRICT_MODE_TYPE:
  150. return 'StrictMode';
  151. case REACT_SUSPENSE_TYPE:
  152. return 'Suspense';
  153. case REACT_SUSPENSE_LIST_TYPE:
  154. return 'SuspenseList';
  155. }
  156. if (typeof type === 'object') {
  157. switch (type.$$typeof) {
  158. case REACT_CONTEXT_TYPE:
  159. var context = type;
  160. return getContextName(context) + '.Consumer';
  161. case REACT_PROVIDER_TYPE:
  162. var provider = type;
  163. return getContextName(provider._context) + '.Provider';
  164. case REACT_FORWARD_REF_TYPE:
  165. return getWrappedName(type, type.render, 'ForwardRef');
  166. case REACT_MEMO_TYPE:
  167. return getComponentName(type.type);
  168. case REACT_BLOCK_TYPE:
  169. return getComponentName(type._render);
  170. case REACT_LAZY_TYPE:
  171. {
  172. var lazyComponent = type;
  173. var payload = lazyComponent._payload;
  174. var init = lazyComponent._init;
  175. try {
  176. return getComponentName(init(payload));
  177. } catch (x) {
  178. return null;
  179. }
  180. }
  181. }
  182. }
  183. return null;
  184. }
  185. // Helpers to patch console.logs to avoid logging during side-effect free
  186. // replaying on render function. This currently only patches the object
  187. // lazily which won't cover if the log function was extracted eagerly.
  188. // We could also eagerly patch the method.
  189. var disabledDepth = 0;
  190. var prevLog;
  191. var prevInfo;
  192. var prevWarn;
  193. var prevError;
  194. var prevGroup;
  195. var prevGroupCollapsed;
  196. var prevGroupEnd;
  197. function disabledLog() {}
  198. disabledLog.__reactDisabledLog = true;
  199. function disableLogs() {
  200. {
  201. if (disabledDepth === 0) {
  202. /* eslint-disable react-internal/no-production-logging */
  203. prevLog = console.log;
  204. prevInfo = console.info;
  205. prevWarn = console.warn;
  206. prevError = console.error;
  207. prevGroup = console.group;
  208. prevGroupCollapsed = console.groupCollapsed;
  209. prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
  210. var props = {
  211. configurable: true,
  212. enumerable: true,
  213. value: disabledLog,
  214. writable: true
  215. }; // $FlowFixMe Flow thinks console is immutable.
  216. Object.defineProperties(console, {
  217. info: props,
  218. log: props,
  219. warn: props,
  220. error: props,
  221. group: props,
  222. groupCollapsed: props,
  223. groupEnd: props
  224. });
  225. /* eslint-enable react-internal/no-production-logging */
  226. }
  227. disabledDepth++;
  228. }
  229. }
  230. function reenableLogs() {
  231. {
  232. disabledDepth--;
  233. if (disabledDepth === 0) {
  234. /* eslint-disable react-internal/no-production-logging */
  235. var props = {
  236. configurable: true,
  237. enumerable: true,
  238. writable: true
  239. }; // $FlowFixMe Flow thinks console is immutable.
  240. Object.defineProperties(console, {
  241. log: _assign({}, props, {
  242. value: prevLog
  243. }),
  244. info: _assign({}, props, {
  245. value: prevInfo
  246. }),
  247. warn: _assign({}, props, {
  248. value: prevWarn
  249. }),
  250. error: _assign({}, props, {
  251. value: prevError
  252. }),
  253. group: _assign({}, props, {
  254. value: prevGroup
  255. }),
  256. groupCollapsed: _assign({}, props, {
  257. value: prevGroupCollapsed
  258. }),
  259. groupEnd: _assign({}, props, {
  260. value: prevGroupEnd
  261. })
  262. });
  263. /* eslint-enable react-internal/no-production-logging */
  264. }
  265. if (disabledDepth < 0) {
  266. error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
  267. }
  268. }
  269. }
  270. var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
  271. var prefix;
  272. function describeBuiltInComponentFrame(name, source, ownerFn) {
  273. {
  274. if (prefix === undefined) {
  275. // Extract the VM specific prefix used by each line.
  276. try {
  277. throw Error();
  278. } catch (x) {
  279. var match = x.stack.trim().match(/\n( *(at )?)/);
  280. prefix = match && match[1] || '';
  281. }
  282. } // We use the prefix to ensure our stacks line up with native stack frames.
  283. return '\n' + prefix + name;
  284. }
  285. }
  286. var reentry = false;
  287. var componentFrameCache;
  288. {
  289. var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
  290. componentFrameCache = new PossiblyWeakMap();
  291. }
  292. function describeNativeComponentFrame(fn, construct) {
  293. // If something asked for a stack inside a fake render, it should get ignored.
  294. if (!fn || reentry) {
  295. return '';
  296. }
  297. {
  298. var frame = componentFrameCache.get(fn);
  299. if (frame !== undefined) {
  300. return frame;
  301. }
  302. }
  303. var control;
  304. reentry = true;
  305. var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
  306. Error.prepareStackTrace = undefined;
  307. var previousDispatcher;
  308. {
  309. previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function
  310. // for warnings.
  311. ReactCurrentDispatcher.current = null;
  312. disableLogs();
  313. }
  314. try {
  315. // This should throw.
  316. if (construct) {
  317. // Something should be setting the props in the constructor.
  318. var Fake = function () {
  319. throw Error();
  320. }; // $FlowFixMe
  321. Object.defineProperty(Fake.prototype, 'props', {
  322. set: function () {
  323. // We use a throwing setter instead of frozen or non-writable props
  324. // because that won't throw in a non-strict mode function.
  325. throw Error();
  326. }
  327. });
  328. if (typeof Reflect === 'object' && Reflect.construct) {
  329. // We construct a different control for this case to include any extra
  330. // frames added by the construct call.
  331. try {
  332. Reflect.construct(Fake, []);
  333. } catch (x) {
  334. control = x;
  335. }
  336. Reflect.construct(fn, [], Fake);
  337. } else {
  338. try {
  339. Fake.call();
  340. } catch (x) {
  341. control = x;
  342. }
  343. fn.call(Fake.prototype);
  344. }
  345. } else {
  346. try {
  347. throw Error();
  348. } catch (x) {
  349. control = x;
  350. }
  351. fn();
  352. }
  353. } catch (sample) {
  354. // This is inlined manually because closure doesn't do it for us.
  355. if (sample && control && typeof sample.stack === 'string') {
  356. // This extracts the first frame from the sample that isn't also in the control.
  357. // Skipping one frame that we assume is the frame that calls the two.
  358. var sampleLines = sample.stack.split('\n');
  359. var controlLines = control.stack.split('\n');
  360. var s = sampleLines.length - 1;
  361. var c = controlLines.length - 1;
  362. while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
  363. // We expect at least one stack frame to be shared.
  364. // Typically this will be the root most one. However, stack frames may be
  365. // cut off due to maximum stack limits. In this case, one maybe cut off
  366. // earlier than the other. We assume that the sample is longer or the same
  367. // and there for cut off earlier. So we should find the root most frame in
  368. // the sample somewhere in the control.
  369. c--;
  370. }
  371. for (; s >= 1 && c >= 0; s--, c--) {
  372. // Next we find the first one that isn't the same which should be the
  373. // frame that called our sample function and the control.
  374. if (sampleLines[s] !== controlLines[c]) {
  375. // In V8, the first line is describing the message but other VMs don't.
  376. // If we're about to return the first line, and the control is also on the same
  377. // line, that's a pretty good indicator that our sample threw at same line as
  378. // the control. I.e. before we entered the sample frame. So we ignore this result.
  379. // This can happen if you passed a class to function component, or non-function.
  380. if (s !== 1 || c !== 1) {
  381. do {
  382. s--;
  383. c--; // We may still have similar intermediate frames from the construct call.
  384. // The next one that isn't the same should be our match though.
  385. if (c < 0 || sampleLines[s] !== controlLines[c]) {
  386. // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
  387. var _frame = '\n' + sampleLines[s].replace(' at new ', ' at ');
  388. {
  389. if (typeof fn === 'function') {
  390. componentFrameCache.set(fn, _frame);
  391. }
  392. } // Return the line we found.
  393. return _frame;
  394. }
  395. } while (s >= 1 && c >= 0);
  396. }
  397. break;
  398. }
  399. }
  400. }
  401. } finally {
  402. reentry = false;
  403. {
  404. ReactCurrentDispatcher.current = previousDispatcher;
  405. reenableLogs();
  406. }
  407. Error.prepareStackTrace = previousPrepareStackTrace;
  408. } // Fallback to just using the name if we couldn't make it throw.
  409. var name = fn ? fn.displayName || fn.name : '';
  410. var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
  411. {
  412. if (typeof fn === 'function') {
  413. componentFrameCache.set(fn, syntheticFrame);
  414. }
  415. }
  416. return syntheticFrame;
  417. }
  418. function describeFunctionComponentFrame(fn, source, ownerFn) {
  419. {
  420. return describeNativeComponentFrame(fn, false);
  421. }
  422. }
  423. function shouldConstruct(Component) {
  424. var prototype = Component.prototype;
  425. return !!(prototype && prototype.isReactComponent);
  426. }
  427. function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
  428. if (type == null) {
  429. return '';
  430. }
  431. if (typeof type === 'function') {
  432. {
  433. return describeNativeComponentFrame(type, shouldConstruct(type));
  434. }
  435. }
  436. if (typeof type === 'string') {
  437. return describeBuiltInComponentFrame(type);
  438. }
  439. switch (type) {
  440. case REACT_SUSPENSE_TYPE:
  441. return describeBuiltInComponentFrame('Suspense');
  442. case REACT_SUSPENSE_LIST_TYPE:
  443. return describeBuiltInComponentFrame('SuspenseList');
  444. }
  445. if (typeof type === 'object') {
  446. switch (type.$$typeof) {
  447. case REACT_FORWARD_REF_TYPE:
  448. return describeFunctionComponentFrame(type.render);
  449. case REACT_MEMO_TYPE:
  450. // Memo may contain any component type so we recursively resolve it.
  451. return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
  452. case REACT_BLOCK_TYPE:
  453. return describeFunctionComponentFrame(type._render);
  454. case REACT_LAZY_TYPE:
  455. {
  456. var lazyComponent = type;
  457. var payload = lazyComponent._payload;
  458. var init = lazyComponent._init;
  459. try {
  460. // Lazy may contain any component type so we recursively resolve it.
  461. return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
  462. } catch (x) {}
  463. }
  464. }
  465. }
  466. return '';
  467. }
  468. var loggedTypeFailures = {};
  469. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  470. function setCurrentlyValidatingElement(element) {
  471. {
  472. if (element) {
  473. var owner = element._owner;
  474. var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
  475. ReactDebugCurrentFrame.setExtraStackFrame(stack);
  476. } else {
  477. ReactDebugCurrentFrame.setExtraStackFrame(null);
  478. }
  479. }
  480. }
  481. function checkPropTypes(typeSpecs, values, location, componentName, element) {
  482. {
  483. // $FlowFixMe This is okay but Flow doesn't know it.
  484. var has = Function.call.bind(Object.prototype.hasOwnProperty);
  485. for (var typeSpecName in typeSpecs) {
  486. if (has(typeSpecs, typeSpecName)) {
  487. var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
  488. // fail the render phase where it didn't fail before. So we log it.
  489. // After these have been cleaned up, we'll let them throw.
  490. try {
  491. // This is intentionally an invariant that gets caught. It's the same
  492. // behavior as without this statement except with a better message.
  493. if (typeof typeSpecs[typeSpecName] !== 'function') {
  494. 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`.');
  495. err.name = 'Invariant Violation';
  496. throw err;
  497. }
  498. error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
  499. } catch (ex) {
  500. error$1 = ex;
  501. }
  502. if (error$1 && !(error$1 instanceof Error)) {
  503. setCurrentlyValidatingElement(element);
  504. 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);
  505. setCurrentlyValidatingElement(null);
  506. }
  507. if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
  508. // Only monitor this failure once because there tends to be a lot of the
  509. // same error.
  510. loggedTypeFailures[error$1.message] = true;
  511. setCurrentlyValidatingElement(element);
  512. error('Failed %s type: %s', location, error$1.message);
  513. setCurrentlyValidatingElement(null);
  514. }
  515. }
  516. }
  517. }
  518. }
  519. var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
  520. var hasOwnProperty = Object.prototype.hasOwnProperty;
  521. var RESERVED_PROPS = {
  522. key: true,
  523. ref: true,
  524. __self: true,
  525. __source: true
  526. };
  527. var specialPropKeyWarningShown;
  528. var specialPropRefWarningShown;
  529. var didWarnAboutStringRefs;
  530. {
  531. didWarnAboutStringRefs = {};
  532. }
  533. function hasValidRef(config) {
  534. {
  535. if (hasOwnProperty.call(config, 'ref')) {
  536. var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
  537. if (getter && getter.isReactWarning) {
  538. return false;
  539. }
  540. }
  541. }
  542. return config.ref !== undefined;
  543. }
  544. function hasValidKey(config) {
  545. {
  546. if (hasOwnProperty.call(config, 'key')) {
  547. var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
  548. if (getter && getter.isReactWarning) {
  549. return false;
  550. }
  551. }
  552. }
  553. return config.key !== undefined;
  554. }
  555. function warnIfStringRefCannotBeAutoConverted(config, self) {
  556. {
  557. if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
  558. var componentName = getComponentName(ReactCurrentOwner.current.type);
  559. if (!didWarnAboutStringRefs[componentName]) {
  560. 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);
  561. didWarnAboutStringRefs[componentName] = true;
  562. }
  563. }
  564. }
  565. }
  566. function defineKeyPropWarningGetter(props, displayName) {
  567. {
  568. var warnAboutAccessingKey = function () {
  569. if (!specialPropKeyWarningShown) {
  570. specialPropKeyWarningShown = true;
  571. 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);
  572. }
  573. };
  574. warnAboutAccessingKey.isReactWarning = true;
  575. Object.defineProperty(props, 'key', {
  576. get: warnAboutAccessingKey,
  577. configurable: true
  578. });
  579. }
  580. }
  581. function defineRefPropWarningGetter(props, displayName) {
  582. {
  583. var warnAboutAccessingRef = function () {
  584. if (!specialPropRefWarningShown) {
  585. specialPropRefWarningShown = true;
  586. 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);
  587. }
  588. };
  589. warnAboutAccessingRef.isReactWarning = true;
  590. Object.defineProperty(props, 'ref', {
  591. get: warnAboutAccessingRef,
  592. configurable: true
  593. });
  594. }
  595. }
  596. /**
  597. * Factory method to create a new React element. This no longer adheres to
  598. * the class pattern, so do not use new to call it. Also, instanceof check
  599. * will not work. Instead test $$typeof field against Symbol.for('react.element') to check
  600. * if something is a React Element.
  601. *
  602. * @param {*} type
  603. * @param {*} props
  604. * @param {*} key
  605. * @param {string|object} ref
  606. * @param {*} owner
  607. * @param {*} self A *temporary* helper to detect places where `this` is
  608. * different from the `owner` when React.createElement is called, so that we
  609. * can warn. We want to get rid of owner and replace string `ref`s with arrow
  610. * functions, and as long as `this` and owner are the same, there will be no
  611. * change in behavior.
  612. * @param {*} source An annotation object (added by a transpiler or otherwise)
  613. * indicating filename, line number, and/or other information.
  614. * @internal
  615. */
  616. var ReactElement = function (type, key, ref, self, source, owner, props) {
  617. var element = {
  618. // This tag allows us to uniquely identify this as a React Element
  619. $$typeof: REACT_ELEMENT_TYPE,
  620. // Built-in properties that belong on the element
  621. type: type,
  622. key: key,
  623. ref: ref,
  624. props: props,
  625. // Record the component responsible for creating this element.
  626. _owner: owner
  627. };
  628. {
  629. // The validation flag is currently mutative. We put it on
  630. // an external backing store so that we can freeze the whole object.
  631. // This can be replaced with a WeakMap once they are implemented in
  632. // commonly used development environments.
  633. element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
  634. // the validation flag non-enumerable (where possible, which should
  635. // include every environment we run tests in), so the test framework
  636. // ignores it.
  637. Object.defineProperty(element._store, 'validated', {
  638. configurable: false,
  639. enumerable: false,
  640. writable: true,
  641. value: false
  642. }); // self and source are DEV only properties.
  643. Object.defineProperty(element, '_self', {
  644. configurable: false,
  645. enumerable: false,
  646. writable: false,
  647. value: self
  648. }); // Two elements created in two different places should be considered
  649. // equal for testing purposes and therefore we hide it from enumeration.
  650. Object.defineProperty(element, '_source', {
  651. configurable: false,
  652. enumerable: false,
  653. writable: false,
  654. value: source
  655. });
  656. if (Object.freeze) {
  657. Object.freeze(element.props);
  658. Object.freeze(element);
  659. }
  660. }
  661. return element;
  662. };
  663. /**
  664. * https://github.com/reactjs/rfcs/pull/107
  665. * @param {*} type
  666. * @param {object} props
  667. * @param {string} key
  668. */
  669. function jsxDEV(type, config, maybeKey, source, self) {
  670. {
  671. var propName; // Reserved names are extracted
  672. var props = {};
  673. var key = null;
  674. var ref = null; // Currently, key can be spread in as a prop. This causes a potential
  675. // issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
  676. // or <div key="Hi" {...props} /> ). We want to deprecate key spread,
  677. // but as an intermediary step, we will use jsxDEV for everything except
  678. // <div {...props} key="Hi" />, because we aren't currently able to tell if
  679. // key is explicitly declared to be undefined or not.
  680. if (maybeKey !== undefined) {
  681. key = '' + maybeKey;
  682. }
  683. if (hasValidKey(config)) {
  684. key = '' + config.key;
  685. }
  686. if (hasValidRef(config)) {
  687. ref = config.ref;
  688. warnIfStringRefCannotBeAutoConverted(config, self);
  689. } // Remaining properties are added to a new props object
  690. for (propName in config) {
  691. if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
  692. props[propName] = config[propName];
  693. }
  694. } // Resolve default props
  695. if (type && type.defaultProps) {
  696. var defaultProps = type.defaultProps;
  697. for (propName in defaultProps) {
  698. if (props[propName] === undefined) {
  699. props[propName] = defaultProps[propName];
  700. }
  701. }
  702. }
  703. if (key || ref) {
  704. var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
  705. if (key) {
  706. defineKeyPropWarningGetter(props, displayName);
  707. }
  708. if (ref) {
  709. defineRefPropWarningGetter(props, displayName);
  710. }
  711. }
  712. return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
  713. }
  714. }
  715. var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
  716. var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
  717. function setCurrentlyValidatingElement$1(element) {
  718. {
  719. if (element) {
  720. var owner = element._owner;
  721. var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
  722. ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
  723. } else {
  724. ReactDebugCurrentFrame$1.setExtraStackFrame(null);
  725. }
  726. }
  727. }
  728. var propTypesMisspellWarningShown;
  729. {
  730. propTypesMisspellWarningShown = false;
  731. }
  732. /**
  733. * Verifies the object is a ReactElement.
  734. * See https://reactjs.org/docs/react-api.html#isvalidelement
  735. * @param {?object} object
  736. * @return {boolean} True if `object` is a ReactElement.
  737. * @final
  738. */
  739. function isValidElement(object) {
  740. {
  741. return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
  742. }
  743. }
  744. function getDeclarationErrorAddendum() {
  745. {
  746. if (ReactCurrentOwner$1.current) {
  747. var name = getComponentName(ReactCurrentOwner$1.current.type);
  748. if (name) {
  749. return '\n\nCheck the render method of `' + name + '`.';
  750. }
  751. }
  752. return '';
  753. }
  754. }
  755. function getSourceInfoErrorAddendum(source) {
  756. {
  757. if (source !== undefined) {
  758. var fileName = source.fileName.replace(/^.*[\\\/]/, '');
  759. var lineNumber = source.lineNumber;
  760. return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
  761. }
  762. return '';
  763. }
  764. }
  765. /**
  766. * Warn if there's no key explicitly set on dynamic arrays of children or
  767. * object keys are not valid. This allows us to keep track of children between
  768. * updates.
  769. */
  770. var ownerHasKeyUseWarning = {};
  771. function getCurrentComponentErrorInfo(parentType) {
  772. {
  773. var info = getDeclarationErrorAddendum();
  774. if (!info) {
  775. var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
  776. if (parentName) {
  777. info = "\n\nCheck the top-level render call using <" + parentName + ">.";
  778. }
  779. }
  780. return info;
  781. }
  782. }
  783. /**
  784. * Warn if the element doesn't have an explicit key assigned to it.
  785. * This element is in an array. The array could grow and shrink or be
  786. * reordered. All children that haven't already been validated are required to
  787. * have a "key" property assigned to it. Error statuses are cached so a warning
  788. * will only be shown once.
  789. *
  790. * @internal
  791. * @param {ReactElement} element Element that requires a key.
  792. * @param {*} parentType element's parent's type.
  793. */
  794. function validateExplicitKey(element, parentType) {
  795. {
  796. if (!element._store || element._store.validated || element.key != null) {
  797. return;
  798. }
  799. element._store.validated = true;
  800. var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
  801. if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
  802. return;
  803. }
  804. ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
  805. // property, it may be the creator of the child that's responsible for
  806. // assigning it a key.
  807. var childOwner = '';
  808. if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
  809. // Give the component that originally created this child.
  810. childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
  811. }
  812. setCurrentlyValidatingElement$1(element);
  813. 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);
  814. setCurrentlyValidatingElement$1(null);
  815. }
  816. }
  817. /**
  818. * Ensure that every element either is passed in a static location, in an
  819. * array with an explicit keys property defined, or in an object literal
  820. * with valid key property.
  821. *
  822. * @internal
  823. * @param {ReactNode} node Statically passed child of any type.
  824. * @param {*} parentType node's parent's type.
  825. */
  826. function validateChildKeys(node, parentType) {
  827. {
  828. if (typeof node !== 'object') {
  829. return;
  830. }
  831. if (Array.isArray(node)) {
  832. for (var i = 0; i < node.length; i++) {
  833. var child = node[i];
  834. if (isValidElement(child)) {
  835. validateExplicitKey(child, parentType);
  836. }
  837. }
  838. } else if (isValidElement(node)) {
  839. // This element was passed in a valid location.
  840. if (node._store) {
  841. node._store.validated = true;
  842. }
  843. } else if (node) {
  844. var iteratorFn = getIteratorFn(node);
  845. if (typeof iteratorFn === 'function') {
  846. // Entry iterators used to provide implicit keys,
  847. // but now we print a separate warning for them later.
  848. if (iteratorFn !== node.entries) {
  849. var iterator = iteratorFn.call(node);
  850. var step;
  851. while (!(step = iterator.next()).done) {
  852. if (isValidElement(step.value)) {
  853. validateExplicitKey(step.value, parentType);
  854. }
  855. }
  856. }
  857. }
  858. }
  859. }
  860. }
  861. /**
  862. * Given an element, validate that its props follow the propTypes definition,
  863. * provided by the type.
  864. *
  865. * @param {ReactElement} element
  866. */
  867. function validatePropTypes(element) {
  868. {
  869. var type = element.type;
  870. if (type === null || type === undefined || typeof type === 'string') {
  871. return;
  872. }
  873. var propTypes;
  874. if (typeof type === 'function') {
  875. propTypes = type.propTypes;
  876. } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
  877. // Inner props are checked in the reconciler.
  878. type.$$typeof === REACT_MEMO_TYPE)) {
  879. propTypes = type.propTypes;
  880. } else {
  881. return;
  882. }
  883. if (propTypes) {
  884. // Intentionally inside to avoid triggering lazy initializers:
  885. var name = getComponentName(type);
  886. checkPropTypes(propTypes, element.props, 'prop', name, element);
  887. } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
  888. propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
  889. var _name = getComponentName(type);
  890. error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
  891. }
  892. if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
  893. error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
  894. }
  895. }
  896. }
  897. /**
  898. * Given a fragment, validate that it can only be provided with fragment props
  899. * @param {ReactElement} fragment
  900. */
  901. function validateFragmentProps(fragment) {
  902. {
  903. var keys = Object.keys(fragment.props);
  904. for (var i = 0; i < keys.length; i++) {
  905. var key = keys[i];
  906. if (key !== 'children' && key !== 'key') {
  907. setCurrentlyValidatingElement$1(fragment);
  908. error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
  909. setCurrentlyValidatingElement$1(null);
  910. break;
  911. }
  912. }
  913. if (fragment.ref !== null) {
  914. setCurrentlyValidatingElement$1(fragment);
  915. error('Invalid attribute `ref` supplied to `React.Fragment`.');
  916. setCurrentlyValidatingElement$1(null);
  917. }
  918. }
  919. }
  920. function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
  921. {
  922. var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
  923. // succeed and there will likely be errors in render.
  924. if (!validType) {
  925. var info = '';
  926. if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
  927. 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.";
  928. }
  929. var sourceInfo = getSourceInfoErrorAddendum(source);
  930. if (sourceInfo) {
  931. info += sourceInfo;
  932. } else {
  933. info += getDeclarationErrorAddendum();
  934. }
  935. var typeString;
  936. if (type === null) {
  937. typeString = 'null';
  938. } else if (Array.isArray(type)) {
  939. typeString = 'array';
  940. } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
  941. typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
  942. info = ' Did you accidentally export a JSX literal instead of a component?';
  943. } else {
  944. typeString = typeof type;
  945. }
  946. 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);
  947. }
  948. var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
  949. // TODO: Drop this when these are no longer allowed as the type argument.
  950. if (element == null) {
  951. return element;
  952. } // Skip key warning if the type isn't valid since our key validation logic
  953. // doesn't expect a non-string/function type and can throw confusing errors.
  954. // We don't want exception behavior to differ between dev and prod.
  955. // (Rendering will throw with a helpful message and as soon as the type is
  956. // fixed, the key warnings will appear.)
  957. if (validType) {
  958. var children = props.children;
  959. if (children !== undefined) {
  960. if (isStaticChildren) {
  961. if (Array.isArray(children)) {
  962. for (var i = 0; i < children.length; i++) {
  963. validateChildKeys(children[i], type);
  964. }
  965. if (Object.freeze) {
  966. Object.freeze(children);
  967. }
  968. } else {
  969. 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.');
  970. }
  971. } else {
  972. validateChildKeys(children, type);
  973. }
  974. }
  975. }
  976. if (type === exports.Fragment) {
  977. validateFragmentProps(element);
  978. } else {
  979. validatePropTypes(element);
  980. }
  981. return element;
  982. }
  983. } // These two functions exist to still get child warnings in dev
  984. var jsxDEV$1 = jsxWithValidation ;
  985. exports.jsxDEV = jsxDEV$1;
  986. })();
  987. }