react-router-dom.js 129 KB

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