react.development.js 70 KB

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