react-router-dom.js 130 KB

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