Dashboard sipadu mbip
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

react-dom.development.js 947KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795
  1. /** @license React v16.12.0
  2. * react-dom.development.js
  3. *
  4. * Copyright (c) Facebook, Inc. and its affiliates.
  5. *
  6. * This source code is licensed under the MIT license found in the
  7. * LICENSE file in the root directory of this source tree.
  8. */
  9. 'use strict';
  10. if (process.env.NODE_ENV !== "production") {
  11. (function() {
  12. 'use strict';
  13. var React = require('react');
  14. var _assign = require('object-assign');
  15. var Scheduler = require('scheduler');
  16. var checkPropTypes = require('prop-types/checkPropTypes');
  17. var tracing = require('scheduler/tracing');
  18. // Do not require this module directly! Use normal `invariant` calls with
  19. // template literal strings. The messages will be replaced with error codes
  20. // during build.
  21. /**
  22. * Use invariant() to assert state which your program assumes to be true.
  23. *
  24. * Provide sprintf-style format (only %s is supported) and arguments
  25. * to provide information about what broke and what you were
  26. * expecting.
  27. *
  28. * The invariant message will be stripped in production, but the invariant
  29. * will remain to ensure logic does not differ in production.
  30. */
  31. if (!React) {
  32. {
  33. throw Error("ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM.");
  34. }
  35. }
  36. /**
  37. * Injectable ordering of event plugins.
  38. */
  39. var eventPluginOrder = null;
  40. /**
  41. * Injectable mapping from names to event plugin modules.
  42. */
  43. var namesToPlugins = {};
  44. /**
  45. * Recomputes the plugin list using the injected plugins and plugin ordering.
  46. *
  47. * @private
  48. */
  49. function recomputePluginOrdering() {
  50. if (!eventPluginOrder) {
  51. // Wait until an `eventPluginOrder` is injected.
  52. return;
  53. }
  54. for (var pluginName in namesToPlugins) {
  55. var pluginModule = namesToPlugins[pluginName];
  56. var pluginIndex = eventPluginOrder.indexOf(pluginName);
  57. if (!(pluginIndex > -1)) {
  58. {
  59. throw Error("EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + pluginName + "`.");
  60. }
  61. }
  62. if (plugins[pluginIndex]) {
  63. continue;
  64. }
  65. if (!pluginModule.extractEvents) {
  66. {
  67. throw Error("EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + pluginName + "` does not.");
  68. }
  69. }
  70. plugins[pluginIndex] = pluginModule;
  71. var publishedEvents = pluginModule.eventTypes;
  72. for (var eventName in publishedEvents) {
  73. if (!publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName)) {
  74. {
  75. throw Error("EventPluginRegistry: Failed to publish event `" + eventName + "` for plugin `" + pluginName + "`.");
  76. }
  77. }
  78. }
  79. }
  80. }
  81. /**
  82. * Publishes an event so that it can be dispatched by the supplied plugin.
  83. *
  84. * @param {object} dispatchConfig Dispatch configuration for the event.
  85. * @param {object} PluginModule Plugin publishing the event.
  86. * @return {boolean} True if the event was successfully published.
  87. * @private
  88. */
  89. function publishEventForPlugin(dispatchConfig, pluginModule, eventName) {
  90. if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) {
  91. {
  92. throw Error("EventPluginHub: More than one plugin attempted to publish the same event name, `" + eventName + "`.");
  93. }
  94. }
  95. eventNameDispatchConfigs[eventName] = dispatchConfig;
  96. var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
  97. if (phasedRegistrationNames) {
  98. for (var phaseName in phasedRegistrationNames) {
  99. if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
  100. var phasedRegistrationName = phasedRegistrationNames[phaseName];
  101. publishRegistrationName(phasedRegistrationName, pluginModule, eventName);
  102. }
  103. }
  104. return true;
  105. } else if (dispatchConfig.registrationName) {
  106. publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName);
  107. return true;
  108. }
  109. return false;
  110. }
  111. /**
  112. * Publishes a registration name that is used to identify dispatched events.
  113. *
  114. * @param {string} registrationName Registration name to add.
  115. * @param {object} PluginModule Plugin publishing the event.
  116. * @private
  117. */
  118. function publishRegistrationName(registrationName, pluginModule, eventName) {
  119. if (!!registrationNameModules[registrationName]) {
  120. {
  121. throw Error("EventPluginHub: More than one plugin attempted to publish the same registration name, `" + registrationName + "`.");
  122. }
  123. }
  124. registrationNameModules[registrationName] = pluginModule;
  125. registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies;
  126. {
  127. var lowerCasedName = registrationName.toLowerCase();
  128. possibleRegistrationNames[lowerCasedName] = registrationName;
  129. if (registrationName === 'onDoubleClick') {
  130. possibleRegistrationNames.ondblclick = registrationName;
  131. }
  132. }
  133. }
  134. /**
  135. * Registers plugins so that they can extract and dispatch events.
  136. *
  137. * @see {EventPluginHub}
  138. */
  139. /**
  140. * Ordered list of injected plugins.
  141. */
  142. var plugins = [];
  143. /**
  144. * Mapping from event name to dispatch config
  145. */
  146. var eventNameDispatchConfigs = {};
  147. /**
  148. * Mapping from registration name to plugin module
  149. */
  150. var registrationNameModules = {};
  151. /**
  152. * Mapping from registration name to event name
  153. */
  154. var registrationNameDependencies = {};
  155. /**
  156. * Mapping from lowercase registration names to the properly cased version,
  157. * used to warn in the case of missing event handlers. Available
  158. * only in true.
  159. * @type {Object}
  160. */
  161. var possibleRegistrationNames = {}; // Trust the developer to only use possibleRegistrationNames in true
  162. /**
  163. * Injects an ordering of plugins (by plugin name). This allows the ordering
  164. * to be decoupled from injection of the actual plugins so that ordering is
  165. * always deterministic regardless of packaging, on-the-fly injection, etc.
  166. *
  167. * @param {array} InjectedEventPluginOrder
  168. * @internal
  169. * @see {EventPluginHub.injection.injectEventPluginOrder}
  170. */
  171. function injectEventPluginOrder(injectedEventPluginOrder) {
  172. if (!!eventPluginOrder) {
  173. {
  174. throw Error("EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React.");
  175. }
  176. } // Clone the ordering so it cannot be dynamically mutated.
  177. eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder);
  178. recomputePluginOrdering();
  179. }
  180. /**
  181. * Injects plugins to be used by `EventPluginHub`. The plugin names must be
  182. * in the ordering injected by `injectEventPluginOrder`.
  183. *
  184. * Plugins can be injected as part of page initialization or on-the-fly.
  185. *
  186. * @param {object} injectedNamesToPlugins Map from names to plugin modules.
  187. * @internal
  188. * @see {EventPluginHub.injection.injectEventPluginsByName}
  189. */
  190. function injectEventPluginsByName(injectedNamesToPlugins) {
  191. var isOrderingDirty = false;
  192. for (var pluginName in injectedNamesToPlugins) {
  193. if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
  194. continue;
  195. }
  196. var pluginModule = injectedNamesToPlugins[pluginName];
  197. if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule) {
  198. if (!!namesToPlugins[pluginName]) {
  199. {
  200. throw Error("EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + pluginName + "`.");
  201. }
  202. }
  203. namesToPlugins[pluginName] = pluginModule;
  204. isOrderingDirty = true;
  205. }
  206. }
  207. if (isOrderingDirty) {
  208. recomputePluginOrdering();
  209. }
  210. }
  211. var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) {
  212. var funcArgs = Array.prototype.slice.call(arguments, 3);
  213. try {
  214. func.apply(context, funcArgs);
  215. } catch (error) {
  216. this.onError(error);
  217. }
  218. };
  219. {
  220. // In DEV mode, we swap out invokeGuardedCallback for a special version
  221. // that plays more nicely with the browser's DevTools. The idea is to preserve
  222. // "Pause on exceptions" behavior. Because React wraps all user-provided
  223. // functions in invokeGuardedCallback, and the production version of
  224. // invokeGuardedCallback uses a try-catch, all user exceptions are treated
  225. // like caught exceptions, and the DevTools won't pause unless the developer
  226. // takes the extra step of enabling pause on caught exceptions. This is
  227. // unintuitive, though, because even though React has caught the error, from
  228. // the developer's perspective, the error is uncaught.
  229. //
  230. // To preserve the expected "Pause on exceptions" behavior, we don't use a
  231. // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake
  232. // DOM node, and call the user-provided callback from inside an event handler
  233. // for that fake event. If the callback throws, the error is "captured" using
  234. // a global event handler. But because the error happens in a different
  235. // event loop context, it does not interrupt the normal program flow.
  236. // Effectively, this gives us try-catch behavior without actually using
  237. // try-catch. Neat!
  238. // Check that the browser supports the APIs we need to implement our special
  239. // DEV version of invokeGuardedCallback
  240. if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
  241. var fakeNode = document.createElement('react');
  242. var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) {
  243. // If document doesn't exist we know for sure we will crash in this method
  244. // when we call document.createEvent(). However this can cause confusing
  245. // errors: https://github.com/facebookincubator/create-react-app/issues/3482
  246. // So we preemptively throw with a better message instead.
  247. if (!(typeof document !== 'undefined')) {
  248. {
  249. throw Error("The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous.");
  250. }
  251. }
  252. var evt = document.createEvent('Event'); // Keeps track of whether the user-provided callback threw an error. We
  253. // set this to true at the beginning, then set it to false right after
  254. // calling the function. If the function errors, `didError` will never be
  255. // set to false. This strategy works even if the browser is flaky and
  256. // fails to call our global error handler, because it doesn't rely on
  257. // the error event at all.
  258. var didError = true; // Keeps track of the value of window.event so that we can reset it
  259. // during the callback to let user code access window.event in the
  260. // browsers that support it.
  261. var windowEvent = window.event; // Keeps track of the descriptor of window.event to restore it after event
  262. // dispatching: https://github.com/facebook/react/issues/13688
  263. var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event'); // Create an event handler for our fake event. We will synchronously
  264. // dispatch our fake event using `dispatchEvent`. Inside the handler, we
  265. // call the user-provided callback.
  266. var funcArgs = Array.prototype.slice.call(arguments, 3);
  267. function callCallback() {
  268. // We immediately remove the callback from event listeners so that
  269. // nested `invokeGuardedCallback` calls do not clash. Otherwise, a
  270. // nested call would trigger the fake event handlers of any call higher
  271. // in the stack.
  272. fakeNode.removeEventListener(evtType, callCallback, false); // We check for window.hasOwnProperty('event') to prevent the
  273. // window.event assignment in both IE <= 10 as they throw an error
  274. // "Member not found" in strict mode, and in Firefox which does not
  275. // support window.event.
  276. if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) {
  277. window.event = windowEvent;
  278. }
  279. func.apply(context, funcArgs);
  280. didError = false;
  281. } // Create a global error event handler. We use this to capture the value
  282. // that was thrown. It's possible that this error handler will fire more
  283. // than once; for example, if non-React code also calls `dispatchEvent`
  284. // and a handler for that event throws. We should be resilient to most of
  285. // those cases. Even if our error event handler fires more than once, the
  286. // last error event is always used. If the callback actually does error,
  287. // we know that the last error event is the correct one, because it's not
  288. // possible for anything else to have happened in between our callback
  289. // erroring and the code that follows the `dispatchEvent` call below. If
  290. // the callback doesn't error, but the error event was fired, we know to
  291. // ignore it because `didError` will be false, as described above.
  292. var error; // Use this to track whether the error event is ever called.
  293. var didSetError = false;
  294. var isCrossOriginError = false;
  295. function handleWindowError(event) {
  296. error = event.error;
  297. didSetError = true;
  298. if (error === null && event.colno === 0 && event.lineno === 0) {
  299. isCrossOriginError = true;
  300. }
  301. if (event.defaultPrevented) {
  302. // Some other error handler has prevented default.
  303. // Browsers silence the error report if this happens.
  304. // We'll remember this to later decide whether to log it or not.
  305. if (error != null && typeof error === 'object') {
  306. try {
  307. error._suppressLogging = true;
  308. } catch (inner) {// Ignore.
  309. }
  310. }
  311. }
  312. } // Create a fake event type.
  313. var evtType = "react-" + (name ? name : 'invokeguardedcallback'); // Attach our event handlers
  314. window.addEventListener('error', handleWindowError);
  315. fakeNode.addEventListener(evtType, callCallback, false); // Synchronously dispatch our fake event. If the user-provided function
  316. // errors, it will trigger our global error handler.
  317. evt.initEvent(evtType, false, false);
  318. fakeNode.dispatchEvent(evt);
  319. if (windowEventDescriptor) {
  320. Object.defineProperty(window, 'event', windowEventDescriptor);
  321. }
  322. if (didError) {
  323. if (!didSetError) {
  324. // The callback errored, but the error event never fired.
  325. error = new Error('An error was thrown inside one of your components, but React ' + "doesn't know what it was. This is likely due to browser " + 'flakiness. React does its best to preserve the "Pause on ' + 'exceptions" behavior of the DevTools, which requires some ' + "DEV-mode only tricks. It's possible that these don't work in " + 'your browser. Try triggering the error in production mode, ' + 'or switching to a modern browser. If you suspect that this is ' + 'actually an issue with React, please file an issue.');
  326. } else if (isCrossOriginError) {
  327. error = new Error("A cross-origin error was thrown. React doesn't have access to " + 'the actual error object in development. ' + 'See https://fb.me/react-crossorigin-error for more information.');
  328. }
  329. this.onError(error);
  330. } // Remove our event listeners
  331. window.removeEventListener('error', handleWindowError);
  332. };
  333. invokeGuardedCallbackImpl = invokeGuardedCallbackDev;
  334. }
  335. }
  336. var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl;
  337. var hasError = false;
  338. var caughtError = null; // Used by event system to capture/rethrow the first error.
  339. var hasRethrowError = false;
  340. var rethrowError = null;
  341. var reporter = {
  342. onError: function (error) {
  343. hasError = true;
  344. caughtError = error;
  345. }
  346. };
  347. /**
  348. * Call a function while guarding against errors that happens within it.
  349. * Returns an error if it throws, otherwise null.
  350. *
  351. * In production, this is implemented using a try-catch. The reason we don't
  352. * use a try-catch directly is so that we can swap out a different
  353. * implementation in DEV mode.
  354. *
  355. * @param {String} name of the guard to use for logging or debugging
  356. * @param {Function} func The function to invoke
  357. * @param {*} context The context to use when calling the function
  358. * @param {...*} args Arguments for function
  359. */
  360. function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
  361. hasError = false;
  362. caughtError = null;
  363. invokeGuardedCallbackImpl$1.apply(reporter, arguments);
  364. }
  365. /**
  366. * Same as invokeGuardedCallback, but instead of returning an error, it stores
  367. * it in a global so it can be rethrown by `rethrowCaughtError` later.
  368. * TODO: See if caughtError and rethrowError can be unified.
  369. *
  370. * @param {String} name of the guard to use for logging or debugging
  371. * @param {Function} func The function to invoke
  372. * @param {*} context The context to use when calling the function
  373. * @param {...*} args Arguments for function
  374. */
  375. function invokeGuardedCallbackAndCatchFirstError(name, func, context, a, b, c, d, e, f) {
  376. invokeGuardedCallback.apply(this, arguments);
  377. if (hasError) {
  378. var error = clearCaughtError();
  379. if (!hasRethrowError) {
  380. hasRethrowError = true;
  381. rethrowError = error;
  382. }
  383. }
  384. }
  385. /**
  386. * During execution of guarded functions we will capture the first error which
  387. * we will rethrow to be handled by the top level error handler.
  388. */
  389. function rethrowCaughtError() {
  390. if (hasRethrowError) {
  391. var error = rethrowError;
  392. hasRethrowError = false;
  393. rethrowError = null;
  394. throw error;
  395. }
  396. }
  397. function hasCaughtError() {
  398. return hasError;
  399. }
  400. function clearCaughtError() {
  401. if (hasError) {
  402. var error = caughtError;
  403. hasError = false;
  404. caughtError = null;
  405. return error;
  406. } else {
  407. {
  408. {
  409. throw Error("clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue.");
  410. }
  411. }
  412. }
  413. }
  414. /**
  415. * Similar to invariant but only logs a warning if the condition is not met.
  416. * This can be used to log issues in development environments in critical
  417. * paths. Removing the logging code for production environments will keep the
  418. * same logic and follow the same code paths.
  419. */
  420. var warningWithoutStack = function () {};
  421. {
  422. warningWithoutStack = function (condition, format) {
  423. for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  424. args[_key - 2] = arguments[_key];
  425. }
  426. if (format === undefined) {
  427. throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
  428. }
  429. if (args.length > 8) {
  430. // Check before the condition to catch violations early.
  431. throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
  432. }
  433. if (condition) {
  434. return;
  435. }
  436. if (typeof console !== 'undefined') {
  437. var argsWithFormat = args.map(function (item) {
  438. return '' + item;
  439. });
  440. argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
  441. // breaks IE9: https://github.com/facebook/react/issues/13610
  442. Function.prototype.apply.call(console.error, console, argsWithFormat);
  443. }
  444. try {
  445. // --- Welcome to debugging React ---
  446. // This error was thrown as a convenience so that you can use this stack
  447. // to find the callsite that caused this warning to fire.
  448. var argIndex = 0;
  449. var message = 'Warning: ' + format.replace(/%s/g, function () {
  450. return args[argIndex++];
  451. });
  452. throw new Error(message);
  453. } catch (x) {}
  454. };
  455. }
  456. var warningWithoutStack$1 = warningWithoutStack;
  457. var getFiberCurrentPropsFromNode = null;
  458. var getInstanceFromNode = null;
  459. var getNodeFromInstance = null;
  460. function setComponentTree(getFiberCurrentPropsFromNodeImpl, getInstanceFromNodeImpl, getNodeFromInstanceImpl) {
  461. getFiberCurrentPropsFromNode = getFiberCurrentPropsFromNodeImpl;
  462. getInstanceFromNode = getInstanceFromNodeImpl;
  463. getNodeFromInstance = getNodeFromInstanceImpl;
  464. {
  465. !(getNodeFromInstance && getInstanceFromNode) ? warningWithoutStack$1(false, 'EventPluginUtils.setComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.') : void 0;
  466. }
  467. }
  468. var validateEventDispatches;
  469. {
  470. validateEventDispatches = function (event) {
  471. var dispatchListeners = event._dispatchListeners;
  472. var dispatchInstances = event._dispatchInstances;
  473. var listenersIsArr = Array.isArray(dispatchListeners);
  474. var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
  475. var instancesIsArr = Array.isArray(dispatchInstances);
  476. var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0;
  477. !(instancesIsArr === listenersIsArr && instancesLen === listenersLen) ? warningWithoutStack$1(false, 'EventPluginUtils: Invalid `event`.') : void 0;
  478. };
  479. }
  480. /**
  481. * Dispatch the event to the listener.
  482. * @param {SyntheticEvent} event SyntheticEvent to handle
  483. * @param {function} listener Application-level callback
  484. * @param {*} inst Internal component instance
  485. */
  486. function executeDispatch(event, listener, inst) {
  487. var type = event.type || 'unknown-event';
  488. event.currentTarget = getNodeFromInstance(inst);
  489. invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event);
  490. event.currentTarget = null;
  491. }
  492. /**
  493. * Standard/simple iteration through an event's collected dispatches.
  494. */
  495. function executeDispatchesInOrder(event) {
  496. var dispatchListeners = event._dispatchListeners;
  497. var dispatchInstances = event._dispatchInstances;
  498. {
  499. validateEventDispatches(event);
  500. }
  501. if (Array.isArray(dispatchListeners)) {
  502. for (var i = 0; i < dispatchListeners.length; i++) {
  503. if (event.isPropagationStopped()) {
  504. break;
  505. } // Listeners and Instances are two parallel arrays that are always in sync.
  506. executeDispatch(event, dispatchListeners[i], dispatchInstances[i]);
  507. }
  508. } else if (dispatchListeners) {
  509. executeDispatch(event, dispatchListeners, dispatchInstances);
  510. }
  511. event._dispatchListeners = null;
  512. event._dispatchInstances = null;
  513. }
  514. /**
  515. * @see executeDispatchesInOrderStopAtTrueImpl
  516. */
  517. /**
  518. * Execution of a "direct" dispatch - there must be at most one dispatch
  519. * accumulated on the event or it is considered an error. It doesn't really make
  520. * sense for an event with multiple dispatches (bubbled) to keep track of the
  521. * return values at each dispatch execution, but it does tend to make sense when
  522. * dealing with "direct" dispatches.
  523. *
  524. * @return {*} The return value of executing the single dispatch.
  525. */
  526. /**
  527. * @param {SyntheticEvent} event
  528. * @return {boolean} True iff number of dispatches accumulated is greater than 0.
  529. */
  530. /**
  531. * Accumulates items that must not be null or undefined into the first one. This
  532. * is used to conserve memory by avoiding array allocations, and thus sacrifices
  533. * API cleanness. Since `current` can be null before being passed in and not
  534. * null after this function, make sure to assign it back to `current`:
  535. *
  536. * `a = accumulateInto(a, b);`
  537. *
  538. * This API should be sparingly used. Try `accumulate` for something cleaner.
  539. *
  540. * @return {*|array<*>} An accumulation of items.
  541. */
  542. function accumulateInto(current, next) {
  543. if (!(next != null)) {
  544. {
  545. throw Error("accumulateInto(...): Accumulated items must not be null or undefined.");
  546. }
  547. }
  548. if (current == null) {
  549. return next;
  550. } // Both are not empty. Warning: Never call x.concat(y) when you are not
  551. // certain that x is an Array (x could be a string with concat method).
  552. if (Array.isArray(current)) {
  553. if (Array.isArray(next)) {
  554. current.push.apply(current, next);
  555. return current;
  556. }
  557. current.push(next);
  558. return current;
  559. }
  560. if (Array.isArray(next)) {
  561. // A bit too dangerous to mutate `next`.
  562. return [current].concat(next);
  563. }
  564. return [current, next];
  565. }
  566. /**
  567. * @param {array} arr an "accumulation" of items which is either an Array or
  568. * a single item. Useful when paired with the `accumulate` module. This is a
  569. * simple utility that allows us to reason about a collection of items, but
  570. * handling the case when there is exactly one item (and we do not need to
  571. * allocate an array).
  572. * @param {function} cb Callback invoked with each element or a collection.
  573. * @param {?} [scope] Scope used as `this` in a callback.
  574. */
  575. function forEachAccumulated(arr, cb, scope) {
  576. if (Array.isArray(arr)) {
  577. arr.forEach(cb, scope);
  578. } else if (arr) {
  579. cb.call(scope, arr);
  580. }
  581. }
  582. /**
  583. * Internal queue of events that have accumulated their dispatches and are
  584. * waiting to have their dispatches executed.
  585. */
  586. var eventQueue = null;
  587. /**
  588. * Dispatches an event and releases it back into the pool, unless persistent.
  589. *
  590. * @param {?object} event Synthetic event to be dispatched.
  591. * @private
  592. */
  593. var executeDispatchesAndRelease = function (event) {
  594. if (event) {
  595. executeDispatchesInOrder(event);
  596. if (!event.isPersistent()) {
  597. event.constructor.release(event);
  598. }
  599. }
  600. };
  601. var executeDispatchesAndReleaseTopLevel = function (e) {
  602. return executeDispatchesAndRelease(e);
  603. };
  604. function runEventsInBatch(events) {
  605. if (events !== null) {
  606. eventQueue = accumulateInto(eventQueue, events);
  607. } // Set `eventQueue` to null before processing it so that we can tell if more
  608. // events get enqueued while processing.
  609. var processingEventQueue = eventQueue;
  610. eventQueue = null;
  611. if (!processingEventQueue) {
  612. return;
  613. }
  614. forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel);
  615. if (!!eventQueue) {
  616. {
  617. throw Error("processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented.");
  618. }
  619. } // This would be a good time to rethrow if any of the event handlers threw.
  620. rethrowCaughtError();
  621. }
  622. function isInteractive(tag) {
  623. return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea';
  624. }
  625. function shouldPreventMouseEvent(name, type, props) {
  626. switch (name) {
  627. case 'onClick':
  628. case 'onClickCapture':
  629. case 'onDoubleClick':
  630. case 'onDoubleClickCapture':
  631. case 'onMouseDown':
  632. case 'onMouseDownCapture':
  633. case 'onMouseMove':
  634. case 'onMouseMoveCapture':
  635. case 'onMouseUp':
  636. case 'onMouseUpCapture':
  637. return !!(props.disabled && isInteractive(type));
  638. default:
  639. return false;
  640. }
  641. }
  642. /**
  643. * This is a unified interface for event plugins to be installed and configured.
  644. *
  645. * Event plugins can implement the following properties:
  646. *
  647. * `extractEvents` {function(string, DOMEventTarget, string, object): *}
  648. * Required. When a top-level event is fired, this method is expected to
  649. * extract synthetic events that will in turn be queued and dispatched.
  650. *
  651. * `eventTypes` {object}
  652. * Optional, plugins that fire events must publish a mapping of registration
  653. * names that are used to register listeners. Values of this mapping must
  654. * be objects that contain `registrationName` or `phasedRegistrationNames`.
  655. *
  656. * `executeDispatch` {function(object, function, string)}
  657. * Optional, allows plugins to override how an event gets dispatched. By
  658. * default, the listener is simply invoked.
  659. *
  660. * Each plugin that is injected into `EventsPluginHub` is immediately operable.
  661. *
  662. * @public
  663. */
  664. /**
  665. * Methods for injecting dependencies.
  666. */
  667. var injection = {
  668. /**
  669. * @param {array} InjectedEventPluginOrder
  670. * @public
  671. */
  672. injectEventPluginOrder: injectEventPluginOrder,
  673. /**
  674. * @param {object} injectedNamesToPlugins Map from names to plugin modules.
  675. */
  676. injectEventPluginsByName: injectEventPluginsByName
  677. };
  678. /**
  679. * @param {object} inst The instance, which is the source of events.
  680. * @param {string} registrationName Name of listener (e.g. `onClick`).
  681. * @return {?function} The stored callback.
  682. */
  683. function getListener(inst, registrationName) {
  684. var listener; // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not
  685. // live here; needs to be moved to a better place soon
  686. var stateNode = inst.stateNode;
  687. if (!stateNode) {
  688. // Work in progress (ex: onload events in incremental mode).
  689. return null;
  690. }
  691. var props = getFiberCurrentPropsFromNode(stateNode);
  692. if (!props) {
  693. // Work in progress.
  694. return null;
  695. }
  696. listener = props[registrationName];
  697. if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
  698. return null;
  699. }
  700. if (!(!listener || typeof listener === 'function')) {
  701. {
  702. throw Error("Expected `" + registrationName + "` listener to be a function, instead got a value of `" + typeof listener + "` type.");
  703. }
  704. }
  705. return listener;
  706. }
  707. /**
  708. * Allows registered plugins an opportunity to extract events from top-level
  709. * native browser events.
  710. *
  711. * @return {*} An accumulation of synthetic events.
  712. * @internal
  713. */
  714. function extractPluginEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) {
  715. var events = null;
  716. for (var i = 0; i < plugins.length; i++) {
  717. // Not every plugin in the ordering may be loaded at runtime.
  718. var possiblePlugin = plugins[i];
  719. if (possiblePlugin) {
  720. var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags);
  721. if (extractedEvents) {
  722. events = accumulateInto(events, extractedEvents);
  723. }
  724. }
  725. }
  726. return events;
  727. }
  728. function runExtractedPluginEventsInBatch(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) {
  729. var events = extractPluginEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags);
  730. runEventsInBatch(events);
  731. }
  732. var FunctionComponent = 0;
  733. var ClassComponent = 1;
  734. var IndeterminateComponent = 2; // Before we know whether it is function or class
  735. var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
  736. var HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
  737. var HostComponent = 5;
  738. var HostText = 6;
  739. var Fragment = 7;
  740. var Mode = 8;
  741. var ContextConsumer = 9;
  742. var ContextProvider = 10;
  743. var ForwardRef = 11;
  744. var Profiler = 12;
  745. var SuspenseComponent = 13;
  746. var MemoComponent = 14;
  747. var SimpleMemoComponent = 15;
  748. var LazyComponent = 16;
  749. var IncompleteClassComponent = 17;
  750. var DehydratedFragment = 18;
  751. var SuspenseListComponent = 19;
  752. var FundamentalComponent = 20;
  753. var ScopeComponent = 21;
  754. var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions.
  755. // Current owner and dispatcher used to share the same ref,
  756. // but PR #14548 split them out to better support the react-debug-tools package.
  757. if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
  758. ReactSharedInternals.ReactCurrentDispatcher = {
  759. current: null
  760. };
  761. }
  762. if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
  763. ReactSharedInternals.ReactCurrentBatchConfig = {
  764. suspense: null
  765. };
  766. }
  767. var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
  768. var describeComponentFrame = function (name, source, ownerName) {
  769. var sourceInfo = '';
  770. if (source) {
  771. var path = source.fileName;
  772. var fileName = path.replace(BEFORE_SLASH_RE, '');
  773. {
  774. // In DEV, include code for a common special case:
  775. // prefer "folder/index.js" instead of just "index.js".
  776. if (/^index\./.test(fileName)) {
  777. var match = path.match(BEFORE_SLASH_RE);
  778. if (match) {
  779. var pathBeforeSlash = match[1];
  780. if (pathBeforeSlash) {
  781. var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
  782. fileName = folderName + '/' + fileName;
  783. }
  784. }
  785. }
  786. }
  787. sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
  788. } else if (ownerName) {
  789. sourceInfo = ' (created by ' + ownerName + ')';
  790. }
  791. return '\n in ' + (name || 'Unknown') + sourceInfo;
  792. };
  793. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  794. // nor polyfill, then a plain number is used for performance.
  795. var hasSymbol = typeof Symbol === 'function' && Symbol.for;
  796. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
  797. var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
  798. var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
  799. var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
  800. var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
  801. var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
  802. var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
  803. // (unstable) APIs that have been removed. Can we remove the symbols?
  804. var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
  805. var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
  806. var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
  807. var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
  808. var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
  809. var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
  810. var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
  811. var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
  812. var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
  813. var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  814. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  815. function getIteratorFn(maybeIterable) {
  816. if (maybeIterable === null || typeof maybeIterable !== 'object') {
  817. return null;
  818. }
  819. var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
  820. if (typeof maybeIterator === 'function') {
  821. return maybeIterator;
  822. }
  823. return null;
  824. }
  825. /**
  826. * Similar to invariant but only logs a warning if the condition is not met.
  827. * This can be used to log issues in development environments in critical
  828. * paths. Removing the logging code for production environments will keep the
  829. * same logic and follow the same code paths.
  830. */
  831. var warning = warningWithoutStack$1;
  832. {
  833. warning = function (condition, format) {
  834. if (condition) {
  835. return;
  836. }
  837. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  838. var stack = ReactDebugCurrentFrame.getStackAddendum(); // eslint-disable-next-line react-internal/warning-and-invariant-args
  839. for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  840. args[_key - 2] = arguments[_key];
  841. }
  842. warningWithoutStack$1.apply(void 0, [false, format + '%s'].concat(args, [stack]));
  843. };
  844. }
  845. var warning$1 = warning;
  846. var Uninitialized = -1;
  847. var Pending = 0;
  848. var Resolved = 1;
  849. var Rejected = 2;
  850. function refineResolvedLazyComponent(lazyComponent) {
  851. return lazyComponent._status === Resolved ? lazyComponent._result : null;
  852. }
  853. function initializeLazyComponentType(lazyComponent) {
  854. if (lazyComponent._status === Uninitialized) {
  855. lazyComponent._status = Pending;
  856. var ctor = lazyComponent._ctor;
  857. var thenable = ctor();
  858. lazyComponent._result = thenable;
  859. thenable.then(function (moduleObject) {
  860. if (lazyComponent._status === Pending) {
  861. var defaultExport = moduleObject.default;
  862. {
  863. if (defaultExport === undefined) {
  864. warning$1(false, 'lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + "const MyComponent = lazy(() => import('./MyComponent'))", moduleObject);
  865. }
  866. }
  867. lazyComponent._status = Resolved;
  868. lazyComponent._result = defaultExport;
  869. }
  870. }, function (error) {
  871. if (lazyComponent._status === Pending) {
  872. lazyComponent._status = Rejected;
  873. lazyComponent._result = error;
  874. }
  875. });
  876. }
  877. }
  878. function getWrappedName(outerType, innerType, wrapperName) {
  879. var functionName = innerType.displayName || innerType.name || '';
  880. return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
  881. }
  882. function getComponentName(type) {
  883. if (type == null) {
  884. // Host root, text node or just invalid type.
  885. return null;
  886. }
  887. {
  888. if (typeof type.tag === 'number') {
  889. warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
  890. }
  891. }
  892. if (typeof type === 'function') {
  893. return type.displayName || type.name || null;
  894. }
  895. if (typeof type === 'string') {
  896. return type;
  897. }
  898. switch (type) {
  899. case REACT_FRAGMENT_TYPE:
  900. return 'Fragment';
  901. case REACT_PORTAL_TYPE:
  902. return 'Portal';
  903. case REACT_PROFILER_TYPE:
  904. return "Profiler";
  905. case REACT_STRICT_MODE_TYPE:
  906. return 'StrictMode';
  907. case REACT_SUSPENSE_TYPE:
  908. return 'Suspense';
  909. case REACT_SUSPENSE_LIST_TYPE:
  910. return 'SuspenseList';
  911. }
  912. if (typeof type === 'object') {
  913. switch (type.$$typeof) {
  914. case REACT_CONTEXT_TYPE:
  915. return 'Context.Consumer';
  916. case REACT_PROVIDER_TYPE:
  917. return 'Context.Provider';
  918. case REACT_FORWARD_REF_TYPE:
  919. return getWrappedName(type, type.render, 'ForwardRef');
  920. case REACT_MEMO_TYPE:
  921. return getComponentName(type.type);
  922. case REACT_LAZY_TYPE:
  923. {
  924. var thenable = type;
  925. var resolvedThenable = refineResolvedLazyComponent(thenable);
  926. if (resolvedThenable) {
  927. return getComponentName(resolvedThenable);
  928. }
  929. break;
  930. }
  931. }
  932. }
  933. return null;
  934. }
  935. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  936. function describeFiber(fiber) {
  937. switch (fiber.tag) {
  938. case HostRoot:
  939. case HostPortal:
  940. case HostText:
  941. case Fragment:
  942. case ContextProvider:
  943. case ContextConsumer:
  944. return '';
  945. default:
  946. var owner = fiber._debugOwner;
  947. var source = fiber._debugSource;
  948. var name = getComponentName(fiber.type);
  949. var ownerName = null;
  950. if (owner) {
  951. ownerName = getComponentName(owner.type);
  952. }
  953. return describeComponentFrame(name, source, ownerName);
  954. }
  955. }
  956. function getStackByFiberInDevAndProd(workInProgress) {
  957. var info = '';
  958. var node = workInProgress;
  959. do {
  960. info += describeFiber(node);
  961. node = node.return;
  962. } while (node);
  963. return info;
  964. }
  965. var current = null;
  966. var phase = null;
  967. function getCurrentFiberOwnerNameInDevOrNull() {
  968. {
  969. if (current === null) {
  970. return null;
  971. }
  972. var owner = current._debugOwner;
  973. if (owner !== null && typeof owner !== 'undefined') {
  974. return getComponentName(owner.type);
  975. }
  976. }
  977. return null;
  978. }
  979. function getCurrentFiberStackInDev() {
  980. {
  981. if (current === null) {
  982. return '';
  983. } // Safe because if current fiber exists, we are reconciling,
  984. // and it is guaranteed to be the work-in-progress version.
  985. return getStackByFiberInDevAndProd(current);
  986. }
  987. return '';
  988. }
  989. function resetCurrentFiber() {
  990. {
  991. ReactDebugCurrentFrame.getCurrentStack = null;
  992. current = null;
  993. phase = null;
  994. }
  995. }
  996. function setCurrentFiber(fiber) {
  997. {
  998. ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev;
  999. current = fiber;
  1000. phase = null;
  1001. }
  1002. }
  1003. function setCurrentPhase(lifeCyclePhase) {
  1004. {
  1005. phase = lifeCyclePhase;
  1006. }
  1007. }
  1008. var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
  1009. function endsWith(subject, search) {
  1010. var length = subject.length;
  1011. return subject.substring(length - search.length, length) === search;
  1012. }
  1013. var PLUGIN_EVENT_SYSTEM = 1;
  1014. var RESPONDER_EVENT_SYSTEM = 1 << 1;
  1015. var IS_PASSIVE = 1 << 2;
  1016. var IS_ACTIVE = 1 << 3;
  1017. var PASSIVE_NOT_SUPPORTED = 1 << 4;
  1018. var IS_REPLAYED = 1 << 5;
  1019. var restoreImpl = null;
  1020. var restoreTarget = null;
  1021. var restoreQueue = null;
  1022. function restoreStateOfTarget(target) {
  1023. // We perform this translation at the end of the event loop so that we
  1024. // always receive the correct fiber here
  1025. var internalInstance = getInstanceFromNode(target);
  1026. if (!internalInstance) {
  1027. // Unmounted
  1028. return;
  1029. }
  1030. if (!(typeof restoreImpl === 'function')) {
  1031. {
  1032. throw Error("setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue.");
  1033. }
  1034. }
  1035. var props = getFiberCurrentPropsFromNode(internalInstance.stateNode);
  1036. restoreImpl(internalInstance.stateNode, internalInstance.type, props);
  1037. }
  1038. function setRestoreImplementation(impl) {
  1039. restoreImpl = impl;
  1040. }
  1041. function enqueueStateRestore(target) {
  1042. if (restoreTarget) {
  1043. if (restoreQueue) {
  1044. restoreQueue.push(target);
  1045. } else {
  1046. restoreQueue = [target];
  1047. }
  1048. } else {
  1049. restoreTarget = target;
  1050. }
  1051. }
  1052. function needsStateRestore() {
  1053. return restoreTarget !== null || restoreQueue !== null;
  1054. }
  1055. function restoreStateIfNeeded() {
  1056. if (!restoreTarget) {
  1057. return;
  1058. }
  1059. var target = restoreTarget;
  1060. var queuedTargets = restoreQueue;
  1061. restoreTarget = null;
  1062. restoreQueue = null;
  1063. restoreStateOfTarget(target);
  1064. if (queuedTargets) {
  1065. for (var i = 0; i < queuedTargets.length; i++) {
  1066. restoreStateOfTarget(queuedTargets[i]);
  1067. }
  1068. }
  1069. }
  1070. var enableUserTimingAPI = true; // Helps identify side effects in render-phase lifecycle hooks and setState
  1071. // reducers by double invoking them in Strict Mode.
  1072. var debugRenderPhaseSideEffectsForStrictMode = true; // To preserve the "Pause on caught exceptions" behavior of the debugger, we
  1073. // replay the begin phase of a failed component inside invokeGuardedCallback.
  1074. var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
  1075. var warnAboutDeprecatedLifecycles = true; // Gather advanced timing metrics for Profiler subtrees.
  1076. var enableProfilerTimer = true; // Trace which interactions trigger each commit.
  1077. var enableSchedulerTracing = true; // SSR experiments
  1078. var enableSuspenseServerRenderer = false;
  1079. var enableSelectiveHydration = false; // Only used in www builds.
  1080. // Only used in www builds.
  1081. // Disable javascript: URL strings in href for XSS protection.
  1082. var disableJavaScriptURLs = false; // React Fire: prevent the value and checked attributes from syncing
  1083. // with their related DOM properties
  1084. var disableInputAttributeSyncing = false; // These APIs will no longer be "unstable" in the upcoming 16.7 release,
  1085. // Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
  1086. var exposeConcurrentModeAPIs = false;
  1087. var warnAboutShorthandPropertyCollision = false; // Experimental React Flare event system and event components support.
  1088. var enableFlareAPI = false; // Experimental Host Component support.
  1089. var enableFundamentalAPI = false; // Experimental Scope support.
  1090. var enableScopeAPI = false; // New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
  1091. // We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)
  1092. // Till then, we warn about the missing mock, but still fallback to a legacy mode compatible version
  1093. var warnAboutUnmockedScheduler = false; // For tests, we flush suspense fallbacks in an act scope;
  1094. // *except* in some of our own tests, where we test incremental loading states.
  1095. var flushSuspenseFallbacksInTests = true; // Add a callback property to suspense to notify which promises are currently
  1096. // in the update queue. This allows reporting and tracing of what is causing
  1097. // the user to see a loading state.
  1098. // Also allows hydration callbacks to fire when a dehydrated boundary gets
  1099. // hydrated or deleted.
  1100. var enableSuspenseCallback = false; // Part of the simplification of React.createElement so we can eventually move
  1101. // from React.createElement to React.jsx
  1102. // https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
  1103. var warnAboutDefaultPropsOnFunctionComponents = false;
  1104. var warnAboutStringRefs = false;
  1105. var disableLegacyContext = false;
  1106. var disableSchedulerTimeoutBasedOnReactExpirationTime = false;
  1107. var enableTrustedTypesIntegration = false; // Flag to turn event.target and event.currentTarget in ReactNative from a reactTag to a component instance
  1108. // the renderer. Such as when we're dispatching events or if third party
  1109. // libraries need to call batchedUpdates. Eventually, this API will go away when
  1110. // everything is batched by default. We'll then have a similar API to opt-out of
  1111. // scheduled work and instead do synchronous work.
  1112. // Defaults
  1113. var batchedUpdatesImpl = function (fn, bookkeeping) {
  1114. return fn(bookkeeping);
  1115. };
  1116. var discreteUpdatesImpl = function (fn, a, b, c) {
  1117. return fn(a, b, c);
  1118. };
  1119. var flushDiscreteUpdatesImpl = function () {};
  1120. var batchedEventUpdatesImpl = batchedUpdatesImpl;
  1121. var isInsideEventHandler = false;
  1122. var isBatchingEventUpdates = false;
  1123. function finishEventHandler() {
  1124. // Here we wait until all updates have propagated, which is important
  1125. // when using controlled components within layers:
  1126. // https://github.com/facebook/react/issues/1698
  1127. // Then we restore state of any controlled component.
  1128. var controlledComponentsHavePendingUpdates = needsStateRestore();
  1129. if (controlledComponentsHavePendingUpdates) {
  1130. // If a controlled event was fired, we may need to restore the state of
  1131. // the DOM node back to the controlled value. This is necessary when React
  1132. // bails out of the update without touching the DOM.
  1133. flushDiscreteUpdatesImpl();
  1134. restoreStateIfNeeded();
  1135. }
  1136. }
  1137. function batchedUpdates(fn, bookkeeping) {
  1138. if (isInsideEventHandler) {
  1139. // If we are currently inside another batch, we need to wait until it
  1140. // fully completes before restoring state.
  1141. return fn(bookkeeping);
  1142. }
  1143. isInsideEventHandler = true;
  1144. try {
  1145. return batchedUpdatesImpl(fn, bookkeeping);
  1146. } finally {
  1147. isInsideEventHandler = false;
  1148. finishEventHandler();
  1149. }
  1150. }
  1151. function batchedEventUpdates(fn, a, b) {
  1152. if (isBatchingEventUpdates) {
  1153. // If we are currently inside another batch, we need to wait until it
  1154. // fully completes before restoring state.
  1155. return fn(a, b);
  1156. }
  1157. isBatchingEventUpdates = true;
  1158. try {
  1159. return batchedEventUpdatesImpl(fn, a, b);
  1160. } finally {
  1161. isBatchingEventUpdates = false;
  1162. finishEventHandler();
  1163. }
  1164. } // This is for the React Flare event system
  1165. function executeUserEventHandler(fn, value) {
  1166. var previouslyInEventHandler = isInsideEventHandler;
  1167. try {
  1168. isInsideEventHandler = true;
  1169. var type = typeof value === 'object' && value !== null ? value.type : '';
  1170. invokeGuardedCallbackAndCatchFirstError(type, fn, undefined, value);
  1171. } finally {
  1172. isInsideEventHandler = previouslyInEventHandler;
  1173. }
  1174. }
  1175. function discreteUpdates(fn, a, b, c) {
  1176. var prevIsInsideEventHandler = isInsideEventHandler;
  1177. isInsideEventHandler = true;
  1178. try {
  1179. return discreteUpdatesImpl(fn, a, b, c);
  1180. } finally {
  1181. isInsideEventHandler = prevIsInsideEventHandler;
  1182. if (!isInsideEventHandler) {
  1183. finishEventHandler();
  1184. }
  1185. }
  1186. }
  1187. var lastFlushedEventTimeStamp = 0;
  1188. function flushDiscreteUpdatesIfNeeded(timeStamp) {
  1189. // event.timeStamp isn't overly reliable due to inconsistencies in
  1190. // how different browsers have historically provided the time stamp.
  1191. // Some browsers provide high-resolution time stamps for all events,
  1192. // some provide low-resolution time stamps for all events. FF < 52
  1193. // even mixes both time stamps together. Some browsers even report
  1194. // negative time stamps or time stamps that are 0 (iOS9) in some cases.
  1195. // Given we are only comparing two time stamps with equality (!==),
  1196. // we are safe from the resolution differences. If the time stamp is 0
  1197. // we bail-out of preventing the flush, which can affect semantics,
  1198. // such as if an earlier flush removes or adds event listeners that
  1199. // are fired in the subsequent flush. However, this is the same
  1200. // behaviour as we had before this change, so the risks are low.
  1201. if (!isInsideEventHandler && (!enableFlareAPI || timeStamp === 0 || lastFlushedEventTimeStamp !== timeStamp)) {
  1202. lastFlushedEventTimeStamp = timeStamp;
  1203. flushDiscreteUpdatesImpl();
  1204. }
  1205. }
  1206. function setBatchingImplementation(_batchedUpdatesImpl, _discreteUpdatesImpl, _flushDiscreteUpdatesImpl, _batchedEventUpdatesImpl) {
  1207. batchedUpdatesImpl = _batchedUpdatesImpl;
  1208. discreteUpdatesImpl = _discreteUpdatesImpl;
  1209. flushDiscreteUpdatesImpl = _flushDiscreteUpdatesImpl;
  1210. batchedEventUpdatesImpl = _batchedEventUpdatesImpl;
  1211. }
  1212. var DiscreteEvent = 0;
  1213. var UserBlockingEvent = 1;
  1214. var ContinuousEvent = 2;
  1215. // CommonJS interop named imports.
  1216. var UserBlockingPriority = Scheduler.unstable_UserBlockingPriority;
  1217. var runWithPriority = Scheduler.unstable_runWithPriority;
  1218. var listenToResponderEventTypesImpl;
  1219. function setListenToResponderEventTypes(_listenToResponderEventTypesImpl) {
  1220. listenToResponderEventTypesImpl = _listenToResponderEventTypesImpl;
  1221. }
  1222. var rootEventTypesToEventResponderInstances = new Map();
  1223. var DoNotPropagateToNextResponder = 0;
  1224. var PropagateToNextResponder = 1;
  1225. var currentTimeStamp = 0;
  1226. var currentInstance = null;
  1227. var currentDocument = null;
  1228. var currentPropagationBehavior = DoNotPropagateToNextResponder;
  1229. var eventResponderContext = {
  1230. dispatchEvent: function (eventValue, eventListener, eventPriority) {
  1231. validateResponderContext();
  1232. validateEventValue(eventValue);
  1233. switch (eventPriority) {
  1234. case DiscreteEvent:
  1235. {
  1236. flushDiscreteUpdatesIfNeeded(currentTimeStamp);
  1237. discreteUpdates(function () {
  1238. return executeUserEventHandler(eventListener, eventValue);
  1239. });
  1240. break;
  1241. }
  1242. case UserBlockingEvent:
  1243. {
  1244. runWithPriority(UserBlockingPriority, function () {
  1245. return executeUserEventHandler(eventListener, eventValue);
  1246. });
  1247. break;
  1248. }
  1249. case ContinuousEvent:
  1250. {
  1251. executeUserEventHandler(eventListener, eventValue);
  1252. break;
  1253. }
  1254. }
  1255. },
  1256. isTargetWithinResponder: function (target) {
  1257. validateResponderContext();
  1258. if (target != null) {
  1259. var fiber = getClosestInstanceFromNode(target);
  1260. var responderFiber = currentInstance.fiber;
  1261. while (fiber !== null) {
  1262. if (fiber === responderFiber || fiber.alternate === responderFiber) {
  1263. return true;
  1264. }
  1265. fiber = fiber.return;
  1266. }
  1267. }
  1268. return false;
  1269. },
  1270. isTargetWithinResponderScope: function (target) {
  1271. validateResponderContext();
  1272. var componentInstance = currentInstance;
  1273. var responder = componentInstance.responder;
  1274. if (target != null) {
  1275. var fiber = getClosestInstanceFromNode(target);
  1276. var responderFiber = currentInstance.fiber;
  1277. while (fiber !== null) {
  1278. if (fiber === responderFiber || fiber.alternate === responderFiber) {
  1279. return true;
  1280. }
  1281. if (doesFiberHaveResponder(fiber, responder)) {
  1282. return false;
  1283. }
  1284. fiber = fiber.return;
  1285. }
  1286. }
  1287. return false;
  1288. },
  1289. isTargetWithinNode: function (childTarget, parentTarget) {
  1290. validateResponderContext();
  1291. var childFiber = getClosestInstanceFromNode(childTarget);
  1292. var parentFiber = getClosestInstanceFromNode(parentTarget);
  1293. if (childFiber != null && parentFiber != null) {
  1294. var parentAlternateFiber = parentFiber.alternate;
  1295. var node = childFiber;
  1296. while (node !== null) {
  1297. if (node === parentFiber || node === parentAlternateFiber) {
  1298. return true;
  1299. }
  1300. node = node.return;
  1301. }
  1302. return false;
  1303. } // Fallback to DOM APIs
  1304. return parentTarget.contains(childTarget);
  1305. },
  1306. addRootEventTypes: function (rootEventTypes) {
  1307. validateResponderContext();
  1308. listenToResponderEventTypesImpl(rootEventTypes, currentDocument);
  1309. for (var i = 0; i < rootEventTypes.length; i++) {
  1310. var rootEventType = rootEventTypes[i];
  1311. var eventResponderInstance = currentInstance;
  1312. registerRootEventType(rootEventType, eventResponderInstance);
  1313. }
  1314. },
  1315. removeRootEventTypes: function (rootEventTypes) {
  1316. validateResponderContext();
  1317. for (var i = 0; i < rootEventTypes.length; i++) {
  1318. var rootEventType = rootEventTypes[i];
  1319. var rootEventResponders = rootEventTypesToEventResponderInstances.get(rootEventType);
  1320. var rootEventTypesSet = currentInstance.rootEventTypes;
  1321. if (rootEventTypesSet !== null) {
  1322. rootEventTypesSet.delete(rootEventType);
  1323. }
  1324. if (rootEventResponders !== undefined) {
  1325. rootEventResponders.delete(currentInstance);
  1326. }
  1327. }
  1328. },
  1329. getActiveDocument: getActiveDocument,
  1330. objectAssign: _assign,
  1331. getTimeStamp: function () {
  1332. validateResponderContext();
  1333. return currentTimeStamp;
  1334. },
  1335. isTargetWithinHostComponent: function (target, elementType) {
  1336. validateResponderContext();
  1337. var fiber = getClosestInstanceFromNode(target);
  1338. while (fiber !== null) {
  1339. if (fiber.tag === HostComponent && fiber.type === elementType) {
  1340. return true;
  1341. }
  1342. fiber = fiber.return;
  1343. }
  1344. return false;
  1345. },
  1346. continuePropagation: function () {
  1347. currentPropagationBehavior = PropagateToNextResponder;
  1348. },
  1349. enqueueStateRestore: enqueueStateRestore,
  1350. getResponderNode: function () {
  1351. validateResponderContext();
  1352. var responderFiber = currentInstance.fiber;
  1353. if (responderFiber.tag === ScopeComponent) {
  1354. return null;
  1355. }
  1356. return responderFiber.stateNode;
  1357. }
  1358. };
  1359. function validateEventValue(eventValue) {
  1360. if (typeof eventValue === 'object' && eventValue !== null) {
  1361. var target = eventValue.target,
  1362. type = eventValue.type,
  1363. timeStamp = eventValue.timeStamp;
  1364. if (target == null || type == null || timeStamp == null) {
  1365. throw new Error('context.dispatchEvent: "target", "timeStamp", and "type" fields on event object are required.');
  1366. }
  1367. var showWarning = function (name) {
  1368. {
  1369. warning$1(false, '%s is not available on event objects created from event responder modules (React Flare). ' + 'Try wrapping in a conditional, i.e. `if (event.type !== "press") { event.%s }`', name, name);
  1370. }
  1371. };
  1372. eventValue.isDefaultPrevented = function () {
  1373. {
  1374. showWarning('isDefaultPrevented()');
  1375. }
  1376. };
  1377. eventValue.isPropagationStopped = function () {
  1378. {
  1379. showWarning('isPropagationStopped()');
  1380. }
  1381. }; // $FlowFixMe: we don't need value, Flow thinks we do
  1382. Object.defineProperty(eventValue, 'nativeEvent', {
  1383. get: function () {
  1384. {
  1385. showWarning('nativeEvent');
  1386. }
  1387. }
  1388. });
  1389. }
  1390. }
  1391. function doesFiberHaveResponder(fiber, responder) {
  1392. var tag = fiber.tag;
  1393. if (tag === HostComponent || tag === ScopeComponent) {
  1394. var dependencies = fiber.dependencies;
  1395. if (dependencies !== null) {
  1396. var respondersMap = dependencies.responders;
  1397. if (respondersMap !== null && respondersMap.has(responder)) {
  1398. return true;
  1399. }
  1400. }
  1401. }
  1402. return false;
  1403. }
  1404. function getActiveDocument() {
  1405. return currentDocument;
  1406. }
  1407. function createDOMResponderEvent(topLevelType, nativeEvent, nativeEventTarget, passive, passiveSupported) {
  1408. var _ref = nativeEvent,
  1409. buttons = _ref.buttons,
  1410. pointerType = _ref.pointerType;
  1411. var eventPointerType = '';
  1412. if (pointerType !== undefined) {
  1413. eventPointerType = pointerType;
  1414. } else if (nativeEvent.key !== undefined) {
  1415. eventPointerType = 'keyboard';
  1416. } else if (buttons !== undefined) {
  1417. eventPointerType = 'mouse';
  1418. } else if (nativeEvent.changedTouches !== undefined) {
  1419. eventPointerType = 'touch';
  1420. }
  1421. return {
  1422. nativeEvent: nativeEvent,
  1423. passive: passive,
  1424. passiveSupported: passiveSupported,
  1425. pointerType: eventPointerType,
  1426. target: nativeEventTarget,
  1427. type: topLevelType
  1428. };
  1429. }
  1430. function responderEventTypesContainType(eventTypes, type) {
  1431. for (var i = 0, len = eventTypes.length; i < len; i++) {
  1432. if (eventTypes[i] === type) {
  1433. return true;
  1434. }
  1435. }
  1436. return false;
  1437. }
  1438. function validateResponderTargetEventTypes(eventType, responder) {
  1439. var targetEventTypes = responder.targetEventTypes; // Validate the target event type exists on the responder
  1440. if (targetEventTypes !== null) {
  1441. return responderEventTypesContainType(targetEventTypes, eventType);
  1442. }
  1443. return false;
  1444. }
  1445. function traverseAndHandleEventResponderInstances(topLevelType, targetFiber, nativeEvent, nativeEventTarget, eventSystemFlags) {
  1446. var isPassiveEvent = (eventSystemFlags & IS_PASSIVE) !== 0;
  1447. var isPassiveSupported = (eventSystemFlags & PASSIVE_NOT_SUPPORTED) === 0;
  1448. var isPassive = isPassiveEvent || !isPassiveSupported;
  1449. var eventType = isPassive ? topLevelType : topLevelType + '_active'; // Trigger event responders in this order:
  1450. // - Bubble target responder phase
  1451. // - Root responder phase
  1452. var visitedResponders = new Set();
  1453. var responderEvent = createDOMResponderEvent(topLevelType, nativeEvent, nativeEventTarget, isPassiveEvent, isPassiveSupported);
  1454. var node = targetFiber;
  1455. var insidePortal = false;
  1456. while (node !== null) {
  1457. var _node = node,
  1458. dependencies = _node.dependencies,
  1459. tag = _node.tag;
  1460. if (tag === HostPortal) {
  1461. insidePortal = true;
  1462. } else if ((tag === HostComponent || tag === ScopeComponent) && dependencies !== null) {
  1463. var respondersMap = dependencies.responders;
  1464. if (respondersMap !== null) {
  1465. var responderInstances = Array.from(respondersMap.values());
  1466. for (var i = 0, length = responderInstances.length; i < length; i++) {
  1467. var responderInstance = responderInstances[i];
  1468. var props = responderInstance.props,
  1469. responder = responderInstance.responder,
  1470. state = responderInstance.state;
  1471. if (!visitedResponders.has(responder) && validateResponderTargetEventTypes(eventType, responder) && (!insidePortal || responder.targetPortalPropagation)) {
  1472. visitedResponders.add(responder);
  1473. var onEvent = responder.onEvent;
  1474. if (onEvent !== null) {
  1475. currentInstance = responderInstance;
  1476. onEvent(responderEvent, eventResponderContext, props, state);
  1477. if (currentPropagationBehavior === PropagateToNextResponder) {
  1478. visitedResponders.delete(responder);
  1479. currentPropagationBehavior = DoNotPropagateToNextResponder;
  1480. }
  1481. }
  1482. }
  1483. }
  1484. }
  1485. }
  1486. node = node.return;
  1487. } // Root phase
  1488. var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get(eventType);
  1489. if (rootEventResponderInstances !== undefined) {
  1490. var _responderInstances = Array.from(rootEventResponderInstances);
  1491. for (var _i = 0; _i < _responderInstances.length; _i++) {
  1492. var _responderInstance = _responderInstances[_i];
  1493. var props = _responderInstance.props,
  1494. responder = _responderInstance.responder,
  1495. state = _responderInstance.state;
  1496. var onRootEvent = responder.onRootEvent;
  1497. if (onRootEvent !== null) {
  1498. currentInstance = _responderInstance;
  1499. onRootEvent(responderEvent, eventResponderContext, props, state);
  1500. }
  1501. }
  1502. }
  1503. }
  1504. function mountEventResponder(responder, responderInstance, props, state) {
  1505. var onMount = responder.onMount;
  1506. if (onMount !== null) {
  1507. var previousInstance = currentInstance;
  1508. currentInstance = responderInstance;
  1509. try {
  1510. batchedEventUpdates(function () {
  1511. onMount(eventResponderContext, props, state);
  1512. });
  1513. } finally {
  1514. currentInstance = previousInstance;
  1515. }
  1516. }
  1517. }
  1518. function unmountEventResponder(responderInstance) {
  1519. var responder = responderInstance.responder;
  1520. var onUnmount = responder.onUnmount;
  1521. if (onUnmount !== null) {
  1522. var props = responderInstance.props,
  1523. state = responderInstance.state;
  1524. var previousInstance = currentInstance;
  1525. currentInstance = responderInstance;
  1526. try {
  1527. batchedEventUpdates(function () {
  1528. onUnmount(eventResponderContext, props, state);
  1529. });
  1530. } finally {
  1531. currentInstance = previousInstance;
  1532. }
  1533. }
  1534. var rootEventTypesSet = responderInstance.rootEventTypes;
  1535. if (rootEventTypesSet !== null) {
  1536. var rootEventTypes = Array.from(rootEventTypesSet);
  1537. for (var i = 0; i < rootEventTypes.length; i++) {
  1538. var topLevelEventType = rootEventTypes[i];
  1539. var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get(topLevelEventType);
  1540. if (rootEventResponderInstances !== undefined) {
  1541. rootEventResponderInstances.delete(responderInstance);
  1542. }
  1543. }
  1544. }
  1545. }
  1546. function validateResponderContext() {
  1547. if (!(currentInstance !== null)) {
  1548. {
  1549. throw Error("An event responder context was used outside of an event cycle.");
  1550. }
  1551. }
  1552. }
  1553. function dispatchEventForResponderEventSystem(topLevelType, targetFiber, nativeEvent, nativeEventTarget, eventSystemFlags) {
  1554. if (enableFlareAPI) {
  1555. var previousInstance = currentInstance;
  1556. var previousTimeStamp = currentTimeStamp;
  1557. var previousDocument = currentDocument;
  1558. var previousPropagationBehavior = currentPropagationBehavior;
  1559. currentPropagationBehavior = DoNotPropagateToNextResponder; // nodeType 9 is DOCUMENT_NODE
  1560. currentDocument = nativeEventTarget.nodeType === 9 ? nativeEventTarget : nativeEventTarget.ownerDocument; // We might want to control timeStamp another way here
  1561. currentTimeStamp = nativeEvent.timeStamp;
  1562. try {
  1563. batchedEventUpdates(function () {
  1564. traverseAndHandleEventResponderInstances(topLevelType, targetFiber, nativeEvent, nativeEventTarget, eventSystemFlags);
  1565. });
  1566. } finally {
  1567. currentInstance = previousInstance;
  1568. currentTimeStamp = previousTimeStamp;
  1569. currentDocument = previousDocument;
  1570. currentPropagationBehavior = previousPropagationBehavior;
  1571. }
  1572. }
  1573. }
  1574. function addRootEventTypesForResponderInstance(responderInstance, rootEventTypes) {
  1575. for (var i = 0; i < rootEventTypes.length; i++) {
  1576. var rootEventType = rootEventTypes[i];
  1577. registerRootEventType(rootEventType, responderInstance);
  1578. }
  1579. }
  1580. function registerRootEventType(rootEventType, eventResponderInstance) {
  1581. var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get(rootEventType);
  1582. if (rootEventResponderInstances === undefined) {
  1583. rootEventResponderInstances = new Set();
  1584. rootEventTypesToEventResponderInstances.set(rootEventType, rootEventResponderInstances);
  1585. }
  1586. var rootEventTypesSet = eventResponderInstance.rootEventTypes;
  1587. if (rootEventTypesSet === null) {
  1588. rootEventTypesSet = eventResponderInstance.rootEventTypes = new Set();
  1589. }
  1590. if (!!rootEventTypesSet.has(rootEventType)) {
  1591. {
  1592. throw Error("addRootEventTypes() found a duplicate root event type of \"" + rootEventType + "\". This might be because the event type exists in the event responder \"rootEventTypes\" array or because of a previous addRootEventTypes() using this root event type.");
  1593. }
  1594. }
  1595. rootEventTypesSet.add(rootEventType);
  1596. rootEventResponderInstances.add(eventResponderInstance);
  1597. }
  1598. // A reserved attribute.
  1599. // It is handled by React separately and shouldn't be written to the DOM.
  1600. var RESERVED = 0; // A simple string attribute.
  1601. // Attributes that aren't in the whitelist are presumed to have this type.
  1602. var STRING = 1; // A string attribute that accepts booleans in React. In HTML, these are called
  1603. // "enumerated" attributes with "true" and "false" as possible values.
  1604. // When true, it should be set to a "true" string.
  1605. // When false, it should be set to a "false" string.
  1606. var BOOLEANISH_STRING = 2; // A real boolean attribute.
  1607. // When true, it should be present (set either to an empty string or its name).
  1608. // When false, it should be omitted.
  1609. var BOOLEAN = 3; // An attribute that can be used as a flag as well as with a value.
  1610. // When true, it should be present (set either to an empty string or its name).
  1611. // When false, it should be omitted.
  1612. // For any other value, should be present with that value.
  1613. var OVERLOADED_BOOLEAN = 4; // An attribute that must be numeric or parse as a numeric.
  1614. // When falsy, it should be removed.
  1615. var NUMERIC = 5; // An attribute that must be positive numeric or parse as a positive numeric.
  1616. // When falsy, it should be removed.
  1617. var POSITIVE_NUMERIC = 6;
  1618. /* eslint-disable max-len */
  1619. var ATTRIBUTE_NAME_START_CHAR = ":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
  1620. /* eslint-enable max-len */
  1621. var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
  1622. var ROOT_ATTRIBUTE_NAME = 'data-reactroot';
  1623. var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$');
  1624. var hasOwnProperty = Object.prototype.hasOwnProperty;
  1625. var illegalAttributeNameCache = {};
  1626. var validatedAttributeNameCache = {};
  1627. function isAttributeNameSafe(attributeName) {
  1628. if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) {
  1629. return true;
  1630. }
  1631. if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) {
  1632. return false;
  1633. }
  1634. if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
  1635. validatedAttributeNameCache[attributeName] = true;
  1636. return true;
  1637. }
  1638. illegalAttributeNameCache[attributeName] = true;
  1639. {
  1640. warning$1(false, 'Invalid attribute name: `%s`', attributeName);
  1641. }
  1642. return false;
  1643. }
  1644. function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) {
  1645. if (propertyInfo !== null) {
  1646. return propertyInfo.type === RESERVED;
  1647. }
  1648. if (isCustomComponentTag) {
  1649. return false;
  1650. }
  1651. if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) {
  1652. return true;
  1653. }
  1654. return false;
  1655. }
  1656. function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) {
  1657. if (propertyInfo !== null && propertyInfo.type === RESERVED) {
  1658. return false;
  1659. }
  1660. switch (typeof value) {
  1661. case 'function': // $FlowIssue symbol is perfectly valid here
  1662. case 'symbol':
  1663. // eslint-disable-line
  1664. return true;
  1665. case 'boolean':
  1666. {
  1667. if (isCustomComponentTag) {
  1668. return false;
  1669. }
  1670. if (propertyInfo !== null) {
  1671. return !propertyInfo.acceptsBooleans;
  1672. } else {
  1673. var prefix = name.toLowerCase().slice(0, 5);
  1674. return prefix !== 'data-' && prefix !== 'aria-';
  1675. }
  1676. }
  1677. default:
  1678. return false;
  1679. }
  1680. }
  1681. function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) {
  1682. if (value === null || typeof value === 'undefined') {
  1683. return true;
  1684. }
  1685. if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) {
  1686. return true;
  1687. }
  1688. if (isCustomComponentTag) {
  1689. return false;
  1690. }
  1691. if (propertyInfo !== null) {
  1692. switch (propertyInfo.type) {
  1693. case BOOLEAN:
  1694. return !value;
  1695. case OVERLOADED_BOOLEAN:
  1696. return value === false;
  1697. case NUMERIC:
  1698. return isNaN(value);
  1699. case POSITIVE_NUMERIC:
  1700. return isNaN(value) || value < 1;
  1701. }
  1702. }
  1703. return false;
  1704. }
  1705. function getPropertyInfo(name) {
  1706. return properties.hasOwnProperty(name) ? properties[name] : null;
  1707. }
  1708. function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL) {
  1709. this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN;
  1710. this.attributeName = attributeName;
  1711. this.attributeNamespace = attributeNamespace;
  1712. this.mustUseProperty = mustUseProperty;
  1713. this.propertyName = name;
  1714. this.type = type;
  1715. this.sanitizeURL = sanitizeURL;
  1716. } // When adding attributes to this list, be sure to also add them to
  1717. // the `possibleStandardNames` module to ensure casing and incorrect
  1718. // name warnings.
  1719. var properties = {}; // These props are reserved by React. They shouldn't be written to the DOM.
  1720. ['children', 'dangerouslySetInnerHTML', // TODO: This prevents the assignment of defaultValue to regular
  1721. // elements (not just inputs). Now that ReactDOMInput assigns to the
  1722. // defaultValue property -- do we need this?
  1723. 'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style'].forEach(function (name) {
  1724. properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty
  1725. name, // attributeName
  1726. null, // attributeNamespace
  1727. false);
  1728. }); // A few React string attributes have a different name.
  1729. // This is a mapping from React prop names to the attribute names.
  1730. [['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) {
  1731. var name = _ref[0],
  1732. attributeName = _ref[1];
  1733. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  1734. attributeName, // attributeName
  1735. null, // attributeNamespace
  1736. false);
  1737. }); // These are "enumerated" HTML attributes that accept "true" and "false".
  1738. // In React, we let users pass `true` and `false` even though technically
  1739. // these aren't boolean attributes (they are coerced to strings).
  1740. ['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) {
  1741. properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
  1742. name.toLowerCase(), // attributeName
  1743. null, // attributeNamespace
  1744. false);
  1745. }); // These are "enumerated" SVG attributes that accept "true" and "false".
  1746. // In React, we let users pass `true` and `false` even though technically
  1747. // these aren't boolean attributes (they are coerced to strings).
  1748. // Since these are SVG attributes, their attribute names are case-sensitive.
  1749. ['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) {
  1750. properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
  1751. name, // attributeName
  1752. null, // attributeNamespace
  1753. false);
  1754. }); // These are HTML boolean attributes.
  1755. ['allowFullScreen', 'async', // Note: there is a special case that prevents it from being written to the DOM
  1756. // on the client side because the browsers are inconsistent. Instead we call focus().
  1757. 'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', // Microdata
  1758. 'itemScope'].forEach(function (name) {
  1759. properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty
  1760. name.toLowerCase(), // attributeName
  1761. null, // attributeNamespace
  1762. false);
  1763. }); // These are the few React props that we set as DOM properties
  1764. // rather than attributes. These are all booleans.
  1765. ['checked', // Note: `option.selected` is not updated if `select.multiple` is
  1766. // disabled with `removeAttribute`. We have special logic for handling this.
  1767. 'multiple', 'muted', 'selected'].forEach(function (name) {
  1768. properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty
  1769. name, // attributeName
  1770. null, // attributeNamespace
  1771. false);
  1772. }); // These are HTML attributes that are "overloaded booleans": they behave like
  1773. // booleans, but can also accept a string value.
  1774. ['capture', 'download'].forEach(function (name) {
  1775. properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty
  1776. name, // attributeName
  1777. null, // attributeNamespace
  1778. false);
  1779. }); // These are HTML attributes that must be positive numbers.
  1780. ['cols', 'rows', 'size', 'span'].forEach(function (name) {
  1781. properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty
  1782. name, // attributeName
  1783. null, // attributeNamespace
  1784. false);
  1785. }); // These are HTML attributes that must be numbers.
  1786. ['rowSpan', 'start'].forEach(function (name) {
  1787. properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty
  1788. name.toLowerCase(), // attributeName
  1789. null, // attributeNamespace
  1790. false);
  1791. });
  1792. var CAMELIZE = /[\-\:]([a-z])/g;
  1793. var capitalize = function (token) {
  1794. return token[1].toUpperCase();
  1795. }; // This is a list of all SVG attributes that need special casing, namespacing,
  1796. // or boolean value assignment. Regular attributes that just accept strings
  1797. // and have the same names are omitted, just like in the HTML whitelist.
  1798. // Some of these attributes can be hard to find. This list was created by
  1799. // scrapping the MDN documentation.
  1800. ['accent-height', 'alignment-baseline', 'arabic-form', 'baseline-shift', 'cap-height', 'clip-path', 'clip-rule', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'dominant-baseline', 'enable-background', 'fill-opacity', 'fill-rule', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-name', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'horiz-adv-x', 'horiz-origin-x', 'image-rendering', 'letter-spacing', 'lighting-color', 'marker-end', 'marker-mid', 'marker-start', 'overline-position', 'overline-thickness', 'paint-order', 'panose-1', 'pointer-events', 'rendering-intent', 'shape-rendering', 'stop-color', 'stop-opacity', 'strikethrough-position', 'strikethrough-thickness', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-decoration', 'text-rendering', 'underline-position', 'underline-thickness', 'unicode-bidi', 'unicode-range', 'units-per-em', 'v-alphabetic', 'v-hanging', 'v-ideographic', 'v-mathematical', 'vector-effect', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'word-spacing', 'writing-mode', 'xmlns:xlink', 'x-height'].forEach(function (attributeName) {
  1801. var name = attributeName.replace(CAMELIZE, capitalize);
  1802. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  1803. attributeName, null, // attributeNamespace
  1804. false);
  1805. }); // String SVG attributes with the xlink namespace.
  1806. ['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type'].forEach(function (attributeName) {
  1807. var name = attributeName.replace(CAMELIZE, capitalize);
  1808. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  1809. attributeName, 'http://www.w3.org/1999/xlink', false);
  1810. }); // String SVG attributes with the xml namespace.
  1811. ['xml:base', 'xml:lang', 'xml:space'].forEach(function (attributeName) {
  1812. var name = attributeName.replace(CAMELIZE, capitalize);
  1813. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  1814. attributeName, 'http://www.w3.org/XML/1998/namespace', false);
  1815. }); // These attribute exists both in HTML and SVG.
  1816. // The attribute name is case-sensitive in SVG so we can't just use
  1817. // the React name like we do for attributes that exist only in HTML.
  1818. ['tabIndex', 'crossOrigin'].forEach(function (attributeName) {
  1819. properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
  1820. attributeName.toLowerCase(), // attributeName
  1821. null, // attributeNamespace
  1822. false);
  1823. }); // These attributes accept URLs. These must not allow javascript: URLS.
  1824. // These will also need to accept Trusted Types object in the future.
  1825. var xlinkHref = 'xlinkHref';
  1826. properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty
  1827. 'xlink:href', 'http://www.w3.org/1999/xlink', true);
  1828. ['src', 'href', 'action', 'formAction'].forEach(function (attributeName) {
  1829. properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
  1830. attributeName.toLowerCase(), // attributeName
  1831. null, // attributeNamespace
  1832. true);
  1833. });
  1834. var ReactDebugCurrentFrame$1 = null;
  1835. {
  1836. ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
  1837. } // A javascript: URL can contain leading C0 control or \u0020 SPACE,
  1838. // and any newline or tab are filtered out as if they're not part of the URL.
  1839. // https://url.spec.whatwg.org/#url-parsing
  1840. // Tab or newline are defined as \r\n\t:
  1841. // https://infra.spec.whatwg.org/#ascii-tab-or-newline
  1842. // A C0 control is a code point in the range \u0000 NULL to \u001F
  1843. // INFORMATION SEPARATOR ONE, inclusive:
  1844. // https://infra.spec.whatwg.org/#c0-control-or-space
  1845. /* eslint-disable max-len */
  1846. var isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i;
  1847. var didWarn = false;
  1848. function sanitizeURL(url) {
  1849. if (disableJavaScriptURLs) {
  1850. if (!!isJavaScriptProtocol.test(url)) {
  1851. {
  1852. throw Error("React has blocked a javascript: URL as a security precaution." + (ReactDebugCurrentFrame$1.getStackAddendum()));
  1853. }
  1854. }
  1855. } else if (true && !didWarn && isJavaScriptProtocol.test(url)) {
  1856. didWarn = true;
  1857. warning$1(false, 'A future version of React will block javascript: URLs as a security precaution. ' + 'Use event handlers instead if you can. If you need to generate unsafe HTML try ' + 'using dangerouslySetInnerHTML instead. React was passed %s.', JSON.stringify(url));
  1858. }
  1859. }
  1860. // Flow does not allow string concatenation of most non-string types. To work
  1861. // around this limitation, we use an opaque type that can only be obtained by
  1862. // passing the value through getToStringValue first.
  1863. function toString(value) {
  1864. return '' + value;
  1865. }
  1866. function getToStringValue(value) {
  1867. switch (typeof value) {
  1868. case 'boolean':
  1869. case 'number':
  1870. case 'object':
  1871. case 'string':
  1872. case 'undefined':
  1873. return value;
  1874. default:
  1875. // function, symbol are assigned as empty strings
  1876. return '';
  1877. }
  1878. }
  1879. /** Trusted value is a wrapper for "safe" values which can be assigned to DOM execution sinks. */
  1880. /**
  1881. * We allow passing objects with toString method as element attributes or in dangerouslySetInnerHTML
  1882. * and we do validations that the value is safe. Once we do validation we want to use the validated
  1883. * value instead of the object (because object.toString may return something else on next call).
  1884. *
  1885. * If application uses Trusted Types we don't stringify trusted values, but preserve them as objects.
  1886. */
  1887. var toStringOrTrustedType = toString;
  1888. if (enableTrustedTypesIntegration && typeof trustedTypes !== 'undefined') {
  1889. toStringOrTrustedType = function (value) {
  1890. if (typeof value === 'object' && (trustedTypes.isHTML(value) || trustedTypes.isScript(value) || trustedTypes.isScriptURL(value) ||
  1891. /* TrustedURLs are deprecated and will be removed soon: https://github.com/WICG/trusted-types/pull/204 */
  1892. trustedTypes.isURL && trustedTypes.isURL(value))) {
  1893. // Pass Trusted Types through.
  1894. return value;
  1895. }
  1896. return toString(value);
  1897. };
  1898. }
  1899. /**
  1900. * Set attribute for a node. The attribute value can be either string or
  1901. * Trusted value (if application uses Trusted Types).
  1902. */
  1903. function setAttribute(node, attributeName, attributeValue) {
  1904. node.setAttribute(attributeName, attributeValue);
  1905. }
  1906. /**
  1907. * Set attribute with namespace for a node. The attribute value can be either string or
  1908. * Trusted value (if application uses Trusted Types).
  1909. */
  1910. function setAttributeNS(node, attributeNamespace, attributeName, attributeValue) {
  1911. node.setAttributeNS(attributeNamespace, attributeName, attributeValue);
  1912. }
  1913. /**
  1914. * Get the value for a property on a node. Only used in DEV for SSR validation.
  1915. * The "expected" argument is used as a hint of what the expected value is.
  1916. * Some properties have multiple equivalent values.
  1917. */
  1918. function getValueForProperty(node, name, expected, propertyInfo) {
  1919. {
  1920. if (propertyInfo.mustUseProperty) {
  1921. var propertyName = propertyInfo.propertyName;
  1922. return node[propertyName];
  1923. } else {
  1924. if (!disableJavaScriptURLs && propertyInfo.sanitizeURL) {
  1925. // If we haven't fully disabled javascript: URLs, and if
  1926. // the hydration is successful of a javascript: URL, we
  1927. // still want to warn on the client.
  1928. sanitizeURL('' + expected);
  1929. }
  1930. var attributeName = propertyInfo.attributeName;
  1931. var stringValue = null;
  1932. if (propertyInfo.type === OVERLOADED_BOOLEAN) {
  1933. if (node.hasAttribute(attributeName)) {
  1934. var value = node.getAttribute(attributeName);
  1935. if (value === '') {
  1936. return true;
  1937. }
  1938. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  1939. return value;
  1940. }
  1941. if (value === '' + expected) {
  1942. return expected;
  1943. }
  1944. return value;
  1945. }
  1946. } else if (node.hasAttribute(attributeName)) {
  1947. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  1948. // We had an attribute but shouldn't have had one, so read it
  1949. // for the error message.
  1950. return node.getAttribute(attributeName);
  1951. }
  1952. if (propertyInfo.type === BOOLEAN) {
  1953. // If this was a boolean, it doesn't matter what the value is
  1954. // the fact that we have it is the same as the expected.
  1955. return expected;
  1956. } // Even if this property uses a namespace we use getAttribute
  1957. // because we assume its namespaced name is the same as our config.
  1958. // To use getAttributeNS we need the local name which we don't have
  1959. // in our config atm.
  1960. stringValue = node.getAttribute(attributeName);
  1961. }
  1962. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  1963. return stringValue === null ? expected : stringValue;
  1964. } else if (stringValue === '' + expected) {
  1965. return expected;
  1966. } else {
  1967. return stringValue;
  1968. }
  1969. }
  1970. }
  1971. }
  1972. /**
  1973. * Get the value for a attribute on a node. Only used in DEV for SSR validation.
  1974. * The third argument is used as a hint of what the expected value is. Some
  1975. * attributes have multiple equivalent values.
  1976. */
  1977. function getValueForAttribute(node, name, expected) {
  1978. {
  1979. if (!isAttributeNameSafe(name)) {
  1980. return;
  1981. }
  1982. if (!node.hasAttribute(name)) {
  1983. return expected === undefined ? undefined : null;
  1984. }
  1985. var value = node.getAttribute(name);
  1986. if (value === '' + expected) {
  1987. return expected;
  1988. }
  1989. return value;
  1990. }
  1991. }
  1992. /**
  1993. * Sets the value for a property on a node.
  1994. *
  1995. * @param {DOMElement} node
  1996. * @param {string} name
  1997. * @param {*} value
  1998. */
  1999. function setValueForProperty(node, name, value, isCustomComponentTag) {
  2000. var propertyInfo = getPropertyInfo(name);
  2001. if (shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag)) {
  2002. return;
  2003. }
  2004. if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) {
  2005. value = null;
  2006. } // If the prop isn't in the special list, treat it as a simple attribute.
  2007. if (isCustomComponentTag || propertyInfo === null) {
  2008. if (isAttributeNameSafe(name)) {
  2009. var _attributeName = name;
  2010. if (value === null) {
  2011. node.removeAttribute(_attributeName);
  2012. } else {
  2013. setAttribute(node, _attributeName, toStringOrTrustedType(value));
  2014. }
  2015. }
  2016. return;
  2017. }
  2018. var mustUseProperty = propertyInfo.mustUseProperty;
  2019. if (mustUseProperty) {
  2020. var propertyName = propertyInfo.propertyName;
  2021. if (value === null) {
  2022. var type = propertyInfo.type;
  2023. node[propertyName] = type === BOOLEAN ? false : '';
  2024. } else {
  2025. // Contrary to `setAttribute`, object properties are properly
  2026. // `toString`ed by IE8/9.
  2027. node[propertyName] = value;
  2028. }
  2029. return;
  2030. } // The rest are treated as attributes with special cases.
  2031. var attributeName = propertyInfo.attributeName,
  2032. attributeNamespace = propertyInfo.attributeNamespace;
  2033. if (value === null) {
  2034. node.removeAttribute(attributeName);
  2035. } else {
  2036. var _type = propertyInfo.type;
  2037. var attributeValue;
  2038. if (_type === BOOLEAN || _type === OVERLOADED_BOOLEAN && value === true) {
  2039. // If attribute type is boolean, we know for sure it won't be an execution sink
  2040. // and we won't require Trusted Type here.
  2041. attributeValue = '';
  2042. } else {
  2043. // `setAttribute` with objects becomes only `[object]` in IE8/9,
  2044. // ('' + value) makes it output the correct toString()-value.
  2045. attributeValue = toStringOrTrustedType(value);
  2046. if (propertyInfo.sanitizeURL) {
  2047. sanitizeURL(attributeValue.toString());
  2048. }
  2049. }
  2050. if (attributeNamespace) {
  2051. setAttributeNS(node, attributeNamespace, attributeName, attributeValue);
  2052. } else {
  2053. setAttribute(node, attributeName, attributeValue);
  2054. }
  2055. }
  2056. }
  2057. var ReactDebugCurrentFrame$2 = null;
  2058. var ReactControlledValuePropTypes = {
  2059. checkPropTypes: null
  2060. };
  2061. {
  2062. ReactDebugCurrentFrame$2 = ReactSharedInternals.ReactDebugCurrentFrame;
  2063. var hasReadOnlyValue = {
  2064. button: true,
  2065. checkbox: true,
  2066. image: true,
  2067. hidden: true,
  2068. radio: true,
  2069. reset: true,
  2070. submit: true
  2071. };
  2072. var propTypes = {
  2073. value: function (props, propName, componentName) {
  2074. if (hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled || props[propName] == null || enableFlareAPI && props.listeners) {
  2075. return null;
  2076. }
  2077. return new Error('You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
  2078. },
  2079. checked: function (props, propName, componentName) {
  2080. if (props.onChange || props.readOnly || props.disabled || props[propName] == null || enableFlareAPI && props.listeners) {
  2081. return null;
  2082. }
  2083. return new Error('You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
  2084. }
  2085. };
  2086. /**
  2087. * Provide a linked `value` attribute for controlled forms. You should not use
  2088. * this outside of the ReactDOM controlled form components.
  2089. */
  2090. ReactControlledValuePropTypes.checkPropTypes = function (tagName, props) {
  2091. checkPropTypes(propTypes, props, 'prop', tagName, ReactDebugCurrentFrame$2.getStackAddendum);
  2092. };
  2093. }
  2094. function isCheckable(elem) {
  2095. var type = elem.type;
  2096. var nodeName = elem.nodeName;
  2097. return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio');
  2098. }
  2099. function getTracker(node) {
  2100. return node._valueTracker;
  2101. }
  2102. function detachTracker(node) {
  2103. node._valueTracker = null;
  2104. }
  2105. function getValueFromNode(node) {
  2106. var value = '';
  2107. if (!node) {
  2108. return value;
  2109. }
  2110. if (isCheckable(node)) {
  2111. value = node.checked ? 'true' : 'false';
  2112. } else {
  2113. value = node.value;
  2114. }
  2115. return value;
  2116. }
  2117. function trackValueOnNode(node) {
  2118. var valueField = isCheckable(node) ? 'checked' : 'value';
  2119. var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField);
  2120. var currentValue = '' + node[valueField]; // if someone has already defined a value or Safari, then bail
  2121. // and don't track value will cause over reporting of changes,
  2122. // but it's better then a hard failure
  2123. // (needed for certain tests that spyOn input values and Safari)
  2124. if (node.hasOwnProperty(valueField) || typeof descriptor === 'undefined' || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') {
  2125. return;
  2126. }
  2127. var get = descriptor.get,
  2128. set = descriptor.set;
  2129. Object.defineProperty(node, valueField, {
  2130. configurable: true,
  2131. get: function () {
  2132. return get.call(this);
  2133. },
  2134. set: function (value) {
  2135. currentValue = '' + value;
  2136. set.call(this, value);
  2137. }
  2138. }); // We could've passed this the first time
  2139. // but it triggers a bug in IE11 and Edge 14/15.
  2140. // Calling defineProperty() again should be equivalent.
  2141. // https://github.com/facebook/react/issues/11768
  2142. Object.defineProperty(node, valueField, {
  2143. enumerable: descriptor.enumerable
  2144. });
  2145. var tracker = {
  2146. getValue: function () {
  2147. return currentValue;
  2148. },
  2149. setValue: function (value) {
  2150. currentValue = '' + value;
  2151. },
  2152. stopTracking: function () {
  2153. detachTracker(node);
  2154. delete node[valueField];
  2155. }
  2156. };
  2157. return tracker;
  2158. }
  2159. function track(node) {
  2160. if (getTracker(node)) {
  2161. return;
  2162. } // TODO: Once it's just Fiber we can move this to node._wrapperState
  2163. node._valueTracker = trackValueOnNode(node);
  2164. }
  2165. function updateValueIfChanged(node) {
  2166. if (!node) {
  2167. return false;
  2168. }
  2169. var tracker = getTracker(node); // if there is no tracker at this point it's unlikely
  2170. // that trying again will succeed
  2171. if (!tracker) {
  2172. return true;
  2173. }
  2174. var lastValue = tracker.getValue();
  2175. var nextValue = getValueFromNode(node);
  2176. if (nextValue !== lastValue) {
  2177. tracker.setValue(nextValue);
  2178. return true;
  2179. }
  2180. return false;
  2181. }
  2182. // TODO: direct imports like some-package/src/* are bad. Fix me.
  2183. var didWarnValueDefaultValue = false;
  2184. var didWarnCheckedDefaultChecked = false;
  2185. var didWarnControlledToUncontrolled = false;
  2186. var didWarnUncontrolledToControlled = false;
  2187. function isControlled(props) {
  2188. var usesChecked = props.type === 'checkbox' || props.type === 'radio';
  2189. return usesChecked ? props.checked != null : props.value != null;
  2190. }
  2191. /**
  2192. * Implements an <input> host component that allows setting these optional
  2193. * props: `checked`, `value`, `defaultChecked`, and `defaultValue`.
  2194. *
  2195. * If `checked` or `value` are not supplied (or null/undefined), user actions
  2196. * that affect the checked state or value will trigger updates to the element.
  2197. *
  2198. * If they are supplied (and not null/undefined), the rendered element will not
  2199. * trigger updates to the element. Instead, the props must change in order for
  2200. * the rendered element to be updated.
  2201. *
  2202. * The rendered element will be initialized as unchecked (or `defaultChecked`)
  2203. * with an empty value (or `defaultValue`).
  2204. *
  2205. * See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html
  2206. */
  2207. function getHostProps(element, props) {
  2208. var node = element;
  2209. var checked = props.checked;
  2210. var hostProps = _assign({}, props, {
  2211. defaultChecked: undefined,
  2212. defaultValue: undefined,
  2213. value: undefined,
  2214. checked: checked != null ? checked : node._wrapperState.initialChecked
  2215. });
  2216. return hostProps;
  2217. }
  2218. function initWrapperState(element, props) {
  2219. {
  2220. ReactControlledValuePropTypes.checkPropTypes('input', props);
  2221. if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) {
  2222. warning$1(false, '%s contains an input of type %s with both checked and defaultChecked props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the checked prop, or the defaultChecked prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type);
  2223. didWarnCheckedDefaultChecked = true;
  2224. }
  2225. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) {
  2226. warning$1(false, '%s contains an input of type %s with both value and defaultValue props. ' + 'Input elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled input ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type);
  2227. didWarnValueDefaultValue = true;
  2228. }
  2229. }
  2230. var node = element;
  2231. var defaultValue = props.defaultValue == null ? '' : props.defaultValue;
  2232. node._wrapperState = {
  2233. initialChecked: props.checked != null ? props.checked : props.defaultChecked,
  2234. initialValue: getToStringValue(props.value != null ? props.value : defaultValue),
  2235. controlled: isControlled(props)
  2236. };
  2237. }
  2238. function updateChecked(element, props) {
  2239. var node = element;
  2240. var checked = props.checked;
  2241. if (checked != null) {
  2242. setValueForProperty(node, 'checked', checked, false);
  2243. }
  2244. }
  2245. function updateWrapper(element, props) {
  2246. var node = element;
  2247. {
  2248. var controlled = isControlled(props);
  2249. if (!node._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) {
  2250. warning$1(false, 'A component is changing an uncontrolled input of type %s to be controlled. ' + 'Input elements should not switch from uncontrolled to controlled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components', props.type);
  2251. didWarnUncontrolledToControlled = true;
  2252. }
  2253. if (node._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) {
  2254. warning$1(false, 'A component is changing a controlled input of type %s to be uncontrolled. ' + 'Input elements should not switch from controlled to uncontrolled (or vice versa). ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://fb.me/react-controlled-components', props.type);
  2255. didWarnControlledToUncontrolled = true;
  2256. }
  2257. }
  2258. updateChecked(element, props);
  2259. var value = getToStringValue(props.value);
  2260. var type = props.type;
  2261. if (value != null) {
  2262. if (type === 'number') {
  2263. if (value === 0 && node.value === '' || // We explicitly want to coerce to number here if possible.
  2264. // eslint-disable-next-line
  2265. node.value != value) {
  2266. node.value = toString(value);
  2267. }
  2268. } else if (node.value !== toString(value)) {
  2269. node.value = toString(value);
  2270. }
  2271. } else if (type === 'submit' || type === 'reset') {
  2272. // Submit/reset inputs need the attribute removed completely to avoid
  2273. // blank-text buttons.
  2274. node.removeAttribute('value');
  2275. return;
  2276. }
  2277. if (disableInputAttributeSyncing) {
  2278. // When not syncing the value attribute, React only assigns a new value
  2279. // whenever the defaultValue React prop has changed. When not present,
  2280. // React does nothing
  2281. if (props.hasOwnProperty('defaultValue')) {
  2282. setDefaultValue(node, props.type, getToStringValue(props.defaultValue));
  2283. }
  2284. } else {
  2285. // When syncing the value attribute, the value comes from a cascade of
  2286. // properties:
  2287. // 1. The value React property
  2288. // 2. The defaultValue React property
  2289. // 3. Otherwise there should be no change
  2290. if (props.hasOwnProperty('value')) {
  2291. setDefaultValue(node, props.type, value);
  2292. } else if (props.hasOwnProperty('defaultValue')) {
  2293. setDefaultValue(node, props.type, getToStringValue(props.defaultValue));
  2294. }
  2295. }
  2296. if (disableInputAttributeSyncing) {
  2297. // When not syncing the checked attribute, the attribute is directly
  2298. // controllable from the defaultValue React property. It needs to be
  2299. // updated as new props come in.
  2300. if (props.defaultChecked == null) {
  2301. node.removeAttribute('checked');
  2302. } else {
  2303. node.defaultChecked = !!props.defaultChecked;
  2304. }
  2305. } else {
  2306. // When syncing the checked attribute, it only changes when it needs
  2307. // to be removed, such as transitioning from a checkbox into a text input
  2308. if (props.checked == null && props.defaultChecked != null) {
  2309. node.defaultChecked = !!props.defaultChecked;
  2310. }
  2311. }
  2312. }
  2313. function postMountWrapper(element, props, isHydrating) {
  2314. var node = element; // Do not assign value if it is already set. This prevents user text input
  2315. // from being lost during SSR hydration.
  2316. if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) {
  2317. var type = props.type;
  2318. var isButton = type === 'submit' || type === 'reset'; // Avoid setting value attribute on submit/reset inputs as it overrides the
  2319. // default value provided by the browser. See: #12872
  2320. if (isButton && (props.value === undefined || props.value === null)) {
  2321. return;
  2322. }
  2323. var initialValue = toString(node._wrapperState.initialValue); // Do not assign value if it is already set. This prevents user text input
  2324. // from being lost during SSR hydration.
  2325. if (!isHydrating) {
  2326. if (disableInputAttributeSyncing) {
  2327. var value = getToStringValue(props.value); // When not syncing the value attribute, the value property points
  2328. // directly to the React prop. Only assign it if it exists.
  2329. if (value != null) {
  2330. // Always assign on buttons so that it is possible to assign an
  2331. // empty string to clear button text.
  2332. //
  2333. // Otherwise, do not re-assign the value property if is empty. This
  2334. // potentially avoids a DOM write and prevents Firefox (~60.0.1) from
  2335. // prematurely marking required inputs as invalid. Equality is compared
  2336. // to the current value in case the browser provided value is not an
  2337. // empty string.
  2338. if (isButton || value !== node.value) {
  2339. node.value = toString(value);
  2340. }
  2341. }
  2342. } else {
  2343. // When syncing the value attribute, the value property should use
  2344. // the wrapperState._initialValue property. This uses:
  2345. //
  2346. // 1. The value React property when present
  2347. // 2. The defaultValue React property when present
  2348. // 3. An empty string
  2349. if (initialValue !== node.value) {
  2350. node.value = initialValue;
  2351. }
  2352. }
  2353. }
  2354. if (disableInputAttributeSyncing) {
  2355. // When not syncing the value attribute, assign the value attribute
  2356. // directly from the defaultValue React property (when present)
  2357. var defaultValue = getToStringValue(props.defaultValue);
  2358. if (defaultValue != null) {
  2359. node.defaultValue = toString(defaultValue);
  2360. }
  2361. } else {
  2362. // Otherwise, the value attribute is synchronized to the property,
  2363. // so we assign defaultValue to the same thing as the value property
  2364. // assignment step above.
  2365. node.defaultValue = initialValue;
  2366. }
  2367. } // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug
  2368. // this is needed to work around a chrome bug where setting defaultChecked
  2369. // will sometimes influence the value of checked (even after detachment).
  2370. // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416
  2371. // We need to temporarily unset name to avoid disrupting radio button groups.
  2372. var name = node.name;
  2373. if (name !== '') {
  2374. node.name = '';
  2375. }
  2376. if (disableInputAttributeSyncing) {
  2377. // When not syncing the checked attribute, the checked property
  2378. // never gets assigned. It must be manually set. We don't want
  2379. // to do this when hydrating so that existing user input isn't
  2380. // modified
  2381. if (!isHydrating) {
  2382. updateChecked(element, props);
  2383. } // Only assign the checked attribute if it is defined. This saves
  2384. // a DOM write when controlling the checked attribute isn't needed
  2385. // (text inputs, submit/reset)
  2386. if (props.hasOwnProperty('defaultChecked')) {
  2387. node.defaultChecked = !node.defaultChecked;
  2388. node.defaultChecked = !!props.defaultChecked;
  2389. }
  2390. } else {
  2391. // When syncing the checked attribute, both the checked property and
  2392. // attribute are assigned at the same time using defaultChecked. This uses:
  2393. //
  2394. // 1. The checked React property when present
  2395. // 2. The defaultChecked React property when present
  2396. // 3. Otherwise, false
  2397. node.defaultChecked = !node.defaultChecked;
  2398. node.defaultChecked = !!node._wrapperState.initialChecked;
  2399. }
  2400. if (name !== '') {
  2401. node.name = name;
  2402. }
  2403. }
  2404. function restoreControlledState$1(element, props) {
  2405. var node = element;
  2406. updateWrapper(node, props);
  2407. updateNamedCousins(node, props);
  2408. }
  2409. function updateNamedCousins(rootNode, props) {
  2410. var name = props.name;
  2411. if (props.type === 'radio' && name != null) {
  2412. var queryRoot = rootNode;
  2413. while (queryRoot.parentNode) {
  2414. queryRoot = queryRoot.parentNode;
  2415. } // If `rootNode.form` was non-null, then we could try `form.elements`,
  2416. // but that sometimes behaves strangely in IE8. We could also try using
  2417. // `form.getElementsByName`, but that will only return direct children
  2418. // and won't include inputs that use the HTML5 `form=` attribute. Since
  2419. // the input might not even be in a form. It might not even be in the
  2420. // document. Let's just use the local `querySelectorAll` to ensure we don't
  2421. // miss anything.
  2422. var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]');
  2423. for (var i = 0; i < group.length; i++) {
  2424. var otherNode = group[i];
  2425. if (otherNode === rootNode || otherNode.form !== rootNode.form) {
  2426. continue;
  2427. } // This will throw if radio buttons rendered by different copies of React
  2428. // and the same name are rendered into the same form (same as #1939).
  2429. // That's probably okay; we don't support it just as we don't support
  2430. // mixing React radio buttons with non-React ones.
  2431. var otherProps = getFiberCurrentPropsFromNode$1(otherNode);
  2432. if (!otherProps) {
  2433. {
  2434. throw Error("ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported.");
  2435. }
  2436. } // We need update the tracked value on the named cousin since the value
  2437. // was changed but the input saw no event or value set
  2438. updateValueIfChanged(otherNode); // If this is a controlled radio button group, forcing the input that
  2439. // was previously checked to update will cause it to be come re-checked
  2440. // as appropriate.
  2441. updateWrapper(otherNode, otherProps);
  2442. }
  2443. }
  2444. } // In Chrome, assigning defaultValue to certain input types triggers input validation.
  2445. // For number inputs, the display value loses trailing decimal points. For email inputs,
  2446. // Chrome raises "The specified value <x> is not a valid email address".
  2447. //
  2448. // Here we check to see if the defaultValue has actually changed, avoiding these problems
  2449. // when the user is inputting text
  2450. //
  2451. // https://github.com/facebook/react/issues/7253
  2452. function setDefaultValue(node, type, value) {
  2453. if ( // Focused number inputs synchronize on blur. See ChangeEventPlugin.js
  2454. type !== 'number' || node.ownerDocument.activeElement !== node) {
  2455. if (value == null) {
  2456. node.defaultValue = toString(node._wrapperState.initialValue);
  2457. } else if (node.defaultValue !== toString(value)) {
  2458. node.defaultValue = toString(value);
  2459. }
  2460. }
  2461. }
  2462. var didWarnSelectedSetOnOption = false;
  2463. var didWarnInvalidChild = false;
  2464. function flattenChildren(children) {
  2465. var content = ''; // Flatten children. We'll warn if they are invalid
  2466. // during validateProps() which runs for hydration too.
  2467. // Note that this would throw on non-element objects.
  2468. // Elements are stringified (which is normally irrelevant
  2469. // but matters for <fbt>).
  2470. React.Children.forEach(children, function (child) {
  2471. if (child == null) {
  2472. return;
  2473. }
  2474. content += child; // Note: we don't warn about invalid children here.
  2475. // Instead, this is done separately below so that
  2476. // it happens during the hydration codepath too.
  2477. });
  2478. return content;
  2479. }
  2480. /**
  2481. * Implements an <option> host component that warns when `selected` is set.
  2482. */
  2483. function validateProps(element, props) {
  2484. {
  2485. // This mirrors the codepath above, but runs for hydration too.
  2486. // Warn about invalid children here so that client and hydration are consistent.
  2487. // TODO: this seems like it could cause a DEV-only throw for hydration
  2488. // if children contains a non-element object. We should try to avoid that.
  2489. if (typeof props.children === 'object' && props.children !== null) {
  2490. React.Children.forEach(props.children, function (child) {
  2491. if (child == null) {
  2492. return;
  2493. }
  2494. if (typeof child === 'string' || typeof child === 'number') {
  2495. return;
  2496. }
  2497. if (typeof child.type !== 'string') {
  2498. return;
  2499. }
  2500. if (!didWarnInvalidChild) {
  2501. didWarnInvalidChild = true;
  2502. warning$1(false, 'Only strings and numbers are supported as <option> children.');
  2503. }
  2504. });
  2505. } // TODO: Remove support for `selected` in <option>.
  2506. if (props.selected != null && !didWarnSelectedSetOnOption) {
  2507. warning$1(false, 'Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.');
  2508. didWarnSelectedSetOnOption = true;
  2509. }
  2510. }
  2511. }
  2512. function postMountWrapper$1(element, props) {
  2513. // value="" should make a value attribute (#6219)
  2514. if (props.value != null) {
  2515. element.setAttribute('value', toString(getToStringValue(props.value)));
  2516. }
  2517. }
  2518. function getHostProps$1(element, props) {
  2519. var hostProps = _assign({
  2520. children: undefined
  2521. }, props);
  2522. var content = flattenChildren(props.children);
  2523. if (content) {
  2524. hostProps.children = content;
  2525. }
  2526. return hostProps;
  2527. }
  2528. // TODO: direct imports like some-package/src/* are bad. Fix me.
  2529. var didWarnValueDefaultValue$1;
  2530. {
  2531. didWarnValueDefaultValue$1 = false;
  2532. }
  2533. function getDeclarationErrorAddendum() {
  2534. var ownerName = getCurrentFiberOwnerNameInDevOrNull();
  2535. if (ownerName) {
  2536. return '\n\nCheck the render method of `' + ownerName + '`.';
  2537. }
  2538. return '';
  2539. }
  2540. var valuePropNames = ['value', 'defaultValue'];
  2541. /**
  2542. * Validation function for `value` and `defaultValue`.
  2543. */
  2544. function checkSelectPropTypes(props) {
  2545. ReactControlledValuePropTypes.checkPropTypes('select', props);
  2546. for (var i = 0; i < valuePropNames.length; i++) {
  2547. var propName = valuePropNames[i];
  2548. if (props[propName] == null) {
  2549. continue;
  2550. }
  2551. var isArray = Array.isArray(props[propName]);
  2552. if (props.multiple && !isArray) {
  2553. warning$1(false, 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum());
  2554. } else if (!props.multiple && isArray) {
  2555. warning$1(false, 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum());
  2556. }
  2557. }
  2558. }
  2559. function updateOptions(node, multiple, propValue, setDefaultSelected) {
  2560. var options = node.options;
  2561. if (multiple) {
  2562. var selectedValues = propValue;
  2563. var selectedValue = {};
  2564. for (var i = 0; i < selectedValues.length; i++) {
  2565. // Prefix to avoid chaos with special keys.
  2566. selectedValue['$' + selectedValues[i]] = true;
  2567. }
  2568. for (var _i = 0; _i < options.length; _i++) {
  2569. var selected = selectedValue.hasOwnProperty('$' + options[_i].value);
  2570. if (options[_i].selected !== selected) {
  2571. options[_i].selected = selected;
  2572. }
  2573. if (selected && setDefaultSelected) {
  2574. options[_i].defaultSelected = true;
  2575. }
  2576. }
  2577. } else {
  2578. // Do not set `select.value` as exact behavior isn't consistent across all
  2579. // browsers for all cases.
  2580. var _selectedValue = toString(getToStringValue(propValue));
  2581. var defaultSelected = null;
  2582. for (var _i2 = 0; _i2 < options.length; _i2++) {
  2583. if (options[_i2].value === _selectedValue) {
  2584. options[_i2].selected = true;
  2585. if (setDefaultSelected) {
  2586. options[_i2].defaultSelected = true;
  2587. }
  2588. return;
  2589. }
  2590. if (defaultSelected === null && !options[_i2].disabled) {
  2591. defaultSelected = options[_i2];
  2592. }
  2593. }
  2594. if (defaultSelected !== null) {
  2595. defaultSelected.selected = true;
  2596. }
  2597. }
  2598. }
  2599. /**
  2600. * Implements a <select> host component that allows optionally setting the
  2601. * props `value` and `defaultValue`. If `multiple` is false, the prop must be a
  2602. * stringable. If `multiple` is true, the prop must be an array of stringables.
  2603. *
  2604. * If `value` is not supplied (or null/undefined), user actions that change the
  2605. * selected option will trigger updates to the rendered options.
  2606. *
  2607. * If it is supplied (and not null/undefined), the rendered options will not
  2608. * update in response to user actions. Instead, the `value` prop must change in
  2609. * order for the rendered options to update.
  2610. *
  2611. * If `defaultValue` is provided, any options with the supplied values will be
  2612. * selected.
  2613. */
  2614. function getHostProps$2(element, props) {
  2615. return _assign({}, props, {
  2616. value: undefined
  2617. });
  2618. }
  2619. function initWrapperState$1(element, props) {
  2620. var node = element;
  2621. {
  2622. checkSelectPropTypes(props);
  2623. }
  2624. node._wrapperState = {
  2625. wasMultiple: !!props.multiple
  2626. };
  2627. {
  2628. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue$1) {
  2629. warning$1(false, 'Select elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled select ' + 'element and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components');
  2630. didWarnValueDefaultValue$1 = true;
  2631. }
  2632. }
  2633. }
  2634. function postMountWrapper$2(element, props) {
  2635. var node = element;
  2636. node.multiple = !!props.multiple;
  2637. var value = props.value;
  2638. if (value != null) {
  2639. updateOptions(node, !!props.multiple, value, false);
  2640. } else if (props.defaultValue != null) {
  2641. updateOptions(node, !!props.multiple, props.defaultValue, true);
  2642. }
  2643. }
  2644. function postUpdateWrapper(element, props) {
  2645. var node = element;
  2646. var wasMultiple = node._wrapperState.wasMultiple;
  2647. node._wrapperState.wasMultiple = !!props.multiple;
  2648. var value = props.value;
  2649. if (value != null) {
  2650. updateOptions(node, !!props.multiple, value, false);
  2651. } else if (wasMultiple !== !!props.multiple) {
  2652. // For simplicity, reapply `defaultValue` if `multiple` is toggled.
  2653. if (props.defaultValue != null) {
  2654. updateOptions(node, !!props.multiple, props.defaultValue, true);
  2655. } else {
  2656. // Revert the select back to its default unselected state.
  2657. updateOptions(node, !!props.multiple, props.multiple ? [] : '', false);
  2658. }
  2659. }
  2660. }
  2661. function restoreControlledState$2(element, props) {
  2662. var node = element;
  2663. var value = props.value;
  2664. if (value != null) {
  2665. updateOptions(node, !!props.multiple, value, false);
  2666. }
  2667. }
  2668. var didWarnValDefaultVal = false;
  2669. /**
  2670. * Implements a <textarea> host component that allows setting `value`, and
  2671. * `defaultValue`. This differs from the traditional DOM API because value is
  2672. * usually set as PCDATA children.
  2673. *
  2674. * If `value` is not supplied (or null/undefined), user actions that affect the
  2675. * value will trigger updates to the element.
  2676. *
  2677. * If `value` is supplied (and not null/undefined), the rendered element will
  2678. * not trigger updates to the element. Instead, the `value` prop must change in
  2679. * order for the rendered element to be updated.
  2680. *
  2681. * The rendered element will be initialized with an empty value, the prop
  2682. * `defaultValue` if specified, or the children content (deprecated).
  2683. */
  2684. function getHostProps$3(element, props) {
  2685. var node = element;
  2686. if (!(props.dangerouslySetInnerHTML == null)) {
  2687. {
  2688. throw Error("`dangerouslySetInnerHTML` does not make sense on <textarea>.");
  2689. }
  2690. } // Always set children to the same thing. In IE9, the selection range will
  2691. // get reset if `textContent` is mutated. We could add a check in setTextContent
  2692. // to only set the value if/when the value differs from the node value (which would
  2693. // completely solve this IE9 bug), but Sebastian+Sophie seemed to like this
  2694. // solution. The value can be a boolean or object so that's why it's forced
  2695. // to be a string.
  2696. var hostProps = _assign({}, props, {
  2697. value: undefined,
  2698. defaultValue: undefined,
  2699. children: toString(node._wrapperState.initialValue)
  2700. });
  2701. return hostProps;
  2702. }
  2703. function initWrapperState$2(element, props) {
  2704. var node = element;
  2705. {
  2706. ReactControlledValuePropTypes.checkPropTypes('textarea', props);
  2707. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) {
  2708. warning$1(false, '%s contains a textarea with both value and defaultValue props. ' + 'Textarea elements must be either controlled or uncontrolled ' + '(specify either the value prop, or the defaultValue prop, but not ' + 'both). Decide between using a controlled or uncontrolled textarea ' + 'and remove one of these props. More info: ' + 'https://fb.me/react-controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component');
  2709. didWarnValDefaultVal = true;
  2710. }
  2711. }
  2712. var initialValue = props.value; // Only bother fetching default value if we're going to use it
  2713. if (initialValue == null) {
  2714. var defaultValue = props.defaultValue; // TODO (yungsters): Remove support for children content in <textarea>.
  2715. var children = props.children;
  2716. if (children != null) {
  2717. {
  2718. warning$1(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.');
  2719. }
  2720. if (!(defaultValue == null)) {
  2721. {
  2722. throw Error("If you supply `defaultValue` on a <textarea>, do not pass children.");
  2723. }
  2724. }
  2725. if (Array.isArray(children)) {
  2726. if (!(children.length <= 1)) {
  2727. {
  2728. throw Error("<textarea> can only have at most one child.");
  2729. }
  2730. }
  2731. children = children[0];
  2732. }
  2733. defaultValue = children;
  2734. }
  2735. if (defaultValue == null) {
  2736. defaultValue = '';
  2737. }
  2738. initialValue = defaultValue;
  2739. }
  2740. node._wrapperState = {
  2741. initialValue: getToStringValue(initialValue)
  2742. };
  2743. }
  2744. function updateWrapper$1(element, props) {
  2745. var node = element;
  2746. var value = getToStringValue(props.value);
  2747. var defaultValue = getToStringValue(props.defaultValue);
  2748. if (value != null) {
  2749. // Cast `value` to a string to ensure the value is set correctly. While
  2750. // browsers typically do this as necessary, jsdom doesn't.
  2751. var newValue = toString(value); // To avoid side effects (such as losing text selection), only set value if changed
  2752. if (newValue !== node.value) {
  2753. node.value = newValue;
  2754. }
  2755. if (props.defaultValue == null && node.defaultValue !== newValue) {
  2756. node.defaultValue = newValue;
  2757. }
  2758. }
  2759. if (defaultValue != null) {
  2760. node.defaultValue = toString(defaultValue);
  2761. }
  2762. }
  2763. function postMountWrapper$3(element, props) {
  2764. var node = element; // This is in postMount because we need access to the DOM node, which is not
  2765. // available until after the component has mounted.
  2766. var textContent = node.textContent; // Only set node.value if textContent is equal to the expected
  2767. // initial value. In IE10/IE11 there is a bug where the placeholder attribute
  2768. // will populate textContent as well.
  2769. // https://developer.microsoft.com/microsoft-edge/platform/issues/101525/
  2770. if (textContent === node._wrapperState.initialValue) {
  2771. if (textContent !== '' && textContent !== null) {
  2772. node.value = textContent;
  2773. }
  2774. }
  2775. }
  2776. function restoreControlledState$3(element, props) {
  2777. // DOM component is still mounted; update
  2778. updateWrapper$1(element, props);
  2779. }
  2780. var HTML_NAMESPACE$1 = 'http://www.w3.org/1999/xhtml';
  2781. var MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
  2782. var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
  2783. var Namespaces = {
  2784. html: HTML_NAMESPACE$1,
  2785. mathml: MATH_NAMESPACE,
  2786. svg: SVG_NAMESPACE
  2787. }; // Assumes there is no parent namespace.
  2788. function getIntrinsicNamespace(type) {
  2789. switch (type) {
  2790. case 'svg':
  2791. return SVG_NAMESPACE;
  2792. case 'math':
  2793. return MATH_NAMESPACE;
  2794. default:
  2795. return HTML_NAMESPACE$1;
  2796. }
  2797. }
  2798. function getChildNamespace(parentNamespace, type) {
  2799. if (parentNamespace == null || parentNamespace === HTML_NAMESPACE$1) {
  2800. // No (or default) parent namespace: potential entry point.
  2801. return getIntrinsicNamespace(type);
  2802. }
  2803. if (parentNamespace === SVG_NAMESPACE && type === 'foreignObject') {
  2804. // We're leaving SVG.
  2805. return HTML_NAMESPACE$1;
  2806. } // By default, pass namespace below.
  2807. return parentNamespace;
  2808. }
  2809. /* globals MSApp */
  2810. /**
  2811. * Create a function which has 'unsafe' privileges (required by windows8 apps)
  2812. */
  2813. var createMicrosoftUnsafeLocalFunction = function (func) {
  2814. if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
  2815. return function (arg0, arg1, arg2, arg3) {
  2816. MSApp.execUnsafeLocalFunction(function () {
  2817. return func(arg0, arg1, arg2, arg3);
  2818. });
  2819. };
  2820. } else {
  2821. return func;
  2822. }
  2823. };
  2824. var reusableSVGContainer;
  2825. /**
  2826. * Set the innerHTML property of a node
  2827. *
  2828. * @param {DOMElement} node
  2829. * @param {string} html
  2830. * @internal
  2831. */
  2832. var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) {
  2833. if (node.namespaceURI === Namespaces.svg) {
  2834. {
  2835. if (enableTrustedTypesIntegration) {
  2836. // TODO: reconsider the text of this warning and when it should show
  2837. // before enabling the feature flag.
  2838. !(typeof trustedTypes === 'undefined') ? warning$1(false, "Using 'dangerouslySetInnerHTML' in an svg element with " + 'Trusted Types enabled in an Internet Explorer will cause ' + 'the trusted value to be converted to string. Assigning string ' + "to 'innerHTML' will throw an error if Trusted Types are enforced. " + "You can try to wrap your svg element inside a div and use 'dangerouslySetInnerHTML' " + 'on the enclosing div instead.') : void 0;
  2839. }
  2840. }
  2841. if (!('innerHTML' in node)) {
  2842. // IE does not have innerHTML for SVG nodes, so instead we inject the
  2843. // new markup in a temp node and then move the child nodes across into
  2844. // the target node
  2845. reusableSVGContainer = reusableSVGContainer || document.createElement('div');
  2846. reusableSVGContainer.innerHTML = '<svg>' + html.valueOf().toString() + '</svg>';
  2847. var svgNode = reusableSVGContainer.firstChild;
  2848. while (node.firstChild) {
  2849. node.removeChild(node.firstChild);
  2850. }
  2851. while (svgNode.firstChild) {
  2852. node.appendChild(svgNode.firstChild);
  2853. }
  2854. return;
  2855. }
  2856. }
  2857. node.innerHTML = html;
  2858. });
  2859. /**
  2860. * HTML nodeType values that represent the type of the node
  2861. */
  2862. var ELEMENT_NODE = 1;
  2863. var TEXT_NODE = 3;
  2864. var COMMENT_NODE = 8;
  2865. var DOCUMENT_NODE = 9;
  2866. var DOCUMENT_FRAGMENT_NODE = 11;
  2867. /**
  2868. * Set the textContent property of a node. For text updates, it's faster
  2869. * to set the `nodeValue` of the Text node directly instead of using
  2870. * `.textContent` which will remove the existing node and create a new one.
  2871. *
  2872. * @param {DOMElement} node
  2873. * @param {string} text
  2874. * @internal
  2875. */
  2876. var setTextContent = function (node, text) {
  2877. if (text) {
  2878. var firstChild = node.firstChild;
  2879. if (firstChild && firstChild === node.lastChild && firstChild.nodeType === TEXT_NODE) {
  2880. firstChild.nodeValue = text;
  2881. return;
  2882. }
  2883. }
  2884. node.textContent = text;
  2885. };
  2886. // Do not use the below two methods directly!
  2887. // Instead use constants exported from DOMTopLevelEventTypes in ReactDOM.
  2888. // (It is the only module that is allowed to access these methods.)
  2889. function unsafeCastStringToDOMTopLevelType(topLevelType) {
  2890. return topLevelType;
  2891. }
  2892. function unsafeCastDOMTopLevelTypeToString(topLevelType) {
  2893. return topLevelType;
  2894. }
  2895. /**
  2896. * Generate a mapping of standard vendor prefixes using the defined style property and event name.
  2897. *
  2898. * @param {string} styleProp
  2899. * @param {string} eventName
  2900. * @returns {object}
  2901. */
  2902. function makePrefixMap(styleProp, eventName) {
  2903. var prefixes = {};
  2904. prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
  2905. prefixes['Webkit' + styleProp] = 'webkit' + eventName;
  2906. prefixes['Moz' + styleProp] = 'moz' + eventName;
  2907. return prefixes;
  2908. }
  2909. /**
  2910. * A list of event names to a configurable list of vendor prefixes.
  2911. */
  2912. var vendorPrefixes = {
  2913. animationend: makePrefixMap('Animation', 'AnimationEnd'),
  2914. animationiteration: makePrefixMap('Animation', 'AnimationIteration'),
  2915. animationstart: makePrefixMap('Animation', 'AnimationStart'),
  2916. transitionend: makePrefixMap('Transition', 'TransitionEnd')
  2917. };
  2918. /**
  2919. * Event names that have already been detected and prefixed (if applicable).
  2920. */
  2921. var prefixedEventNames = {};
  2922. /**
  2923. * Element to check for prefixes on.
  2924. */
  2925. var style = {};
  2926. /**
  2927. * Bootstrap if a DOM exists.
  2928. */
  2929. if (canUseDOM) {
  2930. style = document.createElement('div').style; // On some platforms, in particular some releases of Android 4.x,
  2931. // the un-prefixed "animation" and "transition" properties are defined on the
  2932. // style object but the events that fire will still be prefixed, so we need
  2933. // to check if the un-prefixed events are usable, and if not remove them from the map.
  2934. if (!('AnimationEvent' in window)) {
  2935. delete vendorPrefixes.animationend.animation;
  2936. delete vendorPrefixes.animationiteration.animation;
  2937. delete vendorPrefixes.animationstart.animation;
  2938. } // Same as above
  2939. if (!('TransitionEvent' in window)) {
  2940. delete vendorPrefixes.transitionend.transition;
  2941. }
  2942. }
  2943. /**
  2944. * Attempts to determine the correct vendor prefixed event name.
  2945. *
  2946. * @param {string} eventName
  2947. * @returns {string}
  2948. */
  2949. function getVendorPrefixedEventName(eventName) {
  2950. if (prefixedEventNames[eventName]) {
  2951. return prefixedEventNames[eventName];
  2952. } else if (!vendorPrefixes[eventName]) {
  2953. return eventName;
  2954. }
  2955. var prefixMap = vendorPrefixes[eventName];
  2956. for (var styleProp in prefixMap) {
  2957. if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) {
  2958. return prefixedEventNames[eventName] = prefixMap[styleProp];
  2959. }
  2960. }
  2961. return eventName;
  2962. }
  2963. /**
  2964. * To identify top level events in ReactDOM, we use constants defined by this
  2965. * module. This is the only module that uses the unsafe* methods to express
  2966. * that the constants actually correspond to the browser event names. This lets
  2967. * us save some bundle size by avoiding a top level type -> event name map.
  2968. * The rest of ReactDOM code should import top level types from this file.
  2969. */
  2970. var TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort');
  2971. var TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationend'));
  2972. var TOP_ANIMATION_ITERATION = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationiteration'));
  2973. var TOP_ANIMATION_START = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationstart'));
  2974. var TOP_BLUR = unsafeCastStringToDOMTopLevelType('blur');
  2975. var TOP_CAN_PLAY = unsafeCastStringToDOMTopLevelType('canplay');
  2976. var TOP_CAN_PLAY_THROUGH = unsafeCastStringToDOMTopLevelType('canplaythrough');
  2977. var TOP_CANCEL = unsafeCastStringToDOMTopLevelType('cancel');
  2978. var TOP_CHANGE = unsafeCastStringToDOMTopLevelType('change');
  2979. var TOP_CLICK = unsafeCastStringToDOMTopLevelType('click');
  2980. var TOP_CLOSE = unsafeCastStringToDOMTopLevelType('close');
  2981. var TOP_COMPOSITION_END = unsafeCastStringToDOMTopLevelType('compositionend');
  2982. var TOP_COMPOSITION_START = unsafeCastStringToDOMTopLevelType('compositionstart');
  2983. var TOP_COMPOSITION_UPDATE = unsafeCastStringToDOMTopLevelType('compositionupdate');
  2984. var TOP_CONTEXT_MENU = unsafeCastStringToDOMTopLevelType('contextmenu');
  2985. var TOP_COPY = unsafeCastStringToDOMTopLevelType('copy');
  2986. var TOP_CUT = unsafeCastStringToDOMTopLevelType('cut');
  2987. var TOP_DOUBLE_CLICK = unsafeCastStringToDOMTopLevelType('dblclick');
  2988. var TOP_AUX_CLICK = unsafeCastStringToDOMTopLevelType('auxclick');
  2989. var TOP_DRAG = unsafeCastStringToDOMTopLevelType('drag');
  2990. var TOP_DRAG_END = unsafeCastStringToDOMTopLevelType('dragend');
  2991. var TOP_DRAG_ENTER = unsafeCastStringToDOMTopLevelType('dragenter');
  2992. var TOP_DRAG_EXIT = unsafeCastStringToDOMTopLevelType('dragexit');
  2993. var TOP_DRAG_LEAVE = unsafeCastStringToDOMTopLevelType('dragleave');
  2994. var TOP_DRAG_OVER = unsafeCastStringToDOMTopLevelType('dragover');
  2995. var TOP_DRAG_START = unsafeCastStringToDOMTopLevelType('dragstart');
  2996. var TOP_DROP = unsafeCastStringToDOMTopLevelType('drop');
  2997. var TOP_DURATION_CHANGE = unsafeCastStringToDOMTopLevelType('durationchange');
  2998. var TOP_EMPTIED = unsafeCastStringToDOMTopLevelType('emptied');
  2999. var TOP_ENCRYPTED = unsafeCastStringToDOMTopLevelType('encrypted');
  3000. var TOP_ENDED = unsafeCastStringToDOMTopLevelType('ended');
  3001. var TOP_ERROR = unsafeCastStringToDOMTopLevelType('error');
  3002. var TOP_FOCUS = unsafeCastStringToDOMTopLevelType('focus');
  3003. var TOP_GOT_POINTER_CAPTURE = unsafeCastStringToDOMTopLevelType('gotpointercapture');
  3004. var TOP_INPUT = unsafeCastStringToDOMTopLevelType('input');
  3005. var TOP_INVALID = unsafeCastStringToDOMTopLevelType('invalid');
  3006. var TOP_KEY_DOWN = unsafeCastStringToDOMTopLevelType('keydown');
  3007. var TOP_KEY_PRESS = unsafeCastStringToDOMTopLevelType('keypress');
  3008. var TOP_KEY_UP = unsafeCastStringToDOMTopLevelType('keyup');
  3009. var TOP_LOAD = unsafeCastStringToDOMTopLevelType('load');
  3010. var TOP_LOAD_START = unsafeCastStringToDOMTopLevelType('loadstart');
  3011. var TOP_LOADED_DATA = unsafeCastStringToDOMTopLevelType('loadeddata');
  3012. var TOP_LOADED_METADATA = unsafeCastStringToDOMTopLevelType('loadedmetadata');
  3013. var TOP_LOST_POINTER_CAPTURE = unsafeCastStringToDOMTopLevelType('lostpointercapture');
  3014. var TOP_MOUSE_DOWN = unsafeCastStringToDOMTopLevelType('mousedown');
  3015. var TOP_MOUSE_MOVE = unsafeCastStringToDOMTopLevelType('mousemove');
  3016. var TOP_MOUSE_OUT = unsafeCastStringToDOMTopLevelType('mouseout');
  3017. var TOP_MOUSE_OVER = unsafeCastStringToDOMTopLevelType('mouseover');
  3018. var TOP_MOUSE_UP = unsafeCastStringToDOMTopLevelType('mouseup');
  3019. var TOP_PASTE = unsafeCastStringToDOMTopLevelType('paste');
  3020. var TOP_PAUSE = unsafeCastStringToDOMTopLevelType('pause');
  3021. var TOP_PLAY = unsafeCastStringToDOMTopLevelType('play');
  3022. var TOP_PLAYING = unsafeCastStringToDOMTopLevelType('playing');
  3023. var TOP_POINTER_CANCEL = unsafeCastStringToDOMTopLevelType('pointercancel');
  3024. var TOP_POINTER_DOWN = unsafeCastStringToDOMTopLevelType('pointerdown');
  3025. var TOP_POINTER_MOVE = unsafeCastStringToDOMTopLevelType('pointermove');
  3026. var TOP_POINTER_OUT = unsafeCastStringToDOMTopLevelType('pointerout');
  3027. var TOP_POINTER_OVER = unsafeCastStringToDOMTopLevelType('pointerover');
  3028. var TOP_POINTER_UP = unsafeCastStringToDOMTopLevelType('pointerup');
  3029. var TOP_PROGRESS = unsafeCastStringToDOMTopLevelType('progress');
  3030. var TOP_RATE_CHANGE = unsafeCastStringToDOMTopLevelType('ratechange');
  3031. var TOP_RESET = unsafeCastStringToDOMTopLevelType('reset');
  3032. var TOP_SCROLL = unsafeCastStringToDOMTopLevelType('scroll');
  3033. var TOP_SEEKED = unsafeCastStringToDOMTopLevelType('seeked');
  3034. var TOP_SEEKING = unsafeCastStringToDOMTopLevelType('seeking');
  3035. var TOP_SELECTION_CHANGE = unsafeCastStringToDOMTopLevelType('selectionchange');
  3036. var TOP_STALLED = unsafeCastStringToDOMTopLevelType('stalled');
  3037. var TOP_SUBMIT = unsafeCastStringToDOMTopLevelType('submit');
  3038. var TOP_SUSPEND = unsafeCastStringToDOMTopLevelType('suspend');
  3039. var TOP_TEXT_INPUT = unsafeCastStringToDOMTopLevelType('textInput');
  3040. var TOP_TIME_UPDATE = unsafeCastStringToDOMTopLevelType('timeupdate');
  3041. var TOP_TOGGLE = unsafeCastStringToDOMTopLevelType('toggle');
  3042. var TOP_TOUCH_CANCEL = unsafeCastStringToDOMTopLevelType('touchcancel');
  3043. var TOP_TOUCH_END = unsafeCastStringToDOMTopLevelType('touchend');
  3044. var TOP_TOUCH_MOVE = unsafeCastStringToDOMTopLevelType('touchmove');
  3045. var TOP_TOUCH_START = unsafeCastStringToDOMTopLevelType('touchstart');
  3046. var TOP_TRANSITION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('transitionend'));
  3047. var TOP_VOLUME_CHANGE = unsafeCastStringToDOMTopLevelType('volumechange');
  3048. var TOP_WAITING = unsafeCastStringToDOMTopLevelType('waiting');
  3049. var TOP_WHEEL = unsafeCastStringToDOMTopLevelType('wheel'); // List of events that need to be individually attached to media elements.
  3050. // Note that events in this list will *not* be listened to at the top level
  3051. // unless they're explicitly whitelisted in `ReactBrowserEventEmitter.listenTo`.
  3052. var mediaEventTypes = [TOP_ABORT, TOP_CAN_PLAY, TOP_CAN_PLAY_THROUGH, TOP_DURATION_CHANGE, TOP_EMPTIED, TOP_ENCRYPTED, TOP_ENDED, TOP_ERROR, TOP_LOADED_DATA, TOP_LOADED_METADATA, TOP_LOAD_START, TOP_PAUSE, TOP_PLAY, TOP_PLAYING, TOP_PROGRESS, TOP_RATE_CHANGE, TOP_SEEKED, TOP_SEEKING, TOP_STALLED, TOP_SUSPEND, TOP_TIME_UPDATE, TOP_VOLUME_CHANGE, TOP_WAITING];
  3053. function getRawEventName(topLevelType) {
  3054. return unsafeCastDOMTopLevelTypeToString(topLevelType);
  3055. }
  3056. /**
  3057. * `ReactInstanceMap` maintains a mapping from a public facing stateful
  3058. * instance (key) and the internal representation (value). This allows public
  3059. * methods to accept the user facing instance as an argument and map them back
  3060. * to internal methods.
  3061. *
  3062. * Note that this module is currently shared and assumed to be stateless.
  3063. * If this becomes an actual Map, that will break.
  3064. */
  3065. /**
  3066. * This API should be called `delete` but we'd have to make sure to always
  3067. * transform these to strings for IE support. When this transform is fully
  3068. * supported we can rename it.
  3069. */
  3070. function get(key) {
  3071. return key._reactInternalFiber;
  3072. }
  3073. function has(key) {
  3074. return key._reactInternalFiber !== undefined;
  3075. }
  3076. function set(key, value) {
  3077. key._reactInternalFiber = value;
  3078. }
  3079. // Don't change these two values. They're used by React Dev Tools.
  3080. var NoEffect =
  3081. /* */
  3082. 0;
  3083. var PerformedWork =
  3084. /* */
  3085. 1; // You can change the rest (and add more).
  3086. var Placement =
  3087. /* */
  3088. 2;
  3089. var Update =
  3090. /* */
  3091. 4;
  3092. var PlacementAndUpdate =
  3093. /* */
  3094. 6;
  3095. var Deletion =
  3096. /* */
  3097. 8;
  3098. var ContentReset =
  3099. /* */
  3100. 16;
  3101. var Callback =
  3102. /* */
  3103. 32;
  3104. var DidCapture =
  3105. /* */
  3106. 64;
  3107. var Ref =
  3108. /* */
  3109. 128;
  3110. var Snapshot =
  3111. /* */
  3112. 256;
  3113. var Passive =
  3114. /* */
  3115. 512;
  3116. var Hydrating =
  3117. /* */
  3118. 1024;
  3119. var HydratingAndUpdate =
  3120. /* */
  3121. 1028; // Passive & Update & Callback & Ref & Snapshot
  3122. var LifecycleEffectMask =
  3123. /* */
  3124. 932; // Union of all host effects
  3125. var HostEffectMask =
  3126. /* */
  3127. 2047;
  3128. var Incomplete =
  3129. /* */
  3130. 2048;
  3131. var ShouldCapture =
  3132. /* */
  3133. 4096;
  3134. var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
  3135. function getNearestMountedFiber(fiber) {
  3136. var node = fiber;
  3137. var nearestMounted = fiber;
  3138. if (!fiber.alternate) {
  3139. // If there is no alternate, this might be a new tree that isn't inserted
  3140. // yet. If it is, then it will have a pending insertion effect on it.
  3141. var nextNode = node;
  3142. do {
  3143. node = nextNode;
  3144. if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) {
  3145. // This is an insertion or in-progress hydration. The nearest possible
  3146. // mounted fiber is the parent but we need to continue to figure out
  3147. // if that one is still mounted.
  3148. nearestMounted = node.return;
  3149. }
  3150. nextNode = node.return;
  3151. } while (nextNode);
  3152. } else {
  3153. while (node.return) {
  3154. node = node.return;
  3155. }
  3156. }
  3157. if (node.tag === HostRoot) {
  3158. // TODO: Check if this was a nested HostRoot when used with
  3159. // renderContainerIntoSubtree.
  3160. return nearestMounted;
  3161. } // If we didn't hit the root, that means that we're in an disconnected tree
  3162. // that has been unmounted.
  3163. return null;
  3164. }
  3165. function getSuspenseInstanceFromFiber(fiber) {
  3166. if (fiber.tag === SuspenseComponent) {
  3167. var suspenseState = fiber.memoizedState;
  3168. if (suspenseState === null) {
  3169. var current = fiber.alternate;
  3170. if (current !== null) {
  3171. suspenseState = current.memoizedState;
  3172. }
  3173. }
  3174. if (suspenseState !== null) {
  3175. return suspenseState.dehydrated;
  3176. }
  3177. }
  3178. return null;
  3179. }
  3180. function getContainerFromFiber(fiber) {
  3181. return fiber.tag === HostRoot ? fiber.stateNode.containerInfo : null;
  3182. }
  3183. function isFiberMounted(fiber) {
  3184. return getNearestMountedFiber(fiber) === fiber;
  3185. }
  3186. function isMounted(component) {
  3187. {
  3188. var owner = ReactCurrentOwner.current;
  3189. if (owner !== null && owner.tag === ClassComponent) {
  3190. var ownerFiber = owner;
  3191. var instance = ownerFiber.stateNode;
  3192. !instance._warnedAboutRefsInRender ? warningWithoutStack$1(false, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(ownerFiber.type) || 'A component') : void 0;
  3193. instance._warnedAboutRefsInRender = true;
  3194. }
  3195. }
  3196. var fiber = get(component);
  3197. if (!fiber) {
  3198. return false;
  3199. }
  3200. return getNearestMountedFiber(fiber) === fiber;
  3201. }
  3202. function assertIsMounted(fiber) {
  3203. if (!(getNearestMountedFiber(fiber) === fiber)) {
  3204. {
  3205. throw Error("Unable to find node on an unmounted component.");
  3206. }
  3207. }
  3208. }
  3209. function findCurrentFiberUsingSlowPath(fiber) {
  3210. var alternate = fiber.alternate;
  3211. if (!alternate) {
  3212. // If there is no alternate, then we only need to check if it is mounted.
  3213. var nearestMounted = getNearestMountedFiber(fiber);
  3214. if (!(nearestMounted !== null)) {
  3215. {
  3216. throw Error("Unable to find node on an unmounted component.");
  3217. }
  3218. }
  3219. if (nearestMounted !== fiber) {
  3220. return null;
  3221. }
  3222. return fiber;
  3223. } // If we have two possible branches, we'll walk backwards up to the root
  3224. // to see what path the root points to. On the way we may hit one of the
  3225. // special cases and we'll deal with them.
  3226. var a = fiber;
  3227. var b = alternate;
  3228. while (true) {
  3229. var parentA = a.return;
  3230. if (parentA === null) {
  3231. // We're at the root.
  3232. break;
  3233. }
  3234. var parentB = parentA.alternate;
  3235. if (parentB === null) {
  3236. // There is no alternate. This is an unusual case. Currently, it only
  3237. // happens when a Suspense component is hidden. An extra fragment fiber
  3238. // is inserted in between the Suspense fiber and its children. Skip
  3239. // over this extra fragment fiber and proceed to the next parent.
  3240. var nextParent = parentA.return;
  3241. if (nextParent !== null) {
  3242. a = b = nextParent;
  3243. continue;
  3244. } // If there's no parent, we're at the root.
  3245. break;
  3246. } // If both copies of the parent fiber point to the same child, we can
  3247. // assume that the child is current. This happens when we bailout on low
  3248. // priority: the bailed out fiber's child reuses the current child.
  3249. if (parentA.child === parentB.child) {
  3250. var child = parentA.child;
  3251. while (child) {
  3252. if (child === a) {
  3253. // We've determined that A is the current branch.
  3254. assertIsMounted(parentA);
  3255. return fiber;
  3256. }
  3257. if (child === b) {
  3258. // We've determined that B is the current branch.
  3259. assertIsMounted(parentA);
  3260. return alternate;
  3261. }
  3262. child = child.sibling;
  3263. } // We should never have an alternate for any mounting node. So the only
  3264. // way this could possibly happen is if this was unmounted, if at all.
  3265. {
  3266. {
  3267. throw Error("Unable to find node on an unmounted component.");
  3268. }
  3269. }
  3270. }
  3271. if (a.return !== b.return) {
  3272. // The return pointer of A and the return pointer of B point to different
  3273. // fibers. We assume that return pointers never criss-cross, so A must
  3274. // belong to the child set of A.return, and B must belong to the child
  3275. // set of B.return.
  3276. a = parentA;
  3277. b = parentB;
  3278. } else {
  3279. // The return pointers point to the same fiber. We'll have to use the
  3280. // default, slow path: scan the child sets of each parent alternate to see
  3281. // which child belongs to which set.
  3282. //
  3283. // Search parent A's child set
  3284. var didFindChild = false;
  3285. var _child = parentA.child;
  3286. while (_child) {
  3287. if (_child === a) {
  3288. didFindChild = true;
  3289. a = parentA;
  3290. b = parentB;
  3291. break;
  3292. }
  3293. if (_child === b) {
  3294. didFindChild = true;
  3295. b = parentA;
  3296. a = parentB;
  3297. break;
  3298. }
  3299. _child = _child.sibling;
  3300. }
  3301. if (!didFindChild) {
  3302. // Search parent B's child set
  3303. _child = parentB.child;
  3304. while (_child) {
  3305. if (_child === a) {
  3306. didFindChild = true;
  3307. a = parentB;
  3308. b = parentA;
  3309. break;
  3310. }
  3311. if (_child === b) {
  3312. didFindChild = true;
  3313. b = parentB;
  3314. a = parentA;
  3315. break;
  3316. }
  3317. _child = _child.sibling;
  3318. }
  3319. if (!didFindChild) {
  3320. {
  3321. throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.");
  3322. }
  3323. }
  3324. }
  3325. }
  3326. if (!(a.alternate === b)) {
  3327. {
  3328. throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.");
  3329. }
  3330. }
  3331. } // If the root is not a host container, we're in a disconnected tree. I.e.
  3332. // unmounted.
  3333. if (!(a.tag === HostRoot)) {
  3334. {
  3335. throw Error("Unable to find node on an unmounted component.");
  3336. }
  3337. }
  3338. if (a.stateNode.current === a) {
  3339. // We've determined that A is the current branch.
  3340. return fiber;
  3341. } // Otherwise B has to be current branch.
  3342. return alternate;
  3343. }
  3344. function findCurrentHostFiber(parent) {
  3345. var currentParent = findCurrentFiberUsingSlowPath(parent);
  3346. if (!currentParent) {
  3347. return null;
  3348. } // Next we'll drill down this component to find the first HostComponent/Text.
  3349. var node = currentParent;
  3350. while (true) {
  3351. if (node.tag === HostComponent || node.tag === HostText) {
  3352. return node;
  3353. } else if (node.child) {
  3354. node.child.return = node;
  3355. node = node.child;
  3356. continue;
  3357. }
  3358. if (node === currentParent) {
  3359. return null;
  3360. }
  3361. while (!node.sibling) {
  3362. if (!node.return || node.return === currentParent) {
  3363. return null;
  3364. }
  3365. node = node.return;
  3366. }
  3367. node.sibling.return = node.return;
  3368. node = node.sibling;
  3369. } // Flow needs the return null here, but ESLint complains about it.
  3370. // eslint-disable-next-line no-unreachable
  3371. return null;
  3372. }
  3373. function findCurrentHostFiberWithNoPortals(parent) {
  3374. var currentParent = findCurrentFiberUsingSlowPath(parent);
  3375. if (!currentParent) {
  3376. return null;
  3377. } // Next we'll drill down this component to find the first HostComponent/Text.
  3378. var node = currentParent;
  3379. while (true) {
  3380. if (node.tag === HostComponent || node.tag === HostText || enableFundamentalAPI && node.tag === FundamentalComponent) {
  3381. return node;
  3382. } else if (node.child && node.tag !== HostPortal) {
  3383. node.child.return = node;
  3384. node = node.child;
  3385. continue;
  3386. }
  3387. if (node === currentParent) {
  3388. return null;
  3389. }
  3390. while (!node.sibling) {
  3391. if (!node.return || node.return === currentParent) {
  3392. return null;
  3393. }
  3394. node = node.return;
  3395. }
  3396. node.sibling.return = node.return;
  3397. node = node.sibling;
  3398. } // Flow needs the return null here, but ESLint complains about it.
  3399. // eslint-disable-next-line no-unreachable
  3400. return null;
  3401. }
  3402. var attemptSynchronousHydration;
  3403. function setAttemptSynchronousHydration(fn) {
  3404. attemptSynchronousHydration = fn;
  3405. }
  3406. var attemptUserBlockingHydration;
  3407. function setAttemptUserBlockingHydration(fn) {
  3408. attemptUserBlockingHydration = fn;
  3409. }
  3410. var attemptContinuousHydration;
  3411. function setAttemptContinuousHydration(fn) {
  3412. attemptContinuousHydration = fn;
  3413. }
  3414. var attemptHydrationAtCurrentPriority;
  3415. function setAttemptHydrationAtCurrentPriority(fn) {
  3416. attemptHydrationAtCurrentPriority = fn;
  3417. } // TODO: Upgrade this definition once we're on a newer version of Flow that
  3418. // has this definition built-in.
  3419. var hasScheduledReplayAttempt = false; // The queue of discrete events to be replayed.
  3420. var queuedDiscreteEvents = []; // Indicates if any continuous event targets are non-null for early bailout.
  3421. // if the last target was dehydrated.
  3422. var queuedFocus = null;
  3423. var queuedDrag = null;
  3424. var queuedMouse = null; // For pointer events there can be one latest event per pointerId.
  3425. var queuedPointers = new Map();
  3426. var queuedPointerCaptures = new Map(); // We could consider replaying selectionchange and touchmoves too.
  3427. var queuedExplicitHydrationTargets = [];
  3428. function hasQueuedDiscreteEvents() {
  3429. return queuedDiscreteEvents.length > 0;
  3430. }
  3431. var discreteReplayableEvents = [TOP_MOUSE_DOWN, TOP_MOUSE_UP, TOP_TOUCH_CANCEL, TOP_TOUCH_END, TOP_TOUCH_START, TOP_AUX_CLICK, TOP_DOUBLE_CLICK, TOP_POINTER_CANCEL, TOP_POINTER_DOWN, TOP_POINTER_UP, TOP_DRAG_END, TOP_DRAG_START, TOP_DROP, TOP_COMPOSITION_END, TOP_COMPOSITION_START, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_INPUT, TOP_TEXT_INPUT, TOP_CLOSE, TOP_CANCEL, TOP_COPY, TOP_CUT, TOP_PASTE, TOP_CLICK, TOP_CHANGE, TOP_CONTEXT_MENU, TOP_RESET, TOP_SUBMIT];
  3432. var continuousReplayableEvents = [TOP_FOCUS, TOP_BLUR, TOP_DRAG_ENTER, TOP_DRAG_LEAVE, TOP_MOUSE_OVER, TOP_MOUSE_OUT, TOP_POINTER_OVER, TOP_POINTER_OUT, TOP_GOT_POINTER_CAPTURE, TOP_LOST_POINTER_CAPTURE];
  3433. function isReplayableDiscreteEvent(eventType) {
  3434. return discreteReplayableEvents.indexOf(eventType) > -1;
  3435. }
  3436. function trapReplayableEvent(topLevelType, document, listeningSet) {
  3437. listenToTopLevel(topLevelType, document, listeningSet);
  3438. if (enableFlareAPI) {
  3439. // Trap events for the responder system.
  3440. var passiveEventKey = unsafeCastDOMTopLevelTypeToString(topLevelType) + '_passive';
  3441. if (!listeningSet.has(passiveEventKey)) {
  3442. trapEventForResponderEventSystem(document, topLevelType, true);
  3443. listeningSet.add(passiveEventKey);
  3444. } // TODO: This listens to all events as active which might have
  3445. // undesirable effects. It's also unnecessary to have both
  3446. // passive and active listeners. Instead, we could start with
  3447. // a passive and upgrade it to an active one if needed.
  3448. // For replaying purposes the active is never needed since we
  3449. // currently don't preventDefault.
  3450. var activeEventKey = unsafeCastDOMTopLevelTypeToString(topLevelType) + '_active';
  3451. if (!listeningSet.has(activeEventKey)) {
  3452. trapEventForResponderEventSystem(document, topLevelType, false);
  3453. listeningSet.add(activeEventKey);
  3454. }
  3455. }
  3456. }
  3457. function eagerlyTrapReplayableEvents(document) {
  3458. var listeningSet = getListeningSetForElement(document); // Discrete
  3459. discreteReplayableEvents.forEach(function (topLevelType) {
  3460. trapReplayableEvent(topLevelType, document, listeningSet);
  3461. }); // Continuous
  3462. continuousReplayableEvents.forEach(function (topLevelType) {
  3463. trapReplayableEvent(topLevelType, document, listeningSet);
  3464. });
  3465. }
  3466. function createQueuedReplayableEvent(blockedOn, topLevelType, eventSystemFlags, nativeEvent) {
  3467. return {
  3468. blockedOn: blockedOn,
  3469. topLevelType: topLevelType,
  3470. eventSystemFlags: eventSystemFlags | IS_REPLAYED,
  3471. nativeEvent: nativeEvent
  3472. };
  3473. }
  3474. function queueDiscreteEvent(blockedOn, topLevelType, eventSystemFlags, nativeEvent) {
  3475. var queuedEvent = createQueuedReplayableEvent(blockedOn, topLevelType, eventSystemFlags, nativeEvent);
  3476. queuedDiscreteEvents.push(queuedEvent);
  3477. if (enableSelectiveHydration) {
  3478. if (queuedDiscreteEvents.length === 1) {
  3479. // If this was the first discrete event, we might be able to
  3480. // synchronously unblock it so that preventDefault still works.
  3481. while (queuedEvent.blockedOn !== null) {
  3482. var _fiber = getInstanceFromNode$1(queuedEvent.blockedOn);
  3483. if (_fiber === null) {
  3484. break;
  3485. }
  3486. attemptSynchronousHydration(_fiber);
  3487. if (queuedEvent.blockedOn === null) {
  3488. // We got unblocked by hydration. Let's try again.
  3489. replayUnblockedEvents(); // If we're reblocked, on an inner boundary, we might need
  3490. // to attempt hydrating that one.
  3491. continue;
  3492. } else {
  3493. // We're still blocked from hydation, we have to give up
  3494. // and replay later.
  3495. break;
  3496. }
  3497. }
  3498. }
  3499. }
  3500. } // Resets the replaying for this type of continuous event to no event.
  3501. function clearIfContinuousEvent(topLevelType, nativeEvent) {
  3502. switch (topLevelType) {
  3503. case TOP_FOCUS:
  3504. case TOP_BLUR:
  3505. queuedFocus = null;
  3506. break;
  3507. case TOP_DRAG_ENTER:
  3508. case TOP_DRAG_LEAVE:
  3509. queuedDrag = null;
  3510. break;
  3511. case TOP_MOUSE_OVER:
  3512. case TOP_MOUSE_OUT:
  3513. queuedMouse = null;
  3514. break;
  3515. case TOP_POINTER_OVER:
  3516. case TOP_POINTER_OUT:
  3517. {
  3518. var pointerId = nativeEvent.pointerId;
  3519. queuedPointers.delete(pointerId);
  3520. break;
  3521. }
  3522. case TOP_GOT_POINTER_CAPTURE:
  3523. case TOP_LOST_POINTER_CAPTURE:
  3524. {
  3525. var _pointerId = nativeEvent.pointerId;
  3526. queuedPointerCaptures.delete(_pointerId);
  3527. break;
  3528. }
  3529. }
  3530. }
  3531. function accumulateOrCreateContinuousQueuedReplayableEvent(existingQueuedEvent, blockedOn, topLevelType, eventSystemFlags, nativeEvent) {
  3532. if (existingQueuedEvent === null || existingQueuedEvent.nativeEvent !== nativeEvent) {
  3533. var queuedEvent = createQueuedReplayableEvent(blockedOn, topLevelType, eventSystemFlags, nativeEvent);
  3534. if (blockedOn !== null) {
  3535. var _fiber2 = getInstanceFromNode$1(blockedOn);
  3536. if (_fiber2 !== null) {
  3537. // Attempt to increase the priority of this target.
  3538. attemptContinuousHydration(_fiber2);
  3539. }
  3540. }
  3541. return queuedEvent;
  3542. } // If we have already queued this exact event, then it's because
  3543. // the different event systems have different DOM event listeners.
  3544. // We can accumulate the flags and store a single event to be
  3545. // replayed.
  3546. existingQueuedEvent.eventSystemFlags |= eventSystemFlags;
  3547. return existingQueuedEvent;
  3548. }
  3549. function queueIfContinuousEvent(blockedOn, topLevelType, eventSystemFlags, nativeEvent) {
  3550. // These set relatedTarget to null because the replayed event will be treated as if we
  3551. // moved from outside the window (no target) onto the target once it hydrates.
  3552. // Instead of mutating we could clone the event.
  3553. switch (topLevelType) {
  3554. case TOP_FOCUS:
  3555. {
  3556. var focusEvent = nativeEvent;
  3557. queuedFocus = accumulateOrCreateContinuousQueuedReplayableEvent(queuedFocus, blockedOn, topLevelType, eventSystemFlags, focusEvent);
  3558. return true;
  3559. }
  3560. case TOP_DRAG_ENTER:
  3561. {
  3562. var dragEvent = nativeEvent;
  3563. queuedDrag = accumulateOrCreateContinuousQueuedReplayableEvent(queuedDrag, blockedOn, topLevelType, eventSystemFlags, dragEvent);
  3564. return true;
  3565. }
  3566. case TOP_MOUSE_OVER:
  3567. {
  3568. var mouseEvent = nativeEvent;
  3569. queuedMouse = accumulateOrCreateContinuousQueuedReplayableEvent(queuedMouse, blockedOn, topLevelType, eventSystemFlags, mouseEvent);
  3570. return true;
  3571. }
  3572. case TOP_POINTER_OVER:
  3573. {
  3574. var pointerEvent = nativeEvent;
  3575. var pointerId = pointerEvent.pointerId;
  3576. queuedPointers.set(pointerId, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointers.get(pointerId) || null, blockedOn, topLevelType, eventSystemFlags, pointerEvent));
  3577. return true;
  3578. }
  3579. case TOP_GOT_POINTER_CAPTURE:
  3580. {
  3581. var _pointerEvent = nativeEvent;
  3582. var _pointerId2 = _pointerEvent.pointerId;
  3583. queuedPointerCaptures.set(_pointerId2, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointerCaptures.get(_pointerId2) || null, blockedOn, topLevelType, eventSystemFlags, _pointerEvent));
  3584. return true;
  3585. }
  3586. }
  3587. return false;
  3588. } // Check if this target is unblocked. Returns true if it's unblocked.
  3589. function attemptExplicitHydrationTarget(queuedTarget) {
  3590. // TODO: This function shares a lot of logic with attemptToDispatchEvent.
  3591. // Try to unify them. It's a bit tricky since it would require two return
  3592. // values.
  3593. var targetInst = getClosestInstanceFromNode(queuedTarget.target);
  3594. if (targetInst !== null) {
  3595. var nearestMounted = getNearestMountedFiber(targetInst);
  3596. if (nearestMounted !== null) {
  3597. var tag = nearestMounted.tag;
  3598. if (tag === SuspenseComponent) {
  3599. var instance = getSuspenseInstanceFromFiber(nearestMounted);
  3600. if (instance !== null) {
  3601. // We're blocked on hydrating this boundary.
  3602. // Increase its priority.
  3603. queuedTarget.blockedOn = instance;
  3604. Scheduler.unstable_runWithPriority(queuedTarget.priority, function () {
  3605. attemptHydrationAtCurrentPriority(nearestMounted);
  3606. });
  3607. return;
  3608. }
  3609. } else if (tag === HostRoot) {
  3610. var root = nearestMounted.stateNode;
  3611. if (root.hydrate) {
  3612. queuedTarget.blockedOn = getContainerFromFiber(nearestMounted); // We don't currently have a way to increase the priority of
  3613. // a root other than sync.
  3614. return;
  3615. }
  3616. }
  3617. }
  3618. }
  3619. queuedTarget.blockedOn = null;
  3620. }
  3621. function queueExplicitHydrationTarget(target) {
  3622. if (enableSelectiveHydration) {
  3623. var priority = Scheduler.unstable_getCurrentPriorityLevel();
  3624. var queuedTarget = {
  3625. blockedOn: null,
  3626. target: target,
  3627. priority: priority
  3628. };
  3629. var i = 0;
  3630. for (; i < queuedExplicitHydrationTargets.length; i++) {
  3631. if (priority <= queuedExplicitHydrationTargets[i].priority) {
  3632. break;
  3633. }
  3634. }
  3635. queuedExplicitHydrationTargets.splice(i, 0, queuedTarget);
  3636. if (i === 0) {
  3637. attemptExplicitHydrationTarget(queuedTarget);
  3638. }
  3639. }
  3640. }
  3641. function attemptReplayContinuousQueuedEvent(queuedEvent) {
  3642. if (queuedEvent.blockedOn !== null) {
  3643. return false;
  3644. }
  3645. var nextBlockedOn = attemptToDispatchEvent(queuedEvent.topLevelType, queuedEvent.eventSystemFlags, queuedEvent.nativeEvent);
  3646. if (nextBlockedOn !== null) {
  3647. // We're still blocked. Try again later.
  3648. var _fiber3 = getInstanceFromNode$1(nextBlockedOn);
  3649. if (_fiber3 !== null) {
  3650. attemptContinuousHydration(_fiber3);
  3651. }
  3652. queuedEvent.blockedOn = nextBlockedOn;
  3653. return false;
  3654. }
  3655. return true;
  3656. }
  3657. function attemptReplayContinuousQueuedEventInMap(queuedEvent, key, map) {
  3658. if (attemptReplayContinuousQueuedEvent(queuedEvent)) {
  3659. map.delete(key);
  3660. }
  3661. }
  3662. function replayUnblockedEvents() {
  3663. hasScheduledReplayAttempt = false; // First replay discrete events.
  3664. while (queuedDiscreteEvents.length > 0) {
  3665. var nextDiscreteEvent = queuedDiscreteEvents[0];
  3666. if (nextDiscreteEvent.blockedOn !== null) {
  3667. // We're still blocked.
  3668. // Increase the priority of this boundary to unblock
  3669. // the next discrete event.
  3670. var _fiber4 = getInstanceFromNode$1(nextDiscreteEvent.blockedOn);
  3671. if (_fiber4 !== null) {
  3672. attemptUserBlockingHydration(_fiber4);
  3673. }
  3674. break;
  3675. }
  3676. var nextBlockedOn = attemptToDispatchEvent(nextDiscreteEvent.topLevelType, nextDiscreteEvent.eventSystemFlags, nextDiscreteEvent.nativeEvent);
  3677. if (nextBlockedOn !== null) {
  3678. // We're still blocked. Try again later.
  3679. nextDiscreteEvent.blockedOn = nextBlockedOn;
  3680. } else {
  3681. // We've successfully replayed the first event. Let's try the next one.
  3682. queuedDiscreteEvents.shift();
  3683. }
  3684. } // Next replay any continuous events.
  3685. if (queuedFocus !== null && attemptReplayContinuousQueuedEvent(queuedFocus)) {
  3686. queuedFocus = null;
  3687. }
  3688. if (queuedDrag !== null && attemptReplayContinuousQueuedEvent(queuedDrag)) {
  3689. queuedDrag = null;
  3690. }
  3691. if (queuedMouse !== null && attemptReplayContinuousQueuedEvent(queuedMouse)) {
  3692. queuedMouse = null;
  3693. }
  3694. queuedPointers.forEach(attemptReplayContinuousQueuedEventInMap);
  3695. queuedPointerCaptures.forEach(attemptReplayContinuousQueuedEventInMap);
  3696. }
  3697. function scheduleCallbackIfUnblocked(queuedEvent, unblocked) {
  3698. if (queuedEvent.blockedOn === unblocked) {
  3699. queuedEvent.blockedOn = null;
  3700. if (!hasScheduledReplayAttempt) {
  3701. hasScheduledReplayAttempt = true; // Schedule a callback to attempt replaying as many events as are
  3702. // now unblocked. This first might not actually be unblocked yet.
  3703. // We could check it early to avoid scheduling an unnecessary callback.
  3704. Scheduler.unstable_scheduleCallback(Scheduler.unstable_NormalPriority, replayUnblockedEvents);
  3705. }
  3706. }
  3707. }
  3708. function retryIfBlockedOn(unblocked) {
  3709. // Mark anything that was blocked on this as no longer blocked
  3710. // and eligible for a replay.
  3711. if (queuedDiscreteEvents.length > 0) {
  3712. scheduleCallbackIfUnblocked(queuedDiscreteEvents[0], unblocked); // This is a exponential search for each boundary that commits. I think it's
  3713. // worth it because we expect very few discrete events to queue up and once
  3714. // we are actually fully unblocked it will be fast to replay them.
  3715. for (var i = 1; i < queuedDiscreteEvents.length; i++) {
  3716. var queuedEvent = queuedDiscreteEvents[i];
  3717. if (queuedEvent.blockedOn === unblocked) {
  3718. queuedEvent.blockedOn = null;
  3719. }
  3720. }
  3721. }
  3722. if (queuedFocus !== null) {
  3723. scheduleCallbackIfUnblocked(queuedFocus, unblocked);
  3724. }
  3725. if (queuedDrag !== null) {
  3726. scheduleCallbackIfUnblocked(queuedDrag, unblocked);
  3727. }
  3728. if (queuedMouse !== null) {
  3729. scheduleCallbackIfUnblocked(queuedMouse, unblocked);
  3730. }
  3731. var unblock = function (queuedEvent) {
  3732. return scheduleCallbackIfUnblocked(queuedEvent, unblocked);
  3733. };
  3734. queuedPointers.forEach(unblock);
  3735. queuedPointerCaptures.forEach(unblock);
  3736. for (var _i = 0; _i < queuedExplicitHydrationTargets.length; _i++) {
  3737. var queuedTarget = queuedExplicitHydrationTargets[_i];
  3738. if (queuedTarget.blockedOn === unblocked) {
  3739. queuedTarget.blockedOn = null;
  3740. }
  3741. }
  3742. while (queuedExplicitHydrationTargets.length > 0) {
  3743. var nextExplicitTarget = queuedExplicitHydrationTargets[0];
  3744. if (nextExplicitTarget.blockedOn !== null) {
  3745. // We're still blocked.
  3746. break;
  3747. } else {
  3748. attemptExplicitHydrationTarget(nextExplicitTarget);
  3749. if (nextExplicitTarget.blockedOn === null) {
  3750. // We're unblocked.
  3751. queuedExplicitHydrationTargets.shift();
  3752. }
  3753. }
  3754. }
  3755. }
  3756. function addEventBubbleListener(element, eventType, listener) {
  3757. element.addEventListener(eventType, listener, false);
  3758. }
  3759. function addEventCaptureListener(element, eventType, listener) {
  3760. element.addEventListener(eventType, listener, true);
  3761. }
  3762. function addEventCaptureListenerWithPassiveFlag(element, eventType, listener, passive) {
  3763. element.addEventListener(eventType, listener, {
  3764. capture: true,
  3765. passive: passive
  3766. });
  3767. }
  3768. /**
  3769. * Gets the target node from a native browser event by accounting for
  3770. * inconsistencies in browser DOM APIs.
  3771. *
  3772. * @param {object} nativeEvent Native browser event.
  3773. * @return {DOMEventTarget} Target node.
  3774. */
  3775. function getEventTarget(nativeEvent) {
  3776. // Fallback to nativeEvent.srcElement for IE9
  3777. // https://github.com/facebook/react/issues/12506
  3778. var target = nativeEvent.target || nativeEvent.srcElement || window; // Normalize SVG <use> element events #4963
  3779. if (target.correspondingUseElement) {
  3780. target = target.correspondingUseElement;
  3781. } // Safari may fire events on text nodes (Node.TEXT_NODE is 3).
  3782. // @see http://www.quirksmode.org/js/events_properties.html
  3783. return target.nodeType === TEXT_NODE ? target.parentNode : target;
  3784. }
  3785. function getParent(inst) {
  3786. do {
  3787. inst = inst.return; // TODO: If this is a HostRoot we might want to bail out.
  3788. // That is depending on if we want nested subtrees (layers) to bubble
  3789. // events to their parent. We could also go through parentNode on the
  3790. // host node but that wouldn't work for React Native and doesn't let us
  3791. // do the portal feature.
  3792. } while (inst && inst.tag !== HostComponent);
  3793. if (inst) {
  3794. return inst;
  3795. }
  3796. return null;
  3797. }
  3798. /**
  3799. * Return the lowest common ancestor of A and B, or null if they are in
  3800. * different trees.
  3801. */
  3802. function getLowestCommonAncestor(instA, instB) {
  3803. var depthA = 0;
  3804. for (var tempA = instA; tempA; tempA = getParent(tempA)) {
  3805. depthA++;
  3806. }
  3807. var depthB = 0;
  3808. for (var tempB = instB; tempB; tempB = getParent(tempB)) {
  3809. depthB++;
  3810. } // If A is deeper, crawl up.
  3811. while (depthA - depthB > 0) {
  3812. instA = getParent(instA);
  3813. depthA--;
  3814. } // If B is deeper, crawl up.
  3815. while (depthB - depthA > 0) {
  3816. instB = getParent(instB);
  3817. depthB--;
  3818. } // Walk in lockstep until we find a match.
  3819. var depth = depthA;
  3820. while (depth--) {
  3821. if (instA === instB || instA === instB.alternate) {
  3822. return instA;
  3823. }
  3824. instA = getParent(instA);
  3825. instB = getParent(instB);
  3826. }
  3827. return null;
  3828. }
  3829. /**
  3830. * Return if A is an ancestor of B.
  3831. */
  3832. /**
  3833. * Return the parent instance of the passed-in instance.
  3834. */
  3835. /**
  3836. * Simulates the traversal of a two-phase, capture/bubble event dispatch.
  3837. */
  3838. function traverseTwoPhase(inst, fn, arg) {
  3839. var path = [];
  3840. while (inst) {
  3841. path.push(inst);
  3842. inst = getParent(inst);
  3843. }
  3844. var i;
  3845. for (i = path.length; i-- > 0;) {
  3846. fn(path[i], 'captured', arg);
  3847. }
  3848. for (i = 0; i < path.length; i++) {
  3849. fn(path[i], 'bubbled', arg);
  3850. }
  3851. }
  3852. /**
  3853. * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
  3854. * should would receive a `mouseEnter` or `mouseLeave` event.
  3855. *
  3856. * Does not invoke the callback on the nearest common ancestor because nothing
  3857. * "entered" or "left" that element.
  3858. */
  3859. function traverseEnterLeave(from, to, fn, argFrom, argTo) {
  3860. var common = from && to ? getLowestCommonAncestor(from, to) : null;
  3861. var pathFrom = [];
  3862. while (true) {
  3863. if (!from) {
  3864. break;
  3865. }
  3866. if (from === common) {
  3867. break;
  3868. }
  3869. var alternate = from.alternate;
  3870. if (alternate !== null && alternate === common) {
  3871. break;
  3872. }
  3873. pathFrom.push(from);
  3874. from = getParent(from);
  3875. }
  3876. var pathTo = [];
  3877. while (true) {
  3878. if (!to) {
  3879. break;
  3880. }
  3881. if (to === common) {
  3882. break;
  3883. }
  3884. var _alternate = to.alternate;
  3885. if (_alternate !== null && _alternate === common) {
  3886. break;
  3887. }
  3888. pathTo.push(to);
  3889. to = getParent(to);
  3890. }
  3891. for (var i = 0; i < pathFrom.length; i++) {
  3892. fn(pathFrom[i], 'bubbled', argFrom);
  3893. }
  3894. for (var _i = pathTo.length; _i-- > 0;) {
  3895. fn(pathTo[_i], 'captured', argTo);
  3896. }
  3897. }
  3898. /**
  3899. * Some event types have a notion of different registration names for different
  3900. * "phases" of propagation. This finds listeners by a given phase.
  3901. */
  3902. function listenerAtPhase(inst, event, propagationPhase) {
  3903. var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase];
  3904. return getListener(inst, registrationName);
  3905. }
  3906. /**
  3907. * A small set of propagation patterns, each of which will accept a small amount
  3908. * of information, and generate a set of "dispatch ready event objects" - which
  3909. * are sets of events that have already been annotated with a set of dispatched
  3910. * listener functions/ids. The API is designed this way to discourage these
  3911. * propagation strategies from actually executing the dispatches, since we
  3912. * always want to collect the entire set of dispatches before executing even a
  3913. * single one.
  3914. */
  3915. /**
  3916. * Tags a `SyntheticEvent` with dispatched listeners. Creating this function
  3917. * here, allows us to not have to bind or create functions for each event.
  3918. * Mutating the event's members allows us to not have to create a wrapping
  3919. * "dispatch" object that pairs the event with the listener.
  3920. */
  3921. function accumulateDirectionalDispatches(inst, phase, event) {
  3922. {
  3923. !inst ? warningWithoutStack$1(false, 'Dispatching inst must not be null') : void 0;
  3924. }
  3925. var listener = listenerAtPhase(inst, event, phase);
  3926. if (listener) {
  3927. event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
  3928. event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
  3929. }
  3930. }
  3931. /**
  3932. * Collect dispatches (must be entirely collected before dispatching - see unit
  3933. * tests). Lazily allocate the array to conserve memory. We must loop through
  3934. * each event and perform the traversal for each one. We cannot perform a
  3935. * single traversal for the entire collection of events because each event may
  3936. * have a different target.
  3937. */
  3938. function accumulateTwoPhaseDispatchesSingle(event) {
  3939. if (event && event.dispatchConfig.phasedRegistrationNames) {
  3940. traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
  3941. }
  3942. }
  3943. /**
  3944. * Accumulates without regard to direction, does not look for phased
  3945. * registration names. Same as `accumulateDirectDispatchesSingle` but without
  3946. * requiring that the `dispatchMarker` be the same as the dispatched ID.
  3947. */
  3948. function accumulateDispatches(inst, ignoredDirection, event) {
  3949. if (inst && event && event.dispatchConfig.registrationName) {
  3950. var registrationName = event.dispatchConfig.registrationName;
  3951. var listener = getListener(inst, registrationName);
  3952. if (listener) {
  3953. event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
  3954. event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
  3955. }
  3956. }
  3957. }
  3958. /**
  3959. * Accumulates dispatches on an `SyntheticEvent`, but only for the
  3960. * `dispatchMarker`.
  3961. * @param {SyntheticEvent} event
  3962. */
  3963. function accumulateDirectDispatchesSingle(event) {
  3964. if (event && event.dispatchConfig.registrationName) {
  3965. accumulateDispatches(event._targetInst, null, event);
  3966. }
  3967. }
  3968. function accumulateTwoPhaseDispatches(events) {
  3969. forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
  3970. }
  3971. function accumulateEnterLeaveDispatches(leave, enter, from, to) {
  3972. traverseEnterLeave(from, to, accumulateDispatches, leave, enter);
  3973. }
  3974. function accumulateDirectDispatches(events) {
  3975. forEachAccumulated(events, accumulateDirectDispatchesSingle);
  3976. }
  3977. /* eslint valid-typeof: 0 */
  3978. var EVENT_POOL_SIZE = 10;
  3979. /**
  3980. * @interface Event
  3981. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  3982. */
  3983. var EventInterface = {
  3984. type: null,
  3985. target: null,
  3986. // currentTarget is set when dispatching; no use in copying it here
  3987. currentTarget: function () {
  3988. return null;
  3989. },
  3990. eventPhase: null,
  3991. bubbles: null,
  3992. cancelable: null,
  3993. timeStamp: function (event) {
  3994. return event.timeStamp || Date.now();
  3995. },
  3996. defaultPrevented: null,
  3997. isTrusted: null
  3998. };
  3999. function functionThatReturnsTrue() {
  4000. return true;
  4001. }
  4002. function functionThatReturnsFalse() {
  4003. return false;
  4004. }
  4005. /**
  4006. * Synthetic events are dispatched by event plugins, typically in response to a
  4007. * top-level event delegation handler.
  4008. *
  4009. * These systems should generally use pooling to reduce the frequency of garbage
  4010. * collection. The system should check `isPersistent` to determine whether the
  4011. * event should be released into the pool after being dispatched. Users that
  4012. * need a persisted event should invoke `persist`.
  4013. *
  4014. * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
  4015. * normalizing browser quirks. Subclasses do not necessarily have to implement a
  4016. * DOM interface; custom application-specific events can also subclass this.
  4017. *
  4018. * @param {object} dispatchConfig Configuration used to dispatch this event.
  4019. * @param {*} targetInst Marker identifying the event target.
  4020. * @param {object} nativeEvent Native browser event.
  4021. * @param {DOMEventTarget} nativeEventTarget Target node.
  4022. */
  4023. function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) {
  4024. {
  4025. // these have a getter/setter for warnings
  4026. delete this.nativeEvent;
  4027. delete this.preventDefault;
  4028. delete this.stopPropagation;
  4029. delete this.isDefaultPrevented;
  4030. delete this.isPropagationStopped;
  4031. }
  4032. this.dispatchConfig = dispatchConfig;
  4033. this._targetInst = targetInst;
  4034. this.nativeEvent = nativeEvent;
  4035. var Interface = this.constructor.Interface;
  4036. for (var propName in Interface) {
  4037. if (!Interface.hasOwnProperty(propName)) {
  4038. continue;
  4039. }
  4040. {
  4041. delete this[propName]; // this has a getter/setter for warnings
  4042. }
  4043. var normalize = Interface[propName];
  4044. if (normalize) {
  4045. this[propName] = normalize(nativeEvent);
  4046. } else {
  4047. if (propName === 'target') {
  4048. this.target = nativeEventTarget;
  4049. } else {
  4050. this[propName] = nativeEvent[propName];
  4051. }
  4052. }
  4053. }
  4054. var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
  4055. if (defaultPrevented) {
  4056. this.isDefaultPrevented = functionThatReturnsTrue;
  4057. } else {
  4058. this.isDefaultPrevented = functionThatReturnsFalse;
  4059. }
  4060. this.isPropagationStopped = functionThatReturnsFalse;
  4061. return this;
  4062. }
  4063. _assign(SyntheticEvent.prototype, {
  4064. preventDefault: function () {
  4065. this.defaultPrevented = true;
  4066. var event = this.nativeEvent;
  4067. if (!event) {
  4068. return;
  4069. }
  4070. if (event.preventDefault) {
  4071. event.preventDefault();
  4072. } else if (typeof event.returnValue !== 'unknown') {
  4073. event.returnValue = false;
  4074. }
  4075. this.isDefaultPrevented = functionThatReturnsTrue;
  4076. },
  4077. stopPropagation: function () {
  4078. var event = this.nativeEvent;
  4079. if (!event) {
  4080. return;
  4081. }
  4082. if (event.stopPropagation) {
  4083. event.stopPropagation();
  4084. } else if (typeof event.cancelBubble !== 'unknown') {
  4085. // The ChangeEventPlugin registers a "propertychange" event for
  4086. // IE. This event does not support bubbling or cancelling, and
  4087. // any references to cancelBubble throw "Member not found". A
  4088. // typeof check of "unknown" circumvents this issue (and is also
  4089. // IE specific).
  4090. event.cancelBubble = true;
  4091. }
  4092. this.isPropagationStopped = functionThatReturnsTrue;
  4093. },
  4094. /**
  4095. * We release all dispatched `SyntheticEvent`s after each event loop, adding
  4096. * them back into the pool. This allows a way to hold onto a reference that
  4097. * won't be added back into the pool.
  4098. */
  4099. persist: function () {
  4100. this.isPersistent = functionThatReturnsTrue;
  4101. },
  4102. /**
  4103. * Checks if this event should be released back into the pool.
  4104. *
  4105. * @return {boolean} True if this should not be released, false otherwise.
  4106. */
  4107. isPersistent: functionThatReturnsFalse,
  4108. /**
  4109. * `PooledClass` looks for `destructor` on each instance it releases.
  4110. */
  4111. destructor: function () {
  4112. var Interface = this.constructor.Interface;
  4113. for (var propName in Interface) {
  4114. {
  4115. Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName]));
  4116. }
  4117. }
  4118. this.dispatchConfig = null;
  4119. this._targetInst = null;
  4120. this.nativeEvent = null;
  4121. this.isDefaultPrevented = functionThatReturnsFalse;
  4122. this.isPropagationStopped = functionThatReturnsFalse;
  4123. this._dispatchListeners = null;
  4124. this._dispatchInstances = null;
  4125. {
  4126. Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
  4127. Object.defineProperty(this, 'isDefaultPrevented', getPooledWarningPropertyDefinition('isDefaultPrevented', functionThatReturnsFalse));
  4128. Object.defineProperty(this, 'isPropagationStopped', getPooledWarningPropertyDefinition('isPropagationStopped', functionThatReturnsFalse));
  4129. Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', function () {}));
  4130. Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', function () {}));
  4131. }
  4132. }
  4133. });
  4134. SyntheticEvent.Interface = EventInterface;
  4135. /**
  4136. * Helper to reduce boilerplate when creating subclasses.
  4137. */
  4138. SyntheticEvent.extend = function (Interface) {
  4139. var Super = this;
  4140. var E = function () {};
  4141. E.prototype = Super.prototype;
  4142. var prototype = new E();
  4143. function Class() {
  4144. return Super.apply(this, arguments);
  4145. }
  4146. _assign(prototype, Class.prototype);
  4147. Class.prototype = prototype;
  4148. Class.prototype.constructor = Class;
  4149. Class.Interface = _assign({}, Super.Interface, Interface);
  4150. Class.extend = Super.extend;
  4151. addEventPoolingTo(Class);
  4152. return Class;
  4153. };
  4154. addEventPoolingTo(SyntheticEvent);
  4155. /**
  4156. * Helper to nullify syntheticEvent instance properties when destructing
  4157. *
  4158. * @param {String} propName
  4159. * @param {?object} getVal
  4160. * @return {object} defineProperty object
  4161. */
  4162. function getPooledWarningPropertyDefinition(propName, getVal) {
  4163. var isFunction = typeof getVal === 'function';
  4164. return {
  4165. configurable: true,
  4166. set: set,
  4167. get: get
  4168. };
  4169. function set(val) {
  4170. var action = isFunction ? 'setting the method' : 'setting the property';
  4171. warn(action, 'This is effectively a no-op');
  4172. return val;
  4173. }
  4174. function get() {
  4175. var action = isFunction ? 'accessing the method' : 'accessing the property';
  4176. var result = isFunction ? 'This is a no-op function' : 'This is set to null';
  4177. warn(action, result);
  4178. return getVal;
  4179. }
  4180. function warn(action, result) {
  4181. var warningCondition = false;
  4182. !warningCondition ? warningWithoutStack$1(false, "This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result) : void 0;
  4183. }
  4184. }
  4185. function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
  4186. var EventConstructor = this;
  4187. if (EventConstructor.eventPool.length) {
  4188. var instance = EventConstructor.eventPool.pop();
  4189. EventConstructor.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst);
  4190. return instance;
  4191. }
  4192. return new EventConstructor(dispatchConfig, targetInst, nativeEvent, nativeInst);
  4193. }
  4194. function releasePooledEvent(event) {
  4195. var EventConstructor = this;
  4196. if (!(event instanceof EventConstructor)) {
  4197. {
  4198. throw Error("Trying to release an event instance into a pool of a different type.");
  4199. }
  4200. }
  4201. event.destructor();
  4202. if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) {
  4203. EventConstructor.eventPool.push(event);
  4204. }
  4205. }
  4206. function addEventPoolingTo(EventConstructor) {
  4207. EventConstructor.eventPool = [];
  4208. EventConstructor.getPooled = getPooledEvent;
  4209. EventConstructor.release = releasePooledEvent;
  4210. }
  4211. /**
  4212. * @interface Event
  4213. * @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface
  4214. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent
  4215. */
  4216. var SyntheticAnimationEvent = SyntheticEvent.extend({
  4217. animationName: null,
  4218. elapsedTime: null,
  4219. pseudoElement: null
  4220. });
  4221. /**
  4222. * @interface Event
  4223. * @see http://www.w3.org/TR/clipboard-apis/
  4224. */
  4225. var SyntheticClipboardEvent = SyntheticEvent.extend({
  4226. clipboardData: function (event) {
  4227. return 'clipboardData' in event ? event.clipboardData : window.clipboardData;
  4228. }
  4229. });
  4230. var SyntheticUIEvent = SyntheticEvent.extend({
  4231. view: null,
  4232. detail: null
  4233. });
  4234. /**
  4235. * @interface FocusEvent
  4236. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  4237. */
  4238. var SyntheticFocusEvent = SyntheticUIEvent.extend({
  4239. relatedTarget: null
  4240. });
  4241. /**
  4242. * `charCode` represents the actual "character code" and is safe to use with
  4243. * `String.fromCharCode`. As such, only keys that correspond to printable
  4244. * characters produce a valid `charCode`, the only exception to this is Enter.
  4245. * The Tab-key is considered non-printable and does not have a `charCode`,
  4246. * presumably because it does not produce a tab-character in browsers.
  4247. *
  4248. * @param {object} nativeEvent Native browser event.
  4249. * @return {number} Normalized `charCode` property.
  4250. */
  4251. function getEventCharCode(nativeEvent) {
  4252. var charCode;
  4253. var keyCode = nativeEvent.keyCode;
  4254. if ('charCode' in nativeEvent) {
  4255. charCode = nativeEvent.charCode; // FF does not set `charCode` for the Enter-key, check against `keyCode`.
  4256. if (charCode === 0 && keyCode === 13) {
  4257. charCode = 13;
  4258. }
  4259. } else {
  4260. // IE8 does not implement `charCode`, but `keyCode` has the correct value.
  4261. charCode = keyCode;
  4262. } // IE and Edge (on Windows) and Chrome / Safari (on Windows and Linux)
  4263. // report Enter as charCode 10 when ctrl is pressed.
  4264. if (charCode === 10) {
  4265. charCode = 13;
  4266. } // Some non-printable keys are reported in `charCode`/`keyCode`, discard them.
  4267. // Must not discard the (non-)printable Enter-key.
  4268. if (charCode >= 32 || charCode === 13) {
  4269. return charCode;
  4270. }
  4271. return 0;
  4272. }
  4273. /**
  4274. * Normalization of deprecated HTML5 `key` values
  4275. * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
  4276. */
  4277. var normalizeKey = {
  4278. Esc: 'Escape',
  4279. Spacebar: ' ',
  4280. Left: 'ArrowLeft',
  4281. Up: 'ArrowUp',
  4282. Right: 'ArrowRight',
  4283. Down: 'ArrowDown',
  4284. Del: 'Delete',
  4285. Win: 'OS',
  4286. Menu: 'ContextMenu',
  4287. Apps: 'ContextMenu',
  4288. Scroll: 'ScrollLock',
  4289. MozPrintableKey: 'Unidentified'
  4290. };
  4291. /**
  4292. * Translation from legacy `keyCode` to HTML5 `key`
  4293. * Only special keys supported, all others depend on keyboard layout or browser
  4294. * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
  4295. */
  4296. var translateToKey = {
  4297. '8': 'Backspace',
  4298. '9': 'Tab',
  4299. '12': 'Clear',
  4300. '13': 'Enter',
  4301. '16': 'Shift',
  4302. '17': 'Control',
  4303. '18': 'Alt',
  4304. '19': 'Pause',
  4305. '20': 'CapsLock',
  4306. '27': 'Escape',
  4307. '32': ' ',
  4308. '33': 'PageUp',
  4309. '34': 'PageDown',
  4310. '35': 'End',
  4311. '36': 'Home',
  4312. '37': 'ArrowLeft',
  4313. '38': 'ArrowUp',
  4314. '39': 'ArrowRight',
  4315. '40': 'ArrowDown',
  4316. '45': 'Insert',
  4317. '46': 'Delete',
  4318. '112': 'F1',
  4319. '113': 'F2',
  4320. '114': 'F3',
  4321. '115': 'F4',
  4322. '116': 'F5',
  4323. '117': 'F6',
  4324. '118': 'F7',
  4325. '119': 'F8',
  4326. '120': 'F9',
  4327. '121': 'F10',
  4328. '122': 'F11',
  4329. '123': 'F12',
  4330. '144': 'NumLock',
  4331. '145': 'ScrollLock',
  4332. '224': 'Meta'
  4333. };
  4334. /**
  4335. * @param {object} nativeEvent Native browser event.
  4336. * @return {string} Normalized `key` property.
  4337. */
  4338. function getEventKey(nativeEvent) {
  4339. if (nativeEvent.key) {
  4340. // Normalize inconsistent values reported by browsers due to
  4341. // implementations of a working draft specification.
  4342. // FireFox implements `key` but returns `MozPrintableKey` for all
  4343. // printable characters (normalized to `Unidentified`), ignore it.
  4344. var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
  4345. if (key !== 'Unidentified') {
  4346. return key;
  4347. }
  4348. } // Browser does not implement `key`, polyfill as much of it as we can.
  4349. if (nativeEvent.type === 'keypress') {
  4350. var charCode = getEventCharCode(nativeEvent); // The enter-key is technically both printable and non-printable and can
  4351. // thus be captured by `keypress`, no other non-printable key should.
  4352. return charCode === 13 ? 'Enter' : String.fromCharCode(charCode);
  4353. }
  4354. if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {
  4355. // While user keyboard layout determines the actual meaning of each
  4356. // `keyCode` value, almost all function keys have a universal value.
  4357. return translateToKey[nativeEvent.keyCode] || 'Unidentified';
  4358. }
  4359. return '';
  4360. }
  4361. /**
  4362. * Translation from modifier key to the associated property in the event.
  4363. * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
  4364. */
  4365. var modifierKeyToProp = {
  4366. Alt: 'altKey',
  4367. Control: 'ctrlKey',
  4368. Meta: 'metaKey',
  4369. Shift: 'shiftKey'
  4370. }; // Older browsers (Safari <= 10, iOS Safari <= 10.2) do not support
  4371. // getModifierState. If getModifierState is not supported, we map it to a set of
  4372. // modifier keys exposed by the event. In this case, Lock-keys are not supported.
  4373. function modifierStateGetter(keyArg) {
  4374. var syntheticEvent = this;
  4375. var nativeEvent = syntheticEvent.nativeEvent;
  4376. if (nativeEvent.getModifierState) {
  4377. return nativeEvent.getModifierState(keyArg);
  4378. }
  4379. var keyProp = modifierKeyToProp[keyArg];
  4380. return keyProp ? !!nativeEvent[keyProp] : false;
  4381. }
  4382. function getEventModifierState(nativeEvent) {
  4383. return modifierStateGetter;
  4384. }
  4385. /**
  4386. * @interface KeyboardEvent
  4387. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  4388. */
  4389. var SyntheticKeyboardEvent = SyntheticUIEvent.extend({
  4390. key: getEventKey,
  4391. location: null,
  4392. ctrlKey: null,
  4393. shiftKey: null,
  4394. altKey: null,
  4395. metaKey: null,
  4396. repeat: null,
  4397. locale: null,
  4398. getModifierState: getEventModifierState,
  4399. // Legacy Interface
  4400. charCode: function (event) {
  4401. // `charCode` is the result of a KeyPress event and represents the value of
  4402. // the actual printable character.
  4403. // KeyPress is deprecated, but its replacement is not yet final and not
  4404. // implemented in any major browser. Only KeyPress has charCode.
  4405. if (event.type === 'keypress') {
  4406. return getEventCharCode(event);
  4407. }
  4408. return 0;
  4409. },
  4410. keyCode: function (event) {
  4411. // `keyCode` is the result of a KeyDown/Up event and represents the value of
  4412. // physical keyboard key.
  4413. // The actual meaning of the value depends on the users' keyboard layout
  4414. // which cannot be detected. Assuming that it is a US keyboard layout
  4415. // provides a surprisingly accurate mapping for US and European users.
  4416. // Due to this, it is left to the user to implement at this time.
  4417. if (event.type === 'keydown' || event.type === 'keyup') {
  4418. return event.keyCode;
  4419. }
  4420. return 0;
  4421. },
  4422. which: function (event) {
  4423. // `which` is an alias for either `keyCode` or `charCode` depending on the
  4424. // type of the event.
  4425. if (event.type === 'keypress') {
  4426. return getEventCharCode(event);
  4427. }
  4428. if (event.type === 'keydown' || event.type === 'keyup') {
  4429. return event.keyCode;
  4430. }
  4431. return 0;
  4432. }
  4433. });
  4434. var previousScreenX = 0;
  4435. var previousScreenY = 0; // Use flags to signal movementX/Y has already been set
  4436. var isMovementXSet = false;
  4437. var isMovementYSet = false;
  4438. /**
  4439. * @interface MouseEvent
  4440. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  4441. */
  4442. var SyntheticMouseEvent = SyntheticUIEvent.extend({
  4443. screenX: null,
  4444. screenY: null,
  4445. clientX: null,
  4446. clientY: null,
  4447. pageX: null,
  4448. pageY: null,
  4449. ctrlKey: null,
  4450. shiftKey: null,
  4451. altKey: null,
  4452. metaKey: null,
  4453. getModifierState: getEventModifierState,
  4454. button: null,
  4455. buttons: null,
  4456. relatedTarget: function (event) {
  4457. return event.relatedTarget || (event.fromElement === event.srcElement ? event.toElement : event.fromElement);
  4458. },
  4459. movementX: function (event) {
  4460. if ('movementX' in event) {
  4461. return event.movementX;
  4462. }
  4463. var screenX = previousScreenX;
  4464. previousScreenX = event.screenX;
  4465. if (!isMovementXSet) {
  4466. isMovementXSet = true;
  4467. return 0;
  4468. }
  4469. return event.type === 'mousemove' ? event.screenX - screenX : 0;
  4470. },
  4471. movementY: function (event) {
  4472. if ('movementY' in event) {
  4473. return event.movementY;
  4474. }
  4475. var screenY = previousScreenY;
  4476. previousScreenY = event.screenY;
  4477. if (!isMovementYSet) {
  4478. isMovementYSet = true;
  4479. return 0;
  4480. }
  4481. return event.type === 'mousemove' ? event.screenY - screenY : 0;
  4482. }
  4483. });
  4484. /**
  4485. * @interface PointerEvent
  4486. * @see http://www.w3.org/TR/pointerevents/
  4487. */
  4488. var SyntheticPointerEvent = SyntheticMouseEvent.extend({
  4489. pointerId: null,
  4490. width: null,
  4491. height: null,
  4492. pressure: null,
  4493. tangentialPressure: null,
  4494. tiltX: null,
  4495. tiltY: null,
  4496. twist: null,
  4497. pointerType: null,
  4498. isPrimary: null
  4499. });
  4500. /**
  4501. * @interface DragEvent
  4502. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  4503. */
  4504. var SyntheticDragEvent = SyntheticMouseEvent.extend({
  4505. dataTransfer: null
  4506. });
  4507. /**
  4508. * @interface TouchEvent
  4509. * @see http://www.w3.org/TR/touch-events/
  4510. */
  4511. var SyntheticTouchEvent = SyntheticUIEvent.extend({
  4512. touches: null,
  4513. targetTouches: null,
  4514. changedTouches: null,
  4515. altKey: null,
  4516. metaKey: null,
  4517. ctrlKey: null,
  4518. shiftKey: null,
  4519. getModifierState: getEventModifierState
  4520. });
  4521. /**
  4522. * @interface Event
  4523. * @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events-
  4524. * @see https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent
  4525. */
  4526. var SyntheticTransitionEvent = SyntheticEvent.extend({
  4527. propertyName: null,
  4528. elapsedTime: null,
  4529. pseudoElement: null
  4530. });
  4531. /**
  4532. * @interface WheelEvent
  4533. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  4534. */
  4535. var SyntheticWheelEvent = SyntheticMouseEvent.extend({
  4536. deltaX: function (event) {
  4537. return 'deltaX' in event ? event.deltaX : // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
  4538. 'wheelDeltaX' in event ? -event.wheelDeltaX : 0;
  4539. },
  4540. deltaY: function (event) {
  4541. return 'deltaY' in event ? event.deltaY : // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
  4542. 'wheelDeltaY' in event ? -event.wheelDeltaY : // Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
  4543. 'wheelDelta' in event ? -event.wheelDelta : 0;
  4544. },
  4545. deltaZ: null,
  4546. // Browsers without "deltaMode" is reporting in raw wheel delta where one
  4547. // notch on the scroll is always +/- 120, roughly equivalent to pixels.
  4548. // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or
  4549. // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size.
  4550. deltaMode: null
  4551. });
  4552. /**
  4553. * Turns
  4554. * ['abort', ...]
  4555. * into
  4556. * eventTypes = {
  4557. * 'abort': {
  4558. * phasedRegistrationNames: {
  4559. * bubbled: 'onAbort',
  4560. * captured: 'onAbortCapture',
  4561. * },
  4562. * dependencies: [TOP_ABORT],
  4563. * },
  4564. * ...
  4565. * };
  4566. * topLevelEventsToDispatchConfig = new Map([
  4567. * [TOP_ABORT, { sameConfig }],
  4568. * ]);
  4569. */
  4570. var eventTuples = [// Discrete events
  4571. [TOP_BLUR, 'blur', DiscreteEvent], [TOP_CANCEL, 'cancel', DiscreteEvent], [TOP_CLICK, 'click', DiscreteEvent], [TOP_CLOSE, 'close', DiscreteEvent], [TOP_CONTEXT_MENU, 'contextMenu', DiscreteEvent], [TOP_COPY, 'copy', DiscreteEvent], [TOP_CUT, 'cut', DiscreteEvent], [TOP_AUX_CLICK, 'auxClick', DiscreteEvent], [TOP_DOUBLE_CLICK, 'doubleClick', DiscreteEvent], [TOP_DRAG_END, 'dragEnd', DiscreteEvent], [TOP_DRAG_START, 'dragStart', DiscreteEvent], [TOP_DROP, 'drop', DiscreteEvent], [TOP_FOCUS, 'focus', DiscreteEvent], [TOP_INPUT, 'input', DiscreteEvent], [TOP_INVALID, 'invalid', DiscreteEvent], [TOP_KEY_DOWN, 'keyDown', DiscreteEvent], [TOP_KEY_PRESS, 'keyPress', DiscreteEvent], [TOP_KEY_UP, 'keyUp', DiscreteEvent], [TOP_MOUSE_DOWN, 'mouseDown', DiscreteEvent], [TOP_MOUSE_UP, 'mouseUp', DiscreteEvent], [TOP_PASTE, 'paste', DiscreteEvent], [TOP_PAUSE, 'pause', DiscreteEvent], [TOP_PLAY, 'play', DiscreteEvent], [TOP_POINTER_CANCEL, 'pointerCancel', DiscreteEvent], [TOP_POINTER_DOWN, 'pointerDown', DiscreteEvent], [TOP_POINTER_UP, 'pointerUp', DiscreteEvent], [TOP_RATE_CHANGE, 'rateChange', DiscreteEvent], [TOP_RESET, 'reset', DiscreteEvent], [TOP_SEEKED, 'seeked', DiscreteEvent], [TOP_SUBMIT, 'submit', DiscreteEvent], [TOP_TOUCH_CANCEL, 'touchCancel', DiscreteEvent], [TOP_TOUCH_END, 'touchEnd', DiscreteEvent], [TOP_TOUCH_START, 'touchStart', DiscreteEvent], [TOP_VOLUME_CHANGE, 'volumeChange', DiscreteEvent], // User-blocking events
  4572. [TOP_DRAG, 'drag', UserBlockingEvent], [TOP_DRAG_ENTER, 'dragEnter', UserBlockingEvent], [TOP_DRAG_EXIT, 'dragExit', UserBlockingEvent], [TOP_DRAG_LEAVE, 'dragLeave', UserBlockingEvent], [TOP_DRAG_OVER, 'dragOver', UserBlockingEvent], [TOP_MOUSE_MOVE, 'mouseMove', UserBlockingEvent], [TOP_MOUSE_OUT, 'mouseOut', UserBlockingEvent], [TOP_MOUSE_OVER, 'mouseOver', UserBlockingEvent], [TOP_POINTER_MOVE, 'pointerMove', UserBlockingEvent], [TOP_POINTER_OUT, 'pointerOut', UserBlockingEvent], [TOP_POINTER_OVER, 'pointerOver', UserBlockingEvent], [TOP_SCROLL, 'scroll', UserBlockingEvent], [TOP_TOGGLE, 'toggle', UserBlockingEvent], [TOP_TOUCH_MOVE, 'touchMove', UserBlockingEvent], [TOP_WHEEL, 'wheel', UserBlockingEvent], // Continuous events
  4573. [TOP_ABORT, 'abort', ContinuousEvent], [TOP_ANIMATION_END, 'animationEnd', ContinuousEvent], [TOP_ANIMATION_ITERATION, 'animationIteration', ContinuousEvent], [TOP_ANIMATION_START, 'animationStart', ContinuousEvent], [TOP_CAN_PLAY, 'canPlay', ContinuousEvent], [TOP_CAN_PLAY_THROUGH, 'canPlayThrough', ContinuousEvent], [TOP_DURATION_CHANGE, 'durationChange', ContinuousEvent], [TOP_EMPTIED, 'emptied', ContinuousEvent], [TOP_ENCRYPTED, 'encrypted', ContinuousEvent], [TOP_ENDED, 'ended', ContinuousEvent], [TOP_ERROR, 'error', ContinuousEvent], [TOP_GOT_POINTER_CAPTURE, 'gotPointerCapture', ContinuousEvent], [TOP_LOAD, 'load', ContinuousEvent], [TOP_LOADED_DATA, 'loadedData', ContinuousEvent], [TOP_LOADED_METADATA, 'loadedMetadata', ContinuousEvent], [TOP_LOAD_START, 'loadStart', ContinuousEvent], [TOP_LOST_POINTER_CAPTURE, 'lostPointerCapture', ContinuousEvent], [TOP_PLAYING, 'playing', ContinuousEvent], [TOP_PROGRESS, 'progress', ContinuousEvent], [TOP_SEEKING, 'seeking', ContinuousEvent], [TOP_STALLED, 'stalled', ContinuousEvent], [TOP_SUSPEND, 'suspend', ContinuousEvent], [TOP_TIME_UPDATE, 'timeUpdate', ContinuousEvent], [TOP_TRANSITION_END, 'transitionEnd', ContinuousEvent], [TOP_WAITING, 'waiting', ContinuousEvent]];
  4574. var eventTypes = {};
  4575. var topLevelEventsToDispatchConfig = {};
  4576. for (var i = 0; i < eventTuples.length; i++) {
  4577. var eventTuple = eventTuples[i];
  4578. var topEvent = eventTuple[0];
  4579. var event = eventTuple[1];
  4580. var eventPriority = eventTuple[2];
  4581. var capitalizedEvent = event[0].toUpperCase() + event.slice(1);
  4582. var onEvent = 'on' + capitalizedEvent;
  4583. var config = {
  4584. phasedRegistrationNames: {
  4585. bubbled: onEvent,
  4586. captured: onEvent + 'Capture'
  4587. },
  4588. dependencies: [topEvent],
  4589. eventPriority: eventPriority
  4590. };
  4591. eventTypes[event] = config;
  4592. topLevelEventsToDispatchConfig[topEvent] = config;
  4593. } // Only used in DEV for exhaustiveness validation.
  4594. var knownHTMLTopLevelTypes = [TOP_ABORT, TOP_CANCEL, TOP_CAN_PLAY, TOP_CAN_PLAY_THROUGH, TOP_CLOSE, TOP_DURATION_CHANGE, TOP_EMPTIED, TOP_ENCRYPTED, TOP_ENDED, TOP_ERROR, TOP_INPUT, TOP_INVALID, TOP_LOAD, TOP_LOADED_DATA, TOP_LOADED_METADATA, TOP_LOAD_START, TOP_PAUSE, TOP_PLAY, TOP_PLAYING, TOP_PROGRESS, TOP_RATE_CHANGE, TOP_RESET, TOP_SEEKED, TOP_SEEKING, TOP_STALLED, TOP_SUBMIT, TOP_SUSPEND, TOP_TIME_UPDATE, TOP_TOGGLE, TOP_VOLUME_CHANGE, TOP_WAITING];
  4595. var SimpleEventPlugin = {
  4596. eventTypes: eventTypes,
  4597. getEventPriority: function (topLevelType) {
  4598. var config = topLevelEventsToDispatchConfig[topLevelType];
  4599. return config !== undefined ? config.eventPriority : ContinuousEvent;
  4600. },
  4601. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) {
  4602. var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType];
  4603. if (!dispatchConfig) {
  4604. return null;
  4605. }
  4606. var EventConstructor;
  4607. switch (topLevelType) {
  4608. case TOP_KEY_PRESS:
  4609. // Firefox creates a keypress event for function keys too. This removes
  4610. // the unwanted keypress events. Enter is however both printable and
  4611. // non-printable. One would expect Tab to be as well (but it isn't).
  4612. if (getEventCharCode(nativeEvent) === 0) {
  4613. return null;
  4614. }
  4615. /* falls through */
  4616. case TOP_KEY_DOWN:
  4617. case TOP_KEY_UP:
  4618. EventConstructor = SyntheticKeyboardEvent;
  4619. break;
  4620. case TOP_BLUR:
  4621. case TOP_FOCUS:
  4622. EventConstructor = SyntheticFocusEvent;
  4623. break;
  4624. case TOP_CLICK:
  4625. // Firefox creates a click event on right mouse clicks. This removes the
  4626. // unwanted click events.
  4627. if (nativeEvent.button === 2) {
  4628. return null;
  4629. }
  4630. /* falls through */
  4631. case TOP_AUX_CLICK:
  4632. case TOP_DOUBLE_CLICK:
  4633. case TOP_MOUSE_DOWN:
  4634. case TOP_MOUSE_MOVE:
  4635. case TOP_MOUSE_UP: // TODO: Disabled elements should not respond to mouse events
  4636. /* falls through */
  4637. case TOP_MOUSE_OUT:
  4638. case TOP_MOUSE_OVER:
  4639. case TOP_CONTEXT_MENU:
  4640. EventConstructor = SyntheticMouseEvent;
  4641. break;
  4642. case TOP_DRAG:
  4643. case TOP_DRAG_END:
  4644. case TOP_DRAG_ENTER:
  4645. case TOP_DRAG_EXIT:
  4646. case TOP_DRAG_LEAVE:
  4647. case TOP_DRAG_OVER:
  4648. case TOP_DRAG_START:
  4649. case TOP_DROP:
  4650. EventConstructor = SyntheticDragEvent;
  4651. break;
  4652. case TOP_TOUCH_CANCEL:
  4653. case TOP_TOUCH_END:
  4654. case TOP_TOUCH_MOVE:
  4655. case TOP_TOUCH_START:
  4656. EventConstructor = SyntheticTouchEvent;
  4657. break;
  4658. case TOP_ANIMATION_END:
  4659. case TOP_ANIMATION_ITERATION:
  4660. case TOP_ANIMATION_START:
  4661. EventConstructor = SyntheticAnimationEvent;
  4662. break;
  4663. case TOP_TRANSITION_END:
  4664. EventConstructor = SyntheticTransitionEvent;
  4665. break;
  4666. case TOP_SCROLL:
  4667. EventConstructor = SyntheticUIEvent;
  4668. break;
  4669. case TOP_WHEEL:
  4670. EventConstructor = SyntheticWheelEvent;
  4671. break;
  4672. case TOP_COPY:
  4673. case TOP_CUT:
  4674. case TOP_PASTE:
  4675. EventConstructor = SyntheticClipboardEvent;
  4676. break;
  4677. case TOP_GOT_POINTER_CAPTURE:
  4678. case TOP_LOST_POINTER_CAPTURE:
  4679. case TOP_POINTER_CANCEL:
  4680. case TOP_POINTER_DOWN:
  4681. case TOP_POINTER_MOVE:
  4682. case TOP_POINTER_OUT:
  4683. case TOP_POINTER_OVER:
  4684. case TOP_POINTER_UP:
  4685. EventConstructor = SyntheticPointerEvent;
  4686. break;
  4687. default:
  4688. {
  4689. if (knownHTMLTopLevelTypes.indexOf(topLevelType) === -1) {
  4690. warningWithoutStack$1(false, 'SimpleEventPlugin: Unhandled event type, `%s`. This warning ' + 'is likely caused by a bug in React. Please file an issue.', topLevelType);
  4691. }
  4692. } // HTML Events
  4693. // @see http://www.w3.org/TR/html5/index.html#events-0
  4694. EventConstructor = SyntheticEvent;
  4695. break;
  4696. }
  4697. var event = EventConstructor.getPooled(dispatchConfig, targetInst, nativeEvent, nativeEventTarget);
  4698. accumulateTwoPhaseDispatches(event);
  4699. return event;
  4700. }
  4701. };
  4702. var passiveBrowserEventsSupported = false; // Check if browser support events with passive listeners
  4703. // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
  4704. if (enableFlareAPI && canUseDOM) {
  4705. try {
  4706. var options = {}; // $FlowFixMe: Ignore Flow complaining about needing a value
  4707. Object.defineProperty(options, 'passive', {
  4708. get: function () {
  4709. passiveBrowserEventsSupported = true;
  4710. }
  4711. });
  4712. window.addEventListener('test', options, options);
  4713. window.removeEventListener('test', options, options);
  4714. } catch (e) {
  4715. passiveBrowserEventsSupported = false;
  4716. }
  4717. }
  4718. // Intentionally not named imports because Rollup would use dynamic dispatch for
  4719. // CommonJS interop named imports.
  4720. var UserBlockingPriority$1 = Scheduler.unstable_UserBlockingPriority;
  4721. var runWithPriority$1 = Scheduler.unstable_runWithPriority;
  4722. var getEventPriority = SimpleEventPlugin.getEventPriority;
  4723. var CALLBACK_BOOKKEEPING_POOL_SIZE = 10;
  4724. var callbackBookkeepingPool = [];
  4725. /**
  4726. * Find the deepest React component completely containing the root of the
  4727. * passed-in instance (for use when entire React trees are nested within each
  4728. * other). If React trees are not nested, returns null.
  4729. */
  4730. function findRootContainerNode(inst) {
  4731. if (inst.tag === HostRoot) {
  4732. return inst.stateNode.containerInfo;
  4733. } // TODO: It may be a good idea to cache this to prevent unnecessary DOM
  4734. // traversal, but caching is difficult to do correctly without using a
  4735. // mutation observer to listen for all DOM changes.
  4736. while (inst.return) {
  4737. inst = inst.return;
  4738. }
  4739. if (inst.tag !== HostRoot) {
  4740. // This can happen if we're in a detached tree.
  4741. return null;
  4742. }
  4743. return inst.stateNode.containerInfo;
  4744. } // Used to store ancestor hierarchy in top level callback
  4745. function getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst, eventSystemFlags) {
  4746. if (callbackBookkeepingPool.length) {
  4747. var instance = callbackBookkeepingPool.pop();
  4748. instance.topLevelType = topLevelType;
  4749. instance.eventSystemFlags = eventSystemFlags;
  4750. instance.nativeEvent = nativeEvent;
  4751. instance.targetInst = targetInst;
  4752. return instance;
  4753. }
  4754. return {
  4755. topLevelType: topLevelType,
  4756. eventSystemFlags: eventSystemFlags,
  4757. nativeEvent: nativeEvent,
  4758. targetInst: targetInst,
  4759. ancestors: []
  4760. };
  4761. }
  4762. function releaseTopLevelCallbackBookKeeping(instance) {
  4763. instance.topLevelType = null;
  4764. instance.nativeEvent = null;
  4765. instance.targetInst = null;
  4766. instance.ancestors.length = 0;
  4767. if (callbackBookkeepingPool.length < CALLBACK_BOOKKEEPING_POOL_SIZE) {
  4768. callbackBookkeepingPool.push(instance);
  4769. }
  4770. }
  4771. function handleTopLevel(bookKeeping) {
  4772. var targetInst = bookKeeping.targetInst; // Loop through the hierarchy, in case there's any nested components.
  4773. // It's important that we build the array of ancestors before calling any
  4774. // event handlers, because event handlers can modify the DOM, leading to
  4775. // inconsistencies with ReactMount's node cache. See #1105.
  4776. var ancestor = targetInst;
  4777. do {
  4778. if (!ancestor) {
  4779. var ancestors = bookKeeping.ancestors;
  4780. ancestors.push(ancestor);
  4781. break;
  4782. }
  4783. var root = findRootContainerNode(ancestor);
  4784. if (!root) {
  4785. break;
  4786. }
  4787. var tag = ancestor.tag;
  4788. if (tag === HostComponent || tag === HostText) {
  4789. bookKeeping.ancestors.push(ancestor);
  4790. }
  4791. ancestor = getClosestInstanceFromNode(root);
  4792. } while (ancestor);
  4793. for (var i = 0; i < bookKeeping.ancestors.length; i++) {
  4794. targetInst = bookKeeping.ancestors[i];
  4795. var eventTarget = getEventTarget(bookKeeping.nativeEvent);
  4796. var topLevelType = bookKeeping.topLevelType;
  4797. var nativeEvent = bookKeeping.nativeEvent;
  4798. runExtractedPluginEventsInBatch(topLevelType, targetInst, nativeEvent, eventTarget, bookKeeping.eventSystemFlags);
  4799. }
  4800. } // TODO: can we stop exporting these?
  4801. var _enabled = true;
  4802. function setEnabled(enabled) {
  4803. _enabled = !!enabled;
  4804. }
  4805. function isEnabled() {
  4806. return _enabled;
  4807. }
  4808. function trapBubbledEvent(topLevelType, element) {
  4809. trapEventForPluginEventSystem(element, topLevelType, false);
  4810. }
  4811. function trapCapturedEvent(topLevelType, element) {
  4812. trapEventForPluginEventSystem(element, topLevelType, true);
  4813. }
  4814. function trapEventForResponderEventSystem(element, topLevelType, passive) {
  4815. if (enableFlareAPI) {
  4816. var rawEventName = getRawEventName(topLevelType);
  4817. var eventFlags = RESPONDER_EVENT_SYSTEM; // If passive option is not supported, then the event will be
  4818. // active and not passive, but we flag it as using not being
  4819. // supported too. This way the responder event plugins know,
  4820. // and can provide polyfills if needed.
  4821. if (passive) {
  4822. if (passiveBrowserEventsSupported) {
  4823. eventFlags |= IS_PASSIVE;
  4824. } else {
  4825. eventFlags |= IS_ACTIVE;
  4826. eventFlags |= PASSIVE_NOT_SUPPORTED;
  4827. passive = false;
  4828. }
  4829. } else {
  4830. eventFlags |= IS_ACTIVE;
  4831. } // Check if interactive and wrap in discreteUpdates
  4832. var listener = dispatchEvent.bind(null, topLevelType, eventFlags);
  4833. if (passiveBrowserEventsSupported) {
  4834. addEventCaptureListenerWithPassiveFlag(element, rawEventName, listener, passive);
  4835. } else {
  4836. addEventCaptureListener(element, rawEventName, listener);
  4837. }
  4838. }
  4839. }
  4840. function trapEventForPluginEventSystem(element, topLevelType, capture) {
  4841. var listener;
  4842. switch (getEventPriority(topLevelType)) {
  4843. case DiscreteEvent:
  4844. listener = dispatchDiscreteEvent.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM);
  4845. break;
  4846. case UserBlockingEvent:
  4847. listener = dispatchUserBlockingUpdate.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM);
  4848. break;
  4849. case ContinuousEvent:
  4850. default:
  4851. listener = dispatchEvent.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM);
  4852. break;
  4853. }
  4854. var rawEventName = getRawEventName(topLevelType);
  4855. if (capture) {
  4856. addEventCaptureListener(element, rawEventName, listener);
  4857. } else {
  4858. addEventBubbleListener(element, rawEventName, listener);
  4859. }
  4860. }
  4861. function dispatchDiscreteEvent(topLevelType, eventSystemFlags, nativeEvent) {
  4862. flushDiscreteUpdatesIfNeeded(nativeEvent.timeStamp);
  4863. discreteUpdates(dispatchEvent, topLevelType, eventSystemFlags, nativeEvent);
  4864. }
  4865. function dispatchUserBlockingUpdate(topLevelType, eventSystemFlags, nativeEvent) {
  4866. runWithPriority$1(UserBlockingPriority$1, dispatchEvent.bind(null, topLevelType, eventSystemFlags, nativeEvent));
  4867. }
  4868. function dispatchEventForPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, targetInst) {
  4869. var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst, eventSystemFlags);
  4870. try {
  4871. // Event queue being processed in the same cycle allows
  4872. // `preventDefault`.
  4873. batchedEventUpdates(handleTopLevel, bookKeeping);
  4874. } finally {
  4875. releaseTopLevelCallbackBookKeeping(bookKeeping);
  4876. }
  4877. }
  4878. function dispatchEvent(topLevelType, eventSystemFlags, nativeEvent) {
  4879. if (!_enabled) {
  4880. return;
  4881. }
  4882. if (hasQueuedDiscreteEvents() && isReplayableDiscreteEvent(topLevelType)) {
  4883. // If we already have a queue of discrete events, and this is another discrete
  4884. // event, then we can't dispatch it regardless of its target, since they
  4885. // need to dispatch in order.
  4886. queueDiscreteEvent(null, // Flags that we're not actually blocked on anything as far as we know.
  4887. topLevelType, eventSystemFlags, nativeEvent);
  4888. return;
  4889. }
  4890. var blockedOn = attemptToDispatchEvent(topLevelType, eventSystemFlags, nativeEvent);
  4891. if (blockedOn === null) {
  4892. // We successfully dispatched this event.
  4893. clearIfContinuousEvent(topLevelType, nativeEvent);
  4894. return;
  4895. }
  4896. if (isReplayableDiscreteEvent(topLevelType)) {
  4897. // This this to be replayed later once the target is available.
  4898. queueDiscreteEvent(blockedOn, topLevelType, eventSystemFlags, nativeEvent);
  4899. return;
  4900. }
  4901. if (queueIfContinuousEvent(blockedOn, topLevelType, eventSystemFlags, nativeEvent)) {
  4902. return;
  4903. } // We need to clear only if we didn't queue because
  4904. // queueing is accummulative.
  4905. clearIfContinuousEvent(topLevelType, nativeEvent); // This is not replayable so we'll invoke it but without a target,
  4906. // in case the event system needs to trace it.
  4907. if (enableFlareAPI) {
  4908. if (eventSystemFlags & PLUGIN_EVENT_SYSTEM) {
  4909. dispatchEventForPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, null);
  4910. }
  4911. if (eventSystemFlags & RESPONDER_EVENT_SYSTEM) {
  4912. // React Flare event system
  4913. dispatchEventForResponderEventSystem(topLevelType, null, nativeEvent, getEventTarget(nativeEvent), eventSystemFlags);
  4914. }
  4915. } else {
  4916. dispatchEventForPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, null);
  4917. }
  4918. } // Attempt dispatching an event. Returns a SuspenseInstance or Container if it's blocked.
  4919. function attemptToDispatchEvent(topLevelType, eventSystemFlags, nativeEvent) {
  4920. // TODO: Warn if _enabled is false.
  4921. var nativeEventTarget = getEventTarget(nativeEvent);
  4922. var targetInst = getClosestInstanceFromNode(nativeEventTarget);
  4923. if (targetInst !== null) {
  4924. var nearestMounted = getNearestMountedFiber(targetInst);
  4925. if (nearestMounted === null) {
  4926. // This tree has been unmounted already. Dispatch without a target.
  4927. targetInst = null;
  4928. } else {
  4929. var tag = nearestMounted.tag;
  4930. if (tag === SuspenseComponent) {
  4931. var instance = getSuspenseInstanceFromFiber(nearestMounted);
  4932. if (instance !== null) {
  4933. // Queue the event to be replayed later. Abort dispatching since we
  4934. // don't want this event dispatched twice through the event system.
  4935. // TODO: If this is the first discrete event in the queue. Schedule an increased
  4936. // priority for this boundary.
  4937. return instance;
  4938. } // This shouldn't happen, something went wrong but to avoid blocking
  4939. // the whole system, dispatch the event without a target.
  4940. // TODO: Warn.
  4941. targetInst = null;
  4942. } else if (tag === HostRoot) {
  4943. var root = nearestMounted.stateNode;
  4944. if (root.hydrate) {
  4945. // If this happens during a replay something went wrong and it might block
  4946. // the whole system.
  4947. return getContainerFromFiber(nearestMounted);
  4948. }
  4949. targetInst = null;
  4950. } else if (nearestMounted !== targetInst) {
  4951. // If we get an event (ex: img onload) before committing that
  4952. // component's mount, ignore it for now (that is, treat it as if it was an
  4953. // event on a non-React tree). We might also consider queueing events and
  4954. // dispatching them after the mount.
  4955. targetInst = null;
  4956. }
  4957. }
  4958. }
  4959. if (enableFlareAPI) {
  4960. if (eventSystemFlags & PLUGIN_EVENT_SYSTEM) {
  4961. dispatchEventForPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, targetInst);
  4962. }
  4963. if (eventSystemFlags & RESPONDER_EVENT_SYSTEM) {
  4964. // React Flare event system
  4965. dispatchEventForResponderEventSystem(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags);
  4966. }
  4967. } else {
  4968. dispatchEventForPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, targetInst);
  4969. } // We're not blocked on anything.
  4970. return null;
  4971. }
  4972. /**
  4973. * Checks if an event is supported in the current execution environment.
  4974. *
  4975. * NOTE: This will not work correctly for non-generic events such as `change`,
  4976. * `reset`, `load`, `error`, and `select`.
  4977. *
  4978. * Borrows from Modernizr.
  4979. *
  4980. * @param {string} eventNameSuffix Event name, e.g. "click".
  4981. * @return {boolean} True if the event is supported.
  4982. * @internal
  4983. * @license Modernizr 3.0.0pre (Custom Build) | MIT
  4984. */
  4985. function isEventSupported(eventNameSuffix) {
  4986. if (!canUseDOM) {
  4987. return false;
  4988. }
  4989. var eventName = 'on' + eventNameSuffix;
  4990. var isSupported = eventName in document;
  4991. if (!isSupported) {
  4992. var element = document.createElement('div');
  4993. element.setAttribute(eventName, 'return;');
  4994. isSupported = typeof element[eventName] === 'function';
  4995. }
  4996. return isSupported;
  4997. }
  4998. /**
  4999. * Summary of `ReactBrowserEventEmitter` event handling:
  5000. *
  5001. * - Top-level delegation is used to trap most native browser events. This
  5002. * may only occur in the main thread and is the responsibility of
  5003. * ReactDOMEventListener, which is injected and can therefore support
  5004. * pluggable event sources. This is the only work that occurs in the main
  5005. * thread.
  5006. *
  5007. * - We normalize and de-duplicate events to account for browser quirks. This
  5008. * may be done in the worker thread.
  5009. *
  5010. * - Forward these native events (with the associated top-level type used to
  5011. * trap it) to `EventPluginHub`, which in turn will ask plugins if they want
  5012. * to extract any synthetic events.
  5013. *
  5014. * - The `EventPluginHub` will then process each event by annotating them with
  5015. * "dispatches", a sequence of listeners and IDs that care about that event.
  5016. *
  5017. * - The `EventPluginHub` then dispatches the events.
  5018. *
  5019. * Overview of React and the event system:
  5020. *
  5021. * +------------+ .
  5022. * | DOM | .
  5023. * +------------+ .
  5024. * | .
  5025. * v .
  5026. * +------------+ .
  5027. * | ReactEvent | .
  5028. * | Listener | .
  5029. * +------------+ . +-----------+
  5030. * | . +--------+|SimpleEvent|
  5031. * | . | |Plugin |
  5032. * +-----|------+ . v +-----------+
  5033. * | | | . +--------------+ +------------+
  5034. * | +-----------.--->|EventPluginHub| | Event |
  5035. * | | . | | +-----------+ | Propagators|
  5036. * | ReactEvent | . | | |TapEvent | |------------|
  5037. * | Emitter | . | |<---+|Plugin | |other plugin|
  5038. * | | . | | +-----------+ | utilities |
  5039. * | +-----------.--->| | +------------+
  5040. * | | | . +--------------+
  5041. * +-----|------+ . ^ +-----------+
  5042. * | . | |Enter/Leave|
  5043. * + . +-------+|Plugin |
  5044. * +-------------+ . +-----------+
  5045. * | application | .
  5046. * |-------------| .
  5047. * | | .
  5048. * | | .
  5049. * +-------------+ .
  5050. * .
  5051. * React Core . General Purpose Event Plugin System
  5052. */
  5053. var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
  5054. var elementListeningSets = new PossiblyWeakMap();
  5055. function getListeningSetForElement(element) {
  5056. var listeningSet = elementListeningSets.get(element);
  5057. if (listeningSet === undefined) {
  5058. listeningSet = new Set();
  5059. elementListeningSets.set(element, listeningSet);
  5060. }
  5061. return listeningSet;
  5062. }
  5063. /**
  5064. * We listen for bubbled touch events on the document object.
  5065. *
  5066. * Firefox v8.01 (and possibly others) exhibited strange behavior when
  5067. * mounting `onmousemove` events at some node that was not the document
  5068. * element. The symptoms were that if your mouse is not moving over something
  5069. * contained within that mount point (for example on the background) the
  5070. * top-level listeners for `onmousemove` won't be called. However, if you
  5071. * register the `mousemove` on the document object, then it will of course
  5072. * catch all `mousemove`s. This along with iOS quirks, justifies restricting
  5073. * top-level listeners to the document object only, at least for these
  5074. * movement types of events and possibly all events.
  5075. *
  5076. * @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
  5077. *
  5078. * Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but
  5079. * they bubble to document.
  5080. *
  5081. * @param {string} registrationName Name of listener (e.g. `onClick`).
  5082. * @param {object} mountAt Container where to mount the listener
  5083. */
  5084. function listenTo(registrationName, mountAt) {
  5085. var listeningSet = getListeningSetForElement(mountAt);
  5086. var dependencies = registrationNameDependencies[registrationName];
  5087. for (var i = 0; i < dependencies.length; i++) {
  5088. var dependency = dependencies[i];
  5089. listenToTopLevel(dependency, mountAt, listeningSet);
  5090. }
  5091. }
  5092. function listenToTopLevel(topLevelType, mountAt, listeningSet) {
  5093. if (!listeningSet.has(topLevelType)) {
  5094. switch (topLevelType) {
  5095. case TOP_SCROLL:
  5096. trapCapturedEvent(TOP_SCROLL, mountAt);
  5097. break;
  5098. case TOP_FOCUS:
  5099. case TOP_BLUR:
  5100. trapCapturedEvent(TOP_FOCUS, mountAt);
  5101. trapCapturedEvent(TOP_BLUR, mountAt); // We set the flag for a single dependency later in this function,
  5102. // but this ensures we mark both as attached rather than just one.
  5103. listeningSet.add(TOP_BLUR);
  5104. listeningSet.add(TOP_FOCUS);
  5105. break;
  5106. case TOP_CANCEL:
  5107. case TOP_CLOSE:
  5108. if (isEventSupported(getRawEventName(topLevelType))) {
  5109. trapCapturedEvent(topLevelType, mountAt);
  5110. }
  5111. break;
  5112. case TOP_INVALID:
  5113. case TOP_SUBMIT:
  5114. case TOP_RESET:
  5115. // We listen to them on the target DOM elements.
  5116. // Some of them bubble so we don't want them to fire twice.
  5117. break;
  5118. default:
  5119. // By default, listen on the top level to all non-media events.
  5120. // Media events don't bubble so adding the listener wouldn't do anything.
  5121. var isMediaEvent = mediaEventTypes.indexOf(topLevelType) !== -1;
  5122. if (!isMediaEvent) {
  5123. trapBubbledEvent(topLevelType, mountAt);
  5124. }
  5125. break;
  5126. }
  5127. listeningSet.add(topLevelType);
  5128. }
  5129. }
  5130. function isListeningToAllDependencies(registrationName, mountAt) {
  5131. var listeningSet = getListeningSetForElement(mountAt);
  5132. var dependencies = registrationNameDependencies[registrationName];
  5133. for (var i = 0; i < dependencies.length; i++) {
  5134. var dependency = dependencies[i];
  5135. if (!listeningSet.has(dependency)) {
  5136. return false;
  5137. }
  5138. }
  5139. return true;
  5140. }
  5141. // List derived from Gecko source code:
  5142. // https://github.com/mozilla/gecko-dev/blob/4e638efc71/layout/style/test/property_database.js
  5143. var shorthandToLonghand = {
  5144. animation: ['animationDelay', 'animationDirection', 'animationDuration', 'animationFillMode', 'animationIterationCount', 'animationName', 'animationPlayState', 'animationTimingFunction'],
  5145. background: ['backgroundAttachment', 'backgroundClip', 'backgroundColor', 'backgroundImage', 'backgroundOrigin', 'backgroundPositionX', 'backgroundPositionY', 'backgroundRepeat', 'backgroundSize'],
  5146. backgroundPosition: ['backgroundPositionX', 'backgroundPositionY'],
  5147. border: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth', 'borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth', 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth', 'borderRightColor', 'borderRightStyle', 'borderRightWidth', 'borderTopColor', 'borderTopStyle', 'borderTopWidth'],
  5148. borderBlockEnd: ['borderBlockEndColor', 'borderBlockEndStyle', 'borderBlockEndWidth'],
  5149. borderBlockStart: ['borderBlockStartColor', 'borderBlockStartStyle', 'borderBlockStartWidth'],
  5150. borderBottom: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth'],
  5151. borderColor: ['borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor'],
  5152. borderImage: ['borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth'],
  5153. borderInlineEnd: ['borderInlineEndColor', 'borderInlineEndStyle', 'borderInlineEndWidth'],
  5154. borderInlineStart: ['borderInlineStartColor', 'borderInlineStartStyle', 'borderInlineStartWidth'],
  5155. borderLeft: ['borderLeftColor', 'borderLeftStyle', 'borderLeftWidth'],
  5156. borderRadius: ['borderBottomLeftRadius', 'borderBottomRightRadius', 'borderTopLeftRadius', 'borderTopRightRadius'],
  5157. borderRight: ['borderRightColor', 'borderRightStyle', 'borderRightWidth'],
  5158. borderStyle: ['borderBottomStyle', 'borderLeftStyle', 'borderRightStyle', 'borderTopStyle'],
  5159. borderTop: ['borderTopColor', 'borderTopStyle', 'borderTopWidth'],
  5160. borderWidth: ['borderBottomWidth', 'borderLeftWidth', 'borderRightWidth', 'borderTopWidth'],
  5161. columnRule: ['columnRuleColor', 'columnRuleStyle', 'columnRuleWidth'],
  5162. columns: ['columnCount', 'columnWidth'],
  5163. flex: ['flexBasis', 'flexGrow', 'flexShrink'],
  5164. flexFlow: ['flexDirection', 'flexWrap'],
  5165. font: ['fontFamily', 'fontFeatureSettings', 'fontKerning', 'fontLanguageOverride', 'fontSize', 'fontSizeAdjust', 'fontStretch', 'fontStyle', 'fontVariant', 'fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition', 'fontWeight', 'lineHeight'],
  5166. fontVariant: ['fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition'],
  5167. gap: ['columnGap', 'rowGap'],
  5168. grid: ['gridAutoColumns', 'gridAutoFlow', 'gridAutoRows', 'gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'],
  5169. gridArea: ['gridColumnEnd', 'gridColumnStart', 'gridRowEnd', 'gridRowStart'],
  5170. gridColumn: ['gridColumnEnd', 'gridColumnStart'],
  5171. gridColumnGap: ['columnGap'],
  5172. gridGap: ['columnGap', 'rowGap'],
  5173. gridRow: ['gridRowEnd', 'gridRowStart'],
  5174. gridRowGap: ['rowGap'],
  5175. gridTemplate: ['gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'],
  5176. listStyle: ['listStyleImage', 'listStylePosition', 'listStyleType'],
  5177. margin: ['marginBottom', 'marginLeft', 'marginRight', 'marginTop'],
  5178. marker: ['markerEnd', 'markerMid', 'markerStart'],
  5179. mask: ['maskClip', 'maskComposite', 'maskImage', 'maskMode', 'maskOrigin', 'maskPositionX', 'maskPositionY', 'maskRepeat', 'maskSize'],
  5180. maskPosition: ['maskPositionX', 'maskPositionY'],
  5181. outline: ['outlineColor', 'outlineStyle', 'outlineWidth'],
  5182. overflow: ['overflowX', 'overflowY'],
  5183. padding: ['paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop'],
  5184. placeContent: ['alignContent', 'justifyContent'],
  5185. placeItems: ['alignItems', 'justifyItems'],
  5186. placeSelf: ['alignSelf', 'justifySelf'],
  5187. textDecoration: ['textDecorationColor', 'textDecorationLine', 'textDecorationStyle'],
  5188. textEmphasis: ['textEmphasisColor', 'textEmphasisStyle'],
  5189. transition: ['transitionDelay', 'transitionDuration', 'transitionProperty', 'transitionTimingFunction'],
  5190. wordWrap: ['overflowWrap']
  5191. };
  5192. /**
  5193. * CSS properties which accept numbers but are not in units of "px".
  5194. */
  5195. var isUnitlessNumber = {
  5196. animationIterationCount: true,
  5197. borderImageOutset: true,
  5198. borderImageSlice: true,
  5199. borderImageWidth: true,
  5200. boxFlex: true,
  5201. boxFlexGroup: true,
  5202. boxOrdinalGroup: true,
  5203. columnCount: true,
  5204. columns: true,
  5205. flex: true,
  5206. flexGrow: true,
  5207. flexPositive: true,
  5208. flexShrink: true,
  5209. flexNegative: true,
  5210. flexOrder: true,
  5211. gridArea: true,
  5212. gridRow: true,
  5213. gridRowEnd: true,
  5214. gridRowSpan: true,
  5215. gridRowStart: true,
  5216. gridColumn: true,
  5217. gridColumnEnd: true,
  5218. gridColumnSpan: true,
  5219. gridColumnStart: true,
  5220. fontWeight: true,
  5221. lineClamp: true,
  5222. lineHeight: true,
  5223. opacity: true,
  5224. order: true,
  5225. orphans: true,
  5226. tabSize: true,
  5227. widows: true,
  5228. zIndex: true,
  5229. zoom: true,
  5230. // SVG-related properties
  5231. fillOpacity: true,
  5232. floodOpacity: true,
  5233. stopOpacity: true,
  5234. strokeDasharray: true,
  5235. strokeDashoffset: true,
  5236. strokeMiterlimit: true,
  5237. strokeOpacity: true,
  5238. strokeWidth: true
  5239. };
  5240. /**
  5241. * @param {string} prefix vendor-specific prefix, eg: Webkit
  5242. * @param {string} key style name, eg: transitionDuration
  5243. * @return {string} style name prefixed with `prefix`, properly camelCased, eg:
  5244. * WebkitTransitionDuration
  5245. */
  5246. function prefixKey(prefix, key) {
  5247. return prefix + key.charAt(0).toUpperCase() + key.substring(1);
  5248. }
  5249. /**
  5250. * Support style names that may come passed in prefixed by adding permutations
  5251. * of vendor prefixes.
  5252. */
  5253. var prefixes = ['Webkit', 'ms', 'Moz', 'O']; // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
  5254. // infinite loop, because it iterates over the newly added props too.
  5255. Object.keys(isUnitlessNumber).forEach(function (prop) {
  5256. prefixes.forEach(function (prefix) {
  5257. isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
  5258. });
  5259. });
  5260. /**
  5261. * Convert a value into the proper css writable value. The style name `name`
  5262. * should be logical (no hyphens), as specified
  5263. * in `CSSProperty.isUnitlessNumber`.
  5264. *
  5265. * @param {string} name CSS property name such as `topMargin`.
  5266. * @param {*} value CSS property value such as `10px`.
  5267. * @return {string} Normalized style value with dimensions applied.
  5268. */
  5269. function dangerousStyleValue(name, value, isCustomProperty) {
  5270. // Note that we've removed escapeTextForBrowser() calls here since the
  5271. // whole string will be escaped when the attribute is injected into
  5272. // the markup. If you provide unsafe user data here they can inject
  5273. // arbitrary CSS which may be problematic (I couldn't repro this):
  5274. // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
  5275. // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
  5276. // This is not an XSS hole but instead a potential CSS injection issue
  5277. // which has lead to a greater discussion about how we're going to
  5278. // trust URLs moving forward. See #2115901
  5279. var isEmpty = value == null || typeof value === 'boolean' || value === '';
  5280. if (isEmpty) {
  5281. return '';
  5282. }
  5283. if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) {
  5284. return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers
  5285. }
  5286. return ('' + value).trim();
  5287. }
  5288. var uppercasePattern = /([A-Z])/g;
  5289. var msPattern = /^ms-/;
  5290. /**
  5291. * Hyphenates a camelcased CSS property name, for example:
  5292. *
  5293. * > hyphenateStyleName('backgroundColor')
  5294. * < "background-color"
  5295. * > hyphenateStyleName('MozTransition')
  5296. * < "-moz-transition"
  5297. * > hyphenateStyleName('msTransition')
  5298. * < "-ms-transition"
  5299. *
  5300. * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
  5301. * is converted to `-ms-`.
  5302. */
  5303. function hyphenateStyleName(name) {
  5304. return name.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern, '-ms-');
  5305. }
  5306. var warnValidStyle = function () {};
  5307. {
  5308. // 'msTransform' is correct, but the other prefixes should be capitalized
  5309. var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
  5310. var msPattern$1 = /^-ms-/;
  5311. var hyphenPattern = /-(.)/g; // style values shouldn't contain a semicolon
  5312. var badStyleValueWithSemicolonPattern = /;\s*$/;
  5313. var warnedStyleNames = {};
  5314. var warnedStyleValues = {};
  5315. var warnedForNaNValue = false;
  5316. var warnedForInfinityValue = false;
  5317. var camelize = function (string) {
  5318. return string.replace(hyphenPattern, function (_, character) {
  5319. return character.toUpperCase();
  5320. });
  5321. };
  5322. var warnHyphenatedStyleName = function (name) {
  5323. if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
  5324. return;
  5325. }
  5326. warnedStyleNames[name] = true;
  5327. warning$1(false, 'Unsupported style property %s. Did you mean %s?', name, // As Andi Smith suggests
  5328. // (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
  5329. // is converted to lowercase `ms`.
  5330. camelize(name.replace(msPattern$1, 'ms-')));
  5331. };
  5332. var warnBadVendoredStyleName = function (name) {
  5333. if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
  5334. return;
  5335. }
  5336. warnedStyleNames[name] = true;
  5337. warning$1(false, 'Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1));
  5338. };
  5339. var warnStyleValueWithSemicolon = function (name, value) {
  5340. if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
  5341. return;
  5342. }
  5343. warnedStyleValues[value] = true;
  5344. warning$1(false, "Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, ''));
  5345. };
  5346. var warnStyleValueIsNaN = function (name, value) {
  5347. if (warnedForNaNValue) {
  5348. return;
  5349. }
  5350. warnedForNaNValue = true;
  5351. warning$1(false, '`NaN` is an invalid value for the `%s` css style property.', name);
  5352. };
  5353. var warnStyleValueIsInfinity = function (name, value) {
  5354. if (warnedForInfinityValue) {
  5355. return;
  5356. }
  5357. warnedForInfinityValue = true;
  5358. warning$1(false, '`Infinity` is an invalid value for the `%s` css style property.', name);
  5359. };
  5360. warnValidStyle = function (name, value) {
  5361. if (name.indexOf('-') > -1) {
  5362. warnHyphenatedStyleName(name);
  5363. } else if (badVendoredStyleNamePattern.test(name)) {
  5364. warnBadVendoredStyleName(name);
  5365. } else if (badStyleValueWithSemicolonPattern.test(value)) {
  5366. warnStyleValueWithSemicolon(name, value);
  5367. }
  5368. if (typeof value === 'number') {
  5369. if (isNaN(value)) {
  5370. warnStyleValueIsNaN(name, value);
  5371. } else if (!isFinite(value)) {
  5372. warnStyleValueIsInfinity(name, value);
  5373. }
  5374. }
  5375. };
  5376. }
  5377. var warnValidStyle$1 = warnValidStyle;
  5378. /**
  5379. * Operations for dealing with CSS properties.
  5380. */
  5381. /**
  5382. * This creates a string that is expected to be equivalent to the style
  5383. * attribute generated by server-side rendering. It by-passes warnings and
  5384. * security checks so it's not safe to use this value for anything other than
  5385. * comparison. It is only used in DEV for SSR validation.
  5386. */
  5387. function createDangerousStringForStyles(styles) {
  5388. {
  5389. var serialized = '';
  5390. var delimiter = '';
  5391. for (var styleName in styles) {
  5392. if (!styles.hasOwnProperty(styleName)) {
  5393. continue;
  5394. }
  5395. var styleValue = styles[styleName];
  5396. if (styleValue != null) {
  5397. var isCustomProperty = styleName.indexOf('--') === 0;
  5398. serialized += delimiter + (isCustomProperty ? styleName : hyphenateStyleName(styleName)) + ':';
  5399. serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty);
  5400. delimiter = ';';
  5401. }
  5402. }
  5403. return serialized || null;
  5404. }
  5405. }
  5406. /**
  5407. * Sets the value for multiple styles on a node. If a value is specified as
  5408. * '' (empty string), the corresponding style property will be unset.
  5409. *
  5410. * @param {DOMElement} node
  5411. * @param {object} styles
  5412. */
  5413. function setValueForStyles(node, styles) {
  5414. var style = node.style;
  5415. for (var styleName in styles) {
  5416. if (!styles.hasOwnProperty(styleName)) {
  5417. continue;
  5418. }
  5419. var isCustomProperty = styleName.indexOf('--') === 0;
  5420. {
  5421. if (!isCustomProperty) {
  5422. warnValidStyle$1(styleName, styles[styleName]);
  5423. }
  5424. }
  5425. var styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty);
  5426. if (styleName === 'float') {
  5427. styleName = 'cssFloat';
  5428. }
  5429. if (isCustomProperty) {
  5430. style.setProperty(styleName, styleValue);
  5431. } else {
  5432. style[styleName] = styleValue;
  5433. }
  5434. }
  5435. }
  5436. function isValueEmpty(value) {
  5437. return value == null || typeof value === 'boolean' || value === '';
  5438. }
  5439. /**
  5440. * Given {color: 'red', overflow: 'hidden'} returns {
  5441. * color: 'color',
  5442. * overflowX: 'overflow',
  5443. * overflowY: 'overflow',
  5444. * }. This can be read as "the overflowY property was set by the overflow
  5445. * shorthand". That is, the values are the property that each was derived from.
  5446. */
  5447. function expandShorthandMap(styles) {
  5448. var expanded = {};
  5449. for (var key in styles) {
  5450. var longhands = shorthandToLonghand[key] || [key];
  5451. for (var i = 0; i < longhands.length; i++) {
  5452. expanded[longhands[i]] = key;
  5453. }
  5454. }
  5455. return expanded;
  5456. }
  5457. /**
  5458. * When mixing shorthand and longhand property names, we warn during updates if
  5459. * we expect an incorrect result to occur. In particular, we warn for:
  5460. *
  5461. * Updating a shorthand property (longhand gets overwritten):
  5462. * {font: 'foo', fontVariant: 'bar'} -> {font: 'baz', fontVariant: 'bar'}
  5463. * becomes .style.font = 'baz'
  5464. * Removing a shorthand property (longhand gets lost too):
  5465. * {font: 'foo', fontVariant: 'bar'} -> {fontVariant: 'bar'}
  5466. * becomes .style.font = ''
  5467. * Removing a longhand property (should revert to shorthand; doesn't):
  5468. * {font: 'foo', fontVariant: 'bar'} -> {font: 'foo'}
  5469. * becomes .style.fontVariant = ''
  5470. */
  5471. function validateShorthandPropertyCollisionInDev(styleUpdates, nextStyles) {
  5472. if (!warnAboutShorthandPropertyCollision) {
  5473. return;
  5474. }
  5475. if (!nextStyles) {
  5476. return;
  5477. }
  5478. var expandedUpdates = expandShorthandMap(styleUpdates);
  5479. var expandedStyles = expandShorthandMap(nextStyles);
  5480. var warnedAbout = {};
  5481. for (var key in expandedUpdates) {
  5482. var originalKey = expandedUpdates[key];
  5483. var correctOriginalKey = expandedStyles[key];
  5484. if (correctOriginalKey && originalKey !== correctOriginalKey) {
  5485. var warningKey = originalKey + ',' + correctOriginalKey;
  5486. if (warnedAbout[warningKey]) {
  5487. continue;
  5488. }
  5489. warnedAbout[warningKey] = true;
  5490. warning$1(false, '%s a style property during rerender (%s) when a ' + 'conflicting property is set (%s) can lead to styling bugs. To ' + "avoid this, don't mix shorthand and non-shorthand properties " + 'for the same value; instead, replace the shorthand with ' + 'separate values.', isValueEmpty(styleUpdates[originalKey]) ? 'Removing' : 'Updating', originalKey, correctOriginalKey);
  5491. }
  5492. }
  5493. }
  5494. // For HTML, certain tags should omit their close tag. We keep a whitelist for
  5495. // those special-case tags.
  5496. var omittedCloseTags = {
  5497. area: true,
  5498. base: true,
  5499. br: true,
  5500. col: true,
  5501. embed: true,
  5502. hr: true,
  5503. img: true,
  5504. input: true,
  5505. keygen: true,
  5506. link: true,
  5507. meta: true,
  5508. param: true,
  5509. source: true,
  5510. track: true,
  5511. wbr: true // NOTE: menuitem's close tag should be omitted, but that causes problems.
  5512. };
  5513. // `omittedCloseTags` except that `menuitem` should still have its closing tag.
  5514. var voidElementTags = _assign({
  5515. menuitem: true
  5516. }, omittedCloseTags);
  5517. // or add stack by default to invariants where possible.
  5518. var HTML$1 = '__html';
  5519. var ReactDebugCurrentFrame$3 = null;
  5520. {
  5521. ReactDebugCurrentFrame$3 = ReactSharedInternals.ReactDebugCurrentFrame;
  5522. }
  5523. function assertValidProps(tag, props) {
  5524. if (!props) {
  5525. return;
  5526. } // Note the use of `==` which checks for null or undefined.
  5527. if (voidElementTags[tag]) {
  5528. if (!(props.children == null && props.dangerouslySetInnerHTML == null)) {
  5529. {
  5530. throw Error(tag + " is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`." + (ReactDebugCurrentFrame$3.getStackAddendum()));
  5531. }
  5532. }
  5533. }
  5534. if (props.dangerouslySetInnerHTML != null) {
  5535. if (!(props.children == null)) {
  5536. {
  5537. throw Error("Can only set one of `children` or `props.dangerouslySetInnerHTML`.");
  5538. }
  5539. }
  5540. if (!(typeof props.dangerouslySetInnerHTML === 'object' && HTML$1 in props.dangerouslySetInnerHTML)) {
  5541. {
  5542. throw Error("`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://fb.me/react-invariant-dangerously-set-inner-html for more information.");
  5543. }
  5544. }
  5545. }
  5546. {
  5547. !(props.suppressContentEditableWarning || !props.contentEditable || props.children == null) ? warning$1(false, 'A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.') : void 0;
  5548. }
  5549. if (!(props.style == null || typeof props.style === 'object')) {
  5550. {
  5551. throw Error("The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX." + (ReactDebugCurrentFrame$3.getStackAddendum()));
  5552. }
  5553. }
  5554. }
  5555. function isCustomComponent(tagName, props) {
  5556. if (tagName.indexOf('-') === -1) {
  5557. return typeof props.is === 'string';
  5558. }
  5559. switch (tagName) {
  5560. // These are reserved SVG and MathML elements.
  5561. // We don't mind this whitelist too much because we expect it to never grow.
  5562. // The alternative is to track the namespace in a few places which is convoluted.
  5563. // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
  5564. case 'annotation-xml':
  5565. case 'color-profile':
  5566. case 'font-face':
  5567. case 'font-face-src':
  5568. case 'font-face-uri':
  5569. case 'font-face-format':
  5570. case 'font-face-name':
  5571. case 'missing-glyph':
  5572. return false;
  5573. default:
  5574. return true;
  5575. }
  5576. }
  5577. // When adding attributes to the HTML or SVG whitelist, be sure to
  5578. // also add them to this module to ensure casing and incorrect name
  5579. // warnings.
  5580. var possibleStandardNames = {
  5581. // HTML
  5582. accept: 'accept',
  5583. acceptcharset: 'acceptCharset',
  5584. 'accept-charset': 'acceptCharset',
  5585. accesskey: 'accessKey',
  5586. action: 'action',
  5587. allowfullscreen: 'allowFullScreen',
  5588. alt: 'alt',
  5589. as: 'as',
  5590. async: 'async',
  5591. autocapitalize: 'autoCapitalize',
  5592. autocomplete: 'autoComplete',
  5593. autocorrect: 'autoCorrect',
  5594. autofocus: 'autoFocus',
  5595. autoplay: 'autoPlay',
  5596. autosave: 'autoSave',
  5597. capture: 'capture',
  5598. cellpadding: 'cellPadding',
  5599. cellspacing: 'cellSpacing',
  5600. challenge: 'challenge',
  5601. charset: 'charSet',
  5602. checked: 'checked',
  5603. children: 'children',
  5604. cite: 'cite',
  5605. class: 'className',
  5606. classid: 'classID',
  5607. classname: 'className',
  5608. cols: 'cols',
  5609. colspan: 'colSpan',
  5610. content: 'content',
  5611. contenteditable: 'contentEditable',
  5612. contextmenu: 'contextMenu',
  5613. controls: 'controls',
  5614. controlslist: 'controlsList',
  5615. coords: 'coords',
  5616. crossorigin: 'crossOrigin',
  5617. dangerouslysetinnerhtml: 'dangerouslySetInnerHTML',
  5618. data: 'data',
  5619. datetime: 'dateTime',
  5620. default: 'default',
  5621. defaultchecked: 'defaultChecked',
  5622. defaultvalue: 'defaultValue',
  5623. defer: 'defer',
  5624. dir: 'dir',
  5625. disabled: 'disabled',
  5626. disablepictureinpicture: 'disablePictureInPicture',
  5627. download: 'download',
  5628. draggable: 'draggable',
  5629. enctype: 'encType',
  5630. for: 'htmlFor',
  5631. form: 'form',
  5632. formmethod: 'formMethod',
  5633. formaction: 'formAction',
  5634. formenctype: 'formEncType',
  5635. formnovalidate: 'formNoValidate',
  5636. formtarget: 'formTarget',
  5637. frameborder: 'frameBorder',
  5638. headers: 'headers',
  5639. height: 'height',
  5640. hidden: 'hidden',
  5641. high: 'high',
  5642. href: 'href',
  5643. hreflang: 'hrefLang',
  5644. htmlfor: 'htmlFor',
  5645. httpequiv: 'httpEquiv',
  5646. 'http-equiv': 'httpEquiv',
  5647. icon: 'icon',
  5648. id: 'id',
  5649. innerhtml: 'innerHTML',
  5650. inputmode: 'inputMode',
  5651. integrity: 'integrity',
  5652. is: 'is',
  5653. itemid: 'itemID',
  5654. itemprop: 'itemProp',
  5655. itemref: 'itemRef',
  5656. itemscope: 'itemScope',
  5657. itemtype: 'itemType',
  5658. keyparams: 'keyParams',
  5659. keytype: 'keyType',
  5660. kind: 'kind',
  5661. label: 'label',
  5662. lang: 'lang',
  5663. list: 'list',
  5664. loop: 'loop',
  5665. low: 'low',
  5666. manifest: 'manifest',
  5667. marginwidth: 'marginWidth',
  5668. marginheight: 'marginHeight',
  5669. max: 'max',
  5670. maxlength: 'maxLength',
  5671. media: 'media',
  5672. mediagroup: 'mediaGroup',
  5673. method: 'method',
  5674. min: 'min',
  5675. minlength: 'minLength',
  5676. multiple: 'multiple',
  5677. muted: 'muted',
  5678. name: 'name',
  5679. nomodule: 'noModule',
  5680. nonce: 'nonce',
  5681. novalidate: 'noValidate',
  5682. open: 'open',
  5683. optimum: 'optimum',
  5684. pattern: 'pattern',
  5685. placeholder: 'placeholder',
  5686. playsinline: 'playsInline',
  5687. poster: 'poster',
  5688. preload: 'preload',
  5689. profile: 'profile',
  5690. radiogroup: 'radioGroup',
  5691. readonly: 'readOnly',
  5692. referrerpolicy: 'referrerPolicy',
  5693. rel: 'rel',
  5694. required: 'required',
  5695. reversed: 'reversed',
  5696. role: 'role',
  5697. rows: 'rows',
  5698. rowspan: 'rowSpan',
  5699. sandbox: 'sandbox',
  5700. scope: 'scope',
  5701. scoped: 'scoped',
  5702. scrolling: 'scrolling',
  5703. seamless: 'seamless',
  5704. selected: 'selected',
  5705. shape: 'shape',
  5706. size: 'size',
  5707. sizes: 'sizes',
  5708. span: 'span',
  5709. spellcheck: 'spellCheck',
  5710. src: 'src',
  5711. srcdoc: 'srcDoc',
  5712. srclang: 'srcLang',
  5713. srcset: 'srcSet',
  5714. start: 'start',
  5715. step: 'step',
  5716. style: 'style',
  5717. summary: 'summary',
  5718. tabindex: 'tabIndex',
  5719. target: 'target',
  5720. title: 'title',
  5721. type: 'type',
  5722. usemap: 'useMap',
  5723. value: 'value',
  5724. width: 'width',
  5725. wmode: 'wmode',
  5726. wrap: 'wrap',
  5727. // SVG
  5728. about: 'about',
  5729. accentheight: 'accentHeight',
  5730. 'accent-height': 'accentHeight',
  5731. accumulate: 'accumulate',
  5732. additive: 'additive',
  5733. alignmentbaseline: 'alignmentBaseline',
  5734. 'alignment-baseline': 'alignmentBaseline',
  5735. allowreorder: 'allowReorder',
  5736. alphabetic: 'alphabetic',
  5737. amplitude: 'amplitude',
  5738. arabicform: 'arabicForm',
  5739. 'arabic-form': 'arabicForm',
  5740. ascent: 'ascent',
  5741. attributename: 'attributeName',
  5742. attributetype: 'attributeType',
  5743. autoreverse: 'autoReverse',
  5744. azimuth: 'azimuth',
  5745. basefrequency: 'baseFrequency',
  5746. baselineshift: 'baselineShift',
  5747. 'baseline-shift': 'baselineShift',
  5748. baseprofile: 'baseProfile',
  5749. bbox: 'bbox',
  5750. begin: 'begin',
  5751. bias: 'bias',
  5752. by: 'by',
  5753. calcmode: 'calcMode',
  5754. capheight: 'capHeight',
  5755. 'cap-height': 'capHeight',
  5756. clip: 'clip',
  5757. clippath: 'clipPath',
  5758. 'clip-path': 'clipPath',
  5759. clippathunits: 'clipPathUnits',
  5760. cliprule: 'clipRule',
  5761. 'clip-rule': 'clipRule',
  5762. color: 'color',
  5763. colorinterpolation: 'colorInterpolation',
  5764. 'color-interpolation': 'colorInterpolation',
  5765. colorinterpolationfilters: 'colorInterpolationFilters',
  5766. 'color-interpolation-filters': 'colorInterpolationFilters',
  5767. colorprofile: 'colorProfile',
  5768. 'color-profile': 'colorProfile',
  5769. colorrendering: 'colorRendering',
  5770. 'color-rendering': 'colorRendering',
  5771. contentscripttype: 'contentScriptType',
  5772. contentstyletype: 'contentStyleType',
  5773. cursor: 'cursor',
  5774. cx: 'cx',
  5775. cy: 'cy',
  5776. d: 'd',
  5777. datatype: 'datatype',
  5778. decelerate: 'decelerate',
  5779. descent: 'descent',
  5780. diffuseconstant: 'diffuseConstant',
  5781. direction: 'direction',
  5782. display: 'display',
  5783. divisor: 'divisor',
  5784. dominantbaseline: 'dominantBaseline',
  5785. 'dominant-baseline': 'dominantBaseline',
  5786. dur: 'dur',
  5787. dx: 'dx',
  5788. dy: 'dy',
  5789. edgemode: 'edgeMode',
  5790. elevation: 'elevation',
  5791. enablebackground: 'enableBackground',
  5792. 'enable-background': 'enableBackground',
  5793. end: 'end',
  5794. exponent: 'exponent',
  5795. externalresourcesrequired: 'externalResourcesRequired',
  5796. fill: 'fill',
  5797. fillopacity: 'fillOpacity',
  5798. 'fill-opacity': 'fillOpacity',
  5799. fillrule: 'fillRule',
  5800. 'fill-rule': 'fillRule',
  5801. filter: 'filter',
  5802. filterres: 'filterRes',
  5803. filterunits: 'filterUnits',
  5804. floodopacity: 'floodOpacity',
  5805. 'flood-opacity': 'floodOpacity',
  5806. floodcolor: 'floodColor',
  5807. 'flood-color': 'floodColor',
  5808. focusable: 'focusable',
  5809. fontfamily: 'fontFamily',
  5810. 'font-family': 'fontFamily',
  5811. fontsize: 'fontSize',
  5812. 'font-size': 'fontSize',
  5813. fontsizeadjust: 'fontSizeAdjust',
  5814. 'font-size-adjust': 'fontSizeAdjust',
  5815. fontstretch: 'fontStretch',
  5816. 'font-stretch': 'fontStretch',
  5817. fontstyle: 'fontStyle',
  5818. 'font-style': 'fontStyle',
  5819. fontvariant: 'fontVariant',
  5820. 'font-variant': 'fontVariant',
  5821. fontweight: 'fontWeight',
  5822. 'font-weight': 'fontWeight',
  5823. format: 'format',
  5824. from: 'from',
  5825. fx: 'fx',
  5826. fy: 'fy',
  5827. g1: 'g1',
  5828. g2: 'g2',
  5829. glyphname: 'glyphName',
  5830. 'glyph-name': 'glyphName',
  5831. glyphorientationhorizontal: 'glyphOrientationHorizontal',
  5832. 'glyph-orientation-horizontal': 'glyphOrientationHorizontal',
  5833. glyphorientationvertical: 'glyphOrientationVertical',
  5834. 'glyph-orientation-vertical': 'glyphOrientationVertical',
  5835. glyphref: 'glyphRef',
  5836. gradienttransform: 'gradientTransform',
  5837. gradientunits: 'gradientUnits',
  5838. hanging: 'hanging',
  5839. horizadvx: 'horizAdvX',
  5840. 'horiz-adv-x': 'horizAdvX',
  5841. horizoriginx: 'horizOriginX',
  5842. 'horiz-origin-x': 'horizOriginX',
  5843. ideographic: 'ideographic',
  5844. imagerendering: 'imageRendering',
  5845. 'image-rendering': 'imageRendering',
  5846. in2: 'in2',
  5847. in: 'in',
  5848. inlist: 'inlist',
  5849. intercept: 'intercept',
  5850. k1: 'k1',
  5851. k2: 'k2',
  5852. k3: 'k3',
  5853. k4: 'k4',
  5854. k: 'k',
  5855. kernelmatrix: 'kernelMatrix',
  5856. kernelunitlength: 'kernelUnitLength',
  5857. kerning: 'kerning',
  5858. keypoints: 'keyPoints',
  5859. keysplines: 'keySplines',
  5860. keytimes: 'keyTimes',
  5861. lengthadjust: 'lengthAdjust',
  5862. letterspacing: 'letterSpacing',
  5863. 'letter-spacing': 'letterSpacing',
  5864. lightingcolor: 'lightingColor',
  5865. 'lighting-color': 'lightingColor',
  5866. limitingconeangle: 'limitingConeAngle',
  5867. local: 'local',
  5868. markerend: 'markerEnd',
  5869. 'marker-end': 'markerEnd',
  5870. markerheight: 'markerHeight',
  5871. markermid: 'markerMid',
  5872. 'marker-mid': 'markerMid',
  5873. markerstart: 'markerStart',
  5874. 'marker-start': 'markerStart',
  5875. markerunits: 'markerUnits',
  5876. markerwidth: 'markerWidth',
  5877. mask: 'mask',
  5878. maskcontentunits: 'maskContentUnits',
  5879. maskunits: 'maskUnits',
  5880. mathematical: 'mathematical',
  5881. mode: 'mode',
  5882. numoctaves: 'numOctaves',
  5883. offset: 'offset',
  5884. opacity: 'opacity',
  5885. operator: 'operator',
  5886. order: 'order',
  5887. orient: 'orient',
  5888. orientation: 'orientation',
  5889. origin: 'origin',
  5890. overflow: 'overflow',
  5891. overlineposition: 'overlinePosition',
  5892. 'overline-position': 'overlinePosition',
  5893. overlinethickness: 'overlineThickness',
  5894. 'overline-thickness': 'overlineThickness',
  5895. paintorder: 'paintOrder',
  5896. 'paint-order': 'paintOrder',
  5897. panose1: 'panose1',
  5898. 'panose-1': 'panose1',
  5899. pathlength: 'pathLength',
  5900. patterncontentunits: 'patternContentUnits',
  5901. patterntransform: 'patternTransform',
  5902. patternunits: 'patternUnits',
  5903. pointerevents: 'pointerEvents',
  5904. 'pointer-events': 'pointerEvents',
  5905. points: 'points',
  5906. pointsatx: 'pointsAtX',
  5907. pointsaty: 'pointsAtY',
  5908. pointsatz: 'pointsAtZ',
  5909. prefix: 'prefix',
  5910. preservealpha: 'preserveAlpha',
  5911. preserveaspectratio: 'preserveAspectRatio',
  5912. primitiveunits: 'primitiveUnits',
  5913. property: 'property',
  5914. r: 'r',
  5915. radius: 'radius',
  5916. refx: 'refX',
  5917. refy: 'refY',
  5918. renderingintent: 'renderingIntent',
  5919. 'rendering-intent': 'renderingIntent',
  5920. repeatcount: 'repeatCount',
  5921. repeatdur: 'repeatDur',
  5922. requiredextensions: 'requiredExtensions',
  5923. requiredfeatures: 'requiredFeatures',
  5924. resource: 'resource',
  5925. restart: 'restart',
  5926. result: 'result',
  5927. results: 'results',
  5928. rotate: 'rotate',
  5929. rx: 'rx',
  5930. ry: 'ry',
  5931. scale: 'scale',
  5932. security: 'security',
  5933. seed: 'seed',
  5934. shaperendering: 'shapeRendering',
  5935. 'shape-rendering': 'shapeRendering',
  5936. slope: 'slope',
  5937. spacing: 'spacing',
  5938. specularconstant: 'specularConstant',
  5939. specularexponent: 'specularExponent',
  5940. speed: 'speed',
  5941. spreadmethod: 'spreadMethod',
  5942. startoffset: 'startOffset',
  5943. stddeviation: 'stdDeviation',
  5944. stemh: 'stemh',
  5945. stemv: 'stemv',
  5946. stitchtiles: 'stitchTiles',
  5947. stopcolor: 'stopColor',
  5948. 'stop-color': 'stopColor',
  5949. stopopacity: 'stopOpacity',
  5950. 'stop-opacity': 'stopOpacity',
  5951. strikethroughposition: 'strikethroughPosition',
  5952. 'strikethrough-position': 'strikethroughPosition',
  5953. strikethroughthickness: 'strikethroughThickness',
  5954. 'strikethrough-thickness': 'strikethroughThickness',
  5955. string: 'string',
  5956. stroke: 'stroke',
  5957. strokedasharray: 'strokeDasharray',
  5958. 'stroke-dasharray': 'strokeDasharray',
  5959. strokedashoffset: 'strokeDashoffset',
  5960. 'stroke-dashoffset': 'strokeDashoffset',
  5961. strokelinecap: 'strokeLinecap',
  5962. 'stroke-linecap': 'strokeLinecap',
  5963. strokelinejoin: 'strokeLinejoin',
  5964. 'stroke-linejoin': 'strokeLinejoin',
  5965. strokemiterlimit: 'strokeMiterlimit',
  5966. 'stroke-miterlimit': 'strokeMiterlimit',
  5967. strokewidth: 'strokeWidth',
  5968. 'stroke-width': 'strokeWidth',
  5969. strokeopacity: 'strokeOpacity',
  5970. 'stroke-opacity': 'strokeOpacity',
  5971. suppresscontenteditablewarning: 'suppressContentEditableWarning',
  5972. suppresshydrationwarning: 'suppressHydrationWarning',
  5973. surfacescale: 'surfaceScale',
  5974. systemlanguage: 'systemLanguage',
  5975. tablevalues: 'tableValues',
  5976. targetx: 'targetX',
  5977. targety: 'targetY',
  5978. textanchor: 'textAnchor',
  5979. 'text-anchor': 'textAnchor',
  5980. textdecoration: 'textDecoration',
  5981. 'text-decoration': 'textDecoration',
  5982. textlength: 'textLength',
  5983. textrendering: 'textRendering',
  5984. 'text-rendering': 'textRendering',
  5985. to: 'to',
  5986. transform: 'transform',
  5987. typeof: 'typeof',
  5988. u1: 'u1',
  5989. u2: 'u2',
  5990. underlineposition: 'underlinePosition',
  5991. 'underline-position': 'underlinePosition',
  5992. underlinethickness: 'underlineThickness',
  5993. 'underline-thickness': 'underlineThickness',
  5994. unicode: 'unicode',
  5995. unicodebidi: 'unicodeBidi',
  5996. 'unicode-bidi': 'unicodeBidi',
  5997. unicoderange: 'unicodeRange',
  5998. 'unicode-range': 'unicodeRange',
  5999. unitsperem: 'unitsPerEm',
  6000. 'units-per-em': 'unitsPerEm',
  6001. unselectable: 'unselectable',
  6002. valphabetic: 'vAlphabetic',
  6003. 'v-alphabetic': 'vAlphabetic',
  6004. values: 'values',
  6005. vectoreffect: 'vectorEffect',
  6006. 'vector-effect': 'vectorEffect',
  6007. version: 'version',
  6008. vertadvy: 'vertAdvY',
  6009. 'vert-adv-y': 'vertAdvY',
  6010. vertoriginx: 'vertOriginX',
  6011. 'vert-origin-x': 'vertOriginX',
  6012. vertoriginy: 'vertOriginY',
  6013. 'vert-origin-y': 'vertOriginY',
  6014. vhanging: 'vHanging',
  6015. 'v-hanging': 'vHanging',
  6016. videographic: 'vIdeographic',
  6017. 'v-ideographic': 'vIdeographic',
  6018. viewbox: 'viewBox',
  6019. viewtarget: 'viewTarget',
  6020. visibility: 'visibility',
  6021. vmathematical: 'vMathematical',
  6022. 'v-mathematical': 'vMathematical',
  6023. vocab: 'vocab',
  6024. widths: 'widths',
  6025. wordspacing: 'wordSpacing',
  6026. 'word-spacing': 'wordSpacing',
  6027. writingmode: 'writingMode',
  6028. 'writing-mode': 'writingMode',
  6029. x1: 'x1',
  6030. x2: 'x2',
  6031. x: 'x',
  6032. xchannelselector: 'xChannelSelector',
  6033. xheight: 'xHeight',
  6034. 'x-height': 'xHeight',
  6035. xlinkactuate: 'xlinkActuate',
  6036. 'xlink:actuate': 'xlinkActuate',
  6037. xlinkarcrole: 'xlinkArcrole',
  6038. 'xlink:arcrole': 'xlinkArcrole',
  6039. xlinkhref: 'xlinkHref',
  6040. 'xlink:href': 'xlinkHref',
  6041. xlinkrole: 'xlinkRole',
  6042. 'xlink:role': 'xlinkRole',
  6043. xlinkshow: 'xlinkShow',
  6044. 'xlink:show': 'xlinkShow',
  6045. xlinktitle: 'xlinkTitle',
  6046. 'xlink:title': 'xlinkTitle',
  6047. xlinktype: 'xlinkType',
  6048. 'xlink:type': 'xlinkType',
  6049. xmlbase: 'xmlBase',
  6050. 'xml:base': 'xmlBase',
  6051. xmllang: 'xmlLang',
  6052. 'xml:lang': 'xmlLang',
  6053. xmlns: 'xmlns',
  6054. 'xml:space': 'xmlSpace',
  6055. xmlnsxlink: 'xmlnsXlink',
  6056. 'xmlns:xlink': 'xmlnsXlink',
  6057. xmlspace: 'xmlSpace',
  6058. y1: 'y1',
  6059. y2: 'y2',
  6060. y: 'y',
  6061. ychannelselector: 'yChannelSelector',
  6062. z: 'z',
  6063. zoomandpan: 'zoomAndPan'
  6064. };
  6065. var ariaProperties = {
  6066. 'aria-current': 0,
  6067. // state
  6068. 'aria-details': 0,
  6069. 'aria-disabled': 0,
  6070. // state
  6071. 'aria-hidden': 0,
  6072. // state
  6073. 'aria-invalid': 0,
  6074. // state
  6075. 'aria-keyshortcuts': 0,
  6076. 'aria-label': 0,
  6077. 'aria-roledescription': 0,
  6078. // Widget Attributes
  6079. 'aria-autocomplete': 0,
  6080. 'aria-checked': 0,
  6081. 'aria-expanded': 0,
  6082. 'aria-haspopup': 0,
  6083. 'aria-level': 0,
  6084. 'aria-modal': 0,
  6085. 'aria-multiline': 0,
  6086. 'aria-multiselectable': 0,
  6087. 'aria-orientation': 0,
  6088. 'aria-placeholder': 0,
  6089. 'aria-pressed': 0,
  6090. 'aria-readonly': 0,
  6091. 'aria-required': 0,
  6092. 'aria-selected': 0,
  6093. 'aria-sort': 0,
  6094. 'aria-valuemax': 0,
  6095. 'aria-valuemin': 0,
  6096. 'aria-valuenow': 0,
  6097. 'aria-valuetext': 0,
  6098. // Live Region Attributes
  6099. 'aria-atomic': 0,
  6100. 'aria-busy': 0,
  6101. 'aria-live': 0,
  6102. 'aria-relevant': 0,
  6103. // Drag-and-Drop Attributes
  6104. 'aria-dropeffect': 0,
  6105. 'aria-grabbed': 0,
  6106. // Relationship Attributes
  6107. 'aria-activedescendant': 0,
  6108. 'aria-colcount': 0,
  6109. 'aria-colindex': 0,
  6110. 'aria-colspan': 0,
  6111. 'aria-controls': 0,
  6112. 'aria-describedby': 0,
  6113. 'aria-errormessage': 0,
  6114. 'aria-flowto': 0,
  6115. 'aria-labelledby': 0,
  6116. 'aria-owns': 0,
  6117. 'aria-posinset': 0,
  6118. 'aria-rowcount': 0,
  6119. 'aria-rowindex': 0,
  6120. 'aria-rowspan': 0,
  6121. 'aria-setsize': 0
  6122. };
  6123. var warnedProperties = {};
  6124. var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
  6125. var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
  6126. var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  6127. function validateProperty(tagName, name) {
  6128. if (hasOwnProperty$1.call(warnedProperties, name) && warnedProperties[name]) {
  6129. return true;
  6130. }
  6131. if (rARIACamel.test(name)) {
  6132. var ariaName = 'aria-' + name.slice(4).toLowerCase();
  6133. var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null; // If this is an aria-* attribute, but is not listed in the known DOM
  6134. // DOM properties, then it is an invalid aria-* attribute.
  6135. if (correctName == null) {
  6136. warning$1(false, 'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.', name);
  6137. warnedProperties[name] = true;
  6138. return true;
  6139. } // aria-* attributes should be lowercase; suggest the lowercase version.
  6140. if (name !== correctName) {
  6141. warning$1(false, 'Invalid ARIA attribute `%s`. Did you mean `%s`?', name, correctName);
  6142. warnedProperties[name] = true;
  6143. return true;
  6144. }
  6145. }
  6146. if (rARIA.test(name)) {
  6147. var lowerCasedName = name.toLowerCase();
  6148. var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null; // If this is an aria-* attribute, but is not listed in the known DOM
  6149. // DOM properties, then it is an invalid aria-* attribute.
  6150. if (standardName == null) {
  6151. warnedProperties[name] = true;
  6152. return false;
  6153. } // aria-* attributes should be lowercase; suggest the lowercase version.
  6154. if (name !== standardName) {
  6155. warning$1(false, 'Unknown ARIA attribute `%s`. Did you mean `%s`?', name, standardName);
  6156. warnedProperties[name] = true;
  6157. return true;
  6158. }
  6159. }
  6160. return true;
  6161. }
  6162. function warnInvalidARIAProps(type, props) {
  6163. var invalidProps = [];
  6164. for (var key in props) {
  6165. var isValid = validateProperty(type, key);
  6166. if (!isValid) {
  6167. invalidProps.push(key);
  6168. }
  6169. }
  6170. var unknownPropString = invalidProps.map(function (prop) {
  6171. return '`' + prop + '`';
  6172. }).join(', ');
  6173. if (invalidProps.length === 1) {
  6174. warning$1(false, 'Invalid aria prop %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop', unknownPropString, type);
  6175. } else if (invalidProps.length > 1) {
  6176. warning$1(false, 'Invalid aria props %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop', unknownPropString, type);
  6177. }
  6178. }
  6179. function validateProperties(type, props) {
  6180. if (isCustomComponent(type, props)) {
  6181. return;
  6182. }
  6183. warnInvalidARIAProps(type, props);
  6184. }
  6185. var didWarnValueNull = false;
  6186. function validateProperties$1(type, props) {
  6187. if (type !== 'input' && type !== 'textarea' && type !== 'select') {
  6188. return;
  6189. }
  6190. if (props != null && props.value === null && !didWarnValueNull) {
  6191. didWarnValueNull = true;
  6192. if (type === 'select' && props.multiple) {
  6193. warning$1(false, '`value` prop on `%s` should not be null. ' + 'Consider using an empty array when `multiple` is set to `true` ' + 'to clear the component or `undefined` for uncontrolled components.', type);
  6194. } else {
  6195. warning$1(false, '`value` prop on `%s` should not be null. ' + 'Consider using an empty string to clear the component or `undefined` ' + 'for uncontrolled components.', type);
  6196. }
  6197. }
  6198. }
  6199. var validateProperty$1 = function () {};
  6200. {
  6201. var warnedProperties$1 = {};
  6202. var _hasOwnProperty = Object.prototype.hasOwnProperty;
  6203. var EVENT_NAME_REGEX = /^on./;
  6204. var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/;
  6205. var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
  6206. var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
  6207. validateProperty$1 = function (tagName, name, value, canUseEventSystem) {
  6208. if (_hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) {
  6209. return true;
  6210. }
  6211. var lowerCasedName = name.toLowerCase();
  6212. if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') {
  6213. warning$1(false, 'React uses onFocus and onBlur instead of onFocusIn and onFocusOut. ' + 'All React events are normalized to bubble, so onFocusIn and onFocusOut ' + 'are not needed/supported by React.');
  6214. warnedProperties$1[name] = true;
  6215. return true;
  6216. } // We can't rely on the event system being injected on the server.
  6217. if (canUseEventSystem) {
  6218. if (registrationNameModules.hasOwnProperty(name)) {
  6219. return true;
  6220. }
  6221. var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null;
  6222. if (registrationName != null) {
  6223. warning$1(false, 'Invalid event handler property `%s`. Did you mean `%s`?', name, registrationName);
  6224. warnedProperties$1[name] = true;
  6225. return true;
  6226. }
  6227. if (EVENT_NAME_REGEX.test(name)) {
  6228. warning$1(false, 'Unknown event handler property `%s`. It will be ignored.', name);
  6229. warnedProperties$1[name] = true;
  6230. return true;
  6231. }
  6232. } else if (EVENT_NAME_REGEX.test(name)) {
  6233. // If no event plugins have been injected, we are in a server environment.
  6234. // So we can't tell if the event name is correct for sure, but we can filter
  6235. // out known bad ones like `onclick`. We can't suggest a specific replacement though.
  6236. if (INVALID_EVENT_NAME_REGEX.test(name)) {
  6237. warning$1(false, 'Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.', name);
  6238. }
  6239. warnedProperties$1[name] = true;
  6240. return true;
  6241. } // Let the ARIA attribute hook validate ARIA attributes
  6242. if (rARIA$1.test(name) || rARIACamel$1.test(name)) {
  6243. return true;
  6244. }
  6245. if (lowerCasedName === 'innerhtml') {
  6246. warning$1(false, 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.');
  6247. warnedProperties$1[name] = true;
  6248. return true;
  6249. }
  6250. if (lowerCasedName === 'aria') {
  6251. warning$1(false, 'The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.');
  6252. warnedProperties$1[name] = true;
  6253. return true;
  6254. }
  6255. if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') {
  6256. warning$1(false, 'Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.', typeof value);
  6257. warnedProperties$1[name] = true;
  6258. return true;
  6259. }
  6260. if (typeof value === 'number' && isNaN(value)) {
  6261. warning$1(false, 'Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.', name);
  6262. warnedProperties$1[name] = true;
  6263. return true;
  6264. }
  6265. var propertyInfo = getPropertyInfo(name);
  6266. var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED; // Known attributes should match the casing specified in the property config.
  6267. if (possibleStandardNames.hasOwnProperty(lowerCasedName)) {
  6268. var standardName = possibleStandardNames[lowerCasedName];
  6269. if (standardName !== name) {
  6270. warning$1(false, 'Invalid DOM property `%s`. Did you mean `%s`?', name, standardName);
  6271. warnedProperties$1[name] = true;
  6272. return true;
  6273. }
  6274. } else if (!isReserved && name !== lowerCasedName) {
  6275. // Unknown attributes should have lowercase casing since that's how they
  6276. // will be cased anyway with server rendering.
  6277. warning$1(false, 'React does not recognize the `%s` prop on a DOM element. If you ' + 'intentionally want it to appear in the DOM as a custom ' + 'attribute, spell it as lowercase `%s` instead. ' + 'If you accidentally passed it from a parent component, remove ' + 'it from the DOM element.', name, lowerCasedName);
  6278. warnedProperties$1[name] = true;
  6279. return true;
  6280. }
  6281. if (typeof value === 'boolean' && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
  6282. if (value) {
  6283. warning$1(false, 'Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.', value, name, name, value, name);
  6284. } else {
  6285. warning$1(false, 'Received `%s` for a non-boolean attribute `%s`.\n\n' + 'If you want to write it to the DOM, pass a string instead: ' + '%s="%s" or %s={value.toString()}.\n\n' + 'If you used to conditionally omit it with %s={condition && value}, ' + 'pass %s={condition ? value : undefined} instead.', value, name, name, value, name, name, name);
  6286. }
  6287. warnedProperties$1[name] = true;
  6288. return true;
  6289. } // Now that we've validated casing, do not validate
  6290. // data types for reserved props
  6291. if (isReserved) {
  6292. return true;
  6293. } // Warn when a known attribute is a bad type
  6294. if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
  6295. warnedProperties$1[name] = true;
  6296. return false;
  6297. } // Warn when passing the strings 'false' or 'true' into a boolean prop
  6298. if ((value === 'false' || value === 'true') && propertyInfo !== null && propertyInfo.type === BOOLEAN) {
  6299. warning$1(false, 'Received the string `%s` for the boolean attribute `%s`. ' + '%s ' + 'Did you mean %s={%s}?', value, name, value === 'false' ? 'The browser will interpret it as a truthy value.' : 'Although this works, it will not work as expected if you pass the string "false".', name, value);
  6300. warnedProperties$1[name] = true;
  6301. return true;
  6302. }
  6303. return true;
  6304. };
  6305. }
  6306. var warnUnknownProperties = function (type, props, canUseEventSystem) {
  6307. var unknownProps = [];
  6308. for (var key in props) {
  6309. var isValid = validateProperty$1(type, key, props[key], canUseEventSystem);
  6310. if (!isValid) {
  6311. unknownProps.push(key);
  6312. }
  6313. }
  6314. var unknownPropString = unknownProps.map(function (prop) {
  6315. return '`' + prop + '`';
  6316. }).join(', ');
  6317. if (unknownProps.length === 1) {
  6318. warning$1(false, 'Invalid value for prop %s on <%s> tag. Either remove it from the element, ' + 'or pass a string or number value to keep it in the DOM. ' + 'For details, see https://fb.me/react-attribute-behavior', unknownPropString, type);
  6319. } else if (unknownProps.length > 1) {
  6320. warning$1(false, 'Invalid values for props %s on <%s> tag. Either remove them from the element, ' + 'or pass a string or number value to keep them in the DOM. ' + 'For details, see https://fb.me/react-attribute-behavior', unknownPropString, type);
  6321. }
  6322. };
  6323. function validateProperties$2(type, props, canUseEventSystem) {
  6324. if (isCustomComponent(type, props)) {
  6325. return;
  6326. }
  6327. warnUnknownProperties(type, props, canUseEventSystem);
  6328. }
  6329. // TODO: direct imports like some-package/src/* are bad. Fix me.
  6330. var didWarnInvalidHydration = false;
  6331. var didWarnShadyDOM = false;
  6332. var didWarnScriptTags = false;
  6333. var DANGEROUSLY_SET_INNER_HTML = 'dangerouslySetInnerHTML';
  6334. var SUPPRESS_CONTENT_EDITABLE_WARNING = 'suppressContentEditableWarning';
  6335. var SUPPRESS_HYDRATION_WARNING$1 = 'suppressHydrationWarning';
  6336. var AUTOFOCUS = 'autoFocus';
  6337. var CHILDREN = 'children';
  6338. var STYLE$1 = 'style';
  6339. var HTML = '__html';
  6340. var LISTENERS = 'listeners';
  6341. var HTML_NAMESPACE = Namespaces.html;
  6342. var warnedUnknownTags;
  6343. var suppressHydrationWarning;
  6344. var validatePropertiesInDevelopment;
  6345. var warnForTextDifference;
  6346. var warnForPropDifference;
  6347. var warnForExtraAttributes;
  6348. var warnForInvalidEventListener;
  6349. var canDiffStyleForHydrationWarning;
  6350. var normalizeMarkupForTextOrAttribute;
  6351. var normalizeHTML;
  6352. {
  6353. warnedUnknownTags = {
  6354. // Chrome is the only major browser not shipping <time>. But as of July
  6355. // 2017 it intends to ship it due to widespread usage. We intentionally
  6356. // *don't* warn for <time> even if it's unrecognized by Chrome because
  6357. // it soon will be, and many apps have been using it anyway.
  6358. time: true,
  6359. // There are working polyfills for <dialog>. Let people use it.
  6360. dialog: true,
  6361. // Electron ships a custom <webview> tag to display external web content in
  6362. // an isolated frame and process.
  6363. // This tag is not present in non Electron environments such as JSDom which
  6364. // is often used for testing purposes.
  6365. // @see https://electronjs.org/docs/api/webview-tag
  6366. webview: true
  6367. };
  6368. validatePropertiesInDevelopment = function (type, props) {
  6369. validateProperties(type, props);
  6370. validateProperties$1(type, props);
  6371. validateProperties$2(type, props,
  6372. /* canUseEventSystem */
  6373. true);
  6374. }; // IE 11 parses & normalizes the style attribute as opposed to other
  6375. // browsers. It adds spaces and sorts the properties in some
  6376. // non-alphabetical order. Handling that would require sorting CSS
  6377. // properties in the client & server versions or applying
  6378. // `expectedStyle` to a temporary DOM node to read its `style` attribute
  6379. // normalized. Since it only affects IE, we're skipping style warnings
  6380. // in that browser completely in favor of doing all that work.
  6381. // See https://github.com/facebook/react/issues/11807
  6382. canDiffStyleForHydrationWarning = canUseDOM && !document.documentMode; // HTML parsing normalizes CR and CRLF to LF.
  6383. // It also can turn \u0000 into \uFFFD inside attributes.
  6384. // https://www.w3.org/TR/html5/single-page.html#preprocessing-the-input-stream
  6385. // If we have a mismatch, it might be caused by that.
  6386. // We will still patch up in this case but not fire the warning.
  6387. var NORMALIZE_NEWLINES_REGEX = /\r\n?/g;
  6388. var NORMALIZE_NULL_AND_REPLACEMENT_REGEX = /\u0000|\uFFFD/g;
  6389. normalizeMarkupForTextOrAttribute = function (markup) {
  6390. var markupString = typeof markup === 'string' ? markup : '' + markup;
  6391. return markupString.replace(NORMALIZE_NEWLINES_REGEX, '\n').replace(NORMALIZE_NULL_AND_REPLACEMENT_REGEX, '');
  6392. };
  6393. warnForTextDifference = function (serverText, clientText) {
  6394. if (didWarnInvalidHydration) {
  6395. return;
  6396. }
  6397. var normalizedClientText = normalizeMarkupForTextOrAttribute(clientText);
  6398. var normalizedServerText = normalizeMarkupForTextOrAttribute(serverText);
  6399. if (normalizedServerText === normalizedClientText) {
  6400. return;
  6401. }
  6402. didWarnInvalidHydration = true;
  6403. warningWithoutStack$1(false, 'Text content did not match. Server: "%s" Client: "%s"', normalizedServerText, normalizedClientText);
  6404. };
  6405. warnForPropDifference = function (propName, serverValue, clientValue) {
  6406. if (didWarnInvalidHydration) {
  6407. return;
  6408. }
  6409. var normalizedClientValue = normalizeMarkupForTextOrAttribute(clientValue);
  6410. var normalizedServerValue = normalizeMarkupForTextOrAttribute(serverValue);
  6411. if (normalizedServerValue === normalizedClientValue) {
  6412. return;
  6413. }
  6414. didWarnInvalidHydration = true;
  6415. warningWithoutStack$1(false, 'Prop `%s` did not match. Server: %s Client: %s', propName, JSON.stringify(normalizedServerValue), JSON.stringify(normalizedClientValue));
  6416. };
  6417. warnForExtraAttributes = function (attributeNames) {
  6418. if (didWarnInvalidHydration) {
  6419. return;
  6420. }
  6421. didWarnInvalidHydration = true;
  6422. var names = [];
  6423. attributeNames.forEach(function (name) {
  6424. names.push(name);
  6425. });
  6426. warningWithoutStack$1(false, 'Extra attributes from the server: %s', names);
  6427. };
  6428. warnForInvalidEventListener = function (registrationName, listener) {
  6429. if (listener === false) {
  6430. warning$1(false, 'Expected `%s` listener to be a function, instead got `false`.\n\n' + 'If you used to conditionally omit it with %s={condition && value}, ' + 'pass %s={condition ? value : undefined} instead.', registrationName, registrationName, registrationName);
  6431. } else {
  6432. warning$1(false, 'Expected `%s` listener to be a function, instead got a value of `%s` type.', registrationName, typeof listener);
  6433. }
  6434. }; // Parse the HTML and read it back to normalize the HTML string so that it
  6435. // can be used for comparison.
  6436. normalizeHTML = function (parent, html) {
  6437. // We could have created a separate document here to avoid
  6438. // re-initializing custom elements if they exist. But this breaks
  6439. // how <noscript> is being handled. So we use the same document.
  6440. // See the discussion in https://github.com/facebook/react/pull/11157.
  6441. var testElement = parent.namespaceURI === HTML_NAMESPACE ? parent.ownerDocument.createElement(parent.tagName) : parent.ownerDocument.createElementNS(parent.namespaceURI, parent.tagName);
  6442. testElement.innerHTML = html;
  6443. return testElement.innerHTML;
  6444. };
  6445. }
  6446. function ensureListeningTo(rootContainerElement, registrationName) {
  6447. var isDocumentOrFragment = rootContainerElement.nodeType === DOCUMENT_NODE || rootContainerElement.nodeType === DOCUMENT_FRAGMENT_NODE;
  6448. var doc = isDocumentOrFragment ? rootContainerElement : rootContainerElement.ownerDocument;
  6449. listenTo(registrationName, doc);
  6450. }
  6451. function getOwnerDocumentFromRootContainer(rootContainerElement) {
  6452. return rootContainerElement.nodeType === DOCUMENT_NODE ? rootContainerElement : rootContainerElement.ownerDocument;
  6453. }
  6454. function noop() {}
  6455. function trapClickOnNonInteractiveElement(node) {
  6456. // Mobile Safari does not fire properly bubble click events on
  6457. // non-interactive elements, which means delegated click listeners do not
  6458. // fire. The workaround for this bug involves attaching an empty click
  6459. // listener on the target node.
  6460. // http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
  6461. // Just set it using the onclick property so that we don't have to manage any
  6462. // bookkeeping for it. Not sure if we need to clear it when the listener is
  6463. // removed.
  6464. // TODO: Only do this for the relevant Safaris maybe?
  6465. node.onclick = noop;
  6466. }
  6467. function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) {
  6468. for (var propKey in nextProps) {
  6469. if (!nextProps.hasOwnProperty(propKey)) {
  6470. continue;
  6471. }
  6472. var nextProp = nextProps[propKey];
  6473. if (propKey === STYLE$1) {
  6474. {
  6475. if (nextProp) {
  6476. // Freeze the next style object so that we can assume it won't be
  6477. // mutated. We have already warned for this in the past.
  6478. Object.freeze(nextProp);
  6479. }
  6480. } // Relies on `updateStylesByID` not mutating `styleUpdates`.
  6481. setValueForStyles(domElement, nextProp);
  6482. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  6483. var nextHtml = nextProp ? nextProp[HTML] : undefined;
  6484. if (nextHtml != null) {
  6485. setInnerHTML(domElement, nextHtml);
  6486. }
  6487. } else if (propKey === CHILDREN) {
  6488. if (typeof nextProp === 'string') {
  6489. // Avoid setting initial textContent when the text is empty. In IE11 setting
  6490. // textContent on a <textarea> will cause the placeholder to not
  6491. // show within the <textarea> until it has been focused and blurred again.
  6492. // https://github.com/facebook/react/issues/6731#issuecomment-254874553
  6493. var canSetTextContent = tag !== 'textarea' || nextProp !== '';
  6494. if (canSetTextContent) {
  6495. setTextContent(domElement, nextProp);
  6496. }
  6497. } else if (typeof nextProp === 'number') {
  6498. setTextContent(domElement, '' + nextProp);
  6499. }
  6500. } else if (enableFlareAPI && propKey === LISTENERS || propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {// Noop
  6501. } else if (propKey === AUTOFOCUS) {// We polyfill it separately on the client during commit.
  6502. // We could have excluded it in the property list instead of
  6503. // adding a special case here, but then it wouldn't be emitted
  6504. // on server rendering (but we *do* want to emit it in SSR).
  6505. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  6506. if (nextProp != null) {
  6507. if (true && typeof nextProp !== 'function') {
  6508. warnForInvalidEventListener(propKey, nextProp);
  6509. }
  6510. ensureListeningTo(rootContainerElement, propKey);
  6511. }
  6512. } else if (nextProp != null) {
  6513. setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag);
  6514. }
  6515. }
  6516. }
  6517. function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) {
  6518. // TODO: Handle wasCustomComponentTag
  6519. for (var i = 0; i < updatePayload.length; i += 2) {
  6520. var propKey = updatePayload[i];
  6521. var propValue = updatePayload[i + 1];
  6522. if (propKey === STYLE$1) {
  6523. setValueForStyles(domElement, propValue);
  6524. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  6525. setInnerHTML(domElement, propValue);
  6526. } else if (propKey === CHILDREN) {
  6527. setTextContent(domElement, propValue);
  6528. } else {
  6529. setValueForProperty(domElement, propKey, propValue, isCustomComponentTag);
  6530. }
  6531. }
  6532. }
  6533. function createElement(type, props, rootContainerElement, parentNamespace) {
  6534. var isCustomComponentTag; // We create tags in the namespace of their parent container, except HTML
  6535. // tags get no namespace.
  6536. var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement);
  6537. var domElement;
  6538. var namespaceURI = parentNamespace;
  6539. if (namespaceURI === HTML_NAMESPACE) {
  6540. namespaceURI = getIntrinsicNamespace(type);
  6541. }
  6542. if (namespaceURI === HTML_NAMESPACE) {
  6543. {
  6544. isCustomComponentTag = isCustomComponent(type, props); // Should this check be gated by parent namespace? Not sure we want to
  6545. // allow <SVG> or <mATH>.
  6546. !(isCustomComponentTag || type === type.toLowerCase()) ? warning$1(false, '<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', type) : void 0;
  6547. }
  6548. if (type === 'script') {
  6549. // Create the script via .innerHTML so its "parser-inserted" flag is
  6550. // set to true and it does not execute
  6551. var div = ownerDocument.createElement('div');
  6552. {
  6553. if (enableTrustedTypesIntegration && !didWarnScriptTags) {
  6554. warning$1(false, 'Encountered a script tag while rendering React component. ' + 'Scripts inside React components are never executed when rendering ' + 'on the client. Consider using template tag instead ' + '(https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template).');
  6555. didWarnScriptTags = true;
  6556. }
  6557. }
  6558. div.innerHTML = '<script><' + '/script>'; // eslint-disable-line
  6559. // This is guaranteed to yield a script element.
  6560. var firstChild = div.firstChild;
  6561. domElement = div.removeChild(firstChild);
  6562. } else if (typeof props.is === 'string') {
  6563. // $FlowIssue `createElement` should be updated for Web Components
  6564. domElement = ownerDocument.createElement(type, {
  6565. is: props.is
  6566. });
  6567. } else {
  6568. // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug.
  6569. // See discussion in https://github.com/facebook/react/pull/6896
  6570. // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
  6571. domElement = ownerDocument.createElement(type); // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple` and `size`
  6572. // attributes on `select`s needs to be added before `option`s are inserted.
  6573. // This prevents:
  6574. // - a bug where the `select` does not scroll to the correct option because singular
  6575. // `select` elements automatically pick the first item #13222
  6576. // - a bug where the `select` set the first item as selected despite the `size` attribute #14239
  6577. // See https://github.com/facebook/react/issues/13222
  6578. // and https://github.com/facebook/react/issues/14239
  6579. if (type === 'select') {
  6580. var node = domElement;
  6581. if (props.multiple) {
  6582. node.multiple = true;
  6583. } else if (props.size) {
  6584. // Setting a size greater than 1 causes a select to behave like `multiple=true`, where
  6585. // it is possible that no option is selected.
  6586. //
  6587. // This is only necessary when a select in "single selection mode".
  6588. node.size = props.size;
  6589. }
  6590. }
  6591. }
  6592. } else {
  6593. domElement = ownerDocument.createElementNS(namespaceURI, type);
  6594. }
  6595. {
  6596. if (namespaceURI === HTML_NAMESPACE) {
  6597. if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) {
  6598. warnedUnknownTags[type] = true;
  6599. warning$1(false, 'The tag <%s> is unrecognized in this browser. ' + 'If you meant to render a React component, start its name with ' + 'an uppercase letter.', type);
  6600. }
  6601. }
  6602. }
  6603. return domElement;
  6604. }
  6605. function createTextNode(text, rootContainerElement) {
  6606. return getOwnerDocumentFromRootContainer(rootContainerElement).createTextNode(text);
  6607. }
  6608. function setInitialProperties(domElement, tag, rawProps, rootContainerElement) {
  6609. var isCustomComponentTag = isCustomComponent(tag, rawProps);
  6610. {
  6611. validatePropertiesInDevelopment(tag, rawProps);
  6612. if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) {
  6613. warning$1(false, '%s is using shady DOM. Using shady DOM with React can ' + 'cause things to break subtly.', getCurrentFiberOwnerNameInDevOrNull() || 'A component');
  6614. didWarnShadyDOM = true;
  6615. }
  6616. } // TODO: Make sure that we check isMounted before firing any of these events.
  6617. var props;
  6618. switch (tag) {
  6619. case 'iframe':
  6620. case 'object':
  6621. case 'embed':
  6622. trapBubbledEvent(TOP_LOAD, domElement);
  6623. props = rawProps;
  6624. break;
  6625. case 'video':
  6626. case 'audio':
  6627. // Create listener for each media event
  6628. for (var i = 0; i < mediaEventTypes.length; i++) {
  6629. trapBubbledEvent(mediaEventTypes[i], domElement);
  6630. }
  6631. props = rawProps;
  6632. break;
  6633. case 'source':
  6634. trapBubbledEvent(TOP_ERROR, domElement);
  6635. props = rawProps;
  6636. break;
  6637. case 'img':
  6638. case 'image':
  6639. case 'link':
  6640. trapBubbledEvent(TOP_ERROR, domElement);
  6641. trapBubbledEvent(TOP_LOAD, domElement);
  6642. props = rawProps;
  6643. break;
  6644. case 'form':
  6645. trapBubbledEvent(TOP_RESET, domElement);
  6646. trapBubbledEvent(TOP_SUBMIT, domElement);
  6647. props = rawProps;
  6648. break;
  6649. case 'details':
  6650. trapBubbledEvent(TOP_TOGGLE, domElement);
  6651. props = rawProps;
  6652. break;
  6653. case 'input':
  6654. initWrapperState(domElement, rawProps);
  6655. props = getHostProps(domElement, rawProps);
  6656. trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening
  6657. // to onChange. Even if there is no listener.
  6658. ensureListeningTo(rootContainerElement, 'onChange');
  6659. break;
  6660. case 'option':
  6661. validateProps(domElement, rawProps);
  6662. props = getHostProps$1(domElement, rawProps);
  6663. break;
  6664. case 'select':
  6665. initWrapperState$1(domElement, rawProps);
  6666. props = getHostProps$2(domElement, rawProps);
  6667. trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening
  6668. // to onChange. Even if there is no listener.
  6669. ensureListeningTo(rootContainerElement, 'onChange');
  6670. break;
  6671. case 'textarea':
  6672. initWrapperState$2(domElement, rawProps);
  6673. props = getHostProps$3(domElement, rawProps);
  6674. trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening
  6675. // to onChange. Even if there is no listener.
  6676. ensureListeningTo(rootContainerElement, 'onChange');
  6677. break;
  6678. default:
  6679. props = rawProps;
  6680. }
  6681. assertValidProps(tag, props);
  6682. setInitialDOMProperties(tag, domElement, rootContainerElement, props, isCustomComponentTag);
  6683. switch (tag) {
  6684. case 'input':
  6685. // TODO: Make sure we check if this is still unmounted or do any clean
  6686. // up necessary since we never stop tracking anymore.
  6687. track(domElement);
  6688. postMountWrapper(domElement, rawProps, false);
  6689. break;
  6690. case 'textarea':
  6691. // TODO: Make sure we check if this is still unmounted or do any clean
  6692. // up necessary since we never stop tracking anymore.
  6693. track(domElement);
  6694. postMountWrapper$3(domElement, rawProps);
  6695. break;
  6696. case 'option':
  6697. postMountWrapper$1(domElement, rawProps);
  6698. break;
  6699. case 'select':
  6700. postMountWrapper$2(domElement, rawProps);
  6701. break;
  6702. default:
  6703. if (typeof props.onClick === 'function') {
  6704. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  6705. trapClickOnNonInteractiveElement(domElement);
  6706. }
  6707. break;
  6708. }
  6709. } // Calculate the diff between the two objects.
  6710. function diffProperties(domElement, tag, lastRawProps, nextRawProps, rootContainerElement) {
  6711. {
  6712. validatePropertiesInDevelopment(tag, nextRawProps);
  6713. }
  6714. var updatePayload = null;
  6715. var lastProps;
  6716. var nextProps;
  6717. switch (tag) {
  6718. case 'input':
  6719. lastProps = getHostProps(domElement, lastRawProps);
  6720. nextProps = getHostProps(domElement, nextRawProps);
  6721. updatePayload = [];
  6722. break;
  6723. case 'option':
  6724. lastProps = getHostProps$1(domElement, lastRawProps);
  6725. nextProps = getHostProps$1(domElement, nextRawProps);
  6726. updatePayload = [];
  6727. break;
  6728. case 'select':
  6729. lastProps = getHostProps$2(domElement, lastRawProps);
  6730. nextProps = getHostProps$2(domElement, nextRawProps);
  6731. updatePayload = [];
  6732. break;
  6733. case 'textarea':
  6734. lastProps = getHostProps$3(domElement, lastRawProps);
  6735. nextProps = getHostProps$3(domElement, nextRawProps);
  6736. updatePayload = [];
  6737. break;
  6738. default:
  6739. lastProps = lastRawProps;
  6740. nextProps = nextRawProps;
  6741. if (typeof lastProps.onClick !== 'function' && typeof nextProps.onClick === 'function') {
  6742. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  6743. trapClickOnNonInteractiveElement(domElement);
  6744. }
  6745. break;
  6746. }
  6747. assertValidProps(tag, nextProps);
  6748. var propKey;
  6749. var styleName;
  6750. var styleUpdates = null;
  6751. for (propKey in lastProps) {
  6752. if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) {
  6753. continue;
  6754. }
  6755. if (propKey === STYLE$1) {
  6756. var lastStyle = lastProps[propKey];
  6757. for (styleName in lastStyle) {
  6758. if (lastStyle.hasOwnProperty(styleName)) {
  6759. if (!styleUpdates) {
  6760. styleUpdates = {};
  6761. }
  6762. styleUpdates[styleName] = '';
  6763. }
  6764. }
  6765. } else if (propKey === DANGEROUSLY_SET_INNER_HTML || propKey === CHILDREN) {// Noop. This is handled by the clear text mechanism.
  6766. } else if (enableFlareAPI && propKey === LISTENERS || propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {// Noop
  6767. } else if (propKey === AUTOFOCUS) {// Noop. It doesn't work on updates anyway.
  6768. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  6769. // This is a special case. If any listener updates we need to ensure
  6770. // that the "current" fiber pointer gets updated so we need a commit
  6771. // to update this element.
  6772. if (!updatePayload) {
  6773. updatePayload = [];
  6774. }
  6775. } else {
  6776. // For all other deleted properties we add it to the queue. We use
  6777. // the whitelist in the commit phase instead.
  6778. (updatePayload = updatePayload || []).push(propKey, null);
  6779. }
  6780. }
  6781. for (propKey in nextProps) {
  6782. var nextProp = nextProps[propKey];
  6783. var lastProp = lastProps != null ? lastProps[propKey] : undefined;
  6784. if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) {
  6785. continue;
  6786. }
  6787. if (propKey === STYLE$1) {
  6788. {
  6789. if (nextProp) {
  6790. // Freeze the next style object so that we can assume it won't be
  6791. // mutated. We have already warned for this in the past.
  6792. Object.freeze(nextProp);
  6793. }
  6794. }
  6795. if (lastProp) {
  6796. // Unset styles on `lastProp` but not on `nextProp`.
  6797. for (styleName in lastProp) {
  6798. if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) {
  6799. if (!styleUpdates) {
  6800. styleUpdates = {};
  6801. }
  6802. styleUpdates[styleName] = '';
  6803. }
  6804. } // Update styles that changed since `lastProp`.
  6805. for (styleName in nextProp) {
  6806. if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) {
  6807. if (!styleUpdates) {
  6808. styleUpdates = {};
  6809. }
  6810. styleUpdates[styleName] = nextProp[styleName];
  6811. }
  6812. }
  6813. } else {
  6814. // Relies on `updateStylesByID` not mutating `styleUpdates`.
  6815. if (!styleUpdates) {
  6816. if (!updatePayload) {
  6817. updatePayload = [];
  6818. }
  6819. updatePayload.push(propKey, styleUpdates);
  6820. }
  6821. styleUpdates = nextProp;
  6822. }
  6823. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  6824. var nextHtml = nextProp ? nextProp[HTML] : undefined;
  6825. var lastHtml = lastProp ? lastProp[HTML] : undefined;
  6826. if (nextHtml != null) {
  6827. if (lastHtml !== nextHtml) {
  6828. (updatePayload = updatePayload || []).push(propKey, toStringOrTrustedType(nextHtml));
  6829. }
  6830. } else {// TODO: It might be too late to clear this if we have children
  6831. // inserted already.
  6832. }
  6833. } else if (propKey === CHILDREN) {
  6834. if (lastProp !== nextProp && (typeof nextProp === 'string' || typeof nextProp === 'number')) {
  6835. (updatePayload = updatePayload || []).push(propKey, '' + nextProp);
  6836. }
  6837. } else if (enableFlareAPI && propKey === LISTENERS || propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {// Noop
  6838. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  6839. if (nextProp != null) {
  6840. // We eagerly listen to this even though we haven't committed yet.
  6841. if (true && typeof nextProp !== 'function') {
  6842. warnForInvalidEventListener(propKey, nextProp);
  6843. }
  6844. ensureListeningTo(rootContainerElement, propKey);
  6845. }
  6846. if (!updatePayload && lastProp !== nextProp) {
  6847. // This is a special case. If any listener updates we need to ensure
  6848. // that the "current" props pointer gets updated so we need a commit
  6849. // to update this element.
  6850. updatePayload = [];
  6851. }
  6852. } else {
  6853. // For any other property we always add it to the queue and then we
  6854. // filter it out using the whitelist during the commit.
  6855. (updatePayload = updatePayload || []).push(propKey, nextProp);
  6856. }
  6857. }
  6858. if (styleUpdates) {
  6859. {
  6860. validateShorthandPropertyCollisionInDev(styleUpdates, nextProps[STYLE$1]);
  6861. }
  6862. (updatePayload = updatePayload || []).push(STYLE$1, styleUpdates);
  6863. }
  6864. return updatePayload;
  6865. } // Apply the diff.
  6866. function updateProperties(domElement, updatePayload, tag, lastRawProps, nextRawProps) {
  6867. // Update checked *before* name.
  6868. // In the middle of an update, it is possible to have multiple checked.
  6869. // When a checked radio tries to change name, browser makes another radio's checked false.
  6870. if (tag === 'input' && nextRawProps.type === 'radio' && nextRawProps.name != null) {
  6871. updateChecked(domElement, nextRawProps);
  6872. }
  6873. var wasCustomComponentTag = isCustomComponent(tag, lastRawProps);
  6874. var isCustomComponentTag = isCustomComponent(tag, nextRawProps); // Apply the diff.
  6875. updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag); // TODO: Ensure that an update gets scheduled if any of the special props
  6876. // changed.
  6877. switch (tag) {
  6878. case 'input':
  6879. // Update the wrapper around inputs *after* updating props. This has to
  6880. // happen after `updateDOMProperties`. Otherwise HTML5 input validations
  6881. // raise warnings and prevent the new value from being assigned.
  6882. updateWrapper(domElement, nextRawProps);
  6883. break;
  6884. case 'textarea':
  6885. updateWrapper$1(domElement, nextRawProps);
  6886. break;
  6887. case 'select':
  6888. // <select> value update needs to occur after <option> children
  6889. // reconciliation
  6890. postUpdateWrapper(domElement, nextRawProps);
  6891. break;
  6892. }
  6893. }
  6894. function getPossibleStandardName(propName) {
  6895. {
  6896. var lowerCasedName = propName.toLowerCase();
  6897. if (!possibleStandardNames.hasOwnProperty(lowerCasedName)) {
  6898. return null;
  6899. }
  6900. return possibleStandardNames[lowerCasedName] || null;
  6901. }
  6902. return null;
  6903. }
  6904. function diffHydratedProperties(domElement, tag, rawProps, parentNamespace, rootContainerElement) {
  6905. var isCustomComponentTag;
  6906. var extraAttributeNames;
  6907. {
  6908. suppressHydrationWarning = rawProps[SUPPRESS_HYDRATION_WARNING$1] === true;
  6909. isCustomComponentTag = isCustomComponent(tag, rawProps);
  6910. validatePropertiesInDevelopment(tag, rawProps);
  6911. if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) {
  6912. warning$1(false, '%s is using shady DOM. Using shady DOM with React can ' + 'cause things to break subtly.', getCurrentFiberOwnerNameInDevOrNull() || 'A component');
  6913. didWarnShadyDOM = true;
  6914. }
  6915. } // TODO: Make sure that we check isMounted before firing any of these events.
  6916. switch (tag) {
  6917. case 'iframe':
  6918. case 'object':
  6919. case 'embed':
  6920. trapBubbledEvent(TOP_LOAD, domElement);
  6921. break;
  6922. case 'video':
  6923. case 'audio':
  6924. // Create listener for each media event
  6925. for (var i = 0; i < mediaEventTypes.length; i++) {
  6926. trapBubbledEvent(mediaEventTypes[i], domElement);
  6927. }
  6928. break;
  6929. case 'source':
  6930. trapBubbledEvent(TOP_ERROR, domElement);
  6931. break;
  6932. case 'img':
  6933. case 'image':
  6934. case 'link':
  6935. trapBubbledEvent(TOP_ERROR, domElement);
  6936. trapBubbledEvent(TOP_LOAD, domElement);
  6937. break;
  6938. case 'form':
  6939. trapBubbledEvent(TOP_RESET, domElement);
  6940. trapBubbledEvent(TOP_SUBMIT, domElement);
  6941. break;
  6942. case 'details':
  6943. trapBubbledEvent(TOP_TOGGLE, domElement);
  6944. break;
  6945. case 'input':
  6946. initWrapperState(domElement, rawProps);
  6947. trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening
  6948. // to onChange. Even if there is no listener.
  6949. ensureListeningTo(rootContainerElement, 'onChange');
  6950. break;
  6951. case 'option':
  6952. validateProps(domElement, rawProps);
  6953. break;
  6954. case 'select':
  6955. initWrapperState$1(domElement, rawProps);
  6956. trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening
  6957. // to onChange. Even if there is no listener.
  6958. ensureListeningTo(rootContainerElement, 'onChange');
  6959. break;
  6960. case 'textarea':
  6961. initWrapperState$2(domElement, rawProps);
  6962. trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening
  6963. // to onChange. Even if there is no listener.
  6964. ensureListeningTo(rootContainerElement, 'onChange');
  6965. break;
  6966. }
  6967. assertValidProps(tag, rawProps);
  6968. {
  6969. extraAttributeNames = new Set();
  6970. var attributes = domElement.attributes;
  6971. for (var _i = 0; _i < attributes.length; _i++) {
  6972. var name = attributes[_i].name.toLowerCase();
  6973. switch (name) {
  6974. // Built-in SSR attribute is whitelisted
  6975. case 'data-reactroot':
  6976. break;
  6977. // Controlled attributes are not validated
  6978. // TODO: Only ignore them on controlled tags.
  6979. case 'value':
  6980. break;
  6981. case 'checked':
  6982. break;
  6983. case 'selected':
  6984. break;
  6985. default:
  6986. // Intentionally use the original name.
  6987. // See discussion in https://github.com/facebook/react/pull/10676.
  6988. extraAttributeNames.add(attributes[_i].name);
  6989. }
  6990. }
  6991. }
  6992. var updatePayload = null;
  6993. for (var propKey in rawProps) {
  6994. if (!rawProps.hasOwnProperty(propKey)) {
  6995. continue;
  6996. }
  6997. var nextProp = rawProps[propKey];
  6998. if (propKey === CHILDREN) {
  6999. // For text content children we compare against textContent. This
  7000. // might match additional HTML that is hidden when we read it using
  7001. // textContent. E.g. "foo" will match "f<span>oo</span>" but that still
  7002. // satisfies our requirement. Our requirement is not to produce perfect
  7003. // HTML and attributes. Ideally we should preserve structure but it's
  7004. // ok not to if the visible content is still enough to indicate what
  7005. // even listeners these nodes might be wired up to.
  7006. // TODO: Warn if there is more than a single textNode as a child.
  7007. // TODO: Should we use domElement.firstChild.nodeValue to compare?
  7008. if (typeof nextProp === 'string') {
  7009. if (domElement.textContent !== nextProp) {
  7010. if (true && !suppressHydrationWarning) {
  7011. warnForTextDifference(domElement.textContent, nextProp);
  7012. }
  7013. updatePayload = [CHILDREN, nextProp];
  7014. }
  7015. } else if (typeof nextProp === 'number') {
  7016. if (domElement.textContent !== '' + nextProp) {
  7017. if (true && !suppressHydrationWarning) {
  7018. warnForTextDifference(domElement.textContent, nextProp);
  7019. }
  7020. updatePayload = [CHILDREN, '' + nextProp];
  7021. }
  7022. }
  7023. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  7024. if (nextProp != null) {
  7025. if (true && typeof nextProp !== 'function') {
  7026. warnForInvalidEventListener(propKey, nextProp);
  7027. }
  7028. ensureListeningTo(rootContainerElement, propKey);
  7029. }
  7030. } else if (true && // Convince Flow we've calculated it (it's DEV-only in this method.)
  7031. typeof isCustomComponentTag === 'boolean') {
  7032. // Validate that the properties correspond to their expected values.
  7033. var serverValue = void 0;
  7034. var propertyInfo = getPropertyInfo(propKey);
  7035. if (suppressHydrationWarning) {// Don't bother comparing. We're ignoring all these warnings.
  7036. } else if (enableFlareAPI && propKey === LISTENERS || propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1 || // Controlled attributes are not validated
  7037. // TODO: Only ignore them on controlled tags.
  7038. propKey === 'value' || propKey === 'checked' || propKey === 'selected') {// Noop
  7039. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  7040. var serverHTML = domElement.innerHTML;
  7041. var nextHtml = nextProp ? nextProp[HTML] : undefined;
  7042. var expectedHTML = normalizeHTML(domElement, nextHtml != null ? nextHtml : '');
  7043. if (expectedHTML !== serverHTML) {
  7044. warnForPropDifference(propKey, serverHTML, expectedHTML);
  7045. }
  7046. } else if (propKey === STYLE$1) {
  7047. // $FlowFixMe - Should be inferred as not undefined.
  7048. extraAttributeNames.delete(propKey);
  7049. if (canDiffStyleForHydrationWarning) {
  7050. var expectedStyle = createDangerousStringForStyles(nextProp);
  7051. serverValue = domElement.getAttribute('style');
  7052. if (expectedStyle !== serverValue) {
  7053. warnForPropDifference(propKey, serverValue, expectedStyle);
  7054. }
  7055. }
  7056. } else if (isCustomComponentTag) {
  7057. // $FlowFixMe - Should be inferred as not undefined.
  7058. extraAttributeNames.delete(propKey.toLowerCase());
  7059. serverValue = getValueForAttribute(domElement, propKey, nextProp);
  7060. if (nextProp !== serverValue) {
  7061. warnForPropDifference(propKey, serverValue, nextProp);
  7062. }
  7063. } else if (!shouldIgnoreAttribute(propKey, propertyInfo, isCustomComponentTag) && !shouldRemoveAttribute(propKey, nextProp, propertyInfo, isCustomComponentTag)) {
  7064. var isMismatchDueToBadCasing = false;
  7065. if (propertyInfo !== null) {
  7066. // $FlowFixMe - Should be inferred as not undefined.
  7067. extraAttributeNames.delete(propertyInfo.attributeName);
  7068. serverValue = getValueForProperty(domElement, propKey, nextProp, propertyInfo);
  7069. } else {
  7070. var ownNamespace = parentNamespace;
  7071. if (ownNamespace === HTML_NAMESPACE) {
  7072. ownNamespace = getIntrinsicNamespace(tag);
  7073. }
  7074. if (ownNamespace === HTML_NAMESPACE) {
  7075. // $FlowFixMe - Should be inferred as not undefined.
  7076. extraAttributeNames.delete(propKey.toLowerCase());
  7077. } else {
  7078. var standardName = getPossibleStandardName(propKey);
  7079. if (standardName !== null && standardName !== propKey) {
  7080. // If an SVG prop is supplied with bad casing, it will
  7081. // be successfully parsed from HTML, but will produce a mismatch
  7082. // (and would be incorrectly rendered on the client).
  7083. // However, we already warn about bad casing elsewhere.
  7084. // So we'll skip the misleading extra mismatch warning in this case.
  7085. isMismatchDueToBadCasing = true; // $FlowFixMe - Should be inferred as not undefined.
  7086. extraAttributeNames.delete(standardName);
  7087. } // $FlowFixMe - Should be inferred as not undefined.
  7088. extraAttributeNames.delete(propKey);
  7089. }
  7090. serverValue = getValueForAttribute(domElement, propKey, nextProp);
  7091. }
  7092. if (nextProp !== serverValue && !isMismatchDueToBadCasing) {
  7093. warnForPropDifference(propKey, serverValue, nextProp);
  7094. }
  7095. }
  7096. }
  7097. }
  7098. {
  7099. // $FlowFixMe - Should be inferred as not undefined.
  7100. if (extraAttributeNames.size > 0 && !suppressHydrationWarning) {
  7101. // $FlowFixMe - Should be inferred as not undefined.
  7102. warnForExtraAttributes(extraAttributeNames);
  7103. }
  7104. }
  7105. switch (tag) {
  7106. case 'input':
  7107. // TODO: Make sure we check if this is still unmounted or do any clean
  7108. // up necessary since we never stop tracking anymore.
  7109. track(domElement);
  7110. postMountWrapper(domElement, rawProps, true);
  7111. break;
  7112. case 'textarea':
  7113. // TODO: Make sure we check if this is still unmounted or do any clean
  7114. // up necessary since we never stop tracking anymore.
  7115. track(domElement);
  7116. postMountWrapper$3(domElement, rawProps);
  7117. break;
  7118. case 'select':
  7119. case 'option':
  7120. // For input and textarea we current always set the value property at
  7121. // post mount to force it to diverge from attributes. However, for
  7122. // option and select we don't quite do the same thing and select
  7123. // is not resilient to the DOM state changing so we don't do that here.
  7124. // TODO: Consider not doing this for input and textarea.
  7125. break;
  7126. default:
  7127. if (typeof rawProps.onClick === 'function') {
  7128. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  7129. trapClickOnNonInteractiveElement(domElement);
  7130. }
  7131. break;
  7132. }
  7133. return updatePayload;
  7134. }
  7135. function diffHydratedText(textNode, text) {
  7136. var isDifferent = textNode.nodeValue !== text;
  7137. return isDifferent;
  7138. }
  7139. function warnForUnmatchedText(textNode, text) {
  7140. {
  7141. warnForTextDifference(textNode.nodeValue, text);
  7142. }
  7143. }
  7144. function warnForDeletedHydratableElement(parentNode, child) {
  7145. {
  7146. if (didWarnInvalidHydration) {
  7147. return;
  7148. }
  7149. didWarnInvalidHydration = true;
  7150. warningWithoutStack$1(false, 'Did not expect server HTML to contain a <%s> in <%s>.', child.nodeName.toLowerCase(), parentNode.nodeName.toLowerCase());
  7151. }
  7152. }
  7153. function warnForDeletedHydratableText(parentNode, child) {
  7154. {
  7155. if (didWarnInvalidHydration) {
  7156. return;
  7157. }
  7158. didWarnInvalidHydration = true;
  7159. warningWithoutStack$1(false, 'Did not expect server HTML to contain the text node "%s" in <%s>.', child.nodeValue, parentNode.nodeName.toLowerCase());
  7160. }
  7161. }
  7162. function warnForInsertedHydratedElement(parentNode, tag, props) {
  7163. {
  7164. if (didWarnInvalidHydration) {
  7165. return;
  7166. }
  7167. didWarnInvalidHydration = true;
  7168. warningWithoutStack$1(false, 'Expected server HTML to contain a matching <%s> in <%s>.', tag, parentNode.nodeName.toLowerCase());
  7169. }
  7170. }
  7171. function warnForInsertedHydratedText(parentNode, text) {
  7172. {
  7173. if (text === '') {
  7174. // We expect to insert empty text nodes since they're not represented in
  7175. // the HTML.
  7176. // TODO: Remove this special case if we can just avoid inserting empty
  7177. // text nodes.
  7178. return;
  7179. }
  7180. if (didWarnInvalidHydration) {
  7181. return;
  7182. }
  7183. didWarnInvalidHydration = true;
  7184. warningWithoutStack$1(false, 'Expected server HTML to contain a matching text node for "%s" in <%s>.', text, parentNode.nodeName.toLowerCase());
  7185. }
  7186. }
  7187. function restoreControlledState$$1(domElement, tag, props) {
  7188. switch (tag) {
  7189. case 'input':
  7190. restoreControlledState$1(domElement, props);
  7191. return;
  7192. case 'textarea':
  7193. restoreControlledState$3(domElement, props);
  7194. return;
  7195. case 'select':
  7196. restoreControlledState$2(domElement, props);
  7197. return;
  7198. }
  7199. }
  7200. function listenToEventResponderEventTypes(eventTypes, element) {
  7201. if (enableFlareAPI) {
  7202. // Get the listening Set for this element. We use this to track
  7203. // what events we're listening to.
  7204. var listeningSet = getListeningSetForElement(element); // Go through each target event type of the event responder
  7205. for (var i = 0, length = eventTypes.length; i < length; ++i) {
  7206. var eventType = eventTypes[i];
  7207. var isPassive = !endsWith(eventType, '_active');
  7208. var eventKey = isPassive ? eventType + '_passive' : eventType;
  7209. var targetEventType = isPassive ? eventType : eventType.substring(0, eventType.length - 7);
  7210. if (!listeningSet.has(eventKey)) {
  7211. trapEventForResponderEventSystem(element, targetEventType, isPassive);
  7212. listeningSet.add(eventKey);
  7213. }
  7214. }
  7215. }
  7216. } // We can remove this once the event API is stable and out of a flag
  7217. if (enableFlareAPI) {
  7218. setListenToResponderEventTypes(listenToEventResponderEventTypes);
  7219. }
  7220. function getActiveElement(doc) {
  7221. doc = doc || (typeof document !== 'undefined' ? document : undefined);
  7222. if (typeof doc === 'undefined') {
  7223. return null;
  7224. }
  7225. try {
  7226. return doc.activeElement || doc.body;
  7227. } catch (e) {
  7228. return doc.body;
  7229. }
  7230. }
  7231. /**
  7232. * Given any node return the first leaf node without children.
  7233. *
  7234. * @param {DOMElement|DOMTextNode} node
  7235. * @return {DOMElement|DOMTextNode}
  7236. */
  7237. function getLeafNode(node) {
  7238. while (node && node.firstChild) {
  7239. node = node.firstChild;
  7240. }
  7241. return node;
  7242. }
  7243. /**
  7244. * Get the next sibling within a container. This will walk up the
  7245. * DOM if a node's siblings have been exhausted.
  7246. *
  7247. * @param {DOMElement|DOMTextNode} node
  7248. * @return {?DOMElement|DOMTextNode}
  7249. */
  7250. function getSiblingNode(node) {
  7251. while (node) {
  7252. if (node.nextSibling) {
  7253. return node.nextSibling;
  7254. }
  7255. node = node.parentNode;
  7256. }
  7257. }
  7258. /**
  7259. * Get object describing the nodes which contain characters at offset.
  7260. *
  7261. * @param {DOMElement|DOMTextNode} root
  7262. * @param {number} offset
  7263. * @return {?object}
  7264. */
  7265. function getNodeForCharacterOffset(root, offset) {
  7266. var node = getLeafNode(root);
  7267. var nodeStart = 0;
  7268. var nodeEnd = 0;
  7269. while (node) {
  7270. if (node.nodeType === TEXT_NODE) {
  7271. nodeEnd = nodeStart + node.textContent.length;
  7272. if (nodeStart <= offset && nodeEnd >= offset) {
  7273. return {
  7274. node: node,
  7275. offset: offset - nodeStart
  7276. };
  7277. }
  7278. nodeStart = nodeEnd;
  7279. }
  7280. node = getLeafNode(getSiblingNode(node));
  7281. }
  7282. }
  7283. /**
  7284. * @param {DOMElement} outerNode
  7285. * @return {?object}
  7286. */
  7287. function getOffsets(outerNode) {
  7288. var ownerDocument = outerNode.ownerDocument;
  7289. var win = ownerDocument && ownerDocument.defaultView || window;
  7290. var selection = win.getSelection && win.getSelection();
  7291. if (!selection || selection.rangeCount === 0) {
  7292. return null;
  7293. }
  7294. var anchorNode = selection.anchorNode,
  7295. anchorOffset = selection.anchorOffset,
  7296. focusNode = selection.focusNode,
  7297. focusOffset = selection.focusOffset; // In Firefox, anchorNode and focusNode can be "anonymous divs", e.g. the
  7298. // up/down buttons on an <input type="number">. Anonymous divs do not seem to
  7299. // expose properties, triggering a "Permission denied error" if any of its
  7300. // properties are accessed. The only seemingly possible way to avoid erroring
  7301. // is to access a property that typically works for non-anonymous divs and
  7302. // catch any error that may otherwise arise. See
  7303. // https://bugzilla.mozilla.org/show_bug.cgi?id=208427
  7304. try {
  7305. /* eslint-disable no-unused-expressions */
  7306. anchorNode.nodeType;
  7307. focusNode.nodeType;
  7308. /* eslint-enable no-unused-expressions */
  7309. } catch (e) {
  7310. return null;
  7311. }
  7312. return getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset);
  7313. }
  7314. /**
  7315. * Returns {start, end} where `start` is the character/codepoint index of
  7316. * (anchorNode, anchorOffset) within the textContent of `outerNode`, and
  7317. * `end` is the index of (focusNode, focusOffset).
  7318. *
  7319. * Returns null if you pass in garbage input but we should probably just crash.
  7320. *
  7321. * Exported only for testing.
  7322. */
  7323. function getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset) {
  7324. var length = 0;
  7325. var start = -1;
  7326. var end = -1;
  7327. var indexWithinAnchor = 0;
  7328. var indexWithinFocus = 0;
  7329. var node = outerNode;
  7330. var parentNode = null;
  7331. outer: while (true) {
  7332. var next = null;
  7333. while (true) {
  7334. if (node === anchorNode && (anchorOffset === 0 || node.nodeType === TEXT_NODE)) {
  7335. start = length + anchorOffset;
  7336. }
  7337. if (node === focusNode && (focusOffset === 0 || node.nodeType === TEXT_NODE)) {
  7338. end = length + focusOffset;
  7339. }
  7340. if (node.nodeType === TEXT_NODE) {
  7341. length += node.nodeValue.length;
  7342. }
  7343. if ((next = node.firstChild) === null) {
  7344. break;
  7345. } // Moving from `node` to its first child `next`.
  7346. parentNode = node;
  7347. node = next;
  7348. }
  7349. while (true) {
  7350. if (node === outerNode) {
  7351. // If `outerNode` has children, this is always the second time visiting
  7352. // it. If it has no children, this is still the first loop, and the only
  7353. // valid selection is anchorNode and focusNode both equal to this node
  7354. // and both offsets 0, in which case we will have handled above.
  7355. break outer;
  7356. }
  7357. if (parentNode === anchorNode && ++indexWithinAnchor === anchorOffset) {
  7358. start = length;
  7359. }
  7360. if (parentNode === focusNode && ++indexWithinFocus === focusOffset) {
  7361. end = length;
  7362. }
  7363. if ((next = node.nextSibling) !== null) {
  7364. break;
  7365. }
  7366. node = parentNode;
  7367. parentNode = node.parentNode;
  7368. } // Moving from `node` to its next sibling `next`.
  7369. node = next;
  7370. }
  7371. if (start === -1 || end === -1) {
  7372. // This should never happen. (Would happen if the anchor/focus nodes aren't
  7373. // actually inside the passed-in node.)
  7374. return null;
  7375. }
  7376. return {
  7377. start: start,
  7378. end: end
  7379. };
  7380. }
  7381. /**
  7382. * In modern non-IE browsers, we can support both forward and backward
  7383. * selections.
  7384. *
  7385. * Note: IE10+ supports the Selection object, but it does not support
  7386. * the `extend` method, which means that even in modern IE, it's not possible
  7387. * to programmatically create a backward selection. Thus, for all IE
  7388. * versions, we use the old IE API to create our selections.
  7389. *
  7390. * @param {DOMElement|DOMTextNode} node
  7391. * @param {object} offsets
  7392. */
  7393. function setOffsets(node, offsets) {
  7394. var doc = node.ownerDocument || document;
  7395. var win = doc && doc.defaultView || window; // Edge fails with "Object expected" in some scenarios.
  7396. // (For instance: TinyMCE editor used in a list component that supports pasting to add more,
  7397. // fails when pasting 100+ items)
  7398. if (!win.getSelection) {
  7399. return;
  7400. }
  7401. var selection = win.getSelection();
  7402. var length = node.textContent.length;
  7403. var start = Math.min(offsets.start, length);
  7404. var end = offsets.end === undefined ? start : Math.min(offsets.end, length); // IE 11 uses modern selection, but doesn't support the extend method.
  7405. // Flip backward selections, so we can set with a single range.
  7406. if (!selection.extend && start > end) {
  7407. var temp = end;
  7408. end = start;
  7409. start = temp;
  7410. }
  7411. var startMarker = getNodeForCharacterOffset(node, start);
  7412. var endMarker = getNodeForCharacterOffset(node, end);
  7413. if (startMarker && endMarker) {
  7414. if (selection.rangeCount === 1 && selection.anchorNode === startMarker.node && selection.anchorOffset === startMarker.offset && selection.focusNode === endMarker.node && selection.focusOffset === endMarker.offset) {
  7415. return;
  7416. }
  7417. var range = doc.createRange();
  7418. range.setStart(startMarker.node, startMarker.offset);
  7419. selection.removeAllRanges();
  7420. if (start > end) {
  7421. selection.addRange(range);
  7422. selection.extend(endMarker.node, endMarker.offset);
  7423. } else {
  7424. range.setEnd(endMarker.node, endMarker.offset);
  7425. selection.addRange(range);
  7426. }
  7427. }
  7428. }
  7429. function isTextNode(node) {
  7430. return node && node.nodeType === TEXT_NODE;
  7431. }
  7432. function containsNode(outerNode, innerNode) {
  7433. if (!outerNode || !innerNode) {
  7434. return false;
  7435. } else if (outerNode === innerNode) {
  7436. return true;
  7437. } else if (isTextNode(outerNode)) {
  7438. return false;
  7439. } else if (isTextNode(innerNode)) {
  7440. return containsNode(outerNode, innerNode.parentNode);
  7441. } else if ('contains' in outerNode) {
  7442. return outerNode.contains(innerNode);
  7443. } else if (outerNode.compareDocumentPosition) {
  7444. return !!(outerNode.compareDocumentPosition(innerNode) & 16);
  7445. } else {
  7446. return false;
  7447. }
  7448. }
  7449. function isInDocument(node) {
  7450. return node && node.ownerDocument && containsNode(node.ownerDocument.documentElement, node);
  7451. }
  7452. function isSameOriginFrame(iframe) {
  7453. try {
  7454. // Accessing the contentDocument of a HTMLIframeElement can cause the browser
  7455. // to throw, e.g. if it has a cross-origin src attribute.
  7456. // Safari will show an error in the console when the access results in "Blocked a frame with origin". e.g:
  7457. // iframe.contentDocument.defaultView;
  7458. // A safety way is to access one of the cross origin properties: Window or Location
  7459. // Which might result in "SecurityError" DOM Exception and it is compatible to Safari.
  7460. // https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl
  7461. return typeof iframe.contentWindow.location.href === 'string';
  7462. } catch (err) {
  7463. return false;
  7464. }
  7465. }
  7466. function getActiveElementDeep() {
  7467. var win = window;
  7468. var element = getActiveElement();
  7469. while (element instanceof win.HTMLIFrameElement) {
  7470. if (isSameOriginFrame(element)) {
  7471. win = element.contentWindow;
  7472. } else {
  7473. return element;
  7474. }
  7475. element = getActiveElement(win.document);
  7476. }
  7477. return element;
  7478. }
  7479. /**
  7480. * @ReactInputSelection: React input selection module. Based on Selection.js,
  7481. * but modified to be suitable for react and has a couple of bug fixes (doesn't
  7482. * assume buttons have range selections allowed).
  7483. * Input selection module for React.
  7484. */
  7485. /**
  7486. * @hasSelectionCapabilities: we get the element types that support selection
  7487. * from https://html.spec.whatwg.org/#do-not-apply, looking at `selectionStart`
  7488. * and `selectionEnd` rows.
  7489. */
  7490. function hasSelectionCapabilities(elem) {
  7491. var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
  7492. return nodeName && (nodeName === 'input' && (elem.type === 'text' || elem.type === 'search' || elem.type === 'tel' || elem.type === 'url' || elem.type === 'password') || nodeName === 'textarea' || elem.contentEditable === 'true');
  7493. }
  7494. function getSelectionInformation() {
  7495. var focusedElem = getActiveElementDeep();
  7496. return {
  7497. focusedElem: focusedElem,
  7498. selectionRange: hasSelectionCapabilities(focusedElem) ? getSelection(focusedElem) : null
  7499. };
  7500. }
  7501. /**
  7502. * @restoreSelection: If any selection information was potentially lost,
  7503. * restore it. This is useful when performing operations that could remove dom
  7504. * nodes and place them back in, resulting in focus being lost.
  7505. */
  7506. function restoreSelection(priorSelectionInformation) {
  7507. var curFocusedElem = getActiveElementDeep();
  7508. var priorFocusedElem = priorSelectionInformation.focusedElem;
  7509. var priorSelectionRange = priorSelectionInformation.selectionRange;
  7510. if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) {
  7511. if (priorSelectionRange !== null && hasSelectionCapabilities(priorFocusedElem)) {
  7512. setSelection(priorFocusedElem, priorSelectionRange);
  7513. } // Focusing a node can change the scroll position, which is undesirable
  7514. var ancestors = [];
  7515. var ancestor = priorFocusedElem;
  7516. while (ancestor = ancestor.parentNode) {
  7517. if (ancestor.nodeType === ELEMENT_NODE) {
  7518. ancestors.push({
  7519. element: ancestor,
  7520. left: ancestor.scrollLeft,
  7521. top: ancestor.scrollTop
  7522. });
  7523. }
  7524. }
  7525. if (typeof priorFocusedElem.focus === 'function') {
  7526. priorFocusedElem.focus();
  7527. }
  7528. for (var i = 0; i < ancestors.length; i++) {
  7529. var info = ancestors[i];
  7530. info.element.scrollLeft = info.left;
  7531. info.element.scrollTop = info.top;
  7532. }
  7533. }
  7534. }
  7535. /**
  7536. * @getSelection: Gets the selection bounds of a focused textarea, input or
  7537. * contentEditable node.
  7538. * -@input: Look up selection bounds of this input
  7539. * -@return {start: selectionStart, end: selectionEnd}
  7540. */
  7541. function getSelection(input) {
  7542. var selection;
  7543. if ('selectionStart' in input) {
  7544. // Modern browser with input or textarea.
  7545. selection = {
  7546. start: input.selectionStart,
  7547. end: input.selectionEnd
  7548. };
  7549. } else {
  7550. // Content editable or old IE textarea.
  7551. selection = getOffsets(input);
  7552. }
  7553. return selection || {
  7554. start: 0,
  7555. end: 0
  7556. };
  7557. }
  7558. /**
  7559. * @setSelection: Sets the selection bounds of a textarea or input and focuses
  7560. * the input.
  7561. * -@input Set selection bounds of this input or textarea
  7562. * -@offsets Object of same form that is returned from get*
  7563. */
  7564. function setSelection(input, offsets) {
  7565. var start = offsets.start,
  7566. end = offsets.end;
  7567. if (end === undefined) {
  7568. end = start;
  7569. }
  7570. if ('selectionStart' in input) {
  7571. input.selectionStart = start;
  7572. input.selectionEnd = Math.min(end, input.value.length);
  7573. } else {
  7574. setOffsets(input, offsets);
  7575. }
  7576. }
  7577. var validateDOMNesting = function () {};
  7578. var updatedAncestorInfo = function () {};
  7579. {
  7580. // This validation code was written based on the HTML5 parsing spec:
  7581. // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope
  7582. //
  7583. // Note: this does not catch all invalid nesting, nor does it try to (as it's
  7584. // not clear what practical benefit doing so provides); instead, we warn only
  7585. // for cases where the parser will give a parse tree differing from what React
  7586. // intended. For example, <b><div></div></b> is invalid but we don't warn
  7587. // because it still parses correctly; we do warn for other cases like nested
  7588. // <p> tags where the beginning of the second element implicitly closes the
  7589. // first, causing a confusing mess.
  7590. // https://html.spec.whatwg.org/multipage/syntax.html#special
  7591. var specialTags = ['address', 'applet', 'area', 'article', 'aside', 'base', 'basefont', 'bgsound', 'blockquote', 'body', 'br', 'button', 'caption', 'center', 'col', 'colgroup', 'dd', 'details', 'dir', 'div', 'dl', 'dt', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'iframe', 'img', 'input', 'isindex', 'li', 'link', 'listing', 'main', 'marquee', 'menu', 'menuitem', 'meta', 'nav', 'noembed', 'noframes', 'noscript', 'object', 'ol', 'p', 'param', 'plaintext', 'pre', 'script', 'section', 'select', 'source', 'style', 'summary', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'track', 'ul', 'wbr', 'xmp']; // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope
  7592. var inScopeTags = ['applet', 'caption', 'html', 'table', 'td', 'th', 'marquee', 'object', 'template', // https://html.spec.whatwg.org/multipage/syntax.html#html-integration-point
  7593. // TODO: Distinguish by namespace here -- for <title>, including it here
  7594. // errs on the side of fewer warnings
  7595. 'foreignObject', 'desc', 'title']; // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-button-scope
  7596. var buttonScopeTags = inScopeTags.concat(['button']); // https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags
  7597. var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt'];
  7598. var emptyAncestorInfo = {
  7599. current: null,
  7600. formTag: null,
  7601. aTagInScope: null,
  7602. buttonTagInScope: null,
  7603. nobrTagInScope: null,
  7604. pTagInButtonScope: null,
  7605. listItemTagAutoclosing: null,
  7606. dlItemTagAutoclosing: null
  7607. };
  7608. updatedAncestorInfo = function (oldInfo, tag) {
  7609. var ancestorInfo = _assign({}, oldInfo || emptyAncestorInfo);
  7610. var info = {
  7611. tag: tag
  7612. };
  7613. if (inScopeTags.indexOf(tag) !== -1) {
  7614. ancestorInfo.aTagInScope = null;
  7615. ancestorInfo.buttonTagInScope = null;
  7616. ancestorInfo.nobrTagInScope = null;
  7617. }
  7618. if (buttonScopeTags.indexOf(tag) !== -1) {
  7619. ancestorInfo.pTagInButtonScope = null;
  7620. } // See rules for 'li', 'dd', 'dt' start tags in
  7621. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
  7622. if (specialTags.indexOf(tag) !== -1 && tag !== 'address' && tag !== 'div' && tag !== 'p') {
  7623. ancestorInfo.listItemTagAutoclosing = null;
  7624. ancestorInfo.dlItemTagAutoclosing = null;
  7625. }
  7626. ancestorInfo.current = info;
  7627. if (tag === 'form') {
  7628. ancestorInfo.formTag = info;
  7629. }
  7630. if (tag === 'a') {
  7631. ancestorInfo.aTagInScope = info;
  7632. }
  7633. if (tag === 'button') {
  7634. ancestorInfo.buttonTagInScope = info;
  7635. }
  7636. if (tag === 'nobr') {
  7637. ancestorInfo.nobrTagInScope = info;
  7638. }
  7639. if (tag === 'p') {
  7640. ancestorInfo.pTagInButtonScope = info;
  7641. }
  7642. if (tag === 'li') {
  7643. ancestorInfo.listItemTagAutoclosing = info;
  7644. }
  7645. if (tag === 'dd' || tag === 'dt') {
  7646. ancestorInfo.dlItemTagAutoclosing = info;
  7647. }
  7648. return ancestorInfo;
  7649. };
  7650. /**
  7651. * Returns whether
  7652. */
  7653. var isTagValidWithParent = function (tag, parentTag) {
  7654. // First, let's check if we're in an unusual parsing mode...
  7655. switch (parentTag) {
  7656. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect
  7657. case 'select':
  7658. return tag === 'option' || tag === 'optgroup' || tag === '#text';
  7659. case 'optgroup':
  7660. return tag === 'option' || tag === '#text';
  7661. // Strictly speaking, seeing an <option> doesn't mean we're in a <select>
  7662. // but
  7663. case 'option':
  7664. return tag === '#text';
  7665. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd
  7666. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption
  7667. // No special behavior since these rules fall back to "in body" mode for
  7668. // all except special table nodes which cause bad parsing behavior anyway.
  7669. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr
  7670. case 'tr':
  7671. return tag === 'th' || tag === 'td' || tag === 'style' || tag === 'script' || tag === 'template';
  7672. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody
  7673. case 'tbody':
  7674. case 'thead':
  7675. case 'tfoot':
  7676. return tag === 'tr' || tag === 'style' || tag === 'script' || tag === 'template';
  7677. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup
  7678. case 'colgroup':
  7679. return tag === 'col' || tag === 'template';
  7680. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable
  7681. case 'table':
  7682. return tag === 'caption' || tag === 'colgroup' || tag === 'tbody' || tag === 'tfoot' || tag === 'thead' || tag === 'style' || tag === 'script' || tag === 'template';
  7683. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead
  7684. case 'head':
  7685. return tag === 'base' || tag === 'basefont' || tag === 'bgsound' || tag === 'link' || tag === 'meta' || tag === 'title' || tag === 'noscript' || tag === 'noframes' || tag === 'style' || tag === 'script' || tag === 'template';
  7686. // https://html.spec.whatwg.org/multipage/semantics.html#the-html-element
  7687. case 'html':
  7688. return tag === 'head' || tag === 'body' || tag === 'frameset';
  7689. case 'frameset':
  7690. return tag === 'frame';
  7691. case '#document':
  7692. return tag === 'html';
  7693. } // Probably in the "in body" parsing mode, so we outlaw only tag combos
  7694. // where the parsing rules cause implicit opens or closes to be added.
  7695. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
  7696. switch (tag) {
  7697. case 'h1':
  7698. case 'h2':
  7699. case 'h3':
  7700. case 'h4':
  7701. case 'h5':
  7702. case 'h6':
  7703. return parentTag !== 'h1' && parentTag !== 'h2' && parentTag !== 'h3' && parentTag !== 'h4' && parentTag !== 'h5' && parentTag !== 'h6';
  7704. case 'rp':
  7705. case 'rt':
  7706. return impliedEndTags.indexOf(parentTag) === -1;
  7707. case 'body':
  7708. case 'caption':
  7709. case 'col':
  7710. case 'colgroup':
  7711. case 'frameset':
  7712. case 'frame':
  7713. case 'head':
  7714. case 'html':
  7715. case 'tbody':
  7716. case 'td':
  7717. case 'tfoot':
  7718. case 'th':
  7719. case 'thead':
  7720. case 'tr':
  7721. // These tags are only valid with a few parents that have special child
  7722. // parsing rules -- if we're down here, then none of those matched and
  7723. // so we allow it only if we don't know what the parent is, as all other
  7724. // cases are invalid.
  7725. return parentTag == null;
  7726. }
  7727. return true;
  7728. };
  7729. /**
  7730. * Returns whether
  7731. */
  7732. var findInvalidAncestorForTag = function (tag, ancestorInfo) {
  7733. switch (tag) {
  7734. case 'address':
  7735. case 'article':
  7736. case 'aside':
  7737. case 'blockquote':
  7738. case 'center':
  7739. case 'details':
  7740. case 'dialog':
  7741. case 'dir':
  7742. case 'div':
  7743. case 'dl':
  7744. case 'fieldset':
  7745. case 'figcaption':
  7746. case 'figure':
  7747. case 'footer':
  7748. case 'header':
  7749. case 'hgroup':
  7750. case 'main':
  7751. case 'menu':
  7752. case 'nav':
  7753. case 'ol':
  7754. case 'p':
  7755. case 'section':
  7756. case 'summary':
  7757. case 'ul':
  7758. case 'pre':
  7759. case 'listing':
  7760. case 'table':
  7761. case 'hr':
  7762. case 'xmp':
  7763. case 'h1':
  7764. case 'h2':
  7765. case 'h3':
  7766. case 'h4':
  7767. case 'h5':
  7768. case 'h6':
  7769. return ancestorInfo.pTagInButtonScope;
  7770. case 'form':
  7771. return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope;
  7772. case 'li':
  7773. return ancestorInfo.listItemTagAutoclosing;
  7774. case 'dd':
  7775. case 'dt':
  7776. return ancestorInfo.dlItemTagAutoclosing;
  7777. case 'button':
  7778. return ancestorInfo.buttonTagInScope;
  7779. case 'a':
  7780. // Spec says something about storing a list of markers, but it sounds
  7781. // equivalent to this check.
  7782. return ancestorInfo.aTagInScope;
  7783. case 'nobr':
  7784. return ancestorInfo.nobrTagInScope;
  7785. }
  7786. return null;
  7787. };
  7788. var didWarn$1 = {};
  7789. validateDOMNesting = function (childTag, childText, ancestorInfo) {
  7790. ancestorInfo = ancestorInfo || emptyAncestorInfo;
  7791. var parentInfo = ancestorInfo.current;
  7792. var parentTag = parentInfo && parentInfo.tag;
  7793. if (childText != null) {
  7794. !(childTag == null) ? warningWithoutStack$1(false, 'validateDOMNesting: when childText is passed, childTag should be null') : void 0;
  7795. childTag = '#text';
  7796. }
  7797. var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo;
  7798. var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo);
  7799. var invalidParentOrAncestor = invalidParent || invalidAncestor;
  7800. if (!invalidParentOrAncestor) {
  7801. return;
  7802. }
  7803. var ancestorTag = invalidParentOrAncestor.tag;
  7804. var addendum = getCurrentFiberStackInDev();
  7805. var warnKey = !!invalidParent + '|' + childTag + '|' + ancestorTag + '|' + addendum;
  7806. if (didWarn$1[warnKey]) {
  7807. return;
  7808. }
  7809. didWarn$1[warnKey] = true;
  7810. var tagDisplayName = childTag;
  7811. var whitespaceInfo = '';
  7812. if (childTag === '#text') {
  7813. if (/\S/.test(childText)) {
  7814. tagDisplayName = 'Text nodes';
  7815. } else {
  7816. tagDisplayName = 'Whitespace text nodes';
  7817. whitespaceInfo = " Make sure you don't have any extra whitespace between tags on " + 'each line of your source code.';
  7818. }
  7819. } else {
  7820. tagDisplayName = '<' + childTag + '>';
  7821. }
  7822. if (invalidParent) {
  7823. var info = '';
  7824. if (ancestorTag === 'table' && childTag === 'tr') {
  7825. info += ' Add a <tbody>, <thead> or <tfoot> to your code to match the DOM tree generated by ' + 'the browser.';
  7826. }
  7827. warningWithoutStack$1(false, 'validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s%s', tagDisplayName, ancestorTag, whitespaceInfo, info, addendum);
  7828. } else {
  7829. warningWithoutStack$1(false, 'validateDOMNesting(...): %s cannot appear as a descendant of ' + '<%s>.%s', tagDisplayName, ancestorTag, addendum);
  7830. }
  7831. };
  7832. }
  7833. // can re-export everything from this module.
  7834. function shim() {
  7835. {
  7836. {
  7837. throw Error("The current renderer does not support persistence. This error is likely caused by a bug in React. Please file an issue.");
  7838. }
  7839. }
  7840. } // Persistence (when unsupported)
  7841. var supportsPersistence = false;
  7842. var cloneInstance = shim;
  7843. var cloneFundamentalInstance = shim;
  7844. var createContainerChildSet = shim;
  7845. var appendChildToContainerChildSet = shim;
  7846. var finalizeContainerChildren = shim;
  7847. var replaceContainerChildren = shim;
  7848. var cloneHiddenInstance = shim;
  7849. var cloneHiddenTextInstance = shim;
  7850. var SUPPRESS_HYDRATION_WARNING;
  7851. {
  7852. SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning';
  7853. }
  7854. var SUSPENSE_START_DATA = '$';
  7855. var SUSPENSE_END_DATA = '/$';
  7856. var SUSPENSE_PENDING_START_DATA = '$?';
  7857. var SUSPENSE_FALLBACK_START_DATA = '$!';
  7858. var STYLE = 'style';
  7859. var eventsEnabled = null;
  7860. var selectionInformation = null;
  7861. function shouldAutoFocusHostComponent(type, props) {
  7862. switch (type) {
  7863. case 'button':
  7864. case 'input':
  7865. case 'select':
  7866. case 'textarea':
  7867. return !!props.autoFocus;
  7868. }
  7869. return false;
  7870. }
  7871. function getRootHostContext(rootContainerInstance) {
  7872. var type;
  7873. var namespace;
  7874. var nodeType = rootContainerInstance.nodeType;
  7875. switch (nodeType) {
  7876. case DOCUMENT_NODE:
  7877. case DOCUMENT_FRAGMENT_NODE:
  7878. {
  7879. type = nodeType === DOCUMENT_NODE ? '#document' : '#fragment';
  7880. var root = rootContainerInstance.documentElement;
  7881. namespace = root ? root.namespaceURI : getChildNamespace(null, '');
  7882. break;
  7883. }
  7884. default:
  7885. {
  7886. var container = nodeType === COMMENT_NODE ? rootContainerInstance.parentNode : rootContainerInstance;
  7887. var ownNamespace = container.namespaceURI || null;
  7888. type = container.tagName;
  7889. namespace = getChildNamespace(ownNamespace, type);
  7890. break;
  7891. }
  7892. }
  7893. {
  7894. var validatedTag = type.toLowerCase();
  7895. var ancestorInfo = updatedAncestorInfo(null, validatedTag);
  7896. return {
  7897. namespace: namespace,
  7898. ancestorInfo: ancestorInfo
  7899. };
  7900. }
  7901. return namespace;
  7902. }
  7903. function getChildHostContext(parentHostContext, type, rootContainerInstance) {
  7904. {
  7905. var parentHostContextDev = parentHostContext;
  7906. var namespace = getChildNamespace(parentHostContextDev.namespace, type);
  7907. var ancestorInfo = updatedAncestorInfo(parentHostContextDev.ancestorInfo, type);
  7908. return {
  7909. namespace: namespace,
  7910. ancestorInfo: ancestorInfo
  7911. };
  7912. }
  7913. var parentNamespace = parentHostContext;
  7914. return getChildNamespace(parentNamespace, type);
  7915. }
  7916. function getPublicInstance(instance) {
  7917. return instance;
  7918. }
  7919. function prepareForCommit(containerInfo) {
  7920. eventsEnabled = isEnabled();
  7921. selectionInformation = getSelectionInformation();
  7922. setEnabled(false);
  7923. }
  7924. function resetAfterCommit(containerInfo) {
  7925. restoreSelection(selectionInformation);
  7926. selectionInformation = null;
  7927. setEnabled(eventsEnabled);
  7928. eventsEnabled = null;
  7929. }
  7930. function createInstance(type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
  7931. var parentNamespace;
  7932. {
  7933. // TODO: take namespace into account when validating.
  7934. var hostContextDev = hostContext;
  7935. validateDOMNesting(type, null, hostContextDev.ancestorInfo);
  7936. if (typeof props.children === 'string' || typeof props.children === 'number') {
  7937. var string = '' + props.children;
  7938. var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type);
  7939. validateDOMNesting(null, string, ownAncestorInfo);
  7940. }
  7941. parentNamespace = hostContextDev.namespace;
  7942. }
  7943. var domElement = createElement(type, props, rootContainerInstance, parentNamespace);
  7944. precacheFiberNode(internalInstanceHandle, domElement);
  7945. updateFiberProps(domElement, props);
  7946. return domElement;
  7947. }
  7948. function appendInitialChild(parentInstance, child) {
  7949. parentInstance.appendChild(child);
  7950. }
  7951. function finalizeInitialChildren(domElement, type, props, rootContainerInstance, hostContext) {
  7952. setInitialProperties(domElement, type, props, rootContainerInstance);
  7953. return shouldAutoFocusHostComponent(type, props);
  7954. }
  7955. function prepareUpdate(domElement, type, oldProps, newProps, rootContainerInstance, hostContext) {
  7956. {
  7957. var hostContextDev = hostContext;
  7958. if (typeof newProps.children !== typeof oldProps.children && (typeof newProps.children === 'string' || typeof newProps.children === 'number')) {
  7959. var string = '' + newProps.children;
  7960. var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type);
  7961. validateDOMNesting(null, string, ownAncestorInfo);
  7962. }
  7963. }
  7964. return diffProperties(domElement, type, oldProps, newProps, rootContainerInstance);
  7965. }
  7966. function shouldSetTextContent(type, props) {
  7967. return type === 'textarea' || type === 'option' || type === 'noscript' || typeof props.children === 'string' || typeof props.children === 'number' || typeof props.dangerouslySetInnerHTML === 'object' && props.dangerouslySetInnerHTML !== null && props.dangerouslySetInnerHTML.__html != null;
  7968. }
  7969. function shouldDeprioritizeSubtree(type, props) {
  7970. return !!props.hidden;
  7971. }
  7972. function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) {
  7973. {
  7974. var hostContextDev = hostContext;
  7975. validateDOMNesting(null, text, hostContextDev.ancestorInfo);
  7976. }
  7977. var textNode = createTextNode(text, rootContainerInstance);
  7978. precacheFiberNode(internalInstanceHandle, textNode);
  7979. return textNode;
  7980. }
  7981. var isPrimaryRenderer = true;
  7982. var warnsIfNotActing = true; // This initialization code may run even on server environments
  7983. // if a component just imports ReactDOM (e.g. for findDOMNode).
  7984. // Some environments might not have setTimeout or clearTimeout.
  7985. var scheduleTimeout = typeof setTimeout === 'function' ? setTimeout : undefined;
  7986. var cancelTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined;
  7987. var noTimeout = -1; // -------------------
  7988. // Mutation
  7989. // -------------------
  7990. var supportsMutation = true;
  7991. function commitMount(domElement, type, newProps, internalInstanceHandle) {
  7992. // Despite the naming that might imply otherwise, this method only
  7993. // fires if there is an `Update` effect scheduled during mounting.
  7994. // This happens if `finalizeInitialChildren` returns `true` (which it
  7995. // does to implement the `autoFocus` attribute on the client). But
  7996. // there are also other cases when this might happen (such as patching
  7997. // up text content during hydration mismatch). So we'll check this again.
  7998. if (shouldAutoFocusHostComponent(type, newProps)) {
  7999. domElement.focus();
  8000. }
  8001. }
  8002. function commitUpdate(domElement, updatePayload, type, oldProps, newProps, internalInstanceHandle) {
  8003. // Update the props handle so that we know which props are the ones with
  8004. // with current event handlers.
  8005. updateFiberProps(domElement, newProps); // Apply the diff to the DOM node.
  8006. updateProperties(domElement, updatePayload, type, oldProps, newProps);
  8007. }
  8008. function resetTextContent(domElement) {
  8009. setTextContent(domElement, '');
  8010. }
  8011. function commitTextUpdate(textInstance, oldText, newText) {
  8012. textInstance.nodeValue = newText;
  8013. }
  8014. function appendChild(parentInstance, child) {
  8015. parentInstance.appendChild(child);
  8016. }
  8017. function appendChildToContainer(container, child) {
  8018. var parentNode;
  8019. if (container.nodeType === COMMENT_NODE) {
  8020. parentNode = container.parentNode;
  8021. parentNode.insertBefore(child, container);
  8022. } else {
  8023. parentNode = container;
  8024. parentNode.appendChild(child);
  8025. } // This container might be used for a portal.
  8026. // If something inside a portal is clicked, that click should bubble
  8027. // through the React tree. However, on Mobile Safari the click would
  8028. // never bubble through the *DOM* tree unless an ancestor with onclick
  8029. // event exists. So we wouldn't see it and dispatch it.
  8030. // This is why we ensure that non React root containers have inline onclick
  8031. // defined.
  8032. // https://github.com/facebook/react/issues/11918
  8033. var reactRootContainer = container._reactRootContainer;
  8034. if ((reactRootContainer === null || reactRootContainer === undefined) && parentNode.onclick === null) {
  8035. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  8036. trapClickOnNonInteractiveElement(parentNode);
  8037. }
  8038. }
  8039. function insertBefore(parentInstance, child, beforeChild) {
  8040. parentInstance.insertBefore(child, beforeChild);
  8041. }
  8042. function insertInContainerBefore(container, child, beforeChild) {
  8043. if (container.nodeType === COMMENT_NODE) {
  8044. container.parentNode.insertBefore(child, beforeChild);
  8045. } else {
  8046. container.insertBefore(child, beforeChild);
  8047. }
  8048. } // This is a specific event for the React Flare
  8049. // event system, so event responders can act
  8050. // accordingly to a DOM node being unmounted that
  8051. // previously had active document focus.
  8052. function dispatchDetachedVisibleNodeEvent(child) {
  8053. if (enableFlareAPI && selectionInformation && child === selectionInformation.focusedElem) {
  8054. var targetFiber = getClosestInstanceFromNode(child); // Simlulate a blur event to the React Flare responder system.
  8055. dispatchEventForResponderEventSystem('detachedvisiblenode', targetFiber, {
  8056. target: child,
  8057. timeStamp: Date.now()
  8058. }, child, RESPONDER_EVENT_SYSTEM | IS_PASSIVE);
  8059. }
  8060. }
  8061. function removeChild(parentInstance, child) {
  8062. dispatchDetachedVisibleNodeEvent(child);
  8063. parentInstance.removeChild(child);
  8064. }
  8065. function removeChildFromContainer(container, child) {
  8066. if (container.nodeType === COMMENT_NODE) {
  8067. container.parentNode.removeChild(child);
  8068. } else {
  8069. dispatchDetachedVisibleNodeEvent(child);
  8070. container.removeChild(child);
  8071. }
  8072. }
  8073. function clearSuspenseBoundary(parentInstance, suspenseInstance) {
  8074. var node = suspenseInstance; // Delete all nodes within this suspense boundary.
  8075. // There might be nested nodes so we need to keep track of how
  8076. // deep we are and only break out when we're back on top.
  8077. var depth = 0;
  8078. do {
  8079. var nextNode = node.nextSibling;
  8080. parentInstance.removeChild(node);
  8081. if (nextNode && nextNode.nodeType === COMMENT_NODE) {
  8082. var data = nextNode.data;
  8083. if (data === SUSPENSE_END_DATA) {
  8084. if (depth === 0) {
  8085. parentInstance.removeChild(nextNode); // Retry if any event replaying was blocked on this.
  8086. retryIfBlockedOn(suspenseInstance);
  8087. return;
  8088. } else {
  8089. depth--;
  8090. }
  8091. } else if (data === SUSPENSE_START_DATA || data === SUSPENSE_PENDING_START_DATA || data === SUSPENSE_FALLBACK_START_DATA) {
  8092. depth++;
  8093. }
  8094. }
  8095. node = nextNode;
  8096. } while (node); // TODO: Warn, we didn't find the end comment boundary.
  8097. // Retry if any event replaying was blocked on this.
  8098. retryIfBlockedOn(suspenseInstance);
  8099. }
  8100. function clearSuspenseBoundaryFromContainer(container, suspenseInstance) {
  8101. if (container.nodeType === COMMENT_NODE) {
  8102. clearSuspenseBoundary(container.parentNode, suspenseInstance);
  8103. } else if (container.nodeType === ELEMENT_NODE) {
  8104. clearSuspenseBoundary(container, suspenseInstance);
  8105. } else {} // Document nodes should never contain suspense boundaries.
  8106. // Retry if any event replaying was blocked on this.
  8107. retryIfBlockedOn(container);
  8108. }
  8109. function hideInstance(instance) {
  8110. // TODO: Does this work for all element types? What about MathML? Should we
  8111. // pass host context to this method?
  8112. instance = instance;
  8113. var style = instance.style;
  8114. if (typeof style.setProperty === 'function') {
  8115. style.setProperty('display', 'none', 'important');
  8116. } else {
  8117. style.display = 'none';
  8118. }
  8119. }
  8120. function hideTextInstance(textInstance) {
  8121. textInstance.nodeValue = '';
  8122. }
  8123. function unhideInstance(instance, props) {
  8124. instance = instance;
  8125. var styleProp = props[STYLE];
  8126. var display = styleProp !== undefined && styleProp !== null && styleProp.hasOwnProperty('display') ? styleProp.display : null;
  8127. instance.style.display = dangerousStyleValue('display', display);
  8128. }
  8129. function unhideTextInstance(textInstance, text) {
  8130. textInstance.nodeValue = text;
  8131. } // -------------------
  8132. // Hydration
  8133. // -------------------
  8134. var supportsHydration = true;
  8135. function canHydrateInstance(instance, type, props) {
  8136. if (instance.nodeType !== ELEMENT_NODE || type.toLowerCase() !== instance.nodeName.toLowerCase()) {
  8137. return null;
  8138. } // This has now been refined to an element node.
  8139. return instance;
  8140. }
  8141. function canHydrateTextInstance(instance, text) {
  8142. if (text === '' || instance.nodeType !== TEXT_NODE) {
  8143. // Empty strings are not parsed by HTML so there won't be a correct match here.
  8144. return null;
  8145. } // This has now been refined to a text node.
  8146. return instance;
  8147. }
  8148. function canHydrateSuspenseInstance(instance) {
  8149. if (instance.nodeType !== COMMENT_NODE) {
  8150. // Empty strings are not parsed by HTML so there won't be a correct match here.
  8151. return null;
  8152. } // This has now been refined to a suspense node.
  8153. return instance;
  8154. }
  8155. function isSuspenseInstancePending(instance) {
  8156. return instance.data === SUSPENSE_PENDING_START_DATA;
  8157. }
  8158. function isSuspenseInstanceFallback(instance) {
  8159. return instance.data === SUSPENSE_FALLBACK_START_DATA;
  8160. }
  8161. function registerSuspenseInstanceRetry(instance, callback) {
  8162. instance._reactRetry = callback;
  8163. }
  8164. function getNextHydratable(node) {
  8165. // Skip non-hydratable nodes.
  8166. for (; node != null; node = node.nextSibling) {
  8167. var nodeType = node.nodeType;
  8168. if (nodeType === ELEMENT_NODE || nodeType === TEXT_NODE) {
  8169. break;
  8170. }
  8171. if (enableSuspenseServerRenderer) {
  8172. if (nodeType === COMMENT_NODE) {
  8173. var nodeData = node.data;
  8174. if (nodeData === SUSPENSE_START_DATA || nodeData === SUSPENSE_FALLBACK_START_DATA || nodeData === SUSPENSE_PENDING_START_DATA) {
  8175. break;
  8176. }
  8177. }
  8178. }
  8179. }
  8180. return node;
  8181. }
  8182. function getNextHydratableSibling(instance) {
  8183. return getNextHydratable(instance.nextSibling);
  8184. }
  8185. function getFirstHydratableChild(parentInstance) {
  8186. return getNextHydratable(parentInstance.firstChild);
  8187. }
  8188. function hydrateInstance(instance, type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
  8189. precacheFiberNode(internalInstanceHandle, instance); // TODO: Possibly defer this until the commit phase where all the events
  8190. // get attached.
  8191. updateFiberProps(instance, props);
  8192. var parentNamespace;
  8193. {
  8194. var hostContextDev = hostContext;
  8195. parentNamespace = hostContextDev.namespace;
  8196. }
  8197. return diffHydratedProperties(instance, type, props, parentNamespace, rootContainerInstance);
  8198. }
  8199. function hydrateTextInstance(textInstance, text, internalInstanceHandle) {
  8200. precacheFiberNode(internalInstanceHandle, textInstance);
  8201. return diffHydratedText(textInstance, text);
  8202. }
  8203. function hydrateSuspenseInstance(suspenseInstance, internalInstanceHandle) {
  8204. precacheFiberNode(internalInstanceHandle, suspenseInstance);
  8205. }
  8206. function getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance) {
  8207. var node = suspenseInstance.nextSibling; // Skip past all nodes within this suspense boundary.
  8208. // There might be nested nodes so we need to keep track of how
  8209. // deep we are and only break out when we're back on top.
  8210. var depth = 0;
  8211. while (node) {
  8212. if (node.nodeType === COMMENT_NODE) {
  8213. var data = node.data;
  8214. if (data === SUSPENSE_END_DATA) {
  8215. if (depth === 0) {
  8216. return getNextHydratableSibling(node);
  8217. } else {
  8218. depth--;
  8219. }
  8220. } else if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) {
  8221. depth++;
  8222. }
  8223. }
  8224. node = node.nextSibling;
  8225. } // TODO: Warn, we didn't find the end comment boundary.
  8226. return null;
  8227. } // Returns the SuspenseInstance if this node is a direct child of a
  8228. // SuspenseInstance. I.e. if its previous sibling is a Comment with
  8229. // SUSPENSE_x_START_DATA. Otherwise, null.
  8230. function getParentSuspenseInstance(targetInstance) {
  8231. var node = targetInstance.previousSibling; // Skip past all nodes within this suspense boundary.
  8232. // There might be nested nodes so we need to keep track of how
  8233. // deep we are and only break out when we're back on top.
  8234. var depth = 0;
  8235. while (node) {
  8236. if (node.nodeType === COMMENT_NODE) {
  8237. var data = node.data;
  8238. if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) {
  8239. if (depth === 0) {
  8240. return node;
  8241. } else {
  8242. depth--;
  8243. }
  8244. } else if (data === SUSPENSE_END_DATA) {
  8245. depth++;
  8246. }
  8247. }
  8248. node = node.previousSibling;
  8249. }
  8250. return null;
  8251. }
  8252. function commitHydratedContainer(container) {
  8253. // Retry if any event replaying was blocked on this.
  8254. retryIfBlockedOn(container);
  8255. }
  8256. function commitHydratedSuspenseInstance(suspenseInstance) {
  8257. // Retry if any event replaying was blocked on this.
  8258. retryIfBlockedOn(suspenseInstance);
  8259. }
  8260. function didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, text) {
  8261. {
  8262. warnForUnmatchedText(textInstance, text);
  8263. }
  8264. }
  8265. function didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, text) {
  8266. if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  8267. warnForUnmatchedText(textInstance, text);
  8268. }
  8269. }
  8270. function didNotHydrateContainerInstance(parentContainer, instance) {
  8271. {
  8272. if (instance.nodeType === ELEMENT_NODE) {
  8273. warnForDeletedHydratableElement(parentContainer, instance);
  8274. } else if (instance.nodeType === COMMENT_NODE) {// TODO: warnForDeletedHydratableSuspenseBoundary
  8275. } else {
  8276. warnForDeletedHydratableText(parentContainer, instance);
  8277. }
  8278. }
  8279. }
  8280. function didNotHydrateInstance(parentType, parentProps, parentInstance, instance) {
  8281. if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  8282. if (instance.nodeType === ELEMENT_NODE) {
  8283. warnForDeletedHydratableElement(parentInstance, instance);
  8284. } else if (instance.nodeType === COMMENT_NODE) {// TODO: warnForDeletedHydratableSuspenseBoundary
  8285. } else {
  8286. warnForDeletedHydratableText(parentInstance, instance);
  8287. }
  8288. }
  8289. }
  8290. function didNotFindHydratableContainerInstance(parentContainer, type, props) {
  8291. {
  8292. warnForInsertedHydratedElement(parentContainer, type, props);
  8293. }
  8294. }
  8295. function didNotFindHydratableContainerTextInstance(parentContainer, text) {
  8296. {
  8297. warnForInsertedHydratedText(parentContainer, text);
  8298. }
  8299. }
  8300. function didNotFindHydratableInstance(parentType, parentProps, parentInstance, type, props) {
  8301. if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  8302. warnForInsertedHydratedElement(parentInstance, type, props);
  8303. }
  8304. }
  8305. function didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, text) {
  8306. if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  8307. warnForInsertedHydratedText(parentInstance, text);
  8308. }
  8309. }
  8310. function didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance) {
  8311. if (true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {// TODO: warnForInsertedHydratedSuspense(parentInstance);
  8312. }
  8313. }
  8314. function mountResponderInstance(responder, responderInstance, responderProps, responderState, instance) {
  8315. // Listen to events
  8316. var doc = instance.ownerDocument;
  8317. var _ref = responder,
  8318. rootEventTypes = _ref.rootEventTypes,
  8319. targetEventTypes = _ref.targetEventTypes;
  8320. if (targetEventTypes !== null) {
  8321. listenToEventResponderEventTypes(targetEventTypes, doc);
  8322. }
  8323. if (rootEventTypes !== null) {
  8324. addRootEventTypesForResponderInstance(responderInstance, rootEventTypes);
  8325. listenToEventResponderEventTypes(rootEventTypes, doc);
  8326. }
  8327. mountEventResponder(responder, responderInstance, responderProps, responderState);
  8328. return responderInstance;
  8329. }
  8330. function unmountResponderInstance(responderInstance) {
  8331. if (enableFlareAPI) {
  8332. // TODO stop listening to targetEventTypes
  8333. unmountEventResponder(responderInstance);
  8334. }
  8335. }
  8336. function getFundamentalComponentInstance(fundamentalInstance) {
  8337. if (enableFundamentalAPI) {
  8338. var currentFiber = fundamentalInstance.currentFiber,
  8339. impl = fundamentalInstance.impl,
  8340. props = fundamentalInstance.props,
  8341. state = fundamentalInstance.state;
  8342. var instance = impl.getInstance(null, props, state);
  8343. precacheFiberNode(currentFiber, instance);
  8344. return instance;
  8345. } // Because of the flag above, this gets around the Flow error;
  8346. return null;
  8347. }
  8348. function mountFundamentalComponent(fundamentalInstance) {
  8349. if (enableFundamentalAPI) {
  8350. var impl = fundamentalInstance.impl,
  8351. instance = fundamentalInstance.instance,
  8352. props = fundamentalInstance.props,
  8353. state = fundamentalInstance.state;
  8354. var onMount = impl.onMount;
  8355. if (onMount !== undefined) {
  8356. onMount(null, instance, props, state);
  8357. }
  8358. }
  8359. }
  8360. function shouldUpdateFundamentalComponent(fundamentalInstance) {
  8361. if (enableFundamentalAPI) {
  8362. var impl = fundamentalInstance.impl,
  8363. prevProps = fundamentalInstance.prevProps,
  8364. props = fundamentalInstance.props,
  8365. state = fundamentalInstance.state;
  8366. var shouldUpdate = impl.shouldUpdate;
  8367. if (shouldUpdate !== undefined) {
  8368. return shouldUpdate(null, prevProps, props, state);
  8369. }
  8370. }
  8371. return true;
  8372. }
  8373. function updateFundamentalComponent(fundamentalInstance) {
  8374. if (enableFundamentalAPI) {
  8375. var impl = fundamentalInstance.impl,
  8376. instance = fundamentalInstance.instance,
  8377. prevProps = fundamentalInstance.prevProps,
  8378. props = fundamentalInstance.props,
  8379. state = fundamentalInstance.state;
  8380. var onUpdate = impl.onUpdate;
  8381. if (onUpdate !== undefined) {
  8382. onUpdate(null, instance, prevProps, props, state);
  8383. }
  8384. }
  8385. }
  8386. function unmountFundamentalComponent(fundamentalInstance) {
  8387. if (enableFundamentalAPI) {
  8388. var impl = fundamentalInstance.impl,
  8389. instance = fundamentalInstance.instance,
  8390. props = fundamentalInstance.props,
  8391. state = fundamentalInstance.state;
  8392. var onUnmount = impl.onUnmount;
  8393. if (onUnmount !== undefined) {
  8394. onUnmount(null, instance, props, state);
  8395. }
  8396. }
  8397. }
  8398. function getInstanceFromNode$2(node) {
  8399. return getClosestInstanceFromNode(node) || null;
  8400. }
  8401. var randomKey = Math.random().toString(36).slice(2);
  8402. var internalInstanceKey = '__reactInternalInstance$' + randomKey;
  8403. var internalEventHandlersKey = '__reactEventHandlers$' + randomKey;
  8404. var internalContainerInstanceKey = '__reactContainere$' + randomKey;
  8405. function precacheFiberNode(hostInst, node) {
  8406. node[internalInstanceKey] = hostInst;
  8407. }
  8408. function markContainerAsRoot(hostRoot, node) {
  8409. node[internalContainerInstanceKey] = hostRoot;
  8410. }
  8411. function unmarkContainerAsRoot(node) {
  8412. node[internalContainerInstanceKey] = null;
  8413. }
  8414. function isContainerMarkedAsRoot(node) {
  8415. return !!node[internalContainerInstanceKey];
  8416. } // Given a DOM node, return the closest HostComponent or HostText fiber ancestor.
  8417. // If the target node is part of a hydrated or not yet rendered subtree, then
  8418. // this may also return a SuspenseComponent or HostRoot to indicate that.
  8419. // Conceptually the HostRoot fiber is a child of the Container node. So if you
  8420. // pass the Container node as the targetNode, you will not actually get the
  8421. // HostRoot back. To get to the HostRoot, you need to pass a child of it.
  8422. // The same thing applies to Suspense boundaries.
  8423. function getClosestInstanceFromNode(targetNode) {
  8424. var targetInst = targetNode[internalInstanceKey];
  8425. if (targetInst) {
  8426. // Don't return HostRoot or SuspenseComponent here.
  8427. return targetInst;
  8428. } // If the direct event target isn't a React owned DOM node, we need to look
  8429. // to see if one of its parents is a React owned DOM node.
  8430. var parentNode = targetNode.parentNode;
  8431. while (parentNode) {
  8432. // We'll check if this is a container root that could include
  8433. // React nodes in the future. We need to check this first because
  8434. // if we're a child of a dehydrated container, we need to first
  8435. // find that inner container before moving on to finding the parent
  8436. // instance. Note that we don't check this field on the targetNode
  8437. // itself because the fibers are conceptually between the container
  8438. // node and the first child. It isn't surrounding the container node.
  8439. // If it's not a container, we check if it's an instance.
  8440. targetInst = parentNode[internalContainerInstanceKey] || parentNode[internalInstanceKey];
  8441. if (targetInst) {
  8442. // Since this wasn't the direct target of the event, we might have
  8443. // stepped past dehydrated DOM nodes to get here. However they could
  8444. // also have been non-React nodes. We need to answer which one.
  8445. // If we the instance doesn't have any children, then there can't be
  8446. // a nested suspense boundary within it. So we can use this as a fast
  8447. // bailout. Most of the time, when people add non-React children to
  8448. // the tree, it is using a ref to a child-less DOM node.
  8449. // Normally we'd only need to check one of the fibers because if it
  8450. // has ever gone from having children to deleting them or vice versa
  8451. // it would have deleted the dehydrated boundary nested inside already.
  8452. // However, since the HostRoot starts out with an alternate it might
  8453. // have one on the alternate so we need to check in case this was a
  8454. // root.
  8455. var alternate = targetInst.alternate;
  8456. if (targetInst.child !== null || alternate !== null && alternate.child !== null) {
  8457. // Next we need to figure out if the node that skipped past is
  8458. // nested within a dehydrated boundary and if so, which one.
  8459. var suspenseInstance = getParentSuspenseInstance(targetNode);
  8460. while (suspenseInstance !== null) {
  8461. // We found a suspense instance. That means that we haven't
  8462. // hydrated it yet. Even though we leave the comments in the
  8463. // DOM after hydrating, and there are boundaries in the DOM
  8464. // that could already be hydrated, we wouldn't have found them
  8465. // through this pass since if the target is hydrated it would
  8466. // have had an internalInstanceKey on it.
  8467. // Let's get the fiber associated with the SuspenseComponent
  8468. // as the deepest instance.
  8469. var targetSuspenseInst = suspenseInstance[internalInstanceKey];
  8470. if (targetSuspenseInst) {
  8471. return targetSuspenseInst;
  8472. } // If we don't find a Fiber on the comment, it might be because
  8473. // we haven't gotten to hydrate it yet. There might still be a
  8474. // parent boundary that hasn't above this one so we need to find
  8475. // the outer most that is known.
  8476. suspenseInstance = getParentSuspenseInstance(suspenseInstance); // If we don't find one, then that should mean that the parent
  8477. // host component also hasn't hydrated yet. We can return it
  8478. // below since it will bail out on the isMounted check later.
  8479. }
  8480. }
  8481. return targetInst;
  8482. }
  8483. targetNode = parentNode;
  8484. parentNode = targetNode.parentNode;
  8485. }
  8486. return null;
  8487. }
  8488. /**
  8489. * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent
  8490. * instance, or null if the node was not rendered by this React.
  8491. */
  8492. function getInstanceFromNode$1(node) {
  8493. var inst = node[internalInstanceKey] || node[internalContainerInstanceKey];
  8494. if (inst) {
  8495. if (inst.tag === HostComponent || inst.tag === HostText || inst.tag === SuspenseComponent || inst.tag === HostRoot) {
  8496. return inst;
  8497. } else {
  8498. return null;
  8499. }
  8500. }
  8501. return null;
  8502. }
  8503. /**
  8504. * Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding
  8505. * DOM node.
  8506. */
  8507. function getNodeFromInstance$1(inst) {
  8508. if (inst.tag === HostComponent || inst.tag === HostText) {
  8509. // In Fiber this, is just the state node right now. We assume it will be
  8510. // a host component or host text.
  8511. return inst.stateNode;
  8512. } // Without this first invariant, passing a non-DOM-component triggers the next
  8513. // invariant for a missing parent, which is super confusing.
  8514. {
  8515. {
  8516. throw Error("getNodeFromInstance: Invalid argument.");
  8517. }
  8518. }
  8519. }
  8520. function getFiberCurrentPropsFromNode$1(node) {
  8521. return node[internalEventHandlersKey] || null;
  8522. }
  8523. function updateFiberProps(node, props) {
  8524. node[internalEventHandlersKey] = props;
  8525. }
  8526. /**
  8527. * These variables store information about text content of a target node,
  8528. * allowing comparison of content before and after a given event.
  8529. *
  8530. * Identify the node where selection currently begins, then observe
  8531. * both its text content and its current position in the DOM. Since the
  8532. * browser may natively replace the target node during composition, we can
  8533. * use its position to find its replacement.
  8534. *
  8535. *
  8536. */
  8537. var root = null;
  8538. var startText = null;
  8539. var fallbackText = null;
  8540. function initialize(nativeEventTarget) {
  8541. root = nativeEventTarget;
  8542. startText = getText();
  8543. return true;
  8544. }
  8545. function reset() {
  8546. root = null;
  8547. startText = null;
  8548. fallbackText = null;
  8549. }
  8550. function getData() {
  8551. if (fallbackText) {
  8552. return fallbackText;
  8553. }
  8554. var start;
  8555. var startValue = startText;
  8556. var startLength = startValue.length;
  8557. var end;
  8558. var endValue = getText();
  8559. var endLength = endValue.length;
  8560. for (start = 0; start < startLength; start++) {
  8561. if (startValue[start] !== endValue[start]) {
  8562. break;
  8563. }
  8564. }
  8565. var minEnd = startLength - start;
  8566. for (end = 1; end <= minEnd; end++) {
  8567. if (startValue[startLength - end] !== endValue[endLength - end]) {
  8568. break;
  8569. }
  8570. }
  8571. var sliceTail = end > 1 ? 1 - end : undefined;
  8572. fallbackText = endValue.slice(start, sliceTail);
  8573. return fallbackText;
  8574. }
  8575. function getText() {
  8576. if ('value' in root) {
  8577. return root.value;
  8578. }
  8579. return root.textContent;
  8580. }
  8581. /**
  8582. * @interface Event
  8583. * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents
  8584. */
  8585. var SyntheticCompositionEvent = SyntheticEvent.extend({
  8586. data: null
  8587. });
  8588. /**
  8589. * @interface Event
  8590. * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105
  8591. * /#events-inputevents
  8592. */
  8593. var SyntheticInputEvent = SyntheticEvent.extend({
  8594. data: null
  8595. });
  8596. var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
  8597. var START_KEYCODE = 229;
  8598. var canUseCompositionEvent = canUseDOM && 'CompositionEvent' in window;
  8599. var documentMode = null;
  8600. if (canUseDOM && 'documentMode' in document) {
  8601. documentMode = document.documentMode;
  8602. } // Webkit offers a very useful `textInput` event that can be used to
  8603. // directly represent `beforeInput`. The IE `textinput` event is not as
  8604. // useful, so we don't use it.
  8605. var canUseTextInputEvent = canUseDOM && 'TextEvent' in window && !documentMode; // In IE9+, we have access to composition events, but the data supplied
  8606. // by the native compositionend event may be incorrect. Japanese ideographic
  8607. // spaces, for instance (\u3000) are not recorded correctly.
  8608. var useFallbackCompositionData = canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11);
  8609. var SPACEBAR_CODE = 32;
  8610. var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE); // Events and their corresponding property names.
  8611. var eventTypes$1 = {
  8612. beforeInput: {
  8613. phasedRegistrationNames: {
  8614. bubbled: 'onBeforeInput',
  8615. captured: 'onBeforeInputCapture'
  8616. },
  8617. dependencies: [TOP_COMPOSITION_END, TOP_KEY_PRESS, TOP_TEXT_INPUT, TOP_PASTE]
  8618. },
  8619. compositionEnd: {
  8620. phasedRegistrationNames: {
  8621. bubbled: 'onCompositionEnd',
  8622. captured: 'onCompositionEndCapture'
  8623. },
  8624. dependencies: [TOP_BLUR, TOP_COMPOSITION_END, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN]
  8625. },
  8626. compositionStart: {
  8627. phasedRegistrationNames: {
  8628. bubbled: 'onCompositionStart',
  8629. captured: 'onCompositionStartCapture'
  8630. },
  8631. dependencies: [TOP_BLUR, TOP_COMPOSITION_START, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN]
  8632. },
  8633. compositionUpdate: {
  8634. phasedRegistrationNames: {
  8635. bubbled: 'onCompositionUpdate',
  8636. captured: 'onCompositionUpdateCapture'
  8637. },
  8638. dependencies: [TOP_BLUR, TOP_COMPOSITION_UPDATE, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN]
  8639. }
  8640. }; // Track whether we've ever handled a keypress on the space key.
  8641. var hasSpaceKeypress = false;
  8642. /**
  8643. * Return whether a native keypress event is assumed to be a command.
  8644. * This is required because Firefox fires `keypress` events for key commands
  8645. * (cut, copy, select-all, etc.) even though no character is inserted.
  8646. */
  8647. function isKeypressCommand(nativeEvent) {
  8648. return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) && // ctrlKey && altKey is equivalent to AltGr, and is not a command.
  8649. !(nativeEvent.ctrlKey && nativeEvent.altKey);
  8650. }
  8651. /**
  8652. * Translate native top level events into event types.
  8653. *
  8654. * @param {string} topLevelType
  8655. * @return {object}
  8656. */
  8657. function getCompositionEventType(topLevelType) {
  8658. switch (topLevelType) {
  8659. case TOP_COMPOSITION_START:
  8660. return eventTypes$1.compositionStart;
  8661. case TOP_COMPOSITION_END:
  8662. return eventTypes$1.compositionEnd;
  8663. case TOP_COMPOSITION_UPDATE:
  8664. return eventTypes$1.compositionUpdate;
  8665. }
  8666. }
  8667. /**
  8668. * Does our fallback best-guess model think this event signifies that
  8669. * composition has begun?
  8670. *
  8671. * @param {string} topLevelType
  8672. * @param {object} nativeEvent
  8673. * @return {boolean}
  8674. */
  8675. function isFallbackCompositionStart(topLevelType, nativeEvent) {
  8676. return topLevelType === TOP_KEY_DOWN && nativeEvent.keyCode === START_KEYCODE;
  8677. }
  8678. /**
  8679. * Does our fallback mode think that this event is the end of composition?
  8680. *
  8681. * @param {string} topLevelType
  8682. * @param {object} nativeEvent
  8683. * @return {boolean}
  8684. */
  8685. function isFallbackCompositionEnd(topLevelType, nativeEvent) {
  8686. switch (topLevelType) {
  8687. case TOP_KEY_UP:
  8688. // Command keys insert or clear IME input.
  8689. return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1;
  8690. case TOP_KEY_DOWN:
  8691. // Expect IME keyCode on each keydown. If we get any other
  8692. // code we must have exited earlier.
  8693. return nativeEvent.keyCode !== START_KEYCODE;
  8694. case TOP_KEY_PRESS:
  8695. case TOP_MOUSE_DOWN:
  8696. case TOP_BLUR:
  8697. // Events are not possible without cancelling IME.
  8698. return true;
  8699. default:
  8700. return false;
  8701. }
  8702. }
  8703. /**
  8704. * Google Input Tools provides composition data via a CustomEvent,
  8705. * with the `data` property populated in the `detail` object. If this
  8706. * is available on the event object, use it. If not, this is a plain
  8707. * composition event and we have nothing special to extract.
  8708. *
  8709. * @param {object} nativeEvent
  8710. * @return {?string}
  8711. */
  8712. function getDataFromCustomEvent(nativeEvent) {
  8713. var detail = nativeEvent.detail;
  8714. if (typeof detail === 'object' && 'data' in detail) {
  8715. return detail.data;
  8716. }
  8717. return null;
  8718. }
  8719. /**
  8720. * Check if a composition event was triggered by Korean IME.
  8721. * Our fallback mode does not work well with IE's Korean IME,
  8722. * so just use native composition events when Korean IME is used.
  8723. * Although CompositionEvent.locale property is deprecated,
  8724. * it is available in IE, where our fallback mode is enabled.
  8725. *
  8726. * @param {object} nativeEvent
  8727. * @return {boolean}
  8728. */
  8729. function isUsingKoreanIME(nativeEvent) {
  8730. return nativeEvent.locale === 'ko';
  8731. } // Track the current IME composition status, if any.
  8732. var isComposing = false;
  8733. /**
  8734. * @return {?object} A SyntheticCompositionEvent.
  8735. */
  8736. function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  8737. var eventType;
  8738. var fallbackData;
  8739. if (canUseCompositionEvent) {
  8740. eventType = getCompositionEventType(topLevelType);
  8741. } else if (!isComposing) {
  8742. if (isFallbackCompositionStart(topLevelType, nativeEvent)) {
  8743. eventType = eventTypes$1.compositionStart;
  8744. }
  8745. } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) {
  8746. eventType = eventTypes$1.compositionEnd;
  8747. }
  8748. if (!eventType) {
  8749. return null;
  8750. }
  8751. if (useFallbackCompositionData && !isUsingKoreanIME(nativeEvent)) {
  8752. // The current composition is stored statically and must not be
  8753. // overwritten while composition continues.
  8754. if (!isComposing && eventType === eventTypes$1.compositionStart) {
  8755. isComposing = initialize(nativeEventTarget);
  8756. } else if (eventType === eventTypes$1.compositionEnd) {
  8757. if (isComposing) {
  8758. fallbackData = getData();
  8759. }
  8760. }
  8761. }
  8762. var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget);
  8763. if (fallbackData) {
  8764. // Inject data generated from fallback path into the synthetic event.
  8765. // This matches the property of native CompositionEventInterface.
  8766. event.data = fallbackData;
  8767. } else {
  8768. var customData = getDataFromCustomEvent(nativeEvent);
  8769. if (customData !== null) {
  8770. event.data = customData;
  8771. }
  8772. }
  8773. accumulateTwoPhaseDispatches(event);
  8774. return event;
  8775. }
  8776. /**
  8777. * @param {TopLevelType} topLevelType Number from `TopLevelType`.
  8778. * @param {object} nativeEvent Native browser event.
  8779. * @return {?string} The string corresponding to this `beforeInput` event.
  8780. */
  8781. function getNativeBeforeInputChars(topLevelType, nativeEvent) {
  8782. switch (topLevelType) {
  8783. case TOP_COMPOSITION_END:
  8784. return getDataFromCustomEvent(nativeEvent);
  8785. case TOP_KEY_PRESS:
  8786. /**
  8787. * If native `textInput` events are available, our goal is to make
  8788. * use of them. However, there is a special case: the spacebar key.
  8789. * In Webkit, preventing default on a spacebar `textInput` event
  8790. * cancels character insertion, but it *also* causes the browser
  8791. * to fall back to its default spacebar behavior of scrolling the
  8792. * page.
  8793. *
  8794. * Tracking at:
  8795. * https://code.google.com/p/chromium/issues/detail?id=355103
  8796. *
  8797. * To avoid this issue, use the keypress event as if no `textInput`
  8798. * event is available.
  8799. */
  8800. var which = nativeEvent.which;
  8801. if (which !== SPACEBAR_CODE) {
  8802. return null;
  8803. }
  8804. hasSpaceKeypress = true;
  8805. return SPACEBAR_CHAR;
  8806. case TOP_TEXT_INPUT:
  8807. // Record the characters to be added to the DOM.
  8808. var chars = nativeEvent.data; // If it's a spacebar character, assume that we have already handled
  8809. // it at the keypress level and bail immediately. Android Chrome
  8810. // doesn't give us keycodes, so we need to ignore it.
  8811. if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
  8812. return null;
  8813. }
  8814. return chars;
  8815. default:
  8816. // For other native event types, do nothing.
  8817. return null;
  8818. }
  8819. }
  8820. /**
  8821. * For browsers that do not provide the `textInput` event, extract the
  8822. * appropriate string to use for SyntheticInputEvent.
  8823. *
  8824. * @param {number} topLevelType Number from `TopLevelEventTypes`.
  8825. * @param {object} nativeEvent Native browser event.
  8826. * @return {?string} The fallback string for this `beforeInput` event.
  8827. */
  8828. function getFallbackBeforeInputChars(topLevelType, nativeEvent) {
  8829. // If we are currently composing (IME) and using a fallback to do so,
  8830. // try to extract the composed characters from the fallback object.
  8831. // If composition event is available, we extract a string only at
  8832. // compositionevent, otherwise extract it at fallback events.
  8833. if (isComposing) {
  8834. if (topLevelType === TOP_COMPOSITION_END || !canUseCompositionEvent && isFallbackCompositionEnd(topLevelType, nativeEvent)) {
  8835. var chars = getData();
  8836. reset();
  8837. isComposing = false;
  8838. return chars;
  8839. }
  8840. return null;
  8841. }
  8842. switch (topLevelType) {
  8843. case TOP_PASTE:
  8844. // If a paste event occurs after a keypress, throw out the input
  8845. // chars. Paste events should not lead to BeforeInput events.
  8846. return null;
  8847. case TOP_KEY_PRESS:
  8848. /**
  8849. * As of v27, Firefox may fire keypress events even when no character
  8850. * will be inserted. A few possibilities:
  8851. *
  8852. * - `which` is `0`. Arrow keys, Esc key, etc.
  8853. *
  8854. * - `which` is the pressed key code, but no char is available.
  8855. * Ex: 'AltGr + d` in Polish. There is no modified character for
  8856. * this key combination and no character is inserted into the
  8857. * document, but FF fires the keypress for char code `100` anyway.
  8858. * No `input` event will occur.
  8859. *
  8860. * - `which` is the pressed key code, but a command combination is
  8861. * being used. Ex: `Cmd+C`. No character is inserted, and no
  8862. * `input` event will occur.
  8863. */
  8864. if (!isKeypressCommand(nativeEvent)) {
  8865. // IE fires the `keypress` event when a user types an emoji via
  8866. // Touch keyboard of Windows. In such a case, the `char` property
  8867. // holds an emoji character like `\uD83D\uDE0A`. Because its length
  8868. // is 2, the property `which` does not represent an emoji correctly.
  8869. // In such a case, we directly return the `char` property instead of
  8870. // using `which`.
  8871. if (nativeEvent.char && nativeEvent.char.length > 1) {
  8872. return nativeEvent.char;
  8873. } else if (nativeEvent.which) {
  8874. return String.fromCharCode(nativeEvent.which);
  8875. }
  8876. }
  8877. return null;
  8878. case TOP_COMPOSITION_END:
  8879. return useFallbackCompositionData && !isUsingKoreanIME(nativeEvent) ? null : nativeEvent.data;
  8880. default:
  8881. return null;
  8882. }
  8883. }
  8884. /**
  8885. * Extract a SyntheticInputEvent for `beforeInput`, based on either native
  8886. * `textInput` or fallback behavior.
  8887. *
  8888. * @return {?object} A SyntheticInputEvent.
  8889. */
  8890. function extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  8891. var chars;
  8892. if (canUseTextInputEvent) {
  8893. chars = getNativeBeforeInputChars(topLevelType, nativeEvent);
  8894. } else {
  8895. chars = getFallbackBeforeInputChars(topLevelType, nativeEvent);
  8896. } // If no characters are being inserted, no BeforeInput event should
  8897. // be fired.
  8898. if (!chars) {
  8899. return null;
  8900. }
  8901. var event = SyntheticInputEvent.getPooled(eventTypes$1.beforeInput, targetInst, nativeEvent, nativeEventTarget);
  8902. event.data = chars;
  8903. accumulateTwoPhaseDispatches(event);
  8904. return event;
  8905. }
  8906. /**
  8907. * Create an `onBeforeInput` event to match
  8908. * http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents.
  8909. *
  8910. * This event plugin is based on the native `textInput` event
  8911. * available in Chrome, Safari, Opera, and IE. This event fires after
  8912. * `onKeyPress` and `onCompositionEnd`, but before `onInput`.
  8913. *
  8914. * `beforeInput` is spec'd but not implemented in any browsers, and
  8915. * the `input` event does not provide any useful information about what has
  8916. * actually been added, contrary to the spec. Thus, `textInput` is the best
  8917. * available event to identify the characters that have actually been inserted
  8918. * into the target node.
  8919. *
  8920. * This plugin is also responsible for emitting `composition` events, thus
  8921. * allowing us to share composition fallback code for both `beforeInput` and
  8922. * `composition` event types.
  8923. */
  8924. var BeforeInputEventPlugin = {
  8925. eventTypes: eventTypes$1,
  8926. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) {
  8927. var composition = extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget);
  8928. var beforeInput = extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget);
  8929. if (composition === null) {
  8930. return beforeInput;
  8931. }
  8932. if (beforeInput === null) {
  8933. return composition;
  8934. }
  8935. return [composition, beforeInput];
  8936. }
  8937. };
  8938. /**
  8939. * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
  8940. */
  8941. var supportedInputTypes = {
  8942. color: true,
  8943. date: true,
  8944. datetime: true,
  8945. 'datetime-local': true,
  8946. email: true,
  8947. month: true,
  8948. number: true,
  8949. password: true,
  8950. range: true,
  8951. search: true,
  8952. tel: true,
  8953. text: true,
  8954. time: true,
  8955. url: true,
  8956. week: true
  8957. };
  8958. function isTextInputElement(elem) {
  8959. var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
  8960. if (nodeName === 'input') {
  8961. return !!supportedInputTypes[elem.type];
  8962. }
  8963. if (nodeName === 'textarea') {
  8964. return true;
  8965. }
  8966. return false;
  8967. }
  8968. var eventTypes$2 = {
  8969. change: {
  8970. phasedRegistrationNames: {
  8971. bubbled: 'onChange',
  8972. captured: 'onChangeCapture'
  8973. },
  8974. dependencies: [TOP_BLUR, TOP_CHANGE, TOP_CLICK, TOP_FOCUS, TOP_INPUT, TOP_KEY_DOWN, TOP_KEY_UP, TOP_SELECTION_CHANGE]
  8975. }
  8976. };
  8977. function createAndAccumulateChangeEvent(inst, nativeEvent, target) {
  8978. var event = SyntheticEvent.getPooled(eventTypes$2.change, inst, nativeEvent, target);
  8979. event.type = 'change'; // Flag this event loop as needing state restore.
  8980. enqueueStateRestore(target);
  8981. accumulateTwoPhaseDispatches(event);
  8982. return event;
  8983. }
  8984. /**
  8985. * For IE shims
  8986. */
  8987. var activeElement = null;
  8988. var activeElementInst = null;
  8989. /**
  8990. * SECTION: handle `change` event
  8991. */
  8992. function shouldUseChangeEvent(elem) {
  8993. var nodeName = elem.nodeName && elem.nodeName.toLowerCase();
  8994. return nodeName === 'select' || nodeName === 'input' && elem.type === 'file';
  8995. }
  8996. function manualDispatchChangeEvent(nativeEvent) {
  8997. var event = createAndAccumulateChangeEvent(activeElementInst, nativeEvent, getEventTarget(nativeEvent)); // If change and propertychange bubbled, we'd just bind to it like all the
  8998. // other events and have it go through ReactBrowserEventEmitter. Since it
  8999. // doesn't, we manually listen for the events and so we have to enqueue and
  9000. // process the abstract event manually.
  9001. //
  9002. // Batching is necessary here in order to ensure that all event handlers run
  9003. // before the next rerender (including event handlers attached to ancestor
  9004. // elements instead of directly on the input). Without this, controlled
  9005. // components don't work properly in conjunction with event bubbling because
  9006. // the component is rerendered and the value reverted before all the event
  9007. // handlers can run. See https://github.com/facebook/react/issues/708.
  9008. batchedUpdates(runEventInBatch, event);
  9009. }
  9010. function runEventInBatch(event) {
  9011. runEventsInBatch(event);
  9012. }
  9013. function getInstIfValueChanged(targetInst) {
  9014. var targetNode = getNodeFromInstance$1(targetInst);
  9015. if (updateValueIfChanged(targetNode)) {
  9016. return targetInst;
  9017. }
  9018. }
  9019. function getTargetInstForChangeEvent(topLevelType, targetInst) {
  9020. if (topLevelType === TOP_CHANGE) {
  9021. return targetInst;
  9022. }
  9023. }
  9024. /**
  9025. * SECTION: handle `input` event
  9026. */
  9027. var isInputEventSupported = false;
  9028. if (canUseDOM) {
  9029. // IE9 claims to support the input event but fails to trigger it when
  9030. // deleting text, so we ignore its input events.
  9031. isInputEventSupported = isEventSupported('input') && (!document.documentMode || document.documentMode > 9);
  9032. }
  9033. /**
  9034. * (For IE <=9) Starts tracking propertychange events on the passed-in element
  9035. * and override the value property so that we can distinguish user events from
  9036. * value changes in JS.
  9037. */
  9038. function startWatchingForValueChange(target, targetInst) {
  9039. activeElement = target;
  9040. activeElementInst = targetInst;
  9041. activeElement.attachEvent('onpropertychange', handlePropertyChange);
  9042. }
  9043. /**
  9044. * (For IE <=9) Removes the event listeners from the currently-tracked element,
  9045. * if any exists.
  9046. */
  9047. function stopWatchingForValueChange() {
  9048. if (!activeElement) {
  9049. return;
  9050. }
  9051. activeElement.detachEvent('onpropertychange', handlePropertyChange);
  9052. activeElement = null;
  9053. activeElementInst = null;
  9054. }
  9055. /**
  9056. * (For IE <=9) Handles a propertychange event, sending a `change` event if
  9057. * the value of the active element has changed.
  9058. */
  9059. function handlePropertyChange(nativeEvent) {
  9060. if (nativeEvent.propertyName !== 'value') {
  9061. return;
  9062. }
  9063. if (getInstIfValueChanged(activeElementInst)) {
  9064. manualDispatchChangeEvent(nativeEvent);
  9065. }
  9066. }
  9067. function handleEventsForInputEventPolyfill(topLevelType, target, targetInst) {
  9068. if (topLevelType === TOP_FOCUS) {
  9069. // In IE9, propertychange fires for most input events but is buggy and
  9070. // doesn't fire when text is deleted, but conveniently, selectionchange
  9071. // appears to fire in all of the remaining cases so we catch those and
  9072. // forward the event if the value has changed
  9073. // In either case, we don't want to call the event handler if the value
  9074. // is changed from JS so we redefine a setter for `.value` that updates
  9075. // our activeElementValue variable, allowing us to ignore those changes
  9076. //
  9077. // stopWatching() should be a noop here but we call it just in case we
  9078. // missed a blur event somehow.
  9079. stopWatchingForValueChange();
  9080. startWatchingForValueChange(target, targetInst);
  9081. } else if (topLevelType === TOP_BLUR) {
  9082. stopWatchingForValueChange();
  9083. }
  9084. } // For IE8 and IE9.
  9085. function getTargetInstForInputEventPolyfill(topLevelType, targetInst) {
  9086. if (topLevelType === TOP_SELECTION_CHANGE || topLevelType === TOP_KEY_UP || topLevelType === TOP_KEY_DOWN) {
  9087. // On the selectionchange event, the target is just document which isn't
  9088. // helpful for us so just check activeElement instead.
  9089. //
  9090. // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire
  9091. // propertychange on the first input event after setting `value` from a
  9092. // script and fires only keydown, keypress, keyup. Catching keyup usually
  9093. // gets it and catching keydown lets us fire an event for the first
  9094. // keystroke if user does a key repeat (it'll be a little delayed: right
  9095. // before the second keystroke). Other input methods (e.g., paste) seem to
  9096. // fire selectionchange normally.
  9097. return getInstIfValueChanged(activeElementInst);
  9098. }
  9099. }
  9100. /**
  9101. * SECTION: handle `click` event
  9102. */
  9103. function shouldUseClickEvent(elem) {
  9104. // Use the `click` event to detect changes to checkbox and radio inputs.
  9105. // This approach works across all browsers, whereas `change` does not fire
  9106. // until `blur` in IE8.
  9107. var nodeName = elem.nodeName;
  9108. return nodeName && nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio');
  9109. }
  9110. function getTargetInstForClickEvent(topLevelType, targetInst) {
  9111. if (topLevelType === TOP_CLICK) {
  9112. return getInstIfValueChanged(targetInst);
  9113. }
  9114. }
  9115. function getTargetInstForInputOrChangeEvent(topLevelType, targetInst) {
  9116. if (topLevelType === TOP_INPUT || topLevelType === TOP_CHANGE) {
  9117. return getInstIfValueChanged(targetInst);
  9118. }
  9119. }
  9120. function handleControlledInputBlur(node) {
  9121. var state = node._wrapperState;
  9122. if (!state || !state.controlled || node.type !== 'number') {
  9123. return;
  9124. }
  9125. if (!disableInputAttributeSyncing) {
  9126. // If controlled, assign the value attribute to the current value on blur
  9127. setDefaultValue(node, 'number', node.value);
  9128. }
  9129. }
  9130. /**
  9131. * This plugin creates an `onChange` event that normalizes change events
  9132. * across form elements. This event fires at a time when it's possible to
  9133. * change the element's value without seeing a flicker.
  9134. *
  9135. * Supported elements are:
  9136. * - input (see `isTextInputElement`)
  9137. * - textarea
  9138. * - select
  9139. */
  9140. var ChangeEventPlugin = {
  9141. eventTypes: eventTypes$2,
  9142. _isInputEventSupported: isInputEventSupported,
  9143. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) {
  9144. var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window;
  9145. var getTargetInstFunc, handleEventFunc;
  9146. if (shouldUseChangeEvent(targetNode)) {
  9147. getTargetInstFunc = getTargetInstForChangeEvent;
  9148. } else if (isTextInputElement(targetNode)) {
  9149. if (isInputEventSupported) {
  9150. getTargetInstFunc = getTargetInstForInputOrChangeEvent;
  9151. } else {
  9152. getTargetInstFunc = getTargetInstForInputEventPolyfill;
  9153. handleEventFunc = handleEventsForInputEventPolyfill;
  9154. }
  9155. } else if (shouldUseClickEvent(targetNode)) {
  9156. getTargetInstFunc = getTargetInstForClickEvent;
  9157. }
  9158. if (getTargetInstFunc) {
  9159. var inst = getTargetInstFunc(topLevelType, targetInst);
  9160. if (inst) {
  9161. var event = createAndAccumulateChangeEvent(inst, nativeEvent, nativeEventTarget);
  9162. return event;
  9163. }
  9164. }
  9165. if (handleEventFunc) {
  9166. handleEventFunc(topLevelType, targetNode, targetInst);
  9167. } // When blurring, set the value attribute for number inputs
  9168. if (topLevelType === TOP_BLUR) {
  9169. handleControlledInputBlur(targetNode);
  9170. }
  9171. }
  9172. };
  9173. /**
  9174. * Module that is injectable into `EventPluginHub`, that specifies a
  9175. * deterministic ordering of `EventPlugin`s. A convenient way to reason about
  9176. * plugins, without having to package every one of them. This is better than
  9177. * having plugins be ordered in the same order that they are injected because
  9178. * that ordering would be influenced by the packaging order.
  9179. * `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
  9180. * preventing default on events is convenient in `SimpleEventPlugin` handlers.
  9181. */
  9182. var DOMEventPluginOrder = ['ResponderEventPlugin', 'SimpleEventPlugin', 'EnterLeaveEventPlugin', 'ChangeEventPlugin', 'SelectEventPlugin', 'BeforeInputEventPlugin'];
  9183. var eventTypes$3 = {
  9184. mouseEnter: {
  9185. registrationName: 'onMouseEnter',
  9186. dependencies: [TOP_MOUSE_OUT, TOP_MOUSE_OVER]
  9187. },
  9188. mouseLeave: {
  9189. registrationName: 'onMouseLeave',
  9190. dependencies: [TOP_MOUSE_OUT, TOP_MOUSE_OVER]
  9191. },
  9192. pointerEnter: {
  9193. registrationName: 'onPointerEnter',
  9194. dependencies: [TOP_POINTER_OUT, TOP_POINTER_OVER]
  9195. },
  9196. pointerLeave: {
  9197. registrationName: 'onPointerLeave',
  9198. dependencies: [TOP_POINTER_OUT, TOP_POINTER_OVER]
  9199. }
  9200. }; // We track the lastNativeEvent to ensure that when we encounter
  9201. // cases where we process the same nativeEvent multiple times,
  9202. // which can happen when have multiple ancestors, that we don't
  9203. // duplicate enter
  9204. var lastNativeEvent;
  9205. var EnterLeaveEventPlugin = {
  9206. eventTypes: eventTypes$3,
  9207. /**
  9208. * For almost every interaction we care about, there will be both a top-level
  9209. * `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that
  9210. * we do not extract duplicate events. However, moving the mouse into the
  9211. * browser from outside will not fire a `mouseout` event. In this case, we use
  9212. * the `mouseover` top-level event.
  9213. */
  9214. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) {
  9215. var isOverEvent = topLevelType === TOP_MOUSE_OVER || topLevelType === TOP_POINTER_OVER;
  9216. var isOutEvent = topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_POINTER_OUT;
  9217. if (isOverEvent && (eventSystemFlags & IS_REPLAYED) === 0 && (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
  9218. // If this is an over event with a target, then we've already dispatched
  9219. // the event in the out event of the other target. If this is replayed,
  9220. // then it's because we couldn't dispatch against this target previously
  9221. // so we have to do it now instead.
  9222. return null;
  9223. }
  9224. if (!isOutEvent && !isOverEvent) {
  9225. // Must not be a mouse or pointer in or out - ignoring.
  9226. return null;
  9227. }
  9228. var win;
  9229. if (nativeEventTarget.window === nativeEventTarget) {
  9230. // `nativeEventTarget` is probably a window object.
  9231. win = nativeEventTarget;
  9232. } else {
  9233. // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
  9234. var doc = nativeEventTarget.ownerDocument;
  9235. if (doc) {
  9236. win = doc.defaultView || doc.parentWindow;
  9237. } else {
  9238. win = window;
  9239. }
  9240. }
  9241. var from;
  9242. var to;
  9243. if (isOutEvent) {
  9244. from = targetInst;
  9245. var related = nativeEvent.relatedTarget || nativeEvent.toElement;
  9246. to = related ? getClosestInstanceFromNode(related) : null;
  9247. if (to !== null) {
  9248. var nearestMounted = getNearestMountedFiber(to);
  9249. if (to !== nearestMounted || to.tag !== HostComponent && to.tag !== HostText) {
  9250. to = null;
  9251. }
  9252. }
  9253. } else {
  9254. // Moving to a node from outside the window.
  9255. from = null;
  9256. to = targetInst;
  9257. }
  9258. if (from === to) {
  9259. // Nothing pertains to our managed components.
  9260. return null;
  9261. }
  9262. var eventInterface, leaveEventType, enterEventType, eventTypePrefix;
  9263. if (topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_MOUSE_OVER) {
  9264. eventInterface = SyntheticMouseEvent;
  9265. leaveEventType = eventTypes$3.mouseLeave;
  9266. enterEventType = eventTypes$3.mouseEnter;
  9267. eventTypePrefix = 'mouse';
  9268. } else if (topLevelType === TOP_POINTER_OUT || topLevelType === TOP_POINTER_OVER) {
  9269. eventInterface = SyntheticPointerEvent;
  9270. leaveEventType = eventTypes$3.pointerLeave;
  9271. enterEventType = eventTypes$3.pointerEnter;
  9272. eventTypePrefix = 'pointer';
  9273. }
  9274. var fromNode = from == null ? win : getNodeFromInstance$1(from);
  9275. var toNode = to == null ? win : getNodeFromInstance$1(to);
  9276. var leave = eventInterface.getPooled(leaveEventType, from, nativeEvent, nativeEventTarget);
  9277. leave.type = eventTypePrefix + 'leave';
  9278. leave.target = fromNode;
  9279. leave.relatedTarget = toNode;
  9280. var enter = eventInterface.getPooled(enterEventType, to, nativeEvent, nativeEventTarget);
  9281. enter.type = eventTypePrefix + 'enter';
  9282. enter.target = toNode;
  9283. enter.relatedTarget = fromNode;
  9284. accumulateEnterLeaveDispatches(leave, enter, from, to);
  9285. if (nativeEvent === lastNativeEvent) {
  9286. lastNativeEvent = null;
  9287. return [leave];
  9288. }
  9289. lastNativeEvent = nativeEvent;
  9290. return [leave, enter];
  9291. }
  9292. };
  9293. /**
  9294. * inlined Object.is polyfill to avoid requiring consumers ship their own
  9295. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  9296. */
  9297. function is(x, y) {
  9298. return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
  9299. ;
  9300. }
  9301. var is$1 = typeof Object.is === 'function' ? Object.is : is;
  9302. var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
  9303. /**
  9304. * Performs equality by iterating through keys on an object and returning false
  9305. * when any key has values which are not strictly equal between the arguments.
  9306. * Returns true when the values of all keys are strictly equal.
  9307. */
  9308. function shallowEqual(objA, objB) {
  9309. if (is$1(objA, objB)) {
  9310. return true;
  9311. }
  9312. if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
  9313. return false;
  9314. }
  9315. var keysA = Object.keys(objA);
  9316. var keysB = Object.keys(objB);
  9317. if (keysA.length !== keysB.length) {
  9318. return false;
  9319. } // Test for A's keys different from B.
  9320. for (var i = 0; i < keysA.length; i++) {
  9321. if (!hasOwnProperty$2.call(objB, keysA[i]) || !is$1(objA[keysA[i]], objB[keysA[i]])) {
  9322. return false;
  9323. }
  9324. }
  9325. return true;
  9326. }
  9327. var skipSelectionChangeEvent = canUseDOM && 'documentMode' in document && document.documentMode <= 11;
  9328. var eventTypes$4 = {
  9329. select: {
  9330. phasedRegistrationNames: {
  9331. bubbled: 'onSelect',
  9332. captured: 'onSelectCapture'
  9333. },
  9334. dependencies: [TOP_BLUR, TOP_CONTEXT_MENU, TOP_DRAG_END, TOP_FOCUS, TOP_KEY_DOWN, TOP_KEY_UP, TOP_MOUSE_DOWN, TOP_MOUSE_UP, TOP_SELECTION_CHANGE]
  9335. }
  9336. };
  9337. var activeElement$1 = null;
  9338. var activeElementInst$1 = null;
  9339. var lastSelection = null;
  9340. var mouseDown = false;
  9341. /**
  9342. * Get an object which is a unique representation of the current selection.
  9343. *
  9344. * The return value will not be consistent across nodes or browsers, but
  9345. * two identical selections on the same node will return identical objects.
  9346. *
  9347. * @param {DOMElement} node
  9348. * @return {object}
  9349. */
  9350. function getSelection$1(node) {
  9351. if ('selectionStart' in node && hasSelectionCapabilities(node)) {
  9352. return {
  9353. start: node.selectionStart,
  9354. end: node.selectionEnd
  9355. };
  9356. } else {
  9357. var win = node.ownerDocument && node.ownerDocument.defaultView || window;
  9358. var selection = win.getSelection();
  9359. return {
  9360. anchorNode: selection.anchorNode,
  9361. anchorOffset: selection.anchorOffset,
  9362. focusNode: selection.focusNode,
  9363. focusOffset: selection.focusOffset
  9364. };
  9365. }
  9366. }
  9367. /**
  9368. * Get document associated with the event target.
  9369. *
  9370. * @param {object} nativeEventTarget
  9371. * @return {Document}
  9372. */
  9373. function getEventTargetDocument(eventTarget) {
  9374. return eventTarget.window === eventTarget ? eventTarget.document : eventTarget.nodeType === DOCUMENT_NODE ? eventTarget : eventTarget.ownerDocument;
  9375. }
  9376. /**
  9377. * Poll selection to see whether it's changed.
  9378. *
  9379. * @param {object} nativeEvent
  9380. * @param {object} nativeEventTarget
  9381. * @return {?SyntheticEvent}
  9382. */
  9383. function constructSelectEvent(nativeEvent, nativeEventTarget) {
  9384. // Ensure we have the right element, and that the user is not dragging a
  9385. // selection (this matches native `select` event behavior). In HTML5, select
  9386. // fires only on input and textarea thus if there's no focused element we
  9387. // won't dispatch.
  9388. var doc = getEventTargetDocument(nativeEventTarget);
  9389. if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement(doc)) {
  9390. return null;
  9391. } // Only fire when selection has actually changed.
  9392. var currentSelection = getSelection$1(activeElement$1);
  9393. if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
  9394. lastSelection = currentSelection;
  9395. var syntheticEvent = SyntheticEvent.getPooled(eventTypes$4.select, activeElementInst$1, nativeEvent, nativeEventTarget);
  9396. syntheticEvent.type = 'select';
  9397. syntheticEvent.target = activeElement$1;
  9398. accumulateTwoPhaseDispatches(syntheticEvent);
  9399. return syntheticEvent;
  9400. }
  9401. return null;
  9402. }
  9403. /**
  9404. * This plugin creates an `onSelect` event that normalizes select events
  9405. * across form elements.
  9406. *
  9407. * Supported elements are:
  9408. * - input (see `isTextInputElement`)
  9409. * - textarea
  9410. * - contentEditable
  9411. *
  9412. * This differs from native browser implementations in the following ways:
  9413. * - Fires on contentEditable fields as well as inputs.
  9414. * - Fires for collapsed selection.
  9415. * - Fires after user input.
  9416. */
  9417. var SelectEventPlugin = {
  9418. eventTypes: eventTypes$4,
  9419. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) {
  9420. var doc = getEventTargetDocument(nativeEventTarget); // Track whether all listeners exists for this plugin. If none exist, we do
  9421. // not extract events. See #3639.
  9422. if (!doc || !isListeningToAllDependencies('onSelect', doc)) {
  9423. return null;
  9424. }
  9425. var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window;
  9426. switch (topLevelType) {
  9427. // Track the input node that has focus.
  9428. case TOP_FOCUS:
  9429. if (isTextInputElement(targetNode) || targetNode.contentEditable === 'true') {
  9430. activeElement$1 = targetNode;
  9431. activeElementInst$1 = targetInst;
  9432. lastSelection = null;
  9433. }
  9434. break;
  9435. case TOP_BLUR:
  9436. activeElement$1 = null;
  9437. activeElementInst$1 = null;
  9438. lastSelection = null;
  9439. break;
  9440. // Don't fire the event while the user is dragging. This matches the
  9441. // semantics of the native select event.
  9442. case TOP_MOUSE_DOWN:
  9443. mouseDown = true;
  9444. break;
  9445. case TOP_CONTEXT_MENU:
  9446. case TOP_MOUSE_UP:
  9447. case TOP_DRAG_END:
  9448. mouseDown = false;
  9449. return constructSelectEvent(nativeEvent, nativeEventTarget);
  9450. // Chrome and IE fire non-standard event when selection is changed (and
  9451. // sometimes when it hasn't). IE's event fires out of order with respect
  9452. // to key and input events on deletion, so we discard it.
  9453. //
  9454. // Firefox doesn't support selectionchange, so check selection status
  9455. // after each key entry. The selection changes after keydown and before
  9456. // keyup, but we check on keydown as well in the case of holding down a
  9457. // key, when multiple keydown events are fired but only one keyup is.
  9458. // This is also our approach for IE handling, for the reason above.
  9459. case TOP_SELECTION_CHANGE:
  9460. if (skipSelectionChangeEvent) {
  9461. break;
  9462. }
  9463. // falls through
  9464. case TOP_KEY_DOWN:
  9465. case TOP_KEY_UP:
  9466. return constructSelectEvent(nativeEvent, nativeEventTarget);
  9467. }
  9468. return null;
  9469. }
  9470. };
  9471. /**
  9472. * Inject modules for resolving DOM hierarchy and plugin ordering.
  9473. */
  9474. injection.injectEventPluginOrder(DOMEventPluginOrder);
  9475. setComponentTree(getFiberCurrentPropsFromNode$1, getInstanceFromNode$1, getNodeFromInstance$1);
  9476. /**
  9477. * Some important event plugins included by default (without having to require
  9478. * them).
  9479. */
  9480. injection.injectEventPluginsByName({
  9481. SimpleEventPlugin: SimpleEventPlugin,
  9482. EnterLeaveEventPlugin: EnterLeaveEventPlugin,
  9483. ChangeEventPlugin: ChangeEventPlugin,
  9484. SelectEventPlugin: SelectEventPlugin,
  9485. BeforeInputEventPlugin: BeforeInputEventPlugin
  9486. });
  9487. // Prefix measurements so that it's possible to filter them.
  9488. // Longer prefixes are hard to read in DevTools.
  9489. var reactEmoji = "\u269B";
  9490. var warningEmoji = "\u26D4";
  9491. var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function'; // Keep track of current fiber so that we know the path to unwind on pause.
  9492. // TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them?
  9493. var currentFiber = null; // If we're in the middle of user code, which fiber and method is it?
  9494. // Reusing `currentFiber` would be confusing for this because user code fiber
  9495. // can change during commit phase too, but we don't need to unwind it (since
  9496. // lifecycles in the commit phase don't resemble a tree).
  9497. var currentPhase = null;
  9498. var currentPhaseFiber = null; // Did lifecycle hook schedule an update? This is often a performance problem,
  9499. // so we will keep track of it, and include it in the report.
  9500. // Track commits caused by cascading updates.
  9501. var isCommitting = false;
  9502. var hasScheduledUpdateInCurrentCommit = false;
  9503. var hasScheduledUpdateInCurrentPhase = false;
  9504. var commitCountInCurrentWorkLoop = 0;
  9505. var effectCountInCurrentCommit = 0;
  9506. // to avoid stretch the commit phase with measurement overhead.
  9507. var labelsInCurrentCommit = new Set();
  9508. var formatMarkName = function (markName) {
  9509. return reactEmoji + " " + markName;
  9510. };
  9511. var formatLabel = function (label, warning) {
  9512. var prefix = warning ? warningEmoji + " " : reactEmoji + " ";
  9513. var suffix = warning ? " Warning: " + warning : '';
  9514. return "" + prefix + label + suffix;
  9515. };
  9516. var beginMark = function (markName) {
  9517. performance.mark(formatMarkName(markName));
  9518. };
  9519. var clearMark = function (markName) {
  9520. performance.clearMarks(formatMarkName(markName));
  9521. };
  9522. var endMark = function (label, markName, warning) {
  9523. var formattedMarkName = formatMarkName(markName);
  9524. var formattedLabel = formatLabel(label, warning);
  9525. try {
  9526. performance.measure(formattedLabel, formattedMarkName);
  9527. } catch (err) {} // If previous mark was missing for some reason, this will throw.
  9528. // This could only happen if React crashed in an unexpected place earlier.
  9529. // Don't pile on with more errors.
  9530. // Clear marks immediately to avoid growing buffer.
  9531. performance.clearMarks(formattedMarkName);
  9532. performance.clearMeasures(formattedLabel);
  9533. };
  9534. var getFiberMarkName = function (label, debugID) {
  9535. return label + " (#" + debugID + ")";
  9536. };
  9537. var getFiberLabel = function (componentName, isMounted, phase) {
  9538. if (phase === null) {
  9539. // These are composite component total time measurements.
  9540. return componentName + " [" + (isMounted ? 'update' : 'mount') + "]";
  9541. } else {
  9542. // Composite component methods.
  9543. return componentName + "." + phase;
  9544. }
  9545. };
  9546. var beginFiberMark = function (fiber, phase) {
  9547. var componentName = getComponentName(fiber.type) || 'Unknown';
  9548. var debugID = fiber._debugID;
  9549. var isMounted = fiber.alternate !== null;
  9550. var label = getFiberLabel(componentName, isMounted, phase);
  9551. if (isCommitting && labelsInCurrentCommit.has(label)) {
  9552. // During the commit phase, we don't show duplicate labels because
  9553. // there is a fixed overhead for every measurement, and we don't
  9554. // want to stretch the commit phase beyond necessary.
  9555. return false;
  9556. }
  9557. labelsInCurrentCommit.add(label);
  9558. var markName = getFiberMarkName(label, debugID);
  9559. beginMark(markName);
  9560. return true;
  9561. };
  9562. var clearFiberMark = function (fiber, phase) {
  9563. var componentName = getComponentName(fiber.type) || 'Unknown';
  9564. var debugID = fiber._debugID;
  9565. var isMounted = fiber.alternate !== null;
  9566. var label = getFiberLabel(componentName, isMounted, phase);
  9567. var markName = getFiberMarkName(label, debugID);
  9568. clearMark(markName);
  9569. };
  9570. var endFiberMark = function (fiber, phase, warning) {
  9571. var componentName = getComponentName(fiber.type) || 'Unknown';
  9572. var debugID = fiber._debugID;
  9573. var isMounted = fiber.alternate !== null;
  9574. var label = getFiberLabel(componentName, isMounted, phase);
  9575. var markName = getFiberMarkName(label, debugID);
  9576. endMark(label, markName, warning);
  9577. };
  9578. var shouldIgnoreFiber = function (fiber) {
  9579. // Host components should be skipped in the timeline.
  9580. // We could check typeof fiber.type, but does this work with RN?
  9581. switch (fiber.tag) {
  9582. case HostRoot:
  9583. case HostComponent:
  9584. case HostText:
  9585. case HostPortal:
  9586. case Fragment:
  9587. case ContextProvider:
  9588. case ContextConsumer:
  9589. case Mode:
  9590. return true;
  9591. default:
  9592. return false;
  9593. }
  9594. };
  9595. var clearPendingPhaseMeasurement = function () {
  9596. if (currentPhase !== null && currentPhaseFiber !== null) {
  9597. clearFiberMark(currentPhaseFiber, currentPhase);
  9598. }
  9599. currentPhaseFiber = null;
  9600. currentPhase = null;
  9601. hasScheduledUpdateInCurrentPhase = false;
  9602. };
  9603. var pauseTimers = function () {
  9604. // Stops all currently active measurements so that they can be resumed
  9605. // if we continue in a later deferred loop from the same unit of work.
  9606. var fiber = currentFiber;
  9607. while (fiber) {
  9608. if (fiber._debugIsCurrentlyTiming) {
  9609. endFiberMark(fiber, null, null);
  9610. }
  9611. fiber = fiber.return;
  9612. }
  9613. };
  9614. var resumeTimersRecursively = function (fiber) {
  9615. if (fiber.return !== null) {
  9616. resumeTimersRecursively(fiber.return);
  9617. }
  9618. if (fiber._debugIsCurrentlyTiming) {
  9619. beginFiberMark(fiber, null);
  9620. }
  9621. };
  9622. var resumeTimers = function () {
  9623. // Resumes all measurements that were active during the last deferred loop.
  9624. if (currentFiber !== null) {
  9625. resumeTimersRecursively(currentFiber);
  9626. }
  9627. };
  9628. function recordEffect() {
  9629. if (enableUserTimingAPI) {
  9630. effectCountInCurrentCommit++;
  9631. }
  9632. }
  9633. function recordScheduleUpdate() {
  9634. if (enableUserTimingAPI) {
  9635. if (isCommitting) {
  9636. hasScheduledUpdateInCurrentCommit = true;
  9637. }
  9638. if (currentPhase !== null && currentPhase !== 'componentWillMount' && currentPhase !== 'componentWillReceiveProps') {
  9639. hasScheduledUpdateInCurrentPhase = true;
  9640. }
  9641. }
  9642. }
  9643. function startWorkTimer(fiber) {
  9644. if (enableUserTimingAPI) {
  9645. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  9646. return;
  9647. } // If we pause, this is the fiber to unwind from.
  9648. currentFiber = fiber;
  9649. if (!beginFiberMark(fiber, null)) {
  9650. return;
  9651. }
  9652. fiber._debugIsCurrentlyTiming = true;
  9653. }
  9654. }
  9655. function cancelWorkTimer(fiber) {
  9656. if (enableUserTimingAPI) {
  9657. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  9658. return;
  9659. } // Remember we shouldn't complete measurement for this fiber.
  9660. // Otherwise flamechart will be deep even for small updates.
  9661. fiber._debugIsCurrentlyTiming = false;
  9662. clearFiberMark(fiber, null);
  9663. }
  9664. }
  9665. function stopWorkTimer(fiber) {
  9666. if (enableUserTimingAPI) {
  9667. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  9668. return;
  9669. } // If we pause, its parent is the fiber to unwind from.
  9670. currentFiber = fiber.return;
  9671. if (!fiber._debugIsCurrentlyTiming) {
  9672. return;
  9673. }
  9674. fiber._debugIsCurrentlyTiming = false;
  9675. endFiberMark(fiber, null, null);
  9676. }
  9677. }
  9678. function stopFailedWorkTimer(fiber) {
  9679. if (enableUserTimingAPI) {
  9680. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  9681. return;
  9682. } // If we pause, its parent is the fiber to unwind from.
  9683. currentFiber = fiber.return;
  9684. if (!fiber._debugIsCurrentlyTiming) {
  9685. return;
  9686. }
  9687. fiber._debugIsCurrentlyTiming = false;
  9688. var warning = fiber.tag === SuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
  9689. endFiberMark(fiber, null, warning);
  9690. }
  9691. }
  9692. function startPhaseTimer(fiber, phase) {
  9693. if (enableUserTimingAPI) {
  9694. if (!supportsUserTiming) {
  9695. return;
  9696. }
  9697. clearPendingPhaseMeasurement();
  9698. if (!beginFiberMark(fiber, phase)) {
  9699. return;
  9700. }
  9701. currentPhaseFiber = fiber;
  9702. currentPhase = phase;
  9703. }
  9704. }
  9705. function stopPhaseTimer() {
  9706. if (enableUserTimingAPI) {
  9707. if (!supportsUserTiming) {
  9708. return;
  9709. }
  9710. if (currentPhase !== null && currentPhaseFiber !== null) {
  9711. var warning = hasScheduledUpdateInCurrentPhase ? 'Scheduled a cascading update' : null;
  9712. endFiberMark(currentPhaseFiber, currentPhase, warning);
  9713. }
  9714. currentPhase = null;
  9715. currentPhaseFiber = null;
  9716. }
  9717. }
  9718. function startWorkLoopTimer(nextUnitOfWork) {
  9719. if (enableUserTimingAPI) {
  9720. currentFiber = nextUnitOfWork;
  9721. if (!supportsUserTiming) {
  9722. return;
  9723. }
  9724. commitCountInCurrentWorkLoop = 0; // This is top level call.
  9725. // Any other measurements are performed within.
  9726. beginMark('(React Tree Reconciliation)'); // Resume any measurements that were in progress during the last loop.
  9727. resumeTimers();
  9728. }
  9729. }
  9730. function stopWorkLoopTimer(interruptedBy, didCompleteRoot) {
  9731. if (enableUserTimingAPI) {
  9732. if (!supportsUserTiming) {
  9733. return;
  9734. }
  9735. var warning = null;
  9736. if (interruptedBy !== null) {
  9737. if (interruptedBy.tag === HostRoot) {
  9738. warning = 'A top-level update interrupted the previous render';
  9739. } else {
  9740. var componentName = getComponentName(interruptedBy.type) || 'Unknown';
  9741. warning = "An update to " + componentName + " interrupted the previous render";
  9742. }
  9743. } else if (commitCountInCurrentWorkLoop > 1) {
  9744. warning = 'There were cascading updates';
  9745. }
  9746. commitCountInCurrentWorkLoop = 0;
  9747. var label = didCompleteRoot ? '(React Tree Reconciliation: Completed Root)' : '(React Tree Reconciliation: Yielded)'; // Pause any measurements until the next loop.
  9748. pauseTimers();
  9749. endMark(label, '(React Tree Reconciliation)', warning);
  9750. }
  9751. }
  9752. function startCommitTimer() {
  9753. if (enableUserTimingAPI) {
  9754. if (!supportsUserTiming) {
  9755. return;
  9756. }
  9757. isCommitting = true;
  9758. hasScheduledUpdateInCurrentCommit = false;
  9759. labelsInCurrentCommit.clear();
  9760. beginMark('(Committing Changes)');
  9761. }
  9762. }
  9763. function stopCommitTimer() {
  9764. if (enableUserTimingAPI) {
  9765. if (!supportsUserTiming) {
  9766. return;
  9767. }
  9768. var warning = null;
  9769. if (hasScheduledUpdateInCurrentCommit) {
  9770. warning = 'Lifecycle hook scheduled a cascading update';
  9771. } else if (commitCountInCurrentWorkLoop > 0) {
  9772. warning = 'Caused by a cascading update in earlier commit';
  9773. }
  9774. hasScheduledUpdateInCurrentCommit = false;
  9775. commitCountInCurrentWorkLoop++;
  9776. isCommitting = false;
  9777. labelsInCurrentCommit.clear();
  9778. endMark('(Committing Changes)', '(Committing Changes)', warning);
  9779. }
  9780. }
  9781. function startCommitSnapshotEffectsTimer() {
  9782. if (enableUserTimingAPI) {
  9783. if (!supportsUserTiming) {
  9784. return;
  9785. }
  9786. effectCountInCurrentCommit = 0;
  9787. beginMark('(Committing Snapshot Effects)');
  9788. }
  9789. }
  9790. function stopCommitSnapshotEffectsTimer() {
  9791. if (enableUserTimingAPI) {
  9792. if (!supportsUserTiming) {
  9793. return;
  9794. }
  9795. var count = effectCountInCurrentCommit;
  9796. effectCountInCurrentCommit = 0;
  9797. endMark("(Committing Snapshot Effects: " + count + " Total)", '(Committing Snapshot Effects)', null);
  9798. }
  9799. }
  9800. function startCommitHostEffectsTimer() {
  9801. if (enableUserTimingAPI) {
  9802. if (!supportsUserTiming) {
  9803. return;
  9804. }
  9805. effectCountInCurrentCommit = 0;
  9806. beginMark('(Committing Host Effects)');
  9807. }
  9808. }
  9809. function stopCommitHostEffectsTimer() {
  9810. if (enableUserTimingAPI) {
  9811. if (!supportsUserTiming) {
  9812. return;
  9813. }
  9814. var count = effectCountInCurrentCommit;
  9815. effectCountInCurrentCommit = 0;
  9816. endMark("(Committing Host Effects: " + count + " Total)", '(Committing Host Effects)', null);
  9817. }
  9818. }
  9819. function startCommitLifeCyclesTimer() {
  9820. if (enableUserTimingAPI) {
  9821. if (!supportsUserTiming) {
  9822. return;
  9823. }
  9824. effectCountInCurrentCommit = 0;
  9825. beginMark('(Calling Lifecycle Methods)');
  9826. }
  9827. }
  9828. function stopCommitLifeCyclesTimer() {
  9829. if (enableUserTimingAPI) {
  9830. if (!supportsUserTiming) {
  9831. return;
  9832. }
  9833. var count = effectCountInCurrentCommit;
  9834. effectCountInCurrentCommit = 0;
  9835. endMark("(Calling Lifecycle Methods: " + count + " Total)", '(Calling Lifecycle Methods)', null);
  9836. }
  9837. }
  9838. var valueStack = [];
  9839. var fiberStack;
  9840. {
  9841. fiberStack = [];
  9842. }
  9843. var index = -1;
  9844. function createCursor(defaultValue) {
  9845. return {
  9846. current: defaultValue
  9847. };
  9848. }
  9849. function pop(cursor, fiber) {
  9850. if (index < 0) {
  9851. {
  9852. warningWithoutStack$1(false, 'Unexpected pop.');
  9853. }
  9854. return;
  9855. }
  9856. {
  9857. if (fiber !== fiberStack[index]) {
  9858. warningWithoutStack$1(false, 'Unexpected Fiber popped.');
  9859. }
  9860. }
  9861. cursor.current = valueStack[index];
  9862. valueStack[index] = null;
  9863. {
  9864. fiberStack[index] = null;
  9865. }
  9866. index--;
  9867. }
  9868. function push(cursor, value, fiber) {
  9869. index++;
  9870. valueStack[index] = cursor.current;
  9871. {
  9872. fiberStack[index] = fiber;
  9873. }
  9874. cursor.current = value;
  9875. }
  9876. var warnedAboutMissingGetChildContext;
  9877. {
  9878. warnedAboutMissingGetChildContext = {};
  9879. }
  9880. var emptyContextObject = {};
  9881. {
  9882. Object.freeze(emptyContextObject);
  9883. } // A cursor to the current merged context object on the stack.
  9884. var contextStackCursor = createCursor(emptyContextObject); // A cursor to a boolean indicating whether the context has changed.
  9885. var didPerformWorkStackCursor = createCursor(false); // Keep track of the previous context object that was on the stack.
  9886. // We use this to get access to the parent context after we have already
  9887. // pushed the next context provider, and now need to merge their contexts.
  9888. var previousContext = emptyContextObject;
  9889. function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) {
  9890. if (disableLegacyContext) {
  9891. return emptyContextObject;
  9892. } else {
  9893. if (didPushOwnContextIfProvider && isContextProvider(Component)) {
  9894. // If the fiber is a context provider itself, when we read its context
  9895. // we may have already pushed its own child context on the stack. A context
  9896. // provider should not "see" its own child context. Therefore we read the
  9897. // previous (parent) context instead for a context provider.
  9898. return previousContext;
  9899. }
  9900. return contextStackCursor.current;
  9901. }
  9902. }
  9903. function cacheContext(workInProgress, unmaskedContext, maskedContext) {
  9904. if (disableLegacyContext) {
  9905. return;
  9906. } else {
  9907. var instance = workInProgress.stateNode;
  9908. instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
  9909. instance.__reactInternalMemoizedMaskedChildContext = maskedContext;
  9910. }
  9911. }
  9912. function getMaskedContext(workInProgress, unmaskedContext) {
  9913. if (disableLegacyContext) {
  9914. return emptyContextObject;
  9915. } else {
  9916. var type = workInProgress.type;
  9917. var contextTypes = type.contextTypes;
  9918. if (!contextTypes) {
  9919. return emptyContextObject;
  9920. } // Avoid recreating masked context unless unmasked context has changed.
  9921. // Failing to do this will result in unnecessary calls to componentWillReceiveProps.
  9922. // This may trigger infinite loops if componentWillReceiveProps calls setState.
  9923. var instance = workInProgress.stateNode;
  9924. if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
  9925. return instance.__reactInternalMemoizedMaskedChildContext;
  9926. }
  9927. var context = {};
  9928. for (var key in contextTypes) {
  9929. context[key] = unmaskedContext[key];
  9930. }
  9931. {
  9932. var name = getComponentName(type) || 'Unknown';
  9933. checkPropTypes(contextTypes, context, 'context', name, getCurrentFiberStackInDev);
  9934. } // Cache unmasked context so we can avoid recreating masked context unless necessary.
  9935. // Context is created before the class component is instantiated so check for instance.
  9936. if (instance) {
  9937. cacheContext(workInProgress, unmaskedContext, context);
  9938. }
  9939. return context;
  9940. }
  9941. }
  9942. function hasContextChanged() {
  9943. if (disableLegacyContext) {
  9944. return false;
  9945. } else {
  9946. return didPerformWorkStackCursor.current;
  9947. }
  9948. }
  9949. function isContextProvider(type) {
  9950. if (disableLegacyContext) {
  9951. return false;
  9952. } else {
  9953. var childContextTypes = type.childContextTypes;
  9954. return childContextTypes !== null && childContextTypes !== undefined;
  9955. }
  9956. }
  9957. function popContext(fiber) {
  9958. if (disableLegacyContext) {
  9959. return;
  9960. } else {
  9961. pop(didPerformWorkStackCursor, fiber);
  9962. pop(contextStackCursor, fiber);
  9963. }
  9964. }
  9965. function popTopLevelContextObject(fiber) {
  9966. if (disableLegacyContext) {
  9967. return;
  9968. } else {
  9969. pop(didPerformWorkStackCursor, fiber);
  9970. pop(contextStackCursor, fiber);
  9971. }
  9972. }
  9973. function pushTopLevelContextObject(fiber, context, didChange) {
  9974. if (disableLegacyContext) {
  9975. return;
  9976. } else {
  9977. if (!(contextStackCursor.current === emptyContextObject)) {
  9978. {
  9979. throw Error("Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue.");
  9980. }
  9981. }
  9982. push(contextStackCursor, context, fiber);
  9983. push(didPerformWorkStackCursor, didChange, fiber);
  9984. }
  9985. }
  9986. function processChildContext(fiber, type, parentContext) {
  9987. if (disableLegacyContext) {
  9988. return parentContext;
  9989. } else {
  9990. var instance = fiber.stateNode;
  9991. var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future.
  9992. // It has only been added in Fiber to match the (unintentional) behavior in Stack.
  9993. if (typeof instance.getChildContext !== 'function') {
  9994. {
  9995. var componentName = getComponentName(type) || 'Unknown';
  9996. if (!warnedAboutMissingGetChildContext[componentName]) {
  9997. warnedAboutMissingGetChildContext[componentName] = true;
  9998. warningWithoutStack$1(false, '%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName);
  9999. }
  10000. }
  10001. return parentContext;
  10002. }
  10003. var childContext;
  10004. {
  10005. setCurrentPhase('getChildContext');
  10006. }
  10007. startPhaseTimer(fiber, 'getChildContext');
  10008. childContext = instance.getChildContext();
  10009. stopPhaseTimer();
  10010. {
  10011. setCurrentPhase(null);
  10012. }
  10013. for (var contextKey in childContext) {
  10014. if (!(contextKey in childContextTypes)) {
  10015. {
  10016. throw Error((getComponentName(type) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes.");
  10017. }
  10018. }
  10019. }
  10020. {
  10021. var name = getComponentName(type) || 'Unknown';
  10022. checkPropTypes(childContextTypes, childContext, 'child context', name, // In practice, there is one case in which we won't get a stack. It's when
  10023. // somebody calls unstable_renderSubtreeIntoContainer() and we process
  10024. // context from the parent component instance. The stack will be missing
  10025. // because it's outside of the reconciliation, and so the pointer has not
  10026. // been set. This is rare and doesn't matter. We'll also remove that API.
  10027. getCurrentFiberStackInDev);
  10028. }
  10029. return _assign({}, parentContext, {}, childContext);
  10030. }
  10031. }
  10032. function pushContextProvider(workInProgress) {
  10033. if (disableLegacyContext) {
  10034. return false;
  10035. } else {
  10036. var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity.
  10037. // If the instance does not exist yet, we will push null at first,
  10038. // and replace it on the stack later when invalidating the context.
  10039. var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject; // Remember the parent context so we can merge with it later.
  10040. // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates.
  10041. previousContext = contextStackCursor.current;
  10042. push(contextStackCursor, memoizedMergedChildContext, workInProgress);
  10043. push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress);
  10044. return true;
  10045. }
  10046. }
  10047. function invalidateContextProvider(workInProgress, type, didChange) {
  10048. if (disableLegacyContext) {
  10049. return;
  10050. } else {
  10051. var instance = workInProgress.stateNode;
  10052. if (!instance) {
  10053. {
  10054. throw Error("Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue.");
  10055. }
  10056. }
  10057. if (didChange) {
  10058. // Merge parent and own context.
  10059. // Skip this if we're not updating due to sCU.
  10060. // This avoids unnecessarily recomputing memoized values.
  10061. var mergedContext = processChildContext(workInProgress, type, previousContext);
  10062. instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one.
  10063. // It is important to unwind the context in the reverse order.
  10064. pop(didPerformWorkStackCursor, workInProgress);
  10065. pop(contextStackCursor, workInProgress); // Now push the new context and mark that it has changed.
  10066. push(contextStackCursor, mergedContext, workInProgress);
  10067. push(didPerformWorkStackCursor, didChange, workInProgress);
  10068. } else {
  10069. pop(didPerformWorkStackCursor, workInProgress);
  10070. push(didPerformWorkStackCursor, didChange, workInProgress);
  10071. }
  10072. }
  10073. }
  10074. function findCurrentUnmaskedContext(fiber) {
  10075. if (disableLegacyContext) {
  10076. return emptyContextObject;
  10077. } else {
  10078. // Currently this is only used with renderSubtreeIntoContainer; not sure if it
  10079. // makes sense elsewhere
  10080. if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) {
  10081. {
  10082. throw Error("Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue.");
  10083. }
  10084. }
  10085. var node = fiber;
  10086. do {
  10087. switch (node.tag) {
  10088. case HostRoot:
  10089. return node.stateNode.context;
  10090. case ClassComponent:
  10091. {
  10092. var Component = node.type;
  10093. if (isContextProvider(Component)) {
  10094. return node.stateNode.__reactInternalMemoizedMergedChildContext;
  10095. }
  10096. break;
  10097. }
  10098. }
  10099. node = node.return;
  10100. } while (node !== null);
  10101. {
  10102. {
  10103. throw Error("Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue.");
  10104. }
  10105. }
  10106. }
  10107. }
  10108. var LegacyRoot = 0;
  10109. var BlockingRoot = 1;
  10110. var ConcurrentRoot = 2;
  10111. // Intentionally not named imports because Rollup would use dynamic dispatch for
  10112. // CommonJS interop named imports.
  10113. var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority;
  10114. var Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback;
  10115. var Scheduler_cancelCallback = Scheduler.unstable_cancelCallback;
  10116. var Scheduler_shouldYield = Scheduler.unstable_shouldYield;
  10117. var Scheduler_requestPaint = Scheduler.unstable_requestPaint;
  10118. var Scheduler_now = Scheduler.unstable_now;
  10119. var Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel;
  10120. var Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority;
  10121. var Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority;
  10122. var Scheduler_NormalPriority = Scheduler.unstable_NormalPriority;
  10123. var Scheduler_LowPriority = Scheduler.unstable_LowPriority;
  10124. var Scheduler_IdlePriority = Scheduler.unstable_IdlePriority;
  10125. if (enableSchedulerTracing) {
  10126. // Provide explicit error message when production+profiling bundle of e.g.
  10127. // react-dom is used with production (non-profiling) bundle of
  10128. // scheduler/tracing
  10129. if (!(tracing.__interactionsRef != null && tracing.__interactionsRef.current != null)) {
  10130. {
  10131. throw Error("It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling");
  10132. }
  10133. }
  10134. }
  10135. var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Scheduler priorities. We use
  10136. // ascending numbers so we can compare them like numbers. They start at 90 to
  10137. // avoid clashing with Scheduler's priorities.
  10138. var ImmediatePriority = 99;
  10139. var UserBlockingPriority$2 = 98;
  10140. var NormalPriority = 97;
  10141. var LowPriority = 96;
  10142. var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only.
  10143. var NoPriority = 90;
  10144. var shouldYield = Scheduler_shouldYield;
  10145. var requestPaint = // Fall back gracefully if we're running an older version of Scheduler.
  10146. Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function () {};
  10147. var syncQueue = null;
  10148. var immediateQueueCallbackNode = null;
  10149. var isFlushingSyncQueue = false;
  10150. var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly.
  10151. // This will be the case for modern browsers that support `performance.now`. In
  10152. // older browsers, Scheduler falls back to `Date.now`, which returns a Unix
  10153. // timestamp. In that case, subtract the module initialization time to simulate
  10154. // the behavior of performance.now and keep our times small enough to fit
  10155. // within 32 bits.
  10156. // TODO: Consider lifting this into Scheduler.
  10157. var now = initialTimeMs < 10000 ? Scheduler_now : function () {
  10158. return Scheduler_now() - initialTimeMs;
  10159. };
  10160. function getCurrentPriorityLevel() {
  10161. switch (Scheduler_getCurrentPriorityLevel()) {
  10162. case Scheduler_ImmediatePriority:
  10163. return ImmediatePriority;
  10164. case Scheduler_UserBlockingPriority:
  10165. return UserBlockingPriority$2;
  10166. case Scheduler_NormalPriority:
  10167. return NormalPriority;
  10168. case Scheduler_LowPriority:
  10169. return LowPriority;
  10170. case Scheduler_IdlePriority:
  10171. return IdlePriority;
  10172. default:
  10173. {
  10174. {
  10175. throw Error("Unknown priority level.");
  10176. }
  10177. }
  10178. }
  10179. }
  10180. function reactPriorityToSchedulerPriority(reactPriorityLevel) {
  10181. switch (reactPriorityLevel) {
  10182. case ImmediatePriority:
  10183. return Scheduler_ImmediatePriority;
  10184. case UserBlockingPriority$2:
  10185. return Scheduler_UserBlockingPriority;
  10186. case NormalPriority:
  10187. return Scheduler_NormalPriority;
  10188. case LowPriority:
  10189. return Scheduler_LowPriority;
  10190. case IdlePriority:
  10191. return Scheduler_IdlePriority;
  10192. default:
  10193. {
  10194. {
  10195. throw Error("Unknown priority level.");
  10196. }
  10197. }
  10198. }
  10199. }
  10200. function runWithPriority$2(reactPriorityLevel, fn) {
  10201. var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
  10202. return Scheduler_runWithPriority(priorityLevel, fn);
  10203. }
  10204. function scheduleCallback(reactPriorityLevel, callback, options) {
  10205. var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
  10206. return Scheduler_scheduleCallback(priorityLevel, callback, options);
  10207. }
  10208. function scheduleSyncCallback(callback) {
  10209. // Push this callback into an internal queue. We'll flush these either in
  10210. // the next tick, or earlier if something calls `flushSyncCallbackQueue`.
  10211. if (syncQueue === null) {
  10212. syncQueue = [callback]; // Flush the queue in the next tick, at the earliest.
  10213. immediateQueueCallbackNode = Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueueImpl);
  10214. } else {
  10215. // Push onto existing queue. Don't need to schedule a callback because
  10216. // we already scheduled one when we created the queue.
  10217. syncQueue.push(callback);
  10218. }
  10219. return fakeCallbackNode;
  10220. }
  10221. function cancelCallback(callbackNode) {
  10222. if (callbackNode !== fakeCallbackNode) {
  10223. Scheduler_cancelCallback(callbackNode);
  10224. }
  10225. }
  10226. function flushSyncCallbackQueue() {
  10227. if (immediateQueueCallbackNode !== null) {
  10228. var node = immediateQueueCallbackNode;
  10229. immediateQueueCallbackNode = null;
  10230. Scheduler_cancelCallback(node);
  10231. }
  10232. flushSyncCallbackQueueImpl();
  10233. }
  10234. function flushSyncCallbackQueueImpl() {
  10235. if (!isFlushingSyncQueue && syncQueue !== null) {
  10236. // Prevent re-entrancy.
  10237. isFlushingSyncQueue = true;
  10238. var i = 0;
  10239. try {
  10240. var _isSync = true;
  10241. var queue = syncQueue;
  10242. runWithPriority$2(ImmediatePriority, function () {
  10243. for (; i < queue.length; i++) {
  10244. var callback = queue[i];
  10245. do {
  10246. callback = callback(_isSync);
  10247. } while (callback !== null);
  10248. }
  10249. });
  10250. syncQueue = null;
  10251. } catch (error) {
  10252. // If something throws, leave the remaining callbacks on the queue.
  10253. if (syncQueue !== null) {
  10254. syncQueue = syncQueue.slice(i + 1);
  10255. } // Resume flushing in the next tick
  10256. Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueue);
  10257. throw error;
  10258. } finally {
  10259. isFlushingSyncQueue = false;
  10260. }
  10261. }
  10262. }
  10263. var NoMode = 0;
  10264. var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root
  10265. // tag instead
  10266. var BlockingMode = 2;
  10267. var ConcurrentMode = 4;
  10268. var ProfileMode = 8;
  10269. // Max 31 bit integer. The max integer size in V8 for 32-bit systems.
  10270. // Math.pow(2, 30) - 1
  10271. // 0b111111111111111111111111111111
  10272. var MAX_SIGNED_31_BIT_INT = 1073741823;
  10273. var NoWork = 0; // TODO: Think of a better name for Never. The key difference with Idle is that
  10274. // Never work can be committed in an inconsistent state without tearing the UI.
  10275. // The main example is offscreen content, like a hidden subtree. So one possible
  10276. // name is Offscreen. However, it also includes dehydrated Suspense boundaries,
  10277. // which are inconsistent in the sense that they haven't finished yet, but
  10278. // aren't visibly inconsistent because the server rendered HTML matches what the
  10279. // hydrated tree would look like.
  10280. var Never = 1; // Idle is slightly higher priority than Never. It must completely finish in
  10281. // order to be consistent.
  10282. var Idle = 2; // Continuous Hydration is a moving priority. It is slightly higher than Idle
  10283. // and is used to increase priority of hover targets. It is increasing with
  10284. // each usage so that last always wins.
  10285. var ContinuousHydration = 3;
  10286. var Sync = MAX_SIGNED_31_BIT_INT;
  10287. var Batched = Sync - 1;
  10288. var UNIT_SIZE = 10;
  10289. var MAGIC_NUMBER_OFFSET = Batched - 1; // 1 unit of expiration time represents 10ms.
  10290. function msToExpirationTime(ms) {
  10291. // Always add an offset so that we don't clash with the magic number for NoWork.
  10292. return MAGIC_NUMBER_OFFSET - (ms / UNIT_SIZE | 0);
  10293. }
  10294. function expirationTimeToMs(expirationTime) {
  10295. return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE;
  10296. }
  10297. function ceiling(num, precision) {
  10298. return ((num / precision | 0) + 1) * precision;
  10299. }
  10300. function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) {
  10301. return MAGIC_NUMBER_OFFSET - ceiling(MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE);
  10302. } // TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update
  10303. // the names to reflect.
  10304. var LOW_PRIORITY_EXPIRATION = 5000;
  10305. var LOW_PRIORITY_BATCH_SIZE = 250;
  10306. function computeAsyncExpiration(currentTime) {
  10307. return computeExpirationBucket(currentTime, LOW_PRIORITY_EXPIRATION, LOW_PRIORITY_BATCH_SIZE);
  10308. }
  10309. function computeSuspenseExpiration(currentTime, timeoutMs) {
  10310. // TODO: Should we warn if timeoutMs is lower than the normal pri expiration time?
  10311. return computeExpirationBucket(currentTime, timeoutMs, LOW_PRIORITY_BATCH_SIZE);
  10312. } // We intentionally set a higher expiration time for interactive updates in
  10313. // dev than in production.
  10314. //
  10315. // If the main thread is being blocked so long that you hit the expiration,
  10316. // it's a problem that could be solved with better scheduling.
  10317. //
  10318. // People will be more likely to notice this and fix it with the long
  10319. // expiration time in development.
  10320. //
  10321. // In production we opt for better UX at the risk of masking scheduling
  10322. // problems, by expiring fast.
  10323. var HIGH_PRIORITY_EXPIRATION = 500;
  10324. var HIGH_PRIORITY_BATCH_SIZE = 100;
  10325. function computeInteractiveExpiration(currentTime) {
  10326. return computeExpirationBucket(currentTime, HIGH_PRIORITY_EXPIRATION, HIGH_PRIORITY_BATCH_SIZE);
  10327. }
  10328. function computeContinuousHydrationExpiration(currentTime) {
  10329. // Each time we ask for a new one of these we increase the priority.
  10330. // This ensures that the last one always wins since we can't deprioritize
  10331. // once we've scheduled work already.
  10332. return ContinuousHydration++;
  10333. }
  10334. function inferPriorityFromExpirationTime(currentTime, expirationTime) {
  10335. if (expirationTime === Sync) {
  10336. return ImmediatePriority;
  10337. }
  10338. if (expirationTime === Never || expirationTime === Idle) {
  10339. return IdlePriority;
  10340. }
  10341. var msUntil = expirationTimeToMs(expirationTime) - expirationTimeToMs(currentTime);
  10342. if (msUntil <= 0) {
  10343. return ImmediatePriority;
  10344. }
  10345. if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) {
  10346. return UserBlockingPriority$2;
  10347. }
  10348. if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) {
  10349. return NormalPriority;
  10350. } // TODO: Handle LowPriority
  10351. // Assume anything lower has idle priority
  10352. return IdlePriority;
  10353. }
  10354. /**
  10355. * Forked from fbjs/warning:
  10356. * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
  10357. *
  10358. * Only change is we use console.warn instead of console.error,
  10359. * and do nothing when 'console' is not supported.
  10360. * This really simplifies the code.
  10361. * ---
  10362. * Similar to invariant but only logs a warning if the condition is not met.
  10363. * This can be used to log issues in development environments in critical
  10364. * paths. Removing the logging code for production environments will keep the
  10365. * same logic and follow the same code paths.
  10366. */
  10367. var lowPriorityWarningWithoutStack = function () {};
  10368. {
  10369. var printWarning = function (format) {
  10370. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  10371. args[_key - 1] = arguments[_key];
  10372. }
  10373. var argIndex = 0;
  10374. var message = 'Warning: ' + format.replace(/%s/g, function () {
  10375. return args[argIndex++];
  10376. });
  10377. if (typeof console !== 'undefined') {
  10378. console.warn(message);
  10379. }
  10380. try {
  10381. // --- Welcome to debugging React ---
  10382. // This error was thrown as a convenience so that you can use this stack
  10383. // to find the callsite that caused this warning to fire.
  10384. throw new Error(message);
  10385. } catch (x) {}
  10386. };
  10387. lowPriorityWarningWithoutStack = function (condition, format) {
  10388. if (format === undefined) {
  10389. throw new Error('`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
  10390. }
  10391. if (!condition) {
  10392. for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  10393. args[_key2 - 2] = arguments[_key2];
  10394. }
  10395. printWarning.apply(void 0, [format].concat(args));
  10396. }
  10397. };
  10398. }
  10399. var lowPriorityWarningWithoutStack$1 = lowPriorityWarningWithoutStack;
  10400. var ReactStrictModeWarnings = {
  10401. recordUnsafeLifecycleWarnings: function (fiber, instance) {},
  10402. flushPendingUnsafeLifecycleWarnings: function () {},
  10403. recordLegacyContextWarning: function (fiber, instance) {},
  10404. flushLegacyContextWarning: function () {},
  10405. discardPendingWarnings: function () {}
  10406. };
  10407. {
  10408. var findStrictRoot = function (fiber) {
  10409. var maybeStrictRoot = null;
  10410. var node = fiber;
  10411. while (node !== null) {
  10412. if (node.mode & StrictMode) {
  10413. maybeStrictRoot = node;
  10414. }
  10415. node = node.return;
  10416. }
  10417. return maybeStrictRoot;
  10418. };
  10419. var setToSortedString = function (set) {
  10420. var array = [];
  10421. set.forEach(function (value) {
  10422. array.push(value);
  10423. });
  10424. return array.sort().join(', ');
  10425. };
  10426. var pendingComponentWillMountWarnings = [];
  10427. var pendingUNSAFE_ComponentWillMountWarnings = [];
  10428. var pendingComponentWillReceivePropsWarnings = [];
  10429. var pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
  10430. var pendingComponentWillUpdateWarnings = [];
  10431. var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about.
  10432. var didWarnAboutUnsafeLifecycles = new Set();
  10433. ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) {
  10434. // Dedup strategy: Warn once per component.
  10435. if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
  10436. return;
  10437. }
  10438. if (typeof instance.componentWillMount === 'function' && // Don't warn about react-lifecycles-compat polyfilled components.
  10439. instance.componentWillMount.__suppressDeprecationWarning !== true) {
  10440. pendingComponentWillMountWarnings.push(fiber);
  10441. }
  10442. if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillMount === 'function') {
  10443. pendingUNSAFE_ComponentWillMountWarnings.push(fiber);
  10444. }
  10445. if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
  10446. pendingComponentWillReceivePropsWarnings.push(fiber);
  10447. }
  10448. if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  10449. pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber);
  10450. }
  10451. if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
  10452. pendingComponentWillUpdateWarnings.push(fiber);
  10453. }
  10454. if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillUpdate === 'function') {
  10455. pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber);
  10456. }
  10457. };
  10458. ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () {
  10459. // We do an initial pass to gather component names
  10460. var componentWillMountUniqueNames = new Set();
  10461. if (pendingComponentWillMountWarnings.length > 0) {
  10462. pendingComponentWillMountWarnings.forEach(function (fiber) {
  10463. componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component');
  10464. didWarnAboutUnsafeLifecycles.add(fiber.type);
  10465. });
  10466. pendingComponentWillMountWarnings = [];
  10467. }
  10468. var UNSAFE_componentWillMountUniqueNames = new Set();
  10469. if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) {
  10470. pendingUNSAFE_ComponentWillMountWarnings.forEach(function (fiber) {
  10471. UNSAFE_componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component');
  10472. didWarnAboutUnsafeLifecycles.add(fiber.type);
  10473. });
  10474. pendingUNSAFE_ComponentWillMountWarnings = [];
  10475. }
  10476. var componentWillReceivePropsUniqueNames = new Set();
  10477. if (pendingComponentWillReceivePropsWarnings.length > 0) {
  10478. pendingComponentWillReceivePropsWarnings.forEach(function (fiber) {
  10479. componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component');
  10480. didWarnAboutUnsafeLifecycles.add(fiber.type);
  10481. });
  10482. pendingComponentWillReceivePropsWarnings = [];
  10483. }
  10484. var UNSAFE_componentWillReceivePropsUniqueNames = new Set();
  10485. if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) {
  10486. pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function (fiber) {
  10487. UNSAFE_componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component');
  10488. didWarnAboutUnsafeLifecycles.add(fiber.type);
  10489. });
  10490. pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
  10491. }
  10492. var componentWillUpdateUniqueNames = new Set();
  10493. if (pendingComponentWillUpdateWarnings.length > 0) {
  10494. pendingComponentWillUpdateWarnings.forEach(function (fiber) {
  10495. componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component');
  10496. didWarnAboutUnsafeLifecycles.add(fiber.type);
  10497. });
  10498. pendingComponentWillUpdateWarnings = [];
  10499. }
  10500. var UNSAFE_componentWillUpdateUniqueNames = new Set();
  10501. if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) {
  10502. pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function (fiber) {
  10503. UNSAFE_componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component');
  10504. didWarnAboutUnsafeLifecycles.add(fiber.type);
  10505. });
  10506. pendingUNSAFE_ComponentWillUpdateWarnings = [];
  10507. } // Finally, we flush all the warnings
  10508. // UNSAFE_ ones before the deprecated ones, since they'll be 'louder'
  10509. if (UNSAFE_componentWillMountUniqueNames.size > 0) {
  10510. var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames);
  10511. warningWithoutStack$1(false, 'Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '\nPlease update the following components: %s', sortedNames);
  10512. }
  10513. if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) {
  10514. var _sortedNames = setToSortedString(UNSAFE_componentWillReceivePropsUniqueNames);
  10515. warningWithoutStack$1(false, 'Using UNSAFE_componentWillReceiveProps in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, " + 'refactor your code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n' + '\nPlease update the following components: %s', _sortedNames);
  10516. }
  10517. if (UNSAFE_componentWillUpdateUniqueNames.size > 0) {
  10518. var _sortedNames2 = setToSortedString(UNSAFE_componentWillUpdateUniqueNames);
  10519. warningWithoutStack$1(false, 'Using UNSAFE_componentWillUpdate in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '\nPlease update the following components: %s', _sortedNames2);
  10520. }
  10521. if (componentWillMountUniqueNames.size > 0) {
  10522. var _sortedNames3 = setToSortedString(componentWillMountUniqueNames);
  10523. lowPriorityWarningWithoutStack$1(false, 'componentWillMount has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '* Rename componentWillMount to UNSAFE_componentWillMount to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames3);
  10524. }
  10525. if (componentWillReceivePropsUniqueNames.size > 0) {
  10526. var _sortedNames4 = setToSortedString(componentWillReceivePropsUniqueNames);
  10527. lowPriorityWarningWithoutStack$1(false, 'componentWillReceiveProps has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, refactor your " + 'code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n' + '* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames4);
  10528. }
  10529. if (componentWillUpdateUniqueNames.size > 0) {
  10530. var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames);
  10531. lowPriorityWarningWithoutStack$1(false, 'componentWillUpdate has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames5);
  10532. }
  10533. };
  10534. var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about.
  10535. var didWarnAboutLegacyContext = new Set();
  10536. ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) {
  10537. var strictRoot = findStrictRoot(fiber);
  10538. if (strictRoot === null) {
  10539. warningWithoutStack$1(false, 'Expected to find a StrictMode component in a strict mode tree. ' + 'This error is likely caused by a bug in React. Please file an issue.');
  10540. return;
  10541. } // Dedup strategy: Warn once per component.
  10542. if (didWarnAboutLegacyContext.has(fiber.type)) {
  10543. return;
  10544. }
  10545. var warningsForRoot = pendingLegacyContextWarning.get(strictRoot);
  10546. if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') {
  10547. if (warningsForRoot === undefined) {
  10548. warningsForRoot = [];
  10549. pendingLegacyContextWarning.set(strictRoot, warningsForRoot);
  10550. }
  10551. warningsForRoot.push(fiber);
  10552. }
  10553. };
  10554. ReactStrictModeWarnings.flushLegacyContextWarning = function () {
  10555. pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) {
  10556. var uniqueNames = new Set();
  10557. fiberArray.forEach(function (fiber) {
  10558. uniqueNames.add(getComponentName(fiber.type) || 'Component');
  10559. didWarnAboutLegacyContext.add(fiber.type);
  10560. });
  10561. var sortedNames = setToSortedString(uniqueNames);
  10562. var strictRootComponentStack = getStackByFiberInDevAndProd(strictRoot);
  10563. warningWithoutStack$1(false, 'Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://fb.me/react-legacy-context' + '%s', sortedNames, strictRootComponentStack);
  10564. });
  10565. };
  10566. ReactStrictModeWarnings.discardPendingWarnings = function () {
  10567. pendingComponentWillMountWarnings = [];
  10568. pendingUNSAFE_ComponentWillMountWarnings = [];
  10569. pendingComponentWillReceivePropsWarnings = [];
  10570. pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
  10571. pendingComponentWillUpdateWarnings = [];
  10572. pendingUNSAFE_ComponentWillUpdateWarnings = [];
  10573. pendingLegacyContextWarning = new Map();
  10574. };
  10575. }
  10576. var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below.
  10577. var failedBoundaries = null;
  10578. var setRefreshHandler = function (handler) {
  10579. {
  10580. resolveFamily = handler;
  10581. }
  10582. };
  10583. function resolveFunctionForHotReloading(type) {
  10584. {
  10585. if (resolveFamily === null) {
  10586. // Hot reloading is disabled.
  10587. return type;
  10588. }
  10589. var family = resolveFamily(type);
  10590. if (family === undefined) {
  10591. return type;
  10592. } // Use the latest known implementation.
  10593. return family.current;
  10594. }
  10595. }
  10596. function resolveClassForHotReloading(type) {
  10597. // No implementation differences.
  10598. return resolveFunctionForHotReloading(type);
  10599. }
  10600. function resolveForwardRefForHotReloading(type) {
  10601. {
  10602. if (resolveFamily === null) {
  10603. // Hot reloading is disabled.
  10604. return type;
  10605. }
  10606. var family = resolveFamily(type);
  10607. if (family === undefined) {
  10608. // Check if we're dealing with a real forwardRef. Don't want to crash early.
  10609. if (type !== null && type !== undefined && typeof type.render === 'function') {
  10610. // ForwardRef is special because its resolved .type is an object,
  10611. // but it's possible that we only have its inner render function in the map.
  10612. // If that inner render function is different, we'll build a new forwardRef type.
  10613. var currentRender = resolveFunctionForHotReloading(type.render);
  10614. if (type.render !== currentRender) {
  10615. var syntheticType = {
  10616. $$typeof: REACT_FORWARD_REF_TYPE,
  10617. render: currentRender
  10618. };
  10619. if (type.displayName !== undefined) {
  10620. syntheticType.displayName = type.displayName;
  10621. }
  10622. return syntheticType;
  10623. }
  10624. }
  10625. return type;
  10626. } // Use the latest known implementation.
  10627. return family.current;
  10628. }
  10629. }
  10630. function isCompatibleFamilyForHotReloading(fiber, element) {
  10631. {
  10632. if (resolveFamily === null) {
  10633. // Hot reloading is disabled.
  10634. return false;
  10635. }
  10636. var prevType = fiber.elementType;
  10637. var nextType = element.type; // If we got here, we know types aren't === equal.
  10638. var needsCompareFamilies = false;
  10639. var $$typeofNextType = typeof nextType === 'object' && nextType !== null ? nextType.$$typeof : null;
  10640. switch (fiber.tag) {
  10641. case ClassComponent:
  10642. {
  10643. if (typeof nextType === 'function') {
  10644. needsCompareFamilies = true;
  10645. }
  10646. break;
  10647. }
  10648. case FunctionComponent:
  10649. {
  10650. if (typeof nextType === 'function') {
  10651. needsCompareFamilies = true;
  10652. } else if ($$typeofNextType === REACT_LAZY_TYPE) {
  10653. // We don't know the inner type yet.
  10654. // We're going to assume that the lazy inner type is stable,
  10655. // and so it is sufficient to avoid reconciling it away.
  10656. // We're not going to unwrap or actually use the new lazy type.
  10657. needsCompareFamilies = true;
  10658. }
  10659. break;
  10660. }
  10661. case ForwardRef:
  10662. {
  10663. if ($$typeofNextType === REACT_FORWARD_REF_TYPE) {
  10664. needsCompareFamilies = true;
  10665. } else if ($$typeofNextType === REACT_LAZY_TYPE) {
  10666. needsCompareFamilies = true;
  10667. }
  10668. break;
  10669. }
  10670. case MemoComponent:
  10671. case SimpleMemoComponent:
  10672. {
  10673. if ($$typeofNextType === REACT_MEMO_TYPE) {
  10674. // TODO: if it was but can no longer be simple,
  10675. // we shouldn't set this.
  10676. needsCompareFamilies = true;
  10677. } else if ($$typeofNextType === REACT_LAZY_TYPE) {
  10678. needsCompareFamilies = true;
  10679. }
  10680. break;
  10681. }
  10682. default:
  10683. return false;
  10684. } // Check if both types have a family and it's the same one.
  10685. if (needsCompareFamilies) {
  10686. // Note: memo() and forwardRef() we'll compare outer rather than inner type.
  10687. // This means both of them need to be registered to preserve state.
  10688. // If we unwrapped and compared the inner types for wrappers instead,
  10689. // then we would risk falsely saying two separate memo(Foo)
  10690. // calls are equivalent because they wrap the same Foo function.
  10691. var prevFamily = resolveFamily(prevType);
  10692. if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) {
  10693. return true;
  10694. }
  10695. }
  10696. return false;
  10697. }
  10698. }
  10699. function markFailedErrorBoundaryForHotReloading(fiber) {
  10700. {
  10701. if (resolveFamily === null) {
  10702. // Hot reloading is disabled.
  10703. return;
  10704. }
  10705. if (typeof WeakSet !== 'function') {
  10706. return;
  10707. }
  10708. if (failedBoundaries === null) {
  10709. failedBoundaries = new WeakSet();
  10710. }
  10711. failedBoundaries.add(fiber);
  10712. }
  10713. }
  10714. var scheduleRefresh = function (root, update) {
  10715. {
  10716. if (resolveFamily === null) {
  10717. // Hot reloading is disabled.
  10718. return;
  10719. }
  10720. var staleFamilies = update.staleFamilies,
  10721. updatedFamilies = update.updatedFamilies;
  10722. flushPassiveEffects();
  10723. flushSync(function () {
  10724. scheduleFibersWithFamiliesRecursively(root.current, updatedFamilies, staleFamilies);
  10725. });
  10726. }
  10727. };
  10728. var scheduleRoot = function (root, element) {
  10729. {
  10730. if (root.context !== emptyContextObject) {
  10731. // Super edge case: root has a legacy _renderSubtree context
  10732. // but we don't know the parentComponent so we can't pass it.
  10733. // Just ignore. We'll delete this with _renderSubtree code path later.
  10734. return;
  10735. }
  10736. flushPassiveEffects();
  10737. syncUpdates(function () {
  10738. updateContainer(element, root, null, null);
  10739. });
  10740. }
  10741. };
  10742. function scheduleFibersWithFamiliesRecursively(fiber, updatedFamilies, staleFamilies) {
  10743. {
  10744. var alternate = fiber.alternate,
  10745. child = fiber.child,
  10746. sibling = fiber.sibling,
  10747. tag = fiber.tag,
  10748. type = fiber.type;
  10749. var candidateType = null;
  10750. switch (tag) {
  10751. case FunctionComponent:
  10752. case SimpleMemoComponent:
  10753. case ClassComponent:
  10754. candidateType = type;
  10755. break;
  10756. case ForwardRef:
  10757. candidateType = type.render;
  10758. break;
  10759. default:
  10760. break;
  10761. }
  10762. if (resolveFamily === null) {
  10763. throw new Error('Expected resolveFamily to be set during hot reload.');
  10764. }
  10765. var needsRender = false;
  10766. var needsRemount = false;
  10767. if (candidateType !== null) {
  10768. var family = resolveFamily(candidateType);
  10769. if (family !== undefined) {
  10770. if (staleFamilies.has(family)) {
  10771. needsRemount = true;
  10772. } else if (updatedFamilies.has(family)) {
  10773. if (tag === ClassComponent) {
  10774. needsRemount = true;
  10775. } else {
  10776. needsRender = true;
  10777. }
  10778. }
  10779. }
  10780. }
  10781. if (failedBoundaries !== null) {
  10782. if (failedBoundaries.has(fiber) || alternate !== null && failedBoundaries.has(alternate)) {
  10783. needsRemount = true;
  10784. }
  10785. }
  10786. if (needsRemount) {
  10787. fiber._debugNeedsRemount = true;
  10788. }
  10789. if (needsRemount || needsRender) {
  10790. scheduleWork(fiber, Sync);
  10791. }
  10792. if (child !== null && !needsRemount) {
  10793. scheduleFibersWithFamiliesRecursively(child, updatedFamilies, staleFamilies);
  10794. }
  10795. if (sibling !== null) {
  10796. scheduleFibersWithFamiliesRecursively(sibling, updatedFamilies, staleFamilies);
  10797. }
  10798. }
  10799. }
  10800. var findHostInstancesForRefresh = function (root, families) {
  10801. {
  10802. var hostInstances = new Set();
  10803. var types = new Set(families.map(function (family) {
  10804. return family.current;
  10805. }));
  10806. findHostInstancesForMatchingFibersRecursively(root.current, types, hostInstances);
  10807. return hostInstances;
  10808. }
  10809. };
  10810. function findHostInstancesForMatchingFibersRecursively(fiber, types, hostInstances) {
  10811. {
  10812. var child = fiber.child,
  10813. sibling = fiber.sibling,
  10814. tag = fiber.tag,
  10815. type = fiber.type;
  10816. var candidateType = null;
  10817. switch (tag) {
  10818. case FunctionComponent:
  10819. case SimpleMemoComponent:
  10820. case ClassComponent:
  10821. candidateType = type;
  10822. break;
  10823. case ForwardRef:
  10824. candidateType = type.render;
  10825. break;
  10826. default:
  10827. break;
  10828. }
  10829. var didMatch = false;
  10830. if (candidateType !== null) {
  10831. if (types.has(candidateType)) {
  10832. didMatch = true;
  10833. }
  10834. }
  10835. if (didMatch) {
  10836. // We have a match. This only drills down to the closest host components.
  10837. // There's no need to search deeper because for the purpose of giving
  10838. // visual feedback, "flashing" outermost parent rectangles is sufficient.
  10839. findHostInstancesForFiberShallowly(fiber, hostInstances);
  10840. } else {
  10841. // If there's no match, maybe there will be one further down in the child tree.
  10842. if (child !== null) {
  10843. findHostInstancesForMatchingFibersRecursively(child, types, hostInstances);
  10844. }
  10845. }
  10846. if (sibling !== null) {
  10847. findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances);
  10848. }
  10849. }
  10850. }
  10851. function findHostInstancesForFiberShallowly(fiber, hostInstances) {
  10852. {
  10853. var foundHostInstances = findChildHostInstancesForFiberShallowly(fiber, hostInstances);
  10854. if (foundHostInstances) {
  10855. return;
  10856. } // If we didn't find any host children, fallback to closest host parent.
  10857. var node = fiber;
  10858. while (true) {
  10859. switch (node.tag) {
  10860. case HostComponent:
  10861. hostInstances.add(node.stateNode);
  10862. return;
  10863. case HostPortal:
  10864. hostInstances.add(node.stateNode.containerInfo);
  10865. return;
  10866. case HostRoot:
  10867. hostInstances.add(node.stateNode.containerInfo);
  10868. return;
  10869. }
  10870. if (node.return === null) {
  10871. throw new Error('Expected to reach root first.');
  10872. }
  10873. node = node.return;
  10874. }
  10875. }
  10876. }
  10877. function findChildHostInstancesForFiberShallowly(fiber, hostInstances) {
  10878. {
  10879. var node = fiber;
  10880. var foundHostInstances = false;
  10881. while (true) {
  10882. if (node.tag === HostComponent) {
  10883. // We got a match.
  10884. foundHostInstances = true;
  10885. hostInstances.add(node.stateNode); // There may still be more, so keep searching.
  10886. } else if (node.child !== null) {
  10887. node.child.return = node;
  10888. node = node.child;
  10889. continue;
  10890. }
  10891. if (node === fiber) {
  10892. return foundHostInstances;
  10893. }
  10894. while (node.sibling === null) {
  10895. if (node.return === null || node.return === fiber) {
  10896. return foundHostInstances;
  10897. }
  10898. node = node.return;
  10899. }
  10900. node.sibling.return = node.return;
  10901. node = node.sibling;
  10902. }
  10903. }
  10904. return false;
  10905. }
  10906. function resolveDefaultProps(Component, baseProps) {
  10907. if (Component && Component.defaultProps) {
  10908. // Resolve default props. Taken from ReactElement
  10909. var props = _assign({}, baseProps);
  10910. var defaultProps = Component.defaultProps;
  10911. for (var propName in defaultProps) {
  10912. if (props[propName] === undefined) {
  10913. props[propName] = defaultProps[propName];
  10914. }
  10915. }
  10916. return props;
  10917. }
  10918. return baseProps;
  10919. }
  10920. function readLazyComponentType(lazyComponent) {
  10921. initializeLazyComponentType(lazyComponent);
  10922. if (lazyComponent._status !== Resolved) {
  10923. throw lazyComponent._result;
  10924. }
  10925. return lazyComponent._result;
  10926. }
  10927. var valueCursor = createCursor(null);
  10928. var rendererSigil;
  10929. {
  10930. // Use this to detect multiple renderers using the same context
  10931. rendererSigil = {};
  10932. }
  10933. var currentlyRenderingFiber = null;
  10934. var lastContextDependency = null;
  10935. var lastContextWithAllBitsObserved = null;
  10936. var isDisallowedContextReadInDEV = false;
  10937. function resetContextDependencies() {
  10938. // This is called right before React yields execution, to ensure `readContext`
  10939. // cannot be called outside the render phase.
  10940. currentlyRenderingFiber = null;
  10941. lastContextDependency = null;
  10942. lastContextWithAllBitsObserved = null;
  10943. {
  10944. isDisallowedContextReadInDEV = false;
  10945. }
  10946. }
  10947. function enterDisallowedContextReadInDEV() {
  10948. {
  10949. isDisallowedContextReadInDEV = true;
  10950. }
  10951. }
  10952. function exitDisallowedContextReadInDEV() {
  10953. {
  10954. isDisallowedContextReadInDEV = false;
  10955. }
  10956. }
  10957. function pushProvider(providerFiber, nextValue) {
  10958. var context = providerFiber.type._context;
  10959. if (isPrimaryRenderer) {
  10960. push(valueCursor, context._currentValue, providerFiber);
  10961. context._currentValue = nextValue;
  10962. {
  10963. !(context._currentRenderer === undefined || context._currentRenderer === null || context._currentRenderer === rendererSigil) ? warningWithoutStack$1(false, 'Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.') : void 0;
  10964. context._currentRenderer = rendererSigil;
  10965. }
  10966. } else {
  10967. push(valueCursor, context._currentValue2, providerFiber);
  10968. context._currentValue2 = nextValue;
  10969. {
  10970. !(context._currentRenderer2 === undefined || context._currentRenderer2 === null || context._currentRenderer2 === rendererSigil) ? warningWithoutStack$1(false, 'Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.') : void 0;
  10971. context._currentRenderer2 = rendererSigil;
  10972. }
  10973. }
  10974. }
  10975. function popProvider(providerFiber) {
  10976. var currentValue = valueCursor.current;
  10977. pop(valueCursor, providerFiber);
  10978. var context = providerFiber.type._context;
  10979. if (isPrimaryRenderer) {
  10980. context._currentValue = currentValue;
  10981. } else {
  10982. context._currentValue2 = currentValue;
  10983. }
  10984. }
  10985. function calculateChangedBits(context, newValue, oldValue) {
  10986. if (is$1(oldValue, newValue)) {
  10987. // No change
  10988. return 0;
  10989. } else {
  10990. var changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
  10991. {
  10992. !((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits) ? warning$1(false, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits) : void 0;
  10993. }
  10994. return changedBits | 0;
  10995. }
  10996. }
  10997. function scheduleWorkOnParentPath(parent, renderExpirationTime) {
  10998. // Update the child expiration time of all the ancestors, including
  10999. // the alternates.
  11000. var node = parent;
  11001. while (node !== null) {
  11002. var alternate = node.alternate;
  11003. if (node.childExpirationTime < renderExpirationTime) {
  11004. node.childExpirationTime = renderExpirationTime;
  11005. if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
  11006. alternate.childExpirationTime = renderExpirationTime;
  11007. }
  11008. } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
  11009. alternate.childExpirationTime = renderExpirationTime;
  11010. } else {
  11011. // Neither alternate was updated, which means the rest of the
  11012. // ancestor path already has sufficient priority.
  11013. break;
  11014. }
  11015. node = node.return;
  11016. }
  11017. }
  11018. function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
  11019. var fiber = workInProgress.child;
  11020. if (fiber !== null) {
  11021. // Set the return pointer of the child to the work-in-progress fiber.
  11022. fiber.return = workInProgress;
  11023. }
  11024. while (fiber !== null) {
  11025. var nextFiber = void 0; // Visit this fiber.
  11026. var list = fiber.dependencies;
  11027. if (list !== null) {
  11028. nextFiber = fiber.child;
  11029. var dependency = list.firstContext;
  11030. while (dependency !== null) {
  11031. // Check if the context matches.
  11032. if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) {
  11033. // Match! Schedule an update on this fiber.
  11034. if (fiber.tag === ClassComponent) {
  11035. // Schedule a force update on the work-in-progress.
  11036. var update = createUpdate(renderExpirationTime, null);
  11037. update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the
  11038. // update to the current fiber, too, which means it will persist even if
  11039. // this render is thrown away. Since it's a race condition, not sure it's
  11040. // worth fixing.
  11041. enqueueUpdate(fiber, update);
  11042. }
  11043. if (fiber.expirationTime < renderExpirationTime) {
  11044. fiber.expirationTime = renderExpirationTime;
  11045. }
  11046. var alternate = fiber.alternate;
  11047. if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
  11048. alternate.expirationTime = renderExpirationTime;
  11049. }
  11050. scheduleWorkOnParentPath(fiber.return, renderExpirationTime); // Mark the expiration time on the list, too.
  11051. if (list.expirationTime < renderExpirationTime) {
  11052. list.expirationTime = renderExpirationTime;
  11053. } // Since we already found a match, we can stop traversing the
  11054. // dependency list.
  11055. break;
  11056. }
  11057. dependency = dependency.next;
  11058. }
  11059. } else if (fiber.tag === ContextProvider) {
  11060. // Don't scan deeper if this is a matching provider
  11061. nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
  11062. } else if (enableSuspenseServerRenderer && fiber.tag === DehydratedFragment) {
  11063. // If a dehydrated suspense bounudary is in this subtree, we don't know
  11064. // if it will have any context consumers in it. The best we can do is
  11065. // mark it as having updates.
  11066. var parentSuspense = fiber.return;
  11067. if (!(parentSuspense !== null)) {
  11068. {
  11069. throw Error("We just came from a parent so we must have had a parent. This is a bug in React.");
  11070. }
  11071. }
  11072. if (parentSuspense.expirationTime < renderExpirationTime) {
  11073. parentSuspense.expirationTime = renderExpirationTime;
  11074. }
  11075. var _alternate = parentSuspense.alternate;
  11076. if (_alternate !== null && _alternate.expirationTime < renderExpirationTime) {
  11077. _alternate.expirationTime = renderExpirationTime;
  11078. } // This is intentionally passing this fiber as the parent
  11079. // because we want to schedule this fiber as having work
  11080. // on its children. We'll use the childExpirationTime on
  11081. // this fiber to indicate that a context has changed.
  11082. scheduleWorkOnParentPath(parentSuspense, renderExpirationTime);
  11083. nextFiber = fiber.sibling;
  11084. } else {
  11085. // Traverse down.
  11086. nextFiber = fiber.child;
  11087. }
  11088. if (nextFiber !== null) {
  11089. // Set the return pointer of the child to the work-in-progress fiber.
  11090. nextFiber.return = fiber;
  11091. } else {
  11092. // No child. Traverse to next sibling.
  11093. nextFiber = fiber;
  11094. while (nextFiber !== null) {
  11095. if (nextFiber === workInProgress) {
  11096. // We're back to the root of this subtree. Exit.
  11097. nextFiber = null;
  11098. break;
  11099. }
  11100. var sibling = nextFiber.sibling;
  11101. if (sibling !== null) {
  11102. // Set the return pointer of the sibling to the work-in-progress fiber.
  11103. sibling.return = nextFiber.return;
  11104. nextFiber = sibling;
  11105. break;
  11106. } // No more siblings. Traverse up.
  11107. nextFiber = nextFiber.return;
  11108. }
  11109. }
  11110. fiber = nextFiber;
  11111. }
  11112. }
  11113. function prepareToReadContext(workInProgress, renderExpirationTime) {
  11114. currentlyRenderingFiber = workInProgress;
  11115. lastContextDependency = null;
  11116. lastContextWithAllBitsObserved = null;
  11117. var dependencies = workInProgress.dependencies;
  11118. if (dependencies !== null) {
  11119. var firstContext = dependencies.firstContext;
  11120. if (firstContext !== null) {
  11121. if (dependencies.expirationTime >= renderExpirationTime) {
  11122. // Context list has a pending update. Mark that this fiber performed work.
  11123. markWorkInProgressReceivedUpdate();
  11124. } // Reset the work-in-progress list
  11125. dependencies.firstContext = null;
  11126. }
  11127. }
  11128. }
  11129. function readContext(context, observedBits) {
  11130. {
  11131. // This warning would fire if you read context inside a Hook like useMemo.
  11132. // Unlike the class check below, it's not enforced in production for perf.
  11133. !!isDisallowedContextReadInDEV ? warning$1(false, 'Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().') : void 0;
  11134. }
  11135. if (lastContextWithAllBitsObserved === context) {// Nothing to do. We already observe everything in this context.
  11136. } else if (observedBits === false || observedBits === 0) {// Do not observe any updates.
  11137. } else {
  11138. var resolvedObservedBits; // Avoid deopting on observable arguments or heterogeneous types.
  11139. if (typeof observedBits !== 'number' || observedBits === MAX_SIGNED_31_BIT_INT) {
  11140. // Observe all updates.
  11141. lastContextWithAllBitsObserved = context;
  11142. resolvedObservedBits = MAX_SIGNED_31_BIT_INT;
  11143. } else {
  11144. resolvedObservedBits = observedBits;
  11145. }
  11146. var contextItem = {
  11147. context: context,
  11148. observedBits: resolvedObservedBits,
  11149. next: null
  11150. };
  11151. if (lastContextDependency === null) {
  11152. if (!(currentlyRenderingFiber !== null)) {
  11153. {
  11154. throw Error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().");
  11155. }
  11156. } // This is the first dependency for this component. Create a new list.
  11157. lastContextDependency = contextItem;
  11158. currentlyRenderingFiber.dependencies = {
  11159. expirationTime: NoWork,
  11160. firstContext: contextItem,
  11161. responders: null
  11162. };
  11163. } else {
  11164. // Append a new context item.
  11165. lastContextDependency = lastContextDependency.next = contextItem;
  11166. }
  11167. }
  11168. return isPrimaryRenderer ? context._currentValue : context._currentValue2;
  11169. }
  11170. // UpdateQueue is a linked list of prioritized updates.
  11171. //
  11172. // Like fibers, update queues come in pairs: a current queue, which represents
  11173. // the visible state of the screen, and a work-in-progress queue, which can be
  11174. // mutated and processed asynchronously before it is committed — a form of
  11175. // double buffering. If a work-in-progress render is discarded before finishing,
  11176. // we create a new work-in-progress by cloning the current queue.
  11177. //
  11178. // Both queues share a persistent, singly-linked list structure. To schedule an
  11179. // update, we append it to the end of both queues. Each queue maintains a
  11180. // pointer to first update in the persistent list that hasn't been processed.
  11181. // The work-in-progress pointer always has a position equal to or greater than
  11182. // the current queue, since we always work on that one. The current queue's
  11183. // pointer is only updated during the commit phase, when we swap in the
  11184. // work-in-progress.
  11185. //
  11186. // For example:
  11187. //
  11188. // Current pointer: A - B - C - D - E - F
  11189. // Work-in-progress pointer: D - E - F
  11190. // ^
  11191. // The work-in-progress queue has
  11192. // processed more updates than current.
  11193. //
  11194. // The reason we append to both queues is because otherwise we might drop
  11195. // updates without ever processing them. For example, if we only add updates to
  11196. // the work-in-progress queue, some updates could be lost whenever a work-in
  11197. // -progress render restarts by cloning from current. Similarly, if we only add
  11198. // updates to the current queue, the updates will be lost whenever an already
  11199. // in-progress queue commits and swaps with the current queue. However, by
  11200. // adding to both queues, we guarantee that the update will be part of the next
  11201. // work-in-progress. (And because the work-in-progress queue becomes the
  11202. // current queue once it commits, there's no danger of applying the same
  11203. // update twice.)
  11204. //
  11205. // Prioritization
  11206. // --------------
  11207. //
  11208. // Updates are not sorted by priority, but by insertion; new updates are always
  11209. // appended to the end of the list.
  11210. //
  11211. // The priority is still important, though. When processing the update queue
  11212. // during the render phase, only the updates with sufficient priority are
  11213. // included in the result. If we skip an update because it has insufficient
  11214. // priority, it remains in the queue to be processed later, during a lower
  11215. // priority render. Crucially, all updates subsequent to a skipped update also
  11216. // remain in the queue *regardless of their priority*. That means high priority
  11217. // updates are sometimes processed twice, at two separate priorities. We also
  11218. // keep track of a base state, that represents the state before the first
  11219. // update in the queue is applied.
  11220. //
  11221. // For example:
  11222. //
  11223. // Given a base state of '', and the following queue of updates
  11224. //
  11225. // A1 - B2 - C1 - D2
  11226. //
  11227. // where the number indicates the priority, and the update is applied to the
  11228. // previous state by appending a letter, React will process these updates as
  11229. // two separate renders, one per distinct priority level:
  11230. //
  11231. // First render, at priority 1:
  11232. // Base state: ''
  11233. // Updates: [A1, C1]
  11234. // Result state: 'AC'
  11235. //
  11236. // Second render, at priority 2:
  11237. // Base state: 'A' <- The base state does not include C1,
  11238. // because B2 was skipped.
  11239. // Updates: [B2, C1, D2] <- C1 was rebased on top of B2
  11240. // Result state: 'ABCD'
  11241. //
  11242. // Because we process updates in insertion order, and rebase high priority
  11243. // updates when preceding updates are skipped, the final result is deterministic
  11244. // regardless of priority. Intermediate state may vary according to system
  11245. // resources, but the final state is always the same.
  11246. var UpdateState = 0;
  11247. var ReplaceState = 1;
  11248. var ForceUpdate = 2;
  11249. var CaptureUpdate = 3; // Global state that is reset at the beginning of calling `processUpdateQueue`.
  11250. // It should only be read right after calling `processUpdateQueue`, via
  11251. // `checkHasForceUpdateAfterProcessing`.
  11252. var hasForceUpdate = false;
  11253. var didWarnUpdateInsideUpdate;
  11254. var currentlyProcessingQueue;
  11255. {
  11256. didWarnUpdateInsideUpdate = false;
  11257. currentlyProcessingQueue = null;
  11258. }
  11259. function createUpdateQueue(baseState) {
  11260. var queue = {
  11261. baseState: baseState,
  11262. firstUpdate: null,
  11263. lastUpdate: null,
  11264. firstCapturedUpdate: null,
  11265. lastCapturedUpdate: null,
  11266. firstEffect: null,
  11267. lastEffect: null,
  11268. firstCapturedEffect: null,
  11269. lastCapturedEffect: null
  11270. };
  11271. return queue;
  11272. }
  11273. function cloneUpdateQueue(currentQueue) {
  11274. var queue = {
  11275. baseState: currentQueue.baseState,
  11276. firstUpdate: currentQueue.firstUpdate,
  11277. lastUpdate: currentQueue.lastUpdate,
  11278. // TODO: With resuming, if we bail out and resuse the child tree, we should
  11279. // keep these effects.
  11280. firstCapturedUpdate: null,
  11281. lastCapturedUpdate: null,
  11282. firstEffect: null,
  11283. lastEffect: null,
  11284. firstCapturedEffect: null,
  11285. lastCapturedEffect: null
  11286. };
  11287. return queue;
  11288. }
  11289. function createUpdate(expirationTime, suspenseConfig) {
  11290. var update = {
  11291. expirationTime: expirationTime,
  11292. suspenseConfig: suspenseConfig,
  11293. tag: UpdateState,
  11294. payload: null,
  11295. callback: null,
  11296. next: null,
  11297. nextEffect: null
  11298. };
  11299. {
  11300. update.priority = getCurrentPriorityLevel();
  11301. }
  11302. return update;
  11303. }
  11304. function appendUpdateToQueue(queue, update) {
  11305. // Append the update to the end of the list.
  11306. if (queue.lastUpdate === null) {
  11307. // Queue is empty
  11308. queue.firstUpdate = queue.lastUpdate = update;
  11309. } else {
  11310. queue.lastUpdate.next = update;
  11311. queue.lastUpdate = update;
  11312. }
  11313. }
  11314. function enqueueUpdate(fiber, update) {
  11315. // Update queues are created lazily.
  11316. var alternate = fiber.alternate;
  11317. var queue1;
  11318. var queue2;
  11319. if (alternate === null) {
  11320. // There's only one fiber.
  11321. queue1 = fiber.updateQueue;
  11322. queue2 = null;
  11323. if (queue1 === null) {
  11324. queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState);
  11325. }
  11326. } else {
  11327. // There are two owners.
  11328. queue1 = fiber.updateQueue;
  11329. queue2 = alternate.updateQueue;
  11330. if (queue1 === null) {
  11331. if (queue2 === null) {
  11332. // Neither fiber has an update queue. Create new ones.
  11333. queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState);
  11334. queue2 = alternate.updateQueue = createUpdateQueue(alternate.memoizedState);
  11335. } else {
  11336. // Only one fiber has an update queue. Clone to create a new one.
  11337. queue1 = fiber.updateQueue = cloneUpdateQueue(queue2);
  11338. }
  11339. } else {
  11340. if (queue2 === null) {
  11341. // Only one fiber has an update queue. Clone to create a new one.
  11342. queue2 = alternate.updateQueue = cloneUpdateQueue(queue1);
  11343. } else {// Both owners have an update queue.
  11344. }
  11345. }
  11346. }
  11347. if (queue2 === null || queue1 === queue2) {
  11348. // There's only a single queue.
  11349. appendUpdateToQueue(queue1, update);
  11350. } else {
  11351. // There are two queues. We need to append the update to both queues,
  11352. // while accounting for the persistent structure of the list — we don't
  11353. // want the same update to be added multiple times.
  11354. if (queue1.lastUpdate === null || queue2.lastUpdate === null) {
  11355. // One of the queues is not empty. We must add the update to both queues.
  11356. appendUpdateToQueue(queue1, update);
  11357. appendUpdateToQueue(queue2, update);
  11358. } else {
  11359. // Both queues are non-empty. The last update is the same in both lists,
  11360. // because of structural sharing. So, only append to one of the lists.
  11361. appendUpdateToQueue(queue1, update); // But we still need to update the `lastUpdate` pointer of queue2.
  11362. queue2.lastUpdate = update;
  11363. }
  11364. }
  11365. {
  11366. if (fiber.tag === ClassComponent && (currentlyProcessingQueue === queue1 || queue2 !== null && currentlyProcessingQueue === queue2) && !didWarnUpdateInsideUpdate) {
  11367. warningWithoutStack$1(false, 'An update (setState, replaceState, or forceUpdate) was scheduled ' + 'from inside an update function. Update functions should be pure, ' + 'with zero side-effects. Consider using componentDidUpdate or a ' + 'callback.');
  11368. didWarnUpdateInsideUpdate = true;
  11369. }
  11370. }
  11371. }
  11372. function enqueueCapturedUpdate(workInProgress, update) {
  11373. // Captured updates go into a separate list, and only on the work-in-
  11374. // progress queue.
  11375. var workInProgressQueue = workInProgress.updateQueue;
  11376. if (workInProgressQueue === null) {
  11377. workInProgressQueue = workInProgress.updateQueue = createUpdateQueue(workInProgress.memoizedState);
  11378. } else {
  11379. // TODO: I put this here rather than createWorkInProgress so that we don't
  11380. // clone the queue unnecessarily. There's probably a better way to
  11381. // structure this.
  11382. workInProgressQueue = ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue);
  11383. } // Append the update to the end of the list.
  11384. if (workInProgressQueue.lastCapturedUpdate === null) {
  11385. // This is the first render phase update
  11386. workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update;
  11387. } else {
  11388. workInProgressQueue.lastCapturedUpdate.next = update;
  11389. workInProgressQueue.lastCapturedUpdate = update;
  11390. }
  11391. }
  11392. function ensureWorkInProgressQueueIsAClone(workInProgress, queue) {
  11393. var current = workInProgress.alternate;
  11394. if (current !== null) {
  11395. // If the work-in-progress queue is equal to the current queue,
  11396. // we need to clone it first.
  11397. if (queue === current.updateQueue) {
  11398. queue = workInProgress.updateQueue = cloneUpdateQueue(queue);
  11399. }
  11400. }
  11401. return queue;
  11402. }
  11403. function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) {
  11404. switch (update.tag) {
  11405. case ReplaceState:
  11406. {
  11407. var payload = update.payload;
  11408. if (typeof payload === 'function') {
  11409. // Updater function
  11410. {
  11411. enterDisallowedContextReadInDEV();
  11412. if (debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  11413. payload.call(instance, prevState, nextProps);
  11414. }
  11415. }
  11416. var nextState = payload.call(instance, prevState, nextProps);
  11417. {
  11418. exitDisallowedContextReadInDEV();
  11419. }
  11420. return nextState;
  11421. } // State object
  11422. return payload;
  11423. }
  11424. case CaptureUpdate:
  11425. {
  11426. workInProgress.effectTag = workInProgress.effectTag & ~ShouldCapture | DidCapture;
  11427. }
  11428. // Intentional fallthrough
  11429. case UpdateState:
  11430. {
  11431. var _payload = update.payload;
  11432. var partialState;
  11433. if (typeof _payload === 'function') {
  11434. // Updater function
  11435. {
  11436. enterDisallowedContextReadInDEV();
  11437. if (debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  11438. _payload.call(instance, prevState, nextProps);
  11439. }
  11440. }
  11441. partialState = _payload.call(instance, prevState, nextProps);
  11442. {
  11443. exitDisallowedContextReadInDEV();
  11444. }
  11445. } else {
  11446. // Partial state object
  11447. partialState = _payload;
  11448. }
  11449. if (partialState === null || partialState === undefined) {
  11450. // Null and undefined are treated as no-ops.
  11451. return prevState;
  11452. } // Merge the partial state and the previous state.
  11453. return _assign({}, prevState, partialState);
  11454. }
  11455. case ForceUpdate:
  11456. {
  11457. hasForceUpdate = true;
  11458. return prevState;
  11459. }
  11460. }
  11461. return prevState;
  11462. }
  11463. function processUpdateQueue(workInProgress, queue, props, instance, renderExpirationTime) {
  11464. hasForceUpdate = false;
  11465. queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue);
  11466. {
  11467. currentlyProcessingQueue = queue;
  11468. } // These values may change as we process the queue.
  11469. var newBaseState = queue.baseState;
  11470. var newFirstUpdate = null;
  11471. var newExpirationTime = NoWork; // Iterate through the list of updates to compute the result.
  11472. var update = queue.firstUpdate;
  11473. var resultState = newBaseState;
  11474. while (update !== null) {
  11475. var updateExpirationTime = update.expirationTime;
  11476. if (updateExpirationTime < renderExpirationTime) {
  11477. // This update does not have sufficient priority. Skip it.
  11478. if (newFirstUpdate === null) {
  11479. // This is the first skipped update. It will be the first update in
  11480. // the new list.
  11481. newFirstUpdate = update; // Since this is the first update that was skipped, the current result
  11482. // is the new base state.
  11483. newBaseState = resultState;
  11484. } // Since this update will remain in the list, update the remaining
  11485. // expiration time.
  11486. if (newExpirationTime < updateExpirationTime) {
  11487. newExpirationTime = updateExpirationTime;
  11488. }
  11489. } else {
  11490. // This update does have sufficient priority.
  11491. // Mark the event time of this update as relevant to this render pass.
  11492. // TODO: This should ideally use the true event time of this update rather than
  11493. // its priority which is a derived and not reverseable value.
  11494. // TODO: We should skip this update if it was already committed but currently
  11495. // we have no way of detecting the difference between a committed and suspended
  11496. // update here.
  11497. markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig); // Process it and compute a new result.
  11498. resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance);
  11499. var callback = update.callback;
  11500. if (callback !== null) {
  11501. workInProgress.effectTag |= Callback; // Set this to null, in case it was mutated during an aborted render.
  11502. update.nextEffect = null;
  11503. if (queue.lastEffect === null) {
  11504. queue.firstEffect = queue.lastEffect = update;
  11505. } else {
  11506. queue.lastEffect.nextEffect = update;
  11507. queue.lastEffect = update;
  11508. }
  11509. }
  11510. } // Continue to the next update.
  11511. update = update.next;
  11512. } // Separately, iterate though the list of captured updates.
  11513. var newFirstCapturedUpdate = null;
  11514. update = queue.firstCapturedUpdate;
  11515. while (update !== null) {
  11516. var _updateExpirationTime = update.expirationTime;
  11517. if (_updateExpirationTime < renderExpirationTime) {
  11518. // This update does not have sufficient priority. Skip it.
  11519. if (newFirstCapturedUpdate === null) {
  11520. // This is the first skipped captured update. It will be the first
  11521. // update in the new list.
  11522. newFirstCapturedUpdate = update; // If this is the first update that was skipped, the current result is
  11523. // the new base state.
  11524. if (newFirstUpdate === null) {
  11525. newBaseState = resultState;
  11526. }
  11527. } // Since this update will remain in the list, update the remaining
  11528. // expiration time.
  11529. if (newExpirationTime < _updateExpirationTime) {
  11530. newExpirationTime = _updateExpirationTime;
  11531. }
  11532. } else {
  11533. // This update does have sufficient priority. Process it and compute
  11534. // a new result.
  11535. resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance);
  11536. var _callback = update.callback;
  11537. if (_callback !== null) {
  11538. workInProgress.effectTag |= Callback; // Set this to null, in case it was mutated during an aborted render.
  11539. update.nextEffect = null;
  11540. if (queue.lastCapturedEffect === null) {
  11541. queue.firstCapturedEffect = queue.lastCapturedEffect = update;
  11542. } else {
  11543. queue.lastCapturedEffect.nextEffect = update;
  11544. queue.lastCapturedEffect = update;
  11545. }
  11546. }
  11547. }
  11548. update = update.next;
  11549. }
  11550. if (newFirstUpdate === null) {
  11551. queue.lastUpdate = null;
  11552. }
  11553. if (newFirstCapturedUpdate === null) {
  11554. queue.lastCapturedUpdate = null;
  11555. } else {
  11556. workInProgress.effectTag |= Callback;
  11557. }
  11558. if (newFirstUpdate === null && newFirstCapturedUpdate === null) {
  11559. // We processed every update, without skipping. That means the new base
  11560. // state is the same as the result state.
  11561. newBaseState = resultState;
  11562. }
  11563. queue.baseState = newBaseState;
  11564. queue.firstUpdate = newFirstUpdate;
  11565. queue.firstCapturedUpdate = newFirstCapturedUpdate; // Set the remaining expiration time to be whatever is remaining in the queue.
  11566. // This should be fine because the only two other things that contribute to
  11567. // expiration time are props and context. We're already in the middle of the
  11568. // begin phase by the time we start processing the queue, so we've already
  11569. // dealt with the props. Context in components that specify
  11570. // shouldComponentUpdate is tricky; but we'll have to account for
  11571. // that regardless.
  11572. markUnprocessedUpdateTime(newExpirationTime);
  11573. workInProgress.expirationTime = newExpirationTime;
  11574. workInProgress.memoizedState = resultState;
  11575. {
  11576. currentlyProcessingQueue = null;
  11577. }
  11578. }
  11579. function callCallback(callback, context) {
  11580. if (!(typeof callback === 'function')) {
  11581. {
  11582. throw Error("Invalid argument passed as callback. Expected a function. Instead received: " + callback);
  11583. }
  11584. }
  11585. callback.call(context);
  11586. }
  11587. function resetHasForceUpdateBeforeProcessing() {
  11588. hasForceUpdate = false;
  11589. }
  11590. function checkHasForceUpdateAfterProcessing() {
  11591. return hasForceUpdate;
  11592. }
  11593. function commitUpdateQueue(finishedWork, finishedQueue, instance, renderExpirationTime) {
  11594. // If the finished render included captured updates, and there are still
  11595. // lower priority updates left over, we need to keep the captured updates
  11596. // in the queue so that they are rebased and not dropped once we process the
  11597. // queue again at the lower priority.
  11598. if (finishedQueue.firstCapturedUpdate !== null) {
  11599. // Join the captured update list to the end of the normal list.
  11600. if (finishedQueue.lastUpdate !== null) {
  11601. finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate;
  11602. finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate;
  11603. } // Clear the list of captured updates.
  11604. finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null;
  11605. } // Commit the effects
  11606. commitUpdateEffects(finishedQueue.firstEffect, instance);
  11607. finishedQueue.firstEffect = finishedQueue.lastEffect = null;
  11608. commitUpdateEffects(finishedQueue.firstCapturedEffect, instance);
  11609. finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null;
  11610. }
  11611. function commitUpdateEffects(effect, instance) {
  11612. while (effect !== null) {
  11613. var callback = effect.callback;
  11614. if (callback !== null) {
  11615. effect.callback = null;
  11616. callCallback(callback, instance);
  11617. }
  11618. effect = effect.nextEffect;
  11619. }
  11620. }
  11621. var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
  11622. function requestCurrentSuspenseConfig() {
  11623. return ReactCurrentBatchConfig.suspense;
  11624. }
  11625. var fakeInternalInstance = {};
  11626. var isArray$1 = Array.isArray; // React.Component uses a shared frozen object by default.
  11627. // We'll use it to determine whether we need to initialize legacy refs.
  11628. var emptyRefsObject = new React.Component().refs;
  11629. var didWarnAboutStateAssignmentForComponent;
  11630. var didWarnAboutUninitializedState;
  11631. var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate;
  11632. var didWarnAboutLegacyLifecyclesAndDerivedState;
  11633. var didWarnAboutUndefinedDerivedState;
  11634. var warnOnUndefinedDerivedState;
  11635. var warnOnInvalidCallback$1;
  11636. var didWarnAboutDirectlyAssigningPropsToState;
  11637. var didWarnAboutContextTypeAndContextTypes;
  11638. var didWarnAboutInvalidateContextType;
  11639. {
  11640. didWarnAboutStateAssignmentForComponent = new Set();
  11641. didWarnAboutUninitializedState = new Set();
  11642. didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set();
  11643. didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
  11644. didWarnAboutDirectlyAssigningPropsToState = new Set();
  11645. didWarnAboutUndefinedDerivedState = new Set();
  11646. didWarnAboutContextTypeAndContextTypes = new Set();
  11647. didWarnAboutInvalidateContextType = new Set();
  11648. var didWarnOnInvalidCallback = new Set();
  11649. warnOnInvalidCallback$1 = function (callback, callerName) {
  11650. if (callback === null || typeof callback === 'function') {
  11651. return;
  11652. }
  11653. var key = callerName + "_" + callback;
  11654. if (!didWarnOnInvalidCallback.has(key)) {
  11655. didWarnOnInvalidCallback.add(key);
  11656. warningWithoutStack$1(false, '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
  11657. }
  11658. };
  11659. warnOnUndefinedDerivedState = function (type, partialState) {
  11660. if (partialState === undefined) {
  11661. var componentName = getComponentName(type) || 'Component';
  11662. if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
  11663. didWarnAboutUndefinedDerivedState.add(componentName);
  11664. warningWithoutStack$1(false, '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
  11665. }
  11666. }
  11667. }; // This is so gross but it's at least non-critical and can be removed if
  11668. // it causes problems. This is meant to give a nicer error message for
  11669. // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component,
  11670. // ...)) which otherwise throws a "_processChildContext is not a function"
  11671. // exception.
  11672. Object.defineProperty(fakeInternalInstance, '_processChildContext', {
  11673. enumerable: false,
  11674. value: function () {
  11675. {
  11676. {
  11677. throw Error("_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn't supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal).");
  11678. }
  11679. }
  11680. }
  11681. });
  11682. Object.freeze(fakeInternalInstance);
  11683. }
  11684. function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) {
  11685. var prevState = workInProgress.memoizedState;
  11686. {
  11687. if (debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  11688. // Invoke the function an extra time to help detect side-effects.
  11689. getDerivedStateFromProps(nextProps, prevState);
  11690. }
  11691. }
  11692. var partialState = getDerivedStateFromProps(nextProps, prevState);
  11693. {
  11694. warnOnUndefinedDerivedState(ctor, partialState);
  11695. } // Merge the partial state and the previous state.
  11696. var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState);
  11697. workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the
  11698. // base state.
  11699. var updateQueue = workInProgress.updateQueue;
  11700. if (updateQueue !== null && workInProgress.expirationTime === NoWork) {
  11701. updateQueue.baseState = memoizedState;
  11702. }
  11703. }
  11704. var classComponentUpdater = {
  11705. isMounted: isMounted,
  11706. enqueueSetState: function (inst, payload, callback) {
  11707. var fiber = get(inst);
  11708. var currentTime = requestCurrentTimeForUpdate();
  11709. var suspenseConfig = requestCurrentSuspenseConfig();
  11710. var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
  11711. var update = createUpdate(expirationTime, suspenseConfig);
  11712. update.payload = payload;
  11713. if (callback !== undefined && callback !== null) {
  11714. {
  11715. warnOnInvalidCallback$1(callback, 'setState');
  11716. }
  11717. update.callback = callback;
  11718. }
  11719. enqueueUpdate(fiber, update);
  11720. scheduleWork(fiber, expirationTime);
  11721. },
  11722. enqueueReplaceState: function (inst, payload, callback) {
  11723. var fiber = get(inst);
  11724. var currentTime = requestCurrentTimeForUpdate();
  11725. var suspenseConfig = requestCurrentSuspenseConfig();
  11726. var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
  11727. var update = createUpdate(expirationTime, suspenseConfig);
  11728. update.tag = ReplaceState;
  11729. update.payload = payload;
  11730. if (callback !== undefined && callback !== null) {
  11731. {
  11732. warnOnInvalidCallback$1(callback, 'replaceState');
  11733. }
  11734. update.callback = callback;
  11735. }
  11736. enqueueUpdate(fiber, update);
  11737. scheduleWork(fiber, expirationTime);
  11738. },
  11739. enqueueForceUpdate: function (inst, callback) {
  11740. var fiber = get(inst);
  11741. var currentTime = requestCurrentTimeForUpdate();
  11742. var suspenseConfig = requestCurrentSuspenseConfig();
  11743. var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
  11744. var update = createUpdate(expirationTime, suspenseConfig);
  11745. update.tag = ForceUpdate;
  11746. if (callback !== undefined && callback !== null) {
  11747. {
  11748. warnOnInvalidCallback$1(callback, 'forceUpdate');
  11749. }
  11750. update.callback = callback;
  11751. }
  11752. enqueueUpdate(fiber, update);
  11753. scheduleWork(fiber, expirationTime);
  11754. }
  11755. };
  11756. function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) {
  11757. var instance = workInProgress.stateNode;
  11758. if (typeof instance.shouldComponentUpdate === 'function') {
  11759. startPhaseTimer(workInProgress, 'shouldComponentUpdate');
  11760. var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext);
  11761. stopPhaseTimer();
  11762. {
  11763. !(shouldUpdate !== undefined) ? warningWithoutStack$1(false, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(ctor) || 'Component') : void 0;
  11764. }
  11765. return shouldUpdate;
  11766. }
  11767. if (ctor.prototype && ctor.prototype.isPureReactComponent) {
  11768. return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
  11769. }
  11770. return true;
  11771. }
  11772. function checkClassInstance(workInProgress, ctor, newProps) {
  11773. var instance = workInProgress.stateNode;
  11774. {
  11775. var name = getComponentName(ctor) || 'Component';
  11776. var renderPresent = instance.render;
  11777. if (!renderPresent) {
  11778. if (ctor.prototype && typeof ctor.prototype.render === 'function') {
  11779. warningWithoutStack$1(false, '%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
  11780. } else {
  11781. warningWithoutStack$1(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
  11782. }
  11783. }
  11784. var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state;
  11785. !noGetInitialStateOnES6 ? warningWithoutStack$1(false, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name) : void 0;
  11786. var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved;
  11787. !noGetDefaultPropsOnES6 ? warningWithoutStack$1(false, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name) : void 0;
  11788. var noInstancePropTypes = !instance.propTypes;
  11789. !noInstancePropTypes ? warningWithoutStack$1(false, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name) : void 0;
  11790. var noInstanceContextType = !instance.contextType;
  11791. !noInstanceContextType ? warningWithoutStack$1(false, 'contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name) : void 0;
  11792. if (disableLegacyContext) {
  11793. if (ctor.childContextTypes) {
  11794. warningWithoutStack$1(false, '%s uses the legacy childContextTypes API which is no longer supported. ' + 'Use React.createContext() instead.', name);
  11795. }
  11796. if (ctor.contextTypes) {
  11797. warningWithoutStack$1(false, '%s uses the legacy contextTypes API which is no longer supported. ' + 'Use React.createContext() with static contextType instead.', name);
  11798. }
  11799. } else {
  11800. var noInstanceContextTypes = !instance.contextTypes;
  11801. !noInstanceContextTypes ? warningWithoutStack$1(false, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name) : void 0;
  11802. if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
  11803. didWarnAboutContextTypeAndContextTypes.add(ctor);
  11804. warningWithoutStack$1(false, '%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
  11805. }
  11806. }
  11807. var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';
  11808. !noComponentShouldUpdate ? warningWithoutStack$1(false, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name) : void 0;
  11809. if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
  11810. warningWithoutStack$1(false, '%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentName(ctor) || 'A pure component');
  11811. }
  11812. var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';
  11813. !noComponentDidUnmount ? warningWithoutStack$1(false, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name) : void 0;
  11814. var noComponentDidReceiveProps = typeof instance.componentDidReceiveProps !== 'function';
  11815. !noComponentDidReceiveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'componentDidReceiveProps(). But there is no such lifecycle method. ' + 'If you meant to update the state in response to changing props, ' + 'use componentWillReceiveProps(). If you meant to fetch data or ' + 'run side-effects or mutations after React has updated the UI, use componentDidUpdate().', name) : void 0;
  11816. var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';
  11817. !noComponentWillRecieveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name) : void 0;
  11818. var noUnsafeComponentWillRecieveProps = typeof instance.UNSAFE_componentWillRecieveProps !== 'function';
  11819. !noUnsafeComponentWillRecieveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name) : void 0;
  11820. var hasMutatedProps = instance.props !== newProps;
  11821. !(instance.props === undefined || !hasMutatedProps) ? warningWithoutStack$1(false, '%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name) : void 0;
  11822. var noInstanceDefaultProps = !instance.defaultProps;
  11823. !noInstanceDefaultProps ? warningWithoutStack$1(false, 'Setting defaultProps as an instance property on %s is not supported and will be ignored.' + ' Instead, define defaultProps as a static property on %s.', name, name) : void 0;
  11824. if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) {
  11825. didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor);
  11826. warningWithoutStack$1(false, '%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(ctor));
  11827. }
  11828. var noInstanceGetDerivedStateFromProps = typeof instance.getDerivedStateFromProps !== 'function';
  11829. !noInstanceGetDerivedStateFromProps ? warningWithoutStack$1(false, '%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
  11830. var noInstanceGetDerivedStateFromCatch = typeof instance.getDerivedStateFromError !== 'function';
  11831. !noInstanceGetDerivedStateFromCatch ? warningWithoutStack$1(false, '%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name) : void 0;
  11832. var noStaticGetSnapshotBeforeUpdate = typeof ctor.getSnapshotBeforeUpdate !== 'function';
  11833. !noStaticGetSnapshotBeforeUpdate ? warningWithoutStack$1(false, '%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name) : void 0;
  11834. var _state = instance.state;
  11835. if (_state && (typeof _state !== 'object' || isArray$1(_state))) {
  11836. warningWithoutStack$1(false, '%s.state: must be set to an object or null', name);
  11837. }
  11838. if (typeof instance.getChildContext === 'function') {
  11839. !(typeof ctor.childContextTypes === 'object') ? warningWithoutStack$1(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name) : void 0;
  11840. }
  11841. }
  11842. }
  11843. function adoptClassInstance(workInProgress, instance) {
  11844. instance.updater = classComponentUpdater;
  11845. workInProgress.stateNode = instance; // The instance needs access to the fiber so that it can schedule updates
  11846. set(instance, workInProgress);
  11847. {
  11848. instance._reactInternalInstance = fakeInternalInstance;
  11849. }
  11850. }
  11851. function constructClassInstance(workInProgress, ctor, props, renderExpirationTime) {
  11852. var isLegacyContextConsumer = false;
  11853. var unmaskedContext = emptyContextObject;
  11854. var context = emptyContextObject;
  11855. var contextType = ctor.contextType;
  11856. {
  11857. if ('contextType' in ctor) {
  11858. var isValid = // Allow null for conditional declaration
  11859. contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer>
  11860. if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
  11861. didWarnAboutInvalidateContextType.add(ctor);
  11862. var addendum = '';
  11863. if (contextType === undefined) {
  11864. addendum = ' However, it is set to undefined. ' + 'This can be caused by a typo or by mixing up named and default imports. ' + 'This can also happen due to a circular dependency, so ' + 'try moving the createContext() call to a separate file.';
  11865. } else if (typeof contextType !== 'object') {
  11866. addendum = ' However, it is set to a ' + typeof contextType + '.';
  11867. } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
  11868. addendum = ' Did you accidentally pass the Context.Provider instead?';
  11869. } else if (contextType._context !== undefined) {
  11870. // <Context.Consumer>
  11871. addendum = ' Did you accidentally pass the Context.Consumer instead?';
  11872. } else {
  11873. addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.';
  11874. }
  11875. warningWithoutStack$1(false, '%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum);
  11876. }
  11877. }
  11878. }
  11879. if (typeof contextType === 'object' && contextType !== null) {
  11880. context = readContext(contextType);
  11881. } else if (!disableLegacyContext) {
  11882. unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  11883. var contextTypes = ctor.contextTypes;
  11884. isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined;
  11885. context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject;
  11886. } // Instantiate twice to help detect side-effects.
  11887. {
  11888. if (debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  11889. new ctor(props, context); // eslint-disable-line no-new
  11890. }
  11891. }
  11892. var instance = new ctor(props, context);
  11893. var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null;
  11894. adoptClassInstance(workInProgress, instance);
  11895. {
  11896. if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) {
  11897. var componentName = getComponentName(ctor) || 'Component';
  11898. if (!didWarnAboutUninitializedState.has(componentName)) {
  11899. didWarnAboutUninitializedState.add(componentName);
  11900. warningWithoutStack$1(false, '`%s` uses `getDerivedStateFromProps` but its initial state is ' + '%s. This is not recommended. Instead, define the initial state by ' + 'assigning an object to `this.state` in the constructor of `%s`. ' + 'This ensures that `getDerivedStateFromProps` arguments have a consistent shape.', componentName, instance.state === null ? 'null' : 'undefined', componentName);
  11901. }
  11902. } // If new component APIs are defined, "unsafe" lifecycles won't be called.
  11903. // Warn about these lifecycles if they are present.
  11904. // Don't warn about react-lifecycles-compat polyfilled methods though.
  11905. if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') {
  11906. var foundWillMountName = null;
  11907. var foundWillReceivePropsName = null;
  11908. var foundWillUpdateName = null;
  11909. if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
  11910. foundWillMountName = 'componentWillMount';
  11911. } else if (typeof instance.UNSAFE_componentWillMount === 'function') {
  11912. foundWillMountName = 'UNSAFE_componentWillMount';
  11913. }
  11914. if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
  11915. foundWillReceivePropsName = 'componentWillReceiveProps';
  11916. } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  11917. foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
  11918. }
  11919. if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
  11920. foundWillUpdateName = 'componentWillUpdate';
  11921. } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
  11922. foundWillUpdateName = 'UNSAFE_componentWillUpdate';
  11923. }
  11924. if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
  11925. var _componentName = getComponentName(ctor) || 'Component';
  11926. var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()';
  11927. if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) {
  11928. didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName);
  11929. warningWithoutStack$1(false, 'Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' + '%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\n' + 'The above lifecycles should be removed. Learn more about this warning here:\n' + 'https://fb.me/react-unsafe-component-lifecycles', _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : '', foundWillReceivePropsName !== null ? "\n " + foundWillReceivePropsName : '', foundWillUpdateName !== null ? "\n " + foundWillUpdateName : '');
  11930. }
  11931. }
  11932. }
  11933. } // Cache unmasked context so we can avoid recreating masked context unless necessary.
  11934. // ReactFiberContext usually updates this cache but can't for newly-created instances.
  11935. if (isLegacyContextConsumer) {
  11936. cacheContext(workInProgress, unmaskedContext, context);
  11937. }
  11938. return instance;
  11939. }
  11940. function callComponentWillMount(workInProgress, instance) {
  11941. startPhaseTimer(workInProgress, 'componentWillMount');
  11942. var oldState = instance.state;
  11943. if (typeof instance.componentWillMount === 'function') {
  11944. instance.componentWillMount();
  11945. }
  11946. if (typeof instance.UNSAFE_componentWillMount === 'function') {
  11947. instance.UNSAFE_componentWillMount();
  11948. }
  11949. stopPhaseTimer();
  11950. if (oldState !== instance.state) {
  11951. {
  11952. warningWithoutStack$1(false, '%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress.type) || 'Component');
  11953. }
  11954. classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
  11955. }
  11956. }
  11957. function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) {
  11958. var oldState = instance.state;
  11959. startPhaseTimer(workInProgress, 'componentWillReceiveProps');
  11960. if (typeof instance.componentWillReceiveProps === 'function') {
  11961. instance.componentWillReceiveProps(newProps, nextContext);
  11962. }
  11963. if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  11964. instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
  11965. }
  11966. stopPhaseTimer();
  11967. if (instance.state !== oldState) {
  11968. {
  11969. var componentName = getComponentName(workInProgress.type) || 'Component';
  11970. if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
  11971. didWarnAboutStateAssignmentForComponent.add(componentName);
  11972. warningWithoutStack$1(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName);
  11973. }
  11974. }
  11975. classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
  11976. }
  11977. } // Invokes the mount life-cycles on a previously never rendered instance.
  11978. function mountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
  11979. {
  11980. checkClassInstance(workInProgress, ctor, newProps);
  11981. }
  11982. var instance = workInProgress.stateNode;
  11983. instance.props = newProps;
  11984. instance.state = workInProgress.memoizedState;
  11985. instance.refs = emptyRefsObject;
  11986. var contextType = ctor.contextType;
  11987. if (typeof contextType === 'object' && contextType !== null) {
  11988. instance.context = readContext(contextType);
  11989. } else if (disableLegacyContext) {
  11990. instance.context = emptyContextObject;
  11991. } else {
  11992. var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  11993. instance.context = getMaskedContext(workInProgress, unmaskedContext);
  11994. }
  11995. {
  11996. if (instance.state === newProps) {
  11997. var componentName = getComponentName(ctor) || 'Component';
  11998. if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) {
  11999. didWarnAboutDirectlyAssigningPropsToState.add(componentName);
  12000. warningWithoutStack$1(false, '%s: It is not recommended to assign props directly to state ' + "because updates to props won't be reflected in state. " + 'In most cases, it is better to use props directly.', componentName);
  12001. }
  12002. }
  12003. if (workInProgress.mode & StrictMode) {
  12004. ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance);
  12005. }
  12006. if (warnAboutDeprecatedLifecycles) {
  12007. ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance);
  12008. }
  12009. }
  12010. var updateQueue = workInProgress.updateQueue;
  12011. if (updateQueue !== null) {
  12012. processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
  12013. instance.state = workInProgress.memoizedState;
  12014. }
  12015. var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
  12016. if (typeof getDerivedStateFromProps === 'function') {
  12017. applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
  12018. instance.state = workInProgress.memoizedState;
  12019. } // In order to support react-lifecycles-compat polyfilled components,
  12020. // Unsafe lifecycles should not be invoked for components using the new APIs.
  12021. if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
  12022. callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's
  12023. // process them now.
  12024. updateQueue = workInProgress.updateQueue;
  12025. if (updateQueue !== null) {
  12026. processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
  12027. instance.state = workInProgress.memoizedState;
  12028. }
  12029. }
  12030. if (typeof instance.componentDidMount === 'function') {
  12031. workInProgress.effectTag |= Update;
  12032. }
  12033. }
  12034. function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
  12035. var instance = workInProgress.stateNode;
  12036. var oldProps = workInProgress.memoizedProps;
  12037. instance.props = oldProps;
  12038. var oldContext = instance.context;
  12039. var contextType = ctor.contextType;
  12040. var nextContext = emptyContextObject;
  12041. if (typeof contextType === 'object' && contextType !== null) {
  12042. nextContext = readContext(contextType);
  12043. } else if (!disableLegacyContext) {
  12044. var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  12045. nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext);
  12046. }
  12047. var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
  12048. var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what
  12049. // ever the previously attempted to render - not the "current". However,
  12050. // during componentDidUpdate we pass the "current" props.
  12051. // In order to support react-lifecycles-compat polyfilled components,
  12052. // Unsafe lifecycles should not be invoked for components using the new APIs.
  12053. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
  12054. if (oldProps !== newProps || oldContext !== nextContext) {
  12055. callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
  12056. }
  12057. }
  12058. resetHasForceUpdateBeforeProcessing();
  12059. var oldState = workInProgress.memoizedState;
  12060. var newState = instance.state = oldState;
  12061. var updateQueue = workInProgress.updateQueue;
  12062. if (updateQueue !== null) {
  12063. processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
  12064. newState = workInProgress.memoizedState;
  12065. }
  12066. if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
  12067. // If an update was already in progress, we should schedule an Update
  12068. // effect even though we're bailing out, so that cWU/cDU are called.
  12069. if (typeof instance.componentDidMount === 'function') {
  12070. workInProgress.effectTag |= Update;
  12071. }
  12072. return false;
  12073. }
  12074. if (typeof getDerivedStateFromProps === 'function') {
  12075. applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
  12076. newState = workInProgress.memoizedState;
  12077. }
  12078. var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
  12079. if (shouldUpdate) {
  12080. // In order to support react-lifecycles-compat polyfilled components,
  12081. // Unsafe lifecycles should not be invoked for components using the new APIs.
  12082. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
  12083. startPhaseTimer(workInProgress, 'componentWillMount');
  12084. if (typeof instance.componentWillMount === 'function') {
  12085. instance.componentWillMount();
  12086. }
  12087. if (typeof instance.UNSAFE_componentWillMount === 'function') {
  12088. instance.UNSAFE_componentWillMount();
  12089. }
  12090. stopPhaseTimer();
  12091. }
  12092. if (typeof instance.componentDidMount === 'function') {
  12093. workInProgress.effectTag |= Update;
  12094. }
  12095. } else {
  12096. // If an update was already in progress, we should schedule an Update
  12097. // effect even though we're bailing out, so that cWU/cDU are called.
  12098. if (typeof instance.componentDidMount === 'function') {
  12099. workInProgress.effectTag |= Update;
  12100. } // If shouldComponentUpdate returned false, we should still update the
  12101. // memoized state to indicate that this work can be reused.
  12102. workInProgress.memoizedProps = newProps;
  12103. workInProgress.memoizedState = newState;
  12104. } // Update the existing instance's state, props, and context pointers even
  12105. // if shouldComponentUpdate returns false.
  12106. instance.props = newProps;
  12107. instance.state = newState;
  12108. instance.context = nextContext;
  12109. return shouldUpdate;
  12110. } // Invokes the update life-cycles and returns false if it shouldn't rerender.
  12111. function updateClassInstance(current, workInProgress, ctor, newProps, renderExpirationTime) {
  12112. var instance = workInProgress.stateNode;
  12113. var oldProps = workInProgress.memoizedProps;
  12114. instance.props = workInProgress.type === workInProgress.elementType ? oldProps : resolveDefaultProps(workInProgress.type, oldProps);
  12115. var oldContext = instance.context;
  12116. var contextType = ctor.contextType;
  12117. var nextContext = emptyContextObject;
  12118. if (typeof contextType === 'object' && contextType !== null) {
  12119. nextContext = readContext(contextType);
  12120. } else if (!disableLegacyContext) {
  12121. var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  12122. nextContext = getMaskedContext(workInProgress, nextUnmaskedContext);
  12123. }
  12124. var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
  12125. var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what
  12126. // ever the previously attempted to render - not the "current". However,
  12127. // during componentDidUpdate we pass the "current" props.
  12128. // In order to support react-lifecycles-compat polyfilled components,
  12129. // Unsafe lifecycles should not be invoked for components using the new APIs.
  12130. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
  12131. if (oldProps !== newProps || oldContext !== nextContext) {
  12132. callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
  12133. }
  12134. }
  12135. resetHasForceUpdateBeforeProcessing();
  12136. var oldState = workInProgress.memoizedState;
  12137. var newState = instance.state = oldState;
  12138. var updateQueue = workInProgress.updateQueue;
  12139. if (updateQueue !== null) {
  12140. processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
  12141. newState = workInProgress.memoizedState;
  12142. }
  12143. if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
  12144. // If an update was already in progress, we should schedule an Update
  12145. // effect even though we're bailing out, so that cWU/cDU are called.
  12146. if (typeof instance.componentDidUpdate === 'function') {
  12147. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  12148. workInProgress.effectTag |= Update;
  12149. }
  12150. }
  12151. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  12152. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  12153. workInProgress.effectTag |= Snapshot;
  12154. }
  12155. }
  12156. return false;
  12157. }
  12158. if (typeof getDerivedStateFromProps === 'function') {
  12159. applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
  12160. newState = workInProgress.memoizedState;
  12161. }
  12162. var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
  12163. if (shouldUpdate) {
  12164. // In order to support react-lifecycles-compat polyfilled components,
  12165. // Unsafe lifecycles should not be invoked for components using the new APIs.
  12166. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) {
  12167. startPhaseTimer(workInProgress, 'componentWillUpdate');
  12168. if (typeof instance.componentWillUpdate === 'function') {
  12169. instance.componentWillUpdate(newProps, newState, nextContext);
  12170. }
  12171. if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
  12172. instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext);
  12173. }
  12174. stopPhaseTimer();
  12175. }
  12176. if (typeof instance.componentDidUpdate === 'function') {
  12177. workInProgress.effectTag |= Update;
  12178. }
  12179. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  12180. workInProgress.effectTag |= Snapshot;
  12181. }
  12182. } else {
  12183. // If an update was already in progress, we should schedule an Update
  12184. // effect even though we're bailing out, so that cWU/cDU are called.
  12185. if (typeof instance.componentDidUpdate === 'function') {
  12186. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  12187. workInProgress.effectTag |= Update;
  12188. }
  12189. }
  12190. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  12191. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  12192. workInProgress.effectTag |= Snapshot;
  12193. }
  12194. } // If shouldComponentUpdate returned false, we should still update the
  12195. // memoized props/state to indicate that this work can be reused.
  12196. workInProgress.memoizedProps = newProps;
  12197. workInProgress.memoizedState = newState;
  12198. } // Update the existing instance's state, props, and context pointers even
  12199. // if shouldComponentUpdate returns false.
  12200. instance.props = newProps;
  12201. instance.state = newState;
  12202. instance.context = nextContext;
  12203. return shouldUpdate;
  12204. }
  12205. var didWarnAboutMaps;
  12206. var didWarnAboutGenerators;
  12207. var didWarnAboutStringRefs;
  12208. var ownerHasKeyUseWarning;
  12209. var ownerHasFunctionTypeWarning;
  12210. var warnForMissingKey = function (child) {};
  12211. {
  12212. didWarnAboutMaps = false;
  12213. didWarnAboutGenerators = false;
  12214. didWarnAboutStringRefs = {};
  12215. /**
  12216. * Warn if there's no key explicitly set on dynamic arrays of children or
  12217. * object keys are not valid. This allows us to keep track of children between
  12218. * updates.
  12219. */
  12220. ownerHasKeyUseWarning = {};
  12221. ownerHasFunctionTypeWarning = {};
  12222. warnForMissingKey = function (child) {
  12223. if (child === null || typeof child !== 'object') {
  12224. return;
  12225. }
  12226. if (!child._store || child._store.validated || child.key != null) {
  12227. return;
  12228. }
  12229. if (!(typeof child._store === 'object')) {
  12230. {
  12231. throw Error("React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue.");
  12232. }
  12233. }
  12234. child._store.validated = true;
  12235. var currentComponentErrorInfo = 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.' + getCurrentFiberStackInDev();
  12236. if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
  12237. return;
  12238. }
  12239. ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
  12240. warning$1(false, 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.');
  12241. };
  12242. }
  12243. var isArray = Array.isArray;
  12244. function coerceRef(returnFiber, current$$1, element) {
  12245. var mixedRef = element.ref;
  12246. if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') {
  12247. {
  12248. // TODO: Clean this up once we turn on the string ref warning for
  12249. // everyone, because the strict mode case will no longer be relevant
  12250. if (returnFiber.mode & StrictMode || warnAboutStringRefs) {
  12251. var componentName = getComponentName(returnFiber.type) || 'Component';
  12252. if (!didWarnAboutStringRefs[componentName]) {
  12253. if (warnAboutStringRefs) {
  12254. warningWithoutStack$1(false, 'Component "%s" contains the string ref "%s". Support for string refs ' + 'will be removed in a future major release. We recommend using ' + 'useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-string-ref%s', componentName, mixedRef, getStackByFiberInDevAndProd(returnFiber));
  12255. } else {
  12256. warningWithoutStack$1(false, 'A string ref, "%s", has been found within a strict mode tree. ' + 'String refs are a source of potential bugs and should be avoided. ' + 'We recommend using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-string-ref%s', mixedRef, getStackByFiberInDevAndProd(returnFiber));
  12257. }
  12258. didWarnAboutStringRefs[componentName] = true;
  12259. }
  12260. }
  12261. }
  12262. if (element._owner) {
  12263. var owner = element._owner;
  12264. var inst;
  12265. if (owner) {
  12266. var ownerFiber = owner;
  12267. if (!(ownerFiber.tag === ClassComponent)) {
  12268. {
  12269. throw Error("Function components cannot have refs. Did you mean to use React.forwardRef()?");
  12270. }
  12271. }
  12272. inst = ownerFiber.stateNode;
  12273. }
  12274. if (!inst) {
  12275. {
  12276. throw Error("Missing owner for string ref " + mixedRef + ". This error is likely caused by a bug in React. Please file an issue.");
  12277. }
  12278. }
  12279. var stringRef = '' + mixedRef; // Check if previous string ref matches new string ref
  12280. if (current$$1 !== null && current$$1.ref !== null && typeof current$$1.ref === 'function' && current$$1.ref._stringRef === stringRef) {
  12281. return current$$1.ref;
  12282. }
  12283. var ref = function (value) {
  12284. var refs = inst.refs;
  12285. if (refs === emptyRefsObject) {
  12286. // This is a lazy pooled frozen object, so we need to initialize.
  12287. refs = inst.refs = {};
  12288. }
  12289. if (value === null) {
  12290. delete refs[stringRef];
  12291. } else {
  12292. refs[stringRef] = value;
  12293. }
  12294. };
  12295. ref._stringRef = stringRef;
  12296. return ref;
  12297. } else {
  12298. if (!(typeof mixedRef === 'string')) {
  12299. {
  12300. throw Error("Expected ref to be a function, a string, an object returned by React.createRef(), or null.");
  12301. }
  12302. }
  12303. if (!element._owner) {
  12304. {
  12305. throw Error("Element ref was specified as a string (" + mixedRef + ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information.");
  12306. }
  12307. }
  12308. }
  12309. }
  12310. return mixedRef;
  12311. }
  12312. function throwOnInvalidObjectType(returnFiber, newChild) {
  12313. if (returnFiber.type !== 'textarea') {
  12314. var addendum = '';
  12315. {
  12316. addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + getCurrentFiberStackInDev();
  12317. }
  12318. {
  12319. {
  12320. throw Error("Objects are not valid as a React child (found: " + (Object.prototype.toString.call(newChild) === '[object Object]' ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' : newChild) + ")." + addendum);
  12321. }
  12322. }
  12323. }
  12324. }
  12325. function warnOnFunctionType() {
  12326. var currentComponentErrorInfo = 'Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.' + getCurrentFiberStackInDev();
  12327. if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) {
  12328. return;
  12329. }
  12330. ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true;
  12331. warning$1(false, 'Functions are not valid as a React child. This may happen if ' + 'you return a Component instead of <Component /> from render. ' + 'Or maybe you meant to call this function rather than return it.');
  12332. } // This wrapper function exists because I expect to clone the code in each path
  12333. // to be able to optimize each path individually by branching early. This needs
  12334. // a compiler or we can do it manually. Helpers that don't need this branching
  12335. // live outside of this function.
  12336. function ChildReconciler(shouldTrackSideEffects) {
  12337. function deleteChild(returnFiber, childToDelete) {
  12338. if (!shouldTrackSideEffects) {
  12339. // Noop.
  12340. return;
  12341. } // Deletions are added in reversed order so we add it to the front.
  12342. // At this point, the return fiber's effect list is empty except for
  12343. // deletions, so we can just append the deletion to the list. The remaining
  12344. // effects aren't added until the complete phase. Once we implement
  12345. // resuming, this may not be true.
  12346. var last = returnFiber.lastEffect;
  12347. if (last !== null) {
  12348. last.nextEffect = childToDelete;
  12349. returnFiber.lastEffect = childToDelete;
  12350. } else {
  12351. returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
  12352. }
  12353. childToDelete.nextEffect = null;
  12354. childToDelete.effectTag = Deletion;
  12355. }
  12356. function deleteRemainingChildren(returnFiber, currentFirstChild) {
  12357. if (!shouldTrackSideEffects) {
  12358. // Noop.
  12359. return null;
  12360. } // TODO: For the shouldClone case, this could be micro-optimized a bit by
  12361. // assuming that after the first child we've already added everything.
  12362. var childToDelete = currentFirstChild;
  12363. while (childToDelete !== null) {
  12364. deleteChild(returnFiber, childToDelete);
  12365. childToDelete = childToDelete.sibling;
  12366. }
  12367. return null;
  12368. }
  12369. function mapRemainingChildren(returnFiber, currentFirstChild) {
  12370. // Add the remaining children to a temporary map so that we can find them by
  12371. // keys quickly. Implicit (null) keys get added to this set with their index
  12372. // instead.
  12373. var existingChildren = new Map();
  12374. var existingChild = currentFirstChild;
  12375. while (existingChild !== null) {
  12376. if (existingChild.key !== null) {
  12377. existingChildren.set(existingChild.key, existingChild);
  12378. } else {
  12379. existingChildren.set(existingChild.index, existingChild);
  12380. }
  12381. existingChild = existingChild.sibling;
  12382. }
  12383. return existingChildren;
  12384. }
  12385. function useFiber(fiber, pendingProps, expirationTime) {
  12386. // We currently set sibling to null and index to 0 here because it is easy
  12387. // to forget to do before returning it. E.g. for the single child case.
  12388. var clone = createWorkInProgress(fiber, pendingProps, expirationTime);
  12389. clone.index = 0;
  12390. clone.sibling = null;
  12391. return clone;
  12392. }
  12393. function placeChild(newFiber, lastPlacedIndex, newIndex) {
  12394. newFiber.index = newIndex;
  12395. if (!shouldTrackSideEffects) {
  12396. // Noop.
  12397. return lastPlacedIndex;
  12398. }
  12399. var current$$1 = newFiber.alternate;
  12400. if (current$$1 !== null) {
  12401. var oldIndex = current$$1.index;
  12402. if (oldIndex < lastPlacedIndex) {
  12403. // This is a move.
  12404. newFiber.effectTag = Placement;
  12405. return lastPlacedIndex;
  12406. } else {
  12407. // This item can stay in place.
  12408. return oldIndex;
  12409. }
  12410. } else {
  12411. // This is an insertion.
  12412. newFiber.effectTag = Placement;
  12413. return lastPlacedIndex;
  12414. }
  12415. }
  12416. function placeSingleChild(newFiber) {
  12417. // This is simpler for the single child case. We only need to do a
  12418. // placement for inserting new children.
  12419. if (shouldTrackSideEffects && newFiber.alternate === null) {
  12420. newFiber.effectTag = Placement;
  12421. }
  12422. return newFiber;
  12423. }
  12424. function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {
  12425. if (current$$1 === null || current$$1.tag !== HostText) {
  12426. // Insert
  12427. var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
  12428. created.return = returnFiber;
  12429. return created;
  12430. } else {
  12431. // Update
  12432. var existing = useFiber(current$$1, textContent, expirationTime);
  12433. existing.return = returnFiber;
  12434. return existing;
  12435. }
  12436. }
  12437. function updateElement(returnFiber, current$$1, element, expirationTime) {
  12438. if (current$$1 !== null && (current$$1.elementType === element.type || ( // Keep this check inline so it only runs on the false path:
  12439. isCompatibleFamilyForHotReloading(current$$1, element)))) {
  12440. // Move based on index
  12441. var existing = useFiber(current$$1, element.props, expirationTime);
  12442. existing.ref = coerceRef(returnFiber, current$$1, element);
  12443. existing.return = returnFiber;
  12444. {
  12445. existing._debugSource = element._source;
  12446. existing._debugOwner = element._owner;
  12447. }
  12448. return existing;
  12449. } else {
  12450. // Insert
  12451. var created = createFiberFromElement(element, returnFiber.mode, expirationTime);
  12452. created.ref = coerceRef(returnFiber, current$$1, element);
  12453. created.return = returnFiber;
  12454. return created;
  12455. }
  12456. }
  12457. function updatePortal(returnFiber, current$$1, portal, expirationTime) {
  12458. if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {
  12459. // Insert
  12460. var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
  12461. created.return = returnFiber;
  12462. return created;
  12463. } else {
  12464. // Update
  12465. var existing = useFiber(current$$1, portal.children || [], expirationTime);
  12466. existing.return = returnFiber;
  12467. return existing;
  12468. }
  12469. }
  12470. function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {
  12471. if (current$$1 === null || current$$1.tag !== Fragment) {
  12472. // Insert
  12473. var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);
  12474. created.return = returnFiber;
  12475. return created;
  12476. } else {
  12477. // Update
  12478. var existing = useFiber(current$$1, fragment, expirationTime);
  12479. existing.return = returnFiber;
  12480. return existing;
  12481. }
  12482. }
  12483. function createChild(returnFiber, newChild, expirationTime) {
  12484. if (typeof newChild === 'string' || typeof newChild === 'number') {
  12485. // Text nodes don't have keys. If the previous node is implicitly keyed
  12486. // we can continue to replace it without aborting even if it is not a text
  12487. // node.
  12488. var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);
  12489. created.return = returnFiber;
  12490. return created;
  12491. }
  12492. if (typeof newChild === 'object' && newChild !== null) {
  12493. switch (newChild.$$typeof) {
  12494. case REACT_ELEMENT_TYPE:
  12495. {
  12496. var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);
  12497. _created.ref = coerceRef(returnFiber, null, newChild);
  12498. _created.return = returnFiber;
  12499. return _created;
  12500. }
  12501. case REACT_PORTAL_TYPE:
  12502. {
  12503. var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);
  12504. _created2.return = returnFiber;
  12505. return _created2;
  12506. }
  12507. }
  12508. if (isArray(newChild) || getIteratorFn(newChild)) {
  12509. var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);
  12510. _created3.return = returnFiber;
  12511. return _created3;
  12512. }
  12513. throwOnInvalidObjectType(returnFiber, newChild);
  12514. }
  12515. {
  12516. if (typeof newChild === 'function') {
  12517. warnOnFunctionType();
  12518. }
  12519. }
  12520. return null;
  12521. }
  12522. function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
  12523. // Update the fiber if the keys match, otherwise return null.
  12524. var key = oldFiber !== null ? oldFiber.key : null;
  12525. if (typeof newChild === 'string' || typeof newChild === 'number') {
  12526. // Text nodes don't have keys. If the previous node is implicitly keyed
  12527. // we can continue to replace it without aborting even if it is not a text
  12528. // node.
  12529. if (key !== null) {
  12530. return null;
  12531. }
  12532. return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);
  12533. }
  12534. if (typeof newChild === 'object' && newChild !== null) {
  12535. switch (newChild.$$typeof) {
  12536. case REACT_ELEMENT_TYPE:
  12537. {
  12538. if (newChild.key === key) {
  12539. if (newChild.type === REACT_FRAGMENT_TYPE) {
  12540. return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);
  12541. }
  12542. return updateElement(returnFiber, oldFiber, newChild, expirationTime);
  12543. } else {
  12544. return null;
  12545. }
  12546. }
  12547. case REACT_PORTAL_TYPE:
  12548. {
  12549. if (newChild.key === key) {
  12550. return updatePortal(returnFiber, oldFiber, newChild, expirationTime);
  12551. } else {
  12552. return null;
  12553. }
  12554. }
  12555. }
  12556. if (isArray(newChild) || getIteratorFn(newChild)) {
  12557. if (key !== null) {
  12558. return null;
  12559. }
  12560. return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);
  12561. }
  12562. throwOnInvalidObjectType(returnFiber, newChild);
  12563. }
  12564. {
  12565. if (typeof newChild === 'function') {
  12566. warnOnFunctionType();
  12567. }
  12568. }
  12569. return null;
  12570. }
  12571. function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {
  12572. if (typeof newChild === 'string' || typeof newChild === 'number') {
  12573. // Text nodes don't have keys, so we neither have to check the old nor
  12574. // new node for the key. If both are text nodes, they match.
  12575. var matchedFiber = existingChildren.get(newIdx) || null;
  12576. return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);
  12577. }
  12578. if (typeof newChild === 'object' && newChild !== null) {
  12579. switch (newChild.$$typeof) {
  12580. case REACT_ELEMENT_TYPE:
  12581. {
  12582. var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
  12583. if (newChild.type === REACT_FRAGMENT_TYPE) {
  12584. return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);
  12585. }
  12586. return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);
  12587. }
  12588. case REACT_PORTAL_TYPE:
  12589. {
  12590. var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
  12591. return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);
  12592. }
  12593. }
  12594. if (isArray(newChild) || getIteratorFn(newChild)) {
  12595. var _matchedFiber3 = existingChildren.get(newIdx) || null;
  12596. return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
  12597. }
  12598. throwOnInvalidObjectType(returnFiber, newChild);
  12599. }
  12600. {
  12601. if (typeof newChild === 'function') {
  12602. warnOnFunctionType();
  12603. }
  12604. }
  12605. return null;
  12606. }
  12607. /**
  12608. * Warns if there is a duplicate or missing key
  12609. */
  12610. function warnOnInvalidKey(child, knownKeys) {
  12611. {
  12612. if (typeof child !== 'object' || child === null) {
  12613. return knownKeys;
  12614. }
  12615. switch (child.$$typeof) {
  12616. case REACT_ELEMENT_TYPE:
  12617. case REACT_PORTAL_TYPE:
  12618. warnForMissingKey(child);
  12619. var key = child.key;
  12620. if (typeof key !== 'string') {
  12621. break;
  12622. }
  12623. if (knownKeys === null) {
  12624. knownKeys = new Set();
  12625. knownKeys.add(key);
  12626. break;
  12627. }
  12628. if (!knownKeys.has(key)) {
  12629. knownKeys.add(key);
  12630. break;
  12631. }
  12632. warning$1(false, 'Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key);
  12633. break;
  12634. default:
  12635. break;
  12636. }
  12637. }
  12638. return knownKeys;
  12639. }
  12640. function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
  12641. // This algorithm can't optimize by searching from both ends since we
  12642. // don't have backpointers on fibers. I'm trying to see how far we can get
  12643. // with that model. If it ends up not being worth the tradeoffs, we can
  12644. // add it later.
  12645. // Even with a two ended optimization, we'd want to optimize for the case
  12646. // where there are few changes and brute force the comparison instead of
  12647. // going for the Map. It'd like to explore hitting that path first in
  12648. // forward-only mode and only go for the Map once we notice that we need
  12649. // lots of look ahead. This doesn't handle reversal as well as two ended
  12650. // search but that's unusual. Besides, for the two ended optimization to
  12651. // work on Iterables, we'd need to copy the whole set.
  12652. // In this first iteration, we'll just live with hitting the bad case
  12653. // (adding everything to a Map) in for every insert/move.
  12654. // If you change this code, also update reconcileChildrenIterator() which
  12655. // uses the same algorithm.
  12656. {
  12657. // First, validate keys.
  12658. var knownKeys = null;
  12659. for (var i = 0; i < newChildren.length; i++) {
  12660. var child = newChildren[i];
  12661. knownKeys = warnOnInvalidKey(child, knownKeys);
  12662. }
  12663. }
  12664. var resultingFirstChild = null;
  12665. var previousNewFiber = null;
  12666. var oldFiber = currentFirstChild;
  12667. var lastPlacedIndex = 0;
  12668. var newIdx = 0;
  12669. var nextOldFiber = null;
  12670. for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {
  12671. if (oldFiber.index > newIdx) {
  12672. nextOldFiber = oldFiber;
  12673. oldFiber = null;
  12674. } else {
  12675. nextOldFiber = oldFiber.sibling;
  12676. }
  12677. var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);
  12678. if (newFiber === null) {
  12679. // TODO: This breaks on empty slots like null children. That's
  12680. // unfortunate because it triggers the slow path all the time. We need
  12681. // a better way to communicate whether this was a miss or null,
  12682. // boolean, undefined, etc.
  12683. if (oldFiber === null) {
  12684. oldFiber = nextOldFiber;
  12685. }
  12686. break;
  12687. }
  12688. if (shouldTrackSideEffects) {
  12689. if (oldFiber && newFiber.alternate === null) {
  12690. // We matched the slot, but we didn't reuse the existing fiber, so we
  12691. // need to delete the existing child.
  12692. deleteChild(returnFiber, oldFiber);
  12693. }
  12694. }
  12695. lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
  12696. if (previousNewFiber === null) {
  12697. // TODO: Move out of the loop. This only happens for the first run.
  12698. resultingFirstChild = newFiber;
  12699. } else {
  12700. // TODO: Defer siblings if we're not at the right index for this slot.
  12701. // I.e. if we had null values before, then we want to defer this
  12702. // for each null value. However, we also don't want to call updateSlot
  12703. // with the previous one.
  12704. previousNewFiber.sibling = newFiber;
  12705. }
  12706. previousNewFiber = newFiber;
  12707. oldFiber = nextOldFiber;
  12708. }
  12709. if (newIdx === newChildren.length) {
  12710. // We've reached the end of the new children. We can delete the rest.
  12711. deleteRemainingChildren(returnFiber, oldFiber);
  12712. return resultingFirstChild;
  12713. }
  12714. if (oldFiber === null) {
  12715. // If we don't have any more existing children we can choose a fast path
  12716. // since the rest will all be insertions.
  12717. for (; newIdx < newChildren.length; newIdx++) {
  12718. var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);
  12719. if (_newFiber === null) {
  12720. continue;
  12721. }
  12722. lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);
  12723. if (previousNewFiber === null) {
  12724. // TODO: Move out of the loop. This only happens for the first run.
  12725. resultingFirstChild = _newFiber;
  12726. } else {
  12727. previousNewFiber.sibling = _newFiber;
  12728. }
  12729. previousNewFiber = _newFiber;
  12730. }
  12731. return resultingFirstChild;
  12732. } // Add all children to a key map for quick lookups.
  12733. var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.
  12734. for (; newIdx < newChildren.length; newIdx++) {
  12735. var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);
  12736. if (_newFiber2 !== null) {
  12737. if (shouldTrackSideEffects) {
  12738. if (_newFiber2.alternate !== null) {
  12739. // The new fiber is a work in progress, but if there exists a
  12740. // current, that means that we reused the fiber. We need to delete
  12741. // it from the child list so that we don't add it to the deletion
  12742. // list.
  12743. existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);
  12744. }
  12745. }
  12746. lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);
  12747. if (previousNewFiber === null) {
  12748. resultingFirstChild = _newFiber2;
  12749. } else {
  12750. previousNewFiber.sibling = _newFiber2;
  12751. }
  12752. previousNewFiber = _newFiber2;
  12753. }
  12754. }
  12755. if (shouldTrackSideEffects) {
  12756. // Any existing children that weren't consumed above were deleted. We need
  12757. // to add them to the deletion list.
  12758. existingChildren.forEach(function (child) {
  12759. return deleteChild(returnFiber, child);
  12760. });
  12761. }
  12762. return resultingFirstChild;
  12763. }
  12764. function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {
  12765. // This is the same implementation as reconcileChildrenArray(),
  12766. // but using the iterator instead.
  12767. var iteratorFn = getIteratorFn(newChildrenIterable);
  12768. if (!(typeof iteratorFn === 'function')) {
  12769. {
  12770. throw Error("An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.");
  12771. }
  12772. }
  12773. {
  12774. // We don't support rendering Generators because it's a mutation.
  12775. // See https://github.com/facebook/react/issues/12995
  12776. if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag
  12777. newChildrenIterable[Symbol.toStringTag] === 'Generator') {
  12778. !didWarnAboutGenerators ? warning$1(false, 'Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.') : void 0;
  12779. didWarnAboutGenerators = true;
  12780. } // Warn about using Maps as children
  12781. if (newChildrenIterable.entries === iteratorFn) {
  12782. !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;
  12783. didWarnAboutMaps = true;
  12784. } // First, validate keys.
  12785. // We'll get a different iterator later for the main pass.
  12786. var _newChildren = iteratorFn.call(newChildrenIterable);
  12787. if (_newChildren) {
  12788. var knownKeys = null;
  12789. var _step = _newChildren.next();
  12790. for (; !_step.done; _step = _newChildren.next()) {
  12791. var child = _step.value;
  12792. knownKeys = warnOnInvalidKey(child, knownKeys);
  12793. }
  12794. }
  12795. }
  12796. var newChildren = iteratorFn.call(newChildrenIterable);
  12797. if (!(newChildren != null)) {
  12798. {
  12799. throw Error("An iterable object provided no iterator.");
  12800. }
  12801. }
  12802. var resultingFirstChild = null;
  12803. var previousNewFiber = null;
  12804. var oldFiber = currentFirstChild;
  12805. var lastPlacedIndex = 0;
  12806. var newIdx = 0;
  12807. var nextOldFiber = null;
  12808. var step = newChildren.next();
  12809. for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {
  12810. if (oldFiber.index > newIdx) {
  12811. nextOldFiber = oldFiber;
  12812. oldFiber = null;
  12813. } else {
  12814. nextOldFiber = oldFiber.sibling;
  12815. }
  12816. var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);
  12817. if (newFiber === null) {
  12818. // TODO: This breaks on empty slots like null children. That's
  12819. // unfortunate because it triggers the slow path all the time. We need
  12820. // a better way to communicate whether this was a miss or null,
  12821. // boolean, undefined, etc.
  12822. if (oldFiber === null) {
  12823. oldFiber = nextOldFiber;
  12824. }
  12825. break;
  12826. }
  12827. if (shouldTrackSideEffects) {
  12828. if (oldFiber && newFiber.alternate === null) {
  12829. // We matched the slot, but we didn't reuse the existing fiber, so we
  12830. // need to delete the existing child.
  12831. deleteChild(returnFiber, oldFiber);
  12832. }
  12833. }
  12834. lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
  12835. if (previousNewFiber === null) {
  12836. // TODO: Move out of the loop. This only happens for the first run.
  12837. resultingFirstChild = newFiber;
  12838. } else {
  12839. // TODO: Defer siblings if we're not at the right index for this slot.
  12840. // I.e. if we had null values before, then we want to defer this
  12841. // for each null value. However, we also don't want to call updateSlot
  12842. // with the previous one.
  12843. previousNewFiber.sibling = newFiber;
  12844. }
  12845. previousNewFiber = newFiber;
  12846. oldFiber = nextOldFiber;
  12847. }
  12848. if (step.done) {
  12849. // We've reached the end of the new children. We can delete the rest.
  12850. deleteRemainingChildren(returnFiber, oldFiber);
  12851. return resultingFirstChild;
  12852. }
  12853. if (oldFiber === null) {
  12854. // If we don't have any more existing children we can choose a fast path
  12855. // since the rest will all be insertions.
  12856. for (; !step.done; newIdx++, step = newChildren.next()) {
  12857. var _newFiber3 = createChild(returnFiber, step.value, expirationTime);
  12858. if (_newFiber3 === null) {
  12859. continue;
  12860. }
  12861. lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);
  12862. if (previousNewFiber === null) {
  12863. // TODO: Move out of the loop. This only happens for the first run.
  12864. resultingFirstChild = _newFiber3;
  12865. } else {
  12866. previousNewFiber.sibling = _newFiber3;
  12867. }
  12868. previousNewFiber = _newFiber3;
  12869. }
  12870. return resultingFirstChild;
  12871. } // Add all children to a key map for quick lookups.
  12872. var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.
  12873. for (; !step.done; newIdx++, step = newChildren.next()) {
  12874. var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);
  12875. if (_newFiber4 !== null) {
  12876. if (shouldTrackSideEffects) {
  12877. if (_newFiber4.alternate !== null) {
  12878. // The new fiber is a work in progress, but if there exists a
  12879. // current, that means that we reused the fiber. We need to delete
  12880. // it from the child list so that we don't add it to the deletion
  12881. // list.
  12882. existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);
  12883. }
  12884. }
  12885. lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);
  12886. if (previousNewFiber === null) {
  12887. resultingFirstChild = _newFiber4;
  12888. } else {
  12889. previousNewFiber.sibling = _newFiber4;
  12890. }
  12891. previousNewFiber = _newFiber4;
  12892. }
  12893. }
  12894. if (shouldTrackSideEffects) {
  12895. // Any existing children that weren't consumed above were deleted. We need
  12896. // to add them to the deletion list.
  12897. existingChildren.forEach(function (child) {
  12898. return deleteChild(returnFiber, child);
  12899. });
  12900. }
  12901. return resultingFirstChild;
  12902. }
  12903. function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {
  12904. // There's no need to check for keys on text nodes since we don't have a
  12905. // way to define them.
  12906. if (currentFirstChild !== null && currentFirstChild.tag === HostText) {
  12907. // We already have an existing node so let's just update it and delete
  12908. // the rest.
  12909. deleteRemainingChildren(returnFiber, currentFirstChild.sibling);
  12910. var existing = useFiber(currentFirstChild, textContent, expirationTime);
  12911. existing.return = returnFiber;
  12912. return existing;
  12913. } // The existing first child is not a text node so we need to create one
  12914. // and delete the existing ones.
  12915. deleteRemainingChildren(returnFiber, currentFirstChild);
  12916. var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
  12917. created.return = returnFiber;
  12918. return created;
  12919. }
  12920. function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {
  12921. var key = element.key;
  12922. var child = currentFirstChild;
  12923. while (child !== null) {
  12924. // TODO: If key === null and child.key === null, then this only applies to
  12925. // the first item in the list.
  12926. if (child.key === key) {
  12927. if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:
  12928. isCompatibleFamilyForHotReloading(child, element))) {
  12929. deleteRemainingChildren(returnFiber, child.sibling);
  12930. var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);
  12931. existing.ref = coerceRef(returnFiber, child, element);
  12932. existing.return = returnFiber;
  12933. {
  12934. existing._debugSource = element._source;
  12935. existing._debugOwner = element._owner;
  12936. }
  12937. return existing;
  12938. } else {
  12939. deleteRemainingChildren(returnFiber, child);
  12940. break;
  12941. }
  12942. } else {
  12943. deleteChild(returnFiber, child);
  12944. }
  12945. child = child.sibling;
  12946. }
  12947. if (element.type === REACT_FRAGMENT_TYPE) {
  12948. var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);
  12949. created.return = returnFiber;
  12950. return created;
  12951. } else {
  12952. var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);
  12953. _created4.ref = coerceRef(returnFiber, currentFirstChild, element);
  12954. _created4.return = returnFiber;
  12955. return _created4;
  12956. }
  12957. }
  12958. function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {
  12959. var key = portal.key;
  12960. var child = currentFirstChild;
  12961. while (child !== null) {
  12962. // TODO: If key === null and child.key === null, then this only applies to
  12963. // the first item in the list.
  12964. if (child.key === key) {
  12965. if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {
  12966. deleteRemainingChildren(returnFiber, child.sibling);
  12967. var existing = useFiber(child, portal.children || [], expirationTime);
  12968. existing.return = returnFiber;
  12969. return existing;
  12970. } else {
  12971. deleteRemainingChildren(returnFiber, child);
  12972. break;
  12973. }
  12974. } else {
  12975. deleteChild(returnFiber, child);
  12976. }
  12977. child = child.sibling;
  12978. }
  12979. var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
  12980. created.return = returnFiber;
  12981. return created;
  12982. } // This API will tag the children with the side-effect of the reconciliation
  12983. // itself. They will be added to the side-effect list as we pass through the
  12984. // children and the parent.
  12985. function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {
  12986. // This function is not recursive.
  12987. // If the top level item is an array, we treat it as a set of children,
  12988. // not as a fragment. Nested arrays on the other hand will be treated as
  12989. // fragment nodes. Recursion happens at the normal flow.
  12990. // Handle top level unkeyed fragments as if they were arrays.
  12991. // This leads to an ambiguity between <>{[...]}</> and <>...</>.
  12992. // We treat the ambiguous cases above the same.
  12993. var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;
  12994. if (isUnkeyedTopLevelFragment) {
  12995. newChild = newChild.props.children;
  12996. } // Handle object types
  12997. var isObject = typeof newChild === 'object' && newChild !== null;
  12998. if (isObject) {
  12999. switch (newChild.$$typeof) {
  13000. case REACT_ELEMENT_TYPE:
  13001. return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));
  13002. case REACT_PORTAL_TYPE:
  13003. return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));
  13004. }
  13005. }
  13006. if (typeof newChild === 'string' || typeof newChild === 'number') {
  13007. return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));
  13008. }
  13009. if (isArray(newChild)) {
  13010. return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);
  13011. }
  13012. if (getIteratorFn(newChild)) {
  13013. return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);
  13014. }
  13015. if (isObject) {
  13016. throwOnInvalidObjectType(returnFiber, newChild);
  13017. }
  13018. {
  13019. if (typeof newChild === 'function') {
  13020. warnOnFunctionType();
  13021. }
  13022. }
  13023. if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {
  13024. // If the new child is undefined, and the return fiber is a composite
  13025. // component, throw an error. If Fiber return types are disabled,
  13026. // we already threw above.
  13027. switch (returnFiber.tag) {
  13028. case ClassComponent:
  13029. {
  13030. {
  13031. var instance = returnFiber.stateNode;
  13032. if (instance.render._isMockFunction) {
  13033. // We allow auto-mocks to proceed as if they're returning null.
  13034. break;
  13035. }
  13036. }
  13037. }
  13038. // Intentionally fall through to the next case, which handles both
  13039. // functions and classes
  13040. // eslint-disable-next-lined no-fallthrough
  13041. case FunctionComponent:
  13042. {
  13043. var Component = returnFiber.type;
  13044. {
  13045. {
  13046. throw Error((Component.displayName || Component.name || 'Component') + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.");
  13047. }
  13048. }
  13049. }
  13050. }
  13051. } // Remaining cases are all treated as empty.
  13052. return deleteRemainingChildren(returnFiber, currentFirstChild);
  13053. }
  13054. return reconcileChildFibers;
  13055. }
  13056. var reconcileChildFibers = ChildReconciler(true);
  13057. var mountChildFibers = ChildReconciler(false);
  13058. function cloneChildFibers(current$$1, workInProgress) {
  13059. if (!(current$$1 === null || workInProgress.child === current$$1.child)) {
  13060. {
  13061. throw Error("Resuming work not yet implemented.");
  13062. }
  13063. }
  13064. if (workInProgress.child === null) {
  13065. return;
  13066. }
  13067. var currentChild = workInProgress.child;
  13068. var newChild = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
  13069. workInProgress.child = newChild;
  13070. newChild.return = workInProgress;
  13071. while (currentChild.sibling !== null) {
  13072. currentChild = currentChild.sibling;
  13073. newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
  13074. newChild.return = workInProgress;
  13075. }
  13076. newChild.sibling = null;
  13077. } // Reset a workInProgress child set to prepare it for a second pass.
  13078. function resetChildFibers(workInProgress, renderExpirationTime) {
  13079. var child = workInProgress.child;
  13080. while (child !== null) {
  13081. resetWorkInProgress(child, renderExpirationTime);
  13082. child = child.sibling;
  13083. }
  13084. }
  13085. var NO_CONTEXT = {};
  13086. var contextStackCursor$1 = createCursor(NO_CONTEXT);
  13087. var contextFiberStackCursor = createCursor(NO_CONTEXT);
  13088. var rootInstanceStackCursor = createCursor(NO_CONTEXT);
  13089. function requiredContext(c) {
  13090. if (!(c !== NO_CONTEXT)) {
  13091. {
  13092. throw Error("Expected host context to exist. This error is likely caused by a bug in React. Please file an issue.");
  13093. }
  13094. }
  13095. return c;
  13096. }
  13097. function getRootHostContainer() {
  13098. var rootInstance = requiredContext(rootInstanceStackCursor.current);
  13099. return rootInstance;
  13100. }
  13101. function pushHostContainer(fiber, nextRootInstance) {
  13102. // Push current root instance onto the stack;
  13103. // This allows us to reset root when portals are popped.
  13104. push(rootInstanceStackCursor, nextRootInstance, fiber); // Track the context and the Fiber that provided it.
  13105. // This enables us to pop only Fibers that provide unique contexts.
  13106. push(contextFiberStackCursor, fiber, fiber); // Finally, we need to push the host context to the stack.
  13107. // However, we can't just call getRootHostContext() and push it because
  13108. // we'd have a different number of entries on the stack depending on
  13109. // whether getRootHostContext() throws somewhere in renderer code or not.
  13110. // So we push an empty value first. This lets us safely unwind on errors.
  13111. push(contextStackCursor$1, NO_CONTEXT, fiber);
  13112. var nextRootContext = getRootHostContext(nextRootInstance); // Now that we know this function doesn't throw, replace it.
  13113. pop(contextStackCursor$1, fiber);
  13114. push(contextStackCursor$1, nextRootContext, fiber);
  13115. }
  13116. function popHostContainer(fiber) {
  13117. pop(contextStackCursor$1, fiber);
  13118. pop(contextFiberStackCursor, fiber);
  13119. pop(rootInstanceStackCursor, fiber);
  13120. }
  13121. function getHostContext() {
  13122. var context = requiredContext(contextStackCursor$1.current);
  13123. return context;
  13124. }
  13125. function pushHostContext(fiber) {
  13126. var rootInstance = requiredContext(rootInstanceStackCursor.current);
  13127. var context = requiredContext(contextStackCursor$1.current);
  13128. var nextContext = getChildHostContext(context, fiber.type, rootInstance); // Don't push this Fiber's context unless it's unique.
  13129. if (context === nextContext) {
  13130. return;
  13131. } // Track the context and the Fiber that provided it.
  13132. // This enables us to pop only Fibers that provide unique contexts.
  13133. push(contextFiberStackCursor, fiber, fiber);
  13134. push(contextStackCursor$1, nextContext, fiber);
  13135. }
  13136. function popHostContext(fiber) {
  13137. // Do not pop unless this Fiber provided the current context.
  13138. // pushHostContext() only pushes Fibers that provide unique contexts.
  13139. if (contextFiberStackCursor.current !== fiber) {
  13140. return;
  13141. }
  13142. pop(contextStackCursor$1, fiber);
  13143. pop(contextFiberStackCursor, fiber);
  13144. }
  13145. var DefaultSuspenseContext = 0; // The Suspense Context is split into two parts. The lower bits is
  13146. // inherited deeply down the subtree. The upper bits only affect
  13147. // this immediate suspense boundary and gets reset each new
  13148. // boundary or suspense list.
  13149. var SubtreeSuspenseContextMask = 1; // Subtree Flags:
  13150. // InvisibleParentSuspenseContext indicates that one of our parent Suspense
  13151. // boundaries is not currently showing visible main content.
  13152. // Either because it is already showing a fallback or is not mounted at all.
  13153. // We can use this to determine if it is desirable to trigger a fallback at
  13154. // the parent. If not, then we might need to trigger undesirable boundaries
  13155. // and/or suspend the commit to avoid hiding the parent content.
  13156. var InvisibleParentSuspenseContext = 1; // Shallow Flags:
  13157. // ForceSuspenseFallback can be used by SuspenseList to force newly added
  13158. // items into their fallback state during one of the render passes.
  13159. var ForceSuspenseFallback = 2;
  13160. var suspenseStackCursor = createCursor(DefaultSuspenseContext);
  13161. function hasSuspenseContext(parentContext, flag) {
  13162. return (parentContext & flag) !== 0;
  13163. }
  13164. function setDefaultShallowSuspenseContext(parentContext) {
  13165. return parentContext & SubtreeSuspenseContextMask;
  13166. }
  13167. function setShallowSuspenseContext(parentContext, shallowContext) {
  13168. return parentContext & SubtreeSuspenseContextMask | shallowContext;
  13169. }
  13170. function addSubtreeSuspenseContext(parentContext, subtreeContext) {
  13171. return parentContext | subtreeContext;
  13172. }
  13173. function pushSuspenseContext(fiber, newContext) {
  13174. push(suspenseStackCursor, newContext, fiber);
  13175. }
  13176. function popSuspenseContext(fiber) {
  13177. pop(suspenseStackCursor, fiber);
  13178. }
  13179. function shouldCaptureSuspense(workInProgress, hasInvisibleParent) {
  13180. // If it was the primary children that just suspended, capture and render the
  13181. // fallback. Otherwise, don't capture and bubble to the next boundary.
  13182. var nextState = workInProgress.memoizedState;
  13183. if (nextState !== null) {
  13184. if (nextState.dehydrated !== null) {
  13185. // A dehydrated boundary always captures.
  13186. return true;
  13187. }
  13188. return false;
  13189. }
  13190. var props = workInProgress.memoizedProps; // In order to capture, the Suspense component must have a fallback prop.
  13191. if (props.fallback === undefined) {
  13192. return false;
  13193. } // Regular boundaries always capture.
  13194. if (props.unstable_avoidThisFallback !== true) {
  13195. return true;
  13196. } // If it's a boundary we should avoid, then we prefer to bubble up to the
  13197. // parent boundary if it is currently invisible.
  13198. if (hasInvisibleParent) {
  13199. return false;
  13200. } // If the parent is not able to handle it, we must handle it.
  13201. return true;
  13202. }
  13203. function findFirstSuspended(row) {
  13204. var node = row;
  13205. while (node !== null) {
  13206. if (node.tag === SuspenseComponent) {
  13207. var state = node.memoizedState;
  13208. if (state !== null) {
  13209. var dehydrated = state.dehydrated;
  13210. if (dehydrated === null || isSuspenseInstancePending(dehydrated) || isSuspenseInstanceFallback(dehydrated)) {
  13211. return node;
  13212. }
  13213. }
  13214. } else if (node.tag === SuspenseListComponent && // revealOrder undefined can't be trusted because it don't
  13215. // keep track of whether it suspended or not.
  13216. node.memoizedProps.revealOrder !== undefined) {
  13217. var didSuspend = (node.effectTag & DidCapture) !== NoEffect;
  13218. if (didSuspend) {
  13219. return node;
  13220. }
  13221. } else if (node.child !== null) {
  13222. node.child.return = node;
  13223. node = node.child;
  13224. continue;
  13225. }
  13226. if (node === row) {
  13227. return null;
  13228. }
  13229. while (node.sibling === null) {
  13230. if (node.return === null || node.return === row) {
  13231. return null;
  13232. }
  13233. node = node.return;
  13234. }
  13235. node.sibling.return = node.return;
  13236. node = node.sibling;
  13237. }
  13238. return null;
  13239. }
  13240. var emptyObject = {};
  13241. var isArray$2 = Array.isArray;
  13242. function createResponderInstance(responder, responderProps, responderState, fiber) {
  13243. return {
  13244. fiber: fiber,
  13245. props: responderProps,
  13246. responder: responder,
  13247. rootEventTypes: null,
  13248. state: responderState
  13249. };
  13250. }
  13251. function mountEventResponder$1(responder, responderProps, fiber, respondersMap, rootContainerInstance) {
  13252. var responderState = emptyObject;
  13253. var getInitialState = responder.getInitialState;
  13254. if (getInitialState !== null) {
  13255. responderState = getInitialState(responderProps);
  13256. }
  13257. var responderInstance = createResponderInstance(responder, responderProps, responderState, fiber);
  13258. if (!rootContainerInstance) {
  13259. var node = fiber;
  13260. while (node !== null) {
  13261. var tag = node.tag;
  13262. if (tag === HostComponent) {
  13263. rootContainerInstance = node.stateNode;
  13264. break;
  13265. } else if (tag === HostRoot) {
  13266. rootContainerInstance = node.stateNode.containerInfo;
  13267. break;
  13268. }
  13269. node = node.return;
  13270. }
  13271. }
  13272. mountResponderInstance(responder, responderInstance, responderProps, responderState, rootContainerInstance);
  13273. respondersMap.set(responder, responderInstance);
  13274. }
  13275. function updateEventListener(listener, fiber, visistedResponders, respondersMap, rootContainerInstance) {
  13276. var responder;
  13277. var props;
  13278. if (listener) {
  13279. responder = listener.responder;
  13280. props = listener.props;
  13281. }
  13282. if (!(responder && responder.$$typeof === REACT_RESPONDER_TYPE)) {
  13283. {
  13284. throw Error("An invalid value was used as an event listener. Expect one or many event listeners created via React.unstable_useResponder().");
  13285. }
  13286. }
  13287. var listenerProps = props;
  13288. if (visistedResponders.has(responder)) {
  13289. // show warning
  13290. {
  13291. warning$1(false, 'Duplicate event responder "%s" found in event listeners. ' + 'Event listeners passed to elements cannot use the same event responder more than once.', responder.displayName);
  13292. }
  13293. return;
  13294. }
  13295. visistedResponders.add(responder);
  13296. var responderInstance = respondersMap.get(responder);
  13297. if (responderInstance === undefined) {
  13298. // Mount (happens in either complete or commit phase)
  13299. mountEventResponder$1(responder, listenerProps, fiber, respondersMap, rootContainerInstance);
  13300. } else {
  13301. // Update (happens during commit phase only)
  13302. responderInstance.props = listenerProps;
  13303. responderInstance.fiber = fiber;
  13304. }
  13305. }
  13306. function updateEventListeners(listeners, fiber, rootContainerInstance) {
  13307. var visistedResponders = new Set();
  13308. var dependencies = fiber.dependencies;
  13309. if (listeners != null) {
  13310. if (dependencies === null) {
  13311. dependencies = fiber.dependencies = {
  13312. expirationTime: NoWork,
  13313. firstContext: null,
  13314. responders: new Map()
  13315. };
  13316. }
  13317. var respondersMap = dependencies.responders;
  13318. if (respondersMap === null) {
  13319. respondersMap = new Map();
  13320. }
  13321. if (isArray$2(listeners)) {
  13322. for (var i = 0, length = listeners.length; i < length; i++) {
  13323. var listener = listeners[i];
  13324. updateEventListener(listener, fiber, visistedResponders, respondersMap, rootContainerInstance);
  13325. }
  13326. } else {
  13327. updateEventListener(listeners, fiber, visistedResponders, respondersMap, rootContainerInstance);
  13328. }
  13329. }
  13330. if (dependencies !== null) {
  13331. var _respondersMap = dependencies.responders;
  13332. if (_respondersMap !== null) {
  13333. // Unmount
  13334. var mountedResponders = Array.from(_respondersMap.keys());
  13335. for (var _i = 0, _length = mountedResponders.length; _i < _length; _i++) {
  13336. var mountedResponder = mountedResponders[_i];
  13337. if (!visistedResponders.has(mountedResponder)) {
  13338. var responderInstance = _respondersMap.get(mountedResponder);
  13339. unmountResponderInstance(responderInstance);
  13340. _respondersMap.delete(mountedResponder);
  13341. }
  13342. }
  13343. }
  13344. }
  13345. }
  13346. function createResponderListener(responder, props) {
  13347. var eventResponderListener = {
  13348. responder: responder,
  13349. props: props
  13350. };
  13351. {
  13352. Object.freeze(eventResponderListener);
  13353. }
  13354. return eventResponderListener;
  13355. }
  13356. var NoEffect$1 =
  13357. /* */
  13358. 0;
  13359. var UnmountSnapshot =
  13360. /* */
  13361. 2;
  13362. var UnmountMutation =
  13363. /* */
  13364. 4;
  13365. var MountMutation =
  13366. /* */
  13367. 8;
  13368. var UnmountLayout =
  13369. /* */
  13370. 16;
  13371. var MountLayout =
  13372. /* */
  13373. 32;
  13374. var MountPassive =
  13375. /* */
  13376. 64;
  13377. var UnmountPassive =
  13378. /* */
  13379. 128;
  13380. var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;
  13381. var ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig;
  13382. var didWarnAboutMismatchedHooksForComponent;
  13383. {
  13384. didWarnAboutMismatchedHooksForComponent = new Set();
  13385. }
  13386. // These are set right before calling the component.
  13387. var renderExpirationTime$1 = NoWork; // The work-in-progress fiber. I've named it differently to distinguish it from
  13388. // the work-in-progress hook.
  13389. var currentlyRenderingFiber$1 = null; // Hooks are stored as a linked list on the fiber's memoizedState field. The
  13390. // current hook list is the list that belongs to the current fiber. The
  13391. // work-in-progress hook list is a new list that will be added to the
  13392. // work-in-progress fiber.
  13393. var currentHook = null;
  13394. var nextCurrentHook = null;
  13395. var firstWorkInProgressHook = null;
  13396. var workInProgressHook = null;
  13397. var nextWorkInProgressHook = null;
  13398. var remainingExpirationTime = NoWork;
  13399. var componentUpdateQueue = null;
  13400. var sideEffectTag = 0; // Updates scheduled during render will trigger an immediate re-render at the
  13401. // end of the current pass. We can't store these updates on the normal queue,
  13402. // because if the work is aborted, they should be discarded. Because this is
  13403. // a relatively rare case, we also don't want to add an additional field to
  13404. // either the hook or queue object types. So we store them in a lazily create
  13405. // map of queue -> render-phase updates, which are discarded once the component
  13406. // completes without re-rendering.
  13407. // Whether an update was scheduled during the currently executing render pass.
  13408. var didScheduleRenderPhaseUpdate = false; // Lazily created map of render-phase updates
  13409. var renderPhaseUpdates = null; // Counter to prevent infinite loops.
  13410. var numberOfReRenders = 0;
  13411. var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook
  13412. var currentHookNameInDev = null; // In DEV, this list ensures that hooks are called in the same order between renders.
  13413. // The list stores the order of hooks used during the initial render (mount).
  13414. // Subsequent renders (updates) reference this list.
  13415. var hookTypesDev = null;
  13416. var hookTypesUpdateIndexDev = -1; // In DEV, this tracks whether currently rendering component needs to ignore
  13417. // the dependencies for Hooks that need them (e.g. useEffect or useMemo).
  13418. // When true, such Hooks will always be "remounted". Only used during hot reload.
  13419. var ignorePreviousDependencies = false;
  13420. function mountHookTypesDev() {
  13421. {
  13422. var hookName = currentHookNameInDev;
  13423. if (hookTypesDev === null) {
  13424. hookTypesDev = [hookName];
  13425. } else {
  13426. hookTypesDev.push(hookName);
  13427. }
  13428. }
  13429. }
  13430. function updateHookTypesDev() {
  13431. {
  13432. var hookName = currentHookNameInDev;
  13433. if (hookTypesDev !== null) {
  13434. hookTypesUpdateIndexDev++;
  13435. if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
  13436. warnOnHookMismatchInDev(hookName);
  13437. }
  13438. }
  13439. }
  13440. }
  13441. function checkDepsAreArrayDev(deps) {
  13442. {
  13443. if (deps !== undefined && deps !== null && !Array.isArray(deps)) {
  13444. // Verify deps, but only on mount to avoid extra checks.
  13445. // It's unlikely their type would change as usually you define them inline.
  13446. warning$1(false, '%s received a final argument that is not an array (instead, received `%s`). When ' + 'specified, the final argument must be an array.', currentHookNameInDev, typeof deps);
  13447. }
  13448. }
  13449. }
  13450. function warnOnHookMismatchInDev(currentHookName) {
  13451. {
  13452. var componentName = getComponentName(currentlyRenderingFiber$1.type);
  13453. if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
  13454. didWarnAboutMismatchedHooksForComponent.add(componentName);
  13455. if (hookTypesDev !== null) {
  13456. var table = '';
  13457. var secondColumnStart = 30;
  13458. for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
  13459. var oldHookName = hookTypesDev[i];
  13460. var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
  13461. var row = i + 1 + ". " + oldHookName; // Extra space so second column lines up
  13462. // lol @ IE not supporting String#repeat
  13463. while (row.length < secondColumnStart) {
  13464. row += ' ';
  13465. }
  13466. row += newHookName + '\n';
  13467. table += row;
  13468. }
  13469. warning$1(false, 'React has detected a change in the order of Hooks called by %s. ' + 'This will lead to bugs and errors if not fixed. ' + 'For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' ------------------------------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table);
  13470. }
  13471. }
  13472. }
  13473. }
  13474. function throwInvalidHookError() {
  13475. {
  13476. {
  13477. throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.");
  13478. }
  13479. }
  13480. }
  13481. function areHookInputsEqual(nextDeps, prevDeps) {
  13482. {
  13483. if (ignorePreviousDependencies) {
  13484. // Only true when this component is being hot reloaded.
  13485. return false;
  13486. }
  13487. }
  13488. if (prevDeps === null) {
  13489. {
  13490. warning$1(false, '%s received a final argument during this render, but not during ' + 'the previous render. Even though the final argument is optional, ' + 'its type cannot change between renders.', currentHookNameInDev);
  13491. }
  13492. return false;
  13493. }
  13494. {
  13495. // Don't bother comparing lengths in prod because these arrays should be
  13496. // passed inline.
  13497. if (nextDeps.length !== prevDeps.length) {
  13498. warning$1(false, 'The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev, "[" + prevDeps.join(', ') + "]", "[" + nextDeps.join(', ') + "]");
  13499. }
  13500. }
  13501. for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
  13502. if (is$1(nextDeps[i], prevDeps[i])) {
  13503. continue;
  13504. }
  13505. return false;
  13506. }
  13507. return true;
  13508. }
  13509. function renderWithHooks(current, workInProgress, Component, props, refOrContext, nextRenderExpirationTime) {
  13510. renderExpirationTime$1 = nextRenderExpirationTime;
  13511. currentlyRenderingFiber$1 = workInProgress;
  13512. nextCurrentHook = current !== null ? current.memoizedState : null;
  13513. {
  13514. hookTypesDev = current !== null ? current._debugHookTypes : null;
  13515. hookTypesUpdateIndexDev = -1; // Used for hot reloading:
  13516. ignorePreviousDependencies = current !== null && current.type !== workInProgress.type;
  13517. } // The following should have already been reset
  13518. // currentHook = null;
  13519. // workInProgressHook = null;
  13520. // remainingExpirationTime = NoWork;
  13521. // componentUpdateQueue = null;
  13522. // didScheduleRenderPhaseUpdate = false;
  13523. // renderPhaseUpdates = null;
  13524. // numberOfReRenders = 0;
  13525. // sideEffectTag = 0;
  13526. // TODO Warn if no hooks are used at all during mount, then some are used during update.
  13527. // Currently we will identify the update render as a mount because nextCurrentHook === null.
  13528. // This is tricky because it's valid for certain types of components (e.g. React.lazy)
  13529. // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used.
  13530. // Non-stateful hooks (e.g. context) don't get added to memoizedState,
  13531. // so nextCurrentHook would be null during updates and mounts.
  13532. {
  13533. if (nextCurrentHook !== null) {
  13534. ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
  13535. } else if (hookTypesDev !== null) {
  13536. // This dispatcher handles an edge case where a component is updating,
  13537. // but no stateful hooks have been used.
  13538. // We want to match the production code behavior (which will use HooksDispatcherOnMount),
  13539. // but with the extra DEV validation to ensure hooks ordering hasn't changed.
  13540. // This dispatcher does that.
  13541. ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
  13542. } else {
  13543. ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
  13544. }
  13545. }
  13546. var children = Component(props, refOrContext);
  13547. if (didScheduleRenderPhaseUpdate) {
  13548. do {
  13549. didScheduleRenderPhaseUpdate = false;
  13550. numberOfReRenders += 1;
  13551. {
  13552. // Even when hot reloading, allow dependencies to stabilize
  13553. // after first render to prevent infinite render phase updates.
  13554. ignorePreviousDependencies = false;
  13555. } // Start over from the beginning of the list
  13556. nextCurrentHook = current !== null ? current.memoizedState : null;
  13557. nextWorkInProgressHook = firstWorkInProgressHook;
  13558. currentHook = null;
  13559. workInProgressHook = null;
  13560. componentUpdateQueue = null;
  13561. {
  13562. // Also validate hook order for cascading updates.
  13563. hookTypesUpdateIndexDev = -1;
  13564. }
  13565. ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
  13566. children = Component(props, refOrContext);
  13567. } while (didScheduleRenderPhaseUpdate);
  13568. renderPhaseUpdates = null;
  13569. numberOfReRenders = 0;
  13570. } // We can assume the previous dispatcher is always this one, since we set it
  13571. // at the beginning of the render phase and there's no re-entrancy.
  13572. ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
  13573. var renderedWork = currentlyRenderingFiber$1;
  13574. renderedWork.memoizedState = firstWorkInProgressHook;
  13575. renderedWork.expirationTime = remainingExpirationTime;
  13576. renderedWork.updateQueue = componentUpdateQueue;
  13577. renderedWork.effectTag |= sideEffectTag;
  13578. {
  13579. renderedWork._debugHookTypes = hookTypesDev;
  13580. } // This check uses currentHook so that it works the same in DEV and prod bundles.
  13581. // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
  13582. var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
  13583. renderExpirationTime$1 = NoWork;
  13584. currentlyRenderingFiber$1 = null;
  13585. currentHook = null;
  13586. nextCurrentHook = null;
  13587. firstWorkInProgressHook = null;
  13588. workInProgressHook = null;
  13589. nextWorkInProgressHook = null;
  13590. {
  13591. currentHookNameInDev = null;
  13592. hookTypesDev = null;
  13593. hookTypesUpdateIndexDev = -1;
  13594. }
  13595. remainingExpirationTime = NoWork;
  13596. componentUpdateQueue = null;
  13597. sideEffectTag = 0; // These were reset above
  13598. // didScheduleRenderPhaseUpdate = false;
  13599. // renderPhaseUpdates = null;
  13600. // numberOfReRenders = 0;
  13601. if (!!didRenderTooFewHooks) {
  13602. {
  13603. throw Error("Rendered fewer hooks than expected. This may be caused by an accidental early return statement.");
  13604. }
  13605. }
  13606. return children;
  13607. }
  13608. function bailoutHooks(current, workInProgress, expirationTime) {
  13609. workInProgress.updateQueue = current.updateQueue;
  13610. workInProgress.effectTag &= ~(Passive | Update);
  13611. if (current.expirationTime <= expirationTime) {
  13612. current.expirationTime = NoWork;
  13613. }
  13614. }
  13615. function resetHooks() {
  13616. // We can assume the previous dispatcher is always this one, since we set it
  13617. // at the beginning of the render phase and there's no re-entrancy.
  13618. ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; // This is used to reset the state of this module when a component throws.
  13619. // It's also called inside mountIndeterminateComponent if we determine the
  13620. // component is a module-style component.
  13621. renderExpirationTime$1 = NoWork;
  13622. currentlyRenderingFiber$1 = null;
  13623. currentHook = null;
  13624. nextCurrentHook = null;
  13625. firstWorkInProgressHook = null;
  13626. workInProgressHook = null;
  13627. nextWorkInProgressHook = null;
  13628. {
  13629. hookTypesDev = null;
  13630. hookTypesUpdateIndexDev = -1;
  13631. currentHookNameInDev = null;
  13632. }
  13633. remainingExpirationTime = NoWork;
  13634. componentUpdateQueue = null;
  13635. sideEffectTag = 0;
  13636. didScheduleRenderPhaseUpdate = false;
  13637. renderPhaseUpdates = null;
  13638. numberOfReRenders = 0;
  13639. }
  13640. function mountWorkInProgressHook() {
  13641. var hook = {
  13642. memoizedState: null,
  13643. baseState: null,
  13644. queue: null,
  13645. baseUpdate: null,
  13646. next: null
  13647. };
  13648. if (workInProgressHook === null) {
  13649. // This is the first hook in the list
  13650. firstWorkInProgressHook = workInProgressHook = hook;
  13651. } else {
  13652. // Append to the end of the list
  13653. workInProgressHook = workInProgressHook.next = hook;
  13654. }
  13655. return workInProgressHook;
  13656. }
  13657. function updateWorkInProgressHook() {
  13658. // This function is used both for updates and for re-renders triggered by a
  13659. // render phase update. It assumes there is either a current hook we can
  13660. // clone, or a work-in-progress hook from a previous render pass that we can
  13661. // use as a base. When we reach the end of the base list, we must switch to
  13662. // the dispatcher used for mounts.
  13663. if (nextWorkInProgressHook !== null) {
  13664. // There's already a work-in-progress. Reuse it.
  13665. workInProgressHook = nextWorkInProgressHook;
  13666. nextWorkInProgressHook = workInProgressHook.next;
  13667. currentHook = nextCurrentHook;
  13668. nextCurrentHook = currentHook !== null ? currentHook.next : null;
  13669. } else {
  13670. // Clone from the current hook.
  13671. if (!(nextCurrentHook !== null)) {
  13672. {
  13673. throw Error("Rendered more hooks than during the previous render.");
  13674. }
  13675. }
  13676. currentHook = nextCurrentHook;
  13677. var newHook = {
  13678. memoizedState: currentHook.memoizedState,
  13679. baseState: currentHook.baseState,
  13680. queue: currentHook.queue,
  13681. baseUpdate: currentHook.baseUpdate,
  13682. next: null
  13683. };
  13684. if (workInProgressHook === null) {
  13685. // This is the first hook in the list.
  13686. workInProgressHook = firstWorkInProgressHook = newHook;
  13687. } else {
  13688. // Append to the end of the list.
  13689. workInProgressHook = workInProgressHook.next = newHook;
  13690. }
  13691. nextCurrentHook = currentHook.next;
  13692. }
  13693. return workInProgressHook;
  13694. }
  13695. function createFunctionComponentUpdateQueue() {
  13696. return {
  13697. lastEffect: null
  13698. };
  13699. }
  13700. function basicStateReducer(state, action) {
  13701. return typeof action === 'function' ? action(state) : action;
  13702. }
  13703. function mountReducer(reducer, initialArg, init) {
  13704. var hook = mountWorkInProgressHook();
  13705. var initialState;
  13706. if (init !== undefined) {
  13707. initialState = init(initialArg);
  13708. } else {
  13709. initialState = initialArg;
  13710. }
  13711. hook.memoizedState = hook.baseState = initialState;
  13712. var queue = hook.queue = {
  13713. last: null,
  13714. dispatch: null,
  13715. lastRenderedReducer: reducer,
  13716. lastRenderedState: initialState
  13717. };
  13718. var dispatch = queue.dispatch = dispatchAction.bind(null, // Flow doesn't know this is non-null, but we do.
  13719. currentlyRenderingFiber$1, queue);
  13720. return [hook.memoizedState, dispatch];
  13721. }
  13722. function updateReducer(reducer, initialArg, init) {
  13723. var hook = updateWorkInProgressHook();
  13724. var queue = hook.queue;
  13725. if (!(queue !== null)) {
  13726. {
  13727. throw Error("Should have a queue. This is likely a bug in React. Please file an issue.");
  13728. }
  13729. }
  13730. queue.lastRenderedReducer = reducer;
  13731. if (numberOfReRenders > 0) {
  13732. // This is a re-render. Apply the new render phase updates to the previous
  13733. // work-in-progress hook.
  13734. var _dispatch = queue.dispatch;
  13735. if (renderPhaseUpdates !== null) {
  13736. // Render phase updates are stored in a map of queue -> linked list
  13737. var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
  13738. if (firstRenderPhaseUpdate !== undefined) {
  13739. renderPhaseUpdates.delete(queue);
  13740. var newState = hook.memoizedState;
  13741. var update = firstRenderPhaseUpdate;
  13742. do {
  13743. // Process this render phase update. We don't have to check the
  13744. // priority because it will always be the same as the current
  13745. // render's.
  13746. var action = update.action;
  13747. newState = reducer(newState, action);
  13748. update = update.next;
  13749. } while (update !== null); // Mark that the fiber performed work, but only if the new state is
  13750. // different from the current state.
  13751. if (!is$1(newState, hook.memoizedState)) {
  13752. markWorkInProgressReceivedUpdate();
  13753. }
  13754. hook.memoizedState = newState; // Don't persist the state accumulated from the render phase updates to
  13755. // the base state unless the queue is empty.
  13756. // TODO: Not sure if this is the desired semantics, but it's what we
  13757. // do for gDSFP. I can't remember why.
  13758. if (hook.baseUpdate === queue.last) {
  13759. hook.baseState = newState;
  13760. }
  13761. queue.lastRenderedState = newState;
  13762. return [newState, _dispatch];
  13763. }
  13764. }
  13765. return [hook.memoizedState, _dispatch];
  13766. } // The last update in the entire queue
  13767. var last = queue.last; // The last update that is part of the base state.
  13768. var baseUpdate = hook.baseUpdate;
  13769. var baseState = hook.baseState; // Find the first unprocessed update.
  13770. var first;
  13771. if (baseUpdate !== null) {
  13772. if (last !== null) {
  13773. // For the first update, the queue is a circular linked list where
  13774. // `queue.last.next = queue.first`. Once the first update commits, and
  13775. // the `baseUpdate` is no longer empty, we can unravel the list.
  13776. last.next = null;
  13777. }
  13778. first = baseUpdate.next;
  13779. } else {
  13780. first = last !== null ? last.next : null;
  13781. }
  13782. if (first !== null) {
  13783. var _newState = baseState;
  13784. var newBaseState = null;
  13785. var newBaseUpdate = null;
  13786. var prevUpdate = baseUpdate;
  13787. var _update = first;
  13788. var didSkip = false;
  13789. do {
  13790. var updateExpirationTime = _update.expirationTime;
  13791. if (updateExpirationTime < renderExpirationTime$1) {
  13792. // Priority is insufficient. Skip this update. If this is the first
  13793. // skipped update, the previous update/state is the new base
  13794. // update/state.
  13795. if (!didSkip) {
  13796. didSkip = true;
  13797. newBaseUpdate = prevUpdate;
  13798. newBaseState = _newState;
  13799. } // Update the remaining priority in the queue.
  13800. if (updateExpirationTime > remainingExpirationTime) {
  13801. remainingExpirationTime = updateExpirationTime;
  13802. markUnprocessedUpdateTime(remainingExpirationTime);
  13803. }
  13804. } else {
  13805. // This update does have sufficient priority.
  13806. // Mark the event time of this update as relevant to this render pass.
  13807. // TODO: This should ideally use the true event time of this update rather than
  13808. // its priority which is a derived and not reverseable value.
  13809. // TODO: We should skip this update if it was already committed but currently
  13810. // we have no way of detecting the difference between a committed and suspended
  13811. // update here.
  13812. markRenderEventTimeAndConfig(updateExpirationTime, _update.suspenseConfig); // Process this update.
  13813. if (_update.eagerReducer === reducer) {
  13814. // If this update was processed eagerly, and its reducer matches the
  13815. // current reducer, we can use the eagerly computed state.
  13816. _newState = _update.eagerState;
  13817. } else {
  13818. var _action = _update.action;
  13819. _newState = reducer(_newState, _action);
  13820. }
  13821. }
  13822. prevUpdate = _update;
  13823. _update = _update.next;
  13824. } while (_update !== null && _update !== first);
  13825. if (!didSkip) {
  13826. newBaseUpdate = prevUpdate;
  13827. newBaseState = _newState;
  13828. } // Mark that the fiber performed work, but only if the new state is
  13829. // different from the current state.
  13830. if (!is$1(_newState, hook.memoizedState)) {
  13831. markWorkInProgressReceivedUpdate();
  13832. }
  13833. hook.memoizedState = _newState;
  13834. hook.baseUpdate = newBaseUpdate;
  13835. hook.baseState = newBaseState;
  13836. queue.lastRenderedState = _newState;
  13837. }
  13838. var dispatch = queue.dispatch;
  13839. return [hook.memoizedState, dispatch];
  13840. }
  13841. function mountState(initialState) {
  13842. var hook = mountWorkInProgressHook();
  13843. if (typeof initialState === 'function') {
  13844. initialState = initialState();
  13845. }
  13846. hook.memoizedState = hook.baseState = initialState;
  13847. var queue = hook.queue = {
  13848. last: null,
  13849. dispatch: null,
  13850. lastRenderedReducer: basicStateReducer,
  13851. lastRenderedState: initialState
  13852. };
  13853. var dispatch = queue.dispatch = dispatchAction.bind(null, // Flow doesn't know this is non-null, but we do.
  13854. currentlyRenderingFiber$1, queue);
  13855. return [hook.memoizedState, dispatch];
  13856. }
  13857. function updateState(initialState) {
  13858. return updateReducer(basicStateReducer, initialState);
  13859. }
  13860. function pushEffect(tag, create, destroy, deps) {
  13861. var effect = {
  13862. tag: tag,
  13863. create: create,
  13864. destroy: destroy,
  13865. deps: deps,
  13866. // Circular
  13867. next: null
  13868. };
  13869. if (componentUpdateQueue === null) {
  13870. componentUpdateQueue = createFunctionComponentUpdateQueue();
  13871. componentUpdateQueue.lastEffect = effect.next = effect;
  13872. } else {
  13873. var lastEffect = componentUpdateQueue.lastEffect;
  13874. if (lastEffect === null) {
  13875. componentUpdateQueue.lastEffect = effect.next = effect;
  13876. } else {
  13877. var firstEffect = lastEffect.next;
  13878. lastEffect.next = effect;
  13879. effect.next = firstEffect;
  13880. componentUpdateQueue.lastEffect = effect;
  13881. }
  13882. }
  13883. return effect;
  13884. }
  13885. function mountRef(initialValue) {
  13886. var hook = mountWorkInProgressHook();
  13887. var ref = {
  13888. current: initialValue
  13889. };
  13890. {
  13891. Object.seal(ref);
  13892. }
  13893. hook.memoizedState = ref;
  13894. return ref;
  13895. }
  13896. function updateRef(initialValue) {
  13897. var hook = updateWorkInProgressHook();
  13898. return hook.memoizedState;
  13899. }
  13900. function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
  13901. var hook = mountWorkInProgressHook();
  13902. var nextDeps = deps === undefined ? null : deps;
  13903. sideEffectTag |= fiberEffectTag;
  13904. hook.memoizedState = pushEffect(hookEffectTag, create, undefined, nextDeps);
  13905. }
  13906. function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
  13907. var hook = updateWorkInProgressHook();
  13908. var nextDeps = deps === undefined ? null : deps;
  13909. var destroy = undefined;
  13910. if (currentHook !== null) {
  13911. var prevEffect = currentHook.memoizedState;
  13912. destroy = prevEffect.destroy;
  13913. if (nextDeps !== null) {
  13914. var prevDeps = prevEffect.deps;
  13915. if (areHookInputsEqual(nextDeps, prevDeps)) {
  13916. pushEffect(NoEffect$1, create, destroy, nextDeps);
  13917. return;
  13918. }
  13919. }
  13920. }
  13921. sideEffectTag |= fiberEffectTag;
  13922. hook.memoizedState = pushEffect(hookEffectTag, create, destroy, nextDeps);
  13923. }
  13924. function mountEffect(create, deps) {
  13925. {
  13926. // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
  13927. if ('undefined' !== typeof jest) {
  13928. warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
  13929. }
  13930. }
  13931. return mountEffectImpl(Update | Passive, UnmountPassive | MountPassive, create, deps);
  13932. }
  13933. function updateEffect(create, deps) {
  13934. {
  13935. // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
  13936. if ('undefined' !== typeof jest) {
  13937. warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
  13938. }
  13939. }
  13940. return updateEffectImpl(Update | Passive, UnmountPassive | MountPassive, create, deps);
  13941. }
  13942. function mountLayoutEffect(create, deps) {
  13943. return mountEffectImpl(Update, UnmountMutation | MountLayout, create, deps);
  13944. }
  13945. function updateLayoutEffect(create, deps) {
  13946. return updateEffectImpl(Update, UnmountMutation | MountLayout, create, deps);
  13947. }
  13948. function imperativeHandleEffect(create, ref) {
  13949. if (typeof ref === 'function') {
  13950. var refCallback = ref;
  13951. var _inst = create();
  13952. refCallback(_inst);
  13953. return function () {
  13954. refCallback(null);
  13955. };
  13956. } else if (ref !== null && ref !== undefined) {
  13957. var refObject = ref;
  13958. {
  13959. !refObject.hasOwnProperty('current') ? warning$1(false, 'Expected useImperativeHandle() first argument to either be a ' + 'ref callback or React.createRef() object. Instead received: %s.', 'an object with keys {' + Object.keys(refObject).join(', ') + '}') : void 0;
  13960. }
  13961. var _inst2 = create();
  13962. refObject.current = _inst2;
  13963. return function () {
  13964. refObject.current = null;
  13965. };
  13966. }
  13967. }
  13968. function mountImperativeHandle(ref, create, deps) {
  13969. {
  13970. !(typeof create === 'function') ? warning$1(false, 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null') : void 0;
  13971. } // TODO: If deps are provided, should we skip comparing the ref itself?
  13972. var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
  13973. return mountEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
  13974. }
  13975. function updateImperativeHandle(ref, create, deps) {
  13976. {
  13977. !(typeof create === 'function') ? warning$1(false, 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null') : void 0;
  13978. } // TODO: If deps are provided, should we skip comparing the ref itself?
  13979. var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
  13980. return updateEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
  13981. }
  13982. function mountDebugValue(value, formatterFn) {// This hook is normally a no-op.
  13983. // The react-debug-hooks package injects its own implementation
  13984. // so that e.g. DevTools can display custom hook values.
  13985. }
  13986. var updateDebugValue = mountDebugValue;
  13987. function mountCallback(callback, deps) {
  13988. var hook = mountWorkInProgressHook();
  13989. var nextDeps = deps === undefined ? null : deps;
  13990. hook.memoizedState = [callback, nextDeps];
  13991. return callback;
  13992. }
  13993. function updateCallback(callback, deps) {
  13994. var hook = updateWorkInProgressHook();
  13995. var nextDeps = deps === undefined ? null : deps;
  13996. var prevState = hook.memoizedState;
  13997. if (prevState !== null) {
  13998. if (nextDeps !== null) {
  13999. var prevDeps = prevState[1];
  14000. if (areHookInputsEqual(nextDeps, prevDeps)) {
  14001. return prevState[0];
  14002. }
  14003. }
  14004. }
  14005. hook.memoizedState = [callback, nextDeps];
  14006. return callback;
  14007. }
  14008. function mountMemo(nextCreate, deps) {
  14009. var hook = mountWorkInProgressHook();
  14010. var nextDeps = deps === undefined ? null : deps;
  14011. var nextValue = nextCreate();
  14012. hook.memoizedState = [nextValue, nextDeps];
  14013. return nextValue;
  14014. }
  14015. function updateMemo(nextCreate, deps) {
  14016. var hook = updateWorkInProgressHook();
  14017. var nextDeps = deps === undefined ? null : deps;
  14018. var prevState = hook.memoizedState;
  14019. if (prevState !== null) {
  14020. // Assume these are defined. If they're not, areHookInputsEqual will warn.
  14021. if (nextDeps !== null) {
  14022. var prevDeps = prevState[1];
  14023. if (areHookInputsEqual(nextDeps, prevDeps)) {
  14024. return prevState[0];
  14025. }
  14026. }
  14027. }
  14028. var nextValue = nextCreate();
  14029. hook.memoizedState = [nextValue, nextDeps];
  14030. return nextValue;
  14031. }
  14032. function mountDeferredValue(value, config) {
  14033. var _mountState = mountState(value),
  14034. prevValue = _mountState[0],
  14035. setValue = _mountState[1];
  14036. mountEffect(function () {
  14037. Scheduler.unstable_next(function () {
  14038. var previousConfig = ReactCurrentBatchConfig$1.suspense;
  14039. ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config;
  14040. try {
  14041. setValue(value);
  14042. } finally {
  14043. ReactCurrentBatchConfig$1.suspense = previousConfig;
  14044. }
  14045. });
  14046. }, [value, config]);
  14047. return prevValue;
  14048. }
  14049. function updateDeferredValue(value, config) {
  14050. var _updateState = updateState(value),
  14051. prevValue = _updateState[0],
  14052. setValue = _updateState[1];
  14053. updateEffect(function () {
  14054. Scheduler.unstable_next(function () {
  14055. var previousConfig = ReactCurrentBatchConfig$1.suspense;
  14056. ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config;
  14057. try {
  14058. setValue(value);
  14059. } finally {
  14060. ReactCurrentBatchConfig$1.suspense = previousConfig;
  14061. }
  14062. });
  14063. }, [value, config]);
  14064. return prevValue;
  14065. }
  14066. function mountTransition(config) {
  14067. var _mountState2 = mountState(false),
  14068. isPending = _mountState2[0],
  14069. setPending = _mountState2[1];
  14070. var startTransition = mountCallback(function (callback) {
  14071. setPending(true);
  14072. Scheduler.unstable_next(function () {
  14073. var previousConfig = ReactCurrentBatchConfig$1.suspense;
  14074. ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config;
  14075. try {
  14076. setPending(false);
  14077. callback();
  14078. } finally {
  14079. ReactCurrentBatchConfig$1.suspense = previousConfig;
  14080. }
  14081. });
  14082. }, [config, isPending]);
  14083. return [startTransition, isPending];
  14084. }
  14085. function updateTransition(config) {
  14086. var _updateState2 = updateState(false),
  14087. isPending = _updateState2[0],
  14088. setPending = _updateState2[1];
  14089. var startTransition = updateCallback(function (callback) {
  14090. setPending(true);
  14091. Scheduler.unstable_next(function () {
  14092. var previousConfig = ReactCurrentBatchConfig$1.suspense;
  14093. ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config;
  14094. try {
  14095. setPending(false);
  14096. callback();
  14097. } finally {
  14098. ReactCurrentBatchConfig$1.suspense = previousConfig;
  14099. }
  14100. });
  14101. }, [config, isPending]);
  14102. return [startTransition, isPending];
  14103. }
  14104. function dispatchAction(fiber, queue, action) {
  14105. if (!(numberOfReRenders < RE_RENDER_LIMIT)) {
  14106. {
  14107. throw Error("Too many re-renders. React limits the number of renders to prevent an infinite loop.");
  14108. }
  14109. }
  14110. {
  14111. !(typeof arguments[3] !== 'function') ? warning$1(false, "State updates from the useState() and useReducer() Hooks don't support the " + 'second callback argument. To execute a side effect after ' + 'rendering, declare it in the component body with useEffect().') : void 0;
  14112. }
  14113. var alternate = fiber.alternate;
  14114. if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) {
  14115. // This is a render phase update. Stash it in a lazily-created map of
  14116. // queue -> linked list of updates. After this render pass, we'll restart
  14117. // and apply the stashed updates on top of the work-in-progress hook.
  14118. didScheduleRenderPhaseUpdate = true;
  14119. var update = {
  14120. expirationTime: renderExpirationTime$1,
  14121. suspenseConfig: null,
  14122. action: action,
  14123. eagerReducer: null,
  14124. eagerState: null,
  14125. next: null
  14126. };
  14127. {
  14128. update.priority = getCurrentPriorityLevel();
  14129. }
  14130. if (renderPhaseUpdates === null) {
  14131. renderPhaseUpdates = new Map();
  14132. }
  14133. var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
  14134. if (firstRenderPhaseUpdate === undefined) {
  14135. renderPhaseUpdates.set(queue, update);
  14136. } else {
  14137. // Append the update to the end of the list.
  14138. var lastRenderPhaseUpdate = firstRenderPhaseUpdate;
  14139. while (lastRenderPhaseUpdate.next !== null) {
  14140. lastRenderPhaseUpdate = lastRenderPhaseUpdate.next;
  14141. }
  14142. lastRenderPhaseUpdate.next = update;
  14143. }
  14144. } else {
  14145. var currentTime = requestCurrentTimeForUpdate();
  14146. var suspenseConfig = requestCurrentSuspenseConfig();
  14147. var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
  14148. var _update2 = {
  14149. expirationTime: expirationTime,
  14150. suspenseConfig: suspenseConfig,
  14151. action: action,
  14152. eagerReducer: null,
  14153. eagerState: null,
  14154. next: null
  14155. };
  14156. {
  14157. _update2.priority = getCurrentPriorityLevel();
  14158. } // Append the update to the end of the list.
  14159. var last = queue.last;
  14160. if (last === null) {
  14161. // This is the first update. Create a circular list.
  14162. _update2.next = _update2;
  14163. } else {
  14164. var first = last.next;
  14165. if (first !== null) {
  14166. // Still circular.
  14167. _update2.next = first;
  14168. }
  14169. last.next = _update2;
  14170. }
  14171. queue.last = _update2;
  14172. if (fiber.expirationTime === NoWork && (alternate === null || alternate.expirationTime === NoWork)) {
  14173. // The queue is currently empty, which means we can eagerly compute the
  14174. // next state before entering the render phase. If the new state is the
  14175. // same as the current state, we may be able to bail out entirely.
  14176. var lastRenderedReducer = queue.lastRenderedReducer;
  14177. if (lastRenderedReducer !== null) {
  14178. var prevDispatcher;
  14179. {
  14180. prevDispatcher = ReactCurrentDispatcher$1.current;
  14181. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  14182. }
  14183. try {
  14184. var currentState = queue.lastRenderedState;
  14185. var eagerState = lastRenderedReducer(currentState, action); // Stash the eagerly computed state, and the reducer used to compute
  14186. // it, on the update object. If the reducer hasn't changed by the
  14187. // time we enter the render phase, then the eager state can be used
  14188. // without calling the reducer again.
  14189. _update2.eagerReducer = lastRenderedReducer;
  14190. _update2.eagerState = eagerState;
  14191. if (is$1(eagerState, currentState)) {
  14192. // Fast path. We can bail out without scheduling React to re-render.
  14193. // It's still possible that we'll need to rebase this update later,
  14194. // if the component re-renders for a different reason and by that
  14195. // time the reducer has changed.
  14196. return;
  14197. }
  14198. } catch (error) {// Suppress the error. It will throw again in the render phase.
  14199. } finally {
  14200. {
  14201. ReactCurrentDispatcher$1.current = prevDispatcher;
  14202. }
  14203. }
  14204. }
  14205. }
  14206. {
  14207. // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
  14208. if ('undefined' !== typeof jest) {
  14209. warnIfNotScopedWithMatchingAct(fiber);
  14210. warnIfNotCurrentlyActingUpdatesInDev(fiber);
  14211. }
  14212. }
  14213. scheduleWork(fiber, expirationTime);
  14214. }
  14215. }
  14216. var ContextOnlyDispatcher = {
  14217. readContext: readContext,
  14218. useCallback: throwInvalidHookError,
  14219. useContext: throwInvalidHookError,
  14220. useEffect: throwInvalidHookError,
  14221. useImperativeHandle: throwInvalidHookError,
  14222. useLayoutEffect: throwInvalidHookError,
  14223. useMemo: throwInvalidHookError,
  14224. useReducer: throwInvalidHookError,
  14225. useRef: throwInvalidHookError,
  14226. useState: throwInvalidHookError,
  14227. useDebugValue: throwInvalidHookError,
  14228. useResponder: throwInvalidHookError,
  14229. useDeferredValue: throwInvalidHookError,
  14230. useTransition: throwInvalidHookError
  14231. };
  14232. var HooksDispatcherOnMountInDEV = null;
  14233. var HooksDispatcherOnMountWithHookTypesInDEV = null;
  14234. var HooksDispatcherOnUpdateInDEV = null;
  14235. var InvalidNestedHooksDispatcherOnMountInDEV = null;
  14236. var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
  14237. {
  14238. var warnInvalidContextAccess = function () {
  14239. warning$1(false, 'Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().');
  14240. };
  14241. var warnInvalidHookAccess = function () {
  14242. warning$1(false, 'Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. ' + 'You can only call Hooks at the top level of your React function. ' + 'For more information, see ' + 'https://fb.me/rules-of-hooks');
  14243. };
  14244. HooksDispatcherOnMountInDEV = {
  14245. readContext: function (context, observedBits) {
  14246. return readContext(context, observedBits);
  14247. },
  14248. useCallback: function (callback, deps) {
  14249. currentHookNameInDev = 'useCallback';
  14250. mountHookTypesDev();
  14251. checkDepsAreArrayDev(deps);
  14252. return mountCallback(callback, deps);
  14253. },
  14254. useContext: function (context, observedBits) {
  14255. currentHookNameInDev = 'useContext';
  14256. mountHookTypesDev();
  14257. return readContext(context, observedBits);
  14258. },
  14259. useEffect: function (create, deps) {
  14260. currentHookNameInDev = 'useEffect';
  14261. mountHookTypesDev();
  14262. checkDepsAreArrayDev(deps);
  14263. return mountEffect(create, deps);
  14264. },
  14265. useImperativeHandle: function (ref, create, deps) {
  14266. currentHookNameInDev = 'useImperativeHandle';
  14267. mountHookTypesDev();
  14268. checkDepsAreArrayDev(deps);
  14269. return mountImperativeHandle(ref, create, deps);
  14270. },
  14271. useLayoutEffect: function (create, deps) {
  14272. currentHookNameInDev = 'useLayoutEffect';
  14273. mountHookTypesDev();
  14274. checkDepsAreArrayDev(deps);
  14275. return mountLayoutEffect(create, deps);
  14276. },
  14277. useMemo: function (create, deps) {
  14278. currentHookNameInDev = 'useMemo';
  14279. mountHookTypesDev();
  14280. checkDepsAreArrayDev(deps);
  14281. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14282. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  14283. try {
  14284. return mountMemo(create, deps);
  14285. } finally {
  14286. ReactCurrentDispatcher$1.current = prevDispatcher;
  14287. }
  14288. },
  14289. useReducer: function (reducer, initialArg, init) {
  14290. currentHookNameInDev = 'useReducer';
  14291. mountHookTypesDev();
  14292. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14293. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  14294. try {
  14295. return mountReducer(reducer, initialArg, init);
  14296. } finally {
  14297. ReactCurrentDispatcher$1.current = prevDispatcher;
  14298. }
  14299. },
  14300. useRef: function (initialValue) {
  14301. currentHookNameInDev = 'useRef';
  14302. mountHookTypesDev();
  14303. return mountRef(initialValue);
  14304. },
  14305. useState: function (initialState) {
  14306. currentHookNameInDev = 'useState';
  14307. mountHookTypesDev();
  14308. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14309. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  14310. try {
  14311. return mountState(initialState);
  14312. } finally {
  14313. ReactCurrentDispatcher$1.current = prevDispatcher;
  14314. }
  14315. },
  14316. useDebugValue: function (value, formatterFn) {
  14317. currentHookNameInDev = 'useDebugValue';
  14318. mountHookTypesDev();
  14319. return mountDebugValue(value, formatterFn);
  14320. },
  14321. useResponder: function (responder, props) {
  14322. currentHookNameInDev = 'useResponder';
  14323. mountHookTypesDev();
  14324. return createResponderListener(responder, props);
  14325. },
  14326. useDeferredValue: function (value, config) {
  14327. currentHookNameInDev = 'useDeferredValue';
  14328. mountHookTypesDev();
  14329. return mountDeferredValue(value, config);
  14330. },
  14331. useTransition: function (config) {
  14332. currentHookNameInDev = 'useTransition';
  14333. mountHookTypesDev();
  14334. return mountTransition(config);
  14335. }
  14336. };
  14337. HooksDispatcherOnMountWithHookTypesInDEV = {
  14338. readContext: function (context, observedBits) {
  14339. return readContext(context, observedBits);
  14340. },
  14341. useCallback: function (callback, deps) {
  14342. currentHookNameInDev = 'useCallback';
  14343. updateHookTypesDev();
  14344. return mountCallback(callback, deps);
  14345. },
  14346. useContext: function (context, observedBits) {
  14347. currentHookNameInDev = 'useContext';
  14348. updateHookTypesDev();
  14349. return readContext(context, observedBits);
  14350. },
  14351. useEffect: function (create, deps) {
  14352. currentHookNameInDev = 'useEffect';
  14353. updateHookTypesDev();
  14354. return mountEffect(create, deps);
  14355. },
  14356. useImperativeHandle: function (ref, create, deps) {
  14357. currentHookNameInDev = 'useImperativeHandle';
  14358. updateHookTypesDev();
  14359. return mountImperativeHandle(ref, create, deps);
  14360. },
  14361. useLayoutEffect: function (create, deps) {
  14362. currentHookNameInDev = 'useLayoutEffect';
  14363. updateHookTypesDev();
  14364. return mountLayoutEffect(create, deps);
  14365. },
  14366. useMemo: function (create, deps) {
  14367. currentHookNameInDev = 'useMemo';
  14368. updateHookTypesDev();
  14369. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14370. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  14371. try {
  14372. return mountMemo(create, deps);
  14373. } finally {
  14374. ReactCurrentDispatcher$1.current = prevDispatcher;
  14375. }
  14376. },
  14377. useReducer: function (reducer, initialArg, init) {
  14378. currentHookNameInDev = 'useReducer';
  14379. updateHookTypesDev();
  14380. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14381. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  14382. try {
  14383. return mountReducer(reducer, initialArg, init);
  14384. } finally {
  14385. ReactCurrentDispatcher$1.current = prevDispatcher;
  14386. }
  14387. },
  14388. useRef: function (initialValue) {
  14389. currentHookNameInDev = 'useRef';
  14390. updateHookTypesDev();
  14391. return mountRef(initialValue);
  14392. },
  14393. useState: function (initialState) {
  14394. currentHookNameInDev = 'useState';
  14395. updateHookTypesDev();
  14396. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14397. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  14398. try {
  14399. return mountState(initialState);
  14400. } finally {
  14401. ReactCurrentDispatcher$1.current = prevDispatcher;
  14402. }
  14403. },
  14404. useDebugValue: function (value, formatterFn) {
  14405. currentHookNameInDev = 'useDebugValue';
  14406. updateHookTypesDev();
  14407. return mountDebugValue(value, formatterFn);
  14408. },
  14409. useResponder: function (responder, props) {
  14410. currentHookNameInDev = 'useResponder';
  14411. updateHookTypesDev();
  14412. return createResponderListener(responder, props);
  14413. },
  14414. useDeferredValue: function (value, config) {
  14415. currentHookNameInDev = 'useDeferredValue';
  14416. updateHookTypesDev();
  14417. return mountDeferredValue(value, config);
  14418. },
  14419. useTransition: function (config) {
  14420. currentHookNameInDev = 'useTransition';
  14421. updateHookTypesDev();
  14422. return mountTransition(config);
  14423. }
  14424. };
  14425. HooksDispatcherOnUpdateInDEV = {
  14426. readContext: function (context, observedBits) {
  14427. return readContext(context, observedBits);
  14428. },
  14429. useCallback: function (callback, deps) {
  14430. currentHookNameInDev = 'useCallback';
  14431. updateHookTypesDev();
  14432. return updateCallback(callback, deps);
  14433. },
  14434. useContext: function (context, observedBits) {
  14435. currentHookNameInDev = 'useContext';
  14436. updateHookTypesDev();
  14437. return readContext(context, observedBits);
  14438. },
  14439. useEffect: function (create, deps) {
  14440. currentHookNameInDev = 'useEffect';
  14441. updateHookTypesDev();
  14442. return updateEffect(create, deps);
  14443. },
  14444. useImperativeHandle: function (ref, create, deps) {
  14445. currentHookNameInDev = 'useImperativeHandle';
  14446. updateHookTypesDev();
  14447. return updateImperativeHandle(ref, create, deps);
  14448. },
  14449. useLayoutEffect: function (create, deps) {
  14450. currentHookNameInDev = 'useLayoutEffect';
  14451. updateHookTypesDev();
  14452. return updateLayoutEffect(create, deps);
  14453. },
  14454. useMemo: function (create, deps) {
  14455. currentHookNameInDev = 'useMemo';
  14456. updateHookTypesDev();
  14457. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14458. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  14459. try {
  14460. return updateMemo(create, deps);
  14461. } finally {
  14462. ReactCurrentDispatcher$1.current = prevDispatcher;
  14463. }
  14464. },
  14465. useReducer: function (reducer, initialArg, init) {
  14466. currentHookNameInDev = 'useReducer';
  14467. updateHookTypesDev();
  14468. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14469. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  14470. try {
  14471. return updateReducer(reducer, initialArg, init);
  14472. } finally {
  14473. ReactCurrentDispatcher$1.current = prevDispatcher;
  14474. }
  14475. },
  14476. useRef: function (initialValue) {
  14477. currentHookNameInDev = 'useRef';
  14478. updateHookTypesDev();
  14479. return updateRef(initialValue);
  14480. },
  14481. useState: function (initialState) {
  14482. currentHookNameInDev = 'useState';
  14483. updateHookTypesDev();
  14484. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14485. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  14486. try {
  14487. return updateState(initialState);
  14488. } finally {
  14489. ReactCurrentDispatcher$1.current = prevDispatcher;
  14490. }
  14491. },
  14492. useDebugValue: function (value, formatterFn) {
  14493. currentHookNameInDev = 'useDebugValue';
  14494. updateHookTypesDev();
  14495. return updateDebugValue(value, formatterFn);
  14496. },
  14497. useResponder: function (responder, props) {
  14498. currentHookNameInDev = 'useResponder';
  14499. updateHookTypesDev();
  14500. return createResponderListener(responder, props);
  14501. },
  14502. useDeferredValue: function (value, config) {
  14503. currentHookNameInDev = 'useDeferredValue';
  14504. updateHookTypesDev();
  14505. return updateDeferredValue(value, config);
  14506. },
  14507. useTransition: function (config) {
  14508. currentHookNameInDev = 'useTransition';
  14509. updateHookTypesDev();
  14510. return updateTransition(config);
  14511. }
  14512. };
  14513. InvalidNestedHooksDispatcherOnMountInDEV = {
  14514. readContext: function (context, observedBits) {
  14515. warnInvalidContextAccess();
  14516. return readContext(context, observedBits);
  14517. },
  14518. useCallback: function (callback, deps) {
  14519. currentHookNameInDev = 'useCallback';
  14520. warnInvalidHookAccess();
  14521. mountHookTypesDev();
  14522. return mountCallback(callback, deps);
  14523. },
  14524. useContext: function (context, observedBits) {
  14525. currentHookNameInDev = 'useContext';
  14526. warnInvalidHookAccess();
  14527. mountHookTypesDev();
  14528. return readContext(context, observedBits);
  14529. },
  14530. useEffect: function (create, deps) {
  14531. currentHookNameInDev = 'useEffect';
  14532. warnInvalidHookAccess();
  14533. mountHookTypesDev();
  14534. return mountEffect(create, deps);
  14535. },
  14536. useImperativeHandle: function (ref, create, deps) {
  14537. currentHookNameInDev = 'useImperativeHandle';
  14538. warnInvalidHookAccess();
  14539. mountHookTypesDev();
  14540. return mountImperativeHandle(ref, create, deps);
  14541. },
  14542. useLayoutEffect: function (create, deps) {
  14543. currentHookNameInDev = 'useLayoutEffect';
  14544. warnInvalidHookAccess();
  14545. mountHookTypesDev();
  14546. return mountLayoutEffect(create, deps);
  14547. },
  14548. useMemo: function (create, deps) {
  14549. currentHookNameInDev = 'useMemo';
  14550. warnInvalidHookAccess();
  14551. mountHookTypesDev();
  14552. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14553. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  14554. try {
  14555. return mountMemo(create, deps);
  14556. } finally {
  14557. ReactCurrentDispatcher$1.current = prevDispatcher;
  14558. }
  14559. },
  14560. useReducer: function (reducer, initialArg, init) {
  14561. currentHookNameInDev = 'useReducer';
  14562. warnInvalidHookAccess();
  14563. mountHookTypesDev();
  14564. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14565. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  14566. try {
  14567. return mountReducer(reducer, initialArg, init);
  14568. } finally {
  14569. ReactCurrentDispatcher$1.current = prevDispatcher;
  14570. }
  14571. },
  14572. useRef: function (initialValue) {
  14573. currentHookNameInDev = 'useRef';
  14574. warnInvalidHookAccess();
  14575. mountHookTypesDev();
  14576. return mountRef(initialValue);
  14577. },
  14578. useState: function (initialState) {
  14579. currentHookNameInDev = 'useState';
  14580. warnInvalidHookAccess();
  14581. mountHookTypesDev();
  14582. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14583. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  14584. try {
  14585. return mountState(initialState);
  14586. } finally {
  14587. ReactCurrentDispatcher$1.current = prevDispatcher;
  14588. }
  14589. },
  14590. useDebugValue: function (value, formatterFn) {
  14591. currentHookNameInDev = 'useDebugValue';
  14592. warnInvalidHookAccess();
  14593. mountHookTypesDev();
  14594. return mountDebugValue(value, formatterFn);
  14595. },
  14596. useResponder: function (responder, props) {
  14597. currentHookNameInDev = 'useResponder';
  14598. warnInvalidHookAccess();
  14599. mountHookTypesDev();
  14600. return createResponderListener(responder, props);
  14601. },
  14602. useDeferredValue: function (value, config) {
  14603. currentHookNameInDev = 'useDeferredValue';
  14604. warnInvalidHookAccess();
  14605. mountHookTypesDev();
  14606. return mountDeferredValue(value, config);
  14607. },
  14608. useTransition: function (config) {
  14609. currentHookNameInDev = 'useTransition';
  14610. warnInvalidHookAccess();
  14611. mountHookTypesDev();
  14612. return mountTransition(config);
  14613. }
  14614. };
  14615. InvalidNestedHooksDispatcherOnUpdateInDEV = {
  14616. readContext: function (context, observedBits) {
  14617. warnInvalidContextAccess();
  14618. return readContext(context, observedBits);
  14619. },
  14620. useCallback: function (callback, deps) {
  14621. currentHookNameInDev = 'useCallback';
  14622. warnInvalidHookAccess();
  14623. updateHookTypesDev();
  14624. return updateCallback(callback, deps);
  14625. },
  14626. useContext: function (context, observedBits) {
  14627. currentHookNameInDev = 'useContext';
  14628. warnInvalidHookAccess();
  14629. updateHookTypesDev();
  14630. return readContext(context, observedBits);
  14631. },
  14632. useEffect: function (create, deps) {
  14633. currentHookNameInDev = 'useEffect';
  14634. warnInvalidHookAccess();
  14635. updateHookTypesDev();
  14636. return updateEffect(create, deps);
  14637. },
  14638. useImperativeHandle: function (ref, create, deps) {
  14639. currentHookNameInDev = 'useImperativeHandle';
  14640. warnInvalidHookAccess();
  14641. updateHookTypesDev();
  14642. return updateImperativeHandle(ref, create, deps);
  14643. },
  14644. useLayoutEffect: function (create, deps) {
  14645. currentHookNameInDev = 'useLayoutEffect';
  14646. warnInvalidHookAccess();
  14647. updateHookTypesDev();
  14648. return updateLayoutEffect(create, deps);
  14649. },
  14650. useMemo: function (create, deps) {
  14651. currentHookNameInDev = 'useMemo';
  14652. warnInvalidHookAccess();
  14653. updateHookTypesDev();
  14654. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14655. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  14656. try {
  14657. return updateMemo(create, deps);
  14658. } finally {
  14659. ReactCurrentDispatcher$1.current = prevDispatcher;
  14660. }
  14661. },
  14662. useReducer: function (reducer, initialArg, init) {
  14663. currentHookNameInDev = 'useReducer';
  14664. warnInvalidHookAccess();
  14665. updateHookTypesDev();
  14666. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14667. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  14668. try {
  14669. return updateReducer(reducer, initialArg, init);
  14670. } finally {
  14671. ReactCurrentDispatcher$1.current = prevDispatcher;
  14672. }
  14673. },
  14674. useRef: function (initialValue) {
  14675. currentHookNameInDev = 'useRef';
  14676. warnInvalidHookAccess();
  14677. updateHookTypesDev();
  14678. return updateRef(initialValue);
  14679. },
  14680. useState: function (initialState) {
  14681. currentHookNameInDev = 'useState';
  14682. warnInvalidHookAccess();
  14683. updateHookTypesDev();
  14684. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14685. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  14686. try {
  14687. return updateState(initialState);
  14688. } finally {
  14689. ReactCurrentDispatcher$1.current = prevDispatcher;
  14690. }
  14691. },
  14692. useDebugValue: function (value, formatterFn) {
  14693. currentHookNameInDev = 'useDebugValue';
  14694. warnInvalidHookAccess();
  14695. updateHookTypesDev();
  14696. return updateDebugValue(value, formatterFn);
  14697. },
  14698. useResponder: function (responder, props) {
  14699. currentHookNameInDev = 'useResponder';
  14700. warnInvalidHookAccess();
  14701. updateHookTypesDev();
  14702. return createResponderListener(responder, props);
  14703. },
  14704. useDeferredValue: function (value, config) {
  14705. currentHookNameInDev = 'useDeferredValue';
  14706. warnInvalidHookAccess();
  14707. updateHookTypesDev();
  14708. return updateDeferredValue(value, config);
  14709. },
  14710. useTransition: function (config) {
  14711. currentHookNameInDev = 'useTransition';
  14712. warnInvalidHookAccess();
  14713. updateHookTypesDev();
  14714. return updateTransition(config);
  14715. }
  14716. };
  14717. }
  14718. // CommonJS interop named imports.
  14719. var now$1 = Scheduler.unstable_now;
  14720. var commitTime = 0;
  14721. var profilerStartTime = -1;
  14722. function getCommitTime() {
  14723. return commitTime;
  14724. }
  14725. function recordCommitTime() {
  14726. if (!enableProfilerTimer) {
  14727. return;
  14728. }
  14729. commitTime = now$1();
  14730. }
  14731. function startProfilerTimer(fiber) {
  14732. if (!enableProfilerTimer) {
  14733. return;
  14734. }
  14735. profilerStartTime = now$1();
  14736. if (fiber.actualStartTime < 0) {
  14737. fiber.actualStartTime = now$1();
  14738. }
  14739. }
  14740. function stopProfilerTimerIfRunning(fiber) {
  14741. if (!enableProfilerTimer) {
  14742. return;
  14743. }
  14744. profilerStartTime = -1;
  14745. }
  14746. function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
  14747. if (!enableProfilerTimer) {
  14748. return;
  14749. }
  14750. if (profilerStartTime >= 0) {
  14751. var elapsedTime = now$1() - profilerStartTime;
  14752. fiber.actualDuration += elapsedTime;
  14753. if (overrideBaseTime) {
  14754. fiber.selfBaseDuration = elapsedTime;
  14755. }
  14756. profilerStartTime = -1;
  14757. }
  14758. }
  14759. // This may have been an insertion or a hydration.
  14760. var hydrationParentFiber = null;
  14761. var nextHydratableInstance = null;
  14762. var isHydrating = false;
  14763. function warnIfHydrating() {
  14764. {
  14765. !!isHydrating ? warning$1(false, 'We should not be hydrating here. This is a bug in React. Please file a bug.') : void 0;
  14766. }
  14767. }
  14768. function enterHydrationState(fiber) {
  14769. if (!supportsHydration) {
  14770. return false;
  14771. }
  14772. var parentInstance = fiber.stateNode.containerInfo;
  14773. nextHydratableInstance = getFirstHydratableChild(parentInstance);
  14774. hydrationParentFiber = fiber;
  14775. isHydrating = true;
  14776. return true;
  14777. }
  14778. function reenterHydrationStateFromDehydratedSuspenseInstance(fiber, suspenseInstance) {
  14779. if (!supportsHydration) {
  14780. return false;
  14781. }
  14782. nextHydratableInstance = getNextHydratableSibling(suspenseInstance);
  14783. popToNextHostParent(fiber);
  14784. isHydrating = true;
  14785. return true;
  14786. }
  14787. function deleteHydratableInstance(returnFiber, instance) {
  14788. {
  14789. switch (returnFiber.tag) {
  14790. case HostRoot:
  14791. didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance);
  14792. break;
  14793. case HostComponent:
  14794. didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance);
  14795. break;
  14796. }
  14797. }
  14798. var childToDelete = createFiberFromHostInstanceForDeletion();
  14799. childToDelete.stateNode = instance;
  14800. childToDelete.return = returnFiber;
  14801. childToDelete.effectTag = Deletion; // This might seem like it belongs on progressedFirstDeletion. However,
  14802. // these children are not part of the reconciliation list of children.
  14803. // Even if we abort and rereconcile the children, that will try to hydrate
  14804. // again and the nodes are still in the host tree so these will be
  14805. // recreated.
  14806. if (returnFiber.lastEffect !== null) {
  14807. returnFiber.lastEffect.nextEffect = childToDelete;
  14808. returnFiber.lastEffect = childToDelete;
  14809. } else {
  14810. returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
  14811. }
  14812. }
  14813. function insertNonHydratedInstance(returnFiber, fiber) {
  14814. fiber.effectTag = fiber.effectTag & ~Hydrating | Placement;
  14815. {
  14816. switch (returnFiber.tag) {
  14817. case HostRoot:
  14818. {
  14819. var parentContainer = returnFiber.stateNode.containerInfo;
  14820. switch (fiber.tag) {
  14821. case HostComponent:
  14822. var type = fiber.type;
  14823. var props = fiber.pendingProps;
  14824. didNotFindHydratableContainerInstance(parentContainer, type, props);
  14825. break;
  14826. case HostText:
  14827. var text = fiber.pendingProps;
  14828. didNotFindHydratableContainerTextInstance(parentContainer, text);
  14829. break;
  14830. case SuspenseComponent:
  14831. break;
  14832. }
  14833. break;
  14834. }
  14835. case HostComponent:
  14836. {
  14837. var parentType = returnFiber.type;
  14838. var parentProps = returnFiber.memoizedProps;
  14839. var parentInstance = returnFiber.stateNode;
  14840. switch (fiber.tag) {
  14841. case HostComponent:
  14842. var _type = fiber.type;
  14843. var _props = fiber.pendingProps;
  14844. didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type, _props);
  14845. break;
  14846. case HostText:
  14847. var _text = fiber.pendingProps;
  14848. didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text);
  14849. break;
  14850. case SuspenseComponent:
  14851. didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance);
  14852. break;
  14853. }
  14854. break;
  14855. }
  14856. default:
  14857. return;
  14858. }
  14859. }
  14860. }
  14861. function tryHydrate(fiber, nextInstance) {
  14862. switch (fiber.tag) {
  14863. case HostComponent:
  14864. {
  14865. var type = fiber.type;
  14866. var props = fiber.pendingProps;
  14867. var instance = canHydrateInstance(nextInstance, type, props);
  14868. if (instance !== null) {
  14869. fiber.stateNode = instance;
  14870. return true;
  14871. }
  14872. return false;
  14873. }
  14874. case HostText:
  14875. {
  14876. var text = fiber.pendingProps;
  14877. var textInstance = canHydrateTextInstance(nextInstance, text);
  14878. if (textInstance !== null) {
  14879. fiber.stateNode = textInstance;
  14880. return true;
  14881. }
  14882. return false;
  14883. }
  14884. case SuspenseComponent:
  14885. {
  14886. if (enableSuspenseServerRenderer) {
  14887. var suspenseInstance = canHydrateSuspenseInstance(nextInstance);
  14888. if (suspenseInstance !== null) {
  14889. var suspenseState = {
  14890. dehydrated: suspenseInstance,
  14891. retryTime: Never
  14892. };
  14893. fiber.memoizedState = suspenseState; // Store the dehydrated fragment as a child fiber.
  14894. // This simplifies the code for getHostSibling and deleting nodes,
  14895. // since it doesn't have to consider all Suspense boundaries and
  14896. // check if they're dehydrated ones or not.
  14897. var dehydratedFragment = createFiberFromDehydratedFragment(suspenseInstance);
  14898. dehydratedFragment.return = fiber;
  14899. fiber.child = dehydratedFragment;
  14900. return true;
  14901. }
  14902. }
  14903. return false;
  14904. }
  14905. default:
  14906. return false;
  14907. }
  14908. }
  14909. function tryToClaimNextHydratableInstance(fiber) {
  14910. if (!isHydrating) {
  14911. return;
  14912. }
  14913. var nextInstance = nextHydratableInstance;
  14914. if (!nextInstance) {
  14915. // Nothing to hydrate. Make it an insertion.
  14916. insertNonHydratedInstance(hydrationParentFiber, fiber);
  14917. isHydrating = false;
  14918. hydrationParentFiber = fiber;
  14919. return;
  14920. }
  14921. var firstAttemptedInstance = nextInstance;
  14922. if (!tryHydrate(fiber, nextInstance)) {
  14923. // If we can't hydrate this instance let's try the next one.
  14924. // We use this as a heuristic. It's based on intuition and not data so it
  14925. // might be flawed or unnecessary.
  14926. nextInstance = getNextHydratableSibling(firstAttemptedInstance);
  14927. if (!nextInstance || !tryHydrate(fiber, nextInstance)) {
  14928. // Nothing to hydrate. Make it an insertion.
  14929. insertNonHydratedInstance(hydrationParentFiber, fiber);
  14930. isHydrating = false;
  14931. hydrationParentFiber = fiber;
  14932. return;
  14933. } // We matched the next one, we'll now assume that the first one was
  14934. // superfluous and we'll delete it. Since we can't eagerly delete it
  14935. // we'll have to schedule a deletion. To do that, this node needs a dummy
  14936. // fiber associated with it.
  14937. deleteHydratableInstance(hydrationParentFiber, firstAttemptedInstance);
  14938. }
  14939. hydrationParentFiber = fiber;
  14940. nextHydratableInstance = getFirstHydratableChild(nextInstance);
  14941. }
  14942. function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) {
  14943. if (!supportsHydration) {
  14944. {
  14945. {
  14946. throw Error("Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.");
  14947. }
  14948. }
  14949. }
  14950. var instance = fiber.stateNode;
  14951. var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber); // TODO: Type this specific to this type of component.
  14952. fiber.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there
  14953. // is a new ref we mark this as an update.
  14954. if (updatePayload !== null) {
  14955. return true;
  14956. }
  14957. return false;
  14958. }
  14959. function prepareToHydrateHostTextInstance(fiber) {
  14960. if (!supportsHydration) {
  14961. {
  14962. {
  14963. throw Error("Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.");
  14964. }
  14965. }
  14966. }
  14967. var textInstance = fiber.stateNode;
  14968. var textContent = fiber.memoizedProps;
  14969. var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber);
  14970. {
  14971. if (shouldUpdate) {
  14972. // We assume that prepareToHydrateHostTextInstance is called in a context where the
  14973. // hydration parent is the parent host component of this host text.
  14974. var returnFiber = hydrationParentFiber;
  14975. if (returnFiber !== null) {
  14976. switch (returnFiber.tag) {
  14977. case HostRoot:
  14978. {
  14979. var parentContainer = returnFiber.stateNode.containerInfo;
  14980. didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent);
  14981. break;
  14982. }
  14983. case HostComponent:
  14984. {
  14985. var parentType = returnFiber.type;
  14986. var parentProps = returnFiber.memoizedProps;
  14987. var parentInstance = returnFiber.stateNode;
  14988. didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent);
  14989. break;
  14990. }
  14991. }
  14992. }
  14993. }
  14994. }
  14995. return shouldUpdate;
  14996. }
  14997. function prepareToHydrateHostSuspenseInstance(fiber) {
  14998. if (!supportsHydration) {
  14999. {
  15000. {
  15001. throw Error("Expected prepareToHydrateHostSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.");
  15002. }
  15003. }
  15004. }
  15005. var suspenseState = fiber.memoizedState;
  15006. var suspenseInstance = suspenseState !== null ? suspenseState.dehydrated : null;
  15007. if (!suspenseInstance) {
  15008. {
  15009. throw Error("Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue.");
  15010. }
  15011. }
  15012. hydrateSuspenseInstance(suspenseInstance, fiber);
  15013. }
  15014. function skipPastDehydratedSuspenseInstance(fiber) {
  15015. if (!supportsHydration) {
  15016. {
  15017. {
  15018. throw Error("Expected skipPastDehydratedSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.");
  15019. }
  15020. }
  15021. }
  15022. var suspenseState = fiber.memoizedState;
  15023. var suspenseInstance = suspenseState !== null ? suspenseState.dehydrated : null;
  15024. if (!suspenseInstance) {
  15025. {
  15026. throw Error("Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue.");
  15027. }
  15028. }
  15029. return getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
  15030. }
  15031. function popToNextHostParent(fiber) {
  15032. var parent = fiber.return;
  15033. while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== SuspenseComponent) {
  15034. parent = parent.return;
  15035. }
  15036. hydrationParentFiber = parent;
  15037. }
  15038. function popHydrationState(fiber) {
  15039. if (!supportsHydration) {
  15040. return false;
  15041. }
  15042. if (fiber !== hydrationParentFiber) {
  15043. // We're deeper than the current hydration context, inside an inserted
  15044. // tree.
  15045. return false;
  15046. }
  15047. if (!isHydrating) {
  15048. // If we're not currently hydrating but we're in a hydration context, then
  15049. // we were an insertion and now need to pop up reenter hydration of our
  15050. // siblings.
  15051. popToNextHostParent(fiber);
  15052. isHydrating = true;
  15053. return false;
  15054. }
  15055. var type = fiber.type; // If we have any remaining hydratable nodes, we need to delete them now.
  15056. // We only do this deeper than head and body since they tend to have random
  15057. // other nodes in them. We also ignore components with pure text content in
  15058. // side of them.
  15059. // TODO: Better heuristic.
  15060. if (fiber.tag !== HostComponent || type !== 'head' && type !== 'body' && !shouldSetTextContent(type, fiber.memoizedProps)) {
  15061. var nextInstance = nextHydratableInstance;
  15062. while (nextInstance) {
  15063. deleteHydratableInstance(fiber, nextInstance);
  15064. nextInstance = getNextHydratableSibling(nextInstance);
  15065. }
  15066. }
  15067. popToNextHostParent(fiber);
  15068. if (fiber.tag === SuspenseComponent) {
  15069. nextHydratableInstance = skipPastDehydratedSuspenseInstance(fiber);
  15070. } else {
  15071. nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null;
  15072. }
  15073. return true;
  15074. }
  15075. function resetHydrationState() {
  15076. if (!supportsHydration) {
  15077. return;
  15078. }
  15079. hydrationParentFiber = null;
  15080. nextHydratableInstance = null;
  15081. isHydrating = false;
  15082. }
  15083. var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner;
  15084. var didReceiveUpdate = false;
  15085. var didWarnAboutBadClass;
  15086. var didWarnAboutModulePatternComponent;
  15087. var didWarnAboutContextTypeOnFunctionComponent;
  15088. var didWarnAboutGetDerivedStateOnFunctionComponent;
  15089. var didWarnAboutFunctionRefs;
  15090. var didWarnAboutReassigningProps;
  15091. var didWarnAboutMaxDuration;
  15092. var didWarnAboutRevealOrder;
  15093. var didWarnAboutTailOptions;
  15094. var didWarnAboutDefaultPropsOnFunctionComponent;
  15095. {
  15096. didWarnAboutBadClass = {};
  15097. didWarnAboutModulePatternComponent = {};
  15098. didWarnAboutContextTypeOnFunctionComponent = {};
  15099. didWarnAboutGetDerivedStateOnFunctionComponent = {};
  15100. didWarnAboutFunctionRefs = {};
  15101. didWarnAboutReassigningProps = false;
  15102. didWarnAboutMaxDuration = false;
  15103. didWarnAboutRevealOrder = {};
  15104. didWarnAboutTailOptions = {};
  15105. didWarnAboutDefaultPropsOnFunctionComponent = {};
  15106. }
  15107. function reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime) {
  15108. if (current$$1 === null) {
  15109. // If this is a fresh new component that hasn't been rendered yet, we
  15110. // won't update its child set by applying minimal side-effects. Instead,
  15111. // we will add them all to the child before it gets rendered. That means
  15112. // we can optimize this reconciliation pass by not tracking side-effects.
  15113. workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  15114. } else {
  15115. // If the current child is the same as the work in progress, it means that
  15116. // we haven't yet started any work on these children. Therefore, we use
  15117. // the clone algorithm to create a copy of all the current children.
  15118. // If we had any progressed work already, that is invalid at this point so
  15119. // let's throw it out.
  15120. workInProgress.child = reconcileChildFibers(workInProgress, current$$1.child, nextChildren, renderExpirationTime);
  15121. }
  15122. }
  15123. function forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildren, renderExpirationTime) {
  15124. // This function is fork of reconcileChildren. It's used in cases where we
  15125. // want to reconcile without matching against the existing set. This has the
  15126. // effect of all current children being unmounted; even if the type and key
  15127. // are the same, the old child is unmounted and a new child is created.
  15128. //
  15129. // To do this, we're going to go through the reconcile algorithm twice. In
  15130. // the first pass, we schedule a deletion for all the current children by
  15131. // passing null.
  15132. workInProgress.child = reconcileChildFibers(workInProgress, current$$1.child, null, renderExpirationTime); // In the second pass, we mount the new children. The trick here is that we
  15133. // pass null in place of where we usually pass the current child set. This has
  15134. // the effect of remounting all children regardless of whether their their
  15135. // identity matches.
  15136. workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  15137. }
  15138. function updateForwardRef(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
  15139. // TODO: current can be non-null here even if the component
  15140. // hasn't yet mounted. This happens after the first render suspends.
  15141. // We'll need to figure out if this is fine or can cause issues.
  15142. {
  15143. if (workInProgress.type !== workInProgress.elementType) {
  15144. // Lazy component props can't be validated in createElement
  15145. // because they're only guaranteed to be resolved here.
  15146. var innerPropTypes = Component.propTypes;
  15147. if (innerPropTypes) {
  15148. checkPropTypes(innerPropTypes, nextProps, // Resolved props
  15149. 'prop', getComponentName(Component), getCurrentFiberStackInDev);
  15150. }
  15151. }
  15152. }
  15153. var render = Component.render;
  15154. var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent
  15155. var nextChildren;
  15156. prepareToReadContext(workInProgress, renderExpirationTime);
  15157. {
  15158. ReactCurrentOwner$3.current = workInProgress;
  15159. setCurrentPhase('render');
  15160. nextChildren = renderWithHooks(current$$1, workInProgress, render, nextProps, ref, renderExpirationTime);
  15161. if (debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  15162. // Only double-render components with Hooks
  15163. if (workInProgress.memoizedState !== null) {
  15164. nextChildren = renderWithHooks(current$$1, workInProgress, render, nextProps, ref, renderExpirationTime);
  15165. }
  15166. }
  15167. setCurrentPhase(null);
  15168. }
  15169. if (current$$1 !== null && !didReceiveUpdate) {
  15170. bailoutHooks(current$$1, workInProgress, renderExpirationTime);
  15171. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  15172. } // React DevTools reads this flag.
  15173. workInProgress.effectTag |= PerformedWork;
  15174. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  15175. return workInProgress.child;
  15176. }
  15177. function updateMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
  15178. if (current$$1 === null) {
  15179. var type = Component.type;
  15180. if (isSimpleFunctionComponent(type) && Component.compare === null && // SimpleMemoComponent codepath doesn't resolve outer props either.
  15181. Component.defaultProps === undefined) {
  15182. var resolvedType = type;
  15183. {
  15184. resolvedType = resolveFunctionForHotReloading(type);
  15185. } // If this is a plain function component without default props,
  15186. // and with only the default shallow comparison, we upgrade it
  15187. // to a SimpleMemoComponent to allow fast path updates.
  15188. workInProgress.tag = SimpleMemoComponent;
  15189. workInProgress.type = resolvedType;
  15190. {
  15191. validateFunctionComponentInDev(workInProgress, type);
  15192. }
  15193. return updateSimpleMemoComponent(current$$1, workInProgress, resolvedType, nextProps, updateExpirationTime, renderExpirationTime);
  15194. }
  15195. {
  15196. var innerPropTypes = type.propTypes;
  15197. if (innerPropTypes) {
  15198. // Inner memo component props aren't currently validated in createElement.
  15199. // We could move it there, but we'd still need this for lazy code path.
  15200. checkPropTypes(innerPropTypes, nextProps, // Resolved props
  15201. 'prop', getComponentName(type), getCurrentFiberStackInDev);
  15202. }
  15203. }
  15204. var child = createFiberFromTypeAndProps(Component.type, null, nextProps, null, workInProgress.mode, renderExpirationTime);
  15205. child.ref = workInProgress.ref;
  15206. child.return = workInProgress;
  15207. workInProgress.child = child;
  15208. return child;
  15209. }
  15210. {
  15211. var _type = Component.type;
  15212. var _innerPropTypes = _type.propTypes;
  15213. if (_innerPropTypes) {
  15214. // Inner memo component props aren't currently validated in createElement.
  15215. // We could move it there, but we'd still need this for lazy code path.
  15216. checkPropTypes(_innerPropTypes, nextProps, // Resolved props
  15217. 'prop', getComponentName(_type), getCurrentFiberStackInDev);
  15218. }
  15219. }
  15220. var currentChild = current$$1.child; // This is always exactly one child
  15221. if (updateExpirationTime < renderExpirationTime) {
  15222. // This will be the props with resolved defaultProps,
  15223. // unlike current.memoizedProps which will be the unresolved ones.
  15224. var prevProps = currentChild.memoizedProps; // Default to shallow comparison
  15225. var compare = Component.compare;
  15226. compare = compare !== null ? compare : shallowEqual;
  15227. if (compare(prevProps, nextProps) && current$$1.ref === workInProgress.ref) {
  15228. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  15229. }
  15230. } // React DevTools reads this flag.
  15231. workInProgress.effectTag |= PerformedWork;
  15232. var newChild = createWorkInProgress(currentChild, nextProps, renderExpirationTime);
  15233. newChild.ref = workInProgress.ref;
  15234. newChild.return = workInProgress;
  15235. workInProgress.child = newChild;
  15236. return newChild;
  15237. }
  15238. function updateSimpleMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
  15239. // TODO: current can be non-null here even if the component
  15240. // hasn't yet mounted. This happens when the inner render suspends.
  15241. // We'll need to figure out if this is fine or can cause issues.
  15242. {
  15243. if (workInProgress.type !== workInProgress.elementType) {
  15244. // Lazy component props can't be validated in createElement
  15245. // because they're only guaranteed to be resolved here.
  15246. var outerMemoType = workInProgress.elementType;
  15247. if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
  15248. // We warn when you define propTypes on lazy()
  15249. // so let's just skip over it to find memo() outer wrapper.
  15250. // Inner props for memo are validated later.
  15251. outerMemoType = refineResolvedLazyComponent(outerMemoType);
  15252. }
  15253. var outerPropTypes = outerMemoType && outerMemoType.propTypes;
  15254. if (outerPropTypes) {
  15255. checkPropTypes(outerPropTypes, nextProps, // Resolved (SimpleMemoComponent has no defaultProps)
  15256. 'prop', getComponentName(outerMemoType), getCurrentFiberStackInDev);
  15257. } // Inner propTypes will be validated in the function component path.
  15258. }
  15259. }
  15260. if (current$$1 !== null) {
  15261. var prevProps = current$$1.memoizedProps;
  15262. if (shallowEqual(prevProps, nextProps) && current$$1.ref === workInProgress.ref && ( // Prevent bailout if the implementation changed due to hot reload:
  15263. workInProgress.type === current$$1.type)) {
  15264. didReceiveUpdate = false;
  15265. if (updateExpirationTime < renderExpirationTime) {
  15266. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  15267. }
  15268. }
  15269. }
  15270. return updateFunctionComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime);
  15271. }
  15272. function updateFragment(current$$1, workInProgress, renderExpirationTime) {
  15273. var nextChildren = workInProgress.pendingProps;
  15274. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  15275. return workInProgress.child;
  15276. }
  15277. function updateMode(current$$1, workInProgress, renderExpirationTime) {
  15278. var nextChildren = workInProgress.pendingProps.children;
  15279. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  15280. return workInProgress.child;
  15281. }
  15282. function updateProfiler(current$$1, workInProgress, renderExpirationTime) {
  15283. if (enableProfilerTimer) {
  15284. workInProgress.effectTag |= Update;
  15285. }
  15286. var nextProps = workInProgress.pendingProps;
  15287. var nextChildren = nextProps.children;
  15288. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  15289. return workInProgress.child;
  15290. }
  15291. function markRef(current$$1, workInProgress) {
  15292. var ref = workInProgress.ref;
  15293. if (current$$1 === null && ref !== null || current$$1 !== null && current$$1.ref !== ref) {
  15294. // Schedule a Ref effect
  15295. workInProgress.effectTag |= Ref;
  15296. }
  15297. }
  15298. function updateFunctionComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
  15299. {
  15300. if (workInProgress.type !== workInProgress.elementType) {
  15301. // Lazy component props can't be validated in createElement
  15302. // because they're only guaranteed to be resolved here.
  15303. var innerPropTypes = Component.propTypes;
  15304. if (innerPropTypes) {
  15305. checkPropTypes(innerPropTypes, nextProps, // Resolved props
  15306. 'prop', getComponentName(Component), getCurrentFiberStackInDev);
  15307. }
  15308. }
  15309. }
  15310. var context;
  15311. if (!disableLegacyContext) {
  15312. var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
  15313. context = getMaskedContext(workInProgress, unmaskedContext);
  15314. }
  15315. var nextChildren;
  15316. prepareToReadContext(workInProgress, renderExpirationTime);
  15317. {
  15318. ReactCurrentOwner$3.current = workInProgress;
  15319. setCurrentPhase('render');
  15320. nextChildren = renderWithHooks(current$$1, workInProgress, Component, nextProps, context, renderExpirationTime);
  15321. if (debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  15322. // Only double-render components with Hooks
  15323. if (workInProgress.memoizedState !== null) {
  15324. nextChildren = renderWithHooks(current$$1, workInProgress, Component, nextProps, context, renderExpirationTime);
  15325. }
  15326. }
  15327. setCurrentPhase(null);
  15328. }
  15329. if (current$$1 !== null && !didReceiveUpdate) {
  15330. bailoutHooks(current$$1, workInProgress, renderExpirationTime);
  15331. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  15332. } // React DevTools reads this flag.
  15333. workInProgress.effectTag |= PerformedWork;
  15334. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  15335. return workInProgress.child;
  15336. }
  15337. function updateClassComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
  15338. {
  15339. if (workInProgress.type !== workInProgress.elementType) {
  15340. // Lazy component props can't be validated in createElement
  15341. // because they're only guaranteed to be resolved here.
  15342. var innerPropTypes = Component.propTypes;
  15343. if (innerPropTypes) {
  15344. checkPropTypes(innerPropTypes, nextProps, // Resolved props
  15345. 'prop', getComponentName(Component), getCurrentFiberStackInDev);
  15346. }
  15347. }
  15348. } // Push context providers early to prevent context stack mismatches.
  15349. // During mounting we don't know the child context yet as the instance doesn't exist.
  15350. // We will invalidate the child context in finishClassComponent() right after rendering.
  15351. var hasContext;
  15352. if (isContextProvider(Component)) {
  15353. hasContext = true;
  15354. pushContextProvider(workInProgress);
  15355. } else {
  15356. hasContext = false;
  15357. }
  15358. prepareToReadContext(workInProgress, renderExpirationTime);
  15359. var instance = workInProgress.stateNode;
  15360. var shouldUpdate;
  15361. if (instance === null) {
  15362. if (current$$1 !== null) {
  15363. // An class component without an instance only mounts if it suspended
  15364. // inside a non- concurrent tree, in an inconsistent state. We want to
  15365. // tree it like a new mount, even though an empty version of it already
  15366. // committed. Disconnect the alternate pointers.
  15367. current$$1.alternate = null;
  15368. workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
  15369. workInProgress.effectTag |= Placement;
  15370. } // In the initial pass we might need to construct the instance.
  15371. constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  15372. mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  15373. shouldUpdate = true;
  15374. } else if (current$$1 === null) {
  15375. // In a resume, we'll already have an instance we can reuse.
  15376. shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  15377. } else {
  15378. shouldUpdate = updateClassInstance(current$$1, workInProgress, Component, nextProps, renderExpirationTime);
  15379. }
  15380. var nextUnitOfWork = finishClassComponent(current$$1, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime);
  15381. {
  15382. var inst = workInProgress.stateNode;
  15383. if (inst.props !== nextProps) {
  15384. !didWarnAboutReassigningProps ? warning$1(false, 'It looks like %s is reassigning its own `this.props` while rendering. ' + 'This is not supported and can lead to confusing bugs.', getComponentName(workInProgress.type) || 'a component') : void 0;
  15385. didWarnAboutReassigningProps = true;
  15386. }
  15387. }
  15388. return nextUnitOfWork;
  15389. }
  15390. function finishClassComponent(current$$1, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime) {
  15391. // Refs should update even if shouldComponentUpdate returns false
  15392. markRef(current$$1, workInProgress);
  15393. var didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect;
  15394. if (!shouldUpdate && !didCaptureError) {
  15395. // Context providers should defer to sCU for rendering
  15396. if (hasContext) {
  15397. invalidateContextProvider(workInProgress, Component, false);
  15398. }
  15399. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  15400. }
  15401. var instance = workInProgress.stateNode; // Rerender
  15402. ReactCurrentOwner$3.current = workInProgress;
  15403. var nextChildren;
  15404. if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') {
  15405. // If we captured an error, but getDerivedStateFrom catch is not defined,
  15406. // unmount all the children. componentDidCatch will schedule an update to
  15407. // re-render a fallback. This is temporary until we migrate everyone to
  15408. // the new API.
  15409. // TODO: Warn in a future release.
  15410. nextChildren = null;
  15411. if (enableProfilerTimer) {
  15412. stopProfilerTimerIfRunning(workInProgress);
  15413. }
  15414. } else {
  15415. {
  15416. setCurrentPhase('render');
  15417. nextChildren = instance.render();
  15418. if (debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  15419. instance.render();
  15420. }
  15421. setCurrentPhase(null);
  15422. }
  15423. } // React DevTools reads this flag.
  15424. workInProgress.effectTag |= PerformedWork;
  15425. if (current$$1 !== null && didCaptureError) {
  15426. // If we're recovering from an error, reconcile without reusing any of
  15427. // the existing children. Conceptually, the normal children and the children
  15428. // that are shown on error are two different sets, so we shouldn't reuse
  15429. // normal children even if their identities match.
  15430. forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildren, renderExpirationTime);
  15431. } else {
  15432. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  15433. } // Memoize state using the values we just used to render.
  15434. // TODO: Restructure so we never read values from the instance.
  15435. workInProgress.memoizedState = instance.state; // The context might have changed so we need to recalculate it.
  15436. if (hasContext) {
  15437. invalidateContextProvider(workInProgress, Component, true);
  15438. }
  15439. return workInProgress.child;
  15440. }
  15441. function pushHostRootContext(workInProgress) {
  15442. var root = workInProgress.stateNode;
  15443. if (root.pendingContext) {
  15444. pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context);
  15445. } else if (root.context) {
  15446. // Should always be set
  15447. pushTopLevelContextObject(workInProgress, root.context, false);
  15448. }
  15449. pushHostContainer(workInProgress, root.containerInfo);
  15450. }
  15451. function updateHostRoot(current$$1, workInProgress, renderExpirationTime) {
  15452. pushHostRootContext(workInProgress);
  15453. var updateQueue = workInProgress.updateQueue;
  15454. if (!(updateQueue !== null)) {
  15455. {
  15456. throw Error("If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue.");
  15457. }
  15458. }
  15459. var nextProps = workInProgress.pendingProps;
  15460. var prevState = workInProgress.memoizedState;
  15461. var prevChildren = prevState !== null ? prevState.element : null;
  15462. processUpdateQueue(workInProgress, updateQueue, nextProps, null, renderExpirationTime);
  15463. var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property
  15464. // being called "element".
  15465. var nextChildren = nextState.element;
  15466. if (nextChildren === prevChildren) {
  15467. // If the state is the same as before, that's a bailout because we had
  15468. // no work that expires at this time.
  15469. resetHydrationState();
  15470. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  15471. }
  15472. var root = workInProgress.stateNode;
  15473. if (root.hydrate && enterHydrationState(workInProgress)) {
  15474. // If we don't have any current children this might be the first pass.
  15475. // We always try to hydrate. If this isn't a hydration pass there won't
  15476. // be any children to hydrate which is effectively the same thing as
  15477. // not hydrating.
  15478. var child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  15479. workInProgress.child = child;
  15480. var node = child;
  15481. while (node) {
  15482. // Mark each child as hydrating. This is a fast path to know whether this
  15483. // tree is part of a hydrating tree. This is used to determine if a child
  15484. // node has fully mounted yet, and for scheduling event replaying.
  15485. // Conceptually this is similar to Placement in that a new subtree is
  15486. // inserted into the React tree here. It just happens to not need DOM
  15487. // mutations because it already exists.
  15488. node.effectTag = node.effectTag & ~Placement | Hydrating;
  15489. node = node.sibling;
  15490. }
  15491. } else {
  15492. // Otherwise reset hydration state in case we aborted and resumed another
  15493. // root.
  15494. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  15495. resetHydrationState();
  15496. }
  15497. return workInProgress.child;
  15498. }
  15499. function updateHostComponent(current$$1, workInProgress, renderExpirationTime) {
  15500. pushHostContext(workInProgress);
  15501. if (current$$1 === null) {
  15502. tryToClaimNextHydratableInstance(workInProgress);
  15503. }
  15504. var type = workInProgress.type;
  15505. var nextProps = workInProgress.pendingProps;
  15506. var prevProps = current$$1 !== null ? current$$1.memoizedProps : null;
  15507. var nextChildren = nextProps.children;
  15508. var isDirectTextChild = shouldSetTextContent(type, nextProps);
  15509. if (isDirectTextChild) {
  15510. // We special case a direct text child of a host node. This is a common
  15511. // case. We won't handle it as a reified child. We will instead handle
  15512. // this in the host environment that also have access to this prop. That
  15513. // avoids allocating another HostText fiber and traversing it.
  15514. nextChildren = null;
  15515. } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) {
  15516. // If we're switching from a direct text child to a normal child, or to
  15517. // empty, we need to schedule the text content to be reset.
  15518. workInProgress.effectTag |= ContentReset;
  15519. }
  15520. markRef(current$$1, workInProgress); // Check the host config to see if the children are offscreen/hidden.
  15521. if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(type, nextProps)) {
  15522. if (enableSchedulerTracing) {
  15523. markSpawnedWork(Never);
  15524. } // Schedule this fiber to re-render at offscreen priority. Then bailout.
  15525. workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
  15526. return null;
  15527. }
  15528. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  15529. return workInProgress.child;
  15530. }
  15531. function updateHostText(current$$1, workInProgress) {
  15532. if (current$$1 === null) {
  15533. tryToClaimNextHydratableInstance(workInProgress);
  15534. } // Nothing to do here. This is terminal. We'll do the completion step
  15535. // immediately after.
  15536. return null;
  15537. }
  15538. function mountLazyComponent(_current, workInProgress, elementType, updateExpirationTime, renderExpirationTime) {
  15539. if (_current !== null) {
  15540. // An lazy component only mounts if it suspended inside a non-
  15541. // concurrent tree, in an inconsistent state. We want to treat it like
  15542. // a new mount, even though an empty version of it already committed.
  15543. // Disconnect the alternate pointers.
  15544. _current.alternate = null;
  15545. workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
  15546. workInProgress.effectTag |= Placement;
  15547. }
  15548. var props = workInProgress.pendingProps; // We can't start a User Timing measurement with correct label yet.
  15549. // Cancel and resume right after we know the tag.
  15550. cancelWorkTimer(workInProgress);
  15551. var Component = readLazyComponentType(elementType); // Store the unwrapped component in the type.
  15552. workInProgress.type = Component;
  15553. var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component);
  15554. startWorkTimer(workInProgress);
  15555. var resolvedProps = resolveDefaultProps(Component, props);
  15556. var child;
  15557. switch (resolvedTag) {
  15558. case FunctionComponent:
  15559. {
  15560. {
  15561. validateFunctionComponentInDev(workInProgress, Component);
  15562. workInProgress.type = Component = resolveFunctionForHotReloading(Component);
  15563. }
  15564. child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
  15565. break;
  15566. }
  15567. case ClassComponent:
  15568. {
  15569. {
  15570. workInProgress.type = Component = resolveClassForHotReloading(Component);
  15571. }
  15572. child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
  15573. break;
  15574. }
  15575. case ForwardRef:
  15576. {
  15577. {
  15578. workInProgress.type = Component = resolveForwardRefForHotReloading(Component);
  15579. }
  15580. child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderExpirationTime);
  15581. break;
  15582. }
  15583. case MemoComponent:
  15584. {
  15585. {
  15586. if (workInProgress.type !== workInProgress.elementType) {
  15587. var outerPropTypes = Component.propTypes;
  15588. if (outerPropTypes) {
  15589. checkPropTypes(outerPropTypes, resolvedProps, // Resolved for outer only
  15590. 'prop', getComponentName(Component), getCurrentFiberStackInDev);
  15591. }
  15592. }
  15593. }
  15594. child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too
  15595. updateExpirationTime, renderExpirationTime);
  15596. break;
  15597. }
  15598. default:
  15599. {
  15600. var hint = '';
  15601. {
  15602. if (Component !== null && typeof Component === 'object' && Component.$$typeof === REACT_LAZY_TYPE) {
  15603. hint = ' Did you wrap a component in React.lazy() more than once?';
  15604. }
  15605. } // This message intentionally doesn't mention ForwardRef or MemoComponent
  15606. // because the fact that it's a separate type of work is an
  15607. // implementation detail.
  15608. {
  15609. {
  15610. throw Error("Element type is invalid. Received a promise that resolves to: " + Component + ". Lazy element type must resolve to a class or function." + hint);
  15611. }
  15612. }
  15613. }
  15614. }
  15615. return child;
  15616. }
  15617. function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderExpirationTime) {
  15618. if (_current !== null) {
  15619. // An incomplete component only mounts if it suspended inside a non-
  15620. // concurrent tree, in an inconsistent state. We want to treat it like
  15621. // a new mount, even though an empty version of it already committed.
  15622. // Disconnect the alternate pointers.
  15623. _current.alternate = null;
  15624. workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
  15625. workInProgress.effectTag |= Placement;
  15626. } // Promote the fiber to a class and try rendering again.
  15627. workInProgress.tag = ClassComponent; // The rest of this function is a fork of `updateClassComponent`
  15628. // Push context providers early to prevent context stack mismatches.
  15629. // During mounting we don't know the child context yet as the instance doesn't exist.
  15630. // We will invalidate the child context in finishClassComponent() right after rendering.
  15631. var hasContext;
  15632. if (isContextProvider(Component)) {
  15633. hasContext = true;
  15634. pushContextProvider(workInProgress);
  15635. } else {
  15636. hasContext = false;
  15637. }
  15638. prepareToReadContext(workInProgress, renderExpirationTime);
  15639. constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  15640. mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  15641. return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
  15642. }
  15643. function mountIndeterminateComponent(_current, workInProgress, Component, renderExpirationTime) {
  15644. if (_current !== null) {
  15645. // An indeterminate component only mounts if it suspended inside a non-
  15646. // concurrent tree, in an inconsistent state. We want to treat it like
  15647. // a new mount, even though an empty version of it already committed.
  15648. // Disconnect the alternate pointers.
  15649. _current.alternate = null;
  15650. workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
  15651. workInProgress.effectTag |= Placement;
  15652. }
  15653. var props = workInProgress.pendingProps;
  15654. var context;
  15655. if (!disableLegacyContext) {
  15656. var unmaskedContext = getUnmaskedContext(workInProgress, Component, false);
  15657. context = getMaskedContext(workInProgress, unmaskedContext);
  15658. }
  15659. prepareToReadContext(workInProgress, renderExpirationTime);
  15660. var value;
  15661. {
  15662. if (Component.prototype && typeof Component.prototype.render === 'function') {
  15663. var componentName = getComponentName(Component) || 'Unknown';
  15664. if (!didWarnAboutBadClass[componentName]) {
  15665. warningWithoutStack$1(false, "The <%s /> component appears to have a render method, but doesn't extend React.Component. " + 'This is likely to cause errors. Change %s to extend React.Component instead.', componentName, componentName);
  15666. didWarnAboutBadClass[componentName] = true;
  15667. }
  15668. }
  15669. if (workInProgress.mode & StrictMode) {
  15670. ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
  15671. }
  15672. ReactCurrentOwner$3.current = workInProgress;
  15673. value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
  15674. } // React DevTools reads this flag.
  15675. workInProgress.effectTag |= PerformedWork;
  15676. if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
  15677. {
  15678. var _componentName = getComponentName(Component) || 'Unknown';
  15679. if (!didWarnAboutModulePatternComponent[_componentName]) {
  15680. warningWithoutStack$1(false, 'The <%s /> component appears to be a function component that returns a class instance. ' + 'Change %s to a class that extends React.Component instead. ' + "If you can't use a class try assigning the prototype on the function as a workaround. " + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + 'cannot be called with `new` by React.', _componentName, _componentName, _componentName);
  15681. didWarnAboutModulePatternComponent[_componentName] = true;
  15682. }
  15683. } // Proceed under the assumption that this is a class instance
  15684. workInProgress.tag = ClassComponent; // Throw out any hooks that were used.
  15685. resetHooks(); // Push context providers early to prevent context stack mismatches.
  15686. // During mounting we don't know the child context yet as the instance doesn't exist.
  15687. // We will invalidate the child context in finishClassComponent() right after rendering.
  15688. var hasContext = false;
  15689. if (isContextProvider(Component)) {
  15690. hasContext = true;
  15691. pushContextProvider(workInProgress);
  15692. } else {
  15693. hasContext = false;
  15694. }
  15695. workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null;
  15696. var getDerivedStateFromProps = Component.getDerivedStateFromProps;
  15697. if (typeof getDerivedStateFromProps === 'function') {
  15698. applyDerivedStateFromProps(workInProgress, Component, getDerivedStateFromProps, props);
  15699. }
  15700. adoptClassInstance(workInProgress, value);
  15701. mountClassInstance(workInProgress, Component, props, renderExpirationTime);
  15702. return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
  15703. } else {
  15704. // Proceed under the assumption that this is a function component
  15705. workInProgress.tag = FunctionComponent;
  15706. {
  15707. if (disableLegacyContext && Component.contextTypes) {
  15708. warningWithoutStack$1(false, '%s uses the legacy contextTypes API which is no longer supported. ' + 'Use React.createContext() with React.useContext() instead.', getComponentName(Component) || 'Unknown');
  15709. }
  15710. if (debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  15711. // Only double-render components with Hooks
  15712. if (workInProgress.memoizedState !== null) {
  15713. value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
  15714. }
  15715. }
  15716. }
  15717. reconcileChildren(null, workInProgress, value, renderExpirationTime);
  15718. {
  15719. validateFunctionComponentInDev(workInProgress, Component);
  15720. }
  15721. return workInProgress.child;
  15722. }
  15723. }
  15724. function validateFunctionComponentInDev(workInProgress, Component) {
  15725. if (Component) {
  15726. !!Component.childContextTypes ? warningWithoutStack$1(false, '%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component') : void 0;
  15727. }
  15728. if (workInProgress.ref !== null) {
  15729. var info = '';
  15730. var ownerName = getCurrentFiberOwnerNameInDevOrNull();
  15731. if (ownerName) {
  15732. info += '\n\nCheck the render method of `' + ownerName + '`.';
  15733. }
  15734. var warningKey = ownerName || workInProgress._debugID || '';
  15735. var debugSource = workInProgress._debugSource;
  15736. if (debugSource) {
  15737. warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
  15738. }
  15739. if (!didWarnAboutFunctionRefs[warningKey]) {
  15740. didWarnAboutFunctionRefs[warningKey] = true;
  15741. warning$1(false, 'Function components cannot be given refs. ' + 'Attempts to access this ref will fail. ' + 'Did you mean to use React.forwardRef()?%s', info);
  15742. }
  15743. }
  15744. if (warnAboutDefaultPropsOnFunctionComponents && Component.defaultProps !== undefined) {
  15745. var componentName = getComponentName(Component) || 'Unknown';
  15746. if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
  15747. warningWithoutStack$1(false, '%s: Support for defaultProps will be removed from function components ' + 'in a future major release. Use JavaScript default parameters instead.', componentName);
  15748. didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true;
  15749. }
  15750. }
  15751. if (typeof Component.getDerivedStateFromProps === 'function') {
  15752. var _componentName2 = getComponentName(Component) || 'Unknown';
  15753. if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) {
  15754. warningWithoutStack$1(false, '%s: Function components do not support getDerivedStateFromProps.', _componentName2);
  15755. didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true;
  15756. }
  15757. }
  15758. if (typeof Component.contextType === 'object' && Component.contextType !== null) {
  15759. var _componentName3 = getComponentName(Component) || 'Unknown';
  15760. if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) {
  15761. warningWithoutStack$1(false, '%s: Function components do not support contextType.', _componentName3);
  15762. didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true;
  15763. }
  15764. }
  15765. }
  15766. var SUSPENDED_MARKER = {
  15767. dehydrated: null,
  15768. retryTime: NoWork
  15769. };
  15770. function shouldRemainOnFallback(suspenseContext, current$$1, workInProgress) {
  15771. // If the context is telling us that we should show a fallback, and we're not
  15772. // already showing content, then we should show the fallback instead.
  15773. return hasSuspenseContext(suspenseContext, ForceSuspenseFallback) && (current$$1 === null || current$$1.memoizedState !== null);
  15774. }
  15775. function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime) {
  15776. var mode = workInProgress.mode;
  15777. var nextProps = workInProgress.pendingProps; // This is used by DevTools to force a boundary to suspend.
  15778. {
  15779. if (shouldSuspend(workInProgress)) {
  15780. workInProgress.effectTag |= DidCapture;
  15781. }
  15782. }
  15783. var suspenseContext = suspenseStackCursor.current;
  15784. var nextDidTimeout = false;
  15785. var didSuspend = (workInProgress.effectTag & DidCapture) !== NoEffect;
  15786. if (didSuspend || shouldRemainOnFallback(suspenseContext, current$$1, workInProgress)) {
  15787. // Something in this boundary's subtree already suspended. Switch to
  15788. // rendering the fallback children.
  15789. nextDidTimeout = true;
  15790. workInProgress.effectTag &= ~DidCapture;
  15791. } else {
  15792. // Attempting the main content
  15793. if (current$$1 === null || current$$1.memoizedState !== null) {
  15794. // This is a new mount or this boundary is already showing a fallback state.
  15795. // Mark this subtree context as having at least one invisible parent that could
  15796. // handle the fallback state.
  15797. // Boundaries without fallbacks or should be avoided are not considered since
  15798. // they cannot handle preferred fallback states.
  15799. if (nextProps.fallback !== undefined && nextProps.unstable_avoidThisFallback !== true) {
  15800. suspenseContext = addSubtreeSuspenseContext(suspenseContext, InvisibleParentSuspenseContext);
  15801. }
  15802. }
  15803. }
  15804. suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
  15805. pushSuspenseContext(workInProgress, suspenseContext);
  15806. {
  15807. if ('maxDuration' in nextProps) {
  15808. if (!didWarnAboutMaxDuration) {
  15809. didWarnAboutMaxDuration = true;
  15810. warning$1(false, 'maxDuration has been removed from React. ' + 'Remove the maxDuration prop.');
  15811. }
  15812. }
  15813. } // This next part is a bit confusing. If the children timeout, we switch to
  15814. // showing the fallback children in place of the "primary" children.
  15815. // However, we don't want to delete the primary children because then their
  15816. // state will be lost (both the React state and the host state, e.g.
  15817. // uncontrolled form inputs). Instead we keep them mounted and hide them.
  15818. // Both the fallback children AND the primary children are rendered at the
  15819. // same time. Once the primary children are un-suspended, we can delete
  15820. // the fallback children — don't need to preserve their state.
  15821. //
  15822. // The two sets of children are siblings in the host environment, but
  15823. // semantically, for purposes of reconciliation, they are two separate sets.
  15824. // So we store them using two fragment fibers.
  15825. //
  15826. // However, we want to avoid allocating extra fibers for every placeholder.
  15827. // They're only necessary when the children time out, because that's the
  15828. // only time when both sets are mounted.
  15829. //
  15830. // So, the extra fragment fibers are only used if the children time out.
  15831. // Otherwise, we render the primary children directly. This requires some
  15832. // custom reconciliation logic to preserve the state of the primary
  15833. // children. It's essentially a very basic form of re-parenting.
  15834. if (current$$1 === null) {
  15835. // If we're currently hydrating, try to hydrate this boundary.
  15836. // But only if this has a fallback.
  15837. if (nextProps.fallback !== undefined) {
  15838. tryToClaimNextHydratableInstance(workInProgress); // This could've been a dehydrated suspense component.
  15839. if (enableSuspenseServerRenderer) {
  15840. var suspenseState = workInProgress.memoizedState;
  15841. if (suspenseState !== null) {
  15842. var dehydrated = suspenseState.dehydrated;
  15843. if (dehydrated !== null) {
  15844. return mountDehydratedSuspenseComponent(workInProgress, dehydrated, renderExpirationTime);
  15845. }
  15846. }
  15847. }
  15848. } // This is the initial mount. This branch is pretty simple because there's
  15849. // no previous state that needs to be preserved.
  15850. if (nextDidTimeout) {
  15851. // Mount separate fragments for primary and fallback children.
  15852. var nextFallbackChildren = nextProps.fallback;
  15853. var primaryChildFragment = createFiberFromFragment(null, mode, NoWork, null);
  15854. primaryChildFragment.return = workInProgress;
  15855. if ((workInProgress.mode & BlockingMode) === NoMode) {
  15856. // Outside of blocking mode, we commit the effects from the
  15857. // partially completed, timed-out tree, too.
  15858. var progressedState = workInProgress.memoizedState;
  15859. var progressedPrimaryChild = progressedState !== null ? workInProgress.child.child : workInProgress.child;
  15860. primaryChildFragment.child = progressedPrimaryChild;
  15861. var progressedChild = progressedPrimaryChild;
  15862. while (progressedChild !== null) {
  15863. progressedChild.return = primaryChildFragment;
  15864. progressedChild = progressedChild.sibling;
  15865. }
  15866. }
  15867. var fallbackChildFragment = createFiberFromFragment(nextFallbackChildren, mode, renderExpirationTime, null);
  15868. fallbackChildFragment.return = workInProgress;
  15869. primaryChildFragment.sibling = fallbackChildFragment; // Skip the primary children, and continue working on the
  15870. // fallback children.
  15871. workInProgress.memoizedState = SUSPENDED_MARKER;
  15872. workInProgress.child = primaryChildFragment;
  15873. return fallbackChildFragment;
  15874. } else {
  15875. // Mount the primary children without an intermediate fragment fiber.
  15876. var nextPrimaryChildren = nextProps.children;
  15877. workInProgress.memoizedState = null;
  15878. return workInProgress.child = mountChildFibers(workInProgress, null, nextPrimaryChildren, renderExpirationTime);
  15879. }
  15880. } else {
  15881. // This is an update. This branch is more complicated because we need to
  15882. // ensure the state of the primary children is preserved.
  15883. var prevState = current$$1.memoizedState;
  15884. if (prevState !== null) {
  15885. if (enableSuspenseServerRenderer) {
  15886. var _dehydrated = prevState.dehydrated;
  15887. if (_dehydrated !== null) {
  15888. if (!didSuspend) {
  15889. return updateDehydratedSuspenseComponent(current$$1, workInProgress, _dehydrated, prevState, renderExpirationTime);
  15890. } else if (workInProgress.memoizedState !== null) {
  15891. // Something suspended and we should still be in dehydrated mode.
  15892. // Leave the existing child in place.
  15893. workInProgress.child = current$$1.child; // The dehydrated completion pass expects this flag to be there
  15894. // but the normal suspense pass doesn't.
  15895. workInProgress.effectTag |= DidCapture;
  15896. return null;
  15897. } else {
  15898. // Suspended but we should no longer be in dehydrated mode.
  15899. // Therefore we now have to render the fallback. Wrap the children
  15900. // in a fragment fiber to keep them separate from the fallback
  15901. // children.
  15902. var _nextFallbackChildren = nextProps.fallback;
  15903. var _primaryChildFragment = createFiberFromFragment( // It shouldn't matter what the pending props are because we aren't
  15904. // going to render this fragment.
  15905. null, mode, NoWork, null);
  15906. _primaryChildFragment.return = workInProgress; // This is always null since we never want the previous child
  15907. // that we're not going to hydrate.
  15908. _primaryChildFragment.child = null;
  15909. if ((workInProgress.mode & BlockingMode) === NoMode) {
  15910. // Outside of blocking mode, we commit the effects from the
  15911. // partially completed, timed-out tree, too.
  15912. var _progressedChild = _primaryChildFragment.child = workInProgress.child;
  15913. while (_progressedChild !== null) {
  15914. _progressedChild.return = _primaryChildFragment;
  15915. _progressedChild = _progressedChild.sibling;
  15916. }
  15917. } else {
  15918. // We will have dropped the effect list which contains the deletion.
  15919. // We need to reconcile to delete the current child.
  15920. reconcileChildFibers(workInProgress, current$$1.child, null, renderExpirationTime);
  15921. } // Because primaryChildFragment is a new fiber that we're inserting as the
  15922. // parent of a new tree, we need to set its treeBaseDuration.
  15923. if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
  15924. // treeBaseDuration is the sum of all the child tree base durations.
  15925. var treeBaseDuration = 0;
  15926. var hiddenChild = _primaryChildFragment.child;
  15927. while (hiddenChild !== null) {
  15928. treeBaseDuration += hiddenChild.treeBaseDuration;
  15929. hiddenChild = hiddenChild.sibling;
  15930. }
  15931. _primaryChildFragment.treeBaseDuration = treeBaseDuration;
  15932. } // Create a fragment from the fallback children, too.
  15933. var _fallbackChildFragment = createFiberFromFragment(_nextFallbackChildren, mode, renderExpirationTime, null);
  15934. _fallbackChildFragment.return = workInProgress;
  15935. _primaryChildFragment.sibling = _fallbackChildFragment;
  15936. _fallbackChildFragment.effectTag |= Placement;
  15937. _primaryChildFragment.childExpirationTime = NoWork;
  15938. workInProgress.memoizedState = SUSPENDED_MARKER;
  15939. workInProgress.child = _primaryChildFragment; // Skip the primary children, and continue working on the
  15940. // fallback children.
  15941. return _fallbackChildFragment;
  15942. }
  15943. }
  15944. } // The current tree already timed out. That means each child set is
  15945. // wrapped in a fragment fiber.
  15946. var currentPrimaryChildFragment = current$$1.child;
  15947. var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
  15948. if (nextDidTimeout) {
  15949. // Still timed out. Reuse the current primary children by cloning
  15950. // its fragment. We're going to skip over these entirely.
  15951. var _nextFallbackChildren2 = nextProps.fallback;
  15952. var _primaryChildFragment2 = createWorkInProgress(currentPrimaryChildFragment, currentPrimaryChildFragment.pendingProps, NoWork);
  15953. _primaryChildFragment2.return = workInProgress;
  15954. if ((workInProgress.mode & BlockingMode) === NoMode) {
  15955. // Outside of blocking mode, we commit the effects from the
  15956. // partially completed, timed-out tree, too.
  15957. var _progressedState = workInProgress.memoizedState;
  15958. var _progressedPrimaryChild = _progressedState !== null ? workInProgress.child.child : workInProgress.child;
  15959. if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) {
  15960. _primaryChildFragment2.child = _progressedPrimaryChild;
  15961. var _progressedChild2 = _progressedPrimaryChild;
  15962. while (_progressedChild2 !== null) {
  15963. _progressedChild2.return = _primaryChildFragment2;
  15964. _progressedChild2 = _progressedChild2.sibling;
  15965. }
  15966. }
  15967. } // Because primaryChildFragment is a new fiber that we're inserting as the
  15968. // parent of a new tree, we need to set its treeBaseDuration.
  15969. if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
  15970. // treeBaseDuration is the sum of all the child tree base durations.
  15971. var _treeBaseDuration = 0;
  15972. var _hiddenChild = _primaryChildFragment2.child;
  15973. while (_hiddenChild !== null) {
  15974. _treeBaseDuration += _hiddenChild.treeBaseDuration;
  15975. _hiddenChild = _hiddenChild.sibling;
  15976. }
  15977. _primaryChildFragment2.treeBaseDuration = _treeBaseDuration;
  15978. } // Clone the fallback child fragment, too. These we'll continue
  15979. // working on.
  15980. var _fallbackChildFragment2 = createWorkInProgress(currentFallbackChildFragment, _nextFallbackChildren2, currentFallbackChildFragment.expirationTime);
  15981. _fallbackChildFragment2.return = workInProgress;
  15982. _primaryChildFragment2.sibling = _fallbackChildFragment2;
  15983. _primaryChildFragment2.childExpirationTime = NoWork; // Skip the primary children, and continue working on the
  15984. // fallback children.
  15985. workInProgress.memoizedState = SUSPENDED_MARKER;
  15986. workInProgress.child = _primaryChildFragment2;
  15987. return _fallbackChildFragment2;
  15988. } else {
  15989. // No longer suspended. Switch back to showing the primary children,
  15990. // and remove the intermediate fragment fiber.
  15991. var _nextPrimaryChildren = nextProps.children;
  15992. var currentPrimaryChild = currentPrimaryChildFragment.child;
  15993. var primaryChild = reconcileChildFibers(workInProgress, currentPrimaryChild, _nextPrimaryChildren, renderExpirationTime); // If this render doesn't suspend, we need to delete the fallback
  15994. // children. Wait until the complete phase, after we've confirmed the
  15995. // fallback is no longer needed.
  15996. // TODO: Would it be better to store the fallback fragment on
  15997. // the stateNode?
  15998. // Continue rendering the children, like we normally do.
  15999. workInProgress.memoizedState = null;
  16000. return workInProgress.child = primaryChild;
  16001. }
  16002. } else {
  16003. // The current tree has not already timed out. That means the primary
  16004. // children are not wrapped in a fragment fiber.
  16005. var _currentPrimaryChild = current$$1.child;
  16006. if (nextDidTimeout) {
  16007. // Timed out. Wrap the children in a fragment fiber to keep them
  16008. // separate from the fallback children.
  16009. var _nextFallbackChildren3 = nextProps.fallback;
  16010. var _primaryChildFragment3 = createFiberFromFragment( // It shouldn't matter what the pending props are because we aren't
  16011. // going to render this fragment.
  16012. null, mode, NoWork, null);
  16013. _primaryChildFragment3.return = workInProgress;
  16014. _primaryChildFragment3.child = _currentPrimaryChild;
  16015. if (_currentPrimaryChild !== null) {
  16016. _currentPrimaryChild.return = _primaryChildFragment3;
  16017. } // Even though we're creating a new fiber, there are no new children,
  16018. // because we're reusing an already mounted tree. So we don't need to
  16019. // schedule a placement.
  16020. // primaryChildFragment.effectTag |= Placement;
  16021. if ((workInProgress.mode & BlockingMode) === NoMode) {
  16022. // Outside of blocking mode, we commit the effects from the
  16023. // partially completed, timed-out tree, too.
  16024. var _progressedState2 = workInProgress.memoizedState;
  16025. var _progressedPrimaryChild2 = _progressedState2 !== null ? workInProgress.child.child : workInProgress.child;
  16026. _primaryChildFragment3.child = _progressedPrimaryChild2;
  16027. var _progressedChild3 = _progressedPrimaryChild2;
  16028. while (_progressedChild3 !== null) {
  16029. _progressedChild3.return = _primaryChildFragment3;
  16030. _progressedChild3 = _progressedChild3.sibling;
  16031. }
  16032. } // Because primaryChildFragment is a new fiber that we're inserting as the
  16033. // parent of a new tree, we need to set its treeBaseDuration.
  16034. if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
  16035. // treeBaseDuration is the sum of all the child tree base durations.
  16036. var _treeBaseDuration2 = 0;
  16037. var _hiddenChild2 = _primaryChildFragment3.child;
  16038. while (_hiddenChild2 !== null) {
  16039. _treeBaseDuration2 += _hiddenChild2.treeBaseDuration;
  16040. _hiddenChild2 = _hiddenChild2.sibling;
  16041. }
  16042. _primaryChildFragment3.treeBaseDuration = _treeBaseDuration2;
  16043. } // Create a fragment from the fallback children, too.
  16044. var _fallbackChildFragment3 = createFiberFromFragment(_nextFallbackChildren3, mode, renderExpirationTime, null);
  16045. _fallbackChildFragment3.return = workInProgress;
  16046. _primaryChildFragment3.sibling = _fallbackChildFragment3;
  16047. _fallbackChildFragment3.effectTag |= Placement;
  16048. _primaryChildFragment3.childExpirationTime = NoWork; // Skip the primary children, and continue working on the
  16049. // fallback children.
  16050. workInProgress.memoizedState = SUSPENDED_MARKER;
  16051. workInProgress.child = _primaryChildFragment3;
  16052. return _fallbackChildFragment3;
  16053. } else {
  16054. // Still haven't timed out. Continue rendering the children, like we
  16055. // normally do.
  16056. workInProgress.memoizedState = null;
  16057. var _nextPrimaryChildren2 = nextProps.children;
  16058. return workInProgress.child = reconcileChildFibers(workInProgress, _currentPrimaryChild, _nextPrimaryChildren2, renderExpirationTime);
  16059. }
  16060. }
  16061. }
  16062. }
  16063. function retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime) {
  16064. // We're now not suspended nor dehydrated.
  16065. workInProgress.memoizedState = null; // Retry with the full children.
  16066. var nextProps = workInProgress.pendingProps;
  16067. var nextChildren = nextProps.children; // This will ensure that the children get Placement effects and
  16068. // that the old child gets a Deletion effect.
  16069. // We could also call forceUnmountCurrentAndReconcile.
  16070. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  16071. return workInProgress.child;
  16072. }
  16073. function mountDehydratedSuspenseComponent(workInProgress, suspenseInstance, renderExpirationTime) {
  16074. // During the first pass, we'll bail out and not drill into the children.
  16075. // Instead, we'll leave the content in place and try to hydrate it later.
  16076. if ((workInProgress.mode & BlockingMode) === NoMode) {
  16077. {
  16078. warning$1(false, 'Cannot hydrate Suspense in legacy mode. Switch from ' + 'ReactDOM.hydrate(element, container) to ' + 'ReactDOM.createBlockingRoot(container, { hydrate: true })' + '.render(element) or remove the Suspense components from ' + 'the server rendered components.');
  16079. }
  16080. workInProgress.expirationTime = Sync;
  16081. } else if (isSuspenseInstanceFallback(suspenseInstance)) {
  16082. // This is a client-only boundary. Since we won't get any content from the server
  16083. // for this, we need to schedule that at a higher priority based on when it would
  16084. // have timed out. In theory we could render it in this pass but it would have the
  16085. // wrong priority associated with it and will prevent hydration of parent path.
  16086. // Instead, we'll leave work left on it to render it in a separate commit.
  16087. // TODO This time should be the time at which the server rendered response that is
  16088. // a parent to this boundary was displayed. However, since we currently don't have
  16089. // a protocol to transfer that time, we'll just estimate it by using the current
  16090. // time. This will mean that Suspense timeouts are slightly shifted to later than
  16091. // they should be.
  16092. var serverDisplayTime = requestCurrentTimeForUpdate(); // Schedule a normal pri update to render this content.
  16093. var newExpirationTime = computeAsyncExpiration(serverDisplayTime);
  16094. if (enableSchedulerTracing) {
  16095. markSpawnedWork(newExpirationTime);
  16096. }
  16097. workInProgress.expirationTime = newExpirationTime;
  16098. } else {
  16099. // We'll continue hydrating the rest at offscreen priority since we'll already
  16100. // be showing the right content coming from the server, it is no rush.
  16101. workInProgress.expirationTime = Never;
  16102. if (enableSchedulerTracing) {
  16103. markSpawnedWork(Never);
  16104. }
  16105. }
  16106. return null;
  16107. }
  16108. function updateDehydratedSuspenseComponent(current$$1, workInProgress, suspenseInstance, suspenseState, renderExpirationTime) {
  16109. // We should never be hydrating at this point because it is the first pass,
  16110. // but after we've already committed once.
  16111. warnIfHydrating();
  16112. if ((workInProgress.mode & BlockingMode) === NoMode) {
  16113. return retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime);
  16114. }
  16115. if (isSuspenseInstanceFallback(suspenseInstance)) {
  16116. // This boundary is in a permanent fallback state. In this case, we'll never
  16117. // get an update and we'll never be able to hydrate the final content. Let's just try the
  16118. // client side render instead.
  16119. return retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime);
  16120. } // We use childExpirationTime to indicate that a child might depend on context, so if
  16121. // any context has changed, we need to treat is as if the input might have changed.
  16122. var hasContextChanged$$1 = current$$1.childExpirationTime >= renderExpirationTime;
  16123. if (didReceiveUpdate || hasContextChanged$$1) {
  16124. // This boundary has changed since the first render. This means that we are now unable to
  16125. // hydrate it. We might still be able to hydrate it using an earlier expiration time, if
  16126. // we are rendering at lower expiration than sync.
  16127. if (renderExpirationTime < Sync) {
  16128. if (suspenseState.retryTime <= renderExpirationTime) {
  16129. // This render is even higher pri than we've seen before, let's try again
  16130. // at even higher pri.
  16131. var attemptHydrationAtExpirationTime = renderExpirationTime + 1;
  16132. suspenseState.retryTime = attemptHydrationAtExpirationTime;
  16133. scheduleWork(current$$1, attemptHydrationAtExpirationTime); // TODO: Early abort this render.
  16134. } else {// We have already tried to ping at a higher priority than we're rendering with
  16135. // so if we got here, we must have failed to hydrate at those levels. We must
  16136. // now give up. Instead, we're going to delete the whole subtree and instead inject
  16137. // a new real Suspense boundary to take its place, which may render content
  16138. // or fallback. This might suspend for a while and if it does we might still have
  16139. // an opportunity to hydrate before this pass commits.
  16140. }
  16141. } // If we have scheduled higher pri work above, this will probably just abort the render
  16142. // since we now have higher priority work, but in case it doesn't, we need to prepare to
  16143. // render something, if we time out. Even if that requires us to delete everything and
  16144. // skip hydration.
  16145. // Delay having to do this as long as the suspense timeout allows us.
  16146. renderDidSuspendDelayIfPossible();
  16147. return retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime);
  16148. } else if (isSuspenseInstancePending(suspenseInstance)) {
  16149. // This component is still pending more data from the server, so we can't hydrate its
  16150. // content. We treat it as if this component suspended itself. It might seem as if
  16151. // we could just try to render it client-side instead. However, this will perform a
  16152. // lot of unnecessary work and is unlikely to complete since it often will suspend
  16153. // on missing data anyway. Additionally, the server might be able to render more
  16154. // than we can on the client yet. In that case we'd end up with more fallback states
  16155. // on the client than if we just leave it alone. If the server times out or errors
  16156. // these should update this boundary to the permanent Fallback state instead.
  16157. // Mark it as having captured (i.e. suspended).
  16158. workInProgress.effectTag |= DidCapture; // Leave the child in place. I.e. the dehydrated fragment.
  16159. workInProgress.child = current$$1.child; // Register a callback to retry this boundary once the server has sent the result.
  16160. registerSuspenseInstanceRetry(suspenseInstance, retryDehydratedSuspenseBoundary.bind(null, current$$1));
  16161. return null;
  16162. } else {
  16163. // This is the first attempt.
  16164. reenterHydrationStateFromDehydratedSuspenseInstance(workInProgress, suspenseInstance);
  16165. var nextProps = workInProgress.pendingProps;
  16166. var nextChildren = nextProps.children;
  16167. var child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  16168. var node = child;
  16169. while (node) {
  16170. // Mark each child as hydrating. This is a fast path to know whether this
  16171. // tree is part of a hydrating tree. This is used to determine if a child
  16172. // node has fully mounted yet, and for scheduling event replaying.
  16173. // Conceptually this is similar to Placement in that a new subtree is
  16174. // inserted into the React tree here. It just happens to not need DOM
  16175. // mutations because it already exists.
  16176. node.effectTag |= Hydrating;
  16177. node = node.sibling;
  16178. }
  16179. workInProgress.child = child;
  16180. return workInProgress.child;
  16181. }
  16182. }
  16183. function scheduleWorkOnFiber(fiber, renderExpirationTime) {
  16184. if (fiber.expirationTime < renderExpirationTime) {
  16185. fiber.expirationTime = renderExpirationTime;
  16186. }
  16187. var alternate = fiber.alternate;
  16188. if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
  16189. alternate.expirationTime = renderExpirationTime;
  16190. }
  16191. scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
  16192. }
  16193. function propagateSuspenseContextChange(workInProgress, firstChild, renderExpirationTime) {
  16194. // Mark any Suspense boundaries with fallbacks as having work to do.
  16195. // If they were previously forced into fallbacks, they may now be able
  16196. // to unblock.
  16197. var node = firstChild;
  16198. while (node !== null) {
  16199. if (node.tag === SuspenseComponent) {
  16200. var state = node.memoizedState;
  16201. if (state !== null) {
  16202. scheduleWorkOnFiber(node, renderExpirationTime);
  16203. }
  16204. } else if (node.tag === SuspenseListComponent) {
  16205. // If the tail is hidden there might not be an Suspense boundaries
  16206. // to schedule work on. In this case we have to schedule it on the
  16207. // list itself.
  16208. // We don't have to traverse to the children of the list since
  16209. // the list will propagate the change when it rerenders.
  16210. scheduleWorkOnFiber(node, renderExpirationTime);
  16211. } else if (node.child !== null) {
  16212. node.child.return = node;
  16213. node = node.child;
  16214. continue;
  16215. }
  16216. if (node === workInProgress) {
  16217. return;
  16218. }
  16219. while (node.sibling === null) {
  16220. if (node.return === null || node.return === workInProgress) {
  16221. return;
  16222. }
  16223. node = node.return;
  16224. }
  16225. node.sibling.return = node.return;
  16226. node = node.sibling;
  16227. }
  16228. }
  16229. function findLastContentRow(firstChild) {
  16230. // This is going to find the last row among these children that is already
  16231. // showing content on the screen, as opposed to being in fallback state or
  16232. // new. If a row has multiple Suspense boundaries, any of them being in the
  16233. // fallback state, counts as the whole row being in a fallback state.
  16234. // Note that the "rows" will be workInProgress, but any nested children
  16235. // will still be current since we haven't rendered them yet. The mounted
  16236. // order may not be the same as the new order. We use the new order.
  16237. var row = firstChild;
  16238. var lastContentRow = null;
  16239. while (row !== null) {
  16240. var currentRow = row.alternate; // New rows can't be content rows.
  16241. if (currentRow !== null && findFirstSuspended(currentRow) === null) {
  16242. lastContentRow = row;
  16243. }
  16244. row = row.sibling;
  16245. }
  16246. return lastContentRow;
  16247. }
  16248. function validateRevealOrder(revealOrder) {
  16249. {
  16250. if (revealOrder !== undefined && revealOrder !== 'forwards' && revealOrder !== 'backwards' && revealOrder !== 'together' && !didWarnAboutRevealOrder[revealOrder]) {
  16251. didWarnAboutRevealOrder[revealOrder] = true;
  16252. if (typeof revealOrder === 'string') {
  16253. switch (revealOrder.toLowerCase()) {
  16254. case 'together':
  16255. case 'forwards':
  16256. case 'backwards':
  16257. {
  16258. warning$1(false, '"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase());
  16259. break;
  16260. }
  16261. case 'forward':
  16262. case 'backward':
  16263. {
  16264. warning$1(false, '"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'React uses the -s suffix in the spelling. Use "%ss" instead.', revealOrder, revealOrder.toLowerCase());
  16265. break;
  16266. }
  16267. default:
  16268. warning$1(false, '"%s" is not a supported revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
  16269. break;
  16270. }
  16271. } else {
  16272. warning$1(false, '%s is not a supported value for revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
  16273. }
  16274. }
  16275. }
  16276. }
  16277. function validateTailOptions(tailMode, revealOrder) {
  16278. {
  16279. if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) {
  16280. if (tailMode !== 'collapsed' && tailMode !== 'hidden') {
  16281. didWarnAboutTailOptions[tailMode] = true;
  16282. warning$1(false, '"%s" is not a supported value for tail on <SuspenseList />. ' + 'Did you mean "collapsed" or "hidden"?', tailMode);
  16283. } else if (revealOrder !== 'forwards' && revealOrder !== 'backwards') {
  16284. didWarnAboutTailOptions[tailMode] = true;
  16285. warning$1(false, '<SuspenseList tail="%s" /> is only valid if revealOrder is ' + '"forwards" or "backwards". ' + 'Did you mean to specify revealOrder="forwards"?', tailMode);
  16286. }
  16287. }
  16288. }
  16289. }
  16290. function validateSuspenseListNestedChild(childSlot, index) {
  16291. {
  16292. var isArray = Array.isArray(childSlot);
  16293. var isIterable = !isArray && typeof getIteratorFn(childSlot) === 'function';
  16294. if (isArray || isIterable) {
  16295. var type = isArray ? 'array' : 'iterable';
  16296. warning$1(false, 'A nested %s was passed to row #%s in <SuspenseList />. Wrap it in ' + 'an additional SuspenseList to configure its revealOrder: ' + '<SuspenseList revealOrder=...> ... ' + '<SuspenseList revealOrder=...>{%s}</SuspenseList> ... ' + '</SuspenseList>', type, index, type);
  16297. return false;
  16298. }
  16299. }
  16300. return true;
  16301. }
  16302. function validateSuspenseListChildren(children, revealOrder) {
  16303. {
  16304. if ((revealOrder === 'forwards' || revealOrder === 'backwards') && children !== undefined && children !== null && children !== false) {
  16305. if (Array.isArray(children)) {
  16306. for (var i = 0; i < children.length; i++) {
  16307. if (!validateSuspenseListNestedChild(children[i], i)) {
  16308. return;
  16309. }
  16310. }
  16311. } else {
  16312. var iteratorFn = getIteratorFn(children);
  16313. if (typeof iteratorFn === 'function') {
  16314. var childrenIterator = iteratorFn.call(children);
  16315. if (childrenIterator) {
  16316. var step = childrenIterator.next();
  16317. var _i = 0;
  16318. for (; !step.done; step = childrenIterator.next()) {
  16319. if (!validateSuspenseListNestedChild(step.value, _i)) {
  16320. return;
  16321. }
  16322. _i++;
  16323. }
  16324. }
  16325. } else {
  16326. warning$1(false, 'A single row was passed to a <SuspenseList revealOrder="%s" />. ' + 'This is not useful since it needs multiple rows. ' + 'Did you mean to pass multiple children or an array?', revealOrder);
  16327. }
  16328. }
  16329. }
  16330. }
  16331. }
  16332. function initSuspenseListRenderState(workInProgress, isBackwards, tail, lastContentRow, tailMode, lastEffectBeforeRendering) {
  16333. var renderState = workInProgress.memoizedState;
  16334. if (renderState === null) {
  16335. workInProgress.memoizedState = {
  16336. isBackwards: isBackwards,
  16337. rendering: null,
  16338. last: lastContentRow,
  16339. tail: tail,
  16340. tailExpiration: 0,
  16341. tailMode: tailMode,
  16342. lastEffect: lastEffectBeforeRendering
  16343. };
  16344. } else {
  16345. // We can reuse the existing object from previous renders.
  16346. renderState.isBackwards = isBackwards;
  16347. renderState.rendering = null;
  16348. renderState.last = lastContentRow;
  16349. renderState.tail = tail;
  16350. renderState.tailExpiration = 0;
  16351. renderState.tailMode = tailMode;
  16352. renderState.lastEffect = lastEffectBeforeRendering;
  16353. }
  16354. } // This can end up rendering this component multiple passes.
  16355. // The first pass splits the children fibers into two sets. A head and tail.
  16356. // We first render the head. If anything is in fallback state, we do another
  16357. // pass through beginWork to rerender all children (including the tail) with
  16358. // the force suspend context. If the first render didn't have anything in
  16359. // in fallback state. Then we render each row in the tail one-by-one.
  16360. // That happens in the completeWork phase without going back to beginWork.
  16361. function updateSuspenseListComponent(current$$1, workInProgress, renderExpirationTime) {
  16362. var nextProps = workInProgress.pendingProps;
  16363. var revealOrder = nextProps.revealOrder;
  16364. var tailMode = nextProps.tail;
  16365. var newChildren = nextProps.children;
  16366. validateRevealOrder(revealOrder);
  16367. validateTailOptions(tailMode, revealOrder);
  16368. validateSuspenseListChildren(newChildren, revealOrder);
  16369. reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
  16370. var suspenseContext = suspenseStackCursor.current;
  16371. var shouldForceFallback = hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
  16372. if (shouldForceFallback) {
  16373. suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
  16374. workInProgress.effectTag |= DidCapture;
  16375. } else {
  16376. var didSuspendBefore = current$$1 !== null && (current$$1.effectTag & DidCapture) !== NoEffect;
  16377. if (didSuspendBefore) {
  16378. // If we previously forced a fallback, we need to schedule work
  16379. // on any nested boundaries to let them know to try to render
  16380. // again. This is the same as context updating.
  16381. propagateSuspenseContextChange(workInProgress, workInProgress.child, renderExpirationTime);
  16382. }
  16383. suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
  16384. }
  16385. pushSuspenseContext(workInProgress, suspenseContext);
  16386. if ((workInProgress.mode & BlockingMode) === NoMode) {
  16387. // Outside of blocking mode, SuspenseList doesn't work so we just
  16388. // use make it a noop by treating it as the default revealOrder.
  16389. workInProgress.memoizedState = null;
  16390. } else {
  16391. switch (revealOrder) {
  16392. case 'forwards':
  16393. {
  16394. var lastContentRow = findLastContentRow(workInProgress.child);
  16395. var tail;
  16396. if (lastContentRow === null) {
  16397. // The whole list is part of the tail.
  16398. // TODO: We could fast path by just rendering the tail now.
  16399. tail = workInProgress.child;
  16400. workInProgress.child = null;
  16401. } else {
  16402. // Disconnect the tail rows after the content row.
  16403. // We're going to render them separately later.
  16404. tail = lastContentRow.sibling;
  16405. lastContentRow.sibling = null;
  16406. }
  16407. initSuspenseListRenderState(workInProgress, false, // isBackwards
  16408. tail, lastContentRow, tailMode, workInProgress.lastEffect);
  16409. break;
  16410. }
  16411. case 'backwards':
  16412. {
  16413. // We're going to find the first row that has existing content.
  16414. // At the same time we're going to reverse the list of everything
  16415. // we pass in the meantime. That's going to be our tail in reverse
  16416. // order.
  16417. var _tail = null;
  16418. var row = workInProgress.child;
  16419. workInProgress.child = null;
  16420. while (row !== null) {
  16421. var currentRow = row.alternate; // New rows can't be content rows.
  16422. if (currentRow !== null && findFirstSuspended(currentRow) === null) {
  16423. // This is the beginning of the main content.
  16424. workInProgress.child = row;
  16425. break;
  16426. }
  16427. var nextRow = row.sibling;
  16428. row.sibling = _tail;
  16429. _tail = row;
  16430. row = nextRow;
  16431. } // TODO: If workInProgress.child is null, we can continue on the tail immediately.
  16432. initSuspenseListRenderState(workInProgress, true, // isBackwards
  16433. _tail, null, // last
  16434. tailMode, workInProgress.lastEffect);
  16435. break;
  16436. }
  16437. case 'together':
  16438. {
  16439. initSuspenseListRenderState(workInProgress, false, // isBackwards
  16440. null, // tail
  16441. null, // last
  16442. undefined, workInProgress.lastEffect);
  16443. break;
  16444. }
  16445. default:
  16446. {
  16447. // The default reveal order is the same as not having
  16448. // a boundary.
  16449. workInProgress.memoizedState = null;
  16450. }
  16451. }
  16452. }
  16453. return workInProgress.child;
  16454. }
  16455. function updatePortalComponent(current$$1, workInProgress, renderExpirationTime) {
  16456. pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
  16457. var nextChildren = workInProgress.pendingProps;
  16458. if (current$$1 === null) {
  16459. // Portals are special because we don't append the children during mount
  16460. // but at commit. Therefore we need to track insertions which the normal
  16461. // flow doesn't do during mount. This doesn't happen at the root because
  16462. // the root always starts with a "current" with a null child.
  16463. // TODO: Consider unifying this with how the root works.
  16464. workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  16465. } else {
  16466. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  16467. }
  16468. return workInProgress.child;
  16469. }
  16470. function updateContextProvider(current$$1, workInProgress, renderExpirationTime) {
  16471. var providerType = workInProgress.type;
  16472. var context = providerType._context;
  16473. var newProps = workInProgress.pendingProps;
  16474. var oldProps = workInProgress.memoizedProps;
  16475. var newValue = newProps.value;
  16476. {
  16477. var providerPropTypes = workInProgress.type.propTypes;
  16478. if (providerPropTypes) {
  16479. checkPropTypes(providerPropTypes, newProps, 'prop', 'Context.Provider', getCurrentFiberStackInDev);
  16480. }
  16481. }
  16482. pushProvider(workInProgress, newValue);
  16483. if (oldProps !== null) {
  16484. var oldValue = oldProps.value;
  16485. var changedBits = calculateChangedBits(context, newValue, oldValue);
  16486. if (changedBits === 0) {
  16487. // No change. Bailout early if children are the same.
  16488. if (oldProps.children === newProps.children && !hasContextChanged()) {
  16489. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  16490. }
  16491. } else {
  16492. // The context value changed. Search for matching consumers and schedule
  16493. // them to update.
  16494. propagateContextChange(workInProgress, context, changedBits, renderExpirationTime);
  16495. }
  16496. }
  16497. var newChildren = newProps.children;
  16498. reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
  16499. return workInProgress.child;
  16500. }
  16501. var hasWarnedAboutUsingContextAsConsumer = false;
  16502. function updateContextConsumer(current$$1, workInProgress, renderExpirationTime) {
  16503. var context = workInProgress.type; // The logic below for Context differs depending on PROD or DEV mode. In
  16504. // DEV mode, we create a separate object for Context.Consumer that acts
  16505. // like a proxy to Context. This proxy object adds unnecessary code in PROD
  16506. // so we use the old behaviour (Context.Consumer references Context) to
  16507. // reduce size and overhead. The separate object references context via
  16508. // a property called "_context", which also gives us the ability to check
  16509. // in DEV mode if this property exists or not and warn if it does not.
  16510. {
  16511. if (context._context === undefined) {
  16512. // This may be because it's a Context (rather than a Consumer).
  16513. // Or it may be because it's older React where they're the same thing.
  16514. // We only want to warn if we're sure it's a new React.
  16515. if (context !== context.Consumer) {
  16516. if (!hasWarnedAboutUsingContextAsConsumer) {
  16517. hasWarnedAboutUsingContextAsConsumer = true;
  16518. warning$1(false, 'Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
  16519. }
  16520. }
  16521. } else {
  16522. context = context._context;
  16523. }
  16524. }
  16525. var newProps = workInProgress.pendingProps;
  16526. var render = newProps.children;
  16527. {
  16528. !(typeof render === 'function') ? warningWithoutStack$1(false, 'A context consumer was rendered with multiple children, or a child ' + "that isn't a function. A context consumer expects a single child " + 'that is a function. If you did pass a function, make sure there ' + 'is no trailing or leading whitespace around it.') : void 0;
  16529. }
  16530. prepareToReadContext(workInProgress, renderExpirationTime);
  16531. var newValue = readContext(context, newProps.unstable_observedBits);
  16532. var newChildren;
  16533. {
  16534. ReactCurrentOwner$3.current = workInProgress;
  16535. setCurrentPhase('render');
  16536. newChildren = render(newValue);
  16537. setCurrentPhase(null);
  16538. } // React DevTools reads this flag.
  16539. workInProgress.effectTag |= PerformedWork;
  16540. reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
  16541. return workInProgress.child;
  16542. }
  16543. function updateFundamentalComponent$1(current$$1, workInProgress, renderExpirationTime) {
  16544. var fundamentalImpl = workInProgress.type.impl;
  16545. if (fundamentalImpl.reconcileChildren === false) {
  16546. return null;
  16547. }
  16548. var nextProps = workInProgress.pendingProps;
  16549. var nextChildren = nextProps.children;
  16550. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  16551. return workInProgress.child;
  16552. }
  16553. function updateScopeComponent(current$$1, workInProgress, renderExpirationTime) {
  16554. var nextProps = workInProgress.pendingProps;
  16555. var nextChildren = nextProps.children;
  16556. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  16557. return workInProgress.child;
  16558. }
  16559. function markWorkInProgressReceivedUpdate() {
  16560. didReceiveUpdate = true;
  16561. }
  16562. function bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime) {
  16563. cancelWorkTimer(workInProgress);
  16564. if (current$$1 !== null) {
  16565. // Reuse previous dependencies
  16566. workInProgress.dependencies = current$$1.dependencies;
  16567. }
  16568. if (enableProfilerTimer) {
  16569. // Don't update "base" render times for bailouts.
  16570. stopProfilerTimerIfRunning(workInProgress);
  16571. }
  16572. var updateExpirationTime = workInProgress.expirationTime;
  16573. if (updateExpirationTime !== NoWork) {
  16574. markUnprocessedUpdateTime(updateExpirationTime);
  16575. } // Check if the children have any pending work.
  16576. var childExpirationTime = workInProgress.childExpirationTime;
  16577. if (childExpirationTime < renderExpirationTime) {
  16578. // The children don't have any work either. We can skip them.
  16579. // TODO: Once we add back resuming, we should check if the children are
  16580. // a work-in-progress set. If so, we need to transfer their effects.
  16581. return null;
  16582. } else {
  16583. // This fiber doesn't have work, but its subtree does. Clone the child
  16584. // fibers and continue.
  16585. cloneChildFibers(current$$1, workInProgress);
  16586. return workInProgress.child;
  16587. }
  16588. }
  16589. function remountFiber(current$$1, oldWorkInProgress, newWorkInProgress) {
  16590. {
  16591. var returnFiber = oldWorkInProgress.return;
  16592. if (returnFiber === null) {
  16593. throw new Error('Cannot swap the root fiber.');
  16594. } // Disconnect from the old current.
  16595. // It will get deleted.
  16596. current$$1.alternate = null;
  16597. oldWorkInProgress.alternate = null; // Connect to the new tree.
  16598. newWorkInProgress.index = oldWorkInProgress.index;
  16599. newWorkInProgress.sibling = oldWorkInProgress.sibling;
  16600. newWorkInProgress.return = oldWorkInProgress.return;
  16601. newWorkInProgress.ref = oldWorkInProgress.ref; // Replace the child/sibling pointers above it.
  16602. if (oldWorkInProgress === returnFiber.child) {
  16603. returnFiber.child = newWorkInProgress;
  16604. } else {
  16605. var prevSibling = returnFiber.child;
  16606. if (prevSibling === null) {
  16607. throw new Error('Expected parent to have a child.');
  16608. }
  16609. while (prevSibling.sibling !== oldWorkInProgress) {
  16610. prevSibling = prevSibling.sibling;
  16611. if (prevSibling === null) {
  16612. throw new Error('Expected to find the previous sibling.');
  16613. }
  16614. }
  16615. prevSibling.sibling = newWorkInProgress;
  16616. } // Delete the old fiber and place the new one.
  16617. // Since the old fiber is disconnected, we have to schedule it manually.
  16618. var last = returnFiber.lastEffect;
  16619. if (last !== null) {
  16620. last.nextEffect = current$$1;
  16621. returnFiber.lastEffect = current$$1;
  16622. } else {
  16623. returnFiber.firstEffect = returnFiber.lastEffect = current$$1;
  16624. }
  16625. current$$1.nextEffect = null;
  16626. current$$1.effectTag = Deletion;
  16627. newWorkInProgress.effectTag |= Placement; // Restart work from the new fiber.
  16628. return newWorkInProgress;
  16629. }
  16630. }
  16631. function beginWork$1(current$$1, workInProgress, renderExpirationTime) {
  16632. var updateExpirationTime = workInProgress.expirationTime;
  16633. {
  16634. if (workInProgress._debugNeedsRemount && current$$1 !== null) {
  16635. // This will restart the begin phase with a new fiber.
  16636. return remountFiber(current$$1, workInProgress, createFiberFromTypeAndProps(workInProgress.type, workInProgress.key, workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, workInProgress.expirationTime));
  16637. }
  16638. }
  16639. if (current$$1 !== null) {
  16640. var oldProps = current$$1.memoizedProps;
  16641. var newProps = workInProgress.pendingProps;
  16642. if (oldProps !== newProps || hasContextChanged() || ( // Force a re-render if the implementation changed due to hot reload:
  16643. workInProgress.type !== current$$1.type)) {
  16644. // If props or context changed, mark the fiber as having performed work.
  16645. // This may be unset if the props are determined to be equal later (memo).
  16646. didReceiveUpdate = true;
  16647. } else if (updateExpirationTime < renderExpirationTime) {
  16648. didReceiveUpdate = false; // This fiber does not have any pending work. Bailout without entering
  16649. // the begin phase. There's still some bookkeeping we that needs to be done
  16650. // in this optimized path, mostly pushing stuff onto the stack.
  16651. switch (workInProgress.tag) {
  16652. case HostRoot:
  16653. pushHostRootContext(workInProgress);
  16654. resetHydrationState();
  16655. break;
  16656. case HostComponent:
  16657. pushHostContext(workInProgress);
  16658. if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(workInProgress.type, newProps)) {
  16659. if (enableSchedulerTracing) {
  16660. markSpawnedWork(Never);
  16661. } // Schedule this fiber to re-render at offscreen priority. Then bailout.
  16662. workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
  16663. return null;
  16664. }
  16665. break;
  16666. case ClassComponent:
  16667. {
  16668. var Component = workInProgress.type;
  16669. if (isContextProvider(Component)) {
  16670. pushContextProvider(workInProgress);
  16671. }
  16672. break;
  16673. }
  16674. case HostPortal:
  16675. pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
  16676. break;
  16677. case ContextProvider:
  16678. {
  16679. var newValue = workInProgress.memoizedProps.value;
  16680. pushProvider(workInProgress, newValue);
  16681. break;
  16682. }
  16683. case Profiler:
  16684. if (enableProfilerTimer) {
  16685. // Profiler should only call onRender when one of its descendants actually rendered.
  16686. var hasChildWork = workInProgress.childExpirationTime >= renderExpirationTime;
  16687. if (hasChildWork) {
  16688. workInProgress.effectTag |= Update;
  16689. }
  16690. }
  16691. break;
  16692. case SuspenseComponent:
  16693. {
  16694. var state = workInProgress.memoizedState;
  16695. if (state !== null) {
  16696. if (enableSuspenseServerRenderer) {
  16697. if (state.dehydrated !== null) {
  16698. pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); // We know that this component will suspend again because if it has
  16699. // been unsuspended it has committed as a resolved Suspense component.
  16700. // If it needs to be retried, it should have work scheduled on it.
  16701. workInProgress.effectTag |= DidCapture;
  16702. break;
  16703. }
  16704. } // If this boundary is currently timed out, we need to decide
  16705. // whether to retry the primary children, or to skip over it and
  16706. // go straight to the fallback. Check the priority of the primary
  16707. // child fragment.
  16708. var primaryChildFragment = workInProgress.child;
  16709. var primaryChildExpirationTime = primaryChildFragment.childExpirationTime;
  16710. if (primaryChildExpirationTime !== NoWork && primaryChildExpirationTime >= renderExpirationTime) {
  16711. // The primary children have pending work. Use the normal path
  16712. // to attempt to render the primary children again.
  16713. return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
  16714. } else {
  16715. pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); // The primary children do not have pending work with sufficient
  16716. // priority. Bailout.
  16717. var child = bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  16718. if (child !== null) {
  16719. // The fallback children have pending work. Skip over the
  16720. // primary children and work on the fallback.
  16721. return child.sibling;
  16722. } else {
  16723. return null;
  16724. }
  16725. }
  16726. } else {
  16727. pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
  16728. }
  16729. break;
  16730. }
  16731. case SuspenseListComponent:
  16732. {
  16733. var didSuspendBefore = (current$$1.effectTag & DidCapture) !== NoEffect;
  16734. var _hasChildWork = workInProgress.childExpirationTime >= renderExpirationTime;
  16735. if (didSuspendBefore) {
  16736. if (_hasChildWork) {
  16737. // If something was in fallback state last time, and we have all the
  16738. // same children then we're still in progressive loading state.
  16739. // Something might get unblocked by state updates or retries in the
  16740. // tree which will affect the tail. So we need to use the normal
  16741. // path to compute the correct tail.
  16742. return updateSuspenseListComponent(current$$1, workInProgress, renderExpirationTime);
  16743. } // If none of the children had any work, that means that none of
  16744. // them got retried so they'll still be blocked in the same way
  16745. // as before. We can fast bail out.
  16746. workInProgress.effectTag |= DidCapture;
  16747. } // If nothing suspended before and we're rendering the same children,
  16748. // then the tail doesn't matter. Anything new that suspends will work
  16749. // in the "together" mode, so we can continue from the state we had.
  16750. var renderState = workInProgress.memoizedState;
  16751. if (renderState !== null) {
  16752. // Reset to the "together" mode in case we've started a different
  16753. // update in the past but didn't complete it.
  16754. renderState.rendering = null;
  16755. renderState.tail = null;
  16756. }
  16757. pushSuspenseContext(workInProgress, suspenseStackCursor.current);
  16758. if (_hasChildWork) {
  16759. break;
  16760. } else {
  16761. // If none of the children had any work, that means that none of
  16762. // them got retried so they'll still be blocked in the same way
  16763. // as before. We can fast bail out.
  16764. return null;
  16765. }
  16766. }
  16767. }
  16768. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  16769. } else {
  16770. // An update was scheduled on this fiber, but there are no new props
  16771. // nor legacy context. Set this to false. If an update queue or context
  16772. // consumer produces a changed value, it will set this to true. Otherwise,
  16773. // the component will assume the children have not changed and bail out.
  16774. didReceiveUpdate = false;
  16775. }
  16776. } else {
  16777. didReceiveUpdate = false;
  16778. } // Before entering the begin phase, clear the expiration time.
  16779. workInProgress.expirationTime = NoWork;
  16780. switch (workInProgress.tag) {
  16781. case IndeterminateComponent:
  16782. {
  16783. return mountIndeterminateComponent(current$$1, workInProgress, workInProgress.type, renderExpirationTime);
  16784. }
  16785. case LazyComponent:
  16786. {
  16787. var elementType = workInProgress.elementType;
  16788. return mountLazyComponent(current$$1, workInProgress, elementType, updateExpirationTime, renderExpirationTime);
  16789. }
  16790. case FunctionComponent:
  16791. {
  16792. var _Component = workInProgress.type;
  16793. var unresolvedProps = workInProgress.pendingProps;
  16794. var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps);
  16795. return updateFunctionComponent(current$$1, workInProgress, _Component, resolvedProps, renderExpirationTime);
  16796. }
  16797. case ClassComponent:
  16798. {
  16799. var _Component2 = workInProgress.type;
  16800. var _unresolvedProps = workInProgress.pendingProps;
  16801. var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps);
  16802. return updateClassComponent(current$$1, workInProgress, _Component2, _resolvedProps, renderExpirationTime);
  16803. }
  16804. case HostRoot:
  16805. return updateHostRoot(current$$1, workInProgress, renderExpirationTime);
  16806. case HostComponent:
  16807. return updateHostComponent(current$$1, workInProgress, renderExpirationTime);
  16808. case HostText:
  16809. return updateHostText(current$$1, workInProgress);
  16810. case SuspenseComponent:
  16811. return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
  16812. case HostPortal:
  16813. return updatePortalComponent(current$$1, workInProgress, renderExpirationTime);
  16814. case ForwardRef:
  16815. {
  16816. var type = workInProgress.type;
  16817. var _unresolvedProps2 = workInProgress.pendingProps;
  16818. var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
  16819. return updateForwardRef(current$$1, workInProgress, type, _resolvedProps2, renderExpirationTime);
  16820. }
  16821. case Fragment:
  16822. return updateFragment(current$$1, workInProgress, renderExpirationTime);
  16823. case Mode:
  16824. return updateMode(current$$1, workInProgress, renderExpirationTime);
  16825. case Profiler:
  16826. return updateProfiler(current$$1, workInProgress, renderExpirationTime);
  16827. case ContextProvider:
  16828. return updateContextProvider(current$$1, workInProgress, renderExpirationTime);
  16829. case ContextConsumer:
  16830. return updateContextConsumer(current$$1, workInProgress, renderExpirationTime);
  16831. case MemoComponent:
  16832. {
  16833. var _type2 = workInProgress.type;
  16834. var _unresolvedProps3 = workInProgress.pendingProps; // Resolve outer props first, then resolve inner props.
  16835. var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);
  16836. {
  16837. if (workInProgress.type !== workInProgress.elementType) {
  16838. var outerPropTypes = _type2.propTypes;
  16839. if (outerPropTypes) {
  16840. checkPropTypes(outerPropTypes, _resolvedProps3, // Resolved for outer only
  16841. 'prop', getComponentName(_type2), getCurrentFiberStackInDev);
  16842. }
  16843. }
  16844. }
  16845. _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);
  16846. return updateMemoComponent(current$$1, workInProgress, _type2, _resolvedProps3, updateExpirationTime, renderExpirationTime);
  16847. }
  16848. case SimpleMemoComponent:
  16849. {
  16850. return updateSimpleMemoComponent(current$$1, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime);
  16851. }
  16852. case IncompleteClassComponent:
  16853. {
  16854. var _Component3 = workInProgress.type;
  16855. var _unresolvedProps4 = workInProgress.pendingProps;
  16856. var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
  16857. return mountIncompleteClassComponent(current$$1, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);
  16858. }
  16859. case SuspenseListComponent:
  16860. {
  16861. return updateSuspenseListComponent(current$$1, workInProgress, renderExpirationTime);
  16862. }
  16863. case FundamentalComponent:
  16864. {
  16865. if (enableFundamentalAPI) {
  16866. return updateFundamentalComponent$1(current$$1, workInProgress, renderExpirationTime);
  16867. }
  16868. break;
  16869. }
  16870. case ScopeComponent:
  16871. {
  16872. if (enableScopeAPI) {
  16873. return updateScopeComponent(current$$1, workInProgress, renderExpirationTime);
  16874. }
  16875. break;
  16876. }
  16877. }
  16878. {
  16879. {
  16880. throw Error("Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue.");
  16881. }
  16882. }
  16883. }
  16884. function createFundamentalStateInstance(currentFiber, props, impl, state) {
  16885. return {
  16886. currentFiber: currentFiber,
  16887. impl: impl,
  16888. instance: null,
  16889. prevProps: null,
  16890. props: props,
  16891. state: state
  16892. };
  16893. }
  16894. function isFiberSuspenseAndTimedOut(fiber) {
  16895. return fiber.tag === SuspenseComponent && fiber.memoizedState !== null;
  16896. }
  16897. function getSuspenseFallbackChild(fiber) {
  16898. return fiber.child.sibling.child;
  16899. }
  16900. var emptyObject$1 = {};
  16901. function collectScopedNodes(node, fn, scopedNodes) {
  16902. if (enableScopeAPI) {
  16903. if (node.tag === HostComponent) {
  16904. var _type = node.type,
  16905. memoizedProps = node.memoizedProps,
  16906. stateNode = node.stateNode;
  16907. var _instance = getPublicInstance(stateNode);
  16908. if (_instance !== null && fn(_type, memoizedProps || emptyObject$1, _instance) === true) {
  16909. scopedNodes.push(_instance);
  16910. }
  16911. }
  16912. var child = node.child;
  16913. if (isFiberSuspenseAndTimedOut(node)) {
  16914. child = getSuspenseFallbackChild(node);
  16915. }
  16916. if (child !== null) {
  16917. collectScopedNodesFromChildren(child, fn, scopedNodes);
  16918. }
  16919. }
  16920. }
  16921. function collectFirstScopedNode(node, fn) {
  16922. if (enableScopeAPI) {
  16923. if (node.tag === HostComponent) {
  16924. var _type2 = node.type,
  16925. memoizedProps = node.memoizedProps,
  16926. stateNode = node.stateNode;
  16927. var _instance2 = getPublicInstance(stateNode);
  16928. if (_instance2 !== null && fn(_type2, memoizedProps, _instance2) === true) {
  16929. return _instance2;
  16930. }
  16931. }
  16932. var child = node.child;
  16933. if (isFiberSuspenseAndTimedOut(node)) {
  16934. child = getSuspenseFallbackChild(node);
  16935. }
  16936. if (child !== null) {
  16937. return collectFirstScopedNodeFromChildren(child, fn);
  16938. }
  16939. }
  16940. return null;
  16941. }
  16942. function collectScopedNodesFromChildren(startingChild, fn, scopedNodes) {
  16943. var child = startingChild;
  16944. while (child !== null) {
  16945. collectScopedNodes(child, fn, scopedNodes);
  16946. child = child.sibling;
  16947. }
  16948. }
  16949. function collectFirstScopedNodeFromChildren(startingChild, fn) {
  16950. var child = startingChild;
  16951. while (child !== null) {
  16952. var scopedNode = collectFirstScopedNode(child, fn);
  16953. if (scopedNode !== null) {
  16954. return scopedNode;
  16955. }
  16956. child = child.sibling;
  16957. }
  16958. return null;
  16959. }
  16960. function collectNearestScopeMethods(node, scope, childrenScopes) {
  16961. if (isValidScopeNode(node, scope)) {
  16962. childrenScopes.push(node.stateNode.methods);
  16963. } else {
  16964. var child = node.child;
  16965. if (isFiberSuspenseAndTimedOut(node)) {
  16966. child = getSuspenseFallbackChild(node);
  16967. }
  16968. if (child !== null) {
  16969. collectNearestChildScopeMethods(child, scope, childrenScopes);
  16970. }
  16971. }
  16972. }
  16973. function collectNearestChildScopeMethods(startingChild, scope, childrenScopes) {
  16974. var child = startingChild;
  16975. while (child !== null) {
  16976. collectNearestScopeMethods(child, scope, childrenScopes);
  16977. child = child.sibling;
  16978. }
  16979. }
  16980. function isValidScopeNode(node, scope) {
  16981. return node.tag === ScopeComponent && node.type === scope && node.stateNode !== null;
  16982. }
  16983. function createScopeMethods(scope, instance) {
  16984. return {
  16985. getChildren: function () {
  16986. var currentFiber = instance.fiber;
  16987. var child = currentFiber.child;
  16988. var childrenScopes = [];
  16989. if (child !== null) {
  16990. collectNearestChildScopeMethods(child, scope, childrenScopes);
  16991. }
  16992. return childrenScopes.length === 0 ? null : childrenScopes;
  16993. },
  16994. getChildrenFromRoot: function () {
  16995. var currentFiber = instance.fiber;
  16996. var node = currentFiber;
  16997. while (node !== null) {
  16998. var parent = node.return;
  16999. if (parent === null) {
  17000. break;
  17001. }
  17002. node = parent;
  17003. if (node.tag === ScopeComponent && node.type === scope) {
  17004. break;
  17005. }
  17006. }
  17007. var childrenScopes = [];
  17008. collectNearestChildScopeMethods(node.child, scope, childrenScopes);
  17009. return childrenScopes.length === 0 ? null : childrenScopes;
  17010. },
  17011. getParent: function () {
  17012. var node = instance.fiber.return;
  17013. while (node !== null) {
  17014. if (node.tag === ScopeComponent && node.type === scope) {
  17015. return node.stateNode.methods;
  17016. }
  17017. node = node.return;
  17018. }
  17019. return null;
  17020. },
  17021. getProps: function () {
  17022. var currentFiber = instance.fiber;
  17023. return currentFiber.memoizedProps;
  17024. },
  17025. queryAllNodes: function (fn) {
  17026. var currentFiber = instance.fiber;
  17027. var child = currentFiber.child;
  17028. var scopedNodes = [];
  17029. if (child !== null) {
  17030. collectScopedNodesFromChildren(child, fn, scopedNodes);
  17031. }
  17032. return scopedNodes.length === 0 ? null : scopedNodes;
  17033. },
  17034. queryFirstNode: function (fn) {
  17035. var currentFiber = instance.fiber;
  17036. var child = currentFiber.child;
  17037. if (child !== null) {
  17038. return collectFirstScopedNodeFromChildren(child, fn);
  17039. }
  17040. return null;
  17041. },
  17042. containsNode: function (node) {
  17043. var fiber = getInstanceFromNode$2(node);
  17044. while (fiber !== null) {
  17045. if (fiber.tag === ScopeComponent && fiber.type === scope && fiber.stateNode === instance) {
  17046. return true;
  17047. }
  17048. fiber = fiber.return;
  17049. }
  17050. return false;
  17051. }
  17052. };
  17053. }
  17054. function markUpdate(workInProgress) {
  17055. // Tag the fiber with an update effect. This turns a Placement into
  17056. // a PlacementAndUpdate.
  17057. workInProgress.effectTag |= Update;
  17058. }
  17059. function markRef$1(workInProgress) {
  17060. workInProgress.effectTag |= Ref;
  17061. }
  17062. var appendAllChildren;
  17063. var updateHostContainer;
  17064. var updateHostComponent$1;
  17065. var updateHostText$1;
  17066. if (supportsMutation) {
  17067. // Mutation mode
  17068. appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
  17069. // We only have the top Fiber that was created but we need recurse down its
  17070. // children to find all the terminal nodes.
  17071. var node = workInProgress.child;
  17072. while (node !== null) {
  17073. if (node.tag === HostComponent || node.tag === HostText) {
  17074. appendInitialChild(parent, node.stateNode);
  17075. } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
  17076. appendInitialChild(parent, node.stateNode.instance);
  17077. } else if (node.tag === HostPortal) {// If we have a portal child, then we don't want to traverse
  17078. // down its children. Instead, we'll get insertions from each child in
  17079. // the portal directly.
  17080. } else if (node.child !== null) {
  17081. node.child.return = node;
  17082. node = node.child;
  17083. continue;
  17084. }
  17085. if (node === workInProgress) {
  17086. return;
  17087. }
  17088. while (node.sibling === null) {
  17089. if (node.return === null || node.return === workInProgress) {
  17090. return;
  17091. }
  17092. node = node.return;
  17093. }
  17094. node.sibling.return = node.return;
  17095. node = node.sibling;
  17096. }
  17097. };
  17098. updateHostContainer = function (workInProgress) {// Noop
  17099. };
  17100. updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
  17101. // If we have an alternate, that means this is an update and we need to
  17102. // schedule a side-effect to do the updates.
  17103. var oldProps = current.memoizedProps;
  17104. if (oldProps === newProps) {
  17105. // In mutation mode, this is sufficient for a bailout because
  17106. // we won't touch this node even if children changed.
  17107. return;
  17108. } // If we get updated because one of our children updated, we don't
  17109. // have newProps so we'll have to reuse them.
  17110. // TODO: Split the update API as separate for the props vs. children.
  17111. // Even better would be if children weren't special cased at all tho.
  17112. var instance = workInProgress.stateNode;
  17113. var currentHostContext = getHostContext(); // TODO: Experiencing an error where oldProps is null. Suggests a host
  17114. // component is hitting the resume path. Figure out why. Possibly
  17115. // related to `hidden`.
  17116. var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext); // TODO: Type this specific to this type of component.
  17117. workInProgress.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there
  17118. // is a new ref we mark this as an update. All the work is done in commitWork.
  17119. if (updatePayload) {
  17120. markUpdate(workInProgress);
  17121. }
  17122. };
  17123. updateHostText$1 = function (current, workInProgress, oldText, newText) {
  17124. // If the text differs, mark it as an update. All the work in done in commitWork.
  17125. if (oldText !== newText) {
  17126. markUpdate(workInProgress);
  17127. }
  17128. };
  17129. } else if (supportsPersistence) {
  17130. // Persistent host tree mode
  17131. appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
  17132. // We only have the top Fiber that was created but we need recurse down its
  17133. // children to find all the terminal nodes.
  17134. var node = workInProgress.child;
  17135. while (node !== null) {
  17136. // eslint-disable-next-line no-labels
  17137. branches: if (node.tag === HostComponent) {
  17138. var instance = node.stateNode;
  17139. if (needsVisibilityToggle && isHidden) {
  17140. // This child is inside a timed out tree. Hide it.
  17141. var props = node.memoizedProps;
  17142. var type = node.type;
  17143. instance = cloneHiddenInstance(instance, type, props, node);
  17144. }
  17145. appendInitialChild(parent, instance);
  17146. } else if (node.tag === HostText) {
  17147. var _instance = node.stateNode;
  17148. if (needsVisibilityToggle && isHidden) {
  17149. // This child is inside a timed out tree. Hide it.
  17150. var text = node.memoizedProps;
  17151. _instance = cloneHiddenTextInstance(_instance, text, node);
  17152. }
  17153. appendInitialChild(parent, _instance);
  17154. } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
  17155. var _instance2 = node.stateNode.instance;
  17156. if (needsVisibilityToggle && isHidden) {
  17157. // This child is inside a timed out tree. Hide it.
  17158. var _props = node.memoizedProps;
  17159. var _type = node.type;
  17160. _instance2 = cloneHiddenInstance(_instance2, _type, _props, node);
  17161. }
  17162. appendInitialChild(parent, _instance2);
  17163. } else if (node.tag === HostPortal) {// If we have a portal child, then we don't want to traverse
  17164. // down its children. Instead, we'll get insertions from each child in
  17165. // the portal directly.
  17166. } else if (node.tag === SuspenseComponent) {
  17167. if ((node.effectTag & Update) !== NoEffect) {
  17168. // Need to toggle the visibility of the primary children.
  17169. var newIsHidden = node.memoizedState !== null;
  17170. if (newIsHidden) {
  17171. var primaryChildParent = node.child;
  17172. if (primaryChildParent !== null) {
  17173. if (primaryChildParent.child !== null) {
  17174. primaryChildParent.child.return = primaryChildParent;
  17175. appendAllChildren(parent, primaryChildParent, true, newIsHidden);
  17176. }
  17177. var fallbackChildParent = primaryChildParent.sibling;
  17178. if (fallbackChildParent !== null) {
  17179. fallbackChildParent.return = node;
  17180. node = fallbackChildParent;
  17181. continue;
  17182. }
  17183. }
  17184. }
  17185. }
  17186. if (node.child !== null) {
  17187. // Continue traversing like normal
  17188. node.child.return = node;
  17189. node = node.child;
  17190. continue;
  17191. }
  17192. } else if (node.child !== null) {
  17193. node.child.return = node;
  17194. node = node.child;
  17195. continue;
  17196. } // $FlowFixMe This is correct but Flow is confused by the labeled break.
  17197. node = node;
  17198. if (node === workInProgress) {
  17199. return;
  17200. }
  17201. while (node.sibling === null) {
  17202. if (node.return === null || node.return === workInProgress) {
  17203. return;
  17204. }
  17205. node = node.return;
  17206. }
  17207. node.sibling.return = node.return;
  17208. node = node.sibling;
  17209. }
  17210. }; // An unfortunate fork of appendAllChildren because we have two different parent types.
  17211. var appendAllChildrenToContainer = function (containerChildSet, workInProgress, needsVisibilityToggle, isHidden) {
  17212. // We only have the top Fiber that was created but we need recurse down its
  17213. // children to find all the terminal nodes.
  17214. var node = workInProgress.child;
  17215. while (node !== null) {
  17216. // eslint-disable-next-line no-labels
  17217. branches: if (node.tag === HostComponent) {
  17218. var instance = node.stateNode;
  17219. if (needsVisibilityToggle && isHidden) {
  17220. // This child is inside a timed out tree. Hide it.
  17221. var props = node.memoizedProps;
  17222. var type = node.type;
  17223. instance = cloneHiddenInstance(instance, type, props, node);
  17224. }
  17225. appendChildToContainerChildSet(containerChildSet, instance);
  17226. } else if (node.tag === HostText) {
  17227. var _instance3 = node.stateNode;
  17228. if (needsVisibilityToggle && isHidden) {
  17229. // This child is inside a timed out tree. Hide it.
  17230. var text = node.memoizedProps;
  17231. _instance3 = cloneHiddenTextInstance(_instance3, text, node);
  17232. }
  17233. appendChildToContainerChildSet(containerChildSet, _instance3);
  17234. } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
  17235. var _instance4 = node.stateNode.instance;
  17236. if (needsVisibilityToggle && isHidden) {
  17237. // This child is inside a timed out tree. Hide it.
  17238. var _props2 = node.memoizedProps;
  17239. var _type2 = node.type;
  17240. _instance4 = cloneHiddenInstance(_instance4, _type2, _props2, node);
  17241. }
  17242. appendChildToContainerChildSet(containerChildSet, _instance4);
  17243. } else if (node.tag === HostPortal) {// If we have a portal child, then we don't want to traverse
  17244. // down its children. Instead, we'll get insertions from each child in
  17245. // the portal directly.
  17246. } else if (node.tag === SuspenseComponent) {
  17247. if ((node.effectTag & Update) !== NoEffect) {
  17248. // Need to toggle the visibility of the primary children.
  17249. var newIsHidden = node.memoizedState !== null;
  17250. if (newIsHidden) {
  17251. var primaryChildParent = node.child;
  17252. if (primaryChildParent !== null) {
  17253. if (primaryChildParent.child !== null) {
  17254. primaryChildParent.child.return = primaryChildParent;
  17255. appendAllChildrenToContainer(containerChildSet, primaryChildParent, true, newIsHidden);
  17256. }
  17257. var fallbackChildParent = primaryChildParent.sibling;
  17258. if (fallbackChildParent !== null) {
  17259. fallbackChildParent.return = node;
  17260. node = fallbackChildParent;
  17261. continue;
  17262. }
  17263. }
  17264. }
  17265. }
  17266. if (node.child !== null) {
  17267. // Continue traversing like normal
  17268. node.child.return = node;
  17269. node = node.child;
  17270. continue;
  17271. }
  17272. } else if (node.child !== null) {
  17273. node.child.return = node;
  17274. node = node.child;
  17275. continue;
  17276. } // $FlowFixMe This is correct but Flow is confused by the labeled break.
  17277. node = node;
  17278. if (node === workInProgress) {
  17279. return;
  17280. }
  17281. while (node.sibling === null) {
  17282. if (node.return === null || node.return === workInProgress) {
  17283. return;
  17284. }
  17285. node = node.return;
  17286. }
  17287. node.sibling.return = node.return;
  17288. node = node.sibling;
  17289. }
  17290. };
  17291. updateHostContainer = function (workInProgress) {
  17292. var portalOrRoot = workInProgress.stateNode;
  17293. var childrenUnchanged = workInProgress.firstEffect === null;
  17294. if (childrenUnchanged) {// No changes, just reuse the existing instance.
  17295. } else {
  17296. var container = portalOrRoot.containerInfo;
  17297. var newChildSet = createContainerChildSet(container); // If children might have changed, we have to add them all to the set.
  17298. appendAllChildrenToContainer(newChildSet, workInProgress, false, false);
  17299. portalOrRoot.pendingChildren = newChildSet; // Schedule an update on the container to swap out the container.
  17300. markUpdate(workInProgress);
  17301. finalizeContainerChildren(container, newChildSet);
  17302. }
  17303. };
  17304. updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
  17305. var currentInstance = current.stateNode;
  17306. var oldProps = current.memoizedProps; // If there are no effects associated with this node, then none of our children had any updates.
  17307. // This guarantees that we can reuse all of them.
  17308. var childrenUnchanged = workInProgress.firstEffect === null;
  17309. if (childrenUnchanged && oldProps === newProps) {
  17310. // No changes, just reuse the existing instance.
  17311. // Note that this might release a previous clone.
  17312. workInProgress.stateNode = currentInstance;
  17313. return;
  17314. }
  17315. var recyclableInstance = workInProgress.stateNode;
  17316. var currentHostContext = getHostContext();
  17317. var updatePayload = null;
  17318. if (oldProps !== newProps) {
  17319. updatePayload = prepareUpdate(recyclableInstance, type, oldProps, newProps, rootContainerInstance, currentHostContext);
  17320. }
  17321. if (childrenUnchanged && updatePayload === null) {
  17322. // No changes, just reuse the existing instance.
  17323. // Note that this might release a previous clone.
  17324. workInProgress.stateNode = currentInstance;
  17325. return;
  17326. }
  17327. var newInstance = cloneInstance(currentInstance, updatePayload, type, oldProps, newProps, workInProgress, childrenUnchanged, recyclableInstance);
  17328. if (finalizeInitialChildren(newInstance, type, newProps, rootContainerInstance, currentHostContext)) {
  17329. markUpdate(workInProgress);
  17330. }
  17331. workInProgress.stateNode = newInstance;
  17332. if (childrenUnchanged) {
  17333. // If there are no other effects in this tree, we need to flag this node as having one.
  17334. // Even though we're not going to use it for anything.
  17335. // Otherwise parents won't know that there are new children to propagate upwards.
  17336. markUpdate(workInProgress);
  17337. } else {
  17338. // If children might have changed, we have to add them all to the set.
  17339. appendAllChildren(newInstance, workInProgress, false, false);
  17340. }
  17341. };
  17342. updateHostText$1 = function (current, workInProgress, oldText, newText) {
  17343. if (oldText !== newText) {
  17344. // If the text content differs, we'll create a new text instance for it.
  17345. var rootContainerInstance = getRootHostContainer();
  17346. var currentHostContext = getHostContext();
  17347. workInProgress.stateNode = createTextInstance(newText, rootContainerInstance, currentHostContext, workInProgress); // We'll have to mark it as having an effect, even though we won't use the effect for anything.
  17348. // This lets the parents know that at least one of their children has changed.
  17349. markUpdate(workInProgress);
  17350. }
  17351. };
  17352. } else {
  17353. // No host operations
  17354. updateHostContainer = function (workInProgress) {// Noop
  17355. };
  17356. updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {// Noop
  17357. };
  17358. updateHostText$1 = function (current, workInProgress, oldText, newText) {// Noop
  17359. };
  17360. }
  17361. function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
  17362. switch (renderState.tailMode) {
  17363. case 'hidden':
  17364. {
  17365. // Any insertions at the end of the tail list after this point
  17366. // should be invisible. If there are already mounted boundaries
  17367. // anything before them are not considered for collapsing.
  17368. // Therefore we need to go through the whole tail to find if
  17369. // there are any.
  17370. var tailNode = renderState.tail;
  17371. var lastTailNode = null;
  17372. while (tailNode !== null) {
  17373. if (tailNode.alternate !== null) {
  17374. lastTailNode = tailNode;
  17375. }
  17376. tailNode = tailNode.sibling;
  17377. } // Next we're simply going to delete all insertions after the
  17378. // last rendered item.
  17379. if (lastTailNode === null) {
  17380. // All remaining items in the tail are insertions.
  17381. renderState.tail = null;
  17382. } else {
  17383. // Detach the insertion after the last node that was already
  17384. // inserted.
  17385. lastTailNode.sibling = null;
  17386. }
  17387. break;
  17388. }
  17389. case 'collapsed':
  17390. {
  17391. // Any insertions at the end of the tail list after this point
  17392. // should be invisible. If there are already mounted boundaries
  17393. // anything before them are not considered for collapsing.
  17394. // Therefore we need to go through the whole tail to find if
  17395. // there are any.
  17396. var _tailNode = renderState.tail;
  17397. var _lastTailNode = null;
  17398. while (_tailNode !== null) {
  17399. if (_tailNode.alternate !== null) {
  17400. _lastTailNode = _tailNode;
  17401. }
  17402. _tailNode = _tailNode.sibling;
  17403. } // Next we're simply going to delete all insertions after the
  17404. // last rendered item.
  17405. if (_lastTailNode === null) {
  17406. // All remaining items in the tail are insertions.
  17407. if (!hasRenderedATailFallback && renderState.tail !== null) {
  17408. // We suspended during the head. We want to show at least one
  17409. // row at the tail. So we'll keep on and cut off the rest.
  17410. renderState.tail.sibling = null;
  17411. } else {
  17412. renderState.tail = null;
  17413. }
  17414. } else {
  17415. // Detach the insertion after the last node that was already
  17416. // inserted.
  17417. _lastTailNode.sibling = null;
  17418. }
  17419. break;
  17420. }
  17421. }
  17422. }
  17423. function completeWork(current, workInProgress, renderExpirationTime) {
  17424. var newProps = workInProgress.pendingProps;
  17425. switch (workInProgress.tag) {
  17426. case IndeterminateComponent:
  17427. break;
  17428. case LazyComponent:
  17429. break;
  17430. case SimpleMemoComponent:
  17431. case FunctionComponent:
  17432. break;
  17433. case ClassComponent:
  17434. {
  17435. var Component = workInProgress.type;
  17436. if (isContextProvider(Component)) {
  17437. popContext(workInProgress);
  17438. }
  17439. break;
  17440. }
  17441. case HostRoot:
  17442. {
  17443. popHostContainer(workInProgress);
  17444. popTopLevelContextObject(workInProgress);
  17445. var fiberRoot = workInProgress.stateNode;
  17446. if (fiberRoot.pendingContext) {
  17447. fiberRoot.context = fiberRoot.pendingContext;
  17448. fiberRoot.pendingContext = null;
  17449. }
  17450. if (current === null || current.child === null) {
  17451. // If we hydrated, pop so that we can delete any remaining children
  17452. // that weren't hydrated.
  17453. var wasHydrated = popHydrationState(workInProgress);
  17454. if (wasHydrated) {
  17455. // If we hydrated, then we'll need to schedule an update for
  17456. // the commit side-effects on the root.
  17457. markUpdate(workInProgress);
  17458. }
  17459. }
  17460. updateHostContainer(workInProgress);
  17461. break;
  17462. }
  17463. case HostComponent:
  17464. {
  17465. popHostContext(workInProgress);
  17466. var rootContainerInstance = getRootHostContainer();
  17467. var type = workInProgress.type;
  17468. if (current !== null && workInProgress.stateNode != null) {
  17469. updateHostComponent$1(current, workInProgress, type, newProps, rootContainerInstance);
  17470. if (enableFlareAPI) {
  17471. var prevListeners = current.memoizedProps.listeners;
  17472. var nextListeners = newProps.listeners;
  17473. if (prevListeners !== nextListeners) {
  17474. markUpdate(workInProgress);
  17475. }
  17476. }
  17477. if (current.ref !== workInProgress.ref) {
  17478. markRef$1(workInProgress);
  17479. }
  17480. } else {
  17481. if (!newProps) {
  17482. if (!(workInProgress.stateNode !== null)) {
  17483. {
  17484. throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");
  17485. }
  17486. } // This can happen when we abort work.
  17487. break;
  17488. }
  17489. var currentHostContext = getHostContext(); // TODO: Move createInstance to beginWork and keep it on a context
  17490. // "stack" as the parent. Then append children as we go in beginWork
  17491. // or completeWork depending on we want to add then top->down or
  17492. // bottom->up. Top->down is faster in IE11.
  17493. var _wasHydrated = popHydrationState(workInProgress);
  17494. if (_wasHydrated) {
  17495. // TODO: Move this and createInstance step into the beginPhase
  17496. // to consolidate.
  17497. if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, currentHostContext)) {
  17498. // If changes to the hydrated node needs to be applied at the
  17499. // commit-phase we mark this as such.
  17500. markUpdate(workInProgress);
  17501. }
  17502. if (enableFlareAPI) {
  17503. var listeners = newProps.listeners;
  17504. if (listeners != null) {
  17505. updateEventListeners(listeners, workInProgress, rootContainerInstance);
  17506. }
  17507. }
  17508. } else {
  17509. var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress);
  17510. appendAllChildren(instance, workInProgress, false, false); // This needs to be set before we mount Flare event listeners
  17511. workInProgress.stateNode = instance;
  17512. if (enableFlareAPI) {
  17513. var _listeners = newProps.listeners;
  17514. if (_listeners != null) {
  17515. updateEventListeners(_listeners, workInProgress, rootContainerInstance);
  17516. }
  17517. } // Certain renderers require commit-time effects for initial mount.
  17518. // (eg DOM renderer supports auto-focus for certain elements).
  17519. // Make sure such renderers get scheduled for later work.
  17520. if (finalizeInitialChildren(instance, type, newProps, rootContainerInstance, currentHostContext)) {
  17521. markUpdate(workInProgress);
  17522. }
  17523. }
  17524. if (workInProgress.ref !== null) {
  17525. // If there is a ref on a host node we need to schedule a callback
  17526. markRef$1(workInProgress);
  17527. }
  17528. }
  17529. break;
  17530. }
  17531. case HostText:
  17532. {
  17533. var newText = newProps;
  17534. if (current && workInProgress.stateNode != null) {
  17535. var oldText = current.memoizedProps; // If we have an alternate, that means this is an update and we need
  17536. // to schedule a side-effect to do the updates.
  17537. updateHostText$1(current, workInProgress, oldText, newText);
  17538. } else {
  17539. if (typeof newText !== 'string') {
  17540. if (!(workInProgress.stateNode !== null)) {
  17541. {
  17542. throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");
  17543. }
  17544. } // This can happen when we abort work.
  17545. }
  17546. var _rootContainerInstance = getRootHostContainer();
  17547. var _currentHostContext = getHostContext();
  17548. var _wasHydrated2 = popHydrationState(workInProgress);
  17549. if (_wasHydrated2) {
  17550. if (prepareToHydrateHostTextInstance(workInProgress)) {
  17551. markUpdate(workInProgress);
  17552. }
  17553. } else {
  17554. workInProgress.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext, workInProgress);
  17555. }
  17556. }
  17557. break;
  17558. }
  17559. case ForwardRef:
  17560. break;
  17561. case SuspenseComponent:
  17562. {
  17563. popSuspenseContext(workInProgress);
  17564. var nextState = workInProgress.memoizedState;
  17565. if (enableSuspenseServerRenderer) {
  17566. if (nextState !== null && nextState.dehydrated !== null) {
  17567. if (current === null) {
  17568. var _wasHydrated3 = popHydrationState(workInProgress);
  17569. if (!_wasHydrated3) {
  17570. {
  17571. throw Error("A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.");
  17572. }
  17573. }
  17574. prepareToHydrateHostSuspenseInstance(workInProgress);
  17575. if (enableSchedulerTracing) {
  17576. markSpawnedWork(Never);
  17577. }
  17578. return null;
  17579. } else {
  17580. // We should never have been in a hydration state if we didn't have a current.
  17581. // However, in some of those paths, we might have reentered a hydration state
  17582. // and then we might be inside a hydration state. In that case, we'll need to
  17583. // exit out of it.
  17584. resetHydrationState();
  17585. if ((workInProgress.effectTag & DidCapture) === NoEffect) {
  17586. // This boundary did not suspend so it's now hydrated and unsuspended.
  17587. workInProgress.memoizedState = null;
  17588. } // If nothing suspended, we need to schedule an effect to mark this boundary
  17589. // as having hydrated so events know that they're free be invoked.
  17590. // It's also a signal to replay events and the suspense callback.
  17591. // If something suspended, schedule an effect to attach retry listeners.
  17592. // So we might as well always mark this.
  17593. workInProgress.effectTag |= Update;
  17594. return null;
  17595. }
  17596. }
  17597. }
  17598. if ((workInProgress.effectTag & DidCapture) !== NoEffect) {
  17599. // Something suspended. Re-render with the fallback children.
  17600. workInProgress.expirationTime = renderExpirationTime; // Do not reset the effect list.
  17601. return workInProgress;
  17602. }
  17603. var nextDidTimeout = nextState !== null;
  17604. var prevDidTimeout = false;
  17605. if (current === null) {
  17606. if (workInProgress.memoizedProps.fallback !== undefined) {
  17607. popHydrationState(workInProgress);
  17608. }
  17609. } else {
  17610. var prevState = current.memoizedState;
  17611. prevDidTimeout = prevState !== null;
  17612. if (!nextDidTimeout && prevState !== null) {
  17613. // We just switched from the fallback to the normal children.
  17614. // Delete the fallback.
  17615. // TODO: Would it be better to store the fallback fragment on
  17616. // the stateNode during the begin phase?
  17617. var currentFallbackChild = current.child.sibling;
  17618. if (currentFallbackChild !== null) {
  17619. // Deletions go at the beginning of the return fiber's effect list
  17620. var first = workInProgress.firstEffect;
  17621. if (first !== null) {
  17622. workInProgress.firstEffect = currentFallbackChild;
  17623. currentFallbackChild.nextEffect = first;
  17624. } else {
  17625. workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild;
  17626. currentFallbackChild.nextEffect = null;
  17627. }
  17628. currentFallbackChild.effectTag = Deletion;
  17629. }
  17630. }
  17631. }
  17632. if (nextDidTimeout && !prevDidTimeout) {
  17633. // If this subtreee is running in blocking mode we can suspend,
  17634. // otherwise we won't suspend.
  17635. // TODO: This will still suspend a synchronous tree if anything
  17636. // in the concurrent tree already suspended during this render.
  17637. // This is a known bug.
  17638. if ((workInProgress.mode & BlockingMode) !== NoMode) {
  17639. // TODO: Move this back to throwException because this is too late
  17640. // if this is a large tree which is common for initial loads. We
  17641. // don't know if we should restart a render or not until we get
  17642. // this marker, and this is too late.
  17643. // If this render already had a ping or lower pri updates,
  17644. // and this is the first time we know we're going to suspend we
  17645. // should be able to immediately restart from within throwException.
  17646. var hasInvisibleChildContext = current === null && workInProgress.memoizedProps.unstable_avoidThisFallback !== true;
  17647. if (hasInvisibleChildContext || hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext)) {
  17648. // If this was in an invisible tree or a new render, then showing
  17649. // this boundary is ok.
  17650. renderDidSuspend();
  17651. } else {
  17652. // Otherwise, we're going to have to hide content so we should
  17653. // suspend for longer if possible.
  17654. renderDidSuspendDelayIfPossible();
  17655. }
  17656. }
  17657. }
  17658. if (supportsPersistence) {
  17659. // TODO: Only schedule updates if not prevDidTimeout.
  17660. if (nextDidTimeout) {
  17661. // If this boundary just timed out, schedule an effect to attach a
  17662. // retry listener to the proimse. This flag is also used to hide the
  17663. // primary children.
  17664. workInProgress.effectTag |= Update;
  17665. }
  17666. }
  17667. if (supportsMutation) {
  17668. // TODO: Only schedule updates if these values are non equal, i.e. it changed.
  17669. if (nextDidTimeout || prevDidTimeout) {
  17670. // If this boundary just timed out, schedule an effect to attach a
  17671. // retry listener to the proimse. This flag is also used to hide the
  17672. // primary children. In mutation mode, we also need the flag to
  17673. // *unhide* children that were previously hidden, so check if the
  17674. // is currently timed out, too.
  17675. workInProgress.effectTag |= Update;
  17676. }
  17677. }
  17678. if (enableSuspenseCallback && workInProgress.updateQueue !== null && workInProgress.memoizedProps.suspenseCallback != null) {
  17679. // Always notify the callback
  17680. workInProgress.effectTag |= Update;
  17681. }
  17682. break;
  17683. }
  17684. case Fragment:
  17685. break;
  17686. case Mode:
  17687. break;
  17688. case Profiler:
  17689. break;
  17690. case HostPortal:
  17691. popHostContainer(workInProgress);
  17692. updateHostContainer(workInProgress);
  17693. break;
  17694. case ContextProvider:
  17695. // Pop provider fiber
  17696. popProvider(workInProgress);
  17697. break;
  17698. case ContextConsumer:
  17699. break;
  17700. case MemoComponent:
  17701. break;
  17702. case IncompleteClassComponent:
  17703. {
  17704. // Same as class component case. I put it down here so that the tags are
  17705. // sequential to ensure this switch is compiled to a jump table.
  17706. var _Component = workInProgress.type;
  17707. if (isContextProvider(_Component)) {
  17708. popContext(workInProgress);
  17709. }
  17710. break;
  17711. }
  17712. case SuspenseListComponent:
  17713. {
  17714. popSuspenseContext(workInProgress);
  17715. var renderState = workInProgress.memoizedState;
  17716. if (renderState === null) {
  17717. // We're running in the default, "independent" mode. We don't do anything
  17718. // in this mode.
  17719. break;
  17720. }
  17721. var didSuspendAlready = (workInProgress.effectTag & DidCapture) !== NoEffect;
  17722. var renderedTail = renderState.rendering;
  17723. if (renderedTail === null) {
  17724. // We just rendered the head.
  17725. if (!didSuspendAlready) {
  17726. // This is the first pass. We need to figure out if anything is still
  17727. // suspended in the rendered set.
  17728. // If new content unsuspended, but there's still some content that
  17729. // didn't. Then we need to do a second pass that forces everything
  17730. // to keep showing their fallbacks.
  17731. // We might be suspended if something in this render pass suspended, or
  17732. // something in the previous committed pass suspended. Otherwise,
  17733. // there's no chance so we can skip the expensive call to
  17734. // findFirstSuspended.
  17735. var cannotBeSuspended = renderHasNotSuspendedYet() && (current === null || (current.effectTag & DidCapture) === NoEffect);
  17736. if (!cannotBeSuspended) {
  17737. var row = workInProgress.child;
  17738. while (row !== null) {
  17739. var suspended = findFirstSuspended(row);
  17740. if (suspended !== null) {
  17741. didSuspendAlready = true;
  17742. workInProgress.effectTag |= DidCapture;
  17743. cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as
  17744. // part of the second pass. In that case nothing will subscribe to
  17745. // its thennables. Instead, we'll transfer its thennables to the
  17746. // SuspenseList so that it can retry if they resolve.
  17747. // There might be multiple of these in the list but since we're
  17748. // going to wait for all of them anyway, it doesn't really matter
  17749. // which ones gets to ping. In theory we could get clever and keep
  17750. // track of how many dependencies remain but it gets tricky because
  17751. // in the meantime, we can add/remove/change items and dependencies.
  17752. // We might bail out of the loop before finding any but that
  17753. // doesn't matter since that means that the other boundaries that
  17754. // we did find already has their listeners attached.
  17755. var newThennables = suspended.updateQueue;
  17756. if (newThennables !== null) {
  17757. workInProgress.updateQueue = newThennables;
  17758. workInProgress.effectTag |= Update;
  17759. } // Rerender the whole list, but this time, we'll force fallbacks
  17760. // to stay in place.
  17761. // Reset the effect list before doing the second pass since that's now invalid.
  17762. if (renderState.lastEffect === null) {
  17763. workInProgress.firstEffect = null;
  17764. }
  17765. workInProgress.lastEffect = renderState.lastEffect; // Reset the child fibers to their original state.
  17766. resetChildFibers(workInProgress, renderExpirationTime); // Set up the Suspense Context to force suspense and immediately
  17767. // rerender the children.
  17768. pushSuspenseContext(workInProgress, setShallowSuspenseContext(suspenseStackCursor.current, ForceSuspenseFallback));
  17769. return workInProgress.child;
  17770. }
  17771. row = row.sibling;
  17772. }
  17773. }
  17774. } else {
  17775. cutOffTailIfNeeded(renderState, false);
  17776. } // Next we're going to render the tail.
  17777. } else {
  17778. // Append the rendered row to the child list.
  17779. if (!didSuspendAlready) {
  17780. var _suspended = findFirstSuspended(renderedTail);
  17781. if (_suspended !== null) {
  17782. workInProgress.effectTag |= DidCapture;
  17783. didSuspendAlready = true; // Ensure we transfer the update queue to the parent so that it doesn't
  17784. // get lost if this row ends up dropped during a second pass.
  17785. var _newThennables = _suspended.updateQueue;
  17786. if (_newThennables !== null) {
  17787. workInProgress.updateQueue = _newThennables;
  17788. workInProgress.effectTag |= Update;
  17789. }
  17790. cutOffTailIfNeeded(renderState, true); // This might have been modified.
  17791. if (renderState.tail === null && renderState.tailMode === 'hidden' && !renderedTail.alternate) {
  17792. // We need to delete the row we just rendered.
  17793. // Reset the effect list to what it was before we rendered this
  17794. // child. The nested children have already appended themselves.
  17795. var lastEffect = workInProgress.lastEffect = renderState.lastEffect; // Remove any effects that were appended after this point.
  17796. if (lastEffect !== null) {
  17797. lastEffect.nextEffect = null;
  17798. } // We're done.
  17799. return null;
  17800. }
  17801. } else if (now() > renderState.tailExpiration && renderExpirationTime > Never) {
  17802. // We have now passed our CPU deadline and we'll just give up further
  17803. // attempts to render the main content and only render fallbacks.
  17804. // The assumption is that this is usually faster.
  17805. workInProgress.effectTag |= DidCapture;
  17806. didSuspendAlready = true;
  17807. cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this
  17808. // to get it started back up to attempt the next item. If we can show
  17809. // them, then they really have the same priority as this render.
  17810. // So we'll pick it back up the very next render pass once we've had
  17811. // an opportunity to yield for paint.
  17812. var nextPriority = renderExpirationTime - 1;
  17813. workInProgress.expirationTime = workInProgress.childExpirationTime = nextPriority;
  17814. if (enableSchedulerTracing) {
  17815. markSpawnedWork(nextPriority);
  17816. }
  17817. }
  17818. }
  17819. if (renderState.isBackwards) {
  17820. // The effect list of the backwards tail will have been added
  17821. // to the end. This breaks the guarantee that life-cycles fire in
  17822. // sibling order but that isn't a strong guarantee promised by React.
  17823. // Especially since these might also just pop in during future commits.
  17824. // Append to the beginning of the list.
  17825. renderedTail.sibling = workInProgress.child;
  17826. workInProgress.child = renderedTail;
  17827. } else {
  17828. var previousSibling = renderState.last;
  17829. if (previousSibling !== null) {
  17830. previousSibling.sibling = renderedTail;
  17831. } else {
  17832. workInProgress.child = renderedTail;
  17833. }
  17834. renderState.last = renderedTail;
  17835. }
  17836. }
  17837. if (renderState.tail !== null) {
  17838. // We still have tail rows to render.
  17839. if (renderState.tailExpiration === 0) {
  17840. // Heuristic for how long we're willing to spend rendering rows
  17841. // until we just give up and show what we have so far.
  17842. var TAIL_EXPIRATION_TIMEOUT_MS = 500;
  17843. renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS;
  17844. } // Pop a row.
  17845. var next = renderState.tail;
  17846. renderState.rendering = next;
  17847. renderState.tail = next.sibling;
  17848. renderState.lastEffect = workInProgress.lastEffect;
  17849. next.sibling = null; // Restore the context.
  17850. // TODO: We can probably just avoid popping it instead and only
  17851. // setting it the first time we go from not suspended to suspended.
  17852. var suspenseContext = suspenseStackCursor.current;
  17853. if (didSuspendAlready) {
  17854. suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
  17855. } else {
  17856. suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
  17857. }
  17858. pushSuspenseContext(workInProgress, suspenseContext); // Do a pass over the next row.
  17859. return next;
  17860. }
  17861. break;
  17862. }
  17863. case FundamentalComponent:
  17864. {
  17865. if (enableFundamentalAPI) {
  17866. var fundamentalImpl = workInProgress.type.impl;
  17867. var fundamentalInstance = workInProgress.stateNode;
  17868. if (fundamentalInstance === null) {
  17869. var getInitialState = fundamentalImpl.getInitialState;
  17870. var fundamentalState;
  17871. if (getInitialState !== undefined) {
  17872. fundamentalState = getInitialState(newProps);
  17873. }
  17874. fundamentalInstance = workInProgress.stateNode = createFundamentalStateInstance(workInProgress, newProps, fundamentalImpl, fundamentalState || {});
  17875. var _instance5 = getFundamentalComponentInstance(fundamentalInstance);
  17876. fundamentalInstance.instance = _instance5;
  17877. if (fundamentalImpl.reconcileChildren === false) {
  17878. return null;
  17879. }
  17880. appendAllChildren(_instance5, workInProgress, false, false);
  17881. mountFundamentalComponent(fundamentalInstance);
  17882. } else {
  17883. // We fire update in commit phase
  17884. var prevProps = fundamentalInstance.props;
  17885. fundamentalInstance.prevProps = prevProps;
  17886. fundamentalInstance.props = newProps;
  17887. fundamentalInstance.currentFiber = workInProgress;
  17888. if (supportsPersistence) {
  17889. var _instance6 = cloneFundamentalInstance(fundamentalInstance);
  17890. fundamentalInstance.instance = _instance6;
  17891. appendAllChildren(_instance6, workInProgress, false, false);
  17892. }
  17893. var shouldUpdate = shouldUpdateFundamentalComponent(fundamentalInstance);
  17894. if (shouldUpdate) {
  17895. markUpdate(workInProgress);
  17896. }
  17897. }
  17898. }
  17899. break;
  17900. }
  17901. case ScopeComponent:
  17902. {
  17903. if (enableScopeAPI) {
  17904. if (current === null) {
  17905. var _type3 = workInProgress.type;
  17906. var scopeInstance = {
  17907. fiber: workInProgress,
  17908. methods: null
  17909. };
  17910. workInProgress.stateNode = scopeInstance;
  17911. scopeInstance.methods = createScopeMethods(_type3, scopeInstance);
  17912. if (enableFlareAPI) {
  17913. var _listeners2 = newProps.listeners;
  17914. if (_listeners2 != null) {
  17915. var _rootContainerInstance2 = getRootHostContainer();
  17916. updateEventListeners(_listeners2, workInProgress, _rootContainerInstance2);
  17917. }
  17918. }
  17919. if (workInProgress.ref !== null) {
  17920. markRef$1(workInProgress);
  17921. markUpdate(workInProgress);
  17922. }
  17923. } else {
  17924. if (enableFlareAPI) {
  17925. var _prevListeners = current.memoizedProps.listeners;
  17926. var _nextListeners = newProps.listeners;
  17927. if (_prevListeners !== _nextListeners || workInProgress.ref !== null) {
  17928. markUpdate(workInProgress);
  17929. }
  17930. } else {
  17931. if (workInProgress.ref !== null) {
  17932. markUpdate(workInProgress);
  17933. }
  17934. }
  17935. if (current.ref !== workInProgress.ref) {
  17936. markRef$1(workInProgress);
  17937. }
  17938. }
  17939. }
  17940. break;
  17941. }
  17942. default:
  17943. {
  17944. {
  17945. throw Error("Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue.");
  17946. }
  17947. }
  17948. }
  17949. return null;
  17950. }
  17951. function unwindWork(workInProgress, renderExpirationTime) {
  17952. switch (workInProgress.tag) {
  17953. case ClassComponent:
  17954. {
  17955. var Component = workInProgress.type;
  17956. if (isContextProvider(Component)) {
  17957. popContext(workInProgress);
  17958. }
  17959. var effectTag = workInProgress.effectTag;
  17960. if (effectTag & ShouldCapture) {
  17961. workInProgress.effectTag = effectTag & ~ShouldCapture | DidCapture;
  17962. return workInProgress;
  17963. }
  17964. return null;
  17965. }
  17966. case HostRoot:
  17967. {
  17968. popHostContainer(workInProgress);
  17969. popTopLevelContextObject(workInProgress);
  17970. var _effectTag = workInProgress.effectTag;
  17971. if (!((_effectTag & DidCapture) === NoEffect)) {
  17972. {
  17973. throw Error("The root failed to unmount after an error. This is likely a bug in React. Please file an issue.");
  17974. }
  17975. }
  17976. workInProgress.effectTag = _effectTag & ~ShouldCapture | DidCapture;
  17977. return workInProgress;
  17978. }
  17979. case HostComponent:
  17980. {
  17981. // TODO: popHydrationState
  17982. popHostContext(workInProgress);
  17983. return null;
  17984. }
  17985. case SuspenseComponent:
  17986. {
  17987. popSuspenseContext(workInProgress);
  17988. if (enableSuspenseServerRenderer) {
  17989. var suspenseState = workInProgress.memoizedState;
  17990. if (suspenseState !== null && suspenseState.dehydrated !== null) {
  17991. if (!(workInProgress.alternate !== null)) {
  17992. {
  17993. throw Error("Threw in newly mounted dehydrated component. This is likely a bug in React. Please file an issue.");
  17994. }
  17995. }
  17996. resetHydrationState();
  17997. }
  17998. }
  17999. var _effectTag2 = workInProgress.effectTag;
  18000. if (_effectTag2 & ShouldCapture) {
  18001. workInProgress.effectTag = _effectTag2 & ~ShouldCapture | DidCapture; // Captured a suspense effect. Re-render the boundary.
  18002. return workInProgress;
  18003. }
  18004. return null;
  18005. }
  18006. case SuspenseListComponent:
  18007. {
  18008. popSuspenseContext(workInProgress); // SuspenseList doesn't actually catch anything. It should've been
  18009. // caught by a nested boundary. If not, it should bubble through.
  18010. return null;
  18011. }
  18012. case HostPortal:
  18013. popHostContainer(workInProgress);
  18014. return null;
  18015. case ContextProvider:
  18016. popProvider(workInProgress);
  18017. return null;
  18018. default:
  18019. return null;
  18020. }
  18021. }
  18022. function unwindInterruptedWork(interruptedWork) {
  18023. switch (interruptedWork.tag) {
  18024. case ClassComponent:
  18025. {
  18026. var childContextTypes = interruptedWork.type.childContextTypes;
  18027. if (childContextTypes !== null && childContextTypes !== undefined) {
  18028. popContext(interruptedWork);
  18029. }
  18030. break;
  18031. }
  18032. case HostRoot:
  18033. {
  18034. popHostContainer(interruptedWork);
  18035. popTopLevelContextObject(interruptedWork);
  18036. break;
  18037. }
  18038. case HostComponent:
  18039. {
  18040. popHostContext(interruptedWork);
  18041. break;
  18042. }
  18043. case HostPortal:
  18044. popHostContainer(interruptedWork);
  18045. break;
  18046. case SuspenseComponent:
  18047. popSuspenseContext(interruptedWork);
  18048. break;
  18049. case SuspenseListComponent:
  18050. popSuspenseContext(interruptedWork);
  18051. break;
  18052. case ContextProvider:
  18053. popProvider(interruptedWork);
  18054. break;
  18055. default:
  18056. break;
  18057. }
  18058. }
  18059. function createCapturedValue(value, source) {
  18060. // If the value is an error, call this function immediately after it is thrown
  18061. // so the stack is accurate.
  18062. return {
  18063. value: value,
  18064. source: source,
  18065. stack: getStackByFiberInDevAndProd(source)
  18066. };
  18067. }
  18068. // This module is forked in different environments.
  18069. // By default, return `true` to log errors to the console.
  18070. // Forks can return `false` if this isn't desirable.
  18071. function showErrorDialog(capturedError) {
  18072. return true;
  18073. }
  18074. function logCapturedError(capturedError) {
  18075. var logError = showErrorDialog(capturedError); // Allow injected showErrorDialog() to prevent default console.error logging.
  18076. // This enables renderers like ReactNative to better manage redbox behavior.
  18077. if (logError === false) {
  18078. return;
  18079. }
  18080. var error = capturedError.error;
  18081. {
  18082. var componentName = capturedError.componentName,
  18083. componentStack = capturedError.componentStack,
  18084. errorBoundaryName = capturedError.errorBoundaryName,
  18085. errorBoundaryFound = capturedError.errorBoundaryFound,
  18086. willRetry = capturedError.willRetry; // Browsers support silencing uncaught errors by calling
  18087. // `preventDefault()` in window `error` handler.
  18088. // We record this information as an expando on the error.
  18089. if (error != null && error._suppressLogging) {
  18090. if (errorBoundaryFound && willRetry) {
  18091. // The error is recoverable and was silenced.
  18092. // Ignore it and don't print the stack addendum.
  18093. // This is handy for testing error boundaries without noise.
  18094. return;
  18095. } // The error is fatal. Since the silencing might have
  18096. // been accidental, we'll surface it anyway.
  18097. // However, the browser would have silenced the original error
  18098. // so we'll print it first, and then print the stack addendum.
  18099. console.error(error); // For a more detailed description of this block, see:
  18100. // https://github.com/facebook/react/pull/13384
  18101. }
  18102. var componentNameMessage = componentName ? "The above error occurred in the <" + componentName + "> component:" : 'The above error occurred in one of your React components:';
  18103. var errorBoundaryMessage; // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow.
  18104. if (errorBoundaryFound && errorBoundaryName) {
  18105. if (willRetry) {
  18106. errorBoundaryMessage = "React will try to recreate this component tree from scratch " + ("using the error boundary you provided, " + errorBoundaryName + ".");
  18107. } else {
  18108. errorBoundaryMessage = "This error was initially handled by the error boundary " + errorBoundaryName + ".\n" + "Recreating the tree from scratch failed so React will unmount the tree.";
  18109. }
  18110. } else {
  18111. errorBoundaryMessage = 'Consider adding an error boundary to your tree to customize error handling behavior.\n' + 'Visit https://fb.me/react-error-boundaries to learn more about error boundaries.';
  18112. }
  18113. var combinedMessage = "" + componentNameMessage + componentStack + "\n\n" + ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack.
  18114. // We don't include the original error message and JS stack because the browser
  18115. // has already printed it. Even if the application swallows the error, it is still
  18116. // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils.
  18117. console.error(combinedMessage);
  18118. }
  18119. }
  18120. var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
  18121. {
  18122. didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
  18123. }
  18124. var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
  18125. function logError(boundary, errorInfo) {
  18126. var source = errorInfo.source;
  18127. var stack = errorInfo.stack;
  18128. if (stack === null && source !== null) {
  18129. stack = getStackByFiberInDevAndProd(source);
  18130. }
  18131. var capturedError = {
  18132. componentName: source !== null ? getComponentName(source.type) : null,
  18133. componentStack: stack !== null ? stack : '',
  18134. error: errorInfo.value,
  18135. errorBoundary: null,
  18136. errorBoundaryName: null,
  18137. errorBoundaryFound: false,
  18138. willRetry: false
  18139. };
  18140. if (boundary !== null && boundary.tag === ClassComponent) {
  18141. capturedError.errorBoundary = boundary.stateNode;
  18142. capturedError.errorBoundaryName = getComponentName(boundary.type);
  18143. capturedError.errorBoundaryFound = true;
  18144. capturedError.willRetry = true;
  18145. }
  18146. try {
  18147. logCapturedError(capturedError);
  18148. } catch (e) {
  18149. // This method must not throw, or React internal state will get messed up.
  18150. // If console.error is overridden, or logCapturedError() shows a dialog that throws,
  18151. // we want to report this error outside of the normal stack as a last resort.
  18152. // https://github.com/facebook/react/issues/13188
  18153. setTimeout(function () {
  18154. throw e;
  18155. });
  18156. }
  18157. }
  18158. var callComponentWillUnmountWithTimer = function (current$$1, instance) {
  18159. startPhaseTimer(current$$1, 'componentWillUnmount');
  18160. instance.props = current$$1.memoizedProps;
  18161. instance.state = current$$1.memoizedState;
  18162. instance.componentWillUnmount();
  18163. stopPhaseTimer();
  18164. }; // Capture errors so they don't interrupt unmounting.
  18165. function safelyCallComponentWillUnmount(current$$1, instance) {
  18166. {
  18167. invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current$$1, instance);
  18168. if (hasCaughtError()) {
  18169. var unmountError = clearCaughtError();
  18170. captureCommitPhaseError(current$$1, unmountError);
  18171. }
  18172. }
  18173. }
  18174. function safelyDetachRef(current$$1) {
  18175. var ref = current$$1.ref;
  18176. if (ref !== null) {
  18177. if (typeof ref === 'function') {
  18178. {
  18179. invokeGuardedCallback(null, ref, null, null);
  18180. if (hasCaughtError()) {
  18181. var refError = clearCaughtError();
  18182. captureCommitPhaseError(current$$1, refError);
  18183. }
  18184. }
  18185. } else {
  18186. ref.current = null;
  18187. }
  18188. }
  18189. }
  18190. function safelyCallDestroy(current$$1, destroy) {
  18191. {
  18192. invokeGuardedCallback(null, destroy, null);
  18193. if (hasCaughtError()) {
  18194. var error = clearCaughtError();
  18195. captureCommitPhaseError(current$$1, error);
  18196. }
  18197. }
  18198. }
  18199. function commitBeforeMutationLifeCycles(current$$1, finishedWork) {
  18200. switch (finishedWork.tag) {
  18201. case FunctionComponent:
  18202. case ForwardRef:
  18203. case SimpleMemoComponent:
  18204. {
  18205. commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork);
  18206. return;
  18207. }
  18208. case ClassComponent:
  18209. {
  18210. if (finishedWork.effectTag & Snapshot) {
  18211. if (current$$1 !== null) {
  18212. var prevProps = current$$1.memoizedProps;
  18213. var prevState = current$$1.memoizedState;
  18214. startPhaseTimer(finishedWork, 'getSnapshotBeforeUpdate');
  18215. var instance = finishedWork.stateNode; // We could update instance props and state here,
  18216. // but instead we rely on them being set during last render.
  18217. // TODO: revisit this when we implement resuming.
  18218. {
  18219. if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
  18220. !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
  18221. !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
  18222. }
  18223. }
  18224. var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState);
  18225. {
  18226. var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate;
  18227. if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
  18228. didWarnSet.add(finishedWork.type);
  18229. warningWithoutStack$1(false, '%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork.type));
  18230. }
  18231. }
  18232. instance.__reactInternalSnapshotBeforeUpdate = snapshot;
  18233. stopPhaseTimer();
  18234. }
  18235. }
  18236. return;
  18237. }
  18238. case HostRoot:
  18239. case HostComponent:
  18240. case HostText:
  18241. case HostPortal:
  18242. case IncompleteClassComponent:
  18243. // Nothing to do for these component types
  18244. return;
  18245. default:
  18246. {
  18247. {
  18248. {
  18249. throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.");
  18250. }
  18251. }
  18252. }
  18253. }
  18254. }
  18255. function commitHookEffectList(unmountTag, mountTag, finishedWork) {
  18256. var updateQueue = finishedWork.updateQueue;
  18257. var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
  18258. if (lastEffect !== null) {
  18259. var firstEffect = lastEffect.next;
  18260. var effect = firstEffect;
  18261. do {
  18262. if ((effect.tag & unmountTag) !== NoEffect$1) {
  18263. // Unmount
  18264. var destroy = effect.destroy;
  18265. effect.destroy = undefined;
  18266. if (destroy !== undefined) {
  18267. destroy();
  18268. }
  18269. }
  18270. if ((effect.tag & mountTag) !== NoEffect$1) {
  18271. // Mount
  18272. var create = effect.create;
  18273. effect.destroy = create();
  18274. {
  18275. var _destroy = effect.destroy;
  18276. if (_destroy !== undefined && typeof _destroy !== 'function') {
  18277. var addendum = void 0;
  18278. if (_destroy === null) {
  18279. addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).';
  18280. } else if (typeof _destroy.then === 'function') {
  18281. addendum = '\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. ' + 'Instead, write the async function inside your effect ' + 'and call it immediately:\n\n' + 'useEffect(() => {\n' + ' async function fetchData() {\n' + ' // You can await here\n' + ' const response = await MyAPI.getData(someId);\n' + ' // ...\n' + ' }\n' + ' fetchData();\n' + "}, [someId]); // Or [] if effect doesn't need props or state\n\n" + 'Learn more about data fetching with Hooks: https://fb.me/react-hooks-data-fetching';
  18282. } else {
  18283. addendum = ' You returned: ' + _destroy;
  18284. }
  18285. warningWithoutStack$1(false, 'An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
  18286. }
  18287. }
  18288. }
  18289. effect = effect.next;
  18290. } while (effect !== firstEffect);
  18291. }
  18292. }
  18293. function commitPassiveHookEffects(finishedWork) {
  18294. if ((finishedWork.effectTag & Passive) !== NoEffect) {
  18295. switch (finishedWork.tag) {
  18296. case FunctionComponent:
  18297. case ForwardRef:
  18298. case SimpleMemoComponent:
  18299. {
  18300. commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork);
  18301. commitHookEffectList(NoEffect$1, MountPassive, finishedWork);
  18302. break;
  18303. }
  18304. default:
  18305. break;
  18306. }
  18307. }
  18308. }
  18309. function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpirationTime) {
  18310. switch (finishedWork.tag) {
  18311. case FunctionComponent:
  18312. case ForwardRef:
  18313. case SimpleMemoComponent:
  18314. {
  18315. commitHookEffectList(UnmountLayout, MountLayout, finishedWork);
  18316. break;
  18317. }
  18318. case ClassComponent:
  18319. {
  18320. var instance = finishedWork.stateNode;
  18321. if (finishedWork.effectTag & Update) {
  18322. if (current$$1 === null) {
  18323. startPhaseTimer(finishedWork, 'componentDidMount'); // We could update instance props and state here,
  18324. // but instead we rely on them being set during last render.
  18325. // TODO: revisit this when we implement resuming.
  18326. {
  18327. if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
  18328. !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
  18329. !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
  18330. }
  18331. }
  18332. instance.componentDidMount();
  18333. stopPhaseTimer();
  18334. } else {
  18335. var prevProps = finishedWork.elementType === finishedWork.type ? current$$1.memoizedProps : resolveDefaultProps(finishedWork.type, current$$1.memoizedProps);
  18336. var prevState = current$$1.memoizedState;
  18337. startPhaseTimer(finishedWork, 'componentDidUpdate'); // We could update instance props and state here,
  18338. // but instead we rely on them being set during last render.
  18339. // TODO: revisit this when we implement resuming.
  18340. {
  18341. if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
  18342. !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
  18343. !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
  18344. }
  18345. }
  18346. instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate);
  18347. stopPhaseTimer();
  18348. }
  18349. }
  18350. var updateQueue = finishedWork.updateQueue;
  18351. if (updateQueue !== null) {
  18352. {
  18353. if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
  18354. !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
  18355. !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
  18356. }
  18357. } // We could update instance props and state here,
  18358. // but instead we rely on them being set during last render.
  18359. // TODO: revisit this when we implement resuming.
  18360. commitUpdateQueue(finishedWork, updateQueue, instance, committedExpirationTime);
  18361. }
  18362. return;
  18363. }
  18364. case HostRoot:
  18365. {
  18366. var _updateQueue = finishedWork.updateQueue;
  18367. if (_updateQueue !== null) {
  18368. var _instance = null;
  18369. if (finishedWork.child !== null) {
  18370. switch (finishedWork.child.tag) {
  18371. case HostComponent:
  18372. _instance = getPublicInstance(finishedWork.child.stateNode);
  18373. break;
  18374. case ClassComponent:
  18375. _instance = finishedWork.child.stateNode;
  18376. break;
  18377. }
  18378. }
  18379. commitUpdateQueue(finishedWork, _updateQueue, _instance, committedExpirationTime);
  18380. }
  18381. return;
  18382. }
  18383. case HostComponent:
  18384. {
  18385. var _instance2 = finishedWork.stateNode; // Renderers may schedule work to be done after host components are mounted
  18386. // (eg DOM renderer may schedule auto-focus for inputs and form controls).
  18387. // These effects should only be committed when components are first mounted,
  18388. // aka when there is no current/alternate.
  18389. if (current$$1 === null && finishedWork.effectTag & Update) {
  18390. var type = finishedWork.type;
  18391. var props = finishedWork.memoizedProps;
  18392. commitMount(_instance2, type, props, finishedWork);
  18393. }
  18394. return;
  18395. }
  18396. case HostText:
  18397. {
  18398. // We have no life-cycles associated with text.
  18399. return;
  18400. }
  18401. case HostPortal:
  18402. {
  18403. // We have no life-cycles associated with portals.
  18404. return;
  18405. }
  18406. case Profiler:
  18407. {
  18408. if (enableProfilerTimer) {
  18409. var onRender = finishedWork.memoizedProps.onRender;
  18410. if (typeof onRender === 'function') {
  18411. if (enableSchedulerTracing) {
  18412. onRender(finishedWork.memoizedProps.id, current$$1 === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime(), finishedRoot.memoizedInteractions);
  18413. } else {
  18414. onRender(finishedWork.memoizedProps.id, current$$1 === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime());
  18415. }
  18416. }
  18417. }
  18418. return;
  18419. }
  18420. case SuspenseComponent:
  18421. {
  18422. commitSuspenseHydrationCallbacks(finishedRoot, finishedWork);
  18423. return;
  18424. }
  18425. case SuspenseListComponent:
  18426. case IncompleteClassComponent:
  18427. case FundamentalComponent:
  18428. case ScopeComponent:
  18429. return;
  18430. default:
  18431. {
  18432. {
  18433. {
  18434. throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.");
  18435. }
  18436. }
  18437. }
  18438. }
  18439. }
  18440. function hideOrUnhideAllChildren(finishedWork, isHidden) {
  18441. if (supportsMutation) {
  18442. // We only have the top Fiber that was inserted but we need to recurse down its
  18443. // children to find all the terminal nodes.
  18444. var node = finishedWork;
  18445. while (true) {
  18446. if (node.tag === HostComponent) {
  18447. var instance = node.stateNode;
  18448. if (isHidden) {
  18449. hideInstance(instance);
  18450. } else {
  18451. unhideInstance(node.stateNode, node.memoizedProps);
  18452. }
  18453. } else if (node.tag === HostText) {
  18454. var _instance3 = node.stateNode;
  18455. if (isHidden) {
  18456. hideTextInstance(_instance3);
  18457. } else {
  18458. unhideTextInstance(_instance3, node.memoizedProps);
  18459. }
  18460. } else if (node.tag === SuspenseComponent && node.memoizedState !== null && node.memoizedState.dehydrated === null) {
  18461. // Found a nested Suspense component that timed out. Skip over the
  18462. // primary child fragment, which should remain hidden.
  18463. var fallbackChildFragment = node.child.sibling;
  18464. fallbackChildFragment.return = node;
  18465. node = fallbackChildFragment;
  18466. continue;
  18467. } else if (node.child !== null) {
  18468. node.child.return = node;
  18469. node = node.child;
  18470. continue;
  18471. }
  18472. if (node === finishedWork) {
  18473. return;
  18474. }
  18475. while (node.sibling === null) {
  18476. if (node.return === null || node.return === finishedWork) {
  18477. return;
  18478. }
  18479. node = node.return;
  18480. }
  18481. node.sibling.return = node.return;
  18482. node = node.sibling;
  18483. }
  18484. }
  18485. }
  18486. function commitAttachRef(finishedWork) {
  18487. var ref = finishedWork.ref;
  18488. if (ref !== null) {
  18489. var instance = finishedWork.stateNode;
  18490. var instanceToUse;
  18491. switch (finishedWork.tag) {
  18492. case HostComponent:
  18493. instanceToUse = getPublicInstance(instance);
  18494. break;
  18495. default:
  18496. instanceToUse = instance;
  18497. } // Moved outside to ensure DCE works with this flag
  18498. if (enableScopeAPI && finishedWork.tag === ScopeComponent) {
  18499. instanceToUse = instance.methods;
  18500. }
  18501. if (typeof ref === 'function') {
  18502. ref(instanceToUse);
  18503. } else {
  18504. {
  18505. if (!ref.hasOwnProperty('current')) {
  18506. warningWithoutStack$1(false, 'Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().%s', getComponentName(finishedWork.type), getStackByFiberInDevAndProd(finishedWork));
  18507. }
  18508. }
  18509. ref.current = instanceToUse;
  18510. }
  18511. }
  18512. }
  18513. function commitDetachRef(current$$1) {
  18514. var currentRef = current$$1.ref;
  18515. if (currentRef !== null) {
  18516. if (typeof currentRef === 'function') {
  18517. currentRef(null);
  18518. } else {
  18519. currentRef.current = null;
  18520. }
  18521. }
  18522. } // User-originating errors (lifecycles and refs) should not interrupt
  18523. // deletion, so don't let them throw. Host-originating errors should
  18524. // interrupt deletion, so it's okay
  18525. function commitUnmount(finishedRoot, current$$1, renderPriorityLevel) {
  18526. onCommitUnmount(current$$1);
  18527. switch (current$$1.tag) {
  18528. case FunctionComponent:
  18529. case ForwardRef:
  18530. case MemoComponent:
  18531. case SimpleMemoComponent:
  18532. {
  18533. var updateQueue = current$$1.updateQueue;
  18534. if (updateQueue !== null) {
  18535. var lastEffect = updateQueue.lastEffect;
  18536. if (lastEffect !== null) {
  18537. var firstEffect = lastEffect.next; // When the owner fiber is deleted, the destroy function of a passive
  18538. // effect hook is called during the synchronous commit phase. This is
  18539. // a concession to implementation complexity. Calling it in the
  18540. // passive effect phase (like they usually are, when dependencies
  18541. // change during an update) would require either traversing the
  18542. // children of the deleted fiber again, or including unmount effects
  18543. // as part of the fiber effect list.
  18544. //
  18545. // Because this is during the sync commit phase, we need to change
  18546. // the priority.
  18547. //
  18548. // TODO: Reconsider this implementation trade off.
  18549. var priorityLevel = renderPriorityLevel > NormalPriority ? NormalPriority : renderPriorityLevel;
  18550. runWithPriority$2(priorityLevel, function () {
  18551. var effect = firstEffect;
  18552. do {
  18553. var destroy = effect.destroy;
  18554. if (destroy !== undefined) {
  18555. safelyCallDestroy(current$$1, destroy);
  18556. }
  18557. effect = effect.next;
  18558. } while (effect !== firstEffect);
  18559. });
  18560. }
  18561. }
  18562. break;
  18563. }
  18564. case ClassComponent:
  18565. {
  18566. safelyDetachRef(current$$1);
  18567. var instance = current$$1.stateNode;
  18568. if (typeof instance.componentWillUnmount === 'function') {
  18569. safelyCallComponentWillUnmount(current$$1, instance);
  18570. }
  18571. return;
  18572. }
  18573. case HostComponent:
  18574. {
  18575. if (enableFlareAPI) {
  18576. var dependencies = current$$1.dependencies;
  18577. if (dependencies !== null) {
  18578. var respondersMap = dependencies.responders;
  18579. if (respondersMap !== null) {
  18580. var responderInstances = Array.from(respondersMap.values());
  18581. for (var i = 0, length = responderInstances.length; i < length; i++) {
  18582. var responderInstance = responderInstances[i];
  18583. unmountResponderInstance(responderInstance);
  18584. }
  18585. dependencies.responders = null;
  18586. }
  18587. }
  18588. }
  18589. safelyDetachRef(current$$1);
  18590. return;
  18591. }
  18592. case HostPortal:
  18593. {
  18594. // TODO: this is recursive.
  18595. // We are also not using this parent because
  18596. // the portal will get pushed immediately.
  18597. if (supportsMutation) {
  18598. unmountHostComponents(finishedRoot, current$$1, renderPriorityLevel);
  18599. } else if (supportsPersistence) {
  18600. emptyPortalContainer(current$$1);
  18601. }
  18602. return;
  18603. }
  18604. case FundamentalComponent:
  18605. {
  18606. if (enableFundamentalAPI) {
  18607. var fundamentalInstance = current$$1.stateNode;
  18608. if (fundamentalInstance !== null) {
  18609. unmountFundamentalComponent(fundamentalInstance);
  18610. current$$1.stateNode = null;
  18611. }
  18612. }
  18613. return;
  18614. }
  18615. case DehydratedFragment:
  18616. {
  18617. if (enableSuspenseCallback) {
  18618. var hydrationCallbacks = finishedRoot.hydrationCallbacks;
  18619. if (hydrationCallbacks !== null) {
  18620. var onDeleted = hydrationCallbacks.onDeleted;
  18621. if (onDeleted) {
  18622. onDeleted(current$$1.stateNode);
  18623. }
  18624. }
  18625. }
  18626. return;
  18627. }
  18628. case ScopeComponent:
  18629. {
  18630. if (enableScopeAPI) {
  18631. safelyDetachRef(current$$1);
  18632. }
  18633. }
  18634. }
  18635. }
  18636. function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) {
  18637. // While we're inside a removed host node we don't want to call
  18638. // removeChild on the inner nodes because they're removed by the top
  18639. // call anyway. We also want to call componentWillUnmount on all
  18640. // composites before this host node is removed from the tree. Therefore
  18641. // we do an inner loop while we're still inside the host node.
  18642. var node = root;
  18643. while (true) {
  18644. commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because they may contain more composite or host nodes.
  18645. // Skip portals because commitUnmount() currently visits them recursively.
  18646. if (node.child !== null && ( // If we use mutation we drill down into portals using commitUnmount above.
  18647. // If we don't use mutation we drill down into portals here instead.
  18648. !supportsMutation || node.tag !== HostPortal)) {
  18649. node.child.return = node;
  18650. node = node.child;
  18651. continue;
  18652. }
  18653. if (node === root) {
  18654. return;
  18655. }
  18656. while (node.sibling === null) {
  18657. if (node.return === null || node.return === root) {
  18658. return;
  18659. }
  18660. node = node.return;
  18661. }
  18662. node.sibling.return = node.return;
  18663. node = node.sibling;
  18664. }
  18665. }
  18666. function detachFiber(current$$1) {
  18667. var alternate = current$$1.alternate; // Cut off the return pointers to disconnect it from the tree. Ideally, we
  18668. // should clear the child pointer of the parent alternate to let this
  18669. // get GC:ed but we don't know which for sure which parent is the current
  18670. // one so we'll settle for GC:ing the subtree of this child. This child
  18671. // itself will be GC:ed when the parent updates the next time.
  18672. current$$1.return = null;
  18673. current$$1.child = null;
  18674. current$$1.memoizedState = null;
  18675. current$$1.updateQueue = null;
  18676. current$$1.dependencies = null;
  18677. current$$1.alternate = null;
  18678. current$$1.firstEffect = null;
  18679. current$$1.lastEffect = null;
  18680. current$$1.pendingProps = null;
  18681. current$$1.memoizedProps = null;
  18682. if (alternate !== null) {
  18683. detachFiber(alternate);
  18684. }
  18685. }
  18686. function emptyPortalContainer(current$$1) {
  18687. if (!supportsPersistence) {
  18688. return;
  18689. }
  18690. var portal = current$$1.stateNode;
  18691. var containerInfo = portal.containerInfo;
  18692. var emptyChildSet = createContainerChildSet(containerInfo);
  18693. replaceContainerChildren(containerInfo, emptyChildSet);
  18694. }
  18695. function commitContainer(finishedWork) {
  18696. if (!supportsPersistence) {
  18697. return;
  18698. }
  18699. switch (finishedWork.tag) {
  18700. case ClassComponent:
  18701. case HostComponent:
  18702. case HostText:
  18703. case FundamentalComponent:
  18704. {
  18705. return;
  18706. }
  18707. case HostRoot:
  18708. case HostPortal:
  18709. {
  18710. var portalOrRoot = finishedWork.stateNode;
  18711. var containerInfo = portalOrRoot.containerInfo,
  18712. pendingChildren = portalOrRoot.pendingChildren;
  18713. replaceContainerChildren(containerInfo, pendingChildren);
  18714. return;
  18715. }
  18716. default:
  18717. {
  18718. {
  18719. {
  18720. throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.");
  18721. }
  18722. }
  18723. }
  18724. }
  18725. }
  18726. function getHostParentFiber(fiber) {
  18727. var parent = fiber.return;
  18728. while (parent !== null) {
  18729. if (isHostParent(parent)) {
  18730. return parent;
  18731. }
  18732. parent = parent.return;
  18733. }
  18734. {
  18735. {
  18736. throw Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.");
  18737. }
  18738. }
  18739. }
  18740. function isHostParent(fiber) {
  18741. return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal;
  18742. }
  18743. function getHostSibling(fiber) {
  18744. // We're going to search forward into the tree until we find a sibling host
  18745. // node. Unfortunately, if multiple insertions are done in a row we have to
  18746. // search past them. This leads to exponential search for the next sibling.
  18747. // TODO: Find a more efficient way to do this.
  18748. var node = fiber;
  18749. siblings: while (true) {
  18750. // If we didn't find anything, let's try the next sibling.
  18751. while (node.sibling === null) {
  18752. if (node.return === null || isHostParent(node.return)) {
  18753. // If we pop out of the root or hit the parent the fiber we are the
  18754. // last sibling.
  18755. return null;
  18756. }
  18757. node = node.return;
  18758. }
  18759. node.sibling.return = node.return;
  18760. node = node.sibling;
  18761. while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedFragment) {
  18762. // If it is not host node and, we might have a host node inside it.
  18763. // Try to search down until we find one.
  18764. if (node.effectTag & Placement) {
  18765. // If we don't have a child, try the siblings instead.
  18766. continue siblings;
  18767. } // If we don't have a child, try the siblings instead.
  18768. // We also skip portals because they are not part of this host tree.
  18769. if (node.child === null || node.tag === HostPortal) {
  18770. continue siblings;
  18771. } else {
  18772. node.child.return = node;
  18773. node = node.child;
  18774. }
  18775. } // Check if this host node is stable or about to be placed.
  18776. if (!(node.effectTag & Placement)) {
  18777. // Found it!
  18778. return node.stateNode;
  18779. }
  18780. }
  18781. }
  18782. function commitPlacement(finishedWork) {
  18783. if (!supportsMutation) {
  18784. return;
  18785. } // Recursively insert all host nodes into the parent.
  18786. var parentFiber = getHostParentFiber(finishedWork); // Note: these two variables *must* always be updated together.
  18787. var parent;
  18788. var isContainer;
  18789. var parentStateNode = parentFiber.stateNode;
  18790. switch (parentFiber.tag) {
  18791. case HostComponent:
  18792. parent = parentStateNode;
  18793. isContainer = false;
  18794. break;
  18795. case HostRoot:
  18796. parent = parentStateNode.containerInfo;
  18797. isContainer = true;
  18798. break;
  18799. case HostPortal:
  18800. parent = parentStateNode.containerInfo;
  18801. isContainer = true;
  18802. break;
  18803. case FundamentalComponent:
  18804. if (enableFundamentalAPI) {
  18805. parent = parentStateNode.instance;
  18806. isContainer = false;
  18807. }
  18808. // eslint-disable-next-line-no-fallthrough
  18809. default:
  18810. {
  18811. {
  18812. throw Error("Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.");
  18813. }
  18814. }
  18815. }
  18816. if (parentFiber.effectTag & ContentReset) {
  18817. // Reset the text content of the parent before doing any insertions
  18818. resetTextContent(parent); // Clear ContentReset from the effect tag
  18819. parentFiber.effectTag &= ~ContentReset;
  18820. }
  18821. var before = getHostSibling(finishedWork); // We only have the top Fiber that was inserted but we need to recurse down its
  18822. // children to find all the terminal nodes.
  18823. var node = finishedWork;
  18824. while (true) {
  18825. var isHost = node.tag === HostComponent || node.tag === HostText;
  18826. if (isHost || enableFundamentalAPI && node.tag === FundamentalComponent) {
  18827. var stateNode = isHost ? node.stateNode : node.stateNode.instance;
  18828. if (before) {
  18829. if (isContainer) {
  18830. insertInContainerBefore(parent, stateNode, before);
  18831. } else {
  18832. insertBefore(parent, stateNode, before);
  18833. }
  18834. } else {
  18835. if (isContainer) {
  18836. appendChildToContainer(parent, stateNode);
  18837. } else {
  18838. appendChild(parent, stateNode);
  18839. }
  18840. }
  18841. } else if (node.tag === HostPortal) {// If the insertion itself is a portal, then we don't want to traverse
  18842. // down its children. Instead, we'll get insertions from each child in
  18843. // the portal directly.
  18844. } else if (node.child !== null) {
  18845. node.child.return = node;
  18846. node = node.child;
  18847. continue;
  18848. }
  18849. if (node === finishedWork) {
  18850. return;
  18851. }
  18852. while (node.sibling === null) {
  18853. if (node.return === null || node.return === finishedWork) {
  18854. return;
  18855. }
  18856. node = node.return;
  18857. }
  18858. node.sibling.return = node.return;
  18859. node = node.sibling;
  18860. }
  18861. }
  18862. function unmountHostComponents(finishedRoot, current$$1, renderPriorityLevel) {
  18863. // We only have the top Fiber that was deleted but we need to recurse down its
  18864. // children to find all the terminal nodes.
  18865. var node = current$$1; // Each iteration, currentParent is populated with node's host parent if not
  18866. // currentParentIsValid.
  18867. var currentParentIsValid = false; // Note: these two variables *must* always be updated together.
  18868. var currentParent;
  18869. var currentParentIsContainer;
  18870. while (true) {
  18871. if (!currentParentIsValid) {
  18872. var parent = node.return;
  18873. findParent: while (true) {
  18874. if (!(parent !== null)) {
  18875. {
  18876. throw Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.");
  18877. }
  18878. }
  18879. var parentStateNode = parent.stateNode;
  18880. switch (parent.tag) {
  18881. case HostComponent:
  18882. currentParent = parentStateNode;
  18883. currentParentIsContainer = false;
  18884. break findParent;
  18885. case HostRoot:
  18886. currentParent = parentStateNode.containerInfo;
  18887. currentParentIsContainer = true;
  18888. break findParent;
  18889. case HostPortal:
  18890. currentParent = parentStateNode.containerInfo;
  18891. currentParentIsContainer = true;
  18892. break findParent;
  18893. case FundamentalComponent:
  18894. if (enableFundamentalAPI) {
  18895. currentParent = parentStateNode.instance;
  18896. currentParentIsContainer = false;
  18897. }
  18898. }
  18899. parent = parent.return;
  18900. }
  18901. currentParentIsValid = true;
  18902. }
  18903. if (node.tag === HostComponent || node.tag === HostText) {
  18904. commitNestedUnmounts(finishedRoot, node, renderPriorityLevel); // After all the children have unmounted, it is now safe to remove the
  18905. // node from the tree.
  18906. if (currentParentIsContainer) {
  18907. removeChildFromContainer(currentParent, node.stateNode);
  18908. } else {
  18909. removeChild(currentParent, node.stateNode);
  18910. } // Don't visit children because we already visited them.
  18911. } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
  18912. var fundamentalNode = node.stateNode.instance;
  18913. commitNestedUnmounts(finishedRoot, node, renderPriorityLevel); // After all the children have unmounted, it is now safe to remove the
  18914. // node from the tree.
  18915. if (currentParentIsContainer) {
  18916. removeChildFromContainer(currentParent, fundamentalNode);
  18917. } else {
  18918. removeChild(currentParent, fundamentalNode);
  18919. }
  18920. } else if (enableSuspenseServerRenderer && node.tag === DehydratedFragment) {
  18921. if (enableSuspenseCallback) {
  18922. var hydrationCallbacks = finishedRoot.hydrationCallbacks;
  18923. if (hydrationCallbacks !== null) {
  18924. var onDeleted = hydrationCallbacks.onDeleted;
  18925. if (onDeleted) {
  18926. onDeleted(node.stateNode);
  18927. }
  18928. }
  18929. } // Delete the dehydrated suspense boundary and all of its content.
  18930. if (currentParentIsContainer) {
  18931. clearSuspenseBoundaryFromContainer(currentParent, node.stateNode);
  18932. } else {
  18933. clearSuspenseBoundary(currentParent, node.stateNode);
  18934. }
  18935. } else if (node.tag === HostPortal) {
  18936. if (node.child !== null) {
  18937. // When we go into a portal, it becomes the parent to remove from.
  18938. // We will reassign it back when we pop the portal on the way up.
  18939. currentParent = node.stateNode.containerInfo;
  18940. currentParentIsContainer = true; // Visit children because portals might contain host components.
  18941. node.child.return = node;
  18942. node = node.child;
  18943. continue;
  18944. }
  18945. } else {
  18946. commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because we may find more host components below.
  18947. if (node.child !== null) {
  18948. node.child.return = node;
  18949. node = node.child;
  18950. continue;
  18951. }
  18952. }
  18953. if (node === current$$1) {
  18954. return;
  18955. }
  18956. while (node.sibling === null) {
  18957. if (node.return === null || node.return === current$$1) {
  18958. return;
  18959. }
  18960. node = node.return;
  18961. if (node.tag === HostPortal) {
  18962. // When we go out of the portal, we need to restore the parent.
  18963. // Since we don't keep a stack of them, we will search for it.
  18964. currentParentIsValid = false;
  18965. }
  18966. }
  18967. node.sibling.return = node.return;
  18968. node = node.sibling;
  18969. }
  18970. }
  18971. function commitDeletion(finishedRoot, current$$1, renderPriorityLevel) {
  18972. if (supportsMutation) {
  18973. // Recursively delete all host nodes from the parent.
  18974. // Detach refs and call componentWillUnmount() on the whole subtree.
  18975. unmountHostComponents(finishedRoot, current$$1, renderPriorityLevel);
  18976. } else {
  18977. // Detach refs and call componentWillUnmount() on the whole subtree.
  18978. commitNestedUnmounts(finishedRoot, current$$1, renderPriorityLevel);
  18979. }
  18980. detachFiber(current$$1);
  18981. }
  18982. function commitWork(current$$1, finishedWork) {
  18983. if (!supportsMutation) {
  18984. switch (finishedWork.tag) {
  18985. case FunctionComponent:
  18986. case ForwardRef:
  18987. case MemoComponent:
  18988. case SimpleMemoComponent:
  18989. {
  18990. // Note: We currently never use MountMutation, but useLayout uses
  18991. // UnmountMutation.
  18992. commitHookEffectList(UnmountMutation, MountMutation, finishedWork);
  18993. return;
  18994. }
  18995. case Profiler:
  18996. {
  18997. return;
  18998. }
  18999. case SuspenseComponent:
  19000. {
  19001. commitSuspenseComponent(finishedWork);
  19002. attachSuspenseRetryListeners(finishedWork);
  19003. return;
  19004. }
  19005. case SuspenseListComponent:
  19006. {
  19007. attachSuspenseRetryListeners(finishedWork);
  19008. return;
  19009. }
  19010. case HostRoot:
  19011. {
  19012. if (supportsHydration) {
  19013. var root = finishedWork.stateNode;
  19014. if (root.hydrate) {
  19015. // We've just hydrated. No need to hydrate again.
  19016. root.hydrate = false;
  19017. commitHydratedContainer(root.containerInfo);
  19018. }
  19019. }
  19020. break;
  19021. }
  19022. }
  19023. commitContainer(finishedWork);
  19024. return;
  19025. }
  19026. switch (finishedWork.tag) {
  19027. case FunctionComponent:
  19028. case ForwardRef:
  19029. case MemoComponent:
  19030. case SimpleMemoComponent:
  19031. {
  19032. // Note: We currently never use MountMutation, but useLayout uses
  19033. // UnmountMutation.
  19034. commitHookEffectList(UnmountMutation, MountMutation, finishedWork);
  19035. return;
  19036. }
  19037. case ClassComponent:
  19038. {
  19039. return;
  19040. }
  19041. case HostComponent:
  19042. {
  19043. var instance = finishedWork.stateNode;
  19044. if (instance != null) {
  19045. // Commit the work prepared earlier.
  19046. var newProps = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps
  19047. // as the newProps. The updatePayload will contain the real change in
  19048. // this case.
  19049. var oldProps = current$$1 !== null ? current$$1.memoizedProps : newProps;
  19050. var type = finishedWork.type; // TODO: Type the updateQueue to be specific to host components.
  19051. var updatePayload = finishedWork.updateQueue;
  19052. finishedWork.updateQueue = null;
  19053. if (updatePayload !== null) {
  19054. commitUpdate(instance, updatePayload, type, oldProps, newProps, finishedWork);
  19055. }
  19056. if (enableFlareAPI) {
  19057. var prevListeners = oldProps.listeners;
  19058. var nextListeners = newProps.listeners;
  19059. if (prevListeners !== nextListeners) {
  19060. updateEventListeners(nextListeners, finishedWork, null);
  19061. }
  19062. }
  19063. }
  19064. return;
  19065. }
  19066. case HostText:
  19067. {
  19068. if (!(finishedWork.stateNode !== null)) {
  19069. {
  19070. throw Error("This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue.");
  19071. }
  19072. }
  19073. var textInstance = finishedWork.stateNode;
  19074. var newText = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps
  19075. // as the newProps. The updatePayload will contain the real change in
  19076. // this case.
  19077. var oldText = current$$1 !== null ? current$$1.memoizedProps : newText;
  19078. commitTextUpdate(textInstance, oldText, newText);
  19079. return;
  19080. }
  19081. case HostRoot:
  19082. {
  19083. if (supportsHydration) {
  19084. var _root = finishedWork.stateNode;
  19085. if (_root.hydrate) {
  19086. // We've just hydrated. No need to hydrate again.
  19087. _root.hydrate = false;
  19088. commitHydratedContainer(_root.containerInfo);
  19089. }
  19090. }
  19091. return;
  19092. }
  19093. case Profiler:
  19094. {
  19095. return;
  19096. }
  19097. case SuspenseComponent:
  19098. {
  19099. commitSuspenseComponent(finishedWork);
  19100. attachSuspenseRetryListeners(finishedWork);
  19101. return;
  19102. }
  19103. case SuspenseListComponent:
  19104. {
  19105. attachSuspenseRetryListeners(finishedWork);
  19106. return;
  19107. }
  19108. case IncompleteClassComponent:
  19109. {
  19110. return;
  19111. }
  19112. case FundamentalComponent:
  19113. {
  19114. if (enableFundamentalAPI) {
  19115. var fundamentalInstance = finishedWork.stateNode;
  19116. updateFundamentalComponent(fundamentalInstance);
  19117. }
  19118. return;
  19119. }
  19120. case ScopeComponent:
  19121. {
  19122. if (enableScopeAPI) {
  19123. var scopeInstance = finishedWork.stateNode;
  19124. scopeInstance.fiber = finishedWork;
  19125. if (enableFlareAPI) {
  19126. var _newProps = finishedWork.memoizedProps;
  19127. var _oldProps = current$$1 !== null ? current$$1.memoizedProps : _newProps;
  19128. var _prevListeners = _oldProps.listeners;
  19129. var _nextListeners = _newProps.listeners;
  19130. if (_prevListeners !== _nextListeners) {
  19131. updateEventListeners(_nextListeners, finishedWork, null);
  19132. }
  19133. }
  19134. }
  19135. return;
  19136. }
  19137. default:
  19138. {
  19139. {
  19140. {
  19141. throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.");
  19142. }
  19143. }
  19144. }
  19145. }
  19146. }
  19147. function commitSuspenseComponent(finishedWork) {
  19148. var newState = finishedWork.memoizedState;
  19149. var newDidTimeout;
  19150. var primaryChildParent = finishedWork;
  19151. if (newState === null) {
  19152. newDidTimeout = false;
  19153. } else {
  19154. newDidTimeout = true;
  19155. primaryChildParent = finishedWork.child;
  19156. markCommitTimeOfFallback();
  19157. }
  19158. if (supportsMutation && primaryChildParent !== null) {
  19159. hideOrUnhideAllChildren(primaryChildParent, newDidTimeout);
  19160. }
  19161. if (enableSuspenseCallback && newState !== null) {
  19162. var suspenseCallback = finishedWork.memoizedProps.suspenseCallback;
  19163. if (typeof suspenseCallback === 'function') {
  19164. var thenables = finishedWork.updateQueue;
  19165. if (thenables !== null) {
  19166. suspenseCallback(new Set(thenables));
  19167. }
  19168. } else {
  19169. if (suspenseCallback !== undefined) {
  19170. warning$1(false, 'Unexpected type for suspenseCallback.');
  19171. }
  19172. }
  19173. }
  19174. }
  19175. function commitSuspenseHydrationCallbacks(finishedRoot, finishedWork) {
  19176. if (!supportsHydration) {
  19177. return;
  19178. }
  19179. var newState = finishedWork.memoizedState;
  19180. if (newState === null) {
  19181. var current$$1 = finishedWork.alternate;
  19182. if (current$$1 !== null) {
  19183. var prevState = current$$1.memoizedState;
  19184. if (prevState !== null) {
  19185. var suspenseInstance = prevState.dehydrated;
  19186. if (suspenseInstance !== null) {
  19187. commitHydratedSuspenseInstance(suspenseInstance);
  19188. if (enableSuspenseCallback) {
  19189. var hydrationCallbacks = finishedRoot.hydrationCallbacks;
  19190. if (hydrationCallbacks !== null) {
  19191. var onHydrated = hydrationCallbacks.onHydrated;
  19192. if (onHydrated) {
  19193. onHydrated(suspenseInstance);
  19194. }
  19195. }
  19196. }
  19197. }
  19198. }
  19199. }
  19200. }
  19201. }
  19202. function attachSuspenseRetryListeners(finishedWork) {
  19203. // If this boundary just timed out, then it will have a set of thenables.
  19204. // For each thenable, attach a listener so that when it resolves, React
  19205. // attempts to re-render the boundary in the primary (pre-timeout) state.
  19206. var thenables = finishedWork.updateQueue;
  19207. if (thenables !== null) {
  19208. finishedWork.updateQueue = null;
  19209. var retryCache = finishedWork.stateNode;
  19210. if (retryCache === null) {
  19211. retryCache = finishedWork.stateNode = new PossiblyWeakSet();
  19212. }
  19213. thenables.forEach(function (thenable) {
  19214. // Memoize using the boundary fiber to prevent redundant listeners.
  19215. var retry = resolveRetryThenable.bind(null, finishedWork, thenable);
  19216. if (!retryCache.has(thenable)) {
  19217. if (enableSchedulerTracing) {
  19218. if (thenable.__reactDoNotTraceInteractions !== true) {
  19219. retry = tracing.unstable_wrap(retry);
  19220. }
  19221. }
  19222. retryCache.add(thenable);
  19223. thenable.then(retry, retry);
  19224. }
  19225. });
  19226. }
  19227. }
  19228. function commitResetTextContent(current$$1) {
  19229. if (!supportsMutation) {
  19230. return;
  19231. }
  19232. resetTextContent(current$$1.stateNode);
  19233. }
  19234. var PossiblyWeakMap$1 = typeof WeakMap === 'function' ? WeakMap : Map;
  19235. function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
  19236. var update = createUpdate(expirationTime, null); // Unmount the root by rendering null.
  19237. update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property
  19238. // being called "element".
  19239. update.payload = {
  19240. element: null
  19241. };
  19242. var error = errorInfo.value;
  19243. update.callback = function () {
  19244. onUncaughtError(error);
  19245. logError(fiber, errorInfo);
  19246. };
  19247. return update;
  19248. }
  19249. function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
  19250. var update = createUpdate(expirationTime, null);
  19251. update.tag = CaptureUpdate;
  19252. var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
  19253. if (typeof getDerivedStateFromError === 'function') {
  19254. var error = errorInfo.value;
  19255. update.payload = function () {
  19256. logError(fiber, errorInfo);
  19257. return getDerivedStateFromError(error);
  19258. };
  19259. }
  19260. var inst = fiber.stateNode;
  19261. if (inst !== null && typeof inst.componentDidCatch === 'function') {
  19262. update.callback = function callback() {
  19263. {
  19264. markFailedErrorBoundaryForHotReloading(fiber);
  19265. }
  19266. if (typeof getDerivedStateFromError !== 'function') {
  19267. // To preserve the preexisting retry behavior of error boundaries,
  19268. // we keep track of which ones already failed during this batch.
  19269. // This gets reset before we yield back to the browser.
  19270. // TODO: Warn in strict mode if getDerivedStateFromError is
  19271. // not defined.
  19272. markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined
  19273. logError(fiber, errorInfo);
  19274. }
  19275. var error = errorInfo.value;
  19276. var stack = errorInfo.stack;
  19277. this.componentDidCatch(error, {
  19278. componentStack: stack !== null ? stack : ''
  19279. });
  19280. {
  19281. if (typeof getDerivedStateFromError !== 'function') {
  19282. // If componentDidCatch is the only error boundary method defined,
  19283. // then it needs to call setState to recover from errors.
  19284. // If no state update is scheduled then the boundary will swallow the error.
  19285. !(fiber.expirationTime === Sync) ? warningWithoutStack$1(false, '%s: Error boundaries should implement getDerivedStateFromError(). ' + 'In that method, return a state update to display an error message or fallback UI.', getComponentName(fiber.type) || 'Unknown') : void 0;
  19286. }
  19287. }
  19288. };
  19289. } else {
  19290. update.callback = function () {
  19291. markFailedErrorBoundaryForHotReloading(fiber);
  19292. };
  19293. }
  19294. return update;
  19295. }
  19296. function attachPingListener(root, renderExpirationTime, thenable) {
  19297. // Attach a listener to the promise to "ping" the root and retry. But
  19298. // only if one does not already exist for the current render expiration
  19299. // time (which acts like a "thread ID" here).
  19300. var pingCache = root.pingCache;
  19301. var threadIDs;
  19302. if (pingCache === null) {
  19303. pingCache = root.pingCache = new PossiblyWeakMap$1();
  19304. threadIDs = new Set();
  19305. pingCache.set(thenable, threadIDs);
  19306. } else {
  19307. threadIDs = pingCache.get(thenable);
  19308. if (threadIDs === undefined) {
  19309. threadIDs = new Set();
  19310. pingCache.set(thenable, threadIDs);
  19311. }
  19312. }
  19313. if (!threadIDs.has(renderExpirationTime)) {
  19314. // Memoize using the thread ID to prevent redundant listeners.
  19315. threadIDs.add(renderExpirationTime);
  19316. var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
  19317. thenable.then(ping, ping);
  19318. }
  19319. }
  19320. function throwException(root, returnFiber, sourceFiber, value, renderExpirationTime) {
  19321. // The source fiber did not complete.
  19322. sourceFiber.effectTag |= Incomplete; // Its effect list is no longer valid.
  19323. sourceFiber.firstEffect = sourceFiber.lastEffect = null;
  19324. if (value !== null && typeof value === 'object' && typeof value.then === 'function') {
  19325. // This is a thenable.
  19326. var thenable = value;
  19327. checkForWrongSuspensePriorityInDEV(sourceFiber);
  19328. var hasInvisibleParentBoundary = hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext); // Schedule the nearest Suspense to re-render the timed out view.
  19329. var _workInProgress = returnFiber;
  19330. do {
  19331. if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)) {
  19332. // Found the nearest boundary.
  19333. // Stash the promise on the boundary fiber. If the boundary times out, we'll
  19334. // attach another listener to flip the boundary back to its normal state.
  19335. var thenables = _workInProgress.updateQueue;
  19336. if (thenables === null) {
  19337. var updateQueue = new Set();
  19338. updateQueue.add(thenable);
  19339. _workInProgress.updateQueue = updateQueue;
  19340. } else {
  19341. thenables.add(thenable);
  19342. } // If the boundary is outside of blocking mode, we should *not*
  19343. // suspend the commit. Pretend as if the suspended component rendered
  19344. // null and keep rendering. In the commit phase, we'll schedule a
  19345. // subsequent synchronous update to re-render the Suspense.
  19346. //
  19347. // Note: It doesn't matter whether the component that suspended was
  19348. // inside a blocking mode tree. If the Suspense is outside of it, we
  19349. // should *not* suspend the commit.
  19350. if ((_workInProgress.mode & BlockingMode) === NoMode) {
  19351. _workInProgress.effectTag |= DidCapture; // We're going to commit this fiber even though it didn't complete.
  19352. // But we shouldn't call any lifecycle methods or callbacks. Remove
  19353. // all lifecycle effect tags.
  19354. sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete);
  19355. if (sourceFiber.tag === ClassComponent) {
  19356. var currentSourceFiber = sourceFiber.alternate;
  19357. if (currentSourceFiber === null) {
  19358. // This is a new mount. Change the tag so it's not mistaken for a
  19359. // completed class component. For example, we should not call
  19360. // componentWillUnmount if it is deleted.
  19361. sourceFiber.tag = IncompleteClassComponent;
  19362. } else {
  19363. // When we try rendering again, we should not reuse the current fiber,
  19364. // since it's known to be in an inconsistent state. Use a force update to
  19365. // prevent a bail out.
  19366. var update = createUpdate(Sync, null);
  19367. update.tag = ForceUpdate;
  19368. enqueueUpdate(sourceFiber, update);
  19369. }
  19370. } // The source fiber did not complete. Mark it with Sync priority to
  19371. // indicate that it still has pending work.
  19372. sourceFiber.expirationTime = Sync; // Exit without suspending.
  19373. return;
  19374. } // Confirmed that the boundary is in a concurrent mode tree. Continue
  19375. // with the normal suspend path.
  19376. //
  19377. // After this we'll use a set of heuristics to determine whether this
  19378. // render pass will run to completion or restart or "suspend" the commit.
  19379. // The actual logic for this is spread out in different places.
  19380. //
  19381. // This first principle is that if we're going to suspend when we complete
  19382. // a root, then we should also restart if we get an update or ping that
  19383. // might unsuspend it, and vice versa. The only reason to suspend is
  19384. // because you think you might want to restart before committing. However,
  19385. // it doesn't make sense to restart only while in the period we're suspended.
  19386. //
  19387. // Restarting too aggressively is also not good because it starves out any
  19388. // intermediate loading state. So we use heuristics to determine when.
  19389. // Suspense Heuristics
  19390. //
  19391. // If nothing threw a Promise or all the same fallbacks are already showing,
  19392. // then don't suspend/restart.
  19393. //
  19394. // If this is an initial render of a new tree of Suspense boundaries and
  19395. // those trigger a fallback, then don't suspend/restart. We want to ensure
  19396. // that we can show the initial loading state as quickly as possible.
  19397. //
  19398. // If we hit a "Delayed" case, such as when we'd switch from content back into
  19399. // a fallback, then we should always suspend/restart. SuspenseConfig applies to
  19400. // this case. If none is defined, JND is used instead.
  19401. //
  19402. // If we're already showing a fallback and it gets "retried", allowing us to show
  19403. // another level, but there's still an inner boundary that would show a fallback,
  19404. // then we suspend/restart for 500ms since the last time we showed a fallback
  19405. // anywhere in the tree. This effectively throttles progressive loading into a
  19406. // consistent train of commits. This also gives us an opportunity to restart to
  19407. // get to the completed state slightly earlier.
  19408. //
  19409. // If there's ambiguity due to batching it's resolved in preference of:
  19410. // 1) "delayed", 2) "initial render", 3) "retry".
  19411. //
  19412. // We want to ensure that a "busy" state doesn't get force committed. We want to
  19413. // ensure that new initial loading states can commit as soon as possible.
  19414. attachPingListener(root, renderExpirationTime, thenable);
  19415. _workInProgress.effectTag |= ShouldCapture;
  19416. _workInProgress.expirationTime = renderExpirationTime;
  19417. return;
  19418. } // This boundary already captured during this render. Continue to the next
  19419. // boundary.
  19420. _workInProgress = _workInProgress.return;
  19421. } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode.
  19422. // TODO: Use invariant so the message is stripped in prod?
  19423. value = new Error((getComponentName(sourceFiber.type) || 'A React component') + ' suspended while rendering, but no fallback UI was specified.\n' + '\n' + 'Add a <Suspense fallback=...> component higher in the tree to ' + 'provide a loading indicator or placeholder to display.' + getStackByFiberInDevAndProd(sourceFiber));
  19424. } // We didn't find a boundary that could handle this type of exception. Start
  19425. // over and traverse parent path again, this time treating the exception
  19426. // as an error.
  19427. renderDidError();
  19428. value = createCapturedValue(value, sourceFiber);
  19429. var workInProgress = returnFiber;
  19430. do {
  19431. switch (workInProgress.tag) {
  19432. case HostRoot:
  19433. {
  19434. var _errorInfo = value;
  19435. workInProgress.effectTag |= ShouldCapture;
  19436. workInProgress.expirationTime = renderExpirationTime;
  19437. var _update = createRootErrorUpdate(workInProgress, _errorInfo, renderExpirationTime);
  19438. enqueueCapturedUpdate(workInProgress, _update);
  19439. return;
  19440. }
  19441. case ClassComponent:
  19442. // Capture and retry
  19443. var errorInfo = value;
  19444. var ctor = workInProgress.type;
  19445. var instance = workInProgress.stateNode;
  19446. if ((workInProgress.effectTag & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) {
  19447. workInProgress.effectTag |= ShouldCapture;
  19448. workInProgress.expirationTime = renderExpirationTime; // Schedule the error boundary to re-render using updated state
  19449. var _update2 = createClassErrorUpdate(workInProgress, errorInfo, renderExpirationTime);
  19450. enqueueCapturedUpdate(workInProgress, _update2);
  19451. return;
  19452. }
  19453. break;
  19454. default:
  19455. break;
  19456. }
  19457. workInProgress = workInProgress.return;
  19458. } while (workInProgress !== null);
  19459. }
  19460. var ceil = Math.ceil;
  19461. var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
  19462. var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner;
  19463. var IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing;
  19464. var NoContext =
  19465. /* */
  19466. 0;
  19467. var BatchedContext =
  19468. /* */
  19469. 1;
  19470. var EventContext =
  19471. /* */
  19472. 2;
  19473. var DiscreteEventContext =
  19474. /* */
  19475. 4;
  19476. var LegacyUnbatchedContext =
  19477. /* */
  19478. 8;
  19479. var RenderContext =
  19480. /* */
  19481. 16;
  19482. var CommitContext =
  19483. /* */
  19484. 32;
  19485. var RootIncomplete = 0;
  19486. var RootFatalErrored = 1;
  19487. var RootErrored = 2;
  19488. var RootSuspended = 3;
  19489. var RootSuspendedWithDelay = 4;
  19490. var RootCompleted = 5;
  19491. // Describes where we are in the React execution stack
  19492. var executionContext = NoContext; // The root we're working on
  19493. var workInProgressRoot = null; // The fiber we're working on
  19494. var workInProgress = null; // The expiration time we're rendering
  19495. var renderExpirationTime = NoWork; // Whether to root completed, errored, suspended, etc.
  19496. var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown
  19497. var workInProgressRootFatalError = null; // Most recent event time among processed updates during this render.
  19498. // This is conceptually a time stamp but expressed in terms of an ExpirationTime
  19499. // because we deal mostly with expiration times in the hot path, so this avoids
  19500. // the conversion happening in the hot path.
  19501. var workInProgressRootLatestProcessedExpirationTime = Sync;
  19502. var workInProgressRootLatestSuspenseTimeout = Sync;
  19503. var workInProgressRootCanSuspendUsingConfig = null; // The work left over by components that were visited during this render. Only
  19504. // includes unprocessed updates, not work in bailed out children.
  19505. var workInProgressRootNextUnprocessedUpdateTime = NoWork; // If we're pinged while rendering we don't always restart immediately.
  19506. // This flag determines if it might be worthwhile to restart if an opportunity
  19507. // happens latere.
  19508. var workInProgressRootHasPendingPing = false; // The most recent time we committed a fallback. This lets us ensure a train
  19509. // model where we don't commit new loading states in too quick succession.
  19510. var globalMostRecentFallbackTime = 0;
  19511. var FALLBACK_THROTTLE_MS = 500;
  19512. var nextEffect = null;
  19513. var hasUncaughtError = false;
  19514. var firstUncaughtError = null;
  19515. var legacyErrorBoundariesThatAlreadyFailed = null;
  19516. var rootDoesHavePassiveEffects = false;
  19517. var rootWithPendingPassiveEffects = null;
  19518. var pendingPassiveEffectsRenderPriority = NoPriority;
  19519. var pendingPassiveEffectsExpirationTime = NoWork;
  19520. var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates
  19521. var NESTED_UPDATE_LIMIT = 50;
  19522. var nestedUpdateCount = 0;
  19523. var rootWithNestedUpdates = null;
  19524. var NESTED_PASSIVE_UPDATE_LIMIT = 50;
  19525. var nestedPassiveUpdateCount = 0;
  19526. var interruptedBy = null; // Marks the need to reschedule pending interactions at these expiration times
  19527. // during the commit phase. This enables them to be traced across components
  19528. // that spawn new work during render. E.g. hidden boundaries, suspended SSR
  19529. // hydration or SuspenseList.
  19530. var spawnedWorkDuringRender = null; // Expiration times are computed by adding to the current time (the start
  19531. // time). However, if two updates are scheduled within the same event, we
  19532. // should treat their start times as simultaneous, even if the actual clock
  19533. // time has advanced between the first and second call.
  19534. // In other words, because expiration times determine how updates are batched,
  19535. // we want all updates of like priority that occur within the same event to
  19536. // receive the same expiration time. Otherwise we get tearing.
  19537. var currentEventTime = NoWork;
  19538. function requestCurrentTimeForUpdate() {
  19539. if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
  19540. // We're inside React, so it's fine to read the actual time.
  19541. return msToExpirationTime(now());
  19542. } // We're not inside React, so we may be in the middle of a browser event.
  19543. if (currentEventTime !== NoWork) {
  19544. // Use the same start time for all updates until we enter React again.
  19545. return currentEventTime;
  19546. } // This is the first update since React yielded. Compute a new start time.
  19547. currentEventTime = msToExpirationTime(now());
  19548. return currentEventTime;
  19549. }
  19550. function getCurrentTime() {
  19551. return msToExpirationTime(now());
  19552. }
  19553. function computeExpirationForFiber(currentTime, fiber, suspenseConfig) {
  19554. var mode = fiber.mode;
  19555. if ((mode & BlockingMode) === NoMode) {
  19556. return Sync;
  19557. }
  19558. var priorityLevel = getCurrentPriorityLevel();
  19559. if ((mode & ConcurrentMode) === NoMode) {
  19560. return priorityLevel === ImmediatePriority ? Sync : Batched;
  19561. }
  19562. if ((executionContext & RenderContext) !== NoContext) {
  19563. // Use whatever time we're already rendering
  19564. // TODO: Should there be a way to opt out, like with `runWithPriority`?
  19565. return renderExpirationTime;
  19566. }
  19567. var expirationTime;
  19568. if (suspenseConfig !== null) {
  19569. // Compute an expiration time based on the Suspense timeout.
  19570. expirationTime = computeSuspenseExpiration(currentTime, suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION);
  19571. } else {
  19572. // Compute an expiration time based on the Scheduler priority.
  19573. switch (priorityLevel) {
  19574. case ImmediatePriority:
  19575. expirationTime = Sync;
  19576. break;
  19577. case UserBlockingPriority$2:
  19578. // TODO: Rename this to computeUserBlockingExpiration
  19579. expirationTime = computeInteractiveExpiration(currentTime);
  19580. break;
  19581. case NormalPriority:
  19582. case LowPriority:
  19583. // TODO: Handle LowPriority
  19584. // TODO: Rename this to... something better.
  19585. expirationTime = computeAsyncExpiration(currentTime);
  19586. break;
  19587. case IdlePriority:
  19588. expirationTime = Idle;
  19589. break;
  19590. default:
  19591. {
  19592. {
  19593. throw Error("Expected a valid priority level");
  19594. }
  19595. }
  19596. }
  19597. } // If we're in the middle of rendering a tree, do not update at the same
  19598. // expiration time that is already rendering.
  19599. // TODO: We shouldn't have to do this if the update is on a different root.
  19600. // Refactor computeExpirationForFiber + scheduleUpdate so we have access to
  19601. // the root when we check for this condition.
  19602. if (workInProgressRoot !== null && expirationTime === renderExpirationTime) {
  19603. // This is a trick to move this update into a separate batch
  19604. expirationTime -= 1;
  19605. }
  19606. return expirationTime;
  19607. }
  19608. function scheduleUpdateOnFiber(fiber, expirationTime) {
  19609. checkForNestedUpdates();
  19610. warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber);
  19611. var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime);
  19612. if (root === null) {
  19613. warnAboutUpdateOnUnmountedFiberInDEV(fiber);
  19614. return;
  19615. }
  19616. checkForInterruption(fiber, expirationTime);
  19617. recordScheduleUpdate(); // TODO: computeExpirationForFiber also reads the priority. Pass the
  19618. // priority as an argument to that function and this one.
  19619. var priorityLevel = getCurrentPriorityLevel();
  19620. if (expirationTime === Sync) {
  19621. if ( // Check if we're inside unbatchedUpdates
  19622. (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering
  19623. (executionContext & (RenderContext | CommitContext)) === NoContext) {
  19624. // Register pending interactions on the root to avoid losing traced interaction data.
  19625. schedulePendingInteractions(root, expirationTime); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed
  19626. // root inside of batchedUpdates should be synchronous, but layout updates
  19627. // should be deferred until the end of the batch.
  19628. performSyncWorkOnRoot(root);
  19629. } else {
  19630. ensureRootIsScheduled(root);
  19631. schedulePendingInteractions(root, expirationTime);
  19632. if (executionContext === NoContext) {
  19633. // Flush the synchronous work now, unless we're already working or inside
  19634. // a batch. This is intentionally inside scheduleUpdateOnFiber instead of
  19635. // scheduleCallbackForFiber to preserve the ability to schedule a callback
  19636. // without immediately flushing it. We only do this for user-initiated
  19637. // updates, to preserve historical behavior of legacy mode.
  19638. flushSyncCallbackQueue();
  19639. }
  19640. }
  19641. } else {
  19642. ensureRootIsScheduled(root);
  19643. schedulePendingInteractions(root, expirationTime);
  19644. }
  19645. if ((executionContext & DiscreteEventContext) !== NoContext && ( // Only updates at user-blocking priority or greater are considered
  19646. // discrete, even inside a discrete event.
  19647. priorityLevel === UserBlockingPriority$2 || priorityLevel === ImmediatePriority)) {
  19648. // This is the result of a discrete event. Track the lowest priority
  19649. // discrete update per root so we can flush them early, if needed.
  19650. if (rootsWithPendingDiscreteUpdates === null) {
  19651. rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]);
  19652. } else {
  19653. var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root);
  19654. if (lastDiscreteTime === undefined || lastDiscreteTime > expirationTime) {
  19655. rootsWithPendingDiscreteUpdates.set(root, expirationTime);
  19656. }
  19657. }
  19658. }
  19659. }
  19660. var scheduleWork = scheduleUpdateOnFiber; // This is split into a separate function so we can mark a fiber with pending
  19661. // work without treating it as a typical update that originates from an event;
  19662. // e.g. retrying a Suspense boundary isn't an update, but it does schedule work
  19663. // on a fiber.
  19664. function markUpdateTimeFromFiberToRoot(fiber, expirationTime) {
  19665. // Update the source fiber's expiration time
  19666. if (fiber.expirationTime < expirationTime) {
  19667. fiber.expirationTime = expirationTime;
  19668. }
  19669. var alternate = fiber.alternate;
  19670. if (alternate !== null && alternate.expirationTime < expirationTime) {
  19671. alternate.expirationTime = expirationTime;
  19672. } // Walk the parent path to the root and update the child expiration time.
  19673. var node = fiber.return;
  19674. var root = null;
  19675. if (node === null && fiber.tag === HostRoot) {
  19676. root = fiber.stateNode;
  19677. } else {
  19678. while (node !== null) {
  19679. alternate = node.alternate;
  19680. if (node.childExpirationTime < expirationTime) {
  19681. node.childExpirationTime = expirationTime;
  19682. if (alternate !== null && alternate.childExpirationTime < expirationTime) {
  19683. alternate.childExpirationTime = expirationTime;
  19684. }
  19685. } else if (alternate !== null && alternate.childExpirationTime < expirationTime) {
  19686. alternate.childExpirationTime = expirationTime;
  19687. }
  19688. if (node.return === null && node.tag === HostRoot) {
  19689. root = node.stateNode;
  19690. break;
  19691. }
  19692. node = node.return;
  19693. }
  19694. }
  19695. if (root !== null) {
  19696. if (workInProgressRoot === root) {
  19697. // Received an update to a tree that's in the middle of rendering. Mark
  19698. // that's unprocessed work on this root.
  19699. markUnprocessedUpdateTime(expirationTime);
  19700. if (workInProgressRootExitStatus === RootSuspendedWithDelay) {
  19701. // The root already suspended with a delay, which means this render
  19702. // definitely won't finish. Since we have a new update, let's mark it as
  19703. // suspended now, right before marking the incoming update. This has the
  19704. // effect of interrupting the current render and switching to the update.
  19705. // TODO: This happens to work when receiving an update during the render
  19706. // phase, because of the trick inside computeExpirationForFiber to
  19707. // subtract 1 from `renderExpirationTime` to move it into a
  19708. // separate bucket. But we should probably model it with an exception,
  19709. // using the same mechanism we use to force hydration of a subtree.
  19710. // TODO: This does not account for low pri updates that were already
  19711. // scheduled before the root started rendering. Need to track the next
  19712. // pending expiration time (perhaps by backtracking the return path) and
  19713. // then trigger a restart in the `renderDidSuspendDelayIfPossible` path.
  19714. markRootSuspendedAtTime(root, renderExpirationTime);
  19715. }
  19716. } // Mark that the root has a pending update.
  19717. markRootUpdatedAtTime(root, expirationTime);
  19718. }
  19719. return root;
  19720. }
  19721. function getNextRootExpirationTimeToWorkOn(root) {
  19722. // Determines the next expiration time that the root should render, taking
  19723. // into account levels that may be suspended, or levels that may have
  19724. // received a ping.
  19725. var lastExpiredTime = root.lastExpiredTime;
  19726. if (lastExpiredTime !== NoWork) {
  19727. return lastExpiredTime;
  19728. } // "Pending" refers to any update that hasn't committed yet, including if it
  19729. // suspended. The "suspended" range is therefore a subset.
  19730. var firstPendingTime = root.firstPendingTime;
  19731. if (!isRootSuspendedAtTime(root, firstPendingTime)) {
  19732. // The highest priority pending time is not suspended. Let's work on that.
  19733. return firstPendingTime;
  19734. } // If the first pending time is suspended, check if there's a lower priority
  19735. // pending level that we know about. Or check if we received a ping. Work
  19736. // on whichever is higher priority.
  19737. var lastPingedTime = root.lastPingedTime;
  19738. var nextKnownPendingLevel = root.nextKnownPendingLevel;
  19739. return lastPingedTime > nextKnownPendingLevel ? lastPingedTime : nextKnownPendingLevel;
  19740. } // Use this function to schedule a task for a root. There's only one task per
  19741. // root; if a task was already scheduled, we'll check to make sure the
  19742. // expiration time of the existing task is the same as the expiration time of
  19743. // the next level that the root has work on. This function is called on every
  19744. // update, and right before exiting a task.
  19745. function ensureRootIsScheduled(root) {
  19746. var lastExpiredTime = root.lastExpiredTime;
  19747. if (lastExpiredTime !== NoWork) {
  19748. // Special case: Expired work should flush synchronously.
  19749. root.callbackExpirationTime = Sync;
  19750. root.callbackPriority = ImmediatePriority;
  19751. root.callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
  19752. return;
  19753. }
  19754. var expirationTime = getNextRootExpirationTimeToWorkOn(root);
  19755. var existingCallbackNode = root.callbackNode;
  19756. if (expirationTime === NoWork) {
  19757. // There's nothing to work on.
  19758. if (existingCallbackNode !== null) {
  19759. root.callbackNode = null;
  19760. root.callbackExpirationTime = NoWork;
  19761. root.callbackPriority = NoPriority;
  19762. }
  19763. return;
  19764. } // TODO: If this is an update, we already read the current time. Pass the
  19765. // time as an argument.
  19766. var currentTime = requestCurrentTimeForUpdate();
  19767. var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime); // If there's an existing render task, confirm it has the correct priority and
  19768. // expiration time. Otherwise, we'll cancel it and schedule a new one.
  19769. if (existingCallbackNode !== null) {
  19770. var existingCallbackPriority = root.callbackPriority;
  19771. var existingCallbackExpirationTime = root.callbackExpirationTime;
  19772. if ( // Callback must have the exact same expiration time.
  19773. existingCallbackExpirationTime === expirationTime && // Callback must have greater or equal priority.
  19774. existingCallbackPriority >= priorityLevel) {
  19775. // Existing callback is sufficient.
  19776. return;
  19777. } // Need to schedule a new task.
  19778. // TODO: Instead of scheduling a new task, we should be able to change the
  19779. // priority of the existing one.
  19780. cancelCallback(existingCallbackNode);
  19781. }
  19782. root.callbackExpirationTime = expirationTime;
  19783. root.callbackPriority = priorityLevel;
  19784. var callbackNode;
  19785. if (expirationTime === Sync) {
  19786. // Sync React callbacks are scheduled on a special internal queue
  19787. callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
  19788. } else if (disableSchedulerTimeoutBasedOnReactExpirationTime) {
  19789. callbackNode = scheduleCallback(priorityLevel, performConcurrentWorkOnRoot.bind(null, root));
  19790. } else {
  19791. callbackNode = scheduleCallback(priorityLevel, performConcurrentWorkOnRoot.bind(null, root), // Compute a task timeout based on the expiration time. This also affects
  19792. // ordering because tasks are processed in timeout order.
  19793. {
  19794. timeout: expirationTimeToMs(expirationTime) - now()
  19795. });
  19796. }
  19797. root.callbackNode = callbackNode;
  19798. } // This is the entry point for every concurrent task, i.e. anything that
  19799. // goes through Scheduler.
  19800. function performConcurrentWorkOnRoot(root, didTimeout) {
  19801. // Since we know we're in a React event, we can clear the current
  19802. // event time. The next update will compute a new event time.
  19803. currentEventTime = NoWork;
  19804. if (didTimeout) {
  19805. // The render task took too long to complete. Mark the current time as
  19806. // expired to synchronously render all expired work in a single batch.
  19807. var currentTime = requestCurrentTimeForUpdate();
  19808. markRootExpiredAtTime(root, currentTime); // This will schedule a synchronous callback.
  19809. ensureRootIsScheduled(root);
  19810. return null;
  19811. } // Determine the next expiration time to work on, using the fields stored
  19812. // on the root.
  19813. var expirationTime = getNextRootExpirationTimeToWorkOn(root);
  19814. if (expirationTime !== NoWork) {
  19815. var originalCallbackNode = root.callbackNode;
  19816. if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
  19817. {
  19818. throw Error("Should not already be working.");
  19819. }
  19820. }
  19821. flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack
  19822. // and prepare a fresh one. Otherwise we'll continue where we left off.
  19823. if (root !== workInProgressRoot || expirationTime !== renderExpirationTime) {
  19824. prepareFreshStack(root, expirationTime);
  19825. startWorkOnPendingInteractions(root, expirationTime);
  19826. } // If we have a work-in-progress fiber, it means there's still work to do
  19827. // in this root.
  19828. if (workInProgress !== null) {
  19829. var prevExecutionContext = executionContext;
  19830. executionContext |= RenderContext;
  19831. var prevDispatcher = pushDispatcher(root);
  19832. var prevInteractions = pushInteractions(root);
  19833. startWorkLoopTimer(workInProgress);
  19834. do {
  19835. try {
  19836. workLoopConcurrent();
  19837. break;
  19838. } catch (thrownValue) {
  19839. handleError(root, thrownValue);
  19840. }
  19841. } while (true);
  19842. resetContextDependencies();
  19843. executionContext = prevExecutionContext;
  19844. popDispatcher(prevDispatcher);
  19845. if (enableSchedulerTracing) {
  19846. popInteractions(prevInteractions);
  19847. }
  19848. if (workInProgressRootExitStatus === RootFatalErrored) {
  19849. var fatalError = workInProgressRootFatalError;
  19850. stopInterruptedWorkLoopTimer();
  19851. prepareFreshStack(root, expirationTime);
  19852. markRootSuspendedAtTime(root, expirationTime);
  19853. ensureRootIsScheduled(root);
  19854. throw fatalError;
  19855. }
  19856. if (workInProgress !== null) {
  19857. // There's still work left over. Exit without committing.
  19858. stopInterruptedWorkLoopTimer();
  19859. } else {
  19860. // We now have a consistent tree. The next step is either to commit it,
  19861. // or, if something suspended, wait to commit it after a timeout.
  19862. stopFinishedWorkLoopTimer();
  19863. var finishedWork = root.finishedWork = root.current.alternate;
  19864. root.finishedExpirationTime = expirationTime;
  19865. finishConcurrentRender(root, finishedWork, workInProgressRootExitStatus, expirationTime);
  19866. }
  19867. ensureRootIsScheduled(root);
  19868. if (root.callbackNode === originalCallbackNode) {
  19869. // The task node scheduled for this root is the same one that's
  19870. // currently executed. Need to return a continuation.
  19871. return performConcurrentWorkOnRoot.bind(null, root);
  19872. }
  19873. }
  19874. }
  19875. return null;
  19876. }
  19877. function finishConcurrentRender(root, finishedWork, exitStatus, expirationTime) {
  19878. // Set this to null to indicate there's no in-progress render.
  19879. workInProgressRoot = null;
  19880. switch (exitStatus) {
  19881. case RootIncomplete:
  19882. case RootFatalErrored:
  19883. {
  19884. {
  19885. {
  19886. throw Error("Root did not complete. This is a bug in React.");
  19887. }
  19888. }
  19889. }
  19890. // Flow knows about invariant, so it complains if I add a break
  19891. // statement, but eslint doesn't know about invariant, so it complains
  19892. // if I do. eslint-disable-next-line no-fallthrough
  19893. case RootErrored:
  19894. {
  19895. // If this was an async render, the error may have happened due to
  19896. // a mutation in a concurrent event. Try rendering one more time,
  19897. // synchronously, to see if the error goes away. If there are
  19898. // lower priority updates, let's include those, too, in case they
  19899. // fix the inconsistency. Render at Idle to include all updates.
  19900. // If it was Idle or Never or some not-yet-invented time, render
  19901. // at that time.
  19902. markRootExpiredAtTime(root, expirationTime > Idle ? Idle : expirationTime); // We assume that this second render pass will be synchronous
  19903. // and therefore not hit this path again.
  19904. break;
  19905. }
  19906. case RootSuspended:
  19907. {
  19908. markRootSuspendedAtTime(root, expirationTime);
  19909. var lastSuspendedTime = root.lastSuspendedTime;
  19910. if (expirationTime === lastSuspendedTime) {
  19911. root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
  19912. }
  19913. flushSuspensePriorityWarningInDEV(); // We have an acceptable loading state. We need to figure out if we
  19914. // should immediately commit it or wait a bit.
  19915. // If we have processed new updates during this render, we may now
  19916. // have a new loading state ready. We want to ensure that we commit
  19917. // that as soon as possible.
  19918. var hasNotProcessedNewUpdates = workInProgressRootLatestProcessedExpirationTime === Sync;
  19919. if (hasNotProcessedNewUpdates && // do not delay if we're inside an act() scope
  19920. !(true && flushSuspenseFallbacksInTests && IsThisRendererActing.current)) {
  19921. // If we have not processed any new updates during this pass, then
  19922. // this is either a retry of an existing fallback state or a
  19923. // hidden tree. Hidden trees shouldn't be batched with other work
  19924. // and after that's fixed it can only be a retry. We're going to
  19925. // throttle committing retries so that we don't show too many
  19926. // loading states too quickly.
  19927. var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now(); // Don't bother with a very short suspense time.
  19928. if (msUntilTimeout > 10) {
  19929. if (workInProgressRootHasPendingPing) {
  19930. var lastPingedTime = root.lastPingedTime;
  19931. if (lastPingedTime === NoWork || lastPingedTime >= expirationTime) {
  19932. // This render was pinged but we didn't get to restart
  19933. // earlier so try restarting now instead.
  19934. root.lastPingedTime = expirationTime;
  19935. prepareFreshStack(root, expirationTime);
  19936. break;
  19937. }
  19938. }
  19939. var nextTime = getNextRootExpirationTimeToWorkOn(root);
  19940. if (nextTime !== NoWork && nextTime !== expirationTime) {
  19941. // There's additional work on this root.
  19942. break;
  19943. }
  19944. if (lastSuspendedTime !== NoWork && lastSuspendedTime !== expirationTime) {
  19945. // We should prefer to render the fallback of at the last
  19946. // suspended level. Ping the last suspended level to try
  19947. // rendering it again.
  19948. root.lastPingedTime = lastSuspendedTime;
  19949. break;
  19950. } // The render is suspended, it hasn't timed out, and there's no
  19951. // lower priority work to do. Instead of committing the fallback
  19952. // immediately, wait for more data to arrive.
  19953. root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), msUntilTimeout);
  19954. break;
  19955. }
  19956. } // The work expired. Commit immediately.
  19957. commitRoot(root);
  19958. break;
  19959. }
  19960. case RootSuspendedWithDelay:
  19961. {
  19962. markRootSuspendedAtTime(root, expirationTime);
  19963. var _lastSuspendedTime = root.lastSuspendedTime;
  19964. if (expirationTime === _lastSuspendedTime) {
  19965. root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork);
  19966. }
  19967. flushSuspensePriorityWarningInDEV();
  19968. if ( // do not delay if we're inside an act() scope
  19969. !(true && flushSuspenseFallbacksInTests && IsThisRendererActing.current)) {
  19970. // We're suspended in a state that should be avoided. We'll try to
  19971. // avoid committing it for as long as the timeouts let us.
  19972. if (workInProgressRootHasPendingPing) {
  19973. var _lastPingedTime = root.lastPingedTime;
  19974. if (_lastPingedTime === NoWork || _lastPingedTime >= expirationTime) {
  19975. // This render was pinged but we didn't get to restart earlier
  19976. // so try restarting now instead.
  19977. root.lastPingedTime = expirationTime;
  19978. prepareFreshStack(root, expirationTime);
  19979. break;
  19980. }
  19981. }
  19982. var _nextTime = getNextRootExpirationTimeToWorkOn(root);
  19983. if (_nextTime !== NoWork && _nextTime !== expirationTime) {
  19984. // There's additional work on this root.
  19985. break;
  19986. }
  19987. if (_lastSuspendedTime !== NoWork && _lastSuspendedTime !== expirationTime) {
  19988. // We should prefer to render the fallback of at the last
  19989. // suspended level. Ping the last suspended level to try
  19990. // rendering it again.
  19991. root.lastPingedTime = _lastSuspendedTime;
  19992. break;
  19993. }
  19994. var _msUntilTimeout;
  19995. if (workInProgressRootLatestSuspenseTimeout !== Sync) {
  19996. // We have processed a suspense config whose expiration time we
  19997. // can use as the timeout.
  19998. _msUntilTimeout = expirationTimeToMs(workInProgressRootLatestSuspenseTimeout) - now();
  19999. } else if (workInProgressRootLatestProcessedExpirationTime === Sync) {
  20000. // This should never normally happen because only new updates
  20001. // cause delayed states, so we should have processed something.
  20002. // However, this could also happen in an offscreen tree.
  20003. _msUntilTimeout = 0;
  20004. } else {
  20005. // If we don't have a suspense config, we're going to use a
  20006. // heuristic to determine how long we can suspend.
  20007. var eventTimeMs = inferTimeFromExpirationTime(workInProgressRootLatestProcessedExpirationTime);
  20008. var currentTimeMs = now();
  20009. var timeUntilExpirationMs = expirationTimeToMs(expirationTime) - currentTimeMs;
  20010. var timeElapsed = currentTimeMs - eventTimeMs;
  20011. if (timeElapsed < 0) {
  20012. // We get this wrong some time since we estimate the time.
  20013. timeElapsed = 0;
  20014. }
  20015. _msUntilTimeout = jnd(timeElapsed) - timeElapsed; // Clamp the timeout to the expiration time. TODO: Once the
  20016. // event time is exact instead of inferred from expiration time
  20017. // we don't need this.
  20018. if (timeUntilExpirationMs < _msUntilTimeout) {
  20019. _msUntilTimeout = timeUntilExpirationMs;
  20020. }
  20021. } // Don't bother with a very short suspense time.
  20022. if (_msUntilTimeout > 10) {
  20023. // The render is suspended, it hasn't timed out, and there's no
  20024. // lower priority work to do. Instead of committing the fallback
  20025. // immediately, wait for more data to arrive.
  20026. root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout);
  20027. break;
  20028. }
  20029. } // The work expired. Commit immediately.
  20030. commitRoot(root);
  20031. break;
  20032. }
  20033. case RootCompleted:
  20034. {
  20035. // The work completed. Ready to commit.
  20036. if ( // do not delay if we're inside an act() scope
  20037. !(true && flushSuspenseFallbacksInTests && IsThisRendererActing.current) && workInProgressRootLatestProcessedExpirationTime !== Sync && workInProgressRootCanSuspendUsingConfig !== null) {
  20038. // If we have exceeded the minimum loading delay, which probably
  20039. // means we have shown a spinner already, we might have to suspend
  20040. // a bit longer to ensure that the spinner is shown for
  20041. // enough time.
  20042. var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay(workInProgressRootLatestProcessedExpirationTime, expirationTime, workInProgressRootCanSuspendUsingConfig);
  20043. if (_msUntilTimeout2 > 10) {
  20044. markRootSuspendedAtTime(root, expirationTime);
  20045. root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout2);
  20046. break;
  20047. }
  20048. }
  20049. commitRoot(root);
  20050. break;
  20051. }
  20052. default:
  20053. {
  20054. {
  20055. {
  20056. throw Error("Unknown root exit status.");
  20057. }
  20058. }
  20059. }
  20060. }
  20061. } // This is the entry point for synchronous tasks that don't go
  20062. // through Scheduler
  20063. function performSyncWorkOnRoot(root) {
  20064. // Check if there's expired work on this root. Otherwise, render at Sync.
  20065. var lastExpiredTime = root.lastExpiredTime;
  20066. var expirationTime = lastExpiredTime !== NoWork ? lastExpiredTime : Sync;
  20067. if (root.finishedExpirationTime === expirationTime) {
  20068. // There's already a pending commit at this expiration time.
  20069. // TODO: This is poorly factored. This case only exists for the
  20070. // batch.commit() API.
  20071. commitRoot(root);
  20072. } else {
  20073. if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
  20074. {
  20075. throw Error("Should not already be working.");
  20076. }
  20077. }
  20078. flushPassiveEffects(); // If the root or expiration time have changed, throw out the existing stack
  20079. // and prepare a fresh one. Otherwise we'll continue where we left off.
  20080. if (root !== workInProgressRoot || expirationTime !== renderExpirationTime) {
  20081. prepareFreshStack(root, expirationTime);
  20082. startWorkOnPendingInteractions(root, expirationTime);
  20083. } // If we have a work-in-progress fiber, it means there's still work to do
  20084. // in this root.
  20085. if (workInProgress !== null) {
  20086. var prevExecutionContext = executionContext;
  20087. executionContext |= RenderContext;
  20088. var prevDispatcher = pushDispatcher(root);
  20089. var prevInteractions = pushInteractions(root);
  20090. startWorkLoopTimer(workInProgress);
  20091. do {
  20092. try {
  20093. workLoopSync();
  20094. break;
  20095. } catch (thrownValue) {
  20096. handleError(root, thrownValue);
  20097. }
  20098. } while (true);
  20099. resetContextDependencies();
  20100. executionContext = prevExecutionContext;
  20101. popDispatcher(prevDispatcher);
  20102. if (enableSchedulerTracing) {
  20103. popInteractions(prevInteractions);
  20104. }
  20105. if (workInProgressRootExitStatus === RootFatalErrored) {
  20106. var fatalError = workInProgressRootFatalError;
  20107. stopInterruptedWorkLoopTimer();
  20108. prepareFreshStack(root, expirationTime);
  20109. markRootSuspendedAtTime(root, expirationTime);
  20110. ensureRootIsScheduled(root);
  20111. throw fatalError;
  20112. }
  20113. if (workInProgress !== null) {
  20114. // This is a sync render, so we should have finished the whole tree.
  20115. {
  20116. {
  20117. throw Error("Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue.");
  20118. }
  20119. }
  20120. } else {
  20121. // We now have a consistent tree. Because this is a sync render, we
  20122. // will commit it even if something suspended.
  20123. stopFinishedWorkLoopTimer();
  20124. root.finishedWork = root.current.alternate;
  20125. root.finishedExpirationTime = expirationTime;
  20126. finishSyncRender(root, workInProgressRootExitStatus, expirationTime);
  20127. } // Before exiting, make sure there's a callback scheduled for the next
  20128. // pending level.
  20129. ensureRootIsScheduled(root);
  20130. }
  20131. }
  20132. return null;
  20133. }
  20134. function finishSyncRender(root, exitStatus, expirationTime) {
  20135. // Set this to null to indicate there's no in-progress render.
  20136. workInProgressRoot = null;
  20137. {
  20138. if (exitStatus === RootSuspended || exitStatus === RootSuspendedWithDelay) {
  20139. flushSuspensePriorityWarningInDEV();
  20140. }
  20141. }
  20142. commitRoot(root);
  20143. }
  20144. function flushRoot(root, expirationTime) {
  20145. markRootExpiredAtTime(root, expirationTime);
  20146. ensureRootIsScheduled(root);
  20147. if ((executionContext & (RenderContext | CommitContext)) === NoContext) {
  20148. flushSyncCallbackQueue();
  20149. }
  20150. }
  20151. function flushDiscreteUpdates() {
  20152. // TODO: Should be able to flush inside batchedUpdates, but not inside `act`.
  20153. // However, `act` uses `batchedUpdates`, so there's no way to distinguish
  20154. // those two cases. Need to fix this before exposing flushDiscreteUpdates
  20155. // as a public API.
  20156. if ((executionContext & (BatchedContext | RenderContext | CommitContext)) !== NoContext) {
  20157. if (true && (executionContext & RenderContext) !== NoContext) {
  20158. warning$1(false, 'unstable_flushDiscreteUpdates: Cannot flush updates when React is ' + 'already rendering.');
  20159. } // We're already rendering, so we can't synchronously flush pending work.
  20160. // This is probably a nested event dispatch triggered by a lifecycle/effect,
  20161. // like `el.focus()`. Exit.
  20162. return;
  20163. }
  20164. flushPendingDiscreteUpdates(); // If the discrete updates scheduled passive effects, flush them now so that
  20165. // they fire before the next serial event.
  20166. flushPassiveEffects();
  20167. }
  20168. function syncUpdates(fn, a, b, c) {
  20169. return runWithPriority$2(ImmediatePriority, fn.bind(null, a, b, c));
  20170. }
  20171. function flushPendingDiscreteUpdates() {
  20172. if (rootsWithPendingDiscreteUpdates !== null) {
  20173. // For each root with pending discrete updates, schedule a callback to
  20174. // immediately flush them.
  20175. var roots = rootsWithPendingDiscreteUpdates;
  20176. rootsWithPendingDiscreteUpdates = null;
  20177. roots.forEach(function (expirationTime, root) {
  20178. markRootExpiredAtTime(root, expirationTime);
  20179. ensureRootIsScheduled(root);
  20180. }); // Now flush the immediate queue.
  20181. flushSyncCallbackQueue();
  20182. }
  20183. }
  20184. function batchedUpdates$1(fn, a) {
  20185. var prevExecutionContext = executionContext;
  20186. executionContext |= BatchedContext;
  20187. try {
  20188. return fn(a);
  20189. } finally {
  20190. executionContext = prevExecutionContext;
  20191. if (executionContext === NoContext) {
  20192. // Flush the immediate callbacks that were scheduled during this batch
  20193. flushSyncCallbackQueue();
  20194. }
  20195. }
  20196. }
  20197. function batchedEventUpdates$1(fn, a) {
  20198. var prevExecutionContext = executionContext;
  20199. executionContext |= EventContext;
  20200. try {
  20201. return fn(a);
  20202. } finally {
  20203. executionContext = prevExecutionContext;
  20204. if (executionContext === NoContext) {
  20205. // Flush the immediate callbacks that were scheduled during this batch
  20206. flushSyncCallbackQueue();
  20207. }
  20208. }
  20209. }
  20210. function discreteUpdates$1(fn, a, b, c) {
  20211. var prevExecutionContext = executionContext;
  20212. executionContext |= DiscreteEventContext;
  20213. try {
  20214. // Should this
  20215. return runWithPriority$2(UserBlockingPriority$2, fn.bind(null, a, b, c));
  20216. } finally {
  20217. executionContext = prevExecutionContext;
  20218. if (executionContext === NoContext) {
  20219. // Flush the immediate callbacks that were scheduled during this batch
  20220. flushSyncCallbackQueue();
  20221. }
  20222. }
  20223. }
  20224. function unbatchedUpdates(fn, a) {
  20225. var prevExecutionContext = executionContext;
  20226. executionContext &= ~BatchedContext;
  20227. executionContext |= LegacyUnbatchedContext;
  20228. try {
  20229. return fn(a);
  20230. } finally {
  20231. executionContext = prevExecutionContext;
  20232. if (executionContext === NoContext) {
  20233. // Flush the immediate callbacks that were scheduled during this batch
  20234. flushSyncCallbackQueue();
  20235. }
  20236. }
  20237. }
  20238. function flushSync(fn, a) {
  20239. if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
  20240. {
  20241. {
  20242. throw Error("flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering.");
  20243. }
  20244. }
  20245. }
  20246. var prevExecutionContext = executionContext;
  20247. executionContext |= BatchedContext;
  20248. try {
  20249. return runWithPriority$2(ImmediatePriority, fn.bind(null, a));
  20250. } finally {
  20251. executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch.
  20252. // Note that this will happen even if batchedUpdates is higher up
  20253. // the stack.
  20254. flushSyncCallbackQueue();
  20255. }
  20256. }
  20257. function flushControlled(fn) {
  20258. var prevExecutionContext = executionContext;
  20259. executionContext |= BatchedContext;
  20260. try {
  20261. runWithPriority$2(ImmediatePriority, fn);
  20262. } finally {
  20263. executionContext = prevExecutionContext;
  20264. if (executionContext === NoContext) {
  20265. // Flush the immediate callbacks that were scheduled during this batch
  20266. flushSyncCallbackQueue();
  20267. }
  20268. }
  20269. }
  20270. function prepareFreshStack(root, expirationTime) {
  20271. root.finishedWork = null;
  20272. root.finishedExpirationTime = NoWork;
  20273. var timeoutHandle = root.timeoutHandle;
  20274. if (timeoutHandle !== noTimeout) {
  20275. // The root previous suspended and scheduled a timeout to commit a fallback
  20276. // state. Now that we have additional work, cancel the timeout.
  20277. root.timeoutHandle = noTimeout; // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
  20278. cancelTimeout(timeoutHandle);
  20279. }
  20280. if (workInProgress !== null) {
  20281. var interruptedWork = workInProgress.return;
  20282. while (interruptedWork !== null) {
  20283. unwindInterruptedWork(interruptedWork);
  20284. interruptedWork = interruptedWork.return;
  20285. }
  20286. }
  20287. workInProgressRoot = root;
  20288. workInProgress = createWorkInProgress(root.current, null, expirationTime);
  20289. renderExpirationTime = expirationTime;
  20290. workInProgressRootExitStatus = RootIncomplete;
  20291. workInProgressRootFatalError = null;
  20292. workInProgressRootLatestProcessedExpirationTime = Sync;
  20293. workInProgressRootLatestSuspenseTimeout = Sync;
  20294. workInProgressRootCanSuspendUsingConfig = null;
  20295. workInProgressRootNextUnprocessedUpdateTime = NoWork;
  20296. workInProgressRootHasPendingPing = false;
  20297. if (enableSchedulerTracing) {
  20298. spawnedWorkDuringRender = null;
  20299. }
  20300. {
  20301. ReactStrictModeWarnings.discardPendingWarnings();
  20302. componentsThatTriggeredHighPriSuspend = null;
  20303. }
  20304. }
  20305. function handleError(root, thrownValue) {
  20306. do {
  20307. try {
  20308. // Reset module-level state that was set during the render phase.
  20309. resetContextDependencies();
  20310. resetHooks();
  20311. resetCurrentFiber();
  20312. if (workInProgress === null || workInProgress.return === null) {
  20313. // Expected to be working on a non-root fiber. This is a fatal error
  20314. // because there's no ancestor that can handle it; the root is
  20315. // supposed to capture all errors that weren't caught by an error
  20316. // boundary.
  20317. workInProgressRootExitStatus = RootFatalErrored;
  20318. workInProgressRootFatalError = thrownValue;
  20319. return null;
  20320. }
  20321. if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
  20322. // Record the time spent rendering before an error was thrown. This
  20323. // avoids inaccurate Profiler durations in the case of a
  20324. // suspended render.
  20325. stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true);
  20326. }
  20327. throwException(root, workInProgress.return, workInProgress, thrownValue, renderExpirationTime);
  20328. workInProgress = completeUnitOfWork(workInProgress);
  20329. } catch (yetAnotherThrownValue) {
  20330. // Something in the return path also threw.
  20331. thrownValue = yetAnotherThrownValue;
  20332. continue;
  20333. } // Return to the normal work loop.
  20334. return;
  20335. } while (true);
  20336. }
  20337. function pushDispatcher(root) {
  20338. var prevDispatcher = ReactCurrentDispatcher.current;
  20339. ReactCurrentDispatcher.current = ContextOnlyDispatcher;
  20340. if (prevDispatcher === null) {
  20341. // The React isomorphic package does not include a default dispatcher.
  20342. // Instead the first renderer will lazily attach one, in order to give
  20343. // nicer error messages.
  20344. return ContextOnlyDispatcher;
  20345. } else {
  20346. return prevDispatcher;
  20347. }
  20348. }
  20349. function popDispatcher(prevDispatcher) {
  20350. ReactCurrentDispatcher.current = prevDispatcher;
  20351. }
  20352. function pushInteractions(root) {
  20353. if (enableSchedulerTracing) {
  20354. var prevInteractions = tracing.__interactionsRef.current;
  20355. tracing.__interactionsRef.current = root.memoizedInteractions;
  20356. return prevInteractions;
  20357. }
  20358. return null;
  20359. }
  20360. function popInteractions(prevInteractions) {
  20361. if (enableSchedulerTracing) {
  20362. tracing.__interactionsRef.current = prevInteractions;
  20363. }
  20364. }
  20365. function markCommitTimeOfFallback() {
  20366. globalMostRecentFallbackTime = now();
  20367. }
  20368. function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) {
  20369. if (expirationTime < workInProgressRootLatestProcessedExpirationTime && expirationTime > Idle) {
  20370. workInProgressRootLatestProcessedExpirationTime = expirationTime;
  20371. }
  20372. if (suspenseConfig !== null) {
  20373. if (expirationTime < workInProgressRootLatestSuspenseTimeout && expirationTime > Idle) {
  20374. workInProgressRootLatestSuspenseTimeout = expirationTime; // Most of the time we only have one config and getting wrong is not bad.
  20375. workInProgressRootCanSuspendUsingConfig = suspenseConfig;
  20376. }
  20377. }
  20378. }
  20379. function markUnprocessedUpdateTime(expirationTime) {
  20380. if (expirationTime > workInProgressRootNextUnprocessedUpdateTime) {
  20381. workInProgressRootNextUnprocessedUpdateTime = expirationTime;
  20382. }
  20383. }
  20384. function renderDidSuspend() {
  20385. if (workInProgressRootExitStatus === RootIncomplete) {
  20386. workInProgressRootExitStatus = RootSuspended;
  20387. }
  20388. }
  20389. function renderDidSuspendDelayIfPossible() {
  20390. if (workInProgressRootExitStatus === RootIncomplete || workInProgressRootExitStatus === RootSuspended) {
  20391. workInProgressRootExitStatus = RootSuspendedWithDelay;
  20392. } // Check if there's a lower priority update somewhere else in the tree.
  20393. if (workInProgressRootNextUnprocessedUpdateTime !== NoWork && workInProgressRoot !== null) {
  20394. // Mark the current render as suspended, and then mark that there's a
  20395. // pending update.
  20396. // TODO: This should immediately interrupt the current render, instead
  20397. // of waiting until the next time we yield.
  20398. markRootSuspendedAtTime(workInProgressRoot, renderExpirationTime);
  20399. markRootUpdatedAtTime(workInProgressRoot, workInProgressRootNextUnprocessedUpdateTime);
  20400. }
  20401. }
  20402. function renderDidError() {
  20403. if (workInProgressRootExitStatus !== RootCompleted) {
  20404. workInProgressRootExitStatus = RootErrored;
  20405. }
  20406. } // Called during render to determine if anything has suspended.
  20407. // Returns false if we're not sure.
  20408. function renderHasNotSuspendedYet() {
  20409. // If something errored or completed, we can't really be sure,
  20410. // so those are false.
  20411. return workInProgressRootExitStatus === RootIncomplete;
  20412. }
  20413. function inferTimeFromExpirationTime(expirationTime) {
  20414. // We don't know exactly when the update was scheduled, but we can infer an
  20415. // approximate start time from the expiration time.
  20416. var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
  20417. return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION;
  20418. }
  20419. function inferTimeFromExpirationTimeWithSuspenseConfig(expirationTime, suspenseConfig) {
  20420. // We don't know exactly when the update was scheduled, but we can infer an
  20421. // approximate start time from the expiration time by subtracting the timeout
  20422. // that was added to the event time.
  20423. var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
  20424. return earliestExpirationTimeMs - (suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION);
  20425. } // The work loop is an extremely hot path. Tell Closure not to inline it.
  20426. /** @noinline */
  20427. function workLoopSync() {
  20428. // Already timed out, so perform work without checking if we need to yield.
  20429. while (workInProgress !== null) {
  20430. workInProgress = performUnitOfWork(workInProgress);
  20431. }
  20432. }
  20433. /** @noinline */
  20434. function workLoopConcurrent() {
  20435. // Perform work until Scheduler asks us to yield
  20436. while (workInProgress !== null && !shouldYield()) {
  20437. workInProgress = performUnitOfWork(workInProgress);
  20438. }
  20439. }
  20440. function performUnitOfWork(unitOfWork) {
  20441. // The current, flushed, state of this fiber is the alternate. Ideally
  20442. // nothing should rely on this, but relying on it here means that we don't
  20443. // need an additional field on the work in progress.
  20444. var current$$1 = unitOfWork.alternate;
  20445. startWorkTimer(unitOfWork);
  20446. setCurrentFiber(unitOfWork);
  20447. var next;
  20448. if (enableProfilerTimer && (unitOfWork.mode & ProfileMode) !== NoMode) {
  20449. startProfilerTimer(unitOfWork);
  20450. next = beginWork$$1(current$$1, unitOfWork, renderExpirationTime);
  20451. stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);
  20452. } else {
  20453. next = beginWork$$1(current$$1, unitOfWork, renderExpirationTime);
  20454. }
  20455. resetCurrentFiber();
  20456. unitOfWork.memoizedProps = unitOfWork.pendingProps;
  20457. if (next === null) {
  20458. // If this doesn't spawn new work, complete the current work.
  20459. next = completeUnitOfWork(unitOfWork);
  20460. }
  20461. ReactCurrentOwner$2.current = null;
  20462. return next;
  20463. }
  20464. function completeUnitOfWork(unitOfWork) {
  20465. // Attempt to complete the current unit of work, then move to the next
  20466. // sibling. If there are no more siblings, return to the parent fiber.
  20467. workInProgress = unitOfWork;
  20468. do {
  20469. // The current, flushed, state of this fiber is the alternate. Ideally
  20470. // nothing should rely on this, but relying on it here means that we don't
  20471. // need an additional field on the work in progress.
  20472. var current$$1 = workInProgress.alternate;
  20473. var returnFiber = workInProgress.return; // Check if the work completed or if something threw.
  20474. if ((workInProgress.effectTag & Incomplete) === NoEffect) {
  20475. setCurrentFiber(workInProgress);
  20476. var next = void 0;
  20477. if (!enableProfilerTimer || (workInProgress.mode & ProfileMode) === NoMode) {
  20478. next = completeWork(current$$1, workInProgress, renderExpirationTime);
  20479. } else {
  20480. startProfilerTimer(workInProgress);
  20481. next = completeWork(current$$1, workInProgress, renderExpirationTime); // Update render duration assuming we didn't error.
  20482. stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
  20483. }
  20484. stopWorkTimer(workInProgress);
  20485. resetCurrentFiber();
  20486. resetChildExpirationTime(workInProgress);
  20487. if (next !== null) {
  20488. // Completing this fiber spawned new work. Work on that next.
  20489. return next;
  20490. }
  20491. if (returnFiber !== null && // Do not append effects to parents if a sibling failed to complete
  20492. (returnFiber.effectTag & Incomplete) === NoEffect) {
  20493. // Append all the effects of the subtree and this fiber onto the effect
  20494. // list of the parent. The completion order of the children affects the
  20495. // side-effect order.
  20496. if (returnFiber.firstEffect === null) {
  20497. returnFiber.firstEffect = workInProgress.firstEffect;
  20498. }
  20499. if (workInProgress.lastEffect !== null) {
  20500. if (returnFiber.lastEffect !== null) {
  20501. returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
  20502. }
  20503. returnFiber.lastEffect = workInProgress.lastEffect;
  20504. } // If this fiber had side-effects, we append it AFTER the children's
  20505. // side-effects. We can perform certain side-effects earlier if needed,
  20506. // by doing multiple passes over the effect list. We don't want to
  20507. // schedule our own side-effect on our own list because if end up
  20508. // reusing children we'll schedule this effect onto itself since we're
  20509. // at the end.
  20510. var effectTag = workInProgress.effectTag; // Skip both NoWork and PerformedWork tags when creating the effect
  20511. // list. PerformedWork effect is read by React DevTools but shouldn't be
  20512. // committed.
  20513. if (effectTag > PerformedWork) {
  20514. if (returnFiber.lastEffect !== null) {
  20515. returnFiber.lastEffect.nextEffect = workInProgress;
  20516. } else {
  20517. returnFiber.firstEffect = workInProgress;
  20518. }
  20519. returnFiber.lastEffect = workInProgress;
  20520. }
  20521. }
  20522. } else {
  20523. // This fiber did not complete because something threw. Pop values off
  20524. // the stack without entering the complete phase. If this is a boundary,
  20525. // capture values if possible.
  20526. var _next = unwindWork(workInProgress, renderExpirationTime); // Because this fiber did not complete, don't reset its expiration time.
  20527. if (enableProfilerTimer && (workInProgress.mode & ProfileMode) !== NoMode) {
  20528. // Record the render duration for the fiber that errored.
  20529. stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); // Include the time spent working on failed children before continuing.
  20530. var actualDuration = workInProgress.actualDuration;
  20531. var child = workInProgress.child;
  20532. while (child !== null) {
  20533. actualDuration += child.actualDuration;
  20534. child = child.sibling;
  20535. }
  20536. workInProgress.actualDuration = actualDuration;
  20537. }
  20538. if (_next !== null) {
  20539. // If completing this work spawned new work, do that next. We'll come
  20540. // back here again.
  20541. // Since we're restarting, remove anything that is not a host effect
  20542. // from the effect tag.
  20543. // TODO: The name stopFailedWorkTimer is misleading because Suspense
  20544. // also captures and restarts.
  20545. stopFailedWorkTimer(workInProgress);
  20546. _next.effectTag &= HostEffectMask;
  20547. return _next;
  20548. }
  20549. stopWorkTimer(workInProgress);
  20550. if (returnFiber !== null) {
  20551. // Mark the parent fiber as incomplete and clear its effect list.
  20552. returnFiber.firstEffect = returnFiber.lastEffect = null;
  20553. returnFiber.effectTag |= Incomplete;
  20554. }
  20555. }
  20556. var siblingFiber = workInProgress.sibling;
  20557. if (siblingFiber !== null) {
  20558. // If there is more work to do in this returnFiber, do that next.
  20559. return siblingFiber;
  20560. } // Otherwise, return to the parent
  20561. workInProgress = returnFiber;
  20562. } while (workInProgress !== null); // We've reached the root.
  20563. if (workInProgressRootExitStatus === RootIncomplete) {
  20564. workInProgressRootExitStatus = RootCompleted;
  20565. }
  20566. return null;
  20567. }
  20568. function getRemainingExpirationTime(fiber) {
  20569. var updateExpirationTime = fiber.expirationTime;
  20570. var childExpirationTime = fiber.childExpirationTime;
  20571. return updateExpirationTime > childExpirationTime ? updateExpirationTime : childExpirationTime;
  20572. }
  20573. function resetChildExpirationTime(completedWork) {
  20574. if (renderExpirationTime !== Never && completedWork.childExpirationTime === Never) {
  20575. // The children of this component are hidden. Don't bubble their
  20576. // expiration times.
  20577. return;
  20578. }
  20579. var newChildExpirationTime = NoWork; // Bubble up the earliest expiration time.
  20580. if (enableProfilerTimer && (completedWork.mode & ProfileMode) !== NoMode) {
  20581. // In profiling mode, resetChildExpirationTime is also used to reset
  20582. // profiler durations.
  20583. var actualDuration = completedWork.actualDuration;
  20584. var treeBaseDuration = completedWork.selfBaseDuration; // When a fiber is cloned, its actualDuration is reset to 0. This value will
  20585. // only be updated if work is done on the fiber (i.e. it doesn't bailout).
  20586. // When work is done, it should bubble to the parent's actualDuration. If
  20587. // the fiber has not been cloned though, (meaning no work was done), then
  20588. // this value will reflect the amount of time spent working on a previous
  20589. // render. In that case it should not bubble. We determine whether it was
  20590. // cloned by comparing the child pointer.
  20591. var shouldBubbleActualDurations = completedWork.alternate === null || completedWork.child !== completedWork.alternate.child;
  20592. var child = completedWork.child;
  20593. while (child !== null) {
  20594. var childUpdateExpirationTime = child.expirationTime;
  20595. var childChildExpirationTime = child.childExpirationTime;
  20596. if (childUpdateExpirationTime > newChildExpirationTime) {
  20597. newChildExpirationTime = childUpdateExpirationTime;
  20598. }
  20599. if (childChildExpirationTime > newChildExpirationTime) {
  20600. newChildExpirationTime = childChildExpirationTime;
  20601. }
  20602. if (shouldBubbleActualDurations) {
  20603. actualDuration += child.actualDuration;
  20604. }
  20605. treeBaseDuration += child.treeBaseDuration;
  20606. child = child.sibling;
  20607. }
  20608. completedWork.actualDuration = actualDuration;
  20609. completedWork.treeBaseDuration = treeBaseDuration;
  20610. } else {
  20611. var _child = completedWork.child;
  20612. while (_child !== null) {
  20613. var _childUpdateExpirationTime = _child.expirationTime;
  20614. var _childChildExpirationTime = _child.childExpirationTime;
  20615. if (_childUpdateExpirationTime > newChildExpirationTime) {
  20616. newChildExpirationTime = _childUpdateExpirationTime;
  20617. }
  20618. if (_childChildExpirationTime > newChildExpirationTime) {
  20619. newChildExpirationTime = _childChildExpirationTime;
  20620. }
  20621. _child = _child.sibling;
  20622. }
  20623. }
  20624. completedWork.childExpirationTime = newChildExpirationTime;
  20625. }
  20626. function commitRoot(root) {
  20627. var renderPriorityLevel = getCurrentPriorityLevel();
  20628. runWithPriority$2(ImmediatePriority, commitRootImpl.bind(null, root, renderPriorityLevel));
  20629. return null;
  20630. }
  20631. function commitRootImpl(root, renderPriorityLevel) {
  20632. do {
  20633. // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which
  20634. // means `flushPassiveEffects` will sometimes result in additional
  20635. // passive effects. So we need to keep flushing in a loop until there are
  20636. // no more pending effects.
  20637. // TODO: Might be better if `flushPassiveEffects` did not automatically
  20638. // flush synchronous work at the end, to avoid factoring hazards like this.
  20639. flushPassiveEffects();
  20640. } while (rootWithPendingPassiveEffects !== null);
  20641. flushRenderPhaseStrictModeWarningsInDEV();
  20642. if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
  20643. {
  20644. throw Error("Should not already be working.");
  20645. }
  20646. }
  20647. var finishedWork = root.finishedWork;
  20648. var expirationTime = root.finishedExpirationTime;
  20649. if (finishedWork === null) {
  20650. return null;
  20651. }
  20652. root.finishedWork = null;
  20653. root.finishedExpirationTime = NoWork;
  20654. if (!(finishedWork !== root.current)) {
  20655. {
  20656. throw Error("Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue.");
  20657. }
  20658. } // commitRoot never returns a continuation; it always finishes synchronously.
  20659. // So we can clear these now to allow a new callback to be scheduled.
  20660. root.callbackNode = null;
  20661. root.callbackExpirationTime = NoWork;
  20662. root.callbackPriority = NoPriority;
  20663. root.nextKnownPendingLevel = NoWork;
  20664. startCommitTimer(); // Update the first and last pending times on this root. The new first
  20665. // pending time is whatever is left on the root fiber.
  20666. var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime(finishedWork);
  20667. markRootFinishedAtTime(root, expirationTime, remainingExpirationTimeBeforeCommit);
  20668. if (root === workInProgressRoot) {
  20669. // We can reset these now that they are finished.
  20670. workInProgressRoot = null;
  20671. workInProgress = null;
  20672. renderExpirationTime = NoWork;
  20673. } else {} // This indicates that the last root we worked on is not the same one that
  20674. // we're committing now. This most commonly happens when a suspended root
  20675. // times out.
  20676. // Get the list of effects.
  20677. var firstEffect;
  20678. if (finishedWork.effectTag > PerformedWork) {
  20679. // A fiber's effect list consists only of its children, not itself. So if
  20680. // the root has an effect, we need to add it to the end of the list. The
  20681. // resulting list is the set that would belong to the root's parent, if it
  20682. // had one; that is, all the effects in the tree including the root.
  20683. if (finishedWork.lastEffect !== null) {
  20684. finishedWork.lastEffect.nextEffect = finishedWork;
  20685. firstEffect = finishedWork.firstEffect;
  20686. } else {
  20687. firstEffect = finishedWork;
  20688. }
  20689. } else {
  20690. // There is no effect on the root.
  20691. firstEffect = finishedWork.firstEffect;
  20692. }
  20693. if (firstEffect !== null) {
  20694. var prevExecutionContext = executionContext;
  20695. executionContext |= CommitContext;
  20696. var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles
  20697. ReactCurrentOwner$2.current = null; // The commit phase is broken into several sub-phases. We do a separate pass
  20698. // of the effect list for each phase: all mutation effects come before all
  20699. // layout effects, and so on.
  20700. // The first phase a "before mutation" phase. We use this phase to read the
  20701. // state of the host tree right before we mutate it. This is where
  20702. // getSnapshotBeforeUpdate is called.
  20703. startCommitSnapshotEffectsTimer();
  20704. prepareForCommit(root.containerInfo);
  20705. nextEffect = firstEffect;
  20706. do {
  20707. {
  20708. invokeGuardedCallback(null, commitBeforeMutationEffects, null);
  20709. if (hasCaughtError()) {
  20710. if (!(nextEffect !== null)) {
  20711. {
  20712. throw Error("Should be working on an effect.");
  20713. }
  20714. }
  20715. var error = clearCaughtError();
  20716. captureCommitPhaseError(nextEffect, error);
  20717. nextEffect = nextEffect.nextEffect;
  20718. }
  20719. }
  20720. } while (nextEffect !== null);
  20721. stopCommitSnapshotEffectsTimer();
  20722. if (enableProfilerTimer) {
  20723. // Mark the current commit time to be shared by all Profilers in this
  20724. // batch. This enables them to be grouped later.
  20725. recordCommitTime();
  20726. } // The next phase is the mutation phase, where we mutate the host tree.
  20727. startCommitHostEffectsTimer();
  20728. nextEffect = firstEffect;
  20729. do {
  20730. {
  20731. invokeGuardedCallback(null, commitMutationEffects, null, root, renderPriorityLevel);
  20732. if (hasCaughtError()) {
  20733. if (!(nextEffect !== null)) {
  20734. {
  20735. throw Error("Should be working on an effect.");
  20736. }
  20737. }
  20738. var _error = clearCaughtError();
  20739. captureCommitPhaseError(nextEffect, _error);
  20740. nextEffect = nextEffect.nextEffect;
  20741. }
  20742. }
  20743. } while (nextEffect !== null);
  20744. stopCommitHostEffectsTimer();
  20745. resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after
  20746. // the mutation phase, so that the previous tree is still current during
  20747. // componentWillUnmount, but before the layout phase, so that the finished
  20748. // work is current during componentDidMount/Update.
  20749. root.current = finishedWork; // The next phase is the layout phase, where we call effects that read
  20750. // the host tree after it's been mutated. The idiomatic use case for this is
  20751. // layout, but class component lifecycles also fire here for legacy reasons.
  20752. startCommitLifeCyclesTimer();
  20753. nextEffect = firstEffect;
  20754. do {
  20755. {
  20756. invokeGuardedCallback(null, commitLayoutEffects, null, root, expirationTime);
  20757. if (hasCaughtError()) {
  20758. if (!(nextEffect !== null)) {
  20759. {
  20760. throw Error("Should be working on an effect.");
  20761. }
  20762. }
  20763. var _error2 = clearCaughtError();
  20764. captureCommitPhaseError(nextEffect, _error2);
  20765. nextEffect = nextEffect.nextEffect;
  20766. }
  20767. }
  20768. } while (nextEffect !== null);
  20769. stopCommitLifeCyclesTimer();
  20770. nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an
  20771. // opportunity to paint.
  20772. requestPaint();
  20773. if (enableSchedulerTracing) {
  20774. popInteractions(prevInteractions);
  20775. }
  20776. executionContext = prevExecutionContext;
  20777. } else {
  20778. // No effects.
  20779. root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were
  20780. // no effects.
  20781. // TODO: Maybe there's a better way to report this.
  20782. startCommitSnapshotEffectsTimer();
  20783. stopCommitSnapshotEffectsTimer();
  20784. if (enableProfilerTimer) {
  20785. recordCommitTime();
  20786. }
  20787. startCommitHostEffectsTimer();
  20788. stopCommitHostEffectsTimer();
  20789. startCommitLifeCyclesTimer();
  20790. stopCommitLifeCyclesTimer();
  20791. }
  20792. stopCommitTimer();
  20793. var rootDidHavePassiveEffects = rootDoesHavePassiveEffects;
  20794. if (rootDoesHavePassiveEffects) {
  20795. // This commit has passive effects. Stash a reference to them. But don't
  20796. // schedule a callback until after flushing layout work.
  20797. rootDoesHavePassiveEffects = false;
  20798. rootWithPendingPassiveEffects = root;
  20799. pendingPassiveEffectsExpirationTime = expirationTime;
  20800. pendingPassiveEffectsRenderPriority = renderPriorityLevel;
  20801. } else {
  20802. // We are done with the effect chain at this point so let's clear the
  20803. // nextEffect pointers to assist with GC. If we have passive effects, we'll
  20804. // clear this in flushPassiveEffects.
  20805. nextEffect = firstEffect;
  20806. while (nextEffect !== null) {
  20807. var nextNextEffect = nextEffect.nextEffect;
  20808. nextEffect.nextEffect = null;
  20809. nextEffect = nextNextEffect;
  20810. }
  20811. } // Check if there's remaining work on this root
  20812. var remainingExpirationTime = root.firstPendingTime;
  20813. if (remainingExpirationTime !== NoWork) {
  20814. if (enableSchedulerTracing) {
  20815. if (spawnedWorkDuringRender !== null) {
  20816. var expirationTimes = spawnedWorkDuringRender;
  20817. spawnedWorkDuringRender = null;
  20818. for (var i = 0; i < expirationTimes.length; i++) {
  20819. scheduleInteractions(root, expirationTimes[i], root.memoizedInteractions);
  20820. }
  20821. }
  20822. schedulePendingInteractions(root, remainingExpirationTime);
  20823. }
  20824. } else {
  20825. // If there's no remaining work, we can clear the set of already failed
  20826. // error boundaries.
  20827. legacyErrorBoundariesThatAlreadyFailed = null;
  20828. }
  20829. if (enableSchedulerTracing) {
  20830. if (!rootDidHavePassiveEffects) {
  20831. // If there are no passive effects, then we can complete the pending interactions.
  20832. // Otherwise, we'll wait until after the passive effects are flushed.
  20833. // Wait to do this until after remaining work has been scheduled,
  20834. // so that we don't prematurely signal complete for interactions when there's e.g. hidden work.
  20835. finishPendingInteractions(root, expirationTime);
  20836. }
  20837. }
  20838. if (remainingExpirationTime === Sync) {
  20839. // Count the number of times the root synchronously re-renders without
  20840. // finishing. If there are too many, it indicates an infinite update loop.
  20841. if (root === rootWithNestedUpdates) {
  20842. nestedUpdateCount++;
  20843. } else {
  20844. nestedUpdateCount = 0;
  20845. rootWithNestedUpdates = root;
  20846. }
  20847. } else {
  20848. nestedUpdateCount = 0;
  20849. }
  20850. onCommitRoot(finishedWork.stateNode, expirationTime); // Always call this before exiting `commitRoot`, to ensure that any
  20851. // additional work on this root is scheduled.
  20852. ensureRootIsScheduled(root);
  20853. if (hasUncaughtError) {
  20854. hasUncaughtError = false;
  20855. var _error3 = firstUncaughtError;
  20856. firstUncaughtError = null;
  20857. throw _error3;
  20858. }
  20859. if ((executionContext & LegacyUnbatchedContext) !== NoContext) {
  20860. // This is a legacy edge case. We just committed the initial mount of
  20861. // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired
  20862. // synchronously, but layout updates should be deferred until the end
  20863. // of the batch.
  20864. return null;
  20865. } // If layout work was scheduled, flush it now.
  20866. flushSyncCallbackQueue();
  20867. return null;
  20868. }
  20869. function commitBeforeMutationEffects() {
  20870. while (nextEffect !== null) {
  20871. var effectTag = nextEffect.effectTag;
  20872. if ((effectTag & Snapshot) !== NoEffect) {
  20873. setCurrentFiber(nextEffect);
  20874. recordEffect();
  20875. var current$$1 = nextEffect.alternate;
  20876. commitBeforeMutationLifeCycles(current$$1, nextEffect);
  20877. resetCurrentFiber();
  20878. }
  20879. if ((effectTag & Passive) !== NoEffect) {
  20880. // If there are passive effects, schedule a callback to flush at
  20881. // the earliest opportunity.
  20882. if (!rootDoesHavePassiveEffects) {
  20883. rootDoesHavePassiveEffects = true;
  20884. scheduleCallback(NormalPriority, function () {
  20885. flushPassiveEffects();
  20886. return null;
  20887. });
  20888. }
  20889. }
  20890. nextEffect = nextEffect.nextEffect;
  20891. }
  20892. }
  20893. function commitMutationEffects(root, renderPriorityLevel) {
  20894. // TODO: Should probably move the bulk of this function to commitWork.
  20895. while (nextEffect !== null) {
  20896. setCurrentFiber(nextEffect);
  20897. var effectTag = nextEffect.effectTag;
  20898. if (effectTag & ContentReset) {
  20899. commitResetTextContent(nextEffect);
  20900. }
  20901. if (effectTag & Ref) {
  20902. var current$$1 = nextEffect.alternate;
  20903. if (current$$1 !== null) {
  20904. commitDetachRef(current$$1);
  20905. }
  20906. } // The following switch statement is only concerned about placement,
  20907. // updates, and deletions. To avoid needing to add a case for every possible
  20908. // bitmap value, we remove the secondary effects from the effect tag and
  20909. // switch on that value.
  20910. var primaryEffectTag = effectTag & (Placement | Update | Deletion | Hydrating);
  20911. switch (primaryEffectTag) {
  20912. case Placement:
  20913. {
  20914. commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is
  20915. // inserted, before any life-cycles like componentDidMount gets called.
  20916. // TODO: findDOMNode doesn't rely on this any more but isMounted does
  20917. // and isMounted is deprecated anyway so we should be able to kill this.
  20918. nextEffect.effectTag &= ~Placement;
  20919. break;
  20920. }
  20921. case PlacementAndUpdate:
  20922. {
  20923. // Placement
  20924. commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is
  20925. // inserted, before any life-cycles like componentDidMount gets called.
  20926. nextEffect.effectTag &= ~Placement; // Update
  20927. var _current = nextEffect.alternate;
  20928. commitWork(_current, nextEffect);
  20929. break;
  20930. }
  20931. case Hydrating:
  20932. {
  20933. nextEffect.effectTag &= ~Hydrating;
  20934. break;
  20935. }
  20936. case HydratingAndUpdate:
  20937. {
  20938. nextEffect.effectTag &= ~Hydrating; // Update
  20939. var _current2 = nextEffect.alternate;
  20940. commitWork(_current2, nextEffect);
  20941. break;
  20942. }
  20943. case Update:
  20944. {
  20945. var _current3 = nextEffect.alternate;
  20946. commitWork(_current3, nextEffect);
  20947. break;
  20948. }
  20949. case Deletion:
  20950. {
  20951. commitDeletion(root, nextEffect, renderPriorityLevel);
  20952. break;
  20953. }
  20954. } // TODO: Only record a mutation effect if primaryEffectTag is non-zero.
  20955. recordEffect();
  20956. resetCurrentFiber();
  20957. nextEffect = nextEffect.nextEffect;
  20958. }
  20959. }
  20960. function commitLayoutEffects(root, committedExpirationTime) {
  20961. // TODO: Should probably move the bulk of this function to commitWork.
  20962. while (nextEffect !== null) {
  20963. setCurrentFiber(nextEffect);
  20964. var effectTag = nextEffect.effectTag;
  20965. if (effectTag & (Update | Callback)) {
  20966. recordEffect();
  20967. var current$$1 = nextEffect.alternate;
  20968. commitLifeCycles(root, current$$1, nextEffect, committedExpirationTime);
  20969. }
  20970. if (effectTag & Ref) {
  20971. recordEffect();
  20972. commitAttachRef(nextEffect);
  20973. }
  20974. resetCurrentFiber();
  20975. nextEffect = nextEffect.nextEffect;
  20976. }
  20977. }
  20978. function flushPassiveEffects() {
  20979. if (pendingPassiveEffectsRenderPriority !== NoPriority) {
  20980. var priorityLevel = pendingPassiveEffectsRenderPriority > NormalPriority ? NormalPriority : pendingPassiveEffectsRenderPriority;
  20981. pendingPassiveEffectsRenderPriority = NoPriority;
  20982. return runWithPriority$2(priorityLevel, flushPassiveEffectsImpl);
  20983. }
  20984. }
  20985. function flushPassiveEffectsImpl() {
  20986. if (rootWithPendingPassiveEffects === null) {
  20987. return false;
  20988. }
  20989. var root = rootWithPendingPassiveEffects;
  20990. var expirationTime = pendingPassiveEffectsExpirationTime;
  20991. rootWithPendingPassiveEffects = null;
  20992. pendingPassiveEffectsExpirationTime = NoWork;
  20993. if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
  20994. {
  20995. throw Error("Cannot flush passive effects while already rendering.");
  20996. }
  20997. }
  20998. var prevExecutionContext = executionContext;
  20999. executionContext |= CommitContext;
  21000. var prevInteractions = pushInteractions(root); // Note: This currently assumes there are no passive effects on the root
  21001. // fiber, because the root is not part of its own effect list. This could
  21002. // change in the future.
  21003. var effect = root.current.firstEffect;
  21004. while (effect !== null) {
  21005. {
  21006. setCurrentFiber(effect);
  21007. invokeGuardedCallback(null, commitPassiveHookEffects, null, effect);
  21008. if (hasCaughtError()) {
  21009. if (!(effect !== null)) {
  21010. {
  21011. throw Error("Should be working on an effect.");
  21012. }
  21013. }
  21014. var error = clearCaughtError();
  21015. captureCommitPhaseError(effect, error);
  21016. }
  21017. resetCurrentFiber();
  21018. }
  21019. var nextNextEffect = effect.nextEffect; // Remove nextEffect pointer to assist GC
  21020. effect.nextEffect = null;
  21021. effect = nextNextEffect;
  21022. }
  21023. if (enableSchedulerTracing) {
  21024. popInteractions(prevInteractions);
  21025. finishPendingInteractions(root, expirationTime);
  21026. }
  21027. executionContext = prevExecutionContext;
  21028. flushSyncCallbackQueue(); // If additional passive effects were scheduled, increment a counter. If this
  21029. // exceeds the limit, we'll fire a warning.
  21030. nestedPassiveUpdateCount = rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1;
  21031. return true;
  21032. }
  21033. function isAlreadyFailedLegacyErrorBoundary(instance) {
  21034. return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance);
  21035. }
  21036. function markLegacyErrorBoundaryAsFailed(instance) {
  21037. if (legacyErrorBoundariesThatAlreadyFailed === null) {
  21038. legacyErrorBoundariesThatAlreadyFailed = new Set([instance]);
  21039. } else {
  21040. legacyErrorBoundariesThatAlreadyFailed.add(instance);
  21041. }
  21042. }
  21043. function prepareToThrowUncaughtError(error) {
  21044. if (!hasUncaughtError) {
  21045. hasUncaughtError = true;
  21046. firstUncaughtError = error;
  21047. }
  21048. }
  21049. var onUncaughtError = prepareToThrowUncaughtError;
  21050. function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) {
  21051. var errorInfo = createCapturedValue(error, sourceFiber);
  21052. var update = createRootErrorUpdate(rootFiber, errorInfo, Sync);
  21053. enqueueUpdate(rootFiber, update);
  21054. var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync);
  21055. if (root !== null) {
  21056. ensureRootIsScheduled(root);
  21057. schedulePendingInteractions(root, Sync);
  21058. }
  21059. }
  21060. function captureCommitPhaseError(sourceFiber, error) {
  21061. if (sourceFiber.tag === HostRoot) {
  21062. // Error was thrown at the root. There is no parent, so the root
  21063. // itself should capture it.
  21064. captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error);
  21065. return;
  21066. }
  21067. var fiber = sourceFiber.return;
  21068. while (fiber !== null) {
  21069. if (fiber.tag === HostRoot) {
  21070. captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error);
  21071. return;
  21072. } else if (fiber.tag === ClassComponent) {
  21073. var ctor = fiber.type;
  21074. var instance = fiber.stateNode;
  21075. if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) {
  21076. var errorInfo = createCapturedValue(error, sourceFiber);
  21077. var update = createClassErrorUpdate(fiber, errorInfo, // TODO: This is always sync
  21078. Sync);
  21079. enqueueUpdate(fiber, update);
  21080. var root = markUpdateTimeFromFiberToRoot(fiber, Sync);
  21081. if (root !== null) {
  21082. ensureRootIsScheduled(root);
  21083. schedulePendingInteractions(root, Sync);
  21084. }
  21085. return;
  21086. }
  21087. }
  21088. fiber = fiber.return;
  21089. }
  21090. }
  21091. function pingSuspendedRoot(root, thenable, suspendedTime) {
  21092. var pingCache = root.pingCache;
  21093. if (pingCache !== null) {
  21094. // The thenable resolved, so we no longer need to memoize, because it will
  21095. // never be thrown again.
  21096. pingCache.delete(thenable);
  21097. }
  21098. if (workInProgressRoot === root && renderExpirationTime === suspendedTime) {
  21099. // Received a ping at the same priority level at which we're currently
  21100. // rendering. We might want to restart this render. This should mirror
  21101. // the logic of whether or not a root suspends once it completes.
  21102. // TODO: If we're rendering sync either due to Sync, Batched or expired,
  21103. // we should probably never restart.
  21104. // If we're suspended with delay, we'll always suspend so we can always
  21105. // restart. If we're suspended without any updates, it might be a retry.
  21106. // If it's early in the retry we can restart. We can't know for sure
  21107. // whether we'll eventually process an update during this render pass,
  21108. // but it's somewhat unlikely that we get to a ping before that, since
  21109. // getting to the root most update is usually very fast.
  21110. if (workInProgressRootExitStatus === RootSuspendedWithDelay || workInProgressRootExitStatus === RootSuspended && workInProgressRootLatestProcessedExpirationTime === Sync && now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) {
  21111. // Restart from the root. Don't need to schedule a ping because
  21112. // we're already working on this tree.
  21113. prepareFreshStack(root, renderExpirationTime);
  21114. } else {
  21115. // Even though we can't restart right now, we might get an
  21116. // opportunity later. So we mark this render as having a ping.
  21117. workInProgressRootHasPendingPing = true;
  21118. }
  21119. return;
  21120. }
  21121. if (!isRootSuspendedAtTime(root, suspendedTime)) {
  21122. // The root is no longer suspended at this time.
  21123. return;
  21124. }
  21125. var lastPingedTime = root.lastPingedTime;
  21126. if (lastPingedTime !== NoWork && lastPingedTime < suspendedTime) {
  21127. // There's already a lower priority ping scheduled.
  21128. return;
  21129. } // Mark the time at which this ping was scheduled.
  21130. root.lastPingedTime = suspendedTime;
  21131. if (root.finishedExpirationTime === suspendedTime) {
  21132. // If there's a pending fallback waiting to commit, throw it away.
  21133. root.finishedExpirationTime = NoWork;
  21134. root.finishedWork = null;
  21135. }
  21136. ensureRootIsScheduled(root);
  21137. schedulePendingInteractions(root, suspendedTime);
  21138. }
  21139. function retryTimedOutBoundary(boundaryFiber, retryTime) {
  21140. // The boundary fiber (a Suspense component or SuspenseList component)
  21141. // previously was rendered in its fallback state. One of the promises that
  21142. // suspended it has resolved, which means at least part of the tree was
  21143. // likely unblocked. Try rendering again, at a new expiration time.
  21144. if (retryTime === NoWork) {
  21145. var suspenseConfig = null; // Retries don't carry over the already committed update.
  21146. var currentTime = requestCurrentTimeForUpdate();
  21147. retryTime = computeExpirationForFiber(currentTime, boundaryFiber, suspenseConfig);
  21148. } // TODO: Special case idle priority?
  21149. var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime);
  21150. if (root !== null) {
  21151. ensureRootIsScheduled(root);
  21152. schedulePendingInteractions(root, retryTime);
  21153. }
  21154. }
  21155. function retryDehydratedSuspenseBoundary(boundaryFiber) {
  21156. var suspenseState = boundaryFiber.memoizedState;
  21157. var retryTime = NoWork;
  21158. if (suspenseState !== null) {
  21159. retryTime = suspenseState.retryTime;
  21160. }
  21161. retryTimedOutBoundary(boundaryFiber, retryTime);
  21162. }
  21163. function resolveRetryThenable(boundaryFiber, thenable) {
  21164. var retryTime = NoWork; // Default
  21165. var retryCache;
  21166. if (enableSuspenseServerRenderer) {
  21167. switch (boundaryFiber.tag) {
  21168. case SuspenseComponent:
  21169. retryCache = boundaryFiber.stateNode;
  21170. var suspenseState = boundaryFiber.memoizedState;
  21171. if (suspenseState !== null) {
  21172. retryTime = suspenseState.retryTime;
  21173. }
  21174. break;
  21175. case SuspenseListComponent:
  21176. retryCache = boundaryFiber.stateNode;
  21177. break;
  21178. default:
  21179. {
  21180. {
  21181. throw Error("Pinged unknown suspense boundary type. This is probably a bug in React.");
  21182. }
  21183. }
  21184. }
  21185. } else {
  21186. retryCache = boundaryFiber.stateNode;
  21187. }
  21188. if (retryCache !== null) {
  21189. // The thenable resolved, so we no longer need to memoize, because it will
  21190. // never be thrown again.
  21191. retryCache.delete(thenable);
  21192. }
  21193. retryTimedOutBoundary(boundaryFiber, retryTime);
  21194. } // Computes the next Just Noticeable Difference (JND) boundary.
  21195. // The theory is that a person can't tell the difference between small differences in time.
  21196. // Therefore, if we wait a bit longer than necessary that won't translate to a noticeable
  21197. // difference in the experience. However, waiting for longer might mean that we can avoid
  21198. // showing an intermediate loading state. The longer we have already waited, the harder it
  21199. // is to tell small differences in time. Therefore, the longer we've already waited,
  21200. // the longer we can wait additionally. At some point we have to give up though.
  21201. // We pick a train model where the next boundary commits at a consistent schedule.
  21202. // These particular numbers are vague estimates. We expect to adjust them based on research.
  21203. function jnd(timeElapsed) {
  21204. return timeElapsed < 120 ? 120 : timeElapsed < 480 ? 480 : timeElapsed < 1080 ? 1080 : timeElapsed < 1920 ? 1920 : timeElapsed < 3000 ? 3000 : timeElapsed < 4320 ? 4320 : ceil(timeElapsed / 1960) * 1960;
  21205. }
  21206. function computeMsUntilSuspenseLoadingDelay(mostRecentEventTime, committedExpirationTime, suspenseConfig) {
  21207. var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0;
  21208. if (busyMinDurationMs <= 0) {
  21209. return 0;
  21210. }
  21211. var busyDelayMs = suspenseConfig.busyDelayMs | 0; // Compute the time until this render pass would expire.
  21212. var currentTimeMs = now();
  21213. var eventTimeMs = inferTimeFromExpirationTimeWithSuspenseConfig(mostRecentEventTime, suspenseConfig);
  21214. var timeElapsed = currentTimeMs - eventTimeMs;
  21215. if (timeElapsed <= busyDelayMs) {
  21216. // If we haven't yet waited longer than the initial delay, we don't
  21217. // have to wait any additional time.
  21218. return 0;
  21219. }
  21220. var msUntilTimeout = busyDelayMs + busyMinDurationMs - timeElapsed; // This is the value that is passed to `setTimeout`.
  21221. return msUntilTimeout;
  21222. }
  21223. function checkForNestedUpdates() {
  21224. if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
  21225. nestedUpdateCount = 0;
  21226. rootWithNestedUpdates = null;
  21227. {
  21228. {
  21229. throw Error("Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.");
  21230. }
  21231. }
  21232. }
  21233. {
  21234. if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) {
  21235. nestedPassiveUpdateCount = 0;
  21236. warning$1(false, 'Maximum update depth exceeded. This can happen when a component ' + "calls setState inside useEffect, but useEffect either doesn't " + 'have a dependency array, or one of the dependencies changes on ' + 'every render.');
  21237. }
  21238. }
  21239. }
  21240. function flushRenderPhaseStrictModeWarningsInDEV() {
  21241. {
  21242. ReactStrictModeWarnings.flushLegacyContextWarning();
  21243. if (warnAboutDeprecatedLifecycles) {
  21244. ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
  21245. }
  21246. }
  21247. }
  21248. function stopFinishedWorkLoopTimer() {
  21249. var didCompleteRoot = true;
  21250. stopWorkLoopTimer(interruptedBy, didCompleteRoot);
  21251. interruptedBy = null;
  21252. }
  21253. function stopInterruptedWorkLoopTimer() {
  21254. // TODO: Track which fiber caused the interruption.
  21255. var didCompleteRoot = false;
  21256. stopWorkLoopTimer(interruptedBy, didCompleteRoot);
  21257. interruptedBy = null;
  21258. }
  21259. function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) {
  21260. if (enableUserTimingAPI && workInProgressRoot !== null && updateExpirationTime > renderExpirationTime) {
  21261. interruptedBy = fiberThatReceivedUpdate;
  21262. }
  21263. }
  21264. var didWarnStateUpdateForUnmountedComponent = null;
  21265. function warnAboutUpdateOnUnmountedFiberInDEV(fiber) {
  21266. {
  21267. var tag = fiber.tag;
  21268. if (tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent) {
  21269. // Only warn for user-defined components, not internal ones like Suspense.
  21270. return;
  21271. } // We show the whole stack but dedupe on the top component's name because
  21272. // the problematic code almost always lies inside that component.
  21273. var componentName = getComponentName(fiber.type) || 'ReactComponent';
  21274. if (didWarnStateUpdateForUnmountedComponent !== null) {
  21275. if (didWarnStateUpdateForUnmountedComponent.has(componentName)) {
  21276. return;
  21277. }
  21278. didWarnStateUpdateForUnmountedComponent.add(componentName);
  21279. } else {
  21280. didWarnStateUpdateForUnmountedComponent = new Set([componentName]);
  21281. }
  21282. warningWithoutStack$1(false, "Can't perform a React state update on an unmounted component. This " + 'is a no-op, but it indicates a memory leak in your application. To ' + 'fix, cancel all subscriptions and asynchronous tasks in %s.%s', tag === ClassComponent ? 'the componentWillUnmount method' : 'a useEffect cleanup function', getStackByFiberInDevAndProd(fiber));
  21283. }
  21284. }
  21285. var beginWork$$1;
  21286. if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
  21287. var dummyFiber = null;
  21288. beginWork$$1 = function (current$$1, unitOfWork, expirationTime) {
  21289. // If a component throws an error, we replay it again in a synchronously
  21290. // dispatched event, so that the debugger will treat it as an uncaught
  21291. // error See ReactErrorUtils for more information.
  21292. // Before entering the begin phase, copy the work-in-progress onto a dummy
  21293. // fiber. If beginWork throws, we'll use this to reset the state.
  21294. var originalWorkInProgressCopy = assignFiberPropertiesInDEV(dummyFiber, unitOfWork);
  21295. try {
  21296. return beginWork$1(current$$1, unitOfWork, expirationTime);
  21297. } catch (originalError) {
  21298. if (originalError !== null && typeof originalError === 'object' && typeof originalError.then === 'function') {
  21299. // Don't replay promises. Treat everything else like an error.
  21300. throw originalError;
  21301. } // Keep this code in sync with handleError; any changes here must have
  21302. // corresponding changes there.
  21303. resetContextDependencies();
  21304. resetHooks(); // Don't reset current debug fiber, since we're about to work on the
  21305. // same fiber again.
  21306. // Unwind the failed stack frame
  21307. unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber.
  21308. assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy);
  21309. if (enableProfilerTimer && unitOfWork.mode & ProfileMode) {
  21310. // Reset the profiler timer.
  21311. startProfilerTimer(unitOfWork);
  21312. } // Run beginWork again.
  21313. invokeGuardedCallback(null, beginWork$1, null, current$$1, unitOfWork, expirationTime);
  21314. if (hasCaughtError()) {
  21315. var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`.
  21316. // Rethrow this error instead of the original one.
  21317. throw replayError;
  21318. } else {
  21319. // This branch is reachable if the render phase is impure.
  21320. throw originalError;
  21321. }
  21322. }
  21323. };
  21324. } else {
  21325. beginWork$$1 = beginWork$1;
  21326. }
  21327. var didWarnAboutUpdateInRender = false;
  21328. var didWarnAboutUpdateInGetChildContext = false;
  21329. function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) {
  21330. {
  21331. if (fiber.tag === ClassComponent) {
  21332. switch (phase) {
  21333. case 'getChildContext':
  21334. if (didWarnAboutUpdateInGetChildContext) {
  21335. return;
  21336. }
  21337. warningWithoutStack$1(false, 'setState(...): Cannot call setState() inside getChildContext()');
  21338. didWarnAboutUpdateInGetChildContext = true;
  21339. break;
  21340. case 'render':
  21341. if (didWarnAboutUpdateInRender) {
  21342. return;
  21343. }
  21344. warningWithoutStack$1(false, 'Cannot update during an existing state transition (such as ' + 'within `render`). Render methods should be a pure function of ' + 'props and state.');
  21345. didWarnAboutUpdateInRender = true;
  21346. break;
  21347. }
  21348. }
  21349. }
  21350. } // a 'shared' variable that changes when act() opens/closes in tests.
  21351. var IsThisRendererActing = {
  21352. current: false
  21353. };
  21354. function warnIfNotScopedWithMatchingAct(fiber) {
  21355. {
  21356. if (warnsIfNotActing === true && IsSomeRendererActing.current === true && IsThisRendererActing.current !== true) {
  21357. warningWithoutStack$1(false, "It looks like you're using the wrong act() around your test interactions.\n" + 'Be sure to use the matching version of act() corresponding to your renderer:\n\n' + '// for react-dom:\n' + "import {act} from 'react-dom/test-utils';\n" + '// ...\n' + 'act(() => ...);\n\n' + '// for react-test-renderer:\n' + "import TestRenderer from 'react-test-renderer';\n" + 'const {act} = TestRenderer;\n' + '// ...\n' + 'act(() => ...);' + '%s', getStackByFiberInDevAndProd(fiber));
  21358. }
  21359. }
  21360. }
  21361. function warnIfNotCurrentlyActingEffectsInDEV(fiber) {
  21362. {
  21363. if (warnsIfNotActing === true && (fiber.mode & StrictMode) !== NoMode && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
  21364. warningWithoutStack$1(false, 'An update to %s ran an effect, but was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://fb.me/react-wrap-tests-with-act' + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber));
  21365. }
  21366. }
  21367. }
  21368. function warnIfNotCurrentlyActingUpdatesInDEV(fiber) {
  21369. {
  21370. if (warnsIfNotActing === true && executionContext === NoContext && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
  21371. warningWithoutStack$1(false, 'An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://fb.me/react-wrap-tests-with-act' + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber));
  21372. }
  21373. }
  21374. }
  21375. var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV; // In tests, we want to enforce a mocked scheduler.
  21376. var didWarnAboutUnmockedScheduler = false; // TODO Before we release concurrent mode, revisit this and decide whether a mocked
  21377. // scheduler is the actual recommendation. The alternative could be a testing build,
  21378. // a new lib, or whatever; we dunno just yet. This message is for early adopters
  21379. // to get their tests right.
  21380. function warnIfUnmockedScheduler(fiber) {
  21381. {
  21382. if (didWarnAboutUnmockedScheduler === false && Scheduler.unstable_flushAllWithoutAsserting === undefined) {
  21383. if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) {
  21384. didWarnAboutUnmockedScheduler = true;
  21385. warningWithoutStack$1(false, 'In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' + 'to guarantee consistent behaviour across tests and browsers. ' + 'For example, with jest: \n' + "jest.mock('scheduler', () => require('scheduler/unstable_mock'));\n\n" + 'For more info, visit https://fb.me/react-mock-scheduler');
  21386. } else if (warnAboutUnmockedScheduler === true) {
  21387. didWarnAboutUnmockedScheduler = true;
  21388. warningWithoutStack$1(false, 'Starting from React v17, the "scheduler" module will need to be mocked ' + 'to guarantee consistent behaviour across tests and browsers. ' + 'For example, with jest: \n' + "jest.mock('scheduler', () => require('scheduler/unstable_mock'));\n\n" + 'For more info, visit https://fb.me/react-mock-scheduler');
  21389. }
  21390. }
  21391. }
  21392. }
  21393. var componentsThatTriggeredHighPriSuspend = null;
  21394. function checkForWrongSuspensePriorityInDEV(sourceFiber) {
  21395. {
  21396. var currentPriorityLevel = getCurrentPriorityLevel();
  21397. if ((sourceFiber.mode & ConcurrentMode) !== NoEffect && (currentPriorityLevel === UserBlockingPriority$2 || currentPriorityLevel === ImmediatePriority)) {
  21398. var workInProgressNode = sourceFiber;
  21399. while (workInProgressNode !== null) {
  21400. // Add the component that triggered the suspense
  21401. var current$$1 = workInProgressNode.alternate;
  21402. if (current$$1 !== null) {
  21403. // TODO: warn component that triggers the high priority
  21404. // suspend is the HostRoot
  21405. switch (workInProgressNode.tag) {
  21406. case ClassComponent:
  21407. // Loop through the component's update queue and see whether the component
  21408. // has triggered any high priority updates
  21409. var updateQueue = current$$1.updateQueue;
  21410. if (updateQueue !== null) {
  21411. var update = updateQueue.firstUpdate;
  21412. while (update !== null) {
  21413. var priorityLevel = update.priority;
  21414. if (priorityLevel === UserBlockingPriority$2 || priorityLevel === ImmediatePriority) {
  21415. if (componentsThatTriggeredHighPriSuspend === null) {
  21416. componentsThatTriggeredHighPriSuspend = new Set([getComponentName(workInProgressNode.type)]);
  21417. } else {
  21418. componentsThatTriggeredHighPriSuspend.add(getComponentName(workInProgressNode.type));
  21419. }
  21420. break;
  21421. }
  21422. update = update.next;
  21423. }
  21424. }
  21425. break;
  21426. case FunctionComponent:
  21427. case ForwardRef:
  21428. case SimpleMemoComponent:
  21429. if (workInProgressNode.memoizedState !== null && workInProgressNode.memoizedState.baseUpdate !== null) {
  21430. var _update = workInProgressNode.memoizedState.baseUpdate; // Loop through the functional component's memoized state to see whether
  21431. // the component has triggered any high pri updates
  21432. while (_update !== null) {
  21433. var priority = _update.priority;
  21434. if (priority === UserBlockingPriority$2 || priority === ImmediatePriority) {
  21435. if (componentsThatTriggeredHighPriSuspend === null) {
  21436. componentsThatTriggeredHighPriSuspend = new Set([getComponentName(workInProgressNode.type)]);
  21437. } else {
  21438. componentsThatTriggeredHighPriSuspend.add(getComponentName(workInProgressNode.type));
  21439. }
  21440. break;
  21441. }
  21442. if (_update.next === workInProgressNode.memoizedState.baseUpdate) {
  21443. break;
  21444. }
  21445. _update = _update.next;
  21446. }
  21447. }
  21448. break;
  21449. default:
  21450. break;
  21451. }
  21452. }
  21453. workInProgressNode = workInProgressNode.return;
  21454. }
  21455. }
  21456. }
  21457. }
  21458. function flushSuspensePriorityWarningInDEV() {
  21459. {
  21460. if (componentsThatTriggeredHighPriSuspend !== null) {
  21461. var componentNames = [];
  21462. componentsThatTriggeredHighPriSuspend.forEach(function (name) {
  21463. return componentNames.push(name);
  21464. });
  21465. componentsThatTriggeredHighPriSuspend = null;
  21466. if (componentNames.length > 0) {
  21467. warningWithoutStack$1(false, '%s triggered a user-blocking update that suspended.' + '\n\n' + 'The fix is to split the update into multiple parts: a user-blocking ' + 'update to provide immediate feedback, and another update that ' + 'triggers the bulk of the changes.' + '\n\n' + 'Refer to the documentation for useTransition to learn how ' + 'to implement this pattern.', // TODO: Add link to React docs with more information, once it exists
  21468. componentNames.sort().join(', '));
  21469. }
  21470. }
  21471. }
  21472. }
  21473. function computeThreadID(root, expirationTime) {
  21474. // Interaction threads are unique per root and expiration time.
  21475. return expirationTime * 1000 + root.interactionThreadID;
  21476. }
  21477. function markSpawnedWork(expirationTime) {
  21478. if (!enableSchedulerTracing) {
  21479. return;
  21480. }
  21481. if (spawnedWorkDuringRender === null) {
  21482. spawnedWorkDuringRender = [expirationTime];
  21483. } else {
  21484. spawnedWorkDuringRender.push(expirationTime);
  21485. }
  21486. }
  21487. function scheduleInteractions(root, expirationTime, interactions) {
  21488. if (!enableSchedulerTracing) {
  21489. return;
  21490. }
  21491. if (interactions.size > 0) {
  21492. var pendingInteractionMap = root.pendingInteractionMap;
  21493. var pendingInteractions = pendingInteractionMap.get(expirationTime);
  21494. if (pendingInteractions != null) {
  21495. interactions.forEach(function (interaction) {
  21496. if (!pendingInteractions.has(interaction)) {
  21497. // Update the pending async work count for previously unscheduled interaction.
  21498. interaction.__count++;
  21499. }
  21500. pendingInteractions.add(interaction);
  21501. });
  21502. } else {
  21503. pendingInteractionMap.set(expirationTime, new Set(interactions)); // Update the pending async work count for the current interactions.
  21504. interactions.forEach(function (interaction) {
  21505. interaction.__count++;
  21506. });
  21507. }
  21508. var subscriber = tracing.__subscriberRef.current;
  21509. if (subscriber !== null) {
  21510. var threadID = computeThreadID(root, expirationTime);
  21511. subscriber.onWorkScheduled(interactions, threadID);
  21512. }
  21513. }
  21514. }
  21515. function schedulePendingInteractions(root, expirationTime) {
  21516. // This is called when work is scheduled on a root.
  21517. // It associates the current interactions with the newly-scheduled expiration.
  21518. // They will be restored when that expiration is later committed.
  21519. if (!enableSchedulerTracing) {
  21520. return;
  21521. }
  21522. scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current);
  21523. }
  21524. function startWorkOnPendingInteractions(root, expirationTime) {
  21525. // This is called when new work is started on a root.
  21526. if (!enableSchedulerTracing) {
  21527. return;
  21528. } // Determine which interactions this batch of work currently includes, So that
  21529. // we can accurately attribute time spent working on it, And so that cascading
  21530. // work triggered during the render phase will be associated with it.
  21531. var interactions = new Set();
  21532. root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
  21533. if (scheduledExpirationTime >= expirationTime) {
  21534. scheduledInteractions.forEach(function (interaction) {
  21535. return interactions.add(interaction);
  21536. });
  21537. }
  21538. }); // Store the current set of interactions on the FiberRoot for a few reasons:
  21539. // We can re-use it in hot functions like performConcurrentWorkOnRoot()
  21540. // without having to recalculate it. We will also use it in commitWork() to
  21541. // pass to any Profiler onRender() hooks. This also provides DevTools with a
  21542. // way to access it when the onCommitRoot() hook is called.
  21543. root.memoizedInteractions = interactions;
  21544. if (interactions.size > 0) {
  21545. var subscriber = tracing.__subscriberRef.current;
  21546. if (subscriber !== null) {
  21547. var threadID = computeThreadID(root, expirationTime);
  21548. try {
  21549. subscriber.onWorkStarted(interactions, threadID);
  21550. } catch (error) {
  21551. // If the subscriber throws, rethrow it in a separate task
  21552. scheduleCallback(ImmediatePriority, function () {
  21553. throw error;
  21554. });
  21555. }
  21556. }
  21557. }
  21558. }
  21559. function finishPendingInteractions(root, committedExpirationTime) {
  21560. if (!enableSchedulerTracing) {
  21561. return;
  21562. }
  21563. var earliestRemainingTimeAfterCommit = root.firstPendingTime;
  21564. var subscriber;
  21565. try {
  21566. subscriber = tracing.__subscriberRef.current;
  21567. if (subscriber !== null && root.memoizedInteractions.size > 0) {
  21568. var threadID = computeThreadID(root, committedExpirationTime);
  21569. subscriber.onWorkStopped(root.memoizedInteractions, threadID);
  21570. }
  21571. } catch (error) {
  21572. // If the subscriber throws, rethrow it in a separate task
  21573. scheduleCallback(ImmediatePriority, function () {
  21574. throw error;
  21575. });
  21576. } finally {
  21577. // Clear completed interactions from the pending Map.
  21578. // Unless the render was suspended or cascading work was scheduled,
  21579. // In which case– leave pending interactions until the subsequent render.
  21580. var pendingInteractionMap = root.pendingInteractionMap;
  21581. pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
  21582. // Only decrement the pending interaction count if we're done.
  21583. // If there's still work at the current priority,
  21584. // That indicates that we are waiting for suspense data.
  21585. if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) {
  21586. pendingInteractionMap.delete(scheduledExpirationTime);
  21587. scheduledInteractions.forEach(function (interaction) {
  21588. interaction.__count--;
  21589. if (subscriber !== null && interaction.__count === 0) {
  21590. try {
  21591. subscriber.onInteractionScheduledWorkCompleted(interaction);
  21592. } catch (error) {
  21593. // If the subscriber throws, rethrow it in a separate task
  21594. scheduleCallback(ImmediatePriority, function () {
  21595. throw error;
  21596. });
  21597. }
  21598. }
  21599. });
  21600. }
  21601. });
  21602. }
  21603. }
  21604. var onCommitFiberRoot = null;
  21605. var onCommitFiberUnmount = null;
  21606. var hasLoggedError = false;
  21607. var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined';
  21608. function injectInternals(internals) {
  21609. if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
  21610. // No DevTools
  21611. return false;
  21612. }
  21613. var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
  21614. if (hook.isDisabled) {
  21615. // This isn't a real property on the hook, but it can be set to opt out
  21616. // of DevTools integration and associated warnings and logs.
  21617. // https://github.com/facebook/react/issues/3877
  21618. return true;
  21619. }
  21620. if (!hook.supportsFiber) {
  21621. {
  21622. warningWithoutStack$1(false, 'The installed version of React DevTools is too old and will not work ' + 'with the current version of React. Please update React DevTools. ' + 'https://fb.me/react-devtools');
  21623. } // DevTools exists, even though it doesn't support Fiber.
  21624. return true;
  21625. }
  21626. try {
  21627. var rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks.
  21628. onCommitFiberRoot = function (root, expirationTime) {
  21629. try {
  21630. var didError = (root.current.effectTag & DidCapture) === DidCapture;
  21631. if (enableProfilerTimer) {
  21632. var currentTime = getCurrentTime();
  21633. var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime);
  21634. hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError);
  21635. } else {
  21636. hook.onCommitFiberRoot(rendererID, root, undefined, didError);
  21637. }
  21638. } catch (err) {
  21639. if (true && !hasLoggedError) {
  21640. hasLoggedError = true;
  21641. warningWithoutStack$1(false, 'React DevTools encountered an error: %s', err);
  21642. }
  21643. }
  21644. };
  21645. onCommitFiberUnmount = function (fiber) {
  21646. try {
  21647. hook.onCommitFiberUnmount(rendererID, fiber);
  21648. } catch (err) {
  21649. if (true && !hasLoggedError) {
  21650. hasLoggedError = true;
  21651. warningWithoutStack$1(false, 'React DevTools encountered an error: %s', err);
  21652. }
  21653. }
  21654. };
  21655. } catch (err) {
  21656. // Catch all errors because it is unsafe to throw during initialization.
  21657. {
  21658. warningWithoutStack$1(false, 'React DevTools encountered an error: %s.', err);
  21659. }
  21660. } // DevTools exists
  21661. return true;
  21662. }
  21663. function onCommitRoot(root, expirationTime) {
  21664. if (typeof onCommitFiberRoot === 'function') {
  21665. onCommitFiberRoot(root, expirationTime);
  21666. }
  21667. }
  21668. function onCommitUnmount(fiber) {
  21669. if (typeof onCommitFiberUnmount === 'function') {
  21670. onCommitFiberUnmount(fiber);
  21671. }
  21672. }
  21673. var hasBadMapPolyfill;
  21674. {
  21675. hasBadMapPolyfill = false;
  21676. try {
  21677. var nonExtensibleObject = Object.preventExtensions({});
  21678. var testMap = new Map([[nonExtensibleObject, null]]);
  21679. var testSet = new Set([nonExtensibleObject]); // This is necessary for Rollup to not consider these unused.
  21680. // https://github.com/rollup/rollup/issues/1771
  21681. // TODO: we can remove these if Rollup fixes the bug.
  21682. testMap.set(0, 0);
  21683. testSet.add(0);
  21684. } catch (e) {
  21685. // TODO: Consider warning about bad polyfills
  21686. hasBadMapPolyfill = true;
  21687. }
  21688. }
  21689. var debugCounter = 1;
  21690. function FiberNode(tag, pendingProps, key, mode) {
  21691. // Instance
  21692. this.tag = tag;
  21693. this.key = key;
  21694. this.elementType = null;
  21695. this.type = null;
  21696. this.stateNode = null; // Fiber
  21697. this.return = null;
  21698. this.child = null;
  21699. this.sibling = null;
  21700. this.index = 0;
  21701. this.ref = null;
  21702. this.pendingProps = pendingProps;
  21703. this.memoizedProps = null;
  21704. this.updateQueue = null;
  21705. this.memoizedState = null;
  21706. this.dependencies = null;
  21707. this.mode = mode; // Effects
  21708. this.effectTag = NoEffect;
  21709. this.nextEffect = null;
  21710. this.firstEffect = null;
  21711. this.lastEffect = null;
  21712. this.expirationTime = NoWork;
  21713. this.childExpirationTime = NoWork;
  21714. this.alternate = null;
  21715. if (enableProfilerTimer) {
  21716. // Note: The following is done to avoid a v8 performance cliff.
  21717. //
  21718. // Initializing the fields below to smis and later updating them with
  21719. // double values will cause Fibers to end up having separate shapes.
  21720. // This behavior/bug has something to do with Object.preventExtension().
  21721. // Fortunately this only impacts DEV builds.
  21722. // Unfortunately it makes React unusably slow for some applications.
  21723. // To work around this, initialize the fields below with doubles.
  21724. //
  21725. // Learn more about this here:
  21726. // https://github.com/facebook/react/issues/14365
  21727. // https://bugs.chromium.org/p/v8/issues/detail?id=8538
  21728. this.actualDuration = Number.NaN;
  21729. this.actualStartTime = Number.NaN;
  21730. this.selfBaseDuration = Number.NaN;
  21731. this.treeBaseDuration = Number.NaN; // It's okay to replace the initial doubles with smis after initialization.
  21732. // This won't trigger the performance cliff mentioned above,
  21733. // and it simplifies other profiler code (including DevTools).
  21734. this.actualDuration = 0;
  21735. this.actualStartTime = -1;
  21736. this.selfBaseDuration = 0;
  21737. this.treeBaseDuration = 0;
  21738. } // This is normally DEV-only except www when it adds listeners.
  21739. // TODO: remove the User Timing integration in favor of Root Events.
  21740. if (enableUserTimingAPI) {
  21741. this._debugID = debugCounter++;
  21742. this._debugIsCurrentlyTiming = false;
  21743. }
  21744. {
  21745. this._debugSource = null;
  21746. this._debugOwner = null;
  21747. this._debugNeedsRemount = false;
  21748. this._debugHookTypes = null;
  21749. if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
  21750. Object.preventExtensions(this);
  21751. }
  21752. }
  21753. } // This is a constructor function, rather than a POJO constructor, still
  21754. // please ensure we do the following:
  21755. // 1) Nobody should add any instance methods on this. Instance methods can be
  21756. // more difficult to predict when they get optimized and they are almost
  21757. // never inlined properly in static compilers.
  21758. // 2) Nobody should rely on `instanceof Fiber` for type testing. We should
  21759. // always know when it is a fiber.
  21760. // 3) We might want to experiment with using numeric keys since they are easier
  21761. // to optimize in a non-JIT environment.
  21762. // 4) We can easily go from a constructor to a createFiber object literal if that
  21763. // is faster.
  21764. // 5) It should be easy to port this to a C struct and keep a C implementation
  21765. // compatible.
  21766. var createFiber = function (tag, pendingProps, key, mode) {
  21767. // $FlowFixMe: the shapes are exact here but Flow doesn't like constructors
  21768. return new FiberNode(tag, pendingProps, key, mode);
  21769. };
  21770. function shouldConstruct(Component) {
  21771. var prototype = Component.prototype;
  21772. return !!(prototype && prototype.isReactComponent);
  21773. }
  21774. function isSimpleFunctionComponent(type) {
  21775. return typeof type === 'function' && !shouldConstruct(type) && type.defaultProps === undefined;
  21776. }
  21777. function resolveLazyComponentTag(Component) {
  21778. if (typeof Component === 'function') {
  21779. return shouldConstruct(Component) ? ClassComponent : FunctionComponent;
  21780. } else if (Component !== undefined && Component !== null) {
  21781. var $$typeof = Component.$$typeof;
  21782. if ($$typeof === REACT_FORWARD_REF_TYPE) {
  21783. return ForwardRef;
  21784. }
  21785. if ($$typeof === REACT_MEMO_TYPE) {
  21786. return MemoComponent;
  21787. }
  21788. }
  21789. return IndeterminateComponent;
  21790. } // This is used to create an alternate fiber to do work on.
  21791. function createWorkInProgress(current, pendingProps, expirationTime) {
  21792. var workInProgress = current.alternate;
  21793. if (workInProgress === null) {
  21794. // We use a double buffering pooling technique because we know that we'll
  21795. // only ever need at most two versions of a tree. We pool the "other" unused
  21796. // node that we're free to reuse. This is lazily created to avoid allocating
  21797. // extra objects for things that are never updated. It also allow us to
  21798. // reclaim the extra memory if needed.
  21799. workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
  21800. workInProgress.elementType = current.elementType;
  21801. workInProgress.type = current.type;
  21802. workInProgress.stateNode = current.stateNode;
  21803. {
  21804. // DEV-only fields
  21805. workInProgress._debugID = current._debugID;
  21806. workInProgress._debugSource = current._debugSource;
  21807. workInProgress._debugOwner = current._debugOwner;
  21808. workInProgress._debugHookTypes = current._debugHookTypes;
  21809. }
  21810. workInProgress.alternate = current;
  21811. current.alternate = workInProgress;
  21812. } else {
  21813. workInProgress.pendingProps = pendingProps; // We already have an alternate.
  21814. // Reset the effect tag.
  21815. workInProgress.effectTag = NoEffect; // The effect list is no longer valid.
  21816. workInProgress.nextEffect = null;
  21817. workInProgress.firstEffect = null;
  21818. workInProgress.lastEffect = null;
  21819. if (enableProfilerTimer) {
  21820. // We intentionally reset, rather than copy, actualDuration & actualStartTime.
  21821. // This prevents time from endlessly accumulating in new commits.
  21822. // This has the downside of resetting values for different priority renders,
  21823. // But works for yielding (the common case) and should support resuming.
  21824. workInProgress.actualDuration = 0;
  21825. workInProgress.actualStartTime = -1;
  21826. }
  21827. }
  21828. workInProgress.childExpirationTime = current.childExpirationTime;
  21829. workInProgress.expirationTime = current.expirationTime;
  21830. workInProgress.child = current.child;
  21831. workInProgress.memoizedProps = current.memoizedProps;
  21832. workInProgress.memoizedState = current.memoizedState;
  21833. workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so
  21834. // it cannot be shared with the current fiber.
  21835. var currentDependencies = current.dependencies;
  21836. workInProgress.dependencies = currentDependencies === null ? null : {
  21837. expirationTime: currentDependencies.expirationTime,
  21838. firstContext: currentDependencies.firstContext,
  21839. responders: currentDependencies.responders
  21840. }; // These will be overridden during the parent's reconciliation
  21841. workInProgress.sibling = current.sibling;
  21842. workInProgress.index = current.index;
  21843. workInProgress.ref = current.ref;
  21844. if (enableProfilerTimer) {
  21845. workInProgress.selfBaseDuration = current.selfBaseDuration;
  21846. workInProgress.treeBaseDuration = current.treeBaseDuration;
  21847. }
  21848. {
  21849. workInProgress._debugNeedsRemount = current._debugNeedsRemount;
  21850. switch (workInProgress.tag) {
  21851. case IndeterminateComponent:
  21852. case FunctionComponent:
  21853. case SimpleMemoComponent:
  21854. workInProgress.type = resolveFunctionForHotReloading(current.type);
  21855. break;
  21856. case ClassComponent:
  21857. workInProgress.type = resolveClassForHotReloading(current.type);
  21858. break;
  21859. case ForwardRef:
  21860. workInProgress.type = resolveForwardRefForHotReloading(current.type);
  21861. break;
  21862. default:
  21863. break;
  21864. }
  21865. }
  21866. return workInProgress;
  21867. } // Used to reuse a Fiber for a second pass.
  21868. function resetWorkInProgress(workInProgress, renderExpirationTime) {
  21869. // This resets the Fiber to what createFiber or createWorkInProgress would
  21870. // have set the values to before during the first pass. Ideally this wouldn't
  21871. // be necessary but unfortunately many code paths reads from the workInProgress
  21872. // when they should be reading from current and writing to workInProgress.
  21873. // We assume pendingProps, index, key, ref, return are still untouched to
  21874. // avoid doing another reconciliation.
  21875. // Reset the effect tag but keep any Placement tags, since that's something
  21876. // that child fiber is setting, not the reconciliation.
  21877. workInProgress.effectTag &= Placement; // The effect list is no longer valid.
  21878. workInProgress.nextEffect = null;
  21879. workInProgress.firstEffect = null;
  21880. workInProgress.lastEffect = null;
  21881. var current = workInProgress.alternate;
  21882. if (current === null) {
  21883. // Reset to createFiber's initial values.
  21884. workInProgress.childExpirationTime = NoWork;
  21885. workInProgress.expirationTime = renderExpirationTime;
  21886. workInProgress.child = null;
  21887. workInProgress.memoizedProps = null;
  21888. workInProgress.memoizedState = null;
  21889. workInProgress.updateQueue = null;
  21890. workInProgress.dependencies = null;
  21891. if (enableProfilerTimer) {
  21892. // Note: We don't reset the actualTime counts. It's useful to accumulate
  21893. // actual time across multiple render passes.
  21894. workInProgress.selfBaseDuration = 0;
  21895. workInProgress.treeBaseDuration = 0;
  21896. }
  21897. } else {
  21898. // Reset to the cloned values that createWorkInProgress would've.
  21899. workInProgress.childExpirationTime = current.childExpirationTime;
  21900. workInProgress.expirationTime = current.expirationTime;
  21901. workInProgress.child = current.child;
  21902. workInProgress.memoizedProps = current.memoizedProps;
  21903. workInProgress.memoizedState = current.memoizedState;
  21904. workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so
  21905. // it cannot be shared with the current fiber.
  21906. var currentDependencies = current.dependencies;
  21907. workInProgress.dependencies = currentDependencies === null ? null : {
  21908. expirationTime: currentDependencies.expirationTime,
  21909. firstContext: currentDependencies.firstContext,
  21910. responders: currentDependencies.responders
  21911. };
  21912. if (enableProfilerTimer) {
  21913. // Note: We don't reset the actualTime counts. It's useful to accumulate
  21914. // actual time across multiple render passes.
  21915. workInProgress.selfBaseDuration = current.selfBaseDuration;
  21916. workInProgress.treeBaseDuration = current.treeBaseDuration;
  21917. }
  21918. }
  21919. return workInProgress;
  21920. }
  21921. function createHostRootFiber(tag) {
  21922. var mode;
  21923. if (tag === ConcurrentRoot) {
  21924. mode = ConcurrentMode | BlockingMode | StrictMode;
  21925. } else if (tag === BlockingRoot) {
  21926. mode = BlockingMode | StrictMode;
  21927. } else {
  21928. mode = NoMode;
  21929. }
  21930. if (enableProfilerTimer && isDevToolsPresent) {
  21931. // Always collect profile timings when DevTools are present.
  21932. // This enables DevTools to start capturing timing at any point–
  21933. // Without some nodes in the tree having empty base times.
  21934. mode |= ProfileMode;
  21935. }
  21936. return createFiber(HostRoot, null, null, mode);
  21937. }
  21938. function createFiberFromTypeAndProps(type, // React$ElementType
  21939. key, pendingProps, owner, mode, expirationTime) {
  21940. var fiber;
  21941. var fiberTag = IndeterminateComponent; // The resolved type is set if we know what the final type will be. I.e. it's not lazy.
  21942. var resolvedType = type;
  21943. if (typeof type === 'function') {
  21944. if (shouldConstruct(type)) {
  21945. fiberTag = ClassComponent;
  21946. {
  21947. resolvedType = resolveClassForHotReloading(resolvedType);
  21948. }
  21949. } else {
  21950. {
  21951. resolvedType = resolveFunctionForHotReloading(resolvedType);
  21952. }
  21953. }
  21954. } else if (typeof type === 'string') {
  21955. fiberTag = HostComponent;
  21956. } else {
  21957. getTag: switch (type) {
  21958. case REACT_FRAGMENT_TYPE:
  21959. return createFiberFromFragment(pendingProps.children, mode, expirationTime, key);
  21960. case REACT_CONCURRENT_MODE_TYPE:
  21961. fiberTag = Mode;
  21962. mode |= ConcurrentMode | BlockingMode | StrictMode;
  21963. break;
  21964. case REACT_STRICT_MODE_TYPE:
  21965. fiberTag = Mode;
  21966. mode |= StrictMode;
  21967. break;
  21968. case REACT_PROFILER_TYPE:
  21969. return createFiberFromProfiler(pendingProps, mode, expirationTime, key);
  21970. case REACT_SUSPENSE_TYPE:
  21971. return createFiberFromSuspense(pendingProps, mode, expirationTime, key);
  21972. case REACT_SUSPENSE_LIST_TYPE:
  21973. return createFiberFromSuspenseList(pendingProps, mode, expirationTime, key);
  21974. default:
  21975. {
  21976. if (typeof type === 'object' && type !== null) {
  21977. switch (type.$$typeof) {
  21978. case REACT_PROVIDER_TYPE:
  21979. fiberTag = ContextProvider;
  21980. break getTag;
  21981. case REACT_CONTEXT_TYPE:
  21982. // This is a consumer
  21983. fiberTag = ContextConsumer;
  21984. break getTag;
  21985. case REACT_FORWARD_REF_TYPE:
  21986. fiberTag = ForwardRef;
  21987. {
  21988. resolvedType = resolveForwardRefForHotReloading(resolvedType);
  21989. }
  21990. break getTag;
  21991. case REACT_MEMO_TYPE:
  21992. fiberTag = MemoComponent;
  21993. break getTag;
  21994. case REACT_LAZY_TYPE:
  21995. fiberTag = LazyComponent;
  21996. resolvedType = null;
  21997. break getTag;
  21998. case REACT_FUNDAMENTAL_TYPE:
  21999. if (enableFundamentalAPI) {
  22000. return createFiberFromFundamental(type, pendingProps, mode, expirationTime, key);
  22001. }
  22002. break;
  22003. case REACT_SCOPE_TYPE:
  22004. if (enableScopeAPI) {
  22005. return createFiberFromScope(type, pendingProps, mode, expirationTime, key);
  22006. }
  22007. }
  22008. }
  22009. var info = '';
  22010. {
  22011. if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
  22012. info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and " + 'named imports.';
  22013. }
  22014. var ownerName = owner ? getComponentName(owner.type) : null;
  22015. if (ownerName) {
  22016. info += '\n\nCheck the render method of `' + ownerName + '`.';
  22017. }
  22018. }
  22019. {
  22020. {
  22021. throw Error("Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + (type == null ? type : typeof type) + "." + info);
  22022. }
  22023. }
  22024. }
  22025. }
  22026. }
  22027. fiber = createFiber(fiberTag, pendingProps, key, mode);
  22028. fiber.elementType = type;
  22029. fiber.type = resolvedType;
  22030. fiber.expirationTime = expirationTime;
  22031. return fiber;
  22032. }
  22033. function createFiberFromElement(element, mode, expirationTime) {
  22034. var owner = null;
  22035. {
  22036. owner = element._owner;
  22037. }
  22038. var type = element.type;
  22039. var key = element.key;
  22040. var pendingProps = element.props;
  22041. var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, expirationTime);
  22042. {
  22043. fiber._debugSource = element._source;
  22044. fiber._debugOwner = element._owner;
  22045. }
  22046. return fiber;
  22047. }
  22048. function createFiberFromFragment(elements, mode, expirationTime, key) {
  22049. var fiber = createFiber(Fragment, elements, key, mode);
  22050. fiber.expirationTime = expirationTime;
  22051. return fiber;
  22052. }
  22053. function createFiberFromFundamental(fundamentalComponent, pendingProps, mode, expirationTime, key) {
  22054. var fiber = createFiber(FundamentalComponent, pendingProps, key, mode);
  22055. fiber.elementType = fundamentalComponent;
  22056. fiber.type = fundamentalComponent;
  22057. fiber.expirationTime = expirationTime;
  22058. return fiber;
  22059. }
  22060. function createFiberFromScope(scope, pendingProps, mode, expirationTime, key) {
  22061. var fiber = createFiber(ScopeComponent, pendingProps, key, mode);
  22062. fiber.type = scope;
  22063. fiber.elementType = scope;
  22064. fiber.expirationTime = expirationTime;
  22065. return fiber;
  22066. }
  22067. function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
  22068. {
  22069. if (typeof pendingProps.id !== 'string' || typeof pendingProps.onRender !== 'function') {
  22070. warningWithoutStack$1(false, 'Profiler must specify an "id" string and "onRender" function as props');
  22071. }
  22072. }
  22073. var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode); // TODO: The Profiler fiber shouldn't have a type. It has a tag.
  22074. fiber.elementType = REACT_PROFILER_TYPE;
  22075. fiber.type = REACT_PROFILER_TYPE;
  22076. fiber.expirationTime = expirationTime;
  22077. return fiber;
  22078. }
  22079. function createFiberFromSuspense(pendingProps, mode, expirationTime, key) {
  22080. var fiber = createFiber(SuspenseComponent, pendingProps, key, mode); // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag.
  22081. // This needs to be fixed in getComponentName so that it relies on the tag
  22082. // instead.
  22083. fiber.type = REACT_SUSPENSE_TYPE;
  22084. fiber.elementType = REACT_SUSPENSE_TYPE;
  22085. fiber.expirationTime = expirationTime;
  22086. return fiber;
  22087. }
  22088. function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) {
  22089. var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode);
  22090. {
  22091. // TODO: The SuspenseListComponent fiber shouldn't have a type. It has a tag.
  22092. // This needs to be fixed in getComponentName so that it relies on the tag
  22093. // instead.
  22094. fiber.type = REACT_SUSPENSE_LIST_TYPE;
  22095. }
  22096. fiber.elementType = REACT_SUSPENSE_LIST_TYPE;
  22097. fiber.expirationTime = expirationTime;
  22098. return fiber;
  22099. }
  22100. function createFiberFromText(content, mode, expirationTime) {
  22101. var fiber = createFiber(HostText, content, null, mode);
  22102. fiber.expirationTime = expirationTime;
  22103. return fiber;
  22104. }
  22105. function createFiberFromHostInstanceForDeletion() {
  22106. var fiber = createFiber(HostComponent, null, null, NoMode); // TODO: These should not need a type.
  22107. fiber.elementType = 'DELETED';
  22108. fiber.type = 'DELETED';
  22109. return fiber;
  22110. }
  22111. function createFiberFromDehydratedFragment(dehydratedNode) {
  22112. var fiber = createFiber(DehydratedFragment, null, null, NoMode);
  22113. fiber.stateNode = dehydratedNode;
  22114. return fiber;
  22115. }
  22116. function createFiberFromPortal(portal, mode, expirationTime) {
  22117. var pendingProps = portal.children !== null ? portal.children : [];
  22118. var fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
  22119. fiber.expirationTime = expirationTime;
  22120. fiber.stateNode = {
  22121. containerInfo: portal.containerInfo,
  22122. pendingChildren: null,
  22123. // Used by persistent updates
  22124. implementation: portal.implementation
  22125. };
  22126. return fiber;
  22127. } // Used for stashing WIP properties to replay failed work in DEV.
  22128. function assignFiberPropertiesInDEV(target, source) {
  22129. if (target === null) {
  22130. // This Fiber's initial properties will always be overwritten.
  22131. // We only use a Fiber to ensure the same hidden class so DEV isn't slow.
  22132. target = createFiber(IndeterminateComponent, null, null, NoMode);
  22133. } // This is intentionally written as a list of all properties.
  22134. // We tried to use Object.assign() instead but this is called in
  22135. // the hottest path, and Object.assign() was too slow:
  22136. // https://github.com/facebook/react/issues/12502
  22137. // This code is DEV-only so size is not a concern.
  22138. target.tag = source.tag;
  22139. target.key = source.key;
  22140. target.elementType = source.elementType;
  22141. target.type = source.type;
  22142. target.stateNode = source.stateNode;
  22143. target.return = source.return;
  22144. target.child = source.child;
  22145. target.sibling = source.sibling;
  22146. target.index = source.index;
  22147. target.ref = source.ref;
  22148. target.pendingProps = source.pendingProps;
  22149. target.memoizedProps = source.memoizedProps;
  22150. target.updateQueue = source.updateQueue;
  22151. target.memoizedState = source.memoizedState;
  22152. target.dependencies = source.dependencies;
  22153. target.mode = source.mode;
  22154. target.effectTag = source.effectTag;
  22155. target.nextEffect = source.nextEffect;
  22156. target.firstEffect = source.firstEffect;
  22157. target.lastEffect = source.lastEffect;
  22158. target.expirationTime = source.expirationTime;
  22159. target.childExpirationTime = source.childExpirationTime;
  22160. target.alternate = source.alternate;
  22161. if (enableProfilerTimer) {
  22162. target.actualDuration = source.actualDuration;
  22163. target.actualStartTime = source.actualStartTime;
  22164. target.selfBaseDuration = source.selfBaseDuration;
  22165. target.treeBaseDuration = source.treeBaseDuration;
  22166. }
  22167. target._debugID = source._debugID;
  22168. target._debugSource = source._debugSource;
  22169. target._debugOwner = source._debugOwner;
  22170. target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
  22171. target._debugNeedsRemount = source._debugNeedsRemount;
  22172. target._debugHookTypes = source._debugHookTypes;
  22173. return target;
  22174. }
  22175. function FiberRootNode(containerInfo, tag, hydrate) {
  22176. this.tag = tag;
  22177. this.current = null;
  22178. this.containerInfo = containerInfo;
  22179. this.pendingChildren = null;
  22180. this.pingCache = null;
  22181. this.finishedExpirationTime = NoWork;
  22182. this.finishedWork = null;
  22183. this.timeoutHandle = noTimeout;
  22184. this.context = null;
  22185. this.pendingContext = null;
  22186. this.hydrate = hydrate;
  22187. this.callbackNode = null;
  22188. this.callbackPriority = NoPriority;
  22189. this.firstPendingTime = NoWork;
  22190. this.firstSuspendedTime = NoWork;
  22191. this.lastSuspendedTime = NoWork;
  22192. this.nextKnownPendingLevel = NoWork;
  22193. this.lastPingedTime = NoWork;
  22194. this.lastExpiredTime = NoWork;
  22195. if (enableSchedulerTracing) {
  22196. this.interactionThreadID = tracing.unstable_getThreadID();
  22197. this.memoizedInteractions = new Set();
  22198. this.pendingInteractionMap = new Map();
  22199. }
  22200. if (enableSuspenseCallback) {
  22201. this.hydrationCallbacks = null;
  22202. }
  22203. }
  22204. function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) {
  22205. var root = new FiberRootNode(containerInfo, tag, hydrate);
  22206. if (enableSuspenseCallback) {
  22207. root.hydrationCallbacks = hydrationCallbacks;
  22208. } // Cyclic construction. This cheats the type system right now because
  22209. // stateNode is any.
  22210. var uninitializedFiber = createHostRootFiber(tag);
  22211. root.current = uninitializedFiber;
  22212. uninitializedFiber.stateNode = root;
  22213. return root;
  22214. }
  22215. function isRootSuspendedAtTime(root, expirationTime) {
  22216. var firstSuspendedTime = root.firstSuspendedTime;
  22217. var lastSuspendedTime = root.lastSuspendedTime;
  22218. return firstSuspendedTime !== NoWork && firstSuspendedTime >= expirationTime && lastSuspendedTime <= expirationTime;
  22219. }
  22220. function markRootSuspendedAtTime(root, expirationTime) {
  22221. var firstSuspendedTime = root.firstSuspendedTime;
  22222. var lastSuspendedTime = root.lastSuspendedTime;
  22223. if (firstSuspendedTime < expirationTime) {
  22224. root.firstSuspendedTime = expirationTime;
  22225. }
  22226. if (lastSuspendedTime > expirationTime || firstSuspendedTime === NoWork) {
  22227. root.lastSuspendedTime = expirationTime;
  22228. }
  22229. if (expirationTime <= root.lastPingedTime) {
  22230. root.lastPingedTime = NoWork;
  22231. }
  22232. if (expirationTime <= root.lastExpiredTime) {
  22233. root.lastExpiredTime = NoWork;
  22234. }
  22235. }
  22236. function markRootUpdatedAtTime(root, expirationTime) {
  22237. // Update the range of pending times
  22238. var firstPendingTime = root.firstPendingTime;
  22239. if (expirationTime > firstPendingTime) {
  22240. root.firstPendingTime = expirationTime;
  22241. } // Update the range of suspended times. Treat everything lower priority or
  22242. // equal to this update as unsuspended.
  22243. var firstSuspendedTime = root.firstSuspendedTime;
  22244. if (firstSuspendedTime !== NoWork) {
  22245. if (expirationTime >= firstSuspendedTime) {
  22246. // The entire suspended range is now unsuspended.
  22247. root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork;
  22248. } else if (expirationTime >= root.lastSuspendedTime) {
  22249. root.lastSuspendedTime = expirationTime + 1;
  22250. } // This is a pending level. Check if it's higher priority than the next
  22251. // known pending level.
  22252. if (expirationTime > root.nextKnownPendingLevel) {
  22253. root.nextKnownPendingLevel = expirationTime;
  22254. }
  22255. }
  22256. }
  22257. function markRootFinishedAtTime(root, finishedExpirationTime, remainingExpirationTime) {
  22258. // Update the range of pending times
  22259. root.firstPendingTime = remainingExpirationTime; // Update the range of suspended times. Treat everything higher priority or
  22260. // equal to this update as unsuspended.
  22261. if (finishedExpirationTime <= root.lastSuspendedTime) {
  22262. // The entire suspended range is now unsuspended.
  22263. root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork;
  22264. } else if (finishedExpirationTime <= root.firstSuspendedTime) {
  22265. // Part of the suspended range is now unsuspended. Narrow the range to
  22266. // include everything between the unsuspended time (non-inclusive) and the
  22267. // last suspended time.
  22268. root.firstSuspendedTime = finishedExpirationTime - 1;
  22269. }
  22270. if (finishedExpirationTime <= root.lastPingedTime) {
  22271. // Clear the pinged time
  22272. root.lastPingedTime = NoWork;
  22273. }
  22274. if (finishedExpirationTime <= root.lastExpiredTime) {
  22275. // Clear the expired time
  22276. root.lastExpiredTime = NoWork;
  22277. }
  22278. }
  22279. function markRootExpiredAtTime(root, expirationTime) {
  22280. var lastExpiredTime = root.lastExpiredTime;
  22281. if (lastExpiredTime === NoWork || lastExpiredTime > expirationTime) {
  22282. root.lastExpiredTime = expirationTime;
  22283. }
  22284. }
  22285. // This lets us hook into Fiber to debug what it's doing.
  22286. // See https://github.com/facebook/react/pull/8033.
  22287. // This is not part of the public API, not even for React DevTools.
  22288. // You may only inject a debugTool if you work on React Fiber itself.
  22289. var ReactFiberInstrumentation = {
  22290. debugTool: null
  22291. };
  22292. var ReactFiberInstrumentation_1 = ReactFiberInstrumentation;
  22293. var didWarnAboutNestedUpdates;
  22294. var didWarnAboutFindNodeInStrictMode;
  22295. {
  22296. didWarnAboutNestedUpdates = false;
  22297. didWarnAboutFindNodeInStrictMode = {};
  22298. }
  22299. function getContextForSubtree(parentComponent) {
  22300. if (!parentComponent) {
  22301. return emptyContextObject;
  22302. }
  22303. var fiber = get(parentComponent);
  22304. var parentContext = findCurrentUnmaskedContext(fiber);
  22305. if (fiber.tag === ClassComponent) {
  22306. var Component = fiber.type;
  22307. if (isContextProvider(Component)) {
  22308. return processChildContext(fiber, Component, parentContext);
  22309. }
  22310. }
  22311. return parentContext;
  22312. }
  22313. function findHostInstance(component) {
  22314. var fiber = get(component);
  22315. if (fiber === undefined) {
  22316. if (typeof component.render === 'function') {
  22317. {
  22318. {
  22319. throw Error("Unable to find node on an unmounted component.");
  22320. }
  22321. }
  22322. } else {
  22323. {
  22324. {
  22325. throw Error("Argument appears to not be a ReactComponent. Keys: " + Object.keys(component));
  22326. }
  22327. }
  22328. }
  22329. }
  22330. var hostFiber = findCurrentHostFiber(fiber);
  22331. if (hostFiber === null) {
  22332. return null;
  22333. }
  22334. return hostFiber.stateNode;
  22335. }
  22336. function findHostInstanceWithWarning(component, methodName) {
  22337. {
  22338. var fiber = get(component);
  22339. if (fiber === undefined) {
  22340. if (typeof component.render === 'function') {
  22341. {
  22342. {
  22343. throw Error("Unable to find node on an unmounted component.");
  22344. }
  22345. }
  22346. } else {
  22347. {
  22348. {
  22349. throw Error("Argument appears to not be a ReactComponent. Keys: " + Object.keys(component));
  22350. }
  22351. }
  22352. }
  22353. }
  22354. var hostFiber = findCurrentHostFiber(fiber);
  22355. if (hostFiber === null) {
  22356. return null;
  22357. }
  22358. if (hostFiber.mode & StrictMode) {
  22359. var componentName = getComponentName(fiber.type) || 'Component';
  22360. if (!didWarnAboutFindNodeInStrictMode[componentName]) {
  22361. didWarnAboutFindNodeInStrictMode[componentName] = true;
  22362. if (fiber.mode & StrictMode) {
  22363. warningWithoutStack$1(false, '%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which is inside StrictMode. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-find-node%s', methodName, methodName, componentName, getStackByFiberInDevAndProd(hostFiber));
  22364. } else {
  22365. warningWithoutStack$1(false, '%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which renders StrictMode children. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-find-node%s', methodName, methodName, componentName, getStackByFiberInDevAndProd(hostFiber));
  22366. }
  22367. }
  22368. }
  22369. return hostFiber.stateNode;
  22370. }
  22371. return findHostInstance(component);
  22372. }
  22373. function createContainer(containerInfo, tag, hydrate, hydrationCallbacks) {
  22374. return createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks);
  22375. }
  22376. function updateContainer(element, container, parentComponent, callback) {
  22377. var current$$1 = container.current;
  22378. var currentTime = requestCurrentTimeForUpdate();
  22379. {
  22380. // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
  22381. if ('undefined' !== typeof jest) {
  22382. warnIfUnmockedScheduler(current$$1);
  22383. warnIfNotScopedWithMatchingAct(current$$1);
  22384. }
  22385. }
  22386. var suspenseConfig = requestCurrentSuspenseConfig();
  22387. var expirationTime = computeExpirationForFiber(currentTime, current$$1, suspenseConfig);
  22388. {
  22389. if (ReactFiberInstrumentation_1.debugTool) {
  22390. if (current$$1.alternate === null) {
  22391. ReactFiberInstrumentation_1.debugTool.onMountContainer(container);
  22392. } else if (element === null) {
  22393. ReactFiberInstrumentation_1.debugTool.onUnmountContainer(container);
  22394. } else {
  22395. ReactFiberInstrumentation_1.debugTool.onUpdateContainer(container);
  22396. }
  22397. }
  22398. }
  22399. var context = getContextForSubtree(parentComponent);
  22400. if (container.context === null) {
  22401. container.context = context;
  22402. } else {
  22403. container.pendingContext = context;
  22404. }
  22405. {
  22406. if (phase === 'render' && current !== null && !didWarnAboutNestedUpdates) {
  22407. didWarnAboutNestedUpdates = true;
  22408. warningWithoutStack$1(false, 'Render methods should be a pure function of props and state; ' + 'triggering nested component updates from render is not allowed. ' + 'If necessary, trigger nested updates in componentDidUpdate.\n\n' + 'Check the render method of %s.', getComponentName(current.type) || 'Unknown');
  22409. }
  22410. }
  22411. var update = createUpdate(expirationTime, suspenseConfig); // Caution: React DevTools currently depends on this property
  22412. // being called "element".
  22413. update.payload = {
  22414. element: element
  22415. };
  22416. callback = callback === undefined ? null : callback;
  22417. if (callback !== null) {
  22418. !(typeof callback === 'function') ? warningWithoutStack$1(false, 'render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback) : void 0;
  22419. update.callback = callback;
  22420. }
  22421. enqueueUpdate(current$$1, update);
  22422. scheduleWork(current$$1, expirationTime);
  22423. return expirationTime;
  22424. }
  22425. function getPublicRootInstance(container) {
  22426. var containerFiber = container.current;
  22427. if (!containerFiber.child) {
  22428. return null;
  22429. }
  22430. switch (containerFiber.child.tag) {
  22431. case HostComponent:
  22432. return getPublicInstance(containerFiber.child.stateNode);
  22433. default:
  22434. return containerFiber.child.stateNode;
  22435. }
  22436. }
  22437. function attemptSynchronousHydration$1(fiber) {
  22438. switch (fiber.tag) {
  22439. case HostRoot:
  22440. var root = fiber.stateNode;
  22441. if (root.hydrate) {
  22442. // Flush the first scheduled "update".
  22443. flushRoot(root, root.firstPendingTime);
  22444. }
  22445. break;
  22446. case SuspenseComponent:
  22447. flushSync(function () {
  22448. return scheduleWork(fiber, Sync);
  22449. }); // If we're still blocked after this, we need to increase
  22450. // the priority of any promises resolving within this
  22451. // boundary so that they next attempt also has higher pri.
  22452. var retryExpTime = computeInteractiveExpiration(requestCurrentTimeForUpdate());
  22453. markRetryTimeIfNotHydrated(fiber, retryExpTime);
  22454. break;
  22455. }
  22456. }
  22457. function markRetryTimeImpl(fiber, retryTime) {
  22458. var suspenseState = fiber.memoizedState;
  22459. if (suspenseState !== null && suspenseState.dehydrated !== null) {
  22460. if (suspenseState.retryTime < retryTime) {
  22461. suspenseState.retryTime = retryTime;
  22462. }
  22463. }
  22464. } // Increases the priority of thennables when they resolve within this boundary.
  22465. function markRetryTimeIfNotHydrated(fiber, retryTime) {
  22466. markRetryTimeImpl(fiber, retryTime);
  22467. var alternate = fiber.alternate;
  22468. if (alternate) {
  22469. markRetryTimeImpl(alternate, retryTime);
  22470. }
  22471. }
  22472. function attemptUserBlockingHydration$1(fiber) {
  22473. if (fiber.tag !== SuspenseComponent) {
  22474. // We ignore HostRoots here because we can't increase
  22475. // their priority and they should not suspend on I/O,
  22476. // since you have to wrap anything that might suspend in
  22477. // Suspense.
  22478. return;
  22479. }
  22480. var expTime = computeInteractiveExpiration(requestCurrentTimeForUpdate());
  22481. scheduleWork(fiber, expTime);
  22482. markRetryTimeIfNotHydrated(fiber, expTime);
  22483. }
  22484. function attemptContinuousHydration$1(fiber) {
  22485. if (fiber.tag !== SuspenseComponent) {
  22486. // We ignore HostRoots here because we can't increase
  22487. // their priority and they should not suspend on I/O,
  22488. // since you have to wrap anything that might suspend in
  22489. // Suspense.
  22490. return;
  22491. }
  22492. var expTime = computeContinuousHydrationExpiration(requestCurrentTimeForUpdate());
  22493. scheduleWork(fiber, expTime);
  22494. markRetryTimeIfNotHydrated(fiber, expTime);
  22495. }
  22496. function attemptHydrationAtCurrentPriority$1(fiber) {
  22497. if (fiber.tag !== SuspenseComponent) {
  22498. // We ignore HostRoots here because we can't increase
  22499. // their priority other than synchronously flush it.
  22500. return;
  22501. }
  22502. var currentTime = requestCurrentTimeForUpdate();
  22503. var expTime = computeExpirationForFiber(currentTime, fiber, null);
  22504. scheduleWork(fiber, expTime);
  22505. markRetryTimeIfNotHydrated(fiber, expTime);
  22506. }
  22507. function findHostInstanceWithNoPortals(fiber) {
  22508. var hostFiber = findCurrentHostFiberWithNoPortals(fiber);
  22509. if (hostFiber === null) {
  22510. return null;
  22511. }
  22512. if (hostFiber.tag === FundamentalComponent) {
  22513. return hostFiber.stateNode.instance;
  22514. }
  22515. return hostFiber.stateNode;
  22516. }
  22517. var shouldSuspendImpl = function (fiber) {
  22518. return false;
  22519. };
  22520. function shouldSuspend(fiber) {
  22521. return shouldSuspendImpl(fiber);
  22522. }
  22523. var overrideHookState = null;
  22524. var overrideProps = null;
  22525. var scheduleUpdate = null;
  22526. var setSuspenseHandler = null;
  22527. {
  22528. var copyWithSetImpl = function (obj, path, idx, value) {
  22529. if (idx >= path.length) {
  22530. return value;
  22531. }
  22532. var key = path[idx];
  22533. var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj); // $FlowFixMe number or string is fine here
  22534. updated[key] = copyWithSetImpl(obj[key], path, idx + 1, value);
  22535. return updated;
  22536. };
  22537. var copyWithSet = function (obj, path, value) {
  22538. return copyWithSetImpl(obj, path, 0, value);
  22539. }; // Support DevTools editable values for useState and useReducer.
  22540. overrideHookState = function (fiber, id, path, value) {
  22541. // For now, the "id" of stateful hooks is just the stateful hook index.
  22542. // This may change in the future with e.g. nested hooks.
  22543. var currentHook = fiber.memoizedState;
  22544. while (currentHook !== null && id > 0) {
  22545. currentHook = currentHook.next;
  22546. id--;
  22547. }
  22548. if (currentHook !== null) {
  22549. var newState = copyWithSet(currentHook.memoizedState, path, value);
  22550. currentHook.memoizedState = newState;
  22551. currentHook.baseState = newState; // We aren't actually adding an update to the queue,
  22552. // because there is no update we can add for useReducer hooks that won't trigger an error.
  22553. // (There's no appropriate action type for DevTools overrides.)
  22554. // As a result though, React will see the scheduled update as a noop and bailout.
  22555. // Shallow cloning props works as a workaround for now to bypass the bailout check.
  22556. fiber.memoizedProps = _assign({}, fiber.memoizedProps);
  22557. scheduleWork(fiber, Sync);
  22558. }
  22559. }; // Support DevTools props for function components, forwardRef, memo, host components, etc.
  22560. overrideProps = function (fiber, path, value) {
  22561. fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value);
  22562. if (fiber.alternate) {
  22563. fiber.alternate.pendingProps = fiber.pendingProps;
  22564. }
  22565. scheduleWork(fiber, Sync);
  22566. };
  22567. scheduleUpdate = function (fiber) {
  22568. scheduleWork(fiber, Sync);
  22569. };
  22570. setSuspenseHandler = function (newShouldSuspendImpl) {
  22571. shouldSuspendImpl = newShouldSuspendImpl;
  22572. };
  22573. }
  22574. function injectIntoDevTools(devToolsConfig) {
  22575. var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
  22576. var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
  22577. return injectInternals(_assign({}, devToolsConfig, {
  22578. overrideHookState: overrideHookState,
  22579. overrideProps: overrideProps,
  22580. setSuspenseHandler: setSuspenseHandler,
  22581. scheduleUpdate: scheduleUpdate,
  22582. currentDispatcherRef: ReactCurrentDispatcher,
  22583. findHostInstanceByFiber: function (fiber) {
  22584. var hostFiber = findCurrentHostFiber(fiber);
  22585. if (hostFiber === null) {
  22586. return null;
  22587. }
  22588. return hostFiber.stateNode;
  22589. },
  22590. findFiberByHostInstance: function (instance) {
  22591. if (!findFiberByHostInstance) {
  22592. // Might not be implemented by the renderer.
  22593. return null;
  22594. }
  22595. return findFiberByHostInstance(instance);
  22596. },
  22597. // React Refresh
  22598. findHostInstancesForRefresh: findHostInstancesForRefresh,
  22599. scheduleRefresh: scheduleRefresh,
  22600. scheduleRoot: scheduleRoot,
  22601. setRefreshHandler: setRefreshHandler,
  22602. // Enables DevTools to append owner stacks to error messages in DEV mode.
  22603. getCurrentFiber: function () {
  22604. return current;
  22605. }
  22606. }));
  22607. }
  22608. // This file intentionally does *not* have the Flow annotation.
  22609. // Don't add it. See `./inline-typed.js` for an explanation.
  22610. // TODO: This type is shared between the reconciler and ReactDOM, but will
  22611. // eventually be lifted out to the renderer.
  22612. function ReactDOMRoot(container, options) {
  22613. this._internalRoot = createRootImpl(container, ConcurrentRoot, options);
  22614. }
  22615. function ReactDOMBlockingRoot(container, tag, options) {
  22616. this._internalRoot = createRootImpl(container, tag, options);
  22617. }
  22618. ReactDOMRoot.prototype.render = ReactDOMBlockingRoot.prototype.render = function (children, callback) {
  22619. var root = this._internalRoot;
  22620. var cb = callback === undefined ? null : callback;
  22621. {
  22622. warnOnInvalidCallback(cb, 'render');
  22623. }
  22624. updateContainer(children, root, null, cb);
  22625. };
  22626. ReactDOMRoot.prototype.unmount = ReactDOMBlockingRoot.prototype.unmount = function (callback) {
  22627. var root = this._internalRoot;
  22628. var cb = callback === undefined ? null : callback;
  22629. {
  22630. warnOnInvalidCallback(cb, 'render');
  22631. }
  22632. var container = root.containerInfo;
  22633. updateContainer(null, root, null, function () {
  22634. unmarkContainerAsRoot(container);
  22635. if (cb !== null) {
  22636. cb();
  22637. }
  22638. });
  22639. };
  22640. function createRootImpl(container, tag, options) {
  22641. // Tag is either LegacyRoot or Concurrent Root
  22642. var hydrate = options != null && options.hydrate === true;
  22643. var hydrationCallbacks = options != null && options.hydrationOptions || null;
  22644. var root = createContainer(container, tag, hydrate, hydrationCallbacks);
  22645. markContainerAsRoot(root.current, container);
  22646. if (hydrate && tag !== LegacyRoot) {
  22647. var doc = container.nodeType === DOCUMENT_NODE ? container : container.ownerDocument;
  22648. eagerlyTrapReplayableEvents(doc);
  22649. }
  22650. return root;
  22651. }
  22652. function createRoot(container, options) {
  22653. if (!isValidContainer(container)) {
  22654. {
  22655. throw Error("createRoot(...): Target container is not a DOM element.");
  22656. }
  22657. }
  22658. warnIfReactDOMContainerInDEV(container);
  22659. return new ReactDOMRoot(container, options);
  22660. }
  22661. function createBlockingRoot(container, options) {
  22662. if (!isValidContainer(container)) {
  22663. {
  22664. throw Error("createRoot(...): Target container is not a DOM element.");
  22665. }
  22666. }
  22667. warnIfReactDOMContainerInDEV(container);
  22668. return new ReactDOMBlockingRoot(container, BlockingRoot, options);
  22669. }
  22670. function createLegacyRoot(container, options) {
  22671. return new ReactDOMBlockingRoot(container, LegacyRoot, options);
  22672. }
  22673. function isValidContainer(node) {
  22674. return !!(node && (node.nodeType === ELEMENT_NODE || node.nodeType === DOCUMENT_NODE || node.nodeType === DOCUMENT_FRAGMENT_NODE || node.nodeType === COMMENT_NODE && node.nodeValue === ' react-mount-point-unstable '));
  22675. }
  22676. function warnOnInvalidCallback(callback, callerName) {
  22677. {
  22678. !(callback === null || typeof callback === 'function') ? warningWithoutStack$1(false, '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback) : void 0;
  22679. }
  22680. }
  22681. function warnIfReactDOMContainerInDEV(container) {
  22682. {
  22683. if (isContainerMarkedAsRoot(container)) {
  22684. if (container._reactRootContainer) {
  22685. warningWithoutStack$1(false, 'You are calling ReactDOM.createRoot() on a container that was previously ' + 'passed to ReactDOM.render(). This is not supported.');
  22686. } else {
  22687. warningWithoutStack$1(false, 'You are calling ReactDOM.createRoot() on a container that ' + 'has already been passed to createRoot() before. Instead, call ' + 'root.render() on the existing root instead if you want to update it.');
  22688. }
  22689. }
  22690. }
  22691. }
  22692. var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
  22693. var topLevelUpdateWarnings;
  22694. var warnedAboutHydrateAPI = false;
  22695. {
  22696. topLevelUpdateWarnings = function (container) {
  22697. if (container._reactRootContainer && container.nodeType !== COMMENT_NODE) {
  22698. var hostInstance = findHostInstanceWithNoPortals(container._reactRootContainer._internalRoot.current);
  22699. if (hostInstance) {
  22700. !(hostInstance.parentNode === container) ? warningWithoutStack$1(false, 'render(...): It looks like the React-rendered content of this ' + 'container was removed without using React. This is not ' + 'supported and will cause errors. Instead, call ' + 'ReactDOM.unmountComponentAtNode to empty a container.') : void 0;
  22701. }
  22702. }
  22703. var isRootRenderedBySomeReact = !!container._reactRootContainer;
  22704. var rootEl = getReactRootElementInContainer(container);
  22705. var hasNonRootReactChild = !!(rootEl && getInstanceFromNode$1(rootEl));
  22706. !(!hasNonRootReactChild || isRootRenderedBySomeReact) ? warningWithoutStack$1(false, 'render(...): Replacing React-rendered children with a new root ' + 'component. If you intended to update the children of this node, ' + 'you should instead have the existing children update their state ' + 'and render the new components instead of calling ReactDOM.render.') : void 0;
  22707. !(container.nodeType !== ELEMENT_NODE || !container.tagName || container.tagName.toUpperCase() !== 'BODY') ? warningWithoutStack$1(false, 'render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.') : void 0;
  22708. };
  22709. }
  22710. function getReactRootElementInContainer(container) {
  22711. if (!container) {
  22712. return null;
  22713. }
  22714. if (container.nodeType === DOCUMENT_NODE) {
  22715. return container.documentElement;
  22716. } else {
  22717. return container.firstChild;
  22718. }
  22719. }
  22720. function shouldHydrateDueToLegacyHeuristic(container) {
  22721. var rootElement = getReactRootElementInContainer(container);
  22722. return !!(rootElement && rootElement.nodeType === ELEMENT_NODE && rootElement.hasAttribute(ROOT_ATTRIBUTE_NAME));
  22723. }
  22724. function legacyCreateRootFromDOMContainer(container, forceHydrate) {
  22725. var shouldHydrate = forceHydrate || shouldHydrateDueToLegacyHeuristic(container); // First clear any existing content.
  22726. if (!shouldHydrate) {
  22727. var warned = false;
  22728. var rootSibling;
  22729. while (rootSibling = container.lastChild) {
  22730. {
  22731. if (!warned && rootSibling.nodeType === ELEMENT_NODE && rootSibling.hasAttribute(ROOT_ATTRIBUTE_NAME)) {
  22732. warned = true;
  22733. warningWithoutStack$1(false, 'render(): Target node has markup rendered by React, but there ' + 'are unrelated nodes as well. This is most commonly caused by ' + 'white-space inserted around server-rendered markup.');
  22734. }
  22735. }
  22736. container.removeChild(rootSibling);
  22737. }
  22738. }
  22739. {
  22740. if (shouldHydrate && !forceHydrate && !warnedAboutHydrateAPI) {
  22741. warnedAboutHydrateAPI = true;
  22742. lowPriorityWarningWithoutStack$1(false, 'render(): Calling ReactDOM.render() to hydrate server-rendered markup ' + 'will stop working in React v17. Replace the ReactDOM.render() call ' + 'with ReactDOM.hydrate() if you want React to attach to the server HTML.');
  22743. }
  22744. }
  22745. return createLegacyRoot(container, shouldHydrate ? {
  22746. hydrate: true
  22747. } : undefined);
  22748. }
  22749. function legacyRenderSubtreeIntoContainer(parentComponent, children, container, forceHydrate, callback) {
  22750. {
  22751. topLevelUpdateWarnings(container);
  22752. warnOnInvalidCallback(callback === undefined ? null : callback, 'render');
  22753. } // TODO: Without `any` type, Flow says "Property cannot be accessed on any
  22754. // member of intersection type." Whyyyyyy.
  22755. var root = container._reactRootContainer;
  22756. var fiberRoot;
  22757. if (!root) {
  22758. // Initial mount
  22759. root = container._reactRootContainer = legacyCreateRootFromDOMContainer(container, forceHydrate);
  22760. fiberRoot = root._internalRoot;
  22761. if (typeof callback === 'function') {
  22762. var originalCallback = callback;
  22763. callback = function () {
  22764. var instance = getPublicRootInstance(fiberRoot);
  22765. originalCallback.call(instance);
  22766. };
  22767. } // Initial mount should not be batched.
  22768. unbatchedUpdates(function () {
  22769. updateContainer(children, fiberRoot, parentComponent, callback);
  22770. });
  22771. } else {
  22772. fiberRoot = root._internalRoot;
  22773. if (typeof callback === 'function') {
  22774. var _originalCallback = callback;
  22775. callback = function () {
  22776. var instance = getPublicRootInstance(fiberRoot);
  22777. _originalCallback.call(instance);
  22778. };
  22779. } // Update
  22780. updateContainer(children, fiberRoot, parentComponent, callback);
  22781. }
  22782. return getPublicRootInstance(fiberRoot);
  22783. }
  22784. function findDOMNode(componentOrElement) {
  22785. {
  22786. var owner = ReactCurrentOwner$1.current;
  22787. if (owner !== null && owner.stateNode !== null) {
  22788. var warnedAboutRefsInRender = owner.stateNode._warnedAboutRefsInRender;
  22789. !warnedAboutRefsInRender ? warningWithoutStack$1(false, '%s is accessing findDOMNode inside its render(). ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(owner.type) || 'A component') : void 0;
  22790. owner.stateNode._warnedAboutRefsInRender = true;
  22791. }
  22792. }
  22793. if (componentOrElement == null) {
  22794. return null;
  22795. }
  22796. if (componentOrElement.nodeType === ELEMENT_NODE) {
  22797. return componentOrElement;
  22798. }
  22799. {
  22800. return findHostInstanceWithWarning(componentOrElement, 'findDOMNode');
  22801. }
  22802. return findHostInstance(componentOrElement);
  22803. }
  22804. function hydrate(element, container, callback) {
  22805. if (!isValidContainer(container)) {
  22806. {
  22807. throw Error("Target container is not a DOM element.");
  22808. }
  22809. }
  22810. {
  22811. var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined;
  22812. if (isModernRoot) {
  22813. warningWithoutStack$1(false, 'You are calling ReactDOM.hydrate() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. ' + 'Did you mean to call createRoot(container, {hydrate: true}).render(element)?');
  22814. }
  22815. } // TODO: throw or warn if we couldn't hydrate?
  22816. return legacyRenderSubtreeIntoContainer(null, element, container, true, callback);
  22817. }
  22818. function render(element, container, callback) {
  22819. if (!isValidContainer(container)) {
  22820. {
  22821. throw Error("Target container is not a DOM element.");
  22822. }
  22823. }
  22824. {
  22825. var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined;
  22826. if (isModernRoot) {
  22827. warningWithoutStack$1(false, 'You are calling ReactDOM.render() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. ' + 'Did you mean to call root.render(element)?');
  22828. }
  22829. }
  22830. return legacyRenderSubtreeIntoContainer(null, element, container, false, callback);
  22831. }
  22832. function unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) {
  22833. if (!isValidContainer(containerNode)) {
  22834. {
  22835. throw Error("Target container is not a DOM element.");
  22836. }
  22837. }
  22838. if (!(parentComponent != null && has(parentComponent))) {
  22839. {
  22840. throw Error("parentComponent must be a valid React Component");
  22841. }
  22842. }
  22843. return legacyRenderSubtreeIntoContainer(parentComponent, element, containerNode, false, callback);
  22844. }
  22845. function unmountComponentAtNode(container) {
  22846. if (!isValidContainer(container)) {
  22847. {
  22848. throw Error("unmountComponentAtNode(...): Target container is not a DOM element.");
  22849. }
  22850. }
  22851. {
  22852. var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined;
  22853. if (isModernRoot) {
  22854. warningWithoutStack$1(false, 'You are calling ReactDOM.unmountComponentAtNode() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. Did you mean to call root.unmount()?');
  22855. }
  22856. }
  22857. if (container._reactRootContainer) {
  22858. {
  22859. var rootEl = getReactRootElementInContainer(container);
  22860. var renderedByDifferentReact = rootEl && !getInstanceFromNode$1(rootEl);
  22861. !!renderedByDifferentReact ? warningWithoutStack$1(false, "unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by another copy of React.') : void 0;
  22862. } // Unmount should not be batched.
  22863. unbatchedUpdates(function () {
  22864. legacyRenderSubtreeIntoContainer(null, null, container, false, function () {
  22865. container._reactRootContainer = null;
  22866. unmarkContainerAsRoot(container);
  22867. });
  22868. }); // If you call unmountComponentAtNode twice in quick succession, you'll
  22869. // get `true` twice. That's probably fine?
  22870. return true;
  22871. } else {
  22872. {
  22873. var _rootEl = getReactRootElementInContainer(container);
  22874. var hasNonRootReactChild = !!(_rootEl && getInstanceFromNode$1(_rootEl)); // Check if the container itself is a React root node.
  22875. var isContainerReactRoot = container.nodeType === ELEMENT_NODE && isValidContainer(container.parentNode) && !!container.parentNode._reactRootContainer;
  22876. !!hasNonRootReactChild ? warningWithoutStack$1(false, "unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by React and is not a top-level container. %s', isContainerReactRoot ? 'You may have accidentally passed in a React root node instead ' + 'of its container.' : 'Instead, have the parent component update its state and ' + 'rerender in order to remove this component.') : void 0;
  22877. }
  22878. return false;
  22879. }
  22880. }
  22881. function createPortal$1(children, containerInfo, // TODO: figure out the API for cross-renderer implementation.
  22882. implementation) {
  22883. var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  22884. return {
  22885. // This tag allow us to uniquely identify this as a React Portal
  22886. $$typeof: REACT_PORTAL_TYPE,
  22887. key: key == null ? null : '' + key,
  22888. children: children,
  22889. containerInfo: containerInfo,
  22890. implementation: implementation
  22891. };
  22892. }
  22893. // TODO: this is special because it gets imported during build.
  22894. var ReactVersion = '16.12.0';
  22895. setAttemptSynchronousHydration(attemptSynchronousHydration$1);
  22896. setAttemptUserBlockingHydration(attemptUserBlockingHydration$1);
  22897. setAttemptContinuousHydration(attemptContinuousHydration$1);
  22898. setAttemptHydrationAtCurrentPriority(attemptHydrationAtCurrentPriority$1);
  22899. var didWarnAboutUnstableCreatePortal = false;
  22900. {
  22901. if (typeof Map !== 'function' || // $FlowIssue Flow incorrectly thinks Map has no prototype
  22902. Map.prototype == null || typeof Map.prototype.forEach !== 'function' || typeof Set !== 'function' || // $FlowIssue Flow incorrectly thinks Set has no prototype
  22903. Set.prototype == null || typeof Set.prototype.clear !== 'function' || typeof Set.prototype.forEach !== 'function') {
  22904. warningWithoutStack$1(false, 'React depends on Map and Set built-in types. Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
  22905. }
  22906. }
  22907. setRestoreImplementation(restoreControlledState$$1);
  22908. setBatchingImplementation(batchedUpdates$1, discreteUpdates$1, flushDiscreteUpdates, batchedEventUpdates$1);
  22909. function createPortal$$1(children, container) {
  22910. var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  22911. if (!isValidContainer(container)) {
  22912. {
  22913. throw Error("Target container is not a DOM element.");
  22914. }
  22915. } // TODO: pass ReactDOM portal implementation as third argument
  22916. return createPortal$1(children, container, null, key);
  22917. }
  22918. var ReactDOM = {
  22919. createPortal: createPortal$$1,
  22920. // Legacy
  22921. findDOMNode: findDOMNode,
  22922. hydrate: hydrate,
  22923. render: render,
  22924. unstable_renderSubtreeIntoContainer: unstable_renderSubtreeIntoContainer,
  22925. unmountComponentAtNode: unmountComponentAtNode,
  22926. // Temporary alias since we already shipped React 16 RC with it.
  22927. // TODO: remove in React 17.
  22928. unstable_createPortal: function () {
  22929. if (!didWarnAboutUnstableCreatePortal) {
  22930. didWarnAboutUnstableCreatePortal = true;
  22931. lowPriorityWarningWithoutStack$1(false, 'The ReactDOM.unstable_createPortal() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactDOM.createPortal() instead. It has the exact same API, ' + 'but without the "unstable_" prefix.');
  22932. }
  22933. return createPortal$$1.apply(void 0, arguments);
  22934. },
  22935. unstable_batchedUpdates: batchedUpdates$1,
  22936. flushSync: flushSync,
  22937. __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
  22938. // Keep in sync with ReactDOMUnstableNativeDependencies.js
  22939. // ReactTestUtils.js, and ReactTestUtilsAct.js. This is an array for better minification.
  22940. Events: [getInstanceFromNode$1, getNodeFromInstance$1, getFiberCurrentPropsFromNode$1, injection.injectEventPluginsByName, eventNameDispatchConfigs, accumulateTwoPhaseDispatches, accumulateDirectDispatches, enqueueStateRestore, restoreStateIfNeeded, dispatchEvent, runEventsInBatch, flushPassiveEffects, IsThisRendererActing]
  22941. }
  22942. };
  22943. if (exposeConcurrentModeAPIs) {
  22944. ReactDOM.createRoot = createRoot;
  22945. ReactDOM.createBlockingRoot = createBlockingRoot;
  22946. ReactDOM.unstable_discreteUpdates = discreteUpdates$1;
  22947. ReactDOM.unstable_flushDiscreteUpdates = flushDiscreteUpdates;
  22948. ReactDOM.unstable_flushControlled = flushControlled;
  22949. ReactDOM.unstable_scheduleHydration = function (target) {
  22950. if (target) {
  22951. queueExplicitHydrationTarget(target);
  22952. }
  22953. };
  22954. }
  22955. var foundDevTools = injectIntoDevTools({
  22956. findFiberByHostInstance: getClosestInstanceFromNode,
  22957. bundleType: 1,
  22958. version: ReactVersion,
  22959. rendererPackageName: 'react-dom'
  22960. });
  22961. {
  22962. if (!foundDevTools && canUseDOM && window.top === window.self) {
  22963. // If we're in Chrome or Firefox, provide a download link if not installed.
  22964. if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) {
  22965. var protocol = window.location.protocol; // Don't warn in exotic cases like chrome-extension://.
  22966. if (/^(https?|file):$/.test(protocol)) {
  22967. console.info('%cDownload the React DevTools ' + 'for a better development experience: ' + 'https://fb.me/react-devtools' + (protocol === 'file:' ? '\nYou might need to use a local HTTP server (instead of file://): ' + 'https://fb.me/react-devtools-faq' : ''), 'font-weight:bold');
  22968. }
  22969. }
  22970. }
  22971. }
  22972. var ReactDOM$2 = Object.freeze({
  22973. default: ReactDOM
  22974. });
  22975. var ReactDOM$3 = ( ReactDOM$2 && ReactDOM ) || ReactDOM$2;
  22976. // TODO: decide on the top-level export form.
  22977. // This is hacky but makes it work with both Rollup and Jest.
  22978. var reactDom = ReactDOM$3.default || ReactDOM$3;
  22979. module.exports = reactDom;
  22980. })();
  22981. }