react-router.js 101 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
  3. typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
  4. (global = global || self, factory(global.ReactRouter = {}, global.React));
  5. }(this, function (exports, React) { 'use strict';
  6. var React__default = 'default' in React ? React['default'] : React;
  7. function _inheritsLoose(subClass, superClass) {
  8. subClass.prototype = Object.create(superClass.prototype);
  9. subClass.prototype.constructor = subClass;
  10. subClass.__proto__ = superClass;
  11. }
  12. function unwrapExports (x) {
  13. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  14. }
  15. function createCommonjsModule(fn, module) {
  16. return module = { exports: {} }, fn(module, module.exports), module.exports;
  17. }
  18. var reactIs_production_min = createCommonjsModule(function (module, exports) {
  19. Object.defineProperty(exports,"__esModule",{value:!0});
  20. var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?Symbol.for("react.suspense_list"):
  21. 60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.fundamental"):60117,w=b?Symbol.for("react.responder"):60118;function x(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case h:return a;default:return u}}case t:case r:case d:return u}}}function y(a){return x(a)===m}exports.typeOf=x;exports.AsyncMode=l;
  22. exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;exports.Fragment=e;exports.Lazy=t;exports.Memo=r;exports.Portal=d;exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;
  23. exports.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===v||a.$$typeof===w)};exports.isAsyncMode=function(a){return y(a)||x(a)===l};exports.isConcurrentMode=y;exports.isContextConsumer=function(a){return x(a)===k};exports.isContextProvider=function(a){return x(a)===h};
  24. exports.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return x(a)===n};exports.isFragment=function(a){return x(a)===e};exports.isLazy=function(a){return x(a)===t};exports.isMemo=function(a){return x(a)===r};exports.isPortal=function(a){return x(a)===d};exports.isProfiler=function(a){return x(a)===g};exports.isStrictMode=function(a){return x(a)===f};exports.isSuspense=function(a){return x(a)===p};
  25. });
  26. unwrapExports(reactIs_production_min);
  27. var reactIs_production_min_1 = reactIs_production_min.typeOf;
  28. var reactIs_production_min_2 = reactIs_production_min.AsyncMode;
  29. var reactIs_production_min_3 = reactIs_production_min.ConcurrentMode;
  30. var reactIs_production_min_4 = reactIs_production_min.ContextConsumer;
  31. var reactIs_production_min_5 = reactIs_production_min.ContextProvider;
  32. var reactIs_production_min_6 = reactIs_production_min.Element;
  33. var reactIs_production_min_7 = reactIs_production_min.ForwardRef;
  34. var reactIs_production_min_8 = reactIs_production_min.Fragment;
  35. var reactIs_production_min_9 = reactIs_production_min.Lazy;
  36. var reactIs_production_min_10 = reactIs_production_min.Memo;
  37. var reactIs_production_min_11 = reactIs_production_min.Portal;
  38. var reactIs_production_min_12 = reactIs_production_min.Profiler;
  39. var reactIs_production_min_13 = reactIs_production_min.StrictMode;
  40. var reactIs_production_min_14 = reactIs_production_min.Suspense;
  41. var reactIs_production_min_15 = reactIs_production_min.isValidElementType;
  42. var reactIs_production_min_16 = reactIs_production_min.isAsyncMode;
  43. var reactIs_production_min_17 = reactIs_production_min.isConcurrentMode;
  44. var reactIs_production_min_18 = reactIs_production_min.isContextConsumer;
  45. var reactIs_production_min_19 = reactIs_production_min.isContextProvider;
  46. var reactIs_production_min_20 = reactIs_production_min.isElement;
  47. var reactIs_production_min_21 = reactIs_production_min.isForwardRef;
  48. var reactIs_production_min_22 = reactIs_production_min.isFragment;
  49. var reactIs_production_min_23 = reactIs_production_min.isLazy;
  50. var reactIs_production_min_24 = reactIs_production_min.isMemo;
  51. var reactIs_production_min_25 = reactIs_production_min.isPortal;
  52. var reactIs_production_min_26 = reactIs_production_min.isProfiler;
  53. var reactIs_production_min_27 = reactIs_production_min.isStrictMode;
  54. var reactIs_production_min_28 = reactIs_production_min.isSuspense;
  55. var reactIs_development = createCommonjsModule(function (module, exports) {
  56. {
  57. (function() {
  58. Object.defineProperty(exports, '__esModule', { value: true });
  59. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  60. // nor polyfill, then a plain number is used for performance.
  61. var hasSymbol = typeof Symbol === 'function' && Symbol.for;
  62. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
  63. var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
  64. var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
  65. var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
  66. var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
  67. var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
  68. var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
  69. // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
  70. // (unstable) APIs that have been removed. Can we remove the symbols?
  71. var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
  72. var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
  73. var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
  74. var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
  75. var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
  76. var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
  77. var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
  78. var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
  79. var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
  80. function isValidElementType(type) {
  81. return typeof type === 'string' || typeof type === 'function' ||
  82. // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
  83. type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE);
  84. }
  85. /**
  86. * Forked from fbjs/warning:
  87. * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
  88. *
  89. * Only change is we use console.warn instead of console.error,
  90. * and do nothing when 'console' is not supported.
  91. * This really simplifies the code.
  92. * ---
  93. * Similar to invariant but only logs a warning if the condition is not met.
  94. * This can be used to log issues in development environments in critical
  95. * paths. Removing the logging code for production environments will keep the
  96. * same logic and follow the same code paths.
  97. */
  98. var lowPriorityWarning = function () {};
  99. {
  100. var printWarning = function (format) {
  101. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  102. args[_key - 1] = arguments[_key];
  103. }
  104. var argIndex = 0;
  105. var message = 'Warning: ' + format.replace(/%s/g, function () {
  106. return args[argIndex++];
  107. });
  108. if (typeof console !== 'undefined') {
  109. console.warn(message);
  110. }
  111. try {
  112. // --- Welcome to debugging React ---
  113. // This error was thrown as a convenience so that you can use this stack
  114. // to find the callsite that caused this warning to fire.
  115. throw new Error(message);
  116. } catch (x) {}
  117. };
  118. lowPriorityWarning = function (condition, format) {
  119. if (format === undefined) {
  120. throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
  121. }
  122. if (!condition) {
  123. for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  124. args[_key2 - 2] = arguments[_key2];
  125. }
  126. printWarning.apply(undefined, [format].concat(args));
  127. }
  128. };
  129. }
  130. var lowPriorityWarning$1 = lowPriorityWarning;
  131. function typeOf(object) {
  132. if (typeof object === 'object' && object !== null) {
  133. var $$typeof = object.$$typeof;
  134. switch ($$typeof) {
  135. case REACT_ELEMENT_TYPE:
  136. var type = object.type;
  137. switch (type) {
  138. case REACT_ASYNC_MODE_TYPE:
  139. case REACT_CONCURRENT_MODE_TYPE:
  140. case REACT_FRAGMENT_TYPE:
  141. case REACT_PROFILER_TYPE:
  142. case REACT_STRICT_MODE_TYPE:
  143. case REACT_SUSPENSE_TYPE:
  144. return type;
  145. default:
  146. var $$typeofType = type && type.$$typeof;
  147. switch ($$typeofType) {
  148. case REACT_CONTEXT_TYPE:
  149. case REACT_FORWARD_REF_TYPE:
  150. case REACT_PROVIDER_TYPE:
  151. return $$typeofType;
  152. default:
  153. return $$typeof;
  154. }
  155. }
  156. case REACT_LAZY_TYPE:
  157. case REACT_MEMO_TYPE:
  158. case REACT_PORTAL_TYPE:
  159. return $$typeof;
  160. }
  161. }
  162. return undefined;
  163. }
  164. // AsyncMode is deprecated along with isAsyncMode
  165. var AsyncMode = REACT_ASYNC_MODE_TYPE;
  166. var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
  167. var ContextConsumer = REACT_CONTEXT_TYPE;
  168. var ContextProvider = REACT_PROVIDER_TYPE;
  169. var Element = REACT_ELEMENT_TYPE;
  170. var ForwardRef = REACT_FORWARD_REF_TYPE;
  171. var Fragment = REACT_FRAGMENT_TYPE;
  172. var Lazy = REACT_LAZY_TYPE;
  173. var Memo = REACT_MEMO_TYPE;
  174. var Portal = REACT_PORTAL_TYPE;
  175. var Profiler = REACT_PROFILER_TYPE;
  176. var StrictMode = REACT_STRICT_MODE_TYPE;
  177. var Suspense = REACT_SUSPENSE_TYPE;
  178. var hasWarnedAboutDeprecatedIsAsyncMode = false;
  179. // AsyncMode should be deprecated
  180. function isAsyncMode(object) {
  181. {
  182. if (!hasWarnedAboutDeprecatedIsAsyncMode) {
  183. hasWarnedAboutDeprecatedIsAsyncMode = true;
  184. lowPriorityWarning$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
  185. }
  186. }
  187. return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
  188. }
  189. function isConcurrentMode(object) {
  190. return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
  191. }
  192. function isContextConsumer(object) {
  193. return typeOf(object) === REACT_CONTEXT_TYPE;
  194. }
  195. function isContextProvider(object) {
  196. return typeOf(object) === REACT_PROVIDER_TYPE;
  197. }
  198. function isElement(object) {
  199. return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
  200. }
  201. function isForwardRef(object) {
  202. return typeOf(object) === REACT_FORWARD_REF_TYPE;
  203. }
  204. function isFragment(object) {
  205. return typeOf(object) === REACT_FRAGMENT_TYPE;
  206. }
  207. function isLazy(object) {
  208. return typeOf(object) === REACT_LAZY_TYPE;
  209. }
  210. function isMemo(object) {
  211. return typeOf(object) === REACT_MEMO_TYPE;
  212. }
  213. function isPortal(object) {
  214. return typeOf(object) === REACT_PORTAL_TYPE;
  215. }
  216. function isProfiler(object) {
  217. return typeOf(object) === REACT_PROFILER_TYPE;
  218. }
  219. function isStrictMode(object) {
  220. return typeOf(object) === REACT_STRICT_MODE_TYPE;
  221. }
  222. function isSuspense(object) {
  223. return typeOf(object) === REACT_SUSPENSE_TYPE;
  224. }
  225. exports.typeOf = typeOf;
  226. exports.AsyncMode = AsyncMode;
  227. exports.ConcurrentMode = ConcurrentMode;
  228. exports.ContextConsumer = ContextConsumer;
  229. exports.ContextProvider = ContextProvider;
  230. exports.Element = Element;
  231. exports.ForwardRef = ForwardRef;
  232. exports.Fragment = Fragment;
  233. exports.Lazy = Lazy;
  234. exports.Memo = Memo;
  235. exports.Portal = Portal;
  236. exports.Profiler = Profiler;
  237. exports.StrictMode = StrictMode;
  238. exports.Suspense = Suspense;
  239. exports.isValidElementType = isValidElementType;
  240. exports.isAsyncMode = isAsyncMode;
  241. exports.isConcurrentMode = isConcurrentMode;
  242. exports.isContextConsumer = isContextConsumer;
  243. exports.isContextProvider = isContextProvider;
  244. exports.isElement = isElement;
  245. exports.isForwardRef = isForwardRef;
  246. exports.isFragment = isFragment;
  247. exports.isLazy = isLazy;
  248. exports.isMemo = isMemo;
  249. exports.isPortal = isPortal;
  250. exports.isProfiler = isProfiler;
  251. exports.isStrictMode = isStrictMode;
  252. exports.isSuspense = isSuspense;
  253. })();
  254. }
  255. });
  256. unwrapExports(reactIs_development);
  257. var reactIs_development_1 = reactIs_development.typeOf;
  258. var reactIs_development_2 = reactIs_development.AsyncMode;
  259. var reactIs_development_3 = reactIs_development.ConcurrentMode;
  260. var reactIs_development_4 = reactIs_development.ContextConsumer;
  261. var reactIs_development_5 = reactIs_development.ContextProvider;
  262. var reactIs_development_6 = reactIs_development.Element;
  263. var reactIs_development_7 = reactIs_development.ForwardRef;
  264. var reactIs_development_8 = reactIs_development.Fragment;
  265. var reactIs_development_9 = reactIs_development.Lazy;
  266. var reactIs_development_10 = reactIs_development.Memo;
  267. var reactIs_development_11 = reactIs_development.Portal;
  268. var reactIs_development_12 = reactIs_development.Profiler;
  269. var reactIs_development_13 = reactIs_development.StrictMode;
  270. var reactIs_development_14 = reactIs_development.Suspense;
  271. var reactIs_development_15 = reactIs_development.isValidElementType;
  272. var reactIs_development_16 = reactIs_development.isAsyncMode;
  273. var reactIs_development_17 = reactIs_development.isConcurrentMode;
  274. var reactIs_development_18 = reactIs_development.isContextConsumer;
  275. var reactIs_development_19 = reactIs_development.isContextProvider;
  276. var reactIs_development_20 = reactIs_development.isElement;
  277. var reactIs_development_21 = reactIs_development.isForwardRef;
  278. var reactIs_development_22 = reactIs_development.isFragment;
  279. var reactIs_development_23 = reactIs_development.isLazy;
  280. var reactIs_development_24 = reactIs_development.isMemo;
  281. var reactIs_development_25 = reactIs_development.isPortal;
  282. var reactIs_development_26 = reactIs_development.isProfiler;
  283. var reactIs_development_27 = reactIs_development.isStrictMode;
  284. var reactIs_development_28 = reactIs_development.isSuspense;
  285. var reactIs = createCommonjsModule(function (module) {
  286. {
  287. module.exports = reactIs_development;
  288. }
  289. });
  290. var reactIs_1 = reactIs.isValidElementType;
  291. /*
  292. object-assign
  293. (c) Sindre Sorhus
  294. @license MIT
  295. */
  296. /* eslint-disable no-unused-vars */
  297. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  298. var hasOwnProperty = Object.prototype.hasOwnProperty;
  299. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  300. function toObject(val) {
  301. if (val === null || val === undefined) {
  302. throw new TypeError('Object.assign cannot be called with null or undefined');
  303. }
  304. return Object(val);
  305. }
  306. function shouldUseNative() {
  307. try {
  308. if (!Object.assign) {
  309. return false;
  310. }
  311. // Detect buggy property enumeration order in older V8 versions.
  312. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  313. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  314. test1[5] = 'de';
  315. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  316. return false;
  317. }
  318. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  319. var test2 = {};
  320. for (var i = 0; i < 10; i++) {
  321. test2['_' + String.fromCharCode(i)] = i;
  322. }
  323. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  324. return test2[n];
  325. });
  326. if (order2.join('') !== '0123456789') {
  327. return false;
  328. }
  329. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  330. var test3 = {};
  331. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  332. test3[letter] = letter;
  333. });
  334. if (Object.keys(Object.assign({}, test3)).join('') !==
  335. 'abcdefghijklmnopqrst') {
  336. return false;
  337. }
  338. return true;
  339. } catch (err) {
  340. // We don't expect any of the above to throw, but better to be safe.
  341. return false;
  342. }
  343. }
  344. var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
  345. var from;
  346. var to = toObject(target);
  347. var symbols;
  348. for (var s = 1; s < arguments.length; s++) {
  349. from = Object(arguments[s]);
  350. for (var key in from) {
  351. if (hasOwnProperty.call(from, key)) {
  352. to[key] = from[key];
  353. }
  354. }
  355. if (getOwnPropertySymbols) {
  356. symbols = getOwnPropertySymbols(from);
  357. for (var i = 0; i < symbols.length; i++) {
  358. if (propIsEnumerable.call(from, symbols[i])) {
  359. to[symbols[i]] = from[symbols[i]];
  360. }
  361. }
  362. }
  363. }
  364. return to;
  365. };
  366. /**
  367. * Copyright (c) 2013-present, Facebook, Inc.
  368. *
  369. * This source code is licensed under the MIT license found in the
  370. * LICENSE file in the root directory of this source tree.
  371. */
  372. var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  373. var ReactPropTypesSecret_1 = ReactPropTypesSecret;
  374. var printWarning = function() {};
  375. {
  376. var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
  377. var loggedTypeFailures = {};
  378. var has = Function.call.bind(Object.prototype.hasOwnProperty);
  379. printWarning = function(text) {
  380. var message = 'Warning: ' + text;
  381. if (typeof console !== 'undefined') {
  382. console.error(message);
  383. }
  384. try {
  385. // --- Welcome to debugging React ---
  386. // This error was thrown as a convenience so that you can use this stack
  387. // to find the callsite that caused this warning to fire.
  388. throw new Error(message);
  389. } catch (x) {}
  390. };
  391. }
  392. /**
  393. * Assert that the values match with the type specs.
  394. * Error messages are memorized and will only be shown once.
  395. *
  396. * @param {object} typeSpecs Map of name to a ReactPropType
  397. * @param {object} values Runtime values that need to be type-checked
  398. * @param {string} location e.g. "prop", "context", "child context"
  399. * @param {string} componentName Name of the component for error messages.
  400. * @param {?Function} getStack Returns the component stack.
  401. * @private
  402. */
  403. function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
  404. {
  405. for (var typeSpecName in typeSpecs) {
  406. if (has(typeSpecs, typeSpecName)) {
  407. var error;
  408. // Prop type validation may throw. In case they do, we don't want to
  409. // fail the render phase where it didn't fail before. So we log it.
  410. // After these have been cleaned up, we'll let them throw.
  411. try {
  412. // This is intentionally an invariant that gets caught. It's the same
  413. // behavior as without this statement except with a better message.
  414. if (typeof typeSpecs[typeSpecName] !== 'function') {
  415. var err = Error(
  416. (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
  417. 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
  418. );
  419. err.name = 'Invariant Violation';
  420. throw err;
  421. }
  422. error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
  423. } catch (ex) {
  424. error = ex;
  425. }
  426. if (error && !(error instanceof Error)) {
  427. printWarning(
  428. (componentName || 'React class') + ': type specification of ' +
  429. location + ' `' + typeSpecName + '` is invalid; the type checker ' +
  430. 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
  431. 'You may have forgotten to pass an argument to the type checker ' +
  432. 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
  433. 'shape all require an argument).'
  434. );
  435. }
  436. if (error instanceof Error && !(error.message in loggedTypeFailures)) {
  437. // Only monitor this failure once because there tends to be a lot of the
  438. // same error.
  439. loggedTypeFailures[error.message] = true;
  440. var stack = getStack ? getStack() : '';
  441. printWarning(
  442. 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
  443. );
  444. }
  445. }
  446. }
  447. }
  448. }
  449. /**
  450. * Resets warning cache when testing.
  451. *
  452. * @private
  453. */
  454. checkPropTypes.resetWarningCache = function() {
  455. {
  456. loggedTypeFailures = {};
  457. }
  458. };
  459. var checkPropTypes_1 = checkPropTypes;
  460. var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
  461. var printWarning$1 = function() {};
  462. {
  463. printWarning$1 = function(text) {
  464. var message = 'Warning: ' + text;
  465. if (typeof console !== 'undefined') {
  466. console.error(message);
  467. }
  468. try {
  469. // --- Welcome to debugging React ---
  470. // This error was thrown as a convenience so that you can use this stack
  471. // to find the callsite that caused this warning to fire.
  472. throw new Error(message);
  473. } catch (x) {}
  474. };
  475. }
  476. function emptyFunctionThatReturnsNull() {
  477. return null;
  478. }
  479. var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
  480. /* global Symbol */
  481. var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  482. var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
  483. /**
  484. * Returns the iterator method function contained on the iterable object.
  485. *
  486. * Be sure to invoke the function with the iterable as context:
  487. *
  488. * var iteratorFn = getIteratorFn(myIterable);
  489. * if (iteratorFn) {
  490. * var iterator = iteratorFn.call(myIterable);
  491. * ...
  492. * }
  493. *
  494. * @param {?object} maybeIterable
  495. * @return {?function}
  496. */
  497. function getIteratorFn(maybeIterable) {
  498. var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
  499. if (typeof iteratorFn === 'function') {
  500. return iteratorFn;
  501. }
  502. }
  503. /**
  504. * Collection of methods that allow declaration and validation of props that are
  505. * supplied to React components. Example usage:
  506. *
  507. * var Props = require('ReactPropTypes');
  508. * var MyArticle = React.createClass({
  509. * propTypes: {
  510. * // An optional string prop named "description".
  511. * description: Props.string,
  512. *
  513. * // A required enum prop named "category".
  514. * category: Props.oneOf(['News','Photos']).isRequired,
  515. *
  516. * // A prop named "dialog" that requires an instance of Dialog.
  517. * dialog: Props.instanceOf(Dialog).isRequired
  518. * },
  519. * render: function() { ... }
  520. * });
  521. *
  522. * A more formal specification of how these methods are used:
  523. *
  524. * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
  525. * decl := ReactPropTypes.{type}(.isRequired)?
  526. *
  527. * Each and every declaration produces a function with the same signature. This
  528. * allows the creation of custom validation functions. For example:
  529. *
  530. * var MyLink = React.createClass({
  531. * propTypes: {
  532. * // An optional string or URI prop named "href".
  533. * href: function(props, propName, componentName) {
  534. * var propValue = props[propName];
  535. * if (propValue != null && typeof propValue !== 'string' &&
  536. * !(propValue instanceof URI)) {
  537. * return new Error(
  538. * 'Expected a string or an URI for ' + propName + ' in ' +
  539. * componentName
  540. * );
  541. * }
  542. * }
  543. * },
  544. * render: function() {...}
  545. * });
  546. *
  547. * @internal
  548. */
  549. var ANONYMOUS = '<<anonymous>>';
  550. // Important!
  551. // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
  552. var ReactPropTypes = {
  553. array: createPrimitiveTypeChecker('array'),
  554. bool: createPrimitiveTypeChecker('boolean'),
  555. func: createPrimitiveTypeChecker('function'),
  556. number: createPrimitiveTypeChecker('number'),
  557. object: createPrimitiveTypeChecker('object'),
  558. string: createPrimitiveTypeChecker('string'),
  559. symbol: createPrimitiveTypeChecker('symbol'),
  560. any: createAnyTypeChecker(),
  561. arrayOf: createArrayOfTypeChecker,
  562. element: createElementTypeChecker(),
  563. elementType: createElementTypeTypeChecker(),
  564. instanceOf: createInstanceTypeChecker,
  565. node: createNodeChecker(),
  566. objectOf: createObjectOfTypeChecker,
  567. oneOf: createEnumTypeChecker,
  568. oneOfType: createUnionTypeChecker,
  569. shape: createShapeTypeChecker,
  570. exact: createStrictShapeTypeChecker,
  571. };
  572. /**
  573. * inlined Object.is polyfill to avoid requiring consumers ship their own
  574. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  575. */
  576. /*eslint-disable no-self-compare*/
  577. function is(x, y) {
  578. // SameValue algorithm
  579. if (x === y) {
  580. // Steps 1-5, 7-10
  581. // Steps 6.b-6.e: +0 != -0
  582. return x !== 0 || 1 / x === 1 / y;
  583. } else {
  584. // Step 6.a: NaN == NaN
  585. return x !== x && y !== y;
  586. }
  587. }
  588. /*eslint-enable no-self-compare*/
  589. /**
  590. * We use an Error-like object for backward compatibility as people may call
  591. * PropTypes directly and inspect their output. However, we don't use real
  592. * Errors anymore. We don't inspect their stack anyway, and creating them
  593. * is prohibitively expensive if they are created too often, such as what
  594. * happens in oneOfType() for any type before the one that matched.
  595. */
  596. function PropTypeError(message) {
  597. this.message = message;
  598. this.stack = '';
  599. }
  600. // Make `instanceof Error` still work for returned errors.
  601. PropTypeError.prototype = Error.prototype;
  602. function createChainableTypeChecker(validate) {
  603. {
  604. var manualPropTypeCallCache = {};
  605. var manualPropTypeWarningCount = 0;
  606. }
  607. function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
  608. componentName = componentName || ANONYMOUS;
  609. propFullName = propFullName || propName;
  610. if (secret !== ReactPropTypesSecret_1) {
  611. if (throwOnDirectAccess) {
  612. // New behavior only for users of `prop-types` package
  613. var err = new Error(
  614. 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
  615. 'Use `PropTypes.checkPropTypes()` to call them. ' +
  616. 'Read more at http://fb.me/use-check-prop-types'
  617. );
  618. err.name = 'Invariant Violation';
  619. throw err;
  620. } else if ( typeof console !== 'undefined') {
  621. // Old behavior for people using React.PropTypes
  622. var cacheKey = componentName + ':' + propName;
  623. if (
  624. !manualPropTypeCallCache[cacheKey] &&
  625. // Avoid spamming the console because they are often not actionable except for lib authors
  626. manualPropTypeWarningCount < 3
  627. ) {
  628. printWarning$1(
  629. 'You are manually calling a React.PropTypes validation ' +
  630. 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
  631. 'and will throw in the standalone `prop-types` package. ' +
  632. 'You may be seeing this warning due to a third-party PropTypes ' +
  633. 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
  634. );
  635. manualPropTypeCallCache[cacheKey] = true;
  636. manualPropTypeWarningCount++;
  637. }
  638. }
  639. }
  640. if (props[propName] == null) {
  641. if (isRequired) {
  642. if (props[propName] === null) {
  643. return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
  644. }
  645. return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
  646. }
  647. return null;
  648. } else {
  649. return validate(props, propName, componentName, location, propFullName);
  650. }
  651. }
  652. var chainedCheckType = checkType.bind(null, false);
  653. chainedCheckType.isRequired = checkType.bind(null, true);
  654. return chainedCheckType;
  655. }
  656. function createPrimitiveTypeChecker(expectedType) {
  657. function validate(props, propName, componentName, location, propFullName, secret) {
  658. var propValue = props[propName];
  659. var propType = getPropType(propValue);
  660. if (propType !== expectedType) {
  661. // `propValue` being instance of, say, date/regexp, pass the 'object'
  662. // check, but we can offer a more precise error message here rather than
  663. // 'of type `object`'.
  664. var preciseType = getPreciseType(propValue);
  665. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
  666. }
  667. return null;
  668. }
  669. return createChainableTypeChecker(validate);
  670. }
  671. function createAnyTypeChecker() {
  672. return createChainableTypeChecker(emptyFunctionThatReturnsNull);
  673. }
  674. function createArrayOfTypeChecker(typeChecker) {
  675. function validate(props, propName, componentName, location, propFullName) {
  676. if (typeof typeChecker !== 'function') {
  677. return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
  678. }
  679. var propValue = props[propName];
  680. if (!Array.isArray(propValue)) {
  681. var propType = getPropType(propValue);
  682. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
  683. }
  684. for (var i = 0; i < propValue.length; i++) {
  685. var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
  686. if (error instanceof Error) {
  687. return error;
  688. }
  689. }
  690. return null;
  691. }
  692. return createChainableTypeChecker(validate);
  693. }
  694. function createElementTypeChecker() {
  695. function validate(props, propName, componentName, location, propFullName) {
  696. var propValue = props[propName];
  697. if (!isValidElement(propValue)) {
  698. var propType = getPropType(propValue);
  699. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
  700. }
  701. return null;
  702. }
  703. return createChainableTypeChecker(validate);
  704. }
  705. function createElementTypeTypeChecker() {
  706. function validate(props, propName, componentName, location, propFullName) {
  707. var propValue = props[propName];
  708. if (!reactIs.isValidElementType(propValue)) {
  709. var propType = getPropType(propValue);
  710. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
  711. }
  712. return null;
  713. }
  714. return createChainableTypeChecker(validate);
  715. }
  716. function createInstanceTypeChecker(expectedClass) {
  717. function validate(props, propName, componentName, location, propFullName) {
  718. if (!(props[propName] instanceof expectedClass)) {
  719. var expectedClassName = expectedClass.name || ANONYMOUS;
  720. var actualClassName = getClassName(props[propName]);
  721. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
  722. }
  723. return null;
  724. }
  725. return createChainableTypeChecker(validate);
  726. }
  727. function createEnumTypeChecker(expectedValues) {
  728. if (!Array.isArray(expectedValues)) {
  729. {
  730. if (arguments.length > 1) {
  731. printWarning$1(
  732. 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
  733. 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
  734. );
  735. } else {
  736. printWarning$1('Invalid argument supplied to oneOf, expected an array.');
  737. }
  738. }
  739. return emptyFunctionThatReturnsNull;
  740. }
  741. function validate(props, propName, componentName, location, propFullName) {
  742. var propValue = props[propName];
  743. for (var i = 0; i < expectedValues.length; i++) {
  744. if (is(propValue, expectedValues[i])) {
  745. return null;
  746. }
  747. }
  748. var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
  749. var type = getPreciseType(value);
  750. if (type === 'symbol') {
  751. return String(value);
  752. }
  753. return value;
  754. });
  755. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
  756. }
  757. return createChainableTypeChecker(validate);
  758. }
  759. function createObjectOfTypeChecker(typeChecker) {
  760. function validate(props, propName, componentName, location, propFullName) {
  761. if (typeof typeChecker !== 'function') {
  762. return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
  763. }
  764. var propValue = props[propName];
  765. var propType = getPropType(propValue);
  766. if (propType !== 'object') {
  767. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
  768. }
  769. for (var key in propValue) {
  770. if (has$1(propValue, key)) {
  771. var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  772. if (error instanceof Error) {
  773. return error;
  774. }
  775. }
  776. }
  777. return null;
  778. }
  779. return createChainableTypeChecker(validate);
  780. }
  781. function createUnionTypeChecker(arrayOfTypeCheckers) {
  782. if (!Array.isArray(arrayOfTypeCheckers)) {
  783. printWarning$1('Invalid argument supplied to oneOfType, expected an instance of array.') ;
  784. return emptyFunctionThatReturnsNull;
  785. }
  786. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  787. var checker = arrayOfTypeCheckers[i];
  788. if (typeof checker !== 'function') {
  789. printWarning$1(
  790. 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
  791. 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
  792. );
  793. return emptyFunctionThatReturnsNull;
  794. }
  795. }
  796. function validate(props, propName, componentName, location, propFullName) {
  797. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  798. var checker = arrayOfTypeCheckers[i];
  799. if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
  800. return null;
  801. }
  802. }
  803. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
  804. }
  805. return createChainableTypeChecker(validate);
  806. }
  807. function createNodeChecker() {
  808. function validate(props, propName, componentName, location, propFullName) {
  809. if (!isNode(props[propName])) {
  810. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
  811. }
  812. return null;
  813. }
  814. return createChainableTypeChecker(validate);
  815. }
  816. function createShapeTypeChecker(shapeTypes) {
  817. function validate(props, propName, componentName, location, propFullName) {
  818. var propValue = props[propName];
  819. var propType = getPropType(propValue);
  820. if (propType !== 'object') {
  821. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
  822. }
  823. for (var key in shapeTypes) {
  824. var checker = shapeTypes[key];
  825. if (!checker) {
  826. continue;
  827. }
  828. var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  829. if (error) {
  830. return error;
  831. }
  832. }
  833. return null;
  834. }
  835. return createChainableTypeChecker(validate);
  836. }
  837. function createStrictShapeTypeChecker(shapeTypes) {
  838. function validate(props, propName, componentName, location, propFullName) {
  839. var propValue = props[propName];
  840. var propType = getPropType(propValue);
  841. if (propType !== 'object') {
  842. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
  843. }
  844. // We need to check all keys in case some are required but missing from
  845. // props.
  846. var allKeys = objectAssign({}, props[propName], shapeTypes);
  847. for (var key in allKeys) {
  848. var checker = shapeTypes[key];
  849. if (!checker) {
  850. return new PropTypeError(
  851. 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
  852. '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
  853. '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
  854. );
  855. }
  856. var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  857. if (error) {
  858. return error;
  859. }
  860. }
  861. return null;
  862. }
  863. return createChainableTypeChecker(validate);
  864. }
  865. function isNode(propValue) {
  866. switch (typeof propValue) {
  867. case 'number':
  868. case 'string':
  869. case 'undefined':
  870. return true;
  871. case 'boolean':
  872. return !propValue;
  873. case 'object':
  874. if (Array.isArray(propValue)) {
  875. return propValue.every(isNode);
  876. }
  877. if (propValue === null || isValidElement(propValue)) {
  878. return true;
  879. }
  880. var iteratorFn = getIteratorFn(propValue);
  881. if (iteratorFn) {
  882. var iterator = iteratorFn.call(propValue);
  883. var step;
  884. if (iteratorFn !== propValue.entries) {
  885. while (!(step = iterator.next()).done) {
  886. if (!isNode(step.value)) {
  887. return false;
  888. }
  889. }
  890. } else {
  891. // Iterator will provide entry [k,v] tuples rather than values.
  892. while (!(step = iterator.next()).done) {
  893. var entry = step.value;
  894. if (entry) {
  895. if (!isNode(entry[1])) {
  896. return false;
  897. }
  898. }
  899. }
  900. }
  901. } else {
  902. return false;
  903. }
  904. return true;
  905. default:
  906. return false;
  907. }
  908. }
  909. function isSymbol(propType, propValue) {
  910. // Native Symbol.
  911. if (propType === 'symbol') {
  912. return true;
  913. }
  914. // falsy value can't be a Symbol
  915. if (!propValue) {
  916. return false;
  917. }
  918. // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
  919. if (propValue['@@toStringTag'] === 'Symbol') {
  920. return true;
  921. }
  922. // Fallback for non-spec compliant Symbols which are polyfilled.
  923. if (typeof Symbol === 'function' && propValue instanceof Symbol) {
  924. return true;
  925. }
  926. return false;
  927. }
  928. // Equivalent of `typeof` but with special handling for array and regexp.
  929. function getPropType(propValue) {
  930. var propType = typeof propValue;
  931. if (Array.isArray(propValue)) {
  932. return 'array';
  933. }
  934. if (propValue instanceof RegExp) {
  935. // Old webkits (at least until Android 4.0) return 'function' rather than
  936. // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
  937. // passes PropTypes.object.
  938. return 'object';
  939. }
  940. if (isSymbol(propType, propValue)) {
  941. return 'symbol';
  942. }
  943. return propType;
  944. }
  945. // This handles more types than `getPropType`. Only used for error messages.
  946. // See `createPrimitiveTypeChecker`.
  947. function getPreciseType(propValue) {
  948. if (typeof propValue === 'undefined' || propValue === null) {
  949. return '' + propValue;
  950. }
  951. var propType = getPropType(propValue);
  952. if (propType === 'object') {
  953. if (propValue instanceof Date) {
  954. return 'date';
  955. } else if (propValue instanceof RegExp) {
  956. return 'regexp';
  957. }
  958. }
  959. return propType;
  960. }
  961. // Returns a string that is postfixed to a warning about an invalid type.
  962. // For example, "undefined" or "of type array"
  963. function getPostfixForTypeWarning(value) {
  964. var type = getPreciseType(value);
  965. switch (type) {
  966. case 'array':
  967. case 'object':
  968. return 'an ' + type;
  969. case 'boolean':
  970. case 'date':
  971. case 'regexp':
  972. return 'a ' + type;
  973. default:
  974. return type;
  975. }
  976. }
  977. // Returns class name of the object, if any.
  978. function getClassName(propValue) {
  979. if (!propValue.constructor || !propValue.constructor.name) {
  980. return ANONYMOUS;
  981. }
  982. return propValue.constructor.name;
  983. }
  984. ReactPropTypes.checkPropTypes = checkPropTypes_1;
  985. ReactPropTypes.resetWarningCache = checkPropTypes_1.resetWarningCache;
  986. ReactPropTypes.PropTypes = ReactPropTypes;
  987. return ReactPropTypes;
  988. };
  989. var propTypes = createCommonjsModule(function (module) {
  990. /**
  991. * Copyright (c) 2013-present, Facebook, Inc.
  992. *
  993. * This source code is licensed under the MIT license found in the
  994. * LICENSE file in the root directory of this source tree.
  995. */
  996. {
  997. var ReactIs = reactIs;
  998. // By explicitly using `prop-types` you are opting into new development behavior.
  999. // http://fb.me/prop-types-in-prod
  1000. var throwOnDirectAccess = true;
  1001. module.exports = factoryWithTypeCheckers(ReactIs.isElement, throwOnDirectAccess);
  1002. }
  1003. });
  1004. function _extends() {
  1005. _extends = Object.assign || function (target) {
  1006. for (var i = 1; i < arguments.length; i++) {
  1007. var source = arguments[i];
  1008. for (var key in source) {
  1009. if (Object.prototype.hasOwnProperty.call(source, key)) {
  1010. target[key] = source[key];
  1011. }
  1012. }
  1013. }
  1014. return target;
  1015. };
  1016. return _extends.apply(this, arguments);
  1017. }
  1018. function isAbsolute(pathname) {
  1019. return pathname.charAt(0) === '/';
  1020. }
  1021. // About 1.5x faster than the two-arg version of Array#splice()
  1022. function spliceOne(list, index) {
  1023. for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) {
  1024. list[i] = list[k];
  1025. }
  1026. list.pop();
  1027. }
  1028. // This implementation is based heavily on node's url.parse
  1029. function resolvePathname(to) {
  1030. var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  1031. var toParts = to && to.split('/') || [];
  1032. var fromParts = from && from.split('/') || [];
  1033. var isToAbs = to && isAbsolute(to);
  1034. var isFromAbs = from && isAbsolute(from);
  1035. var mustEndAbs = isToAbs || isFromAbs;
  1036. if (to && isAbsolute(to)) {
  1037. // to is absolute
  1038. fromParts = toParts;
  1039. } else if (toParts.length) {
  1040. // to is relative, drop the filename
  1041. fromParts.pop();
  1042. fromParts = fromParts.concat(toParts);
  1043. }
  1044. if (!fromParts.length) return '/';
  1045. var hasTrailingSlash = void 0;
  1046. if (fromParts.length) {
  1047. var last = fromParts[fromParts.length - 1];
  1048. hasTrailingSlash = last === '.' || last === '..' || last === '';
  1049. } else {
  1050. hasTrailingSlash = false;
  1051. }
  1052. var up = 0;
  1053. for (var i = fromParts.length; i >= 0; i--) {
  1054. var part = fromParts[i];
  1055. if (part === '.') {
  1056. spliceOne(fromParts, i);
  1057. } else if (part === '..') {
  1058. spliceOne(fromParts, i);
  1059. up++;
  1060. } else if (up) {
  1061. spliceOne(fromParts, i);
  1062. up--;
  1063. }
  1064. }
  1065. if (!mustEndAbs) for (; up--; up) {
  1066. fromParts.unshift('..');
  1067. }if (mustEndAbs && fromParts[0] !== '' && (!fromParts[0] || !isAbsolute(fromParts[0]))) fromParts.unshift('');
  1068. var result = fromParts.join('/');
  1069. if (hasTrailingSlash && result.substr(-1) !== '/') result += '/';
  1070. return result;
  1071. }
  1072. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  1073. function valueEqual(a, b) {
  1074. if (a === b) return true;
  1075. if (a == null || b == null) return false;
  1076. if (Array.isArray(a)) {
  1077. return Array.isArray(b) && a.length === b.length && a.every(function (item, index) {
  1078. return valueEqual(item, b[index]);
  1079. });
  1080. }
  1081. var aType = typeof a === 'undefined' ? 'undefined' : _typeof(a);
  1082. var bType = typeof b === 'undefined' ? 'undefined' : _typeof(b);
  1083. if (aType !== bType) return false;
  1084. if (aType === 'object') {
  1085. var aValue = a.valueOf();
  1086. var bValue = b.valueOf();
  1087. if (aValue !== a || bValue !== b) return valueEqual(aValue, bValue);
  1088. var aKeys = Object.keys(a);
  1089. var bKeys = Object.keys(b);
  1090. if (aKeys.length !== bKeys.length) return false;
  1091. return aKeys.every(function (key) {
  1092. return valueEqual(a[key], b[key]);
  1093. });
  1094. }
  1095. return false;
  1096. }
  1097. function warning(condition, message) {
  1098. {
  1099. if (condition) {
  1100. return;
  1101. }
  1102. var text = "Warning: " + message;
  1103. if (typeof console !== 'undefined') {
  1104. console.warn(text);
  1105. }
  1106. try {
  1107. throw Error(text);
  1108. } catch (x) {}
  1109. }
  1110. }
  1111. var prefix = 'Invariant failed';
  1112. function invariant(condition, message) {
  1113. if (condition) {
  1114. return;
  1115. }
  1116. {
  1117. throw new Error(prefix + ": " + (message || ''));
  1118. }
  1119. }
  1120. function parsePath(path) {
  1121. var pathname = path || '/';
  1122. var search = '';
  1123. var hash = '';
  1124. var hashIndex = pathname.indexOf('#');
  1125. if (hashIndex !== -1) {
  1126. hash = pathname.substr(hashIndex);
  1127. pathname = pathname.substr(0, hashIndex);
  1128. }
  1129. var searchIndex = pathname.indexOf('?');
  1130. if (searchIndex !== -1) {
  1131. search = pathname.substr(searchIndex);
  1132. pathname = pathname.substr(0, searchIndex);
  1133. }
  1134. return {
  1135. pathname: pathname,
  1136. search: search === '?' ? '' : search,
  1137. hash: hash === '#' ? '' : hash
  1138. };
  1139. }
  1140. function createPath(location) {
  1141. var pathname = location.pathname,
  1142. search = location.search,
  1143. hash = location.hash;
  1144. var path = pathname || '/';
  1145. if (search && search !== '?') path += search.charAt(0) === '?' ? search : "?" + search;
  1146. if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : "#" + hash;
  1147. return path;
  1148. }
  1149. function createLocation(path, state, key, currentLocation) {
  1150. var location;
  1151. if (typeof path === 'string') {
  1152. // Two-arg form: push(path, state)
  1153. location = parsePath(path);
  1154. location.state = state;
  1155. } else {
  1156. // One-arg form: push(location)
  1157. location = _extends({}, path);
  1158. if (location.pathname === undefined) location.pathname = '';
  1159. if (location.search) {
  1160. if (location.search.charAt(0) !== '?') location.search = '?' + location.search;
  1161. } else {
  1162. location.search = '';
  1163. }
  1164. if (location.hash) {
  1165. if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash;
  1166. } else {
  1167. location.hash = '';
  1168. }
  1169. if (state !== undefined && location.state === undefined) location.state = state;
  1170. }
  1171. try {
  1172. location.pathname = decodeURI(location.pathname);
  1173. } catch (e) {
  1174. if (e instanceof URIError) {
  1175. throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.');
  1176. } else {
  1177. throw e;
  1178. }
  1179. }
  1180. if (key) location.key = key;
  1181. if (currentLocation) {
  1182. // Resolve incomplete/relative pathname relative to current location.
  1183. if (!location.pathname) {
  1184. location.pathname = currentLocation.pathname;
  1185. } else if (location.pathname.charAt(0) !== '/') {
  1186. location.pathname = resolvePathname(location.pathname, currentLocation.pathname);
  1187. }
  1188. } else {
  1189. // When there is no prior location and pathname is empty, set it to /
  1190. if (!location.pathname) {
  1191. location.pathname = '/';
  1192. }
  1193. }
  1194. return location;
  1195. }
  1196. function locationsAreEqual(a, b) {
  1197. return a.pathname === b.pathname && a.search === b.search && a.hash === b.hash && a.key === b.key && valueEqual(a.state, b.state);
  1198. }
  1199. function createTransitionManager() {
  1200. var prompt = null;
  1201. function setPrompt(nextPrompt) {
  1202. warning(prompt == null, 'A history supports only one prompt at a time') ;
  1203. prompt = nextPrompt;
  1204. return function () {
  1205. if (prompt === nextPrompt) prompt = null;
  1206. };
  1207. }
  1208. function confirmTransitionTo(location, action, getUserConfirmation, callback) {
  1209. // TODO: If another transition starts while we're still confirming
  1210. // the previous one, we may end up in a weird state. Figure out the
  1211. // best way to handle this.
  1212. if (prompt != null) {
  1213. var result = typeof prompt === 'function' ? prompt(location, action) : prompt;
  1214. if (typeof result === 'string') {
  1215. if (typeof getUserConfirmation === 'function') {
  1216. getUserConfirmation(result, callback);
  1217. } else {
  1218. warning(false, 'A history needs a getUserConfirmation function in order to use a prompt message') ;
  1219. callback(true);
  1220. }
  1221. } else {
  1222. // Return false from a transition hook to cancel the transition.
  1223. callback(result !== false);
  1224. }
  1225. } else {
  1226. callback(true);
  1227. }
  1228. }
  1229. var listeners = [];
  1230. function appendListener(fn) {
  1231. var isActive = true;
  1232. function listener() {
  1233. if (isActive) fn.apply(void 0, arguments);
  1234. }
  1235. listeners.push(listener);
  1236. return function () {
  1237. isActive = false;
  1238. listeners = listeners.filter(function (item) {
  1239. return item !== listener;
  1240. });
  1241. };
  1242. }
  1243. function notifyListeners() {
  1244. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  1245. args[_key] = arguments[_key];
  1246. }
  1247. listeners.forEach(function (listener) {
  1248. return listener.apply(void 0, args);
  1249. });
  1250. }
  1251. return {
  1252. setPrompt: setPrompt,
  1253. confirmTransitionTo: confirmTransitionTo,
  1254. appendListener: appendListener,
  1255. notifyListeners: notifyListeners
  1256. };
  1257. }
  1258. var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
  1259. function clamp(n, lowerBound, upperBound) {
  1260. return Math.min(Math.max(n, lowerBound), upperBound);
  1261. }
  1262. /**
  1263. * Creates a history object that stores locations in memory.
  1264. */
  1265. function createMemoryHistory(props) {
  1266. if (props === void 0) {
  1267. props = {};
  1268. }
  1269. var _props = props,
  1270. getUserConfirmation = _props.getUserConfirmation,
  1271. _props$initialEntries = _props.initialEntries,
  1272. initialEntries = _props$initialEntries === void 0 ? ['/'] : _props$initialEntries,
  1273. _props$initialIndex = _props.initialIndex,
  1274. initialIndex = _props$initialIndex === void 0 ? 0 : _props$initialIndex,
  1275. _props$keyLength = _props.keyLength,
  1276. keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength;
  1277. var transitionManager = createTransitionManager();
  1278. function setState(nextState) {
  1279. _extends(history, nextState);
  1280. history.length = history.entries.length;
  1281. transitionManager.notifyListeners(history.location, history.action);
  1282. }
  1283. function createKey() {
  1284. return Math.random().toString(36).substr(2, keyLength);
  1285. }
  1286. var index = clamp(initialIndex, 0, initialEntries.length - 1);
  1287. var entries = initialEntries.map(function (entry) {
  1288. return typeof entry === 'string' ? createLocation(entry, undefined, createKey()) : createLocation(entry, undefined, entry.key || createKey());
  1289. }); // Public interface
  1290. var createHref = createPath;
  1291. function push(path, state) {
  1292. warning(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored') ;
  1293. var action = 'PUSH';
  1294. var location = createLocation(path, state, createKey(), history.location);
  1295. transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
  1296. if (!ok) return;
  1297. var prevIndex = history.index;
  1298. var nextIndex = prevIndex + 1;
  1299. var nextEntries = history.entries.slice(0);
  1300. if (nextEntries.length > nextIndex) {
  1301. nextEntries.splice(nextIndex, nextEntries.length - nextIndex, location);
  1302. } else {
  1303. nextEntries.push(location);
  1304. }
  1305. setState({
  1306. action: action,
  1307. location: location,
  1308. index: nextIndex,
  1309. entries: nextEntries
  1310. });
  1311. });
  1312. }
  1313. function replace(path, state) {
  1314. warning(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored') ;
  1315. var action = 'REPLACE';
  1316. var location = createLocation(path, state, createKey(), history.location);
  1317. transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
  1318. if (!ok) return;
  1319. history.entries[history.index] = location;
  1320. setState({
  1321. action: action,
  1322. location: location
  1323. });
  1324. });
  1325. }
  1326. function go(n) {
  1327. var nextIndex = clamp(history.index + n, 0, history.entries.length - 1);
  1328. var action = 'POP';
  1329. var location = history.entries[nextIndex];
  1330. transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
  1331. if (ok) {
  1332. setState({
  1333. action: action,
  1334. location: location,
  1335. index: nextIndex
  1336. });
  1337. } else {
  1338. // Mimic the behavior of DOM histories by
  1339. // causing a render after a cancelled POP.
  1340. setState();
  1341. }
  1342. });
  1343. }
  1344. function goBack() {
  1345. go(-1);
  1346. }
  1347. function goForward() {
  1348. go(1);
  1349. }
  1350. function canGo(n) {
  1351. var nextIndex = history.index + n;
  1352. return nextIndex >= 0 && nextIndex < history.entries.length;
  1353. }
  1354. function block(prompt) {
  1355. if (prompt === void 0) {
  1356. prompt = false;
  1357. }
  1358. return transitionManager.setPrompt(prompt);
  1359. }
  1360. function listen(listener) {
  1361. return transitionManager.appendListener(listener);
  1362. }
  1363. var history = {
  1364. length: entries.length,
  1365. action: 'POP',
  1366. location: entries[index],
  1367. index: index,
  1368. entries: entries,
  1369. createHref: createHref,
  1370. push: push,
  1371. replace: replace,
  1372. go: go,
  1373. goBack: goBack,
  1374. goForward: goForward,
  1375. canGo: canGo,
  1376. block: block,
  1377. listen: listen
  1378. };
  1379. return history;
  1380. }
  1381. function _inheritsLoose$1(subClass, superClass) {
  1382. subClass.prototype = Object.create(superClass.prototype);
  1383. subClass.prototype.constructor = subClass;
  1384. subClass.__proto__ = superClass;
  1385. }
  1386. var MAX_SIGNED_31_BIT_INT = 1073741823;
  1387. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {};
  1388. function getUniqueId() {
  1389. var key = '__global_unique_id__';
  1390. return commonjsGlobal[key] = (commonjsGlobal[key] || 0) + 1;
  1391. }
  1392. function objectIs(x, y) {
  1393. if (x === y) {
  1394. return x !== 0 || 1 / x === 1 / y;
  1395. } else {
  1396. return x !== x && y !== y;
  1397. }
  1398. }
  1399. function createEventEmitter(value) {
  1400. var handlers = [];
  1401. return {
  1402. on: function on(handler) {
  1403. handlers.push(handler);
  1404. },
  1405. off: function off(handler) {
  1406. handlers = handlers.filter(function (h) {
  1407. return h !== handler;
  1408. });
  1409. },
  1410. get: function get() {
  1411. return value;
  1412. },
  1413. set: function set(newValue, changedBits) {
  1414. value = newValue;
  1415. handlers.forEach(function (handler) {
  1416. return handler(value, changedBits);
  1417. });
  1418. }
  1419. };
  1420. }
  1421. function onlyChild(children) {
  1422. return Array.isArray(children) ? children[0] : children;
  1423. }
  1424. function createReactContext(defaultValue, calculateChangedBits) {
  1425. var _Provider$childContex, _Consumer$contextType;
  1426. var contextProp = '__create-react-context-' + getUniqueId() + '__';
  1427. var Provider = /*#__PURE__*/function (_Component) {
  1428. _inheritsLoose$1(Provider, _Component);
  1429. function Provider() {
  1430. var _this;
  1431. _this = _Component.apply(this, arguments) || this;
  1432. _this.emitter = createEventEmitter(_this.props.value);
  1433. return _this;
  1434. }
  1435. var _proto = Provider.prototype;
  1436. _proto.getChildContext = function getChildContext() {
  1437. var _ref;
  1438. return _ref = {}, _ref[contextProp] = this.emitter, _ref;
  1439. };
  1440. _proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
  1441. if (this.props.value !== nextProps.value) {
  1442. var oldValue = this.props.value;
  1443. var newValue = nextProps.value;
  1444. var changedBits;
  1445. if (objectIs(oldValue, newValue)) {
  1446. changedBits = 0;
  1447. } else {
  1448. changedBits = typeof calculateChangedBits === 'function' ? calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
  1449. {
  1450. warning((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: ' + changedBits);
  1451. }
  1452. changedBits |= 0;
  1453. if (changedBits !== 0) {
  1454. this.emitter.set(nextProps.value, changedBits);
  1455. }
  1456. }
  1457. }
  1458. };
  1459. _proto.render = function render() {
  1460. return this.props.children;
  1461. };
  1462. return Provider;
  1463. }(React.Component);
  1464. Provider.childContextTypes = (_Provider$childContex = {}, _Provider$childContex[contextProp] = propTypes.object.isRequired, _Provider$childContex);
  1465. var Consumer = /*#__PURE__*/function (_Component2) {
  1466. _inheritsLoose$1(Consumer, _Component2);
  1467. function Consumer() {
  1468. var _this2;
  1469. _this2 = _Component2.apply(this, arguments) || this;
  1470. _this2.state = {
  1471. value: _this2.getValue()
  1472. };
  1473. _this2.onUpdate = function (newValue, changedBits) {
  1474. var observedBits = _this2.observedBits | 0;
  1475. if ((observedBits & changedBits) !== 0) {
  1476. _this2.setState({
  1477. value: _this2.getValue()
  1478. });
  1479. }
  1480. };
  1481. return _this2;
  1482. }
  1483. var _proto2 = Consumer.prototype;
  1484. _proto2.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
  1485. var observedBits = nextProps.observedBits;
  1486. this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT : observedBits;
  1487. };
  1488. _proto2.componentDidMount = function componentDidMount() {
  1489. if (this.context[contextProp]) {
  1490. this.context[contextProp].on(this.onUpdate);
  1491. }
  1492. var observedBits = this.props.observedBits;
  1493. this.observedBits = observedBits === undefined || observedBits === null ? MAX_SIGNED_31_BIT_INT : observedBits;
  1494. };
  1495. _proto2.componentWillUnmount = function componentWillUnmount() {
  1496. if (this.context[contextProp]) {
  1497. this.context[contextProp].off(this.onUpdate);
  1498. }
  1499. };
  1500. _proto2.getValue = function getValue() {
  1501. if (this.context[contextProp]) {
  1502. return this.context[contextProp].get();
  1503. } else {
  1504. return defaultValue;
  1505. }
  1506. };
  1507. _proto2.render = function render() {
  1508. return onlyChild(this.props.children)(this.state.value);
  1509. };
  1510. return Consumer;
  1511. }(React.Component);
  1512. Consumer.contextTypes = (_Consumer$contextType = {}, _Consumer$contextType[contextProp] = propTypes.object, _Consumer$contextType);
  1513. return {
  1514. Provider: Provider,
  1515. Consumer: Consumer
  1516. };
  1517. }
  1518. var index = React__default.createContext || createReactContext;
  1519. // TODO: Replace with React.createContext once we can assume React 16+
  1520. var createNamedContext = function createNamedContext(name) {
  1521. var context = index();
  1522. context.displayName = name;
  1523. return context;
  1524. };
  1525. var historyContext =
  1526. /*#__PURE__*/
  1527. createNamedContext("Router-History");
  1528. // TODO: Replace with React.createContext once we can assume React 16+
  1529. var createNamedContext$1 = function createNamedContext(name) {
  1530. var context = index();
  1531. context.displayName = name;
  1532. return context;
  1533. };
  1534. var context =
  1535. /*#__PURE__*/
  1536. createNamedContext$1("Router");
  1537. /**
  1538. * The public API for putting history on context.
  1539. */
  1540. var Router =
  1541. /*#__PURE__*/
  1542. function (_React$Component) {
  1543. _inheritsLoose(Router, _React$Component);
  1544. Router.computeRootMatch = function computeRootMatch(pathname) {
  1545. return {
  1546. path: "/",
  1547. url: "/",
  1548. params: {},
  1549. isExact: pathname === "/"
  1550. };
  1551. };
  1552. function Router(props) {
  1553. var _this;
  1554. _this = _React$Component.call(this, props) || this;
  1555. _this.state = {
  1556. location: props.history.location
  1557. }; // This is a bit of a hack. We have to start listening for location
  1558. // changes here in the constructor in case there are any <Redirect>s
  1559. // on the initial render. If there are, they will replace/push when
  1560. // they mount and since cDM fires in children before parents, we may
  1561. // get a new location before the <Router> is mounted.
  1562. _this._isMounted = false;
  1563. _this._pendingLocation = null;
  1564. if (!props.staticContext) {
  1565. _this.unlisten = props.history.listen(function (location) {
  1566. if (_this._isMounted) {
  1567. _this.setState({
  1568. location: location
  1569. });
  1570. } else {
  1571. _this._pendingLocation = location;
  1572. }
  1573. });
  1574. }
  1575. return _this;
  1576. }
  1577. var _proto = Router.prototype;
  1578. _proto.componentDidMount = function componentDidMount() {
  1579. this._isMounted = true;
  1580. if (this._pendingLocation) {
  1581. this.setState({
  1582. location: this._pendingLocation
  1583. });
  1584. }
  1585. };
  1586. _proto.componentWillUnmount = function componentWillUnmount() {
  1587. if (this.unlisten) this.unlisten();
  1588. };
  1589. _proto.render = function render() {
  1590. return React__default.createElement(context.Provider, {
  1591. value: {
  1592. history: this.props.history,
  1593. location: this.state.location,
  1594. match: Router.computeRootMatch(this.state.location.pathname),
  1595. staticContext: this.props.staticContext
  1596. }
  1597. }, React__default.createElement(historyContext.Provider, {
  1598. children: this.props.children || null,
  1599. value: this.props.history
  1600. }));
  1601. };
  1602. return Router;
  1603. }(React__default.Component);
  1604. {
  1605. Router.propTypes = {
  1606. children: propTypes.node,
  1607. history: propTypes.object.isRequired,
  1608. staticContext: propTypes.object
  1609. };
  1610. Router.prototype.componentDidUpdate = function (prevProps) {
  1611. warning(prevProps.history === this.props.history, "You cannot change <Router history>") ;
  1612. };
  1613. }
  1614. /**
  1615. * The public API for a <Router> that stores location in memory.
  1616. */
  1617. var MemoryRouter =
  1618. /*#__PURE__*/
  1619. function (_React$Component) {
  1620. _inheritsLoose(MemoryRouter, _React$Component);
  1621. function MemoryRouter() {
  1622. var _this;
  1623. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  1624. args[_key] = arguments[_key];
  1625. }
  1626. _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
  1627. _this.history = createMemoryHistory(_this.props);
  1628. return _this;
  1629. }
  1630. var _proto = MemoryRouter.prototype;
  1631. _proto.render = function render() {
  1632. return React__default.createElement(Router, {
  1633. history: this.history,
  1634. children: this.props.children
  1635. });
  1636. };
  1637. return MemoryRouter;
  1638. }(React__default.Component);
  1639. {
  1640. MemoryRouter.propTypes = {
  1641. initialEntries: propTypes.array,
  1642. initialIndex: propTypes.number,
  1643. getUserConfirmation: propTypes.func,
  1644. keyLength: propTypes.number,
  1645. children: propTypes.node
  1646. };
  1647. MemoryRouter.prototype.componentDidMount = function () {
  1648. warning(!this.props.history, "<MemoryRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { MemoryRouter as Router }`.") ;
  1649. };
  1650. }
  1651. var Lifecycle =
  1652. /*#__PURE__*/
  1653. function (_React$Component) {
  1654. _inheritsLoose(Lifecycle, _React$Component);
  1655. function Lifecycle() {
  1656. return _React$Component.apply(this, arguments) || this;
  1657. }
  1658. var _proto = Lifecycle.prototype;
  1659. _proto.componentDidMount = function componentDidMount() {
  1660. if (this.props.onMount) this.props.onMount.call(this, this);
  1661. };
  1662. _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
  1663. if (this.props.onUpdate) this.props.onUpdate.call(this, this, prevProps);
  1664. };
  1665. _proto.componentWillUnmount = function componentWillUnmount() {
  1666. if (this.props.onUnmount) this.props.onUnmount.call(this, this);
  1667. };
  1668. _proto.render = function render() {
  1669. return null;
  1670. };
  1671. return Lifecycle;
  1672. }(React__default.Component);
  1673. /**
  1674. * The public API for prompting the user before navigating away from a screen.
  1675. */
  1676. function Prompt(_ref) {
  1677. var message = _ref.message,
  1678. _ref$when = _ref.when,
  1679. when = _ref$when === void 0 ? true : _ref$when;
  1680. return React__default.createElement(context.Consumer, null, function (context) {
  1681. !context ? invariant(false, "You should not use <Prompt> outside a <Router>") : void 0;
  1682. if (!when || context.staticContext) return null;
  1683. var method = context.history.block;
  1684. return React__default.createElement(Lifecycle, {
  1685. onMount: function onMount(self) {
  1686. self.release = method(message);
  1687. },
  1688. onUpdate: function onUpdate(self, prevProps) {
  1689. if (prevProps.message !== message) {
  1690. self.release();
  1691. self.release = method(message);
  1692. }
  1693. },
  1694. onUnmount: function onUnmount(self) {
  1695. self.release();
  1696. },
  1697. message: message
  1698. });
  1699. });
  1700. }
  1701. {
  1702. var messageType = propTypes.oneOfType([propTypes.func, propTypes.string]);
  1703. Prompt.propTypes = {
  1704. when: propTypes.bool,
  1705. message: messageType.isRequired
  1706. };
  1707. }
  1708. var isarray = Array.isArray || function (arr) {
  1709. return Object.prototype.toString.call(arr) == '[object Array]';
  1710. };
  1711. /**
  1712. * Expose `pathToRegexp`.
  1713. */
  1714. var pathToRegexp_1 = pathToRegexp;
  1715. var parse_1 = parse;
  1716. var compile_1 = compile;
  1717. var tokensToFunction_1 = tokensToFunction;
  1718. var tokensToRegExp_1 = tokensToRegExp;
  1719. /**
  1720. * The main path matching regexp utility.
  1721. *
  1722. * @type {RegExp}
  1723. */
  1724. var PATH_REGEXP = new RegExp([
  1725. // Match escaped characters that would otherwise appear in future matches.
  1726. // This allows the user to escape special characters that won't transform.
  1727. '(\\\\.)',
  1728. // Match Express-style parameters and un-named parameters with a prefix
  1729. // and optional suffixes. Matches appear as:
  1730. //
  1731. // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined]
  1732. // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined]
  1733. // "/*" => ["/", undefined, undefined, undefined, undefined, "*"]
  1734. '([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))'
  1735. ].join('|'), 'g');
  1736. /**
  1737. * Parse a string for the raw tokens.
  1738. *
  1739. * @param {string} str
  1740. * @param {Object=} options
  1741. * @return {!Array}
  1742. */
  1743. function parse (str, options) {
  1744. var tokens = [];
  1745. var key = 0;
  1746. var index = 0;
  1747. var path = '';
  1748. var defaultDelimiter = options && options.delimiter || '/';
  1749. var res;
  1750. while ((res = PATH_REGEXP.exec(str)) != null) {
  1751. var m = res[0];
  1752. var escaped = res[1];
  1753. var offset = res.index;
  1754. path += str.slice(index, offset);
  1755. index = offset + m.length;
  1756. // Ignore already escaped sequences.
  1757. if (escaped) {
  1758. path += escaped[1];
  1759. continue
  1760. }
  1761. var next = str[index];
  1762. var prefix = res[2];
  1763. var name = res[3];
  1764. var capture = res[4];
  1765. var group = res[5];
  1766. var modifier = res[6];
  1767. var asterisk = res[7];
  1768. // Push the current path onto the tokens.
  1769. if (path) {
  1770. tokens.push(path);
  1771. path = '';
  1772. }
  1773. var partial = prefix != null && next != null && next !== prefix;
  1774. var repeat = modifier === '+' || modifier === '*';
  1775. var optional = modifier === '?' || modifier === '*';
  1776. var delimiter = res[2] || defaultDelimiter;
  1777. var pattern = capture || group;
  1778. tokens.push({
  1779. name: name || key++,
  1780. prefix: prefix || '',
  1781. delimiter: delimiter,
  1782. optional: optional,
  1783. repeat: repeat,
  1784. partial: partial,
  1785. asterisk: !!asterisk,
  1786. pattern: pattern ? escapeGroup(pattern) : (asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?')
  1787. });
  1788. }
  1789. // Match any characters still remaining.
  1790. if (index < str.length) {
  1791. path += str.substr(index);
  1792. }
  1793. // If the path exists, push it onto the end.
  1794. if (path) {
  1795. tokens.push(path);
  1796. }
  1797. return tokens
  1798. }
  1799. /**
  1800. * Compile a string to a template function for the path.
  1801. *
  1802. * @param {string} str
  1803. * @param {Object=} options
  1804. * @return {!function(Object=, Object=)}
  1805. */
  1806. function compile (str, options) {
  1807. return tokensToFunction(parse(str, options))
  1808. }
  1809. /**
  1810. * Prettier encoding of URI path segments.
  1811. *
  1812. * @param {string}
  1813. * @return {string}
  1814. */
  1815. function encodeURIComponentPretty (str) {
  1816. return encodeURI(str).replace(/[\/?#]/g, function (c) {
  1817. return '%' + c.charCodeAt(0).toString(16).toUpperCase()
  1818. })
  1819. }
  1820. /**
  1821. * Encode the asterisk parameter. Similar to `pretty`, but allows slashes.
  1822. *
  1823. * @param {string}
  1824. * @return {string}
  1825. */
  1826. function encodeAsterisk (str) {
  1827. return encodeURI(str).replace(/[?#]/g, function (c) {
  1828. return '%' + c.charCodeAt(0).toString(16).toUpperCase()
  1829. })
  1830. }
  1831. /**
  1832. * Expose a method for transforming tokens into the path function.
  1833. */
  1834. function tokensToFunction (tokens) {
  1835. // Compile all the tokens into regexps.
  1836. var matches = new Array(tokens.length);
  1837. // Compile all the patterns before compilation.
  1838. for (var i = 0; i < tokens.length; i++) {
  1839. if (typeof tokens[i] === 'object') {
  1840. matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$');
  1841. }
  1842. }
  1843. return function (obj, opts) {
  1844. var path = '';
  1845. var data = obj || {};
  1846. var options = opts || {};
  1847. var encode = options.pretty ? encodeURIComponentPretty : encodeURIComponent;
  1848. for (var i = 0; i < tokens.length; i++) {
  1849. var token = tokens[i];
  1850. if (typeof token === 'string') {
  1851. path += token;
  1852. continue
  1853. }
  1854. var value = data[token.name];
  1855. var segment;
  1856. if (value == null) {
  1857. if (token.optional) {
  1858. // Prepend partial segment prefixes.
  1859. if (token.partial) {
  1860. path += token.prefix;
  1861. }
  1862. continue
  1863. } else {
  1864. throw new TypeError('Expected "' + token.name + '" to be defined')
  1865. }
  1866. }
  1867. if (isarray(value)) {
  1868. if (!token.repeat) {
  1869. throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + '`')
  1870. }
  1871. if (value.length === 0) {
  1872. if (token.optional) {
  1873. continue
  1874. } else {
  1875. throw new TypeError('Expected "' + token.name + '" to not be empty')
  1876. }
  1877. }
  1878. for (var j = 0; j < value.length; j++) {
  1879. segment = encode(value[j]);
  1880. if (!matches[i].test(segment)) {
  1881. throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but received `' + JSON.stringify(segment) + '`')
  1882. }
  1883. path += (j === 0 ? token.prefix : token.delimiter) + segment;
  1884. }
  1885. continue
  1886. }
  1887. segment = token.asterisk ? encodeAsterisk(value) : encode(value);
  1888. if (!matches[i].test(segment)) {
  1889. throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"')
  1890. }
  1891. path += token.prefix + segment;
  1892. }
  1893. return path
  1894. }
  1895. }
  1896. /**
  1897. * Escape a regular expression string.
  1898. *
  1899. * @param {string} str
  1900. * @return {string}
  1901. */
  1902. function escapeString (str) {
  1903. return str.replace(/([.+*?=^!:${}()[\]|\/\\])/g, '\\$1')
  1904. }
  1905. /**
  1906. * Escape the capturing group by escaping special characters and meaning.
  1907. *
  1908. * @param {string} group
  1909. * @return {string}
  1910. */
  1911. function escapeGroup (group) {
  1912. return group.replace(/([=!:$\/()])/g, '\\$1')
  1913. }
  1914. /**
  1915. * Attach the keys as a property of the regexp.
  1916. *
  1917. * @param {!RegExp} re
  1918. * @param {Array} keys
  1919. * @return {!RegExp}
  1920. */
  1921. function attachKeys (re, keys) {
  1922. re.keys = keys;
  1923. return re
  1924. }
  1925. /**
  1926. * Get the flags for a regexp from the options.
  1927. *
  1928. * @param {Object} options
  1929. * @return {string}
  1930. */
  1931. function flags (options) {
  1932. return options.sensitive ? '' : 'i'
  1933. }
  1934. /**
  1935. * Pull out keys from a regexp.
  1936. *
  1937. * @param {!RegExp} path
  1938. * @param {!Array} keys
  1939. * @return {!RegExp}
  1940. */
  1941. function regexpToRegexp (path, keys) {
  1942. // Use a negative lookahead to match only capturing groups.
  1943. var groups = path.source.match(/\((?!\?)/g);
  1944. if (groups) {
  1945. for (var i = 0; i < groups.length; i++) {
  1946. keys.push({
  1947. name: i,
  1948. prefix: null,
  1949. delimiter: null,
  1950. optional: false,
  1951. repeat: false,
  1952. partial: false,
  1953. asterisk: false,
  1954. pattern: null
  1955. });
  1956. }
  1957. }
  1958. return attachKeys(path, keys)
  1959. }
  1960. /**
  1961. * Transform an array into a regexp.
  1962. *
  1963. * @param {!Array} path
  1964. * @param {Array} keys
  1965. * @param {!Object} options
  1966. * @return {!RegExp}
  1967. */
  1968. function arrayToRegexp (path, keys, options) {
  1969. var parts = [];
  1970. for (var i = 0; i < path.length; i++) {
  1971. parts.push(pathToRegexp(path[i], keys, options).source);
  1972. }
  1973. var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options));
  1974. return attachKeys(regexp, keys)
  1975. }
  1976. /**
  1977. * Create a path regexp from string input.
  1978. *
  1979. * @param {string} path
  1980. * @param {!Array} keys
  1981. * @param {!Object} options
  1982. * @return {!RegExp}
  1983. */
  1984. function stringToRegexp (path, keys, options) {
  1985. return tokensToRegExp(parse(path, options), keys, options)
  1986. }
  1987. /**
  1988. * Expose a function for taking tokens and returning a RegExp.
  1989. *
  1990. * @param {!Array} tokens
  1991. * @param {(Array|Object)=} keys
  1992. * @param {Object=} options
  1993. * @return {!RegExp}
  1994. */
  1995. function tokensToRegExp (tokens, keys, options) {
  1996. if (!isarray(keys)) {
  1997. options = /** @type {!Object} */ (keys || options);
  1998. keys = [];
  1999. }
  2000. options = options || {};
  2001. var strict = options.strict;
  2002. var end = options.end !== false;
  2003. var route = '';
  2004. // Iterate over the tokens and create our regexp string.
  2005. for (var i = 0; i < tokens.length; i++) {
  2006. var token = tokens[i];
  2007. if (typeof token === 'string') {
  2008. route += escapeString(token);
  2009. } else {
  2010. var prefix = escapeString(token.prefix);
  2011. var capture = '(?:' + token.pattern + ')';
  2012. keys.push(token);
  2013. if (token.repeat) {
  2014. capture += '(?:' + prefix + capture + ')*';
  2015. }
  2016. if (token.optional) {
  2017. if (!token.partial) {
  2018. capture = '(?:' + prefix + '(' + capture + '))?';
  2019. } else {
  2020. capture = prefix + '(' + capture + ')?';
  2021. }
  2022. } else {
  2023. capture = prefix + '(' + capture + ')';
  2024. }
  2025. route += capture;
  2026. }
  2027. }
  2028. var delimiter = escapeString(options.delimiter || '/');
  2029. var endsWithDelimiter = route.slice(-delimiter.length) === delimiter;
  2030. // In non-strict mode we allow a slash at the end of match. If the path to
  2031. // match already ends with a slash, we remove it for consistency. The slash
  2032. // is valid at the end of a path match, not in the middle. This is important
  2033. // in non-ending mode, where "/test/" shouldn't match "/test//route".
  2034. if (!strict) {
  2035. route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?';
  2036. }
  2037. if (end) {
  2038. route += '$';
  2039. } else {
  2040. // In non-ending mode, we need the capturing groups to match as much as
  2041. // possible by using a positive lookahead to the end or next path segment.
  2042. route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)';
  2043. }
  2044. return attachKeys(new RegExp('^' + route, flags(options)), keys)
  2045. }
  2046. /**
  2047. * Normalize the given path string, returning a regular expression.
  2048. *
  2049. * An empty array can be passed in for the keys, which will hold the
  2050. * placeholder key descriptions. For example, using `/user/:id`, `keys` will
  2051. * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
  2052. *
  2053. * @param {(string|RegExp|Array)} path
  2054. * @param {(Array|Object)=} keys
  2055. * @param {Object=} options
  2056. * @return {!RegExp}
  2057. */
  2058. function pathToRegexp (path, keys, options) {
  2059. if (!isarray(keys)) {
  2060. options = /** @type {!Object} */ (keys || options);
  2061. keys = [];
  2062. }
  2063. options = options || {};
  2064. if (path instanceof RegExp) {
  2065. return regexpToRegexp(path, /** @type {!Array} */ (keys))
  2066. }
  2067. if (isarray(path)) {
  2068. return arrayToRegexp(/** @type {!Array} */ (path), /** @type {!Array} */ (keys), options)
  2069. }
  2070. return stringToRegexp(/** @type {string} */ (path), /** @type {!Array} */ (keys), options)
  2071. }
  2072. pathToRegexp_1.parse = parse_1;
  2073. pathToRegexp_1.compile = compile_1;
  2074. pathToRegexp_1.tokensToFunction = tokensToFunction_1;
  2075. pathToRegexp_1.tokensToRegExp = tokensToRegExp_1;
  2076. var cache = {};
  2077. var cacheLimit = 10000;
  2078. var cacheCount = 0;
  2079. function compilePath(path) {
  2080. if (cache[path]) return cache[path];
  2081. var generator = pathToRegexp_1.compile(path);
  2082. if (cacheCount < cacheLimit) {
  2083. cache[path] = generator;
  2084. cacheCount++;
  2085. }
  2086. return generator;
  2087. }
  2088. /**
  2089. * Public API for generating a URL pathname from a path and parameters.
  2090. */
  2091. function generatePath(path, params) {
  2092. if (path === void 0) {
  2093. path = "/";
  2094. }
  2095. if (params === void 0) {
  2096. params = {};
  2097. }
  2098. return path === "/" ? path : compilePath(path)(params, {
  2099. pretty: true
  2100. });
  2101. }
  2102. /**
  2103. * The public API for navigating programmatically with a component.
  2104. */
  2105. function Redirect(_ref) {
  2106. var computedMatch = _ref.computedMatch,
  2107. to = _ref.to,
  2108. _ref$push = _ref.push,
  2109. push = _ref$push === void 0 ? false : _ref$push;
  2110. return React__default.createElement(context.Consumer, null, function (context) {
  2111. !context ? invariant(false, "You should not use <Redirect> outside a <Router>") : void 0;
  2112. var history = context.history,
  2113. staticContext = context.staticContext;
  2114. var method = push ? history.push : history.replace;
  2115. var location = createLocation(computedMatch ? typeof to === "string" ? generatePath(to, computedMatch.params) : _extends({}, to, {
  2116. pathname: generatePath(to.pathname, computedMatch.params)
  2117. }) : to); // When rendering in a static context,
  2118. // set the new location immediately.
  2119. if (staticContext) {
  2120. method(location);
  2121. return null;
  2122. }
  2123. return React__default.createElement(Lifecycle, {
  2124. onMount: function onMount() {
  2125. method(location);
  2126. },
  2127. onUpdate: function onUpdate(self, prevProps) {
  2128. var prevLocation = createLocation(prevProps.to);
  2129. if (!locationsAreEqual(prevLocation, _extends({}, location, {
  2130. key: prevLocation.key
  2131. }))) {
  2132. method(location);
  2133. }
  2134. },
  2135. to: to
  2136. });
  2137. });
  2138. }
  2139. {
  2140. Redirect.propTypes = {
  2141. push: propTypes.bool,
  2142. from: propTypes.string,
  2143. to: propTypes.oneOfType([propTypes.string, propTypes.object]).isRequired
  2144. };
  2145. }
  2146. var cache$1 = {};
  2147. var cacheLimit$1 = 10000;
  2148. var cacheCount$1 = 0;
  2149. function compilePath$1(path, options) {
  2150. var cacheKey = "" + options.end + options.strict + options.sensitive;
  2151. var pathCache = cache$1[cacheKey] || (cache$1[cacheKey] = {});
  2152. if (pathCache[path]) return pathCache[path];
  2153. var keys = [];
  2154. var regexp = pathToRegexp_1(path, keys, options);
  2155. var result = {
  2156. regexp: regexp,
  2157. keys: keys
  2158. };
  2159. if (cacheCount$1 < cacheLimit$1) {
  2160. pathCache[path] = result;
  2161. cacheCount$1++;
  2162. }
  2163. return result;
  2164. }
  2165. /**
  2166. * Public API for matching a URL pathname to a path.
  2167. */
  2168. function matchPath(pathname, options) {
  2169. if (options === void 0) {
  2170. options = {};
  2171. }
  2172. if (typeof options === "string" || Array.isArray(options)) {
  2173. options = {
  2174. path: options
  2175. };
  2176. }
  2177. var _options = options,
  2178. path = _options.path,
  2179. _options$exact = _options.exact,
  2180. exact = _options$exact === void 0 ? false : _options$exact,
  2181. _options$strict = _options.strict,
  2182. strict = _options$strict === void 0 ? false : _options$strict,
  2183. _options$sensitive = _options.sensitive,
  2184. sensitive = _options$sensitive === void 0 ? false : _options$sensitive;
  2185. var paths = [].concat(path);
  2186. return paths.reduce(function (matched, path) {
  2187. if (!path && path !== "") return null;
  2188. if (matched) return matched;
  2189. var _compilePath = compilePath$1(path, {
  2190. end: exact,
  2191. strict: strict,
  2192. sensitive: sensitive
  2193. }),
  2194. regexp = _compilePath.regexp,
  2195. keys = _compilePath.keys;
  2196. var match = regexp.exec(pathname);
  2197. if (!match) return null;
  2198. var url = match[0],
  2199. values = match.slice(1);
  2200. var isExact = pathname === url;
  2201. if (exact && !isExact) return null;
  2202. return {
  2203. path: path,
  2204. // the path used to match
  2205. url: path === "/" && url === "" ? "/" : url,
  2206. // the matched portion of the URL
  2207. isExact: isExact,
  2208. // whether or not we matched exactly
  2209. params: keys.reduce(function (memo, key, index) {
  2210. memo[key.name] = values[index];
  2211. return memo;
  2212. }, {})
  2213. };
  2214. }, null);
  2215. }
  2216. function isEmptyChildren(children) {
  2217. return React__default.Children.count(children) === 0;
  2218. }
  2219. function evalChildrenDev(children, props, path) {
  2220. var value = children(props);
  2221. warning(value !== undefined, "You returned `undefined` from the `children` function of " + ("<Route" + (path ? " path=\"" + path + "\"" : "") + ">, but you ") + "should have returned a React element or `null`") ;
  2222. return value || null;
  2223. }
  2224. /**
  2225. * The public API for matching a single path and rendering.
  2226. */
  2227. var Route =
  2228. /*#__PURE__*/
  2229. function (_React$Component) {
  2230. _inheritsLoose(Route, _React$Component);
  2231. function Route() {
  2232. return _React$Component.apply(this, arguments) || this;
  2233. }
  2234. var _proto = Route.prototype;
  2235. _proto.render = function render() {
  2236. var _this = this;
  2237. return React__default.createElement(context.Consumer, null, function (context$1) {
  2238. !context$1 ? invariant(false, "You should not use <Route> outside a <Router>") : void 0;
  2239. var location = _this.props.location || context$1.location;
  2240. var match = _this.props.computedMatch ? _this.props.computedMatch // <Switch> already computed the match for us
  2241. : _this.props.path ? matchPath(location.pathname, _this.props) : context$1.match;
  2242. var props = _extends({}, context$1, {
  2243. location: location,
  2244. match: match
  2245. });
  2246. var _this$props = _this.props,
  2247. children = _this$props.children,
  2248. component = _this$props.component,
  2249. render = _this$props.render; // Preact uses an empty array as children by
  2250. // default, so use null if that's the case.
  2251. if (Array.isArray(children) && children.length === 0) {
  2252. children = null;
  2253. }
  2254. return React__default.createElement(context.Provider, {
  2255. value: props
  2256. }, props.match ? children ? typeof children === "function" ? evalChildrenDev(children, props, _this.props.path) : children : component ? React__default.createElement(component, props) : render ? render(props) : null : typeof children === "function" ? evalChildrenDev(children, props, _this.props.path) : null);
  2257. });
  2258. };
  2259. return Route;
  2260. }(React__default.Component);
  2261. {
  2262. Route.propTypes = {
  2263. children: propTypes.oneOfType([propTypes.func, propTypes.node]),
  2264. component: function component(props, propName) {
  2265. if (props[propName] && !reactIs_1(props[propName])) {
  2266. return new Error("Invalid prop 'component' supplied to 'Route': the prop is not a valid React component");
  2267. }
  2268. },
  2269. exact: propTypes.bool,
  2270. location: propTypes.object,
  2271. path: propTypes.oneOfType([propTypes.string, propTypes.arrayOf(propTypes.string)]),
  2272. render: propTypes.func,
  2273. sensitive: propTypes.bool,
  2274. strict: propTypes.bool
  2275. };
  2276. Route.prototype.componentDidMount = function () {
  2277. warning(!(this.props.children && !isEmptyChildren(this.props.children) && this.props.component), "You should not use <Route component> and <Route children> in the same route; <Route component> will be ignored") ;
  2278. warning(!(this.props.children && !isEmptyChildren(this.props.children) && this.props.render), "You should not use <Route render> and <Route children> in the same route; <Route render> will be ignored") ;
  2279. warning(!(this.props.component && this.props.render), "You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored") ;
  2280. };
  2281. Route.prototype.componentDidUpdate = function (prevProps) {
  2282. warning(!(this.props.location && !prevProps.location), '<Route> elements should not change from uncontrolled to controlled (or vice versa). You initially used no "location" prop and then provided one on a subsequent render.') ;
  2283. warning(!(!this.props.location && prevProps.location), '<Route> elements should not change from controlled to uncontrolled (or vice versa). You provided a "location" prop initially but omitted it on a subsequent render.') ;
  2284. };
  2285. }
  2286. function _objectWithoutPropertiesLoose(source, excluded) {
  2287. if (source == null) return {};
  2288. var target = {};
  2289. var sourceKeys = Object.keys(source);
  2290. var key, i;
  2291. for (i = 0; i < sourceKeys.length; i++) {
  2292. key = sourceKeys[i];
  2293. if (excluded.indexOf(key) >= 0) continue;
  2294. target[key] = source[key];
  2295. }
  2296. return target;
  2297. }
  2298. function addLeadingSlash(path) {
  2299. return path.charAt(0) === "/" ? path : "/" + path;
  2300. }
  2301. function addBasename(basename, location) {
  2302. if (!basename) return location;
  2303. return _extends({}, location, {
  2304. pathname: addLeadingSlash(basename) + location.pathname
  2305. });
  2306. }
  2307. function stripBasename(basename, location) {
  2308. if (!basename) return location;
  2309. var base = addLeadingSlash(basename);
  2310. if (location.pathname.indexOf(base) !== 0) return location;
  2311. return _extends({}, location, {
  2312. pathname: location.pathname.substr(base.length)
  2313. });
  2314. }
  2315. function createURL(location) {
  2316. return typeof location === "string" ? location : createPath(location);
  2317. }
  2318. function staticHandler(methodName) {
  2319. return function () {
  2320. invariant(false, "You cannot %s with <StaticRouter>") ;
  2321. };
  2322. }
  2323. function noop() {}
  2324. /**
  2325. * The public top-level API for a "static" <Router>, so-called because it
  2326. * can't actually change the current location. Instead, it just records
  2327. * location changes in a context object. Useful mainly in testing and
  2328. * server-rendering scenarios.
  2329. */
  2330. var StaticRouter =
  2331. /*#__PURE__*/
  2332. function (_React$Component) {
  2333. _inheritsLoose(StaticRouter, _React$Component);
  2334. function StaticRouter() {
  2335. var _this;
  2336. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  2337. args[_key] = arguments[_key];
  2338. }
  2339. _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
  2340. _this.handlePush = function (location) {
  2341. return _this.navigateTo(location, "PUSH");
  2342. };
  2343. _this.handleReplace = function (location) {
  2344. return _this.navigateTo(location, "REPLACE");
  2345. };
  2346. _this.handleListen = function () {
  2347. return noop;
  2348. };
  2349. _this.handleBlock = function () {
  2350. return noop;
  2351. };
  2352. return _this;
  2353. }
  2354. var _proto = StaticRouter.prototype;
  2355. _proto.navigateTo = function navigateTo(location, action) {
  2356. var _this$props = this.props,
  2357. _this$props$basename = _this$props.basename,
  2358. basename = _this$props$basename === void 0 ? "" : _this$props$basename,
  2359. _this$props$context = _this$props.context,
  2360. context = _this$props$context === void 0 ? {} : _this$props$context;
  2361. context.action = action;
  2362. context.location = addBasename(basename, createLocation(location));
  2363. context.url = createURL(context.location);
  2364. };
  2365. _proto.render = function render() {
  2366. var _this$props2 = this.props,
  2367. _this$props2$basename = _this$props2.basename,
  2368. basename = _this$props2$basename === void 0 ? "" : _this$props2$basename,
  2369. _this$props2$context = _this$props2.context,
  2370. context = _this$props2$context === void 0 ? {} : _this$props2$context,
  2371. _this$props2$location = _this$props2.location,
  2372. location = _this$props2$location === void 0 ? "/" : _this$props2$location,
  2373. rest = _objectWithoutPropertiesLoose(_this$props2, ["basename", "context", "location"]);
  2374. var history = {
  2375. createHref: function createHref(path) {
  2376. return addLeadingSlash(basename + createURL(path));
  2377. },
  2378. action: "POP",
  2379. location: stripBasename(basename, createLocation(location)),
  2380. push: this.handlePush,
  2381. replace: this.handleReplace,
  2382. go: staticHandler(),
  2383. goBack: staticHandler(),
  2384. goForward: staticHandler(),
  2385. listen: this.handleListen,
  2386. block: this.handleBlock
  2387. };
  2388. return React__default.createElement(Router, _extends({}, rest, {
  2389. history: history,
  2390. staticContext: context
  2391. }));
  2392. };
  2393. return StaticRouter;
  2394. }(React__default.Component);
  2395. {
  2396. StaticRouter.propTypes = {
  2397. basename: propTypes.string,
  2398. context: propTypes.object,
  2399. location: propTypes.oneOfType([propTypes.string, propTypes.object])
  2400. };
  2401. StaticRouter.prototype.componentDidMount = function () {
  2402. warning(!this.props.history, "<StaticRouter> ignores the history prop. To use a custom history, " + "use `import { Router }` instead of `import { StaticRouter as Router }`.") ;
  2403. };
  2404. }
  2405. /**
  2406. * The public API for rendering the first <Route> that matches.
  2407. */
  2408. var Switch =
  2409. /*#__PURE__*/
  2410. function (_React$Component) {
  2411. _inheritsLoose(Switch, _React$Component);
  2412. function Switch() {
  2413. return _React$Component.apply(this, arguments) || this;
  2414. }
  2415. var _proto = Switch.prototype;
  2416. _proto.render = function render() {
  2417. var _this = this;
  2418. return React__default.createElement(context.Consumer, null, function (context) {
  2419. !context ? invariant(false, "You should not use <Switch> outside a <Router>") : void 0;
  2420. var location = _this.props.location || context.location;
  2421. var element, match; // We use React.Children.forEach instead of React.Children.toArray().find()
  2422. // here because toArray adds keys to all child elements and we do not want
  2423. // to trigger an unmount/remount for two <Route>s that render the same
  2424. // component at different URLs.
  2425. React__default.Children.forEach(_this.props.children, function (child) {
  2426. if (match == null && React__default.isValidElement(child)) {
  2427. element = child;
  2428. var path = child.props.path || child.props.from;
  2429. match = path ? matchPath(location.pathname, _extends({}, child.props, {
  2430. path: path
  2431. })) : context.match;
  2432. }
  2433. });
  2434. return match ? React__default.cloneElement(element, {
  2435. location: location,
  2436. computedMatch: match
  2437. }) : null;
  2438. });
  2439. };
  2440. return Switch;
  2441. }(React__default.Component);
  2442. {
  2443. Switch.propTypes = {
  2444. children: propTypes.node,
  2445. location: propTypes.object
  2446. };
  2447. Switch.prototype.componentDidUpdate = function (prevProps) {
  2448. warning(!(this.props.location && !prevProps.location), '<Switch> elements should not change from uncontrolled to controlled (or vice versa). You initially used no "location" prop and then provided one on a subsequent render.') ;
  2449. warning(!(!this.props.location && prevProps.location), '<Switch> elements should not change from controlled to uncontrolled (or vice versa). You provided a "location" prop initially but omitted it on a subsequent render.') ;
  2450. };
  2451. }
  2452. /**
  2453. * Copyright 2015, Yahoo! Inc.
  2454. * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
  2455. */
  2456. var REACT_STATICS = {
  2457. childContextTypes: true,
  2458. contextType: true,
  2459. contextTypes: true,
  2460. defaultProps: true,
  2461. displayName: true,
  2462. getDefaultProps: true,
  2463. getDerivedStateFromError: true,
  2464. getDerivedStateFromProps: true,
  2465. mixins: true,
  2466. propTypes: true,
  2467. type: true
  2468. };
  2469. var KNOWN_STATICS = {
  2470. name: true,
  2471. length: true,
  2472. prototype: true,
  2473. caller: true,
  2474. callee: true,
  2475. arguments: true,
  2476. arity: true
  2477. };
  2478. var FORWARD_REF_STATICS = {
  2479. '$$typeof': true,
  2480. render: true,
  2481. defaultProps: true,
  2482. displayName: true,
  2483. propTypes: true
  2484. };
  2485. var MEMO_STATICS = {
  2486. '$$typeof': true,
  2487. compare: true,
  2488. defaultProps: true,
  2489. displayName: true,
  2490. propTypes: true,
  2491. type: true
  2492. };
  2493. var TYPE_STATICS = {};
  2494. TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
  2495. function getStatics(component) {
  2496. if (reactIs.isMemo(component)) {
  2497. return MEMO_STATICS;
  2498. }
  2499. return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;
  2500. }
  2501. var defineProperty = Object.defineProperty;
  2502. var getOwnPropertyNames = Object.getOwnPropertyNames;
  2503. var getOwnPropertySymbols$1 = Object.getOwnPropertySymbols;
  2504. var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  2505. var getPrototypeOf = Object.getPrototypeOf;
  2506. var objectPrototype = Object.prototype;
  2507. function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
  2508. if (typeof sourceComponent !== 'string') {
  2509. // don't hoist over string (html) components
  2510. if (objectPrototype) {
  2511. var inheritedComponent = getPrototypeOf(sourceComponent);
  2512. if (inheritedComponent && inheritedComponent !== objectPrototype) {
  2513. hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
  2514. }
  2515. }
  2516. var keys = getOwnPropertyNames(sourceComponent);
  2517. if (getOwnPropertySymbols$1) {
  2518. keys = keys.concat(getOwnPropertySymbols$1(sourceComponent));
  2519. }
  2520. var targetStatics = getStatics(targetComponent);
  2521. var sourceStatics = getStatics(sourceComponent);
  2522. for (var i = 0; i < keys.length; ++i) {
  2523. var key = keys[i];
  2524. if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
  2525. var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
  2526. try {
  2527. // Avoid failures from read-only properties
  2528. defineProperty(targetComponent, key, descriptor);
  2529. } catch (e) {}
  2530. }
  2531. }
  2532. return targetComponent;
  2533. }
  2534. return targetComponent;
  2535. }
  2536. var hoistNonReactStatics_cjs = hoistNonReactStatics;
  2537. /**
  2538. * A public higher-order component to access the imperative API
  2539. */
  2540. function withRouter(Component) {
  2541. var displayName = "withRouter(" + (Component.displayName || Component.name) + ")";
  2542. var C = function C(props) {
  2543. var wrappedComponentRef = props.wrappedComponentRef,
  2544. remainingProps = _objectWithoutPropertiesLoose(props, ["wrappedComponentRef"]);
  2545. return React__default.createElement(context.Consumer, null, function (context) {
  2546. !context ? invariant(false, "You should not use <" + displayName + " /> outside a <Router>") : void 0;
  2547. return React__default.createElement(Component, _extends({}, remainingProps, context, {
  2548. ref: wrappedComponentRef
  2549. }));
  2550. });
  2551. };
  2552. C.displayName = displayName;
  2553. C.WrappedComponent = Component;
  2554. {
  2555. C.propTypes = {
  2556. wrappedComponentRef: propTypes.oneOfType([propTypes.string, propTypes.func, propTypes.object])
  2557. };
  2558. }
  2559. return hoistNonReactStatics_cjs(C, Component);
  2560. }
  2561. var useContext = React__default.useContext;
  2562. function useHistory() {
  2563. {
  2564. !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useHistory()") : void 0;
  2565. }
  2566. return useContext(historyContext);
  2567. }
  2568. function useLocation() {
  2569. {
  2570. !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useLocation()") : void 0;
  2571. }
  2572. return useContext(context).location;
  2573. }
  2574. function useParams() {
  2575. {
  2576. !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useParams()") : void 0;
  2577. }
  2578. var match = useContext(context).match;
  2579. return match ? match.params : {};
  2580. }
  2581. function useRouteMatch(path) {
  2582. {
  2583. !(typeof useContext === "function") ? invariant(false, "You must use React >= 16.8 in order to use useRouteMatch()") : void 0;
  2584. }
  2585. var location = useLocation();
  2586. var match = useContext(context).match;
  2587. return path ? matchPath(location.pathname, path) : match;
  2588. }
  2589. {
  2590. if (typeof window !== "undefined") {
  2591. var global$1 = window;
  2592. var key = "__react_router_build__";
  2593. var buildNames = {
  2594. cjs: "CommonJS",
  2595. esm: "ES modules",
  2596. umd: "UMD"
  2597. };
  2598. if (global$1[key] && global$1[key] !== "umd") {
  2599. var initialBuildName = buildNames[global$1[key]];
  2600. var secondaryBuildName = buildNames["umd"]; // TODO: Add link to article that explains in detail how to avoid
  2601. // loading 2 different builds.
  2602. throw new Error("You are loading the " + secondaryBuildName + " build of React Router " + ("on a page that is already running the " + initialBuildName + " ") + "build, so things won't work right.");
  2603. }
  2604. global$1[key] = "umd";
  2605. }
  2606. }
  2607. exports.MemoryRouter = MemoryRouter;
  2608. exports.Prompt = Prompt;
  2609. exports.Redirect = Redirect;
  2610. exports.Route = Route;
  2611. exports.Router = Router;
  2612. exports.StaticRouter = StaticRouter;
  2613. exports.Switch = Switch;
  2614. exports.__HistoryContext = historyContext;
  2615. exports.__RouterContext = context;
  2616. exports.generatePath = generatePath;
  2617. exports.matchPath = matchPath;
  2618. exports.useHistory = useHistory;
  2619. exports.useLocation = useLocation;
  2620. exports.useParams = useParams;
  2621. exports.useRouteMatch = useRouteMatch;
  2622. exports.withRouter = withRouter;
  2623. Object.defineProperty(exports, '__esModule', { value: true });
  2624. }));
  2625. //# sourceMappingURL=react-router.js.map