babylon.nodeEditor.max.js 830 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-nodeEditor", [], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-nodeEditor"] = factory();
  8. else
  9. root["NODEEDITOR"] = factory();
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/object-assign/index.js":
  99. /*!***************************************************************!*\
  100. !*** D:/Repos/Babylon.js/node_modules/object-assign/index.js ***!
  101. \***************************************************************/
  102. /*! no static exports found */
  103. /***/ (function(module, exports, __webpack_require__) {
  104. "use strict";
  105. /*
  106. object-assign
  107. (c) Sindre Sorhus
  108. @license MIT
  109. */
  110. /* eslint-disable no-unused-vars */
  111. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  112. var hasOwnProperty = Object.prototype.hasOwnProperty;
  113. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  114. function toObject(val) {
  115. if (val === null || val === undefined) {
  116. throw new TypeError('Object.assign cannot be called with null or undefined');
  117. }
  118. return Object(val);
  119. }
  120. function shouldUseNative() {
  121. try {
  122. if (!Object.assign) {
  123. return false;
  124. }
  125. // Detect buggy property enumeration order in older V8 versions.
  126. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  127. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  128. test1[5] = 'de';
  129. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  130. return false;
  131. }
  132. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  133. var test2 = {};
  134. for (var i = 0; i < 10; i++) {
  135. test2['_' + String.fromCharCode(i)] = i;
  136. }
  137. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  138. return test2[n];
  139. });
  140. if (order2.join('') !== '0123456789') {
  141. return false;
  142. }
  143. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  144. var test3 = {};
  145. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  146. test3[letter] = letter;
  147. });
  148. if (Object.keys(Object.assign({}, test3)).join('') !==
  149. 'abcdefghijklmnopqrst') {
  150. return false;
  151. }
  152. return true;
  153. } catch (err) {
  154. // We don't expect any of the above to throw, but better to be safe.
  155. return false;
  156. }
  157. }
  158. module.exports = shouldUseNative() ? Object.assign : function (target, source) {
  159. var from;
  160. var to = toObject(target);
  161. var symbols;
  162. for (var s = 1; s < arguments.length; s++) {
  163. from = Object(arguments[s]);
  164. for (var key in from) {
  165. if (hasOwnProperty.call(from, key)) {
  166. to[key] = from[key];
  167. }
  168. }
  169. if (getOwnPropertySymbols) {
  170. symbols = getOwnPropertySymbols(from);
  171. for (var i = 0; i < symbols.length; i++) {
  172. if (propIsEnumerable.call(from, symbols[i])) {
  173. to[symbols[i]] = from[symbols[i]];
  174. }
  175. }
  176. }
  177. }
  178. return to;
  179. };
  180. /***/ }),
  181. /***/ "../../node_modules/prop-types/checkPropTypes.js":
  182. /*!*********************************************************************!*\
  183. !*** D:/Repos/Babylon.js/node_modules/prop-types/checkPropTypes.js ***!
  184. \*********************************************************************/
  185. /*! no static exports found */
  186. /***/ (function(module, exports, __webpack_require__) {
  187. "use strict";
  188. /**
  189. * Copyright (c) 2013-present, Facebook, Inc.
  190. *
  191. * This source code is licensed under the MIT license found in the
  192. * LICENSE file in the root directory of this source tree.
  193. */
  194. var printWarning = function() {};
  195. if (true) {
  196. var ReactPropTypesSecret = __webpack_require__(/*! ./lib/ReactPropTypesSecret */ "../../node_modules/prop-types/lib/ReactPropTypesSecret.js");
  197. var loggedTypeFailures = {};
  198. printWarning = function(text) {
  199. var message = 'Warning: ' + text;
  200. if (typeof console !== 'undefined') {
  201. console.error(message);
  202. }
  203. try {
  204. // --- Welcome to debugging React ---
  205. // This error was thrown as a convenience so that you can use this stack
  206. // to find the callsite that caused this warning to fire.
  207. throw new Error(message);
  208. } catch (x) {}
  209. };
  210. }
  211. /**
  212. * Assert that the values match with the type specs.
  213. * Error messages are memorized and will only be shown once.
  214. *
  215. * @param {object} typeSpecs Map of name to a ReactPropType
  216. * @param {object} values Runtime values that need to be type-checked
  217. * @param {string} location e.g. "prop", "context", "child context"
  218. * @param {string} componentName Name of the component for error messages.
  219. * @param {?Function} getStack Returns the component stack.
  220. * @private
  221. */
  222. function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
  223. if (true) {
  224. for (var typeSpecName in typeSpecs) {
  225. if (typeSpecs.hasOwnProperty(typeSpecName)) {
  226. var error;
  227. // Prop type validation may throw. In case they do, we don't want to
  228. // fail the render phase where it didn't fail before. So we log it.
  229. // After these have been cleaned up, we'll let them throw.
  230. try {
  231. // This is intentionally an invariant that gets caught. It's the same
  232. // behavior as without this statement except with a better message.
  233. if (typeof typeSpecs[typeSpecName] !== 'function') {
  234. var err = Error(
  235. (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
  236. 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
  237. );
  238. err.name = 'Invariant Violation';
  239. throw err;
  240. }
  241. error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
  242. } catch (ex) {
  243. error = ex;
  244. }
  245. if (error && !(error instanceof Error)) {
  246. printWarning(
  247. (componentName || 'React class') + ': type specification of ' +
  248. location + ' `' + typeSpecName + '` is invalid; the type checker ' +
  249. 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
  250. 'You may have forgotten to pass an argument to the type checker ' +
  251. 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
  252. 'shape all require an argument).'
  253. )
  254. }
  255. if (error instanceof Error && !(error.message in loggedTypeFailures)) {
  256. // Only monitor this failure once because there tends to be a lot of the
  257. // same error.
  258. loggedTypeFailures[error.message] = true;
  259. var stack = getStack ? getStack() : '';
  260. printWarning(
  261. 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
  262. );
  263. }
  264. }
  265. }
  266. }
  267. }
  268. module.exports = checkPropTypes;
  269. /***/ }),
  270. /***/ "../../node_modules/prop-types/lib/ReactPropTypesSecret.js":
  271. /*!*******************************************************************************!*\
  272. !*** D:/Repos/Babylon.js/node_modules/prop-types/lib/ReactPropTypesSecret.js ***!
  273. \*******************************************************************************/
  274. /*! no static exports found */
  275. /***/ (function(module, exports, __webpack_require__) {
  276. "use strict";
  277. /**
  278. * Copyright (c) 2013-present, Facebook, Inc.
  279. *
  280. * This source code is licensed under the MIT license found in the
  281. * LICENSE file in the root directory of this source tree.
  282. */
  283. var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  284. module.exports = ReactPropTypesSecret;
  285. /***/ }),
  286. /***/ "../../node_modules/react-dom/cjs/react-dom.development.js":
  287. /*!*******************************************************************************!*\
  288. !*** D:/Repos/Babylon.js/node_modules/react-dom/cjs/react-dom.development.js ***!
  289. \*******************************************************************************/
  290. /*! no static exports found */
  291. /***/ (function(module, exports, __webpack_require__) {
  292. "use strict";
  293. /** @license React v16.6.1
  294. * react-dom.development.js
  295. *
  296. * Copyright (c) Facebook, Inc. and its affiliates.
  297. *
  298. * This source code is licensed under the MIT license found in the
  299. * LICENSE file in the root directory of this source tree.
  300. */
  301. if (true) {
  302. (function() {
  303. 'use strict';
  304. var React = __webpack_require__(/*! react */ "../../node_modules/react/index.js");
  305. var _assign = __webpack_require__(/*! object-assign */ "../../node_modules/object-assign/index.js");
  306. var checkPropTypes = __webpack_require__(/*! prop-types/checkPropTypes */ "../../node_modules/prop-types/checkPropTypes.js");
  307. var scheduler = __webpack_require__(/*! scheduler */ "../../node_modules/scheduler/index.js");
  308. var tracing = __webpack_require__(/*! scheduler/tracing */ "../../node_modules/scheduler/tracing.js");
  309. /**
  310. * Use invariant() to assert state which your program assumes to be true.
  311. *
  312. * Provide sprintf-style format (only %s is supported) and arguments
  313. * to provide information about what broke and what you were
  314. * expecting.
  315. *
  316. * The invariant message will be stripped in production, but the invariant
  317. * will remain to ensure logic does not differ in production.
  318. */
  319. var validateFormat = function () {};
  320. {
  321. validateFormat = function (format) {
  322. if (format === undefined) {
  323. throw new Error('invariant requires an error message argument');
  324. }
  325. };
  326. }
  327. function invariant(condition, format, a, b, c, d, e, f) {
  328. validateFormat(format);
  329. if (!condition) {
  330. var error = void 0;
  331. if (format === undefined) {
  332. error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
  333. } else {
  334. var args = [a, b, c, d, e, f];
  335. var argIndex = 0;
  336. error = new Error(format.replace(/%s/g, function () {
  337. return args[argIndex++];
  338. }));
  339. error.name = 'Invariant Violation';
  340. }
  341. error.framesToPop = 1; // we don't care about invariant's own frame
  342. throw error;
  343. }
  344. }
  345. // Relying on the `invariant()` implementation lets us
  346. // preserve the format and params in the www builds.
  347. !React ? invariant(false, 'ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM.') : void 0;
  348. var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) {
  349. var funcArgs = Array.prototype.slice.call(arguments, 3);
  350. try {
  351. func.apply(context, funcArgs);
  352. } catch (error) {
  353. this.onError(error);
  354. }
  355. };
  356. {
  357. // In DEV mode, we swap out invokeGuardedCallback for a special version
  358. // that plays more nicely with the browser's DevTools. The idea is to preserve
  359. // "Pause on exceptions" behavior. Because React wraps all user-provided
  360. // functions in invokeGuardedCallback, and the production version of
  361. // invokeGuardedCallback uses a try-catch, all user exceptions are treated
  362. // like caught exceptions, and the DevTools won't pause unless the developer
  363. // takes the extra step of enabling pause on caught exceptions. This is
  364. // untintuitive, though, because even though React has caught the error, from
  365. // the developer's perspective, the error is uncaught.
  366. //
  367. // To preserve the expected "Pause on exceptions" behavior, we don't use a
  368. // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake
  369. // DOM node, and call the user-provided callback from inside an event handler
  370. // for that fake event. If the callback throws, the error is "captured" using
  371. // a global event handler. But because the error happens in a different
  372. // event loop context, it does not interrupt the normal program flow.
  373. // Effectively, this gives us try-catch behavior without actually using
  374. // try-catch. Neat!
  375. // Check that the browser supports the APIs we need to implement our special
  376. // DEV version of invokeGuardedCallback
  377. if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
  378. var fakeNode = document.createElement('react');
  379. var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) {
  380. // If document doesn't exist we know for sure we will crash in this method
  381. // when we call document.createEvent(). However this can cause confusing
  382. // errors: https://github.com/facebookincubator/create-react-app/issues/3482
  383. // So we preemptively throw with a better message instead.
  384. !(typeof document !== 'undefined') ? invariant(false, '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.') : void 0;
  385. var evt = document.createEvent('Event');
  386. // Keeps track of whether the user-provided callback threw an error. We
  387. // set this to true at the beginning, then set it to false right after
  388. // calling the function. If the function errors, `didError` will never be
  389. // set to false. This strategy works even if the browser is flaky and
  390. // fails to call our global error handler, because it doesn't rely on
  391. // the error event at all.
  392. var didError = true;
  393. // Keeps track of the value of window.event so that we can reset it
  394. // during the callback to let user code access window.event in the
  395. // browsers that support it.
  396. var windowEvent = window.event;
  397. // Keeps track of the descriptor of window.event to restore it after event
  398. // dispatching: https://github.com/facebook/react/issues/13688
  399. var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event');
  400. // Create an event handler for our fake event. We will synchronously
  401. // dispatch our fake event using `dispatchEvent`. Inside the handler, we
  402. // call the user-provided callback.
  403. var funcArgs = Array.prototype.slice.call(arguments, 3);
  404. function callCallback() {
  405. // We immediately remove the callback from event listeners so that
  406. // nested `invokeGuardedCallback` calls do not clash. Otherwise, a
  407. // nested call would trigger the fake event handlers of any call higher
  408. // in the stack.
  409. fakeNode.removeEventListener(evtType, callCallback, false);
  410. // We check for window.hasOwnProperty('event') to prevent the
  411. // window.event assignment in both IE <= 10 as they throw an error
  412. // "Member not found" in strict mode, and in Firefox which does not
  413. // support window.event.
  414. if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) {
  415. window.event = windowEvent;
  416. }
  417. func.apply(context, funcArgs);
  418. didError = false;
  419. }
  420. // Create a global error event handler. We use this to capture the value
  421. // that was thrown. It's possible that this error handler will fire more
  422. // than once; for example, if non-React code also calls `dispatchEvent`
  423. // and a handler for that event throws. We should be resilient to most of
  424. // those cases. Even if our error event handler fires more than once, the
  425. // last error event is always used. If the callback actually does error,
  426. // we know that the last error event is the correct one, because it's not
  427. // possible for anything else to have happened in between our callback
  428. // erroring and the code that follows the `dispatchEvent` call below. If
  429. // the callback doesn't error, but the error event was fired, we know to
  430. // ignore it because `didError` will be false, as described above.
  431. var error = void 0;
  432. // Use this to track whether the error event is ever called.
  433. var didSetError = false;
  434. var isCrossOriginError = false;
  435. function handleWindowError(event) {
  436. error = event.error;
  437. didSetError = true;
  438. if (error === null && event.colno === 0 && event.lineno === 0) {
  439. isCrossOriginError = true;
  440. }
  441. if (event.defaultPrevented) {
  442. // Some other error handler has prevented default.
  443. // Browsers silence the error report if this happens.
  444. // We'll remember this to later decide whether to log it or not.
  445. if (error != null && typeof error === 'object') {
  446. try {
  447. error._suppressLogging = true;
  448. } catch (inner) {
  449. // Ignore.
  450. }
  451. }
  452. }
  453. }
  454. // Create a fake event type.
  455. var evtType = 'react-' + (name ? name : 'invokeguardedcallback');
  456. // Attach our event handlers
  457. window.addEventListener('error', handleWindowError);
  458. fakeNode.addEventListener(evtType, callCallback, false);
  459. // Synchronously dispatch our fake event. If the user-provided function
  460. // errors, it will trigger our global error handler.
  461. evt.initEvent(evtType, false, false);
  462. fakeNode.dispatchEvent(evt);
  463. if (windowEventDescriptor) {
  464. Object.defineProperty(window, 'event', windowEventDescriptor);
  465. }
  466. if (didError) {
  467. if (!didSetError) {
  468. // The callback errored, but the error event never fired.
  469. 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.');
  470. } else if (isCrossOriginError) {
  471. 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.');
  472. }
  473. this.onError(error);
  474. }
  475. // Remove our event listeners
  476. window.removeEventListener('error', handleWindowError);
  477. };
  478. invokeGuardedCallbackImpl = invokeGuardedCallbackDev;
  479. }
  480. }
  481. var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl;
  482. // Used by Fiber to simulate a try-catch.
  483. var hasError = false;
  484. var caughtError = null;
  485. // Used by event system to capture/rethrow the first error.
  486. var hasRethrowError = false;
  487. var rethrowError = null;
  488. var reporter = {
  489. onError: function (error) {
  490. hasError = true;
  491. caughtError = error;
  492. }
  493. };
  494. /**
  495. * Call a function while guarding against errors that happens within it.
  496. * Returns an error if it throws, otherwise null.
  497. *
  498. * In production, this is implemented using a try-catch. The reason we don't
  499. * use a try-catch directly is so that we can swap out a different
  500. * implementation in DEV mode.
  501. *
  502. * @param {String} name of the guard to use for logging or debugging
  503. * @param {Function} func The function to invoke
  504. * @param {*} context The context to use when calling the function
  505. * @param {...*} args Arguments for function
  506. */
  507. function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
  508. hasError = false;
  509. caughtError = null;
  510. invokeGuardedCallbackImpl$1.apply(reporter, arguments);
  511. }
  512. /**
  513. * Same as invokeGuardedCallback, but instead of returning an error, it stores
  514. * it in a global so it can be rethrown by `rethrowCaughtError` later.
  515. * TODO: See if caughtError and rethrowError can be unified.
  516. *
  517. * @param {String} name of the guard to use for logging or debugging
  518. * @param {Function} func The function to invoke
  519. * @param {*} context The context to use when calling the function
  520. * @param {...*} args Arguments for function
  521. */
  522. function invokeGuardedCallbackAndCatchFirstError(name, func, context, a, b, c, d, e, f) {
  523. invokeGuardedCallback.apply(this, arguments);
  524. if (hasError) {
  525. var error = clearCaughtError();
  526. if (!hasRethrowError) {
  527. hasRethrowError = true;
  528. rethrowError = error;
  529. }
  530. }
  531. }
  532. /**
  533. * During execution of guarded functions we will capture the first error which
  534. * we will rethrow to be handled by the top level error handler.
  535. */
  536. function rethrowCaughtError() {
  537. if (hasRethrowError) {
  538. var error = rethrowError;
  539. hasRethrowError = false;
  540. rethrowError = null;
  541. throw error;
  542. }
  543. }
  544. function hasCaughtError() {
  545. return hasError;
  546. }
  547. function clearCaughtError() {
  548. if (hasError) {
  549. var error = caughtError;
  550. hasError = false;
  551. caughtError = null;
  552. return error;
  553. } else {
  554. invariant(false, 'clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue.');
  555. }
  556. }
  557. /**
  558. * Injectable ordering of event plugins.
  559. */
  560. var eventPluginOrder = null;
  561. /**
  562. * Injectable mapping from names to event plugin modules.
  563. */
  564. var namesToPlugins = {};
  565. /**
  566. * Recomputes the plugin list using the injected plugins and plugin ordering.
  567. *
  568. * @private
  569. */
  570. function recomputePluginOrdering() {
  571. if (!eventPluginOrder) {
  572. // Wait until an `eventPluginOrder` is injected.
  573. return;
  574. }
  575. for (var pluginName in namesToPlugins) {
  576. var pluginModule = namesToPlugins[pluginName];
  577. var pluginIndex = eventPluginOrder.indexOf(pluginName);
  578. !(pluginIndex > -1) ? invariant(false, 'EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `%s`.', pluginName) : void 0;
  579. if (plugins[pluginIndex]) {
  580. continue;
  581. }
  582. !pluginModule.extractEvents ? invariant(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.', pluginName) : void 0;
  583. plugins[pluginIndex] = pluginModule;
  584. var publishedEvents = pluginModule.eventTypes;
  585. for (var eventName in publishedEvents) {
  586. !publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName) ? invariant(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : void 0;
  587. }
  588. }
  589. }
  590. /**
  591. * Publishes an event so that it can be dispatched by the supplied plugin.
  592. *
  593. * @param {object} dispatchConfig Dispatch configuration for the event.
  594. * @param {object} PluginModule Plugin publishing the event.
  595. * @return {boolean} True if the event was successfully published.
  596. * @private
  597. */
  598. function publishEventForPlugin(dispatchConfig, pluginModule, eventName) {
  599. !!eventNameDispatchConfigs.hasOwnProperty(eventName) ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same event name, `%s`.', eventName) : void 0;
  600. eventNameDispatchConfigs[eventName] = dispatchConfig;
  601. var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
  602. if (phasedRegistrationNames) {
  603. for (var phaseName in phasedRegistrationNames) {
  604. if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
  605. var phasedRegistrationName = phasedRegistrationNames[phaseName];
  606. publishRegistrationName(phasedRegistrationName, pluginModule, eventName);
  607. }
  608. }
  609. return true;
  610. } else if (dispatchConfig.registrationName) {
  611. publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName);
  612. return true;
  613. }
  614. return false;
  615. }
  616. /**
  617. * Publishes a registration name that is used to identify dispatched events.
  618. *
  619. * @param {string} registrationName Registration name to add.
  620. * @param {object} PluginModule Plugin publishing the event.
  621. * @private
  622. */
  623. function publishRegistrationName(registrationName, pluginModule, eventName) {
  624. !!registrationNameModules[registrationName] ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same registration name, `%s`.', registrationName) : void 0;
  625. registrationNameModules[registrationName] = pluginModule;
  626. registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies;
  627. {
  628. var lowerCasedName = registrationName.toLowerCase();
  629. possibleRegistrationNames[lowerCasedName] = registrationName;
  630. if (registrationName === 'onDoubleClick') {
  631. possibleRegistrationNames.ondblclick = registrationName;
  632. }
  633. }
  634. }
  635. /**
  636. * Registers plugins so that they can extract and dispatch events.
  637. *
  638. * @see {EventPluginHub}
  639. */
  640. /**
  641. * Ordered list of injected plugins.
  642. */
  643. var plugins = [];
  644. /**
  645. * Mapping from event name to dispatch config
  646. */
  647. var eventNameDispatchConfigs = {};
  648. /**
  649. * Mapping from registration name to plugin module
  650. */
  651. var registrationNameModules = {};
  652. /**
  653. * Mapping from registration name to event name
  654. */
  655. var registrationNameDependencies = {};
  656. /**
  657. * Mapping from lowercase registration names to the properly cased version,
  658. * used to warn in the case of missing event handlers. Available
  659. * only in true.
  660. * @type {Object}
  661. */
  662. var possibleRegistrationNames = {};
  663. // Trust the developer to only use possibleRegistrationNames in true
  664. /**
  665. * Injects an ordering of plugins (by plugin name). This allows the ordering
  666. * to be decoupled from injection of the actual plugins so that ordering is
  667. * always deterministic regardless of packaging, on-the-fly injection, etc.
  668. *
  669. * @param {array} InjectedEventPluginOrder
  670. * @internal
  671. * @see {EventPluginHub.injection.injectEventPluginOrder}
  672. */
  673. function injectEventPluginOrder(injectedEventPluginOrder) {
  674. !!eventPluginOrder ? invariant(false, 'EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React.') : void 0;
  675. // Clone the ordering so it cannot be dynamically mutated.
  676. eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder);
  677. recomputePluginOrdering();
  678. }
  679. /**
  680. * Injects plugins to be used by `EventPluginHub`. The plugin names must be
  681. * in the ordering injected by `injectEventPluginOrder`.
  682. *
  683. * Plugins can be injected as part of page initialization or on-the-fly.
  684. *
  685. * @param {object} injectedNamesToPlugins Map from names to plugin modules.
  686. * @internal
  687. * @see {EventPluginHub.injection.injectEventPluginsByName}
  688. */
  689. function injectEventPluginsByName(injectedNamesToPlugins) {
  690. var isOrderingDirty = false;
  691. for (var pluginName in injectedNamesToPlugins) {
  692. if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
  693. continue;
  694. }
  695. var pluginModule = injectedNamesToPlugins[pluginName];
  696. if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule) {
  697. !!namesToPlugins[pluginName] ? invariant(false, 'EventPluginRegistry: Cannot inject two different event plugins using the same name, `%s`.', pluginName) : void 0;
  698. namesToPlugins[pluginName] = pluginModule;
  699. isOrderingDirty = true;
  700. }
  701. }
  702. if (isOrderingDirty) {
  703. recomputePluginOrdering();
  704. }
  705. }
  706. /**
  707. * Similar to invariant but only logs a warning if the condition is not met.
  708. * This can be used to log issues in development environments in critical
  709. * paths. Removing the logging code for production environments will keep the
  710. * same logic and follow the same code paths.
  711. */
  712. var warningWithoutStack = function () {};
  713. {
  714. warningWithoutStack = function (condition, format) {
  715. for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  716. args[_key - 2] = arguments[_key];
  717. }
  718. if (format === undefined) {
  719. throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
  720. }
  721. if (args.length > 8) {
  722. // Check before the condition to catch violations early.
  723. throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
  724. }
  725. if (condition) {
  726. return;
  727. }
  728. if (typeof console !== 'undefined') {
  729. var argsWithFormat = args.map(function (item) {
  730. return '' + item;
  731. });
  732. argsWithFormat.unshift('Warning: ' + format);
  733. // We intentionally don't use spread (or .apply) directly because it
  734. // breaks IE9: https://github.com/facebook/react/issues/13610
  735. Function.prototype.apply.call(console.error, console, argsWithFormat);
  736. }
  737. try {
  738. // --- Welcome to debugging React ---
  739. // This error was thrown as a convenience so that you can use this stack
  740. // to find the callsite that caused this warning to fire.
  741. var argIndex = 0;
  742. var message = 'Warning: ' + format.replace(/%s/g, function () {
  743. return args[argIndex++];
  744. });
  745. throw new Error(message);
  746. } catch (x) {}
  747. };
  748. }
  749. var warningWithoutStack$1 = warningWithoutStack;
  750. var getFiberCurrentPropsFromNode = null;
  751. var getInstanceFromNode = null;
  752. var getNodeFromInstance = null;
  753. function setComponentTree(getFiberCurrentPropsFromNodeImpl, getInstanceFromNodeImpl, getNodeFromInstanceImpl) {
  754. getFiberCurrentPropsFromNode = getFiberCurrentPropsFromNodeImpl;
  755. getInstanceFromNode = getInstanceFromNodeImpl;
  756. getNodeFromInstance = getNodeFromInstanceImpl;
  757. {
  758. !(getNodeFromInstance && getInstanceFromNode) ? warningWithoutStack$1(false, 'EventPluginUtils.setComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.') : void 0;
  759. }
  760. }
  761. var validateEventDispatches = void 0;
  762. {
  763. validateEventDispatches = function (event) {
  764. var dispatchListeners = event._dispatchListeners;
  765. var dispatchInstances = event._dispatchInstances;
  766. var listenersIsArr = Array.isArray(dispatchListeners);
  767. var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
  768. var instancesIsArr = Array.isArray(dispatchInstances);
  769. var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0;
  770. !(instancesIsArr === listenersIsArr && instancesLen === listenersLen) ? warningWithoutStack$1(false, 'EventPluginUtils: Invalid `event`.') : void 0;
  771. };
  772. }
  773. /**
  774. * Dispatch the event to the listener.
  775. * @param {SyntheticEvent} event SyntheticEvent to handle
  776. * @param {function} listener Application-level callback
  777. * @param {*} inst Internal component instance
  778. */
  779. function executeDispatch(event, listener, inst) {
  780. var type = event.type || 'unknown-event';
  781. event.currentTarget = getNodeFromInstance(inst);
  782. invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event);
  783. event.currentTarget = null;
  784. }
  785. /**
  786. * Standard/simple iteration through an event's collected dispatches.
  787. */
  788. function executeDispatchesInOrder(event) {
  789. var dispatchListeners = event._dispatchListeners;
  790. var dispatchInstances = event._dispatchInstances;
  791. {
  792. validateEventDispatches(event);
  793. }
  794. if (Array.isArray(dispatchListeners)) {
  795. for (var i = 0; i < dispatchListeners.length; i++) {
  796. if (event.isPropagationStopped()) {
  797. break;
  798. }
  799. // Listeners and Instances are two parallel arrays that are always in sync.
  800. executeDispatch(event, dispatchListeners[i], dispatchInstances[i]);
  801. }
  802. } else if (dispatchListeners) {
  803. executeDispatch(event, dispatchListeners, dispatchInstances);
  804. }
  805. event._dispatchListeners = null;
  806. event._dispatchInstances = null;
  807. }
  808. /**
  809. * @see executeDispatchesInOrderStopAtTrueImpl
  810. */
  811. /**
  812. * Execution of a "direct" dispatch - there must be at most one dispatch
  813. * accumulated on the event or it is considered an error. It doesn't really make
  814. * sense for an event with multiple dispatches (bubbled) to keep track of the
  815. * return values at each dispatch execution, but it does tend to make sense when
  816. * dealing with "direct" dispatches.
  817. *
  818. * @return {*} The return value of executing the single dispatch.
  819. */
  820. /**
  821. * @param {SyntheticEvent} event
  822. * @return {boolean} True iff number of dispatches accumulated is greater than 0.
  823. */
  824. /**
  825. * Accumulates items that must not be null or undefined into the first one. This
  826. * is used to conserve memory by avoiding array allocations, and thus sacrifices
  827. * API cleanness. Since `current` can be null before being passed in and not
  828. * null after this function, make sure to assign it back to `current`:
  829. *
  830. * `a = accumulateInto(a, b);`
  831. *
  832. * This API should be sparingly used. Try `accumulate` for something cleaner.
  833. *
  834. * @return {*|array<*>} An accumulation of items.
  835. */
  836. function accumulateInto(current, next) {
  837. !(next != null) ? invariant(false, 'accumulateInto(...): Accumulated items must not be null or undefined.') : void 0;
  838. if (current == null) {
  839. return next;
  840. }
  841. // Both are not empty. Warning: Never call x.concat(y) when you are not
  842. // certain that x is an Array (x could be a string with concat method).
  843. if (Array.isArray(current)) {
  844. if (Array.isArray(next)) {
  845. current.push.apply(current, next);
  846. return current;
  847. }
  848. current.push(next);
  849. return current;
  850. }
  851. if (Array.isArray(next)) {
  852. // A bit too dangerous to mutate `next`.
  853. return [current].concat(next);
  854. }
  855. return [current, next];
  856. }
  857. /**
  858. * @param {array} arr an "accumulation" of items which is either an Array or
  859. * a single item. Useful when paired with the `accumulate` module. This is a
  860. * simple utility that allows us to reason about a collection of items, but
  861. * handling the case when there is exactly one item (and we do not need to
  862. * allocate an array).
  863. * @param {function} cb Callback invoked with each element or a collection.
  864. * @param {?} [scope] Scope used as `this` in a callback.
  865. */
  866. function forEachAccumulated(arr, cb, scope) {
  867. if (Array.isArray(arr)) {
  868. arr.forEach(cb, scope);
  869. } else if (arr) {
  870. cb.call(scope, arr);
  871. }
  872. }
  873. /**
  874. * Internal queue of events that have accumulated their dispatches and are
  875. * waiting to have their dispatches executed.
  876. */
  877. var eventQueue = null;
  878. /**
  879. * Dispatches an event and releases it back into the pool, unless persistent.
  880. *
  881. * @param {?object} event Synthetic event to be dispatched.
  882. * @private
  883. */
  884. var executeDispatchesAndRelease = function (event) {
  885. if (event) {
  886. executeDispatchesInOrder(event);
  887. if (!event.isPersistent()) {
  888. event.constructor.release(event);
  889. }
  890. }
  891. };
  892. var executeDispatchesAndReleaseTopLevel = function (e) {
  893. return executeDispatchesAndRelease(e);
  894. };
  895. function isInteractive(tag) {
  896. return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea';
  897. }
  898. function shouldPreventMouseEvent(name, type, props) {
  899. switch (name) {
  900. case 'onClick':
  901. case 'onClickCapture':
  902. case 'onDoubleClick':
  903. case 'onDoubleClickCapture':
  904. case 'onMouseDown':
  905. case 'onMouseDownCapture':
  906. case 'onMouseMove':
  907. case 'onMouseMoveCapture':
  908. case 'onMouseUp':
  909. case 'onMouseUpCapture':
  910. return !!(props.disabled && isInteractive(type));
  911. default:
  912. return false;
  913. }
  914. }
  915. /**
  916. * This is a unified interface for event plugins to be installed and configured.
  917. *
  918. * Event plugins can implement the following properties:
  919. *
  920. * `extractEvents` {function(string, DOMEventTarget, string, object): *}
  921. * Required. When a top-level event is fired, this method is expected to
  922. * extract synthetic events that will in turn be queued and dispatched.
  923. *
  924. * `eventTypes` {object}
  925. * Optional, plugins that fire events must publish a mapping of registration
  926. * names that are used to register listeners. Values of this mapping must
  927. * be objects that contain `registrationName` or `phasedRegistrationNames`.
  928. *
  929. * `executeDispatch` {function(object, function, string)}
  930. * Optional, allows plugins to override how an event gets dispatched. By
  931. * default, the listener is simply invoked.
  932. *
  933. * Each plugin that is injected into `EventsPluginHub` is immediately operable.
  934. *
  935. * @public
  936. */
  937. /**
  938. * Methods for injecting dependencies.
  939. */
  940. var injection = {
  941. /**
  942. * @param {array} InjectedEventPluginOrder
  943. * @public
  944. */
  945. injectEventPluginOrder: injectEventPluginOrder,
  946. /**
  947. * @param {object} injectedNamesToPlugins Map from names to plugin modules.
  948. */
  949. injectEventPluginsByName: injectEventPluginsByName
  950. };
  951. /**
  952. * @param {object} inst The instance, which is the source of events.
  953. * @param {string} registrationName Name of listener (e.g. `onClick`).
  954. * @return {?function} The stored callback.
  955. */
  956. function getListener(inst, registrationName) {
  957. var listener = void 0;
  958. // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not
  959. // live here; needs to be moved to a better place soon
  960. var stateNode = inst.stateNode;
  961. if (!stateNode) {
  962. // Work in progress (ex: onload events in incremental mode).
  963. return null;
  964. }
  965. var props = getFiberCurrentPropsFromNode(stateNode);
  966. if (!props) {
  967. // Work in progress.
  968. return null;
  969. }
  970. listener = props[registrationName];
  971. if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
  972. return null;
  973. }
  974. !(!listener || typeof listener === 'function') ? invariant(false, 'Expected `%s` listener to be a function, instead got a value of `%s` type.', registrationName, typeof listener) : void 0;
  975. return listener;
  976. }
  977. /**
  978. * Allows registered plugins an opportunity to extract events from top-level
  979. * native browser events.
  980. *
  981. * @return {*} An accumulation of synthetic events.
  982. * @internal
  983. */
  984. function extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  985. var events = null;
  986. for (var i = 0; i < plugins.length; i++) {
  987. // Not every plugin in the ordering may be loaded at runtime.
  988. var possiblePlugin = plugins[i];
  989. if (possiblePlugin) {
  990. var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget);
  991. if (extractedEvents) {
  992. events = accumulateInto(events, extractedEvents);
  993. }
  994. }
  995. }
  996. return events;
  997. }
  998. function runEventsInBatch(events) {
  999. if (events !== null) {
  1000. eventQueue = accumulateInto(eventQueue, events);
  1001. }
  1002. // Set `eventQueue` to null before processing it so that we can tell if more
  1003. // events get enqueued while processing.
  1004. var processingEventQueue = eventQueue;
  1005. eventQueue = null;
  1006. if (!processingEventQueue) {
  1007. return;
  1008. }
  1009. forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel);
  1010. !!eventQueue ? invariant(false, 'processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented.') : void 0;
  1011. // This would be a good time to rethrow if any of the event handlers threw.
  1012. rethrowCaughtError();
  1013. }
  1014. function runExtractedEventsInBatch(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  1015. var events = extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget);
  1016. runEventsInBatch(events);
  1017. }
  1018. var FunctionComponent = 0;
  1019. var ClassComponent = 1;
  1020. var IndeterminateComponent = 2; // Before we know whether it is function or class
  1021. var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
  1022. var HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
  1023. var HostComponent = 5;
  1024. var HostText = 6;
  1025. var Fragment = 7;
  1026. var Mode = 8;
  1027. var ContextConsumer = 9;
  1028. var ContextProvider = 10;
  1029. var ForwardRef = 11;
  1030. var Profiler = 12;
  1031. var SuspenseComponent = 13;
  1032. var MemoComponent = 14;
  1033. var SimpleMemoComponent = 15;
  1034. var LazyComponent = 16;
  1035. var IncompleteClassComponent = 17;
  1036. var randomKey = Math.random().toString(36).slice(2);
  1037. var internalInstanceKey = '__reactInternalInstance$' + randomKey;
  1038. var internalEventHandlersKey = '__reactEventHandlers$' + randomKey;
  1039. function precacheFiberNode(hostInst, node) {
  1040. node[internalInstanceKey] = hostInst;
  1041. }
  1042. /**
  1043. * Given a DOM node, return the closest ReactDOMComponent or
  1044. * ReactDOMTextComponent instance ancestor.
  1045. */
  1046. function getClosestInstanceFromNode(node) {
  1047. if (node[internalInstanceKey]) {
  1048. return node[internalInstanceKey];
  1049. }
  1050. while (!node[internalInstanceKey]) {
  1051. if (node.parentNode) {
  1052. node = node.parentNode;
  1053. } else {
  1054. // Top of the tree. This node must not be part of a React tree (or is
  1055. // unmounted, potentially).
  1056. return null;
  1057. }
  1058. }
  1059. var inst = node[internalInstanceKey];
  1060. if (inst.tag === HostComponent || inst.tag === HostText) {
  1061. // In Fiber, this will always be the deepest root.
  1062. return inst;
  1063. }
  1064. return null;
  1065. }
  1066. /**
  1067. * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent
  1068. * instance, or null if the node was not rendered by this React.
  1069. */
  1070. function getInstanceFromNode$1(node) {
  1071. var inst = node[internalInstanceKey];
  1072. if (inst) {
  1073. if (inst.tag === HostComponent || inst.tag === HostText) {
  1074. return inst;
  1075. } else {
  1076. return null;
  1077. }
  1078. }
  1079. return null;
  1080. }
  1081. /**
  1082. * Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding
  1083. * DOM node.
  1084. */
  1085. function getNodeFromInstance$1(inst) {
  1086. if (inst.tag === HostComponent || inst.tag === HostText) {
  1087. // In Fiber this, is just the state node right now. We assume it will be
  1088. // a host component or host text.
  1089. return inst.stateNode;
  1090. }
  1091. // Without this first invariant, passing a non-DOM-component triggers the next
  1092. // invariant for a missing parent, which is super confusing.
  1093. invariant(false, 'getNodeFromInstance: Invalid argument.');
  1094. }
  1095. function getFiberCurrentPropsFromNode$1(node) {
  1096. return node[internalEventHandlersKey] || null;
  1097. }
  1098. function updateFiberProps(node, props) {
  1099. node[internalEventHandlersKey] = props;
  1100. }
  1101. function getParent(inst) {
  1102. do {
  1103. inst = inst.return;
  1104. // TODO: If this is a HostRoot we might want to bail out.
  1105. // That is depending on if we want nested subtrees (layers) to bubble
  1106. // events to their parent. We could also go through parentNode on the
  1107. // host node but that wouldn't work for React Native and doesn't let us
  1108. // do the portal feature.
  1109. } while (inst && inst.tag !== HostComponent);
  1110. if (inst) {
  1111. return inst;
  1112. }
  1113. return null;
  1114. }
  1115. /**
  1116. * Return the lowest common ancestor of A and B, or null if they are in
  1117. * different trees.
  1118. */
  1119. function getLowestCommonAncestor(instA, instB) {
  1120. var depthA = 0;
  1121. for (var tempA = instA; tempA; tempA = getParent(tempA)) {
  1122. depthA++;
  1123. }
  1124. var depthB = 0;
  1125. for (var tempB = instB; tempB; tempB = getParent(tempB)) {
  1126. depthB++;
  1127. }
  1128. // If A is deeper, crawl up.
  1129. while (depthA - depthB > 0) {
  1130. instA = getParent(instA);
  1131. depthA--;
  1132. }
  1133. // If B is deeper, crawl up.
  1134. while (depthB - depthA > 0) {
  1135. instB = getParent(instB);
  1136. depthB--;
  1137. }
  1138. // Walk in lockstep until we find a match.
  1139. var depth = depthA;
  1140. while (depth--) {
  1141. if (instA === instB || instA === instB.alternate) {
  1142. return instA;
  1143. }
  1144. instA = getParent(instA);
  1145. instB = getParent(instB);
  1146. }
  1147. return null;
  1148. }
  1149. /**
  1150. * Return if A is an ancestor of B.
  1151. */
  1152. /**
  1153. * Return the parent instance of the passed-in instance.
  1154. */
  1155. /**
  1156. * Simulates the traversal of a two-phase, capture/bubble event dispatch.
  1157. */
  1158. function traverseTwoPhase(inst, fn, arg) {
  1159. var path = [];
  1160. while (inst) {
  1161. path.push(inst);
  1162. inst = getParent(inst);
  1163. }
  1164. var i = void 0;
  1165. for (i = path.length; i-- > 0;) {
  1166. fn(path[i], 'captured', arg);
  1167. }
  1168. for (i = 0; i < path.length; i++) {
  1169. fn(path[i], 'bubbled', arg);
  1170. }
  1171. }
  1172. /**
  1173. * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
  1174. * should would receive a `mouseEnter` or `mouseLeave` event.
  1175. *
  1176. * Does not invoke the callback on the nearest common ancestor because nothing
  1177. * "entered" or "left" that element.
  1178. */
  1179. function traverseEnterLeave(from, to, fn, argFrom, argTo) {
  1180. var common = from && to ? getLowestCommonAncestor(from, to) : null;
  1181. var pathFrom = [];
  1182. while (true) {
  1183. if (!from) {
  1184. break;
  1185. }
  1186. if (from === common) {
  1187. break;
  1188. }
  1189. var alternate = from.alternate;
  1190. if (alternate !== null && alternate === common) {
  1191. break;
  1192. }
  1193. pathFrom.push(from);
  1194. from = getParent(from);
  1195. }
  1196. var pathTo = [];
  1197. while (true) {
  1198. if (!to) {
  1199. break;
  1200. }
  1201. if (to === common) {
  1202. break;
  1203. }
  1204. var _alternate = to.alternate;
  1205. if (_alternate !== null && _alternate === common) {
  1206. break;
  1207. }
  1208. pathTo.push(to);
  1209. to = getParent(to);
  1210. }
  1211. for (var i = 0; i < pathFrom.length; i++) {
  1212. fn(pathFrom[i], 'bubbled', argFrom);
  1213. }
  1214. for (var _i = pathTo.length; _i-- > 0;) {
  1215. fn(pathTo[_i], 'captured', argTo);
  1216. }
  1217. }
  1218. /**
  1219. * Some event types have a notion of different registration names for different
  1220. * "phases" of propagation. This finds listeners by a given phase.
  1221. */
  1222. function listenerAtPhase(inst, event, propagationPhase) {
  1223. var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase];
  1224. return getListener(inst, registrationName);
  1225. }
  1226. /**
  1227. * A small set of propagation patterns, each of which will accept a small amount
  1228. * of information, and generate a set of "dispatch ready event objects" - which
  1229. * are sets of events that have already been annotated with a set of dispatched
  1230. * listener functions/ids. The API is designed this way to discourage these
  1231. * propagation strategies from actually executing the dispatches, since we
  1232. * always want to collect the entire set of dispatches before executing even a
  1233. * single one.
  1234. */
  1235. /**
  1236. * Tags a `SyntheticEvent` with dispatched listeners. Creating this function
  1237. * here, allows us to not have to bind or create functions for each event.
  1238. * Mutating the event's members allows us to not have to create a wrapping
  1239. * "dispatch" object that pairs the event with the listener.
  1240. */
  1241. function accumulateDirectionalDispatches(inst, phase, event) {
  1242. {
  1243. !inst ? warningWithoutStack$1(false, 'Dispatching inst must not be null') : void 0;
  1244. }
  1245. var listener = listenerAtPhase(inst, event, phase);
  1246. if (listener) {
  1247. event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
  1248. event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
  1249. }
  1250. }
  1251. /**
  1252. * Collect dispatches (must be entirely collected before dispatching - see unit
  1253. * tests). Lazily allocate the array to conserve memory. We must loop through
  1254. * each event and perform the traversal for each one. We cannot perform a
  1255. * single traversal for the entire collection of events because each event may
  1256. * have a different target.
  1257. */
  1258. function accumulateTwoPhaseDispatchesSingle(event) {
  1259. if (event && event.dispatchConfig.phasedRegistrationNames) {
  1260. traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
  1261. }
  1262. }
  1263. /**
  1264. * Accumulates without regard to direction, does not look for phased
  1265. * registration names. Same as `accumulateDirectDispatchesSingle` but without
  1266. * requiring that the `dispatchMarker` be the same as the dispatched ID.
  1267. */
  1268. function accumulateDispatches(inst, ignoredDirection, event) {
  1269. if (inst && event && event.dispatchConfig.registrationName) {
  1270. var registrationName = event.dispatchConfig.registrationName;
  1271. var listener = getListener(inst, registrationName);
  1272. if (listener) {
  1273. event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
  1274. event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
  1275. }
  1276. }
  1277. }
  1278. /**
  1279. * Accumulates dispatches on an `SyntheticEvent`, but only for the
  1280. * `dispatchMarker`.
  1281. * @param {SyntheticEvent} event
  1282. */
  1283. function accumulateDirectDispatchesSingle(event) {
  1284. if (event && event.dispatchConfig.registrationName) {
  1285. accumulateDispatches(event._targetInst, null, event);
  1286. }
  1287. }
  1288. function accumulateTwoPhaseDispatches(events) {
  1289. forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
  1290. }
  1291. function accumulateEnterLeaveDispatches(leave, enter, from, to) {
  1292. traverseEnterLeave(from, to, accumulateDispatches, leave, enter);
  1293. }
  1294. function accumulateDirectDispatches(events) {
  1295. forEachAccumulated(events, accumulateDirectDispatchesSingle);
  1296. }
  1297. var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
  1298. // Do not uses the below two methods directly!
  1299. // Instead use constants exported from DOMTopLevelEventTypes in ReactDOM.
  1300. // (It is the only module that is allowed to access these methods.)
  1301. function unsafeCastStringToDOMTopLevelType(topLevelType) {
  1302. return topLevelType;
  1303. }
  1304. function unsafeCastDOMTopLevelTypeToString(topLevelType) {
  1305. return topLevelType;
  1306. }
  1307. /**
  1308. * Generate a mapping of standard vendor prefixes using the defined style property and event name.
  1309. *
  1310. * @param {string} styleProp
  1311. * @param {string} eventName
  1312. * @returns {object}
  1313. */
  1314. function makePrefixMap(styleProp, eventName) {
  1315. var prefixes = {};
  1316. prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
  1317. prefixes['Webkit' + styleProp] = 'webkit' + eventName;
  1318. prefixes['Moz' + styleProp] = 'moz' + eventName;
  1319. return prefixes;
  1320. }
  1321. /**
  1322. * A list of event names to a configurable list of vendor prefixes.
  1323. */
  1324. var vendorPrefixes = {
  1325. animationend: makePrefixMap('Animation', 'AnimationEnd'),
  1326. animationiteration: makePrefixMap('Animation', 'AnimationIteration'),
  1327. animationstart: makePrefixMap('Animation', 'AnimationStart'),
  1328. transitionend: makePrefixMap('Transition', 'TransitionEnd')
  1329. };
  1330. /**
  1331. * Event names that have already been detected and prefixed (if applicable).
  1332. */
  1333. var prefixedEventNames = {};
  1334. /**
  1335. * Element to check for prefixes on.
  1336. */
  1337. var style = {};
  1338. /**
  1339. * Bootstrap if a DOM exists.
  1340. */
  1341. if (canUseDOM) {
  1342. style = document.createElement('div').style;
  1343. // On some platforms, in particular some releases of Android 4.x,
  1344. // the un-prefixed "animation" and "transition" properties are defined on the
  1345. // style object but the events that fire will still be prefixed, so we need
  1346. // to check if the un-prefixed events are usable, and if not remove them from the map.
  1347. if (!('AnimationEvent' in window)) {
  1348. delete vendorPrefixes.animationend.animation;
  1349. delete vendorPrefixes.animationiteration.animation;
  1350. delete vendorPrefixes.animationstart.animation;
  1351. }
  1352. // Same as above
  1353. if (!('TransitionEvent' in window)) {
  1354. delete vendorPrefixes.transitionend.transition;
  1355. }
  1356. }
  1357. /**
  1358. * Attempts to determine the correct vendor prefixed event name.
  1359. *
  1360. * @param {string} eventName
  1361. * @returns {string}
  1362. */
  1363. function getVendorPrefixedEventName(eventName) {
  1364. if (prefixedEventNames[eventName]) {
  1365. return prefixedEventNames[eventName];
  1366. } else if (!vendorPrefixes[eventName]) {
  1367. return eventName;
  1368. }
  1369. var prefixMap = vendorPrefixes[eventName];
  1370. for (var styleProp in prefixMap) {
  1371. if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) {
  1372. return prefixedEventNames[eventName] = prefixMap[styleProp];
  1373. }
  1374. }
  1375. return eventName;
  1376. }
  1377. /**
  1378. * To identify top level events in ReactDOM, we use constants defined by this
  1379. * module. This is the only module that uses the unsafe* methods to express
  1380. * that the constants actually correspond to the browser event names. This lets
  1381. * us save some bundle size by avoiding a top level type -> event name map.
  1382. * The rest of ReactDOM code should import top level types from this file.
  1383. */
  1384. var TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort');
  1385. var TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationend'));
  1386. var TOP_ANIMATION_ITERATION = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationiteration'));
  1387. var TOP_ANIMATION_START = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationstart'));
  1388. var TOP_BLUR = unsafeCastStringToDOMTopLevelType('blur');
  1389. var TOP_CAN_PLAY = unsafeCastStringToDOMTopLevelType('canplay');
  1390. var TOP_CAN_PLAY_THROUGH = unsafeCastStringToDOMTopLevelType('canplaythrough');
  1391. var TOP_CANCEL = unsafeCastStringToDOMTopLevelType('cancel');
  1392. var TOP_CHANGE = unsafeCastStringToDOMTopLevelType('change');
  1393. var TOP_CLICK = unsafeCastStringToDOMTopLevelType('click');
  1394. var TOP_CLOSE = unsafeCastStringToDOMTopLevelType('close');
  1395. var TOP_COMPOSITION_END = unsafeCastStringToDOMTopLevelType('compositionend');
  1396. var TOP_COMPOSITION_START = unsafeCastStringToDOMTopLevelType('compositionstart');
  1397. var TOP_COMPOSITION_UPDATE = unsafeCastStringToDOMTopLevelType('compositionupdate');
  1398. var TOP_CONTEXT_MENU = unsafeCastStringToDOMTopLevelType('contextmenu');
  1399. var TOP_COPY = unsafeCastStringToDOMTopLevelType('copy');
  1400. var TOP_CUT = unsafeCastStringToDOMTopLevelType('cut');
  1401. var TOP_DOUBLE_CLICK = unsafeCastStringToDOMTopLevelType('dblclick');
  1402. var TOP_AUX_CLICK = unsafeCastStringToDOMTopLevelType('auxclick');
  1403. var TOP_DRAG = unsafeCastStringToDOMTopLevelType('drag');
  1404. var TOP_DRAG_END = unsafeCastStringToDOMTopLevelType('dragend');
  1405. var TOP_DRAG_ENTER = unsafeCastStringToDOMTopLevelType('dragenter');
  1406. var TOP_DRAG_EXIT = unsafeCastStringToDOMTopLevelType('dragexit');
  1407. var TOP_DRAG_LEAVE = unsafeCastStringToDOMTopLevelType('dragleave');
  1408. var TOP_DRAG_OVER = unsafeCastStringToDOMTopLevelType('dragover');
  1409. var TOP_DRAG_START = unsafeCastStringToDOMTopLevelType('dragstart');
  1410. var TOP_DROP = unsafeCastStringToDOMTopLevelType('drop');
  1411. var TOP_DURATION_CHANGE = unsafeCastStringToDOMTopLevelType('durationchange');
  1412. var TOP_EMPTIED = unsafeCastStringToDOMTopLevelType('emptied');
  1413. var TOP_ENCRYPTED = unsafeCastStringToDOMTopLevelType('encrypted');
  1414. var TOP_ENDED = unsafeCastStringToDOMTopLevelType('ended');
  1415. var TOP_ERROR = unsafeCastStringToDOMTopLevelType('error');
  1416. var TOP_FOCUS = unsafeCastStringToDOMTopLevelType('focus');
  1417. var TOP_GOT_POINTER_CAPTURE = unsafeCastStringToDOMTopLevelType('gotpointercapture');
  1418. var TOP_INPUT = unsafeCastStringToDOMTopLevelType('input');
  1419. var TOP_INVALID = unsafeCastStringToDOMTopLevelType('invalid');
  1420. var TOP_KEY_DOWN = unsafeCastStringToDOMTopLevelType('keydown');
  1421. var TOP_KEY_PRESS = unsafeCastStringToDOMTopLevelType('keypress');
  1422. var TOP_KEY_UP = unsafeCastStringToDOMTopLevelType('keyup');
  1423. var TOP_LOAD = unsafeCastStringToDOMTopLevelType('load');
  1424. var TOP_LOAD_START = unsafeCastStringToDOMTopLevelType('loadstart');
  1425. var TOP_LOADED_DATA = unsafeCastStringToDOMTopLevelType('loadeddata');
  1426. var TOP_LOADED_METADATA = unsafeCastStringToDOMTopLevelType('loadedmetadata');
  1427. var TOP_LOST_POINTER_CAPTURE = unsafeCastStringToDOMTopLevelType('lostpointercapture');
  1428. var TOP_MOUSE_DOWN = unsafeCastStringToDOMTopLevelType('mousedown');
  1429. var TOP_MOUSE_MOVE = unsafeCastStringToDOMTopLevelType('mousemove');
  1430. var TOP_MOUSE_OUT = unsafeCastStringToDOMTopLevelType('mouseout');
  1431. var TOP_MOUSE_OVER = unsafeCastStringToDOMTopLevelType('mouseover');
  1432. var TOP_MOUSE_UP = unsafeCastStringToDOMTopLevelType('mouseup');
  1433. var TOP_PASTE = unsafeCastStringToDOMTopLevelType('paste');
  1434. var TOP_PAUSE = unsafeCastStringToDOMTopLevelType('pause');
  1435. var TOP_PLAY = unsafeCastStringToDOMTopLevelType('play');
  1436. var TOP_PLAYING = unsafeCastStringToDOMTopLevelType('playing');
  1437. var TOP_POINTER_CANCEL = unsafeCastStringToDOMTopLevelType('pointercancel');
  1438. var TOP_POINTER_DOWN = unsafeCastStringToDOMTopLevelType('pointerdown');
  1439. var TOP_POINTER_MOVE = unsafeCastStringToDOMTopLevelType('pointermove');
  1440. var TOP_POINTER_OUT = unsafeCastStringToDOMTopLevelType('pointerout');
  1441. var TOP_POINTER_OVER = unsafeCastStringToDOMTopLevelType('pointerover');
  1442. var TOP_POINTER_UP = unsafeCastStringToDOMTopLevelType('pointerup');
  1443. var TOP_PROGRESS = unsafeCastStringToDOMTopLevelType('progress');
  1444. var TOP_RATE_CHANGE = unsafeCastStringToDOMTopLevelType('ratechange');
  1445. var TOP_RESET = unsafeCastStringToDOMTopLevelType('reset');
  1446. var TOP_SCROLL = unsafeCastStringToDOMTopLevelType('scroll');
  1447. var TOP_SEEKED = unsafeCastStringToDOMTopLevelType('seeked');
  1448. var TOP_SEEKING = unsafeCastStringToDOMTopLevelType('seeking');
  1449. var TOP_SELECTION_CHANGE = unsafeCastStringToDOMTopLevelType('selectionchange');
  1450. var TOP_STALLED = unsafeCastStringToDOMTopLevelType('stalled');
  1451. var TOP_SUBMIT = unsafeCastStringToDOMTopLevelType('submit');
  1452. var TOP_SUSPEND = unsafeCastStringToDOMTopLevelType('suspend');
  1453. var TOP_TEXT_INPUT = unsafeCastStringToDOMTopLevelType('textInput');
  1454. var TOP_TIME_UPDATE = unsafeCastStringToDOMTopLevelType('timeupdate');
  1455. var TOP_TOGGLE = unsafeCastStringToDOMTopLevelType('toggle');
  1456. var TOP_TOUCH_CANCEL = unsafeCastStringToDOMTopLevelType('touchcancel');
  1457. var TOP_TOUCH_END = unsafeCastStringToDOMTopLevelType('touchend');
  1458. var TOP_TOUCH_MOVE = unsafeCastStringToDOMTopLevelType('touchmove');
  1459. var TOP_TOUCH_START = unsafeCastStringToDOMTopLevelType('touchstart');
  1460. var TOP_TRANSITION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('transitionend'));
  1461. var TOP_VOLUME_CHANGE = unsafeCastStringToDOMTopLevelType('volumechange');
  1462. var TOP_WAITING = unsafeCastStringToDOMTopLevelType('waiting');
  1463. var TOP_WHEEL = unsafeCastStringToDOMTopLevelType('wheel');
  1464. // List of events that need to be individually attached to media elements.
  1465. // Note that events in this list will *not* be listened to at the top level
  1466. // unless they're explicitly whitelisted in `ReactBrowserEventEmitter.listenTo`.
  1467. 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];
  1468. function getRawEventName(topLevelType) {
  1469. return unsafeCastDOMTopLevelTypeToString(topLevelType);
  1470. }
  1471. /**
  1472. * These variables store information about text content of a target node,
  1473. * allowing comparison of content before and after a given event.
  1474. *
  1475. * Identify the node where selection currently begins, then observe
  1476. * both its text content and its current position in the DOM. Since the
  1477. * browser may natively replace the target node during composition, we can
  1478. * use its position to find its replacement.
  1479. *
  1480. *
  1481. */
  1482. var root = null;
  1483. var startText = null;
  1484. var fallbackText = null;
  1485. function initialize(nativeEventTarget) {
  1486. root = nativeEventTarget;
  1487. startText = getText();
  1488. return true;
  1489. }
  1490. function reset() {
  1491. root = null;
  1492. startText = null;
  1493. fallbackText = null;
  1494. }
  1495. function getData() {
  1496. if (fallbackText) {
  1497. return fallbackText;
  1498. }
  1499. var start = void 0;
  1500. var startValue = startText;
  1501. var startLength = startValue.length;
  1502. var end = void 0;
  1503. var endValue = getText();
  1504. var endLength = endValue.length;
  1505. for (start = 0; start < startLength; start++) {
  1506. if (startValue[start] !== endValue[start]) {
  1507. break;
  1508. }
  1509. }
  1510. var minEnd = startLength - start;
  1511. for (end = 1; end <= minEnd; end++) {
  1512. if (startValue[startLength - end] !== endValue[endLength - end]) {
  1513. break;
  1514. }
  1515. }
  1516. var sliceTail = end > 1 ? 1 - end : undefined;
  1517. fallbackText = endValue.slice(start, sliceTail);
  1518. return fallbackText;
  1519. }
  1520. function getText() {
  1521. if ('value' in root) {
  1522. return root.value;
  1523. }
  1524. return root.textContent;
  1525. }
  1526. /* eslint valid-typeof: 0 */
  1527. var EVENT_POOL_SIZE = 10;
  1528. /**
  1529. * @interface Event
  1530. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  1531. */
  1532. var EventInterface = {
  1533. type: null,
  1534. target: null,
  1535. // currentTarget is set when dispatching; no use in copying it here
  1536. currentTarget: function () {
  1537. return null;
  1538. },
  1539. eventPhase: null,
  1540. bubbles: null,
  1541. cancelable: null,
  1542. timeStamp: function (event) {
  1543. return event.timeStamp || Date.now();
  1544. },
  1545. defaultPrevented: null,
  1546. isTrusted: null
  1547. };
  1548. function functionThatReturnsTrue() {
  1549. return true;
  1550. }
  1551. function functionThatReturnsFalse() {
  1552. return false;
  1553. }
  1554. /**
  1555. * Synthetic events are dispatched by event plugins, typically in response to a
  1556. * top-level event delegation handler.
  1557. *
  1558. * These systems should generally use pooling to reduce the frequency of garbage
  1559. * collection. The system should check `isPersistent` to determine whether the
  1560. * event should be released into the pool after being dispatched. Users that
  1561. * need a persisted event should invoke `persist`.
  1562. *
  1563. * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
  1564. * normalizing browser quirks. Subclasses do not necessarily have to implement a
  1565. * DOM interface; custom application-specific events can also subclass this.
  1566. *
  1567. * @param {object} dispatchConfig Configuration used to dispatch this event.
  1568. * @param {*} targetInst Marker identifying the event target.
  1569. * @param {object} nativeEvent Native browser event.
  1570. * @param {DOMEventTarget} nativeEventTarget Target node.
  1571. */
  1572. function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) {
  1573. {
  1574. // these have a getter/setter for warnings
  1575. delete this.nativeEvent;
  1576. delete this.preventDefault;
  1577. delete this.stopPropagation;
  1578. delete this.isDefaultPrevented;
  1579. delete this.isPropagationStopped;
  1580. }
  1581. this.dispatchConfig = dispatchConfig;
  1582. this._targetInst = targetInst;
  1583. this.nativeEvent = nativeEvent;
  1584. var Interface = this.constructor.Interface;
  1585. for (var propName in Interface) {
  1586. if (!Interface.hasOwnProperty(propName)) {
  1587. continue;
  1588. }
  1589. {
  1590. delete this[propName]; // this has a getter/setter for warnings
  1591. }
  1592. var normalize = Interface[propName];
  1593. if (normalize) {
  1594. this[propName] = normalize(nativeEvent);
  1595. } else {
  1596. if (propName === 'target') {
  1597. this.target = nativeEventTarget;
  1598. } else {
  1599. this[propName] = nativeEvent[propName];
  1600. }
  1601. }
  1602. }
  1603. var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
  1604. if (defaultPrevented) {
  1605. this.isDefaultPrevented = functionThatReturnsTrue;
  1606. } else {
  1607. this.isDefaultPrevented = functionThatReturnsFalse;
  1608. }
  1609. this.isPropagationStopped = functionThatReturnsFalse;
  1610. return this;
  1611. }
  1612. _assign(SyntheticEvent.prototype, {
  1613. preventDefault: function () {
  1614. this.defaultPrevented = true;
  1615. var event = this.nativeEvent;
  1616. if (!event) {
  1617. return;
  1618. }
  1619. if (event.preventDefault) {
  1620. event.preventDefault();
  1621. } else if (typeof event.returnValue !== 'unknown') {
  1622. event.returnValue = false;
  1623. }
  1624. this.isDefaultPrevented = functionThatReturnsTrue;
  1625. },
  1626. stopPropagation: function () {
  1627. var event = this.nativeEvent;
  1628. if (!event) {
  1629. return;
  1630. }
  1631. if (event.stopPropagation) {
  1632. event.stopPropagation();
  1633. } else if (typeof event.cancelBubble !== 'unknown') {
  1634. // The ChangeEventPlugin registers a "propertychange" event for
  1635. // IE. This event does not support bubbling or cancelling, and
  1636. // any references to cancelBubble throw "Member not found". A
  1637. // typeof check of "unknown" circumvents this issue (and is also
  1638. // IE specific).
  1639. event.cancelBubble = true;
  1640. }
  1641. this.isPropagationStopped = functionThatReturnsTrue;
  1642. },
  1643. /**
  1644. * We release all dispatched `SyntheticEvent`s after each event loop, adding
  1645. * them back into the pool. This allows a way to hold onto a reference that
  1646. * won't be added back into the pool.
  1647. */
  1648. persist: function () {
  1649. this.isPersistent = functionThatReturnsTrue;
  1650. },
  1651. /**
  1652. * Checks if this event should be released back into the pool.
  1653. *
  1654. * @return {boolean} True if this should not be released, false otherwise.
  1655. */
  1656. isPersistent: functionThatReturnsFalse,
  1657. /**
  1658. * `PooledClass` looks for `destructor` on each instance it releases.
  1659. */
  1660. destructor: function () {
  1661. var Interface = this.constructor.Interface;
  1662. for (var propName in Interface) {
  1663. {
  1664. Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName]));
  1665. }
  1666. }
  1667. this.dispatchConfig = null;
  1668. this._targetInst = null;
  1669. this.nativeEvent = null;
  1670. this.isDefaultPrevented = functionThatReturnsFalse;
  1671. this.isPropagationStopped = functionThatReturnsFalse;
  1672. this._dispatchListeners = null;
  1673. this._dispatchInstances = null;
  1674. {
  1675. Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
  1676. Object.defineProperty(this, 'isDefaultPrevented', getPooledWarningPropertyDefinition('isDefaultPrevented', functionThatReturnsFalse));
  1677. Object.defineProperty(this, 'isPropagationStopped', getPooledWarningPropertyDefinition('isPropagationStopped', functionThatReturnsFalse));
  1678. Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', function () {}));
  1679. Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', function () {}));
  1680. }
  1681. }
  1682. });
  1683. SyntheticEvent.Interface = EventInterface;
  1684. /**
  1685. * Helper to reduce boilerplate when creating subclasses.
  1686. */
  1687. SyntheticEvent.extend = function (Interface) {
  1688. var Super = this;
  1689. var E = function () {};
  1690. E.prototype = Super.prototype;
  1691. var prototype = new E();
  1692. function Class() {
  1693. return Super.apply(this, arguments);
  1694. }
  1695. _assign(prototype, Class.prototype);
  1696. Class.prototype = prototype;
  1697. Class.prototype.constructor = Class;
  1698. Class.Interface = _assign({}, Super.Interface, Interface);
  1699. Class.extend = Super.extend;
  1700. addEventPoolingTo(Class);
  1701. return Class;
  1702. };
  1703. addEventPoolingTo(SyntheticEvent);
  1704. /**
  1705. * Helper to nullify syntheticEvent instance properties when destructing
  1706. *
  1707. * @param {String} propName
  1708. * @param {?object} getVal
  1709. * @return {object} defineProperty object
  1710. */
  1711. function getPooledWarningPropertyDefinition(propName, getVal) {
  1712. var isFunction = typeof getVal === 'function';
  1713. return {
  1714. configurable: true,
  1715. set: set,
  1716. get: get
  1717. };
  1718. function set(val) {
  1719. var action = isFunction ? 'setting the method' : 'setting the property';
  1720. warn(action, 'This is effectively a no-op');
  1721. return val;
  1722. }
  1723. function get() {
  1724. var action = isFunction ? 'accessing the method' : 'accessing the property';
  1725. var result = isFunction ? 'This is a no-op function' : 'This is set to null';
  1726. warn(action, result);
  1727. return getVal;
  1728. }
  1729. function warn(action, result) {
  1730. var warningCondition = false;
  1731. !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;
  1732. }
  1733. }
  1734. function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
  1735. var EventConstructor = this;
  1736. if (EventConstructor.eventPool.length) {
  1737. var instance = EventConstructor.eventPool.pop();
  1738. EventConstructor.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst);
  1739. return instance;
  1740. }
  1741. return new EventConstructor(dispatchConfig, targetInst, nativeEvent, nativeInst);
  1742. }
  1743. function releasePooledEvent(event) {
  1744. var EventConstructor = this;
  1745. !(event instanceof EventConstructor) ? invariant(false, 'Trying to release an event instance into a pool of a different type.') : void 0;
  1746. event.destructor();
  1747. if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) {
  1748. EventConstructor.eventPool.push(event);
  1749. }
  1750. }
  1751. function addEventPoolingTo(EventConstructor) {
  1752. EventConstructor.eventPool = [];
  1753. EventConstructor.getPooled = getPooledEvent;
  1754. EventConstructor.release = releasePooledEvent;
  1755. }
  1756. /**
  1757. * @interface Event
  1758. * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents
  1759. */
  1760. var SyntheticCompositionEvent = SyntheticEvent.extend({
  1761. data: null
  1762. });
  1763. /**
  1764. * @interface Event
  1765. * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105
  1766. * /#events-inputevents
  1767. */
  1768. var SyntheticInputEvent = SyntheticEvent.extend({
  1769. data: null
  1770. });
  1771. var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
  1772. var START_KEYCODE = 229;
  1773. var canUseCompositionEvent = canUseDOM && 'CompositionEvent' in window;
  1774. var documentMode = null;
  1775. if (canUseDOM && 'documentMode' in document) {
  1776. documentMode = document.documentMode;
  1777. }
  1778. // Webkit offers a very useful `textInput` event that can be used to
  1779. // directly represent `beforeInput`. The IE `textinput` event is not as
  1780. // useful, so we don't use it.
  1781. var canUseTextInputEvent = canUseDOM && 'TextEvent' in window && !documentMode;
  1782. // In IE9+, we have access to composition events, but the data supplied
  1783. // by the native compositionend event may be incorrect. Japanese ideographic
  1784. // spaces, for instance (\u3000) are not recorded correctly.
  1785. var useFallbackCompositionData = canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11);
  1786. var SPACEBAR_CODE = 32;
  1787. var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);
  1788. // Events and their corresponding property names.
  1789. var eventTypes = {
  1790. beforeInput: {
  1791. phasedRegistrationNames: {
  1792. bubbled: 'onBeforeInput',
  1793. captured: 'onBeforeInputCapture'
  1794. },
  1795. dependencies: [TOP_COMPOSITION_END, TOP_KEY_PRESS, TOP_TEXT_INPUT, TOP_PASTE]
  1796. },
  1797. compositionEnd: {
  1798. phasedRegistrationNames: {
  1799. bubbled: 'onCompositionEnd',
  1800. captured: 'onCompositionEndCapture'
  1801. },
  1802. dependencies: [TOP_BLUR, TOP_COMPOSITION_END, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN]
  1803. },
  1804. compositionStart: {
  1805. phasedRegistrationNames: {
  1806. bubbled: 'onCompositionStart',
  1807. captured: 'onCompositionStartCapture'
  1808. },
  1809. dependencies: [TOP_BLUR, TOP_COMPOSITION_START, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN]
  1810. },
  1811. compositionUpdate: {
  1812. phasedRegistrationNames: {
  1813. bubbled: 'onCompositionUpdate',
  1814. captured: 'onCompositionUpdateCapture'
  1815. },
  1816. dependencies: [TOP_BLUR, TOP_COMPOSITION_UPDATE, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN]
  1817. }
  1818. };
  1819. // Track whether we've ever handled a keypress on the space key.
  1820. var hasSpaceKeypress = false;
  1821. /**
  1822. * Return whether a native keypress event is assumed to be a command.
  1823. * This is required because Firefox fires `keypress` events for key commands
  1824. * (cut, copy, select-all, etc.) even though no character is inserted.
  1825. */
  1826. function isKeypressCommand(nativeEvent) {
  1827. return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) &&
  1828. // ctrlKey && altKey is equivalent to AltGr, and is not a command.
  1829. !(nativeEvent.ctrlKey && nativeEvent.altKey);
  1830. }
  1831. /**
  1832. * Translate native top level events into event types.
  1833. *
  1834. * @param {string} topLevelType
  1835. * @return {object}
  1836. */
  1837. function getCompositionEventType(topLevelType) {
  1838. switch (topLevelType) {
  1839. case TOP_COMPOSITION_START:
  1840. return eventTypes.compositionStart;
  1841. case TOP_COMPOSITION_END:
  1842. return eventTypes.compositionEnd;
  1843. case TOP_COMPOSITION_UPDATE:
  1844. return eventTypes.compositionUpdate;
  1845. }
  1846. }
  1847. /**
  1848. * Does our fallback best-guess model think this event signifies that
  1849. * composition has begun?
  1850. *
  1851. * @param {string} topLevelType
  1852. * @param {object} nativeEvent
  1853. * @return {boolean}
  1854. */
  1855. function isFallbackCompositionStart(topLevelType, nativeEvent) {
  1856. return topLevelType === TOP_KEY_DOWN && nativeEvent.keyCode === START_KEYCODE;
  1857. }
  1858. /**
  1859. * Does our fallback mode think that this event is the end of composition?
  1860. *
  1861. * @param {string} topLevelType
  1862. * @param {object} nativeEvent
  1863. * @return {boolean}
  1864. */
  1865. function isFallbackCompositionEnd(topLevelType, nativeEvent) {
  1866. switch (topLevelType) {
  1867. case TOP_KEY_UP:
  1868. // Command keys insert or clear IME input.
  1869. return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1;
  1870. case TOP_KEY_DOWN:
  1871. // Expect IME keyCode on each keydown. If we get any other
  1872. // code we must have exited earlier.
  1873. return nativeEvent.keyCode !== START_KEYCODE;
  1874. case TOP_KEY_PRESS:
  1875. case TOP_MOUSE_DOWN:
  1876. case TOP_BLUR:
  1877. // Events are not possible without cancelling IME.
  1878. return true;
  1879. default:
  1880. return false;
  1881. }
  1882. }
  1883. /**
  1884. * Google Input Tools provides composition data via a CustomEvent,
  1885. * with the `data` property populated in the `detail` object. If this
  1886. * is available on the event object, use it. If not, this is a plain
  1887. * composition event and we have nothing special to extract.
  1888. *
  1889. * @param {object} nativeEvent
  1890. * @return {?string}
  1891. */
  1892. function getDataFromCustomEvent(nativeEvent) {
  1893. var detail = nativeEvent.detail;
  1894. if (typeof detail === 'object' && 'data' in detail) {
  1895. return detail.data;
  1896. }
  1897. return null;
  1898. }
  1899. /**
  1900. * Check if a composition event was triggered by Korean IME.
  1901. * Our fallback mode does not work well with IE's Korean IME,
  1902. * so just use native composition events when Korean IME is used.
  1903. * Although CompositionEvent.locale property is deprecated,
  1904. * it is available in IE, where our fallback mode is enabled.
  1905. *
  1906. * @param {object} nativeEvent
  1907. * @return {boolean}
  1908. */
  1909. function isUsingKoreanIME(nativeEvent) {
  1910. return nativeEvent.locale === 'ko';
  1911. }
  1912. // Track the current IME composition status, if any.
  1913. var isComposing = false;
  1914. /**
  1915. * @return {?object} A SyntheticCompositionEvent.
  1916. */
  1917. function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  1918. var eventType = void 0;
  1919. var fallbackData = void 0;
  1920. if (canUseCompositionEvent) {
  1921. eventType = getCompositionEventType(topLevelType);
  1922. } else if (!isComposing) {
  1923. if (isFallbackCompositionStart(topLevelType, nativeEvent)) {
  1924. eventType = eventTypes.compositionStart;
  1925. }
  1926. } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) {
  1927. eventType = eventTypes.compositionEnd;
  1928. }
  1929. if (!eventType) {
  1930. return null;
  1931. }
  1932. if (useFallbackCompositionData && !isUsingKoreanIME(nativeEvent)) {
  1933. // The current composition is stored statically and must not be
  1934. // overwritten while composition continues.
  1935. if (!isComposing && eventType === eventTypes.compositionStart) {
  1936. isComposing = initialize(nativeEventTarget);
  1937. } else if (eventType === eventTypes.compositionEnd) {
  1938. if (isComposing) {
  1939. fallbackData = getData();
  1940. }
  1941. }
  1942. }
  1943. var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget);
  1944. if (fallbackData) {
  1945. // Inject data generated from fallback path into the synthetic event.
  1946. // This matches the property of native CompositionEventInterface.
  1947. event.data = fallbackData;
  1948. } else {
  1949. var customData = getDataFromCustomEvent(nativeEvent);
  1950. if (customData !== null) {
  1951. event.data = customData;
  1952. }
  1953. }
  1954. accumulateTwoPhaseDispatches(event);
  1955. return event;
  1956. }
  1957. /**
  1958. * @param {TopLevelType} topLevelType Number from `TopLevelType`.
  1959. * @param {object} nativeEvent Native browser event.
  1960. * @return {?string} The string corresponding to this `beforeInput` event.
  1961. */
  1962. function getNativeBeforeInputChars(topLevelType, nativeEvent) {
  1963. switch (topLevelType) {
  1964. case TOP_COMPOSITION_END:
  1965. return getDataFromCustomEvent(nativeEvent);
  1966. case TOP_KEY_PRESS:
  1967. /**
  1968. * If native `textInput` events are available, our goal is to make
  1969. * use of them. However, there is a special case: the spacebar key.
  1970. * In Webkit, preventing default on a spacebar `textInput` event
  1971. * cancels character insertion, but it *also* causes the browser
  1972. * to fall back to its default spacebar behavior of scrolling the
  1973. * page.
  1974. *
  1975. * Tracking at:
  1976. * https://code.google.com/p/chromium/issues/detail?id=355103
  1977. *
  1978. * To avoid this issue, use the keypress event as if no `textInput`
  1979. * event is available.
  1980. */
  1981. var which = nativeEvent.which;
  1982. if (which !== SPACEBAR_CODE) {
  1983. return null;
  1984. }
  1985. hasSpaceKeypress = true;
  1986. return SPACEBAR_CHAR;
  1987. case TOP_TEXT_INPUT:
  1988. // Record the characters to be added to the DOM.
  1989. var chars = nativeEvent.data;
  1990. // If it's a spacebar character, assume that we have already handled
  1991. // it at the keypress level and bail immediately. Android Chrome
  1992. // doesn't give us keycodes, so we need to ignore it.
  1993. if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
  1994. return null;
  1995. }
  1996. return chars;
  1997. default:
  1998. // For other native event types, do nothing.
  1999. return null;
  2000. }
  2001. }
  2002. /**
  2003. * For browsers that do not provide the `textInput` event, extract the
  2004. * appropriate string to use for SyntheticInputEvent.
  2005. *
  2006. * @param {number} topLevelType Number from `TopLevelEventTypes`.
  2007. * @param {object} nativeEvent Native browser event.
  2008. * @return {?string} The fallback string for this `beforeInput` event.
  2009. */
  2010. function getFallbackBeforeInputChars(topLevelType, nativeEvent) {
  2011. // If we are currently composing (IME) and using a fallback to do so,
  2012. // try to extract the composed characters from the fallback object.
  2013. // If composition event is available, we extract a string only at
  2014. // compositionevent, otherwise extract it at fallback events.
  2015. if (isComposing) {
  2016. if (topLevelType === TOP_COMPOSITION_END || !canUseCompositionEvent && isFallbackCompositionEnd(topLevelType, nativeEvent)) {
  2017. var chars = getData();
  2018. reset();
  2019. isComposing = false;
  2020. return chars;
  2021. }
  2022. return null;
  2023. }
  2024. switch (topLevelType) {
  2025. case TOP_PASTE:
  2026. // If a paste event occurs after a keypress, throw out the input
  2027. // chars. Paste events should not lead to BeforeInput events.
  2028. return null;
  2029. case TOP_KEY_PRESS:
  2030. /**
  2031. * As of v27, Firefox may fire keypress events even when no character
  2032. * will be inserted. A few possibilities:
  2033. *
  2034. * - `which` is `0`. Arrow keys, Esc key, etc.
  2035. *
  2036. * - `which` is the pressed key code, but no char is available.
  2037. * Ex: 'AltGr + d` in Polish. There is no modified character for
  2038. * this key combination and no character is inserted into the
  2039. * document, but FF fires the keypress for char code `100` anyway.
  2040. * No `input` event will occur.
  2041. *
  2042. * - `which` is the pressed key code, but a command combination is
  2043. * being used. Ex: `Cmd+C`. No character is inserted, and no
  2044. * `input` event will occur.
  2045. */
  2046. if (!isKeypressCommand(nativeEvent)) {
  2047. // IE fires the `keypress` event when a user types an emoji via
  2048. // Touch keyboard of Windows. In such a case, the `char` property
  2049. // holds an emoji character like `\uD83D\uDE0A`. Because its length
  2050. // is 2, the property `which` does not represent an emoji correctly.
  2051. // In such a case, we directly return the `char` property instead of
  2052. // using `which`.
  2053. if (nativeEvent.char && nativeEvent.char.length > 1) {
  2054. return nativeEvent.char;
  2055. } else if (nativeEvent.which) {
  2056. return String.fromCharCode(nativeEvent.which);
  2057. }
  2058. }
  2059. return null;
  2060. case TOP_COMPOSITION_END:
  2061. return useFallbackCompositionData && !isUsingKoreanIME(nativeEvent) ? null : nativeEvent.data;
  2062. default:
  2063. return null;
  2064. }
  2065. }
  2066. /**
  2067. * Extract a SyntheticInputEvent for `beforeInput`, based on either native
  2068. * `textInput` or fallback behavior.
  2069. *
  2070. * @return {?object} A SyntheticInputEvent.
  2071. */
  2072. function extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  2073. var chars = void 0;
  2074. if (canUseTextInputEvent) {
  2075. chars = getNativeBeforeInputChars(topLevelType, nativeEvent);
  2076. } else {
  2077. chars = getFallbackBeforeInputChars(topLevelType, nativeEvent);
  2078. }
  2079. // If no characters are being inserted, no BeforeInput event should
  2080. // be fired.
  2081. if (!chars) {
  2082. return null;
  2083. }
  2084. var event = SyntheticInputEvent.getPooled(eventTypes.beforeInput, targetInst, nativeEvent, nativeEventTarget);
  2085. event.data = chars;
  2086. accumulateTwoPhaseDispatches(event);
  2087. return event;
  2088. }
  2089. /**
  2090. * Create an `onBeforeInput` event to match
  2091. * http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents.
  2092. *
  2093. * This event plugin is based on the native `textInput` event
  2094. * available in Chrome, Safari, Opera, and IE. This event fires after
  2095. * `onKeyPress` and `onCompositionEnd`, but before `onInput`.
  2096. *
  2097. * `beforeInput` is spec'd but not implemented in any browsers, and
  2098. * the `input` event does not provide any useful information about what has
  2099. * actually been added, contrary to the spec. Thus, `textInput` is the best
  2100. * available event to identify the characters that have actually been inserted
  2101. * into the target node.
  2102. *
  2103. * This plugin is also responsible for emitting `composition` events, thus
  2104. * allowing us to share composition fallback code for both `beforeInput` and
  2105. * `composition` event types.
  2106. */
  2107. var BeforeInputEventPlugin = {
  2108. eventTypes: eventTypes,
  2109. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  2110. var composition = extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget);
  2111. var beforeInput = extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget);
  2112. if (composition === null) {
  2113. return beforeInput;
  2114. }
  2115. if (beforeInput === null) {
  2116. return composition;
  2117. }
  2118. return [composition, beforeInput];
  2119. }
  2120. };
  2121. // Use to restore controlled state after a change event has fired.
  2122. var restoreImpl = null;
  2123. var restoreTarget = null;
  2124. var restoreQueue = null;
  2125. function restoreStateOfTarget(target) {
  2126. // We perform this translation at the end of the event loop so that we
  2127. // always receive the correct fiber here
  2128. var internalInstance = getInstanceFromNode(target);
  2129. if (!internalInstance) {
  2130. // Unmounted
  2131. return;
  2132. }
  2133. !(typeof restoreImpl === 'function') ? invariant(false, '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.') : void 0;
  2134. var props = getFiberCurrentPropsFromNode(internalInstance.stateNode);
  2135. restoreImpl(internalInstance.stateNode, internalInstance.type, props);
  2136. }
  2137. function setRestoreImplementation(impl) {
  2138. restoreImpl = impl;
  2139. }
  2140. function enqueueStateRestore(target) {
  2141. if (restoreTarget) {
  2142. if (restoreQueue) {
  2143. restoreQueue.push(target);
  2144. } else {
  2145. restoreQueue = [target];
  2146. }
  2147. } else {
  2148. restoreTarget = target;
  2149. }
  2150. }
  2151. function needsStateRestore() {
  2152. return restoreTarget !== null || restoreQueue !== null;
  2153. }
  2154. function restoreStateIfNeeded() {
  2155. if (!restoreTarget) {
  2156. return;
  2157. }
  2158. var target = restoreTarget;
  2159. var queuedTargets = restoreQueue;
  2160. restoreTarget = null;
  2161. restoreQueue = null;
  2162. restoreStateOfTarget(target);
  2163. if (queuedTargets) {
  2164. for (var i = 0; i < queuedTargets.length; i++) {
  2165. restoreStateOfTarget(queuedTargets[i]);
  2166. }
  2167. }
  2168. }
  2169. // Used as a way to call batchedUpdates when we don't have a reference to
  2170. // the renderer. Such as when we're dispatching events or if third party
  2171. // libraries need to call batchedUpdates. Eventually, this API will go away when
  2172. // everything is batched by default. We'll then have a similar API to opt-out of
  2173. // scheduled work and instead do synchronous work.
  2174. // Defaults
  2175. var _batchedUpdatesImpl = function (fn, bookkeeping) {
  2176. return fn(bookkeeping);
  2177. };
  2178. var _interactiveUpdatesImpl = function (fn, a, b) {
  2179. return fn(a, b);
  2180. };
  2181. var _flushInteractiveUpdatesImpl = function () {};
  2182. var isBatching = false;
  2183. function batchedUpdates(fn, bookkeeping) {
  2184. if (isBatching) {
  2185. // If we are currently inside another batch, we need to wait until it
  2186. // fully completes before restoring state.
  2187. return fn(bookkeeping);
  2188. }
  2189. isBatching = true;
  2190. try {
  2191. return _batchedUpdatesImpl(fn, bookkeeping);
  2192. } finally {
  2193. // Here we wait until all updates have propagated, which is important
  2194. // when using controlled components within layers:
  2195. // https://github.com/facebook/react/issues/1698
  2196. // Then we restore state of any controlled component.
  2197. isBatching = false;
  2198. var controlledComponentsHavePendingUpdates = needsStateRestore();
  2199. if (controlledComponentsHavePendingUpdates) {
  2200. // If a controlled event was fired, we may need to restore the state of
  2201. // the DOM node back to the controlled value. This is necessary when React
  2202. // bails out of the update without touching the DOM.
  2203. _flushInteractiveUpdatesImpl();
  2204. restoreStateIfNeeded();
  2205. }
  2206. }
  2207. }
  2208. function interactiveUpdates(fn, a, b) {
  2209. return _interactiveUpdatesImpl(fn, a, b);
  2210. }
  2211. function setBatchingImplementation(batchedUpdatesImpl, interactiveUpdatesImpl, flushInteractiveUpdatesImpl) {
  2212. _batchedUpdatesImpl = batchedUpdatesImpl;
  2213. _interactiveUpdatesImpl = interactiveUpdatesImpl;
  2214. _flushInteractiveUpdatesImpl = flushInteractiveUpdatesImpl;
  2215. }
  2216. /**
  2217. * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
  2218. */
  2219. var supportedInputTypes = {
  2220. color: true,
  2221. date: true,
  2222. datetime: true,
  2223. 'datetime-local': true,
  2224. email: true,
  2225. month: true,
  2226. number: true,
  2227. password: true,
  2228. range: true,
  2229. search: true,
  2230. tel: true,
  2231. text: true,
  2232. time: true,
  2233. url: true,
  2234. week: true
  2235. };
  2236. function isTextInputElement(elem) {
  2237. var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
  2238. if (nodeName === 'input') {
  2239. return !!supportedInputTypes[elem.type];
  2240. }
  2241. if (nodeName === 'textarea') {
  2242. return true;
  2243. }
  2244. return false;
  2245. }
  2246. /**
  2247. * HTML nodeType values that represent the type of the node
  2248. */
  2249. var ELEMENT_NODE = 1;
  2250. var TEXT_NODE = 3;
  2251. var COMMENT_NODE = 8;
  2252. var DOCUMENT_NODE = 9;
  2253. var DOCUMENT_FRAGMENT_NODE = 11;
  2254. /**
  2255. * Gets the target node from a native browser event by accounting for
  2256. * inconsistencies in browser DOM APIs.
  2257. *
  2258. * @param {object} nativeEvent Native browser event.
  2259. * @return {DOMEventTarget} Target node.
  2260. */
  2261. function getEventTarget(nativeEvent) {
  2262. // Fallback to nativeEvent.srcElement for IE9
  2263. // https://github.com/facebook/react/issues/12506
  2264. var target = nativeEvent.target || nativeEvent.srcElement || window;
  2265. // Normalize SVG <use> element events #4963
  2266. if (target.correspondingUseElement) {
  2267. target = target.correspondingUseElement;
  2268. }
  2269. // Safari may fire events on text nodes (Node.TEXT_NODE is 3).
  2270. // @see http://www.quirksmode.org/js/events_properties.html
  2271. return target.nodeType === TEXT_NODE ? target.parentNode : target;
  2272. }
  2273. /**
  2274. * Checks if an event is supported in the current execution environment.
  2275. *
  2276. * NOTE: This will not work correctly for non-generic events such as `change`,
  2277. * `reset`, `load`, `error`, and `select`.
  2278. *
  2279. * Borrows from Modernizr.
  2280. *
  2281. * @param {string} eventNameSuffix Event name, e.g. "click".
  2282. * @return {boolean} True if the event is supported.
  2283. * @internal
  2284. * @license Modernizr 3.0.0pre (Custom Build) | MIT
  2285. */
  2286. function isEventSupported(eventNameSuffix) {
  2287. if (!canUseDOM) {
  2288. return false;
  2289. }
  2290. var eventName = 'on' + eventNameSuffix;
  2291. var isSupported = eventName in document;
  2292. if (!isSupported) {
  2293. var element = document.createElement('div');
  2294. element.setAttribute(eventName, 'return;');
  2295. isSupported = typeof element[eventName] === 'function';
  2296. }
  2297. return isSupported;
  2298. }
  2299. function isCheckable(elem) {
  2300. var type = elem.type;
  2301. var nodeName = elem.nodeName;
  2302. return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio');
  2303. }
  2304. function getTracker(node) {
  2305. return node._valueTracker;
  2306. }
  2307. function detachTracker(node) {
  2308. node._valueTracker = null;
  2309. }
  2310. function getValueFromNode(node) {
  2311. var value = '';
  2312. if (!node) {
  2313. return value;
  2314. }
  2315. if (isCheckable(node)) {
  2316. value = node.checked ? 'true' : 'false';
  2317. } else {
  2318. value = node.value;
  2319. }
  2320. return value;
  2321. }
  2322. function trackValueOnNode(node) {
  2323. var valueField = isCheckable(node) ? 'checked' : 'value';
  2324. var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField);
  2325. var currentValue = '' + node[valueField];
  2326. // if someone has already defined a value or Safari, then bail
  2327. // and don't track value will cause over reporting of changes,
  2328. // but it's better then a hard failure
  2329. // (needed for certain tests that spyOn input values and Safari)
  2330. if (node.hasOwnProperty(valueField) || typeof descriptor === 'undefined' || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') {
  2331. return;
  2332. }
  2333. var get = descriptor.get,
  2334. set = descriptor.set;
  2335. Object.defineProperty(node, valueField, {
  2336. configurable: true,
  2337. get: function () {
  2338. return get.call(this);
  2339. },
  2340. set: function (value) {
  2341. currentValue = '' + value;
  2342. set.call(this, value);
  2343. }
  2344. });
  2345. // We could've passed this the first time
  2346. // but it triggers a bug in IE11 and Edge 14/15.
  2347. // Calling defineProperty() again should be equivalent.
  2348. // https://github.com/facebook/react/issues/11768
  2349. Object.defineProperty(node, valueField, {
  2350. enumerable: descriptor.enumerable
  2351. });
  2352. var tracker = {
  2353. getValue: function () {
  2354. return currentValue;
  2355. },
  2356. setValue: function (value) {
  2357. currentValue = '' + value;
  2358. },
  2359. stopTracking: function () {
  2360. detachTracker(node);
  2361. delete node[valueField];
  2362. }
  2363. };
  2364. return tracker;
  2365. }
  2366. function track(node) {
  2367. if (getTracker(node)) {
  2368. return;
  2369. }
  2370. // TODO: Once it's just Fiber we can move this to node._wrapperState
  2371. node._valueTracker = trackValueOnNode(node);
  2372. }
  2373. function updateValueIfChanged(node) {
  2374. if (!node) {
  2375. return false;
  2376. }
  2377. var tracker = getTracker(node);
  2378. // if there is no tracker at this point it's unlikely
  2379. // that trying again will succeed
  2380. if (!tracker) {
  2381. return true;
  2382. }
  2383. var lastValue = tracker.getValue();
  2384. var nextValue = getValueFromNode(node);
  2385. if (nextValue !== lastValue) {
  2386. tracker.setValue(nextValue);
  2387. return true;
  2388. }
  2389. return false;
  2390. }
  2391. var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
  2392. var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
  2393. var describeComponentFrame = function (name, source, ownerName) {
  2394. var sourceInfo = '';
  2395. if (source) {
  2396. var path = source.fileName;
  2397. var fileName = path.replace(BEFORE_SLASH_RE, '');
  2398. {
  2399. // In DEV, include code for a common special case:
  2400. // prefer "folder/index.js" instead of just "index.js".
  2401. if (/^index\./.test(fileName)) {
  2402. var match = path.match(BEFORE_SLASH_RE);
  2403. if (match) {
  2404. var pathBeforeSlash = match[1];
  2405. if (pathBeforeSlash) {
  2406. var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
  2407. fileName = folderName + '/' + fileName;
  2408. }
  2409. }
  2410. }
  2411. }
  2412. sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
  2413. } else if (ownerName) {
  2414. sourceInfo = ' (created by ' + ownerName + ')';
  2415. }
  2416. return '\n in ' + (name || 'Unknown') + sourceInfo;
  2417. };
  2418. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  2419. // nor polyfill, then a plain number is used for performance.
  2420. var hasSymbol = typeof Symbol === 'function' && Symbol.for;
  2421. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
  2422. var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
  2423. var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
  2424. var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
  2425. var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
  2426. var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
  2427. var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
  2428. var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
  2429. var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
  2430. var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
  2431. var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
  2432. var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
  2433. var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  2434. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  2435. function getIteratorFn(maybeIterable) {
  2436. if (maybeIterable === null || typeof maybeIterable !== 'object') {
  2437. return null;
  2438. }
  2439. var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
  2440. if (typeof maybeIterator === 'function') {
  2441. return maybeIterator;
  2442. }
  2443. return null;
  2444. }
  2445. var Pending = 0;
  2446. var Resolved = 1;
  2447. var Rejected = 2;
  2448. function refineResolvedLazyComponent(lazyComponent) {
  2449. return lazyComponent._status === Resolved ? lazyComponent._result : null;
  2450. }
  2451. function getWrappedName(outerType, innerType, wrapperName) {
  2452. var functionName = innerType.displayName || innerType.name || '';
  2453. return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
  2454. }
  2455. function getComponentName(type) {
  2456. if (type == null) {
  2457. // Host root, text node or just invalid type.
  2458. return null;
  2459. }
  2460. {
  2461. if (typeof type.tag === 'number') {
  2462. warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
  2463. }
  2464. }
  2465. if (typeof type === 'function') {
  2466. return type.displayName || type.name || null;
  2467. }
  2468. if (typeof type === 'string') {
  2469. return type;
  2470. }
  2471. switch (type) {
  2472. case REACT_CONCURRENT_MODE_TYPE:
  2473. return 'ConcurrentMode';
  2474. case REACT_FRAGMENT_TYPE:
  2475. return 'Fragment';
  2476. case REACT_PORTAL_TYPE:
  2477. return 'Portal';
  2478. case REACT_PROFILER_TYPE:
  2479. return 'Profiler';
  2480. case REACT_STRICT_MODE_TYPE:
  2481. return 'StrictMode';
  2482. case REACT_SUSPENSE_TYPE:
  2483. return 'Suspense';
  2484. }
  2485. if (typeof type === 'object') {
  2486. switch (type.$$typeof) {
  2487. case REACT_CONTEXT_TYPE:
  2488. return 'Context.Consumer';
  2489. case REACT_PROVIDER_TYPE:
  2490. return 'Context.Provider';
  2491. case REACT_FORWARD_REF_TYPE:
  2492. return getWrappedName(type, type.render, 'ForwardRef');
  2493. case REACT_MEMO_TYPE:
  2494. return getComponentName(type.type);
  2495. case REACT_LAZY_TYPE:
  2496. {
  2497. var thenable = type;
  2498. var resolvedThenable = refineResolvedLazyComponent(thenable);
  2499. if (resolvedThenable) {
  2500. return getComponentName(resolvedThenable);
  2501. }
  2502. }
  2503. }
  2504. }
  2505. return null;
  2506. }
  2507. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  2508. function describeFiber(fiber) {
  2509. switch (fiber.tag) {
  2510. case IndeterminateComponent:
  2511. case LazyComponent:
  2512. case FunctionComponent:
  2513. case ClassComponent:
  2514. case HostComponent:
  2515. case Mode:
  2516. case SuspenseComponent:
  2517. var owner = fiber._debugOwner;
  2518. var source = fiber._debugSource;
  2519. var name = getComponentName(fiber.type);
  2520. var ownerName = null;
  2521. if (owner) {
  2522. ownerName = getComponentName(owner.type);
  2523. }
  2524. return describeComponentFrame(name, source, ownerName);
  2525. default:
  2526. return '';
  2527. }
  2528. }
  2529. function getStackByFiberInDevAndProd(workInProgress) {
  2530. var info = '';
  2531. var node = workInProgress;
  2532. do {
  2533. info += describeFiber(node);
  2534. node = node.return;
  2535. } while (node);
  2536. return info;
  2537. }
  2538. var current = null;
  2539. var phase = null;
  2540. function getCurrentFiberOwnerNameInDevOrNull() {
  2541. {
  2542. if (current === null) {
  2543. return null;
  2544. }
  2545. var owner = current._debugOwner;
  2546. if (owner !== null && typeof owner !== 'undefined') {
  2547. return getComponentName(owner.type);
  2548. }
  2549. }
  2550. return null;
  2551. }
  2552. function getCurrentFiberStackInDev() {
  2553. {
  2554. if (current === null) {
  2555. return '';
  2556. }
  2557. // Safe because if current fiber exists, we are reconciling,
  2558. // and it is guaranteed to be the work-in-progress version.
  2559. return getStackByFiberInDevAndProd(current);
  2560. }
  2561. return '';
  2562. }
  2563. function resetCurrentFiber() {
  2564. {
  2565. ReactDebugCurrentFrame.getCurrentStack = null;
  2566. current = null;
  2567. phase = null;
  2568. }
  2569. }
  2570. function setCurrentFiber(fiber) {
  2571. {
  2572. ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev;
  2573. current = fiber;
  2574. phase = null;
  2575. }
  2576. }
  2577. function setCurrentPhase(lifeCyclePhase) {
  2578. {
  2579. phase = lifeCyclePhase;
  2580. }
  2581. }
  2582. /**
  2583. * Similar to invariant but only logs a warning if the condition is not met.
  2584. * This can be used to log issues in development environments in critical
  2585. * paths. Removing the logging code for production environments will keep the
  2586. * same logic and follow the same code paths.
  2587. */
  2588. var warning = warningWithoutStack$1;
  2589. {
  2590. warning = function (condition, format) {
  2591. if (condition) {
  2592. return;
  2593. }
  2594. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  2595. var stack = ReactDebugCurrentFrame.getStackAddendum();
  2596. // eslint-disable-next-line react-internal/warning-and-invariant-args
  2597. for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  2598. args[_key - 2] = arguments[_key];
  2599. }
  2600. warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
  2601. };
  2602. }
  2603. var warning$1 = warning;
  2604. // A reserved attribute.
  2605. // It is handled by React separately and shouldn't be written to the DOM.
  2606. var RESERVED = 0;
  2607. // A simple string attribute.
  2608. // Attributes that aren't in the whitelist are presumed to have this type.
  2609. var STRING = 1;
  2610. // A string attribute that accepts booleans in React. In HTML, these are called
  2611. // "enumerated" attributes with "true" and "false" as possible values.
  2612. // When true, it should be set to a "true" string.
  2613. // When false, it should be set to a "false" string.
  2614. var BOOLEANISH_STRING = 2;
  2615. // A real boolean attribute.
  2616. // When true, it should be present (set either to an empty string or its name).
  2617. // When false, it should be omitted.
  2618. var BOOLEAN = 3;
  2619. // An attribute that can be used as a flag as well as with a value.
  2620. // When true, it should be present (set either to an empty string or its name).
  2621. // When false, it should be omitted.
  2622. // For any other value, should be present with that value.
  2623. var OVERLOADED_BOOLEAN = 4;
  2624. // An attribute that must be numeric or parse as a numeric.
  2625. // When falsy, it should be removed.
  2626. var NUMERIC = 5;
  2627. // An attribute that must be positive numeric or parse as a positive numeric.
  2628. // When falsy, it should be removed.
  2629. var POSITIVE_NUMERIC = 6;
  2630. /* eslint-disable max-len */
  2631. 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';
  2632. /* eslint-enable max-len */
  2633. var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040';
  2634. var ROOT_ATTRIBUTE_NAME = 'data-reactroot';
  2635. var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$');
  2636. var hasOwnProperty = Object.prototype.hasOwnProperty;
  2637. var illegalAttributeNameCache = {};
  2638. var validatedAttributeNameCache = {};
  2639. function isAttributeNameSafe(attributeName) {
  2640. if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) {
  2641. return true;
  2642. }
  2643. if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) {
  2644. return false;
  2645. }
  2646. if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
  2647. validatedAttributeNameCache[attributeName] = true;
  2648. return true;
  2649. }
  2650. illegalAttributeNameCache[attributeName] = true;
  2651. {
  2652. warning$1(false, 'Invalid attribute name: `%s`', attributeName);
  2653. }
  2654. return false;
  2655. }
  2656. function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) {
  2657. if (propertyInfo !== null) {
  2658. return propertyInfo.type === RESERVED;
  2659. }
  2660. if (isCustomComponentTag) {
  2661. return false;
  2662. }
  2663. if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) {
  2664. return true;
  2665. }
  2666. return false;
  2667. }
  2668. function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) {
  2669. if (propertyInfo !== null && propertyInfo.type === RESERVED) {
  2670. return false;
  2671. }
  2672. switch (typeof value) {
  2673. case 'function':
  2674. // $FlowIssue symbol is perfectly valid here
  2675. case 'symbol':
  2676. // eslint-disable-line
  2677. return true;
  2678. case 'boolean':
  2679. {
  2680. if (isCustomComponentTag) {
  2681. return false;
  2682. }
  2683. if (propertyInfo !== null) {
  2684. return !propertyInfo.acceptsBooleans;
  2685. } else {
  2686. var prefix = name.toLowerCase().slice(0, 5);
  2687. return prefix !== 'data-' && prefix !== 'aria-';
  2688. }
  2689. }
  2690. default:
  2691. return false;
  2692. }
  2693. }
  2694. function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) {
  2695. if (value === null || typeof value === 'undefined') {
  2696. return true;
  2697. }
  2698. if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) {
  2699. return true;
  2700. }
  2701. if (isCustomComponentTag) {
  2702. return false;
  2703. }
  2704. if (propertyInfo !== null) {
  2705. switch (propertyInfo.type) {
  2706. case BOOLEAN:
  2707. return !value;
  2708. case OVERLOADED_BOOLEAN:
  2709. return value === false;
  2710. case NUMERIC:
  2711. return isNaN(value);
  2712. case POSITIVE_NUMERIC:
  2713. return isNaN(value) || value < 1;
  2714. }
  2715. }
  2716. return false;
  2717. }
  2718. function getPropertyInfo(name) {
  2719. return properties.hasOwnProperty(name) ? properties[name] : null;
  2720. }
  2721. function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace) {
  2722. this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN;
  2723. this.attributeName = attributeName;
  2724. this.attributeNamespace = attributeNamespace;
  2725. this.mustUseProperty = mustUseProperty;
  2726. this.propertyName = name;
  2727. this.type = type;
  2728. }
  2729. // When adding attributes to this list, be sure to also add them to
  2730. // the `possibleStandardNames` module to ensure casing and incorrect
  2731. // name warnings.
  2732. var properties = {};
  2733. // These props are reserved by React. They shouldn't be written to the DOM.
  2734. ['children', 'dangerouslySetInnerHTML',
  2735. // TODO: This prevents the assignment of defaultValue to regular
  2736. // elements (not just inputs). Now that ReactDOMInput assigns to the
  2737. // defaultValue property -- do we need this?
  2738. 'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style'].forEach(function (name) {
  2739. properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty
  2740. name, // attributeName
  2741. null);
  2742. } // attributeNamespace
  2743. );
  2744. // A few React string attributes have a different name.
  2745. // This is a mapping from React prop names to the attribute names.
  2746. [['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) {
  2747. var name = _ref[0],
  2748. attributeName = _ref[1];
  2749. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  2750. attributeName, // attributeName
  2751. null);
  2752. } // attributeNamespace
  2753. );
  2754. // These are "enumerated" HTML attributes that accept "true" and "false".
  2755. // In React, we let users pass `true` and `false` even though technically
  2756. // these aren't boolean attributes (they are coerced to strings).
  2757. ['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) {
  2758. properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
  2759. name.toLowerCase(), // attributeName
  2760. null);
  2761. } // attributeNamespace
  2762. );
  2763. // These are "enumerated" SVG attributes that accept "true" and "false".
  2764. // In React, we let users pass `true` and `false` even though technically
  2765. // these aren't boolean attributes (they are coerced to strings).
  2766. // Since these are SVG attributes, their attribute names are case-sensitive.
  2767. ['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) {
  2768. properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
  2769. name, // attributeName
  2770. null);
  2771. } // attributeNamespace
  2772. );
  2773. // These are HTML boolean attributes.
  2774. ['allowFullScreen', 'async',
  2775. // Note: there is a special case that prevents it from being written to the DOM
  2776. // on the client side because the browsers are inconsistent. Instead we call focus().
  2777. 'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless',
  2778. // Microdata
  2779. 'itemScope'].forEach(function (name) {
  2780. properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty
  2781. name.toLowerCase(), // attributeName
  2782. null);
  2783. } // attributeNamespace
  2784. );
  2785. // These are the few React props that we set as DOM properties
  2786. // rather than attributes. These are all booleans.
  2787. ['checked',
  2788. // Note: `option.selected` is not updated if `select.multiple` is
  2789. // disabled with `removeAttribute`. We have special logic for handling this.
  2790. 'multiple', 'muted', 'selected'].forEach(function (name) {
  2791. properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty
  2792. name, // attributeName
  2793. null);
  2794. } // attributeNamespace
  2795. );
  2796. // These are HTML attributes that are "overloaded booleans": they behave like
  2797. // booleans, but can also accept a string value.
  2798. ['capture', 'download'].forEach(function (name) {
  2799. properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty
  2800. name, // attributeName
  2801. null);
  2802. } // attributeNamespace
  2803. );
  2804. // These are HTML attributes that must be positive numbers.
  2805. ['cols', 'rows', 'size', 'span'].forEach(function (name) {
  2806. properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty
  2807. name, // attributeName
  2808. null);
  2809. } // attributeNamespace
  2810. );
  2811. // These are HTML attributes that must be numbers.
  2812. ['rowSpan', 'start'].forEach(function (name) {
  2813. properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty
  2814. name.toLowerCase(), // attributeName
  2815. null);
  2816. } // attributeNamespace
  2817. );
  2818. var CAMELIZE = /[\-\:]([a-z])/g;
  2819. var capitalize = function (token) {
  2820. return token[1].toUpperCase();
  2821. };
  2822. // This is a list of all SVG attributes that need special casing, namespacing,
  2823. // or boolean value assignment. Regular attributes that just accept strings
  2824. // and have the same names are omitted, just like in the HTML whitelist.
  2825. // Some of these attributes can be hard to find. This list was created by
  2826. // scrapping the MDN documentation.
  2827. ['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) {
  2828. var name = attributeName.replace(CAMELIZE, capitalize);
  2829. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  2830. attributeName, null);
  2831. } // attributeNamespace
  2832. );
  2833. // String SVG attributes with the xlink namespace.
  2834. ['xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type'].forEach(function (attributeName) {
  2835. var name = attributeName.replace(CAMELIZE, capitalize);
  2836. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  2837. attributeName, 'http://www.w3.org/1999/xlink');
  2838. });
  2839. // String SVG attributes with the xml namespace.
  2840. ['xml:base', 'xml:lang', 'xml:space'].forEach(function (attributeName) {
  2841. var name = attributeName.replace(CAMELIZE, capitalize);
  2842. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  2843. attributeName, 'http://www.w3.org/XML/1998/namespace');
  2844. });
  2845. // Special case: this attribute exists both in HTML and SVG.
  2846. // Its "tabindex" attribute name is case-sensitive in SVG so we can't just use
  2847. // its React `tabIndex` name, like we do for attributes that exist only in HTML.
  2848. properties.tabIndex = new PropertyInfoRecord('tabIndex', STRING, false, // mustUseProperty
  2849. 'tabindex', // attributeName
  2850. null);
  2851. /**
  2852. * Get the value for a property on a node. Only used in DEV for SSR validation.
  2853. * The "expected" argument is used as a hint of what the expected value is.
  2854. * Some properties have multiple equivalent values.
  2855. */
  2856. function getValueForProperty(node, name, expected, propertyInfo) {
  2857. {
  2858. if (propertyInfo.mustUseProperty) {
  2859. var propertyName = propertyInfo.propertyName;
  2860. return node[propertyName];
  2861. } else {
  2862. var attributeName = propertyInfo.attributeName;
  2863. var stringValue = null;
  2864. if (propertyInfo.type === OVERLOADED_BOOLEAN) {
  2865. if (node.hasAttribute(attributeName)) {
  2866. var value = node.getAttribute(attributeName);
  2867. if (value === '') {
  2868. return true;
  2869. }
  2870. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  2871. return value;
  2872. }
  2873. if (value === '' + expected) {
  2874. return expected;
  2875. }
  2876. return value;
  2877. }
  2878. } else if (node.hasAttribute(attributeName)) {
  2879. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  2880. // We had an attribute but shouldn't have had one, so read it
  2881. // for the error message.
  2882. return node.getAttribute(attributeName);
  2883. }
  2884. if (propertyInfo.type === BOOLEAN) {
  2885. // If this was a boolean, it doesn't matter what the value is
  2886. // the fact that we have it is the same as the expected.
  2887. return expected;
  2888. }
  2889. // Even if this property uses a namespace we use getAttribute
  2890. // because we assume its namespaced name is the same as our config.
  2891. // To use getAttributeNS we need the local name which we don't have
  2892. // in our config atm.
  2893. stringValue = node.getAttribute(attributeName);
  2894. }
  2895. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  2896. return stringValue === null ? expected : stringValue;
  2897. } else if (stringValue === '' + expected) {
  2898. return expected;
  2899. } else {
  2900. return stringValue;
  2901. }
  2902. }
  2903. }
  2904. }
  2905. /**
  2906. * Get the value for a attribute on a node. Only used in DEV for SSR validation.
  2907. * The third argument is used as a hint of what the expected value is. Some
  2908. * attributes have multiple equivalent values.
  2909. */
  2910. function getValueForAttribute(node, name, expected) {
  2911. {
  2912. if (!isAttributeNameSafe(name)) {
  2913. return;
  2914. }
  2915. if (!node.hasAttribute(name)) {
  2916. return expected === undefined ? undefined : null;
  2917. }
  2918. var value = node.getAttribute(name);
  2919. if (value === '' + expected) {
  2920. return expected;
  2921. }
  2922. return value;
  2923. }
  2924. }
  2925. /**
  2926. * Sets the value for a property on a node.
  2927. *
  2928. * @param {DOMElement} node
  2929. * @param {string} name
  2930. * @param {*} value
  2931. */
  2932. function setValueForProperty(node, name, value, isCustomComponentTag) {
  2933. var propertyInfo = getPropertyInfo(name);
  2934. if (shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag)) {
  2935. return;
  2936. }
  2937. if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) {
  2938. value = null;
  2939. }
  2940. // If the prop isn't in the special list, treat it as a simple attribute.
  2941. if (isCustomComponentTag || propertyInfo === null) {
  2942. if (isAttributeNameSafe(name)) {
  2943. var _attributeName = name;
  2944. if (value === null) {
  2945. node.removeAttribute(_attributeName);
  2946. } else {
  2947. node.setAttribute(_attributeName, '' + value);
  2948. }
  2949. }
  2950. return;
  2951. }
  2952. var mustUseProperty = propertyInfo.mustUseProperty;
  2953. if (mustUseProperty) {
  2954. var propertyName = propertyInfo.propertyName;
  2955. if (value === null) {
  2956. var type = propertyInfo.type;
  2957. node[propertyName] = type === BOOLEAN ? false : '';
  2958. } else {
  2959. // Contrary to `setAttribute`, object properties are properly
  2960. // `toString`ed by IE8/9.
  2961. node[propertyName] = value;
  2962. }
  2963. return;
  2964. }
  2965. // The rest are treated as attributes with special cases.
  2966. var attributeName = propertyInfo.attributeName,
  2967. attributeNamespace = propertyInfo.attributeNamespace;
  2968. if (value === null) {
  2969. node.removeAttribute(attributeName);
  2970. } else {
  2971. var _type = propertyInfo.type;
  2972. var attributeValue = void 0;
  2973. if (_type === BOOLEAN || _type === OVERLOADED_BOOLEAN && value === true) {
  2974. attributeValue = '';
  2975. } else {
  2976. // `setAttribute` with objects becomes only `[object]` in IE8/9,
  2977. // ('' + value) makes it output the correct toString()-value.
  2978. attributeValue = '' + value;
  2979. }
  2980. if (attributeNamespace) {
  2981. node.setAttributeNS(attributeNamespace, attributeName, attributeValue);
  2982. } else {
  2983. node.setAttribute(attributeName, attributeValue);
  2984. }
  2985. }
  2986. }
  2987. // Flow does not allow string concatenation of most non-string types. To work
  2988. // around this limitation, we use an opaque type that can only be obtained by
  2989. // passing the value through getToStringValue first.
  2990. function toString(value) {
  2991. return '' + value;
  2992. }
  2993. function getToStringValue(value) {
  2994. switch (typeof value) {
  2995. case 'boolean':
  2996. case 'number':
  2997. case 'object':
  2998. case 'string':
  2999. case 'undefined':
  3000. return value;
  3001. default:
  3002. // function, symbol are assigned as empty strings
  3003. return '';
  3004. }
  3005. }
  3006. var ReactDebugCurrentFrame$1 = null;
  3007. var ReactControlledValuePropTypes = {
  3008. checkPropTypes: null
  3009. };
  3010. {
  3011. ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
  3012. var hasReadOnlyValue = {
  3013. button: true,
  3014. checkbox: true,
  3015. image: true,
  3016. hidden: true,
  3017. radio: true,
  3018. reset: true,
  3019. submit: true
  3020. };
  3021. var propTypes = {
  3022. value: function (props, propName, componentName) {
  3023. if (hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled || props[propName] == null) {
  3024. return null;
  3025. }
  3026. 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`.');
  3027. },
  3028. checked: function (props, propName, componentName) {
  3029. if (props.onChange || props.readOnly || props.disabled || props[propName] == null) {
  3030. return null;
  3031. }
  3032. 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`.');
  3033. }
  3034. };
  3035. /**
  3036. * Provide a linked `value` attribute for controlled forms. You should not use
  3037. * this outside of the ReactDOM controlled form components.
  3038. */
  3039. ReactControlledValuePropTypes.checkPropTypes = function (tagName, props) {
  3040. checkPropTypes(propTypes, props, 'prop', tagName, ReactDebugCurrentFrame$1.getStackAddendum);
  3041. };
  3042. }
  3043. var enableUserTimingAPI = true;
  3044. var enableHooks = false;
  3045. // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
  3046. var debugRenderPhaseSideEffects = false;
  3047. // In some cases, StrictMode should also double-render lifecycles.
  3048. // This can be confusing for tests though,
  3049. // And it can be bad for performance in production.
  3050. // This feature flag can be used to control the behavior:
  3051. var debugRenderPhaseSideEffectsForStrictMode = true;
  3052. // To preserve the "Pause on caught exceptions" behavior of the debugger, we
  3053. // replay the begin phase of a failed component inside invokeGuardedCallback.
  3054. var replayFailedUnitOfWorkWithInvokeGuardedCallback = true;
  3055. // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
  3056. var warnAboutDeprecatedLifecycles = false;
  3057. // Gather advanced timing metrics for Profiler subtrees.
  3058. var enableProfilerTimer = true;
  3059. // Trace which interactions trigger each commit.
  3060. var enableSchedulerTracing = true;
  3061. // Only used in www builds.
  3062. // Only used in www builds.
  3063. // React Fire: prevent the value and checked attributes from syncing
  3064. // with their related DOM properties
  3065. var disableInputAttributeSyncing = false;
  3066. // These APIs will no longer be "unstable" in the upcoming 16.7 release,
  3067. // Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
  3068. var enableStableConcurrentModeAPIs = false;
  3069. // TODO: direct imports like some-package/src/* are bad. Fix me.
  3070. var didWarnValueDefaultValue = false;
  3071. var didWarnCheckedDefaultChecked = false;
  3072. var didWarnControlledToUncontrolled = false;
  3073. var didWarnUncontrolledToControlled = false;
  3074. function isControlled(props) {
  3075. var usesChecked = props.type === 'checkbox' || props.type === 'radio';
  3076. return usesChecked ? props.checked != null : props.value != null;
  3077. }
  3078. /**
  3079. * Implements an <input> host component that allows setting these optional
  3080. * props: `checked`, `value`, `defaultChecked`, and `defaultValue`.
  3081. *
  3082. * If `checked` or `value` are not supplied (or null/undefined), user actions
  3083. * that affect the checked state or value will trigger updates to the element.
  3084. *
  3085. * If they are supplied (and not null/undefined), the rendered element will not
  3086. * trigger updates to the element. Instead, the props must change in order for
  3087. * the rendered element to be updated.
  3088. *
  3089. * The rendered element will be initialized as unchecked (or `defaultChecked`)
  3090. * with an empty value (or `defaultValue`).
  3091. *
  3092. * See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html
  3093. */
  3094. function getHostProps(element, props) {
  3095. var node = element;
  3096. var checked = props.checked;
  3097. var hostProps = _assign({}, props, {
  3098. defaultChecked: undefined,
  3099. defaultValue: undefined,
  3100. value: undefined,
  3101. checked: checked != null ? checked : node._wrapperState.initialChecked
  3102. });
  3103. return hostProps;
  3104. }
  3105. function initWrapperState(element, props) {
  3106. {
  3107. ReactControlledValuePropTypes.checkPropTypes('input', props);
  3108. if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) {
  3109. 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);
  3110. didWarnCheckedDefaultChecked = true;
  3111. }
  3112. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) {
  3113. 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);
  3114. didWarnValueDefaultValue = true;
  3115. }
  3116. }
  3117. var node = element;
  3118. var defaultValue = props.defaultValue == null ? '' : props.defaultValue;
  3119. node._wrapperState = {
  3120. initialChecked: props.checked != null ? props.checked : props.defaultChecked,
  3121. initialValue: getToStringValue(props.value != null ? props.value : defaultValue),
  3122. controlled: isControlled(props)
  3123. };
  3124. }
  3125. function updateChecked(element, props) {
  3126. var node = element;
  3127. var checked = props.checked;
  3128. if (checked != null) {
  3129. setValueForProperty(node, 'checked', checked, false);
  3130. }
  3131. }
  3132. function updateWrapper(element, props) {
  3133. var node = element;
  3134. {
  3135. var _controlled = isControlled(props);
  3136. if (!node._wrapperState.controlled && _controlled && !didWarnUncontrolledToControlled) {
  3137. 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);
  3138. didWarnUncontrolledToControlled = true;
  3139. }
  3140. if (node._wrapperState.controlled && !_controlled && !didWarnControlledToUncontrolled) {
  3141. 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);
  3142. didWarnControlledToUncontrolled = true;
  3143. }
  3144. }
  3145. updateChecked(element, props);
  3146. var value = getToStringValue(props.value);
  3147. var type = props.type;
  3148. if (value != null) {
  3149. if (type === 'number') {
  3150. if (value === 0 && node.value === '' ||
  3151. // We explicitly want to coerce to number here if possible.
  3152. // eslint-disable-next-line
  3153. node.value != value) {
  3154. node.value = toString(value);
  3155. }
  3156. } else if (node.value !== toString(value)) {
  3157. node.value = toString(value);
  3158. }
  3159. } else if (type === 'submit' || type === 'reset') {
  3160. // Submit/reset inputs need the attribute removed completely to avoid
  3161. // blank-text buttons.
  3162. node.removeAttribute('value');
  3163. return;
  3164. }
  3165. if (disableInputAttributeSyncing) {
  3166. // When not syncing the value attribute, React only assigns a new value
  3167. // whenever the defaultValue React prop has changed. When not present,
  3168. // React does nothing
  3169. if (props.hasOwnProperty('defaultValue')) {
  3170. setDefaultValue(node, props.type, getToStringValue(props.defaultValue));
  3171. }
  3172. } else {
  3173. // When syncing the value attribute, the value comes from a cascade of
  3174. // properties:
  3175. // 1. The value React property
  3176. // 2. The defaultValue React property
  3177. // 3. Otherwise there should be no change
  3178. if (props.hasOwnProperty('value')) {
  3179. setDefaultValue(node, props.type, value);
  3180. } else if (props.hasOwnProperty('defaultValue')) {
  3181. setDefaultValue(node, props.type, getToStringValue(props.defaultValue));
  3182. }
  3183. }
  3184. if (disableInputAttributeSyncing) {
  3185. // When not syncing the checked attribute, the attribute is directly
  3186. // controllable from the defaultValue React property. It needs to be
  3187. // updated as new props come in.
  3188. if (props.defaultChecked == null) {
  3189. node.removeAttribute('checked');
  3190. } else {
  3191. node.defaultChecked = !!props.defaultChecked;
  3192. }
  3193. } else {
  3194. // When syncing the checked attribute, it only changes when it needs
  3195. // to be removed, such as transitioning from a checkbox into a text input
  3196. if (props.checked == null && props.defaultChecked != null) {
  3197. node.defaultChecked = !!props.defaultChecked;
  3198. }
  3199. }
  3200. }
  3201. function postMountWrapper(element, props, isHydrating) {
  3202. var node = element;
  3203. // Do not assign value if it is already set. This prevents user text input
  3204. // from being lost during SSR hydration.
  3205. if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) {
  3206. var type = props.type;
  3207. var isButton = type === 'submit' || type === 'reset';
  3208. // Avoid setting value attribute on submit/reset inputs as it overrides the
  3209. // default value provided by the browser. See: #12872
  3210. if (isButton && (props.value === undefined || props.value === null)) {
  3211. return;
  3212. }
  3213. var _initialValue = toString(node._wrapperState.initialValue);
  3214. // Do not assign value if it is already set. This prevents user text input
  3215. // from being lost during SSR hydration.
  3216. if (!isHydrating) {
  3217. if (disableInputAttributeSyncing) {
  3218. var value = getToStringValue(props.value);
  3219. // When not syncing the value attribute, the value property points
  3220. // directly to the React prop. Only assign it if it exists.
  3221. if (value != null) {
  3222. // Always assign on buttons so that it is possible to assign an
  3223. // empty string to clear button text.
  3224. //
  3225. // Otherwise, do not re-assign the value property if is empty. This
  3226. // potentially avoids a DOM write and prevents Firefox (~60.0.1) from
  3227. // prematurely marking required inputs as invalid. Equality is compared
  3228. // to the current value in case the browser provided value is not an
  3229. // empty string.
  3230. if (isButton || value !== node.value) {
  3231. node.value = toString(value);
  3232. }
  3233. }
  3234. } else {
  3235. // When syncing the value attribute, the value property should use
  3236. // the wrapperState._initialValue property. This uses:
  3237. //
  3238. // 1. The value React property when present
  3239. // 2. The defaultValue React property when present
  3240. // 3. An empty string
  3241. if (_initialValue !== node.value) {
  3242. node.value = _initialValue;
  3243. }
  3244. }
  3245. }
  3246. if (disableInputAttributeSyncing) {
  3247. // When not syncing the value attribute, assign the value attribute
  3248. // directly from the defaultValue React property (when present)
  3249. var defaultValue = getToStringValue(props.defaultValue);
  3250. if (defaultValue != null) {
  3251. node.defaultValue = toString(defaultValue);
  3252. }
  3253. } else {
  3254. // Otherwise, the value attribute is synchronized to the property,
  3255. // so we assign defaultValue to the same thing as the value property
  3256. // assignment step above.
  3257. node.defaultValue = _initialValue;
  3258. }
  3259. }
  3260. // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug
  3261. // this is needed to work around a chrome bug where setting defaultChecked
  3262. // will sometimes influence the value of checked (even after detachment).
  3263. // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416
  3264. // We need to temporarily unset name to avoid disrupting radio button groups.
  3265. var name = node.name;
  3266. if (name !== '') {
  3267. node.name = '';
  3268. }
  3269. if (disableInputAttributeSyncing) {
  3270. // When not syncing the checked attribute, the checked property
  3271. // never gets assigned. It must be manually set. We don't want
  3272. // to do this when hydrating so that existing user input isn't
  3273. // modified
  3274. if (!isHydrating) {
  3275. updateChecked(element, props);
  3276. }
  3277. // Only assign the checked attribute if it is defined. This saves
  3278. // a DOM write when controlling the checked attribute isn't needed
  3279. // (text inputs, submit/reset)
  3280. if (props.hasOwnProperty('defaultChecked')) {
  3281. node.defaultChecked = !node.defaultChecked;
  3282. node.defaultChecked = !!props.defaultChecked;
  3283. }
  3284. } else {
  3285. // When syncing the checked attribute, both the checked property and
  3286. // attribute are assigned at the same time using defaultChecked. This uses:
  3287. //
  3288. // 1. The checked React property when present
  3289. // 2. The defaultChecked React property when present
  3290. // 3. Otherwise, false
  3291. node.defaultChecked = !node.defaultChecked;
  3292. node.defaultChecked = !!node._wrapperState.initialChecked;
  3293. }
  3294. if (name !== '') {
  3295. node.name = name;
  3296. }
  3297. }
  3298. function restoreControlledState(element, props) {
  3299. var node = element;
  3300. updateWrapper(node, props);
  3301. updateNamedCousins(node, props);
  3302. }
  3303. function updateNamedCousins(rootNode, props) {
  3304. var name = props.name;
  3305. if (props.type === 'radio' && name != null) {
  3306. var queryRoot = rootNode;
  3307. while (queryRoot.parentNode) {
  3308. queryRoot = queryRoot.parentNode;
  3309. }
  3310. // If `rootNode.form` was non-null, then we could try `form.elements`,
  3311. // but that sometimes behaves strangely in IE8. We could also try using
  3312. // `form.getElementsByName`, but that will only return direct children
  3313. // and won't include inputs that use the HTML5 `form=` attribute. Since
  3314. // the input might not even be in a form. It might not even be in the
  3315. // document. Let's just use the local `querySelectorAll` to ensure we don't
  3316. // miss anything.
  3317. var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]');
  3318. for (var i = 0; i < group.length; i++) {
  3319. var otherNode = group[i];
  3320. if (otherNode === rootNode || otherNode.form !== rootNode.form) {
  3321. continue;
  3322. }
  3323. // This will throw if radio buttons rendered by different copies of React
  3324. // and the same name are rendered into the same form (same as #1939).
  3325. // That's probably okay; we don't support it just as we don't support
  3326. // mixing React radio buttons with non-React ones.
  3327. var otherProps = getFiberCurrentPropsFromNode$1(otherNode);
  3328. !otherProps ? invariant(false, 'ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported.') : void 0;
  3329. // We need update the tracked value on the named cousin since the value
  3330. // was changed but the input saw no event or value set
  3331. updateValueIfChanged(otherNode);
  3332. // If this is a controlled radio button group, forcing the input that
  3333. // was previously checked to update will cause it to be come re-checked
  3334. // as appropriate.
  3335. updateWrapper(otherNode, otherProps);
  3336. }
  3337. }
  3338. }
  3339. // In Chrome, assigning defaultValue to certain input types triggers input validation.
  3340. // For number inputs, the display value loses trailing decimal points. For email inputs,
  3341. // Chrome raises "The specified value <x> is not a valid email address".
  3342. //
  3343. // Here we check to see if the defaultValue has actually changed, avoiding these problems
  3344. // when the user is inputting text
  3345. //
  3346. // https://github.com/facebook/react/issues/7253
  3347. function setDefaultValue(node, type, value) {
  3348. if (
  3349. // Focused number inputs synchronize on blur. See ChangeEventPlugin.js
  3350. type !== 'number' || node.ownerDocument.activeElement !== node) {
  3351. if (value == null) {
  3352. node.defaultValue = toString(node._wrapperState.initialValue);
  3353. } else if (node.defaultValue !== toString(value)) {
  3354. node.defaultValue = toString(value);
  3355. }
  3356. }
  3357. }
  3358. var eventTypes$1 = {
  3359. change: {
  3360. phasedRegistrationNames: {
  3361. bubbled: 'onChange',
  3362. captured: 'onChangeCapture'
  3363. },
  3364. dependencies: [TOP_BLUR, TOP_CHANGE, TOP_CLICK, TOP_FOCUS, TOP_INPUT, TOP_KEY_DOWN, TOP_KEY_UP, TOP_SELECTION_CHANGE]
  3365. }
  3366. };
  3367. function createAndAccumulateChangeEvent(inst, nativeEvent, target) {
  3368. var event = SyntheticEvent.getPooled(eventTypes$1.change, inst, nativeEvent, target);
  3369. event.type = 'change';
  3370. // Flag this event loop as needing state restore.
  3371. enqueueStateRestore(target);
  3372. accumulateTwoPhaseDispatches(event);
  3373. return event;
  3374. }
  3375. /**
  3376. * For IE shims
  3377. */
  3378. var activeElement = null;
  3379. var activeElementInst = null;
  3380. /**
  3381. * SECTION: handle `change` event
  3382. */
  3383. function shouldUseChangeEvent(elem) {
  3384. var nodeName = elem.nodeName && elem.nodeName.toLowerCase();
  3385. return nodeName === 'select' || nodeName === 'input' && elem.type === 'file';
  3386. }
  3387. function manualDispatchChangeEvent(nativeEvent) {
  3388. var event = createAndAccumulateChangeEvent(activeElementInst, nativeEvent, getEventTarget(nativeEvent));
  3389. // If change and propertychange bubbled, we'd just bind to it like all the
  3390. // other events and have it go through ReactBrowserEventEmitter. Since it
  3391. // doesn't, we manually listen for the events and so we have to enqueue and
  3392. // process the abstract event manually.
  3393. //
  3394. // Batching is necessary here in order to ensure that all event handlers run
  3395. // before the next rerender (including event handlers attached to ancestor
  3396. // elements instead of directly on the input). Without this, controlled
  3397. // components don't work properly in conjunction with event bubbling because
  3398. // the component is rerendered and the value reverted before all the event
  3399. // handlers can run. See https://github.com/facebook/react/issues/708.
  3400. batchedUpdates(runEventInBatch, event);
  3401. }
  3402. function runEventInBatch(event) {
  3403. runEventsInBatch(event);
  3404. }
  3405. function getInstIfValueChanged(targetInst) {
  3406. var targetNode = getNodeFromInstance$1(targetInst);
  3407. if (updateValueIfChanged(targetNode)) {
  3408. return targetInst;
  3409. }
  3410. }
  3411. function getTargetInstForChangeEvent(topLevelType, targetInst) {
  3412. if (topLevelType === TOP_CHANGE) {
  3413. return targetInst;
  3414. }
  3415. }
  3416. /**
  3417. * SECTION: handle `input` event
  3418. */
  3419. var isInputEventSupported = false;
  3420. if (canUseDOM) {
  3421. // IE9 claims to support the input event but fails to trigger it when
  3422. // deleting text, so we ignore its input events.
  3423. isInputEventSupported = isEventSupported('input') && (!document.documentMode || document.documentMode > 9);
  3424. }
  3425. /**
  3426. * (For IE <=9) Starts tracking propertychange events on the passed-in element
  3427. * and override the value property so that we can distinguish user events from
  3428. * value changes in JS.
  3429. */
  3430. function startWatchingForValueChange(target, targetInst) {
  3431. activeElement = target;
  3432. activeElementInst = targetInst;
  3433. activeElement.attachEvent('onpropertychange', handlePropertyChange);
  3434. }
  3435. /**
  3436. * (For IE <=9) Removes the event listeners from the currently-tracked element,
  3437. * if any exists.
  3438. */
  3439. function stopWatchingForValueChange() {
  3440. if (!activeElement) {
  3441. return;
  3442. }
  3443. activeElement.detachEvent('onpropertychange', handlePropertyChange);
  3444. activeElement = null;
  3445. activeElementInst = null;
  3446. }
  3447. /**
  3448. * (For IE <=9) Handles a propertychange event, sending a `change` event if
  3449. * the value of the active element has changed.
  3450. */
  3451. function handlePropertyChange(nativeEvent) {
  3452. if (nativeEvent.propertyName !== 'value') {
  3453. return;
  3454. }
  3455. if (getInstIfValueChanged(activeElementInst)) {
  3456. manualDispatchChangeEvent(nativeEvent);
  3457. }
  3458. }
  3459. function handleEventsForInputEventPolyfill(topLevelType, target, targetInst) {
  3460. if (topLevelType === TOP_FOCUS) {
  3461. // In IE9, propertychange fires for most input events but is buggy and
  3462. // doesn't fire when text is deleted, but conveniently, selectionchange
  3463. // appears to fire in all of the remaining cases so we catch those and
  3464. // forward the event if the value has changed
  3465. // In either case, we don't want to call the event handler if the value
  3466. // is changed from JS so we redefine a setter for `.value` that updates
  3467. // our activeElementValue variable, allowing us to ignore those changes
  3468. //
  3469. // stopWatching() should be a noop here but we call it just in case we
  3470. // missed a blur event somehow.
  3471. stopWatchingForValueChange();
  3472. startWatchingForValueChange(target, targetInst);
  3473. } else if (topLevelType === TOP_BLUR) {
  3474. stopWatchingForValueChange();
  3475. }
  3476. }
  3477. // For IE8 and IE9.
  3478. function getTargetInstForInputEventPolyfill(topLevelType, targetInst) {
  3479. if (topLevelType === TOP_SELECTION_CHANGE || topLevelType === TOP_KEY_UP || topLevelType === TOP_KEY_DOWN) {
  3480. // On the selectionchange event, the target is just document which isn't
  3481. // helpful for us so just check activeElement instead.
  3482. //
  3483. // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire
  3484. // propertychange on the first input event after setting `value` from a
  3485. // script and fires only keydown, keypress, keyup. Catching keyup usually
  3486. // gets it and catching keydown lets us fire an event for the first
  3487. // keystroke if user does a key repeat (it'll be a little delayed: right
  3488. // before the second keystroke). Other input methods (e.g., paste) seem to
  3489. // fire selectionchange normally.
  3490. return getInstIfValueChanged(activeElementInst);
  3491. }
  3492. }
  3493. /**
  3494. * SECTION: handle `click` event
  3495. */
  3496. function shouldUseClickEvent(elem) {
  3497. // Use the `click` event to detect changes to checkbox and radio inputs.
  3498. // This approach works across all browsers, whereas `change` does not fire
  3499. // until `blur` in IE8.
  3500. var nodeName = elem.nodeName;
  3501. return nodeName && nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio');
  3502. }
  3503. function getTargetInstForClickEvent(topLevelType, targetInst) {
  3504. if (topLevelType === TOP_CLICK) {
  3505. return getInstIfValueChanged(targetInst);
  3506. }
  3507. }
  3508. function getTargetInstForInputOrChangeEvent(topLevelType, targetInst) {
  3509. if (topLevelType === TOP_INPUT || topLevelType === TOP_CHANGE) {
  3510. return getInstIfValueChanged(targetInst);
  3511. }
  3512. }
  3513. function handleControlledInputBlur(node) {
  3514. var state = node._wrapperState;
  3515. if (!state || !state.controlled || node.type !== 'number') {
  3516. return;
  3517. }
  3518. if (!disableInputAttributeSyncing) {
  3519. // If controlled, assign the value attribute to the current value on blur
  3520. setDefaultValue(node, 'number', node.value);
  3521. }
  3522. }
  3523. /**
  3524. * This plugin creates an `onChange` event that normalizes change events
  3525. * across form elements. This event fires at a time when it's possible to
  3526. * change the element's value without seeing a flicker.
  3527. *
  3528. * Supported elements are:
  3529. * - input (see `isTextInputElement`)
  3530. * - textarea
  3531. * - select
  3532. */
  3533. var ChangeEventPlugin = {
  3534. eventTypes: eventTypes$1,
  3535. _isInputEventSupported: isInputEventSupported,
  3536. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  3537. var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window;
  3538. var getTargetInstFunc = void 0,
  3539. handleEventFunc = void 0;
  3540. if (shouldUseChangeEvent(targetNode)) {
  3541. getTargetInstFunc = getTargetInstForChangeEvent;
  3542. } else if (isTextInputElement(targetNode)) {
  3543. if (isInputEventSupported) {
  3544. getTargetInstFunc = getTargetInstForInputOrChangeEvent;
  3545. } else {
  3546. getTargetInstFunc = getTargetInstForInputEventPolyfill;
  3547. handleEventFunc = handleEventsForInputEventPolyfill;
  3548. }
  3549. } else if (shouldUseClickEvent(targetNode)) {
  3550. getTargetInstFunc = getTargetInstForClickEvent;
  3551. }
  3552. if (getTargetInstFunc) {
  3553. var inst = getTargetInstFunc(topLevelType, targetInst);
  3554. if (inst) {
  3555. var event = createAndAccumulateChangeEvent(inst, nativeEvent, nativeEventTarget);
  3556. return event;
  3557. }
  3558. }
  3559. if (handleEventFunc) {
  3560. handleEventFunc(topLevelType, targetNode, targetInst);
  3561. }
  3562. // When blurring, set the value attribute for number inputs
  3563. if (topLevelType === TOP_BLUR) {
  3564. handleControlledInputBlur(targetNode);
  3565. }
  3566. }
  3567. };
  3568. /**
  3569. * Module that is injectable into `EventPluginHub`, that specifies a
  3570. * deterministic ordering of `EventPlugin`s. A convenient way to reason about
  3571. * plugins, without having to package every one of them. This is better than
  3572. * having plugins be ordered in the same order that they are injected because
  3573. * that ordering would be influenced by the packaging order.
  3574. * `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
  3575. * preventing default on events is convenient in `SimpleEventPlugin` handlers.
  3576. */
  3577. var DOMEventPluginOrder = ['ResponderEventPlugin', 'SimpleEventPlugin', 'EnterLeaveEventPlugin', 'ChangeEventPlugin', 'SelectEventPlugin', 'BeforeInputEventPlugin'];
  3578. var SyntheticUIEvent = SyntheticEvent.extend({
  3579. view: null,
  3580. detail: null
  3581. });
  3582. var modifierKeyToProp = {
  3583. Alt: 'altKey',
  3584. Control: 'ctrlKey',
  3585. Meta: 'metaKey',
  3586. Shift: 'shiftKey'
  3587. };
  3588. // Older browsers (Safari <= 10, iOS Safari <= 10.2) do not support
  3589. // getModifierState. If getModifierState is not supported, we map it to a set of
  3590. // modifier keys exposed by the event. In this case, Lock-keys are not supported.
  3591. /**
  3592. * Translation from modifier key to the associated property in the event.
  3593. * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
  3594. */
  3595. function modifierStateGetter(keyArg) {
  3596. var syntheticEvent = this;
  3597. var nativeEvent = syntheticEvent.nativeEvent;
  3598. if (nativeEvent.getModifierState) {
  3599. return nativeEvent.getModifierState(keyArg);
  3600. }
  3601. var keyProp = modifierKeyToProp[keyArg];
  3602. return keyProp ? !!nativeEvent[keyProp] : false;
  3603. }
  3604. function getEventModifierState(nativeEvent) {
  3605. return modifierStateGetter;
  3606. }
  3607. var previousScreenX = 0;
  3608. var previousScreenY = 0;
  3609. // Use flags to signal movementX/Y has already been set
  3610. var isMovementXSet = false;
  3611. var isMovementYSet = false;
  3612. /**
  3613. * @interface MouseEvent
  3614. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  3615. */
  3616. var SyntheticMouseEvent = SyntheticUIEvent.extend({
  3617. screenX: null,
  3618. screenY: null,
  3619. clientX: null,
  3620. clientY: null,
  3621. pageX: null,
  3622. pageY: null,
  3623. ctrlKey: null,
  3624. shiftKey: null,
  3625. altKey: null,
  3626. metaKey: null,
  3627. getModifierState: getEventModifierState,
  3628. button: null,
  3629. buttons: null,
  3630. relatedTarget: function (event) {
  3631. return event.relatedTarget || (event.fromElement === event.srcElement ? event.toElement : event.fromElement);
  3632. },
  3633. movementX: function (event) {
  3634. if ('movementX' in event) {
  3635. return event.movementX;
  3636. }
  3637. var screenX = previousScreenX;
  3638. previousScreenX = event.screenX;
  3639. if (!isMovementXSet) {
  3640. isMovementXSet = true;
  3641. return 0;
  3642. }
  3643. return event.type === 'mousemove' ? event.screenX - screenX : 0;
  3644. },
  3645. movementY: function (event) {
  3646. if ('movementY' in event) {
  3647. return event.movementY;
  3648. }
  3649. var screenY = previousScreenY;
  3650. previousScreenY = event.screenY;
  3651. if (!isMovementYSet) {
  3652. isMovementYSet = true;
  3653. return 0;
  3654. }
  3655. return event.type === 'mousemove' ? event.screenY - screenY : 0;
  3656. }
  3657. });
  3658. /**
  3659. * @interface PointerEvent
  3660. * @see http://www.w3.org/TR/pointerevents/
  3661. */
  3662. var SyntheticPointerEvent = SyntheticMouseEvent.extend({
  3663. pointerId: null,
  3664. width: null,
  3665. height: null,
  3666. pressure: null,
  3667. tangentialPressure: null,
  3668. tiltX: null,
  3669. tiltY: null,
  3670. twist: null,
  3671. pointerType: null,
  3672. isPrimary: null
  3673. });
  3674. var eventTypes$2 = {
  3675. mouseEnter: {
  3676. registrationName: 'onMouseEnter',
  3677. dependencies: [TOP_MOUSE_OUT, TOP_MOUSE_OVER]
  3678. },
  3679. mouseLeave: {
  3680. registrationName: 'onMouseLeave',
  3681. dependencies: [TOP_MOUSE_OUT, TOP_MOUSE_OVER]
  3682. },
  3683. pointerEnter: {
  3684. registrationName: 'onPointerEnter',
  3685. dependencies: [TOP_POINTER_OUT, TOP_POINTER_OVER]
  3686. },
  3687. pointerLeave: {
  3688. registrationName: 'onPointerLeave',
  3689. dependencies: [TOP_POINTER_OUT, TOP_POINTER_OVER]
  3690. }
  3691. };
  3692. var EnterLeaveEventPlugin = {
  3693. eventTypes: eventTypes$2,
  3694. /**
  3695. * For almost every interaction we care about, there will be both a top-level
  3696. * `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that
  3697. * we do not extract duplicate events. However, moving the mouse into the
  3698. * browser from outside will not fire a `mouseout` event. In this case, we use
  3699. * the `mouseover` top-level event.
  3700. */
  3701. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  3702. var isOverEvent = topLevelType === TOP_MOUSE_OVER || topLevelType === TOP_POINTER_OVER;
  3703. var isOutEvent = topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_POINTER_OUT;
  3704. if (isOverEvent && (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
  3705. return null;
  3706. }
  3707. if (!isOutEvent && !isOverEvent) {
  3708. // Must not be a mouse or pointer in or out - ignoring.
  3709. return null;
  3710. }
  3711. var win = void 0;
  3712. if (nativeEventTarget.window === nativeEventTarget) {
  3713. // `nativeEventTarget` is probably a window object.
  3714. win = nativeEventTarget;
  3715. } else {
  3716. // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
  3717. var doc = nativeEventTarget.ownerDocument;
  3718. if (doc) {
  3719. win = doc.defaultView || doc.parentWindow;
  3720. } else {
  3721. win = window;
  3722. }
  3723. }
  3724. var from = void 0;
  3725. var to = void 0;
  3726. if (isOutEvent) {
  3727. from = targetInst;
  3728. var related = nativeEvent.relatedTarget || nativeEvent.toElement;
  3729. to = related ? getClosestInstanceFromNode(related) : null;
  3730. } else {
  3731. // Moving to a node from outside the window.
  3732. from = null;
  3733. to = targetInst;
  3734. }
  3735. if (from === to) {
  3736. // Nothing pertains to our managed components.
  3737. return null;
  3738. }
  3739. var eventInterface = void 0,
  3740. leaveEventType = void 0,
  3741. enterEventType = void 0,
  3742. eventTypePrefix = void 0;
  3743. if (topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_MOUSE_OVER) {
  3744. eventInterface = SyntheticMouseEvent;
  3745. leaveEventType = eventTypes$2.mouseLeave;
  3746. enterEventType = eventTypes$2.mouseEnter;
  3747. eventTypePrefix = 'mouse';
  3748. } else if (topLevelType === TOP_POINTER_OUT || topLevelType === TOP_POINTER_OVER) {
  3749. eventInterface = SyntheticPointerEvent;
  3750. leaveEventType = eventTypes$2.pointerLeave;
  3751. enterEventType = eventTypes$2.pointerEnter;
  3752. eventTypePrefix = 'pointer';
  3753. }
  3754. var fromNode = from == null ? win : getNodeFromInstance$1(from);
  3755. var toNode = to == null ? win : getNodeFromInstance$1(to);
  3756. var leave = eventInterface.getPooled(leaveEventType, from, nativeEvent, nativeEventTarget);
  3757. leave.type = eventTypePrefix + 'leave';
  3758. leave.target = fromNode;
  3759. leave.relatedTarget = toNode;
  3760. var enter = eventInterface.getPooled(enterEventType, to, nativeEvent, nativeEventTarget);
  3761. enter.type = eventTypePrefix + 'enter';
  3762. enter.target = toNode;
  3763. enter.relatedTarget = fromNode;
  3764. accumulateEnterLeaveDispatches(leave, enter, from, to);
  3765. return [leave, enter];
  3766. }
  3767. };
  3768. /*eslint-disable no-self-compare */
  3769. var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  3770. /**
  3771. * inlined Object.is polyfill to avoid requiring consumers ship their own
  3772. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  3773. */
  3774. function is(x, y) {
  3775. // SameValue algorithm
  3776. if (x === y) {
  3777. // Steps 1-5, 7-10
  3778. // Steps 6.b-6.e: +0 != -0
  3779. // Added the nonzero y check to make Flow happy, but it is redundant
  3780. return x !== 0 || y !== 0 || 1 / x === 1 / y;
  3781. } else {
  3782. // Step 6.a: NaN == NaN
  3783. return x !== x && y !== y;
  3784. }
  3785. }
  3786. /**
  3787. * Performs equality by iterating through keys on an object and returning false
  3788. * when any key has values which are not strictly equal between the arguments.
  3789. * Returns true when the values of all keys are strictly equal.
  3790. */
  3791. function shallowEqual(objA, objB) {
  3792. if (is(objA, objB)) {
  3793. return true;
  3794. }
  3795. if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
  3796. return false;
  3797. }
  3798. var keysA = Object.keys(objA);
  3799. var keysB = Object.keys(objB);
  3800. if (keysA.length !== keysB.length) {
  3801. return false;
  3802. }
  3803. // Test for A's keys different from B.
  3804. for (var i = 0; i < keysA.length; i++) {
  3805. if (!hasOwnProperty$1.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
  3806. return false;
  3807. }
  3808. }
  3809. return true;
  3810. }
  3811. /**
  3812. * `ReactInstanceMap` maintains a mapping from a public facing stateful
  3813. * instance (key) and the internal representation (value). This allows public
  3814. * methods to accept the user facing instance as an argument and map them back
  3815. * to internal methods.
  3816. *
  3817. * Note that this module is currently shared and assumed to be stateless.
  3818. * If this becomes an actual Map, that will break.
  3819. */
  3820. /**
  3821. * This API should be called `delete` but we'd have to make sure to always
  3822. * transform these to strings for IE support. When this transform is fully
  3823. * supported we can rename it.
  3824. */
  3825. function get(key) {
  3826. return key._reactInternalFiber;
  3827. }
  3828. function has(key) {
  3829. return key._reactInternalFiber !== undefined;
  3830. }
  3831. function set(key, value) {
  3832. key._reactInternalFiber = value;
  3833. }
  3834. // Don't change these two values. They're used by React Dev Tools.
  3835. var NoEffect = /* */0;
  3836. var PerformedWork = /* */1;
  3837. // You can change the rest (and add more).
  3838. var Placement = /* */2;
  3839. var Update = /* */4;
  3840. var PlacementAndUpdate = /* */6;
  3841. var Deletion = /* */8;
  3842. var ContentReset = /* */16;
  3843. var Callback = /* */32;
  3844. var DidCapture = /* */64;
  3845. var Ref = /* */128;
  3846. var Snapshot = /* */256;
  3847. var Passive = /* */512;
  3848. // Passive & Update & Callback & Ref & Snapshot
  3849. var LifecycleEffectMask = /* */932;
  3850. // Union of all host effects
  3851. var HostEffectMask = /* */1023;
  3852. var Incomplete = /* */1024;
  3853. var ShouldCapture = /* */2048;
  3854. var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
  3855. var MOUNTING = 1;
  3856. var MOUNTED = 2;
  3857. var UNMOUNTED = 3;
  3858. function isFiberMountedImpl(fiber) {
  3859. var node = fiber;
  3860. if (!fiber.alternate) {
  3861. // If there is no alternate, this might be a new tree that isn't inserted
  3862. // yet. If it is, then it will have a pending insertion effect on it.
  3863. if ((node.effectTag & Placement) !== NoEffect) {
  3864. return MOUNTING;
  3865. }
  3866. while (node.return) {
  3867. node = node.return;
  3868. if ((node.effectTag & Placement) !== NoEffect) {
  3869. return MOUNTING;
  3870. }
  3871. }
  3872. } else {
  3873. while (node.return) {
  3874. node = node.return;
  3875. }
  3876. }
  3877. if (node.tag === HostRoot) {
  3878. // TODO: Check if this was a nested HostRoot when used with
  3879. // renderContainerIntoSubtree.
  3880. return MOUNTED;
  3881. }
  3882. // If we didn't hit the root, that means that we're in an disconnected tree
  3883. // that has been unmounted.
  3884. return UNMOUNTED;
  3885. }
  3886. function isFiberMounted(fiber) {
  3887. return isFiberMountedImpl(fiber) === MOUNTED;
  3888. }
  3889. function isMounted(component) {
  3890. {
  3891. var owner = ReactCurrentOwner$1.current;
  3892. if (owner !== null && owner.tag === ClassComponent) {
  3893. var ownerFiber = owner;
  3894. var instance = ownerFiber.stateNode;
  3895. !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;
  3896. instance._warnedAboutRefsInRender = true;
  3897. }
  3898. }
  3899. var fiber = get(component);
  3900. if (!fiber) {
  3901. return false;
  3902. }
  3903. return isFiberMountedImpl(fiber) === MOUNTED;
  3904. }
  3905. function assertIsMounted(fiber) {
  3906. !(isFiberMountedImpl(fiber) === MOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
  3907. }
  3908. function findCurrentFiberUsingSlowPath(fiber) {
  3909. var alternate = fiber.alternate;
  3910. if (!alternate) {
  3911. // If there is no alternate, then we only need to check if it is mounted.
  3912. var state = isFiberMountedImpl(fiber);
  3913. !(state !== UNMOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
  3914. if (state === MOUNTING) {
  3915. return null;
  3916. }
  3917. return fiber;
  3918. }
  3919. // If we have two possible branches, we'll walk backwards up to the root
  3920. // to see what path the root points to. On the way we may hit one of the
  3921. // special cases and we'll deal with them.
  3922. var a = fiber;
  3923. var b = alternate;
  3924. while (true) {
  3925. var parentA = a.return;
  3926. var parentB = parentA ? parentA.alternate : null;
  3927. if (!parentA || !parentB) {
  3928. // We're at the root.
  3929. break;
  3930. }
  3931. // If both copies of the parent fiber point to the same child, we can
  3932. // assume that the child is current. This happens when we bailout on low
  3933. // priority: the bailed out fiber's child reuses the current child.
  3934. if (parentA.child === parentB.child) {
  3935. var child = parentA.child;
  3936. while (child) {
  3937. if (child === a) {
  3938. // We've determined that A is the current branch.
  3939. assertIsMounted(parentA);
  3940. return fiber;
  3941. }
  3942. if (child === b) {
  3943. // We've determined that B is the current branch.
  3944. assertIsMounted(parentA);
  3945. return alternate;
  3946. }
  3947. child = child.sibling;
  3948. }
  3949. // We should never have an alternate for any mounting node. So the only
  3950. // way this could possibly happen is if this was unmounted, if at all.
  3951. invariant(false, 'Unable to find node on an unmounted component.');
  3952. }
  3953. if (a.return !== b.return) {
  3954. // The return pointer of A and the return pointer of B point to different
  3955. // fibers. We assume that return pointers never criss-cross, so A must
  3956. // belong to the child set of A.return, and B must belong to the child
  3957. // set of B.return.
  3958. a = parentA;
  3959. b = parentB;
  3960. } else {
  3961. // The return pointers point to the same fiber. We'll have to use the
  3962. // default, slow path: scan the child sets of each parent alternate to see
  3963. // which child belongs to which set.
  3964. //
  3965. // Search parent A's child set
  3966. var didFindChild = false;
  3967. var _child = parentA.child;
  3968. while (_child) {
  3969. if (_child === a) {
  3970. didFindChild = true;
  3971. a = parentA;
  3972. b = parentB;
  3973. break;
  3974. }
  3975. if (_child === b) {
  3976. didFindChild = true;
  3977. b = parentA;
  3978. a = parentB;
  3979. break;
  3980. }
  3981. _child = _child.sibling;
  3982. }
  3983. if (!didFindChild) {
  3984. // Search parent B's child set
  3985. _child = parentB.child;
  3986. while (_child) {
  3987. if (_child === a) {
  3988. didFindChild = true;
  3989. a = parentB;
  3990. b = parentA;
  3991. break;
  3992. }
  3993. if (_child === b) {
  3994. didFindChild = true;
  3995. b = parentB;
  3996. a = parentA;
  3997. break;
  3998. }
  3999. _child = _child.sibling;
  4000. }
  4001. !didFindChild ? invariant(false, 'Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.') : void 0;
  4002. }
  4003. }
  4004. !(a.alternate === b) ? invariant(false, 'Return fibers should always be each others\' alternates. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  4005. }
  4006. // If the root is not a host container, we're in a disconnected tree. I.e.
  4007. // unmounted.
  4008. !(a.tag === HostRoot) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;
  4009. if (a.stateNode.current === a) {
  4010. // We've determined that A is the current branch.
  4011. return fiber;
  4012. }
  4013. // Otherwise B has to be current branch.
  4014. return alternate;
  4015. }
  4016. function findCurrentHostFiber(parent) {
  4017. var currentParent = findCurrentFiberUsingSlowPath(parent);
  4018. if (!currentParent) {
  4019. return null;
  4020. }
  4021. // Next we'll drill down this component to find the first HostComponent/Text.
  4022. var node = currentParent;
  4023. while (true) {
  4024. if (node.tag === HostComponent || node.tag === HostText) {
  4025. return node;
  4026. } else if (node.child) {
  4027. node.child.return = node;
  4028. node = node.child;
  4029. continue;
  4030. }
  4031. if (node === currentParent) {
  4032. return null;
  4033. }
  4034. while (!node.sibling) {
  4035. if (!node.return || node.return === currentParent) {
  4036. return null;
  4037. }
  4038. node = node.return;
  4039. }
  4040. node.sibling.return = node.return;
  4041. node = node.sibling;
  4042. }
  4043. // Flow needs the return null here, but ESLint complains about it.
  4044. // eslint-disable-next-line no-unreachable
  4045. return null;
  4046. }
  4047. function findCurrentHostFiberWithNoPortals(parent) {
  4048. var currentParent = findCurrentFiberUsingSlowPath(parent);
  4049. if (!currentParent) {
  4050. return null;
  4051. }
  4052. // Next we'll drill down this component to find the first HostComponent/Text.
  4053. var node = currentParent;
  4054. while (true) {
  4055. if (node.tag === HostComponent || node.tag === HostText) {
  4056. return node;
  4057. } else if (node.child && node.tag !== HostPortal) {
  4058. node.child.return = node;
  4059. node = node.child;
  4060. continue;
  4061. }
  4062. if (node === currentParent) {
  4063. return null;
  4064. }
  4065. while (!node.sibling) {
  4066. if (!node.return || node.return === currentParent) {
  4067. return null;
  4068. }
  4069. node = node.return;
  4070. }
  4071. node.sibling.return = node.return;
  4072. node = node.sibling;
  4073. }
  4074. // Flow needs the return null here, but ESLint complains about it.
  4075. // eslint-disable-next-line no-unreachable
  4076. return null;
  4077. }
  4078. function addEventBubbleListener(element, eventType, listener) {
  4079. element.addEventListener(eventType, listener, false);
  4080. }
  4081. function addEventCaptureListener(element, eventType, listener) {
  4082. element.addEventListener(eventType, listener, true);
  4083. }
  4084. /**
  4085. * @interface Event
  4086. * @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface
  4087. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent
  4088. */
  4089. var SyntheticAnimationEvent = SyntheticEvent.extend({
  4090. animationName: null,
  4091. elapsedTime: null,
  4092. pseudoElement: null
  4093. });
  4094. /**
  4095. * @interface Event
  4096. * @see http://www.w3.org/TR/clipboard-apis/
  4097. */
  4098. var SyntheticClipboardEvent = SyntheticEvent.extend({
  4099. clipboardData: function (event) {
  4100. return 'clipboardData' in event ? event.clipboardData : window.clipboardData;
  4101. }
  4102. });
  4103. /**
  4104. * @interface FocusEvent
  4105. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  4106. */
  4107. var SyntheticFocusEvent = SyntheticUIEvent.extend({
  4108. relatedTarget: null
  4109. });
  4110. /**
  4111. * `charCode` represents the actual "character code" and is safe to use with
  4112. * `String.fromCharCode`. As such, only keys that correspond to printable
  4113. * characters produce a valid `charCode`, the only exception to this is Enter.
  4114. * The Tab-key is considered non-printable and does not have a `charCode`,
  4115. * presumably because it does not produce a tab-character in browsers.
  4116. *
  4117. * @param {object} nativeEvent Native browser event.
  4118. * @return {number} Normalized `charCode` property.
  4119. */
  4120. function getEventCharCode(nativeEvent) {
  4121. var charCode = void 0;
  4122. var keyCode = nativeEvent.keyCode;
  4123. if ('charCode' in nativeEvent) {
  4124. charCode = nativeEvent.charCode;
  4125. // FF does not set `charCode` for the Enter-key, check against `keyCode`.
  4126. if (charCode === 0 && keyCode === 13) {
  4127. charCode = 13;
  4128. }
  4129. } else {
  4130. // IE8 does not implement `charCode`, but `keyCode` has the correct value.
  4131. charCode = keyCode;
  4132. }
  4133. // IE and Edge (on Windows) and Chrome / Safari (on Windows and Linux)
  4134. // report Enter as charCode 10 when ctrl is pressed.
  4135. if (charCode === 10) {
  4136. charCode = 13;
  4137. }
  4138. // Some non-printable keys are reported in `charCode`/`keyCode`, discard them.
  4139. // Must not discard the (non-)printable Enter-key.
  4140. if (charCode >= 32 || charCode === 13) {
  4141. return charCode;
  4142. }
  4143. return 0;
  4144. }
  4145. /**
  4146. * Normalization of deprecated HTML5 `key` values
  4147. * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
  4148. */
  4149. var normalizeKey = {
  4150. Esc: 'Escape',
  4151. Spacebar: ' ',
  4152. Left: 'ArrowLeft',
  4153. Up: 'ArrowUp',
  4154. Right: 'ArrowRight',
  4155. Down: 'ArrowDown',
  4156. Del: 'Delete',
  4157. Win: 'OS',
  4158. Menu: 'ContextMenu',
  4159. Apps: 'ContextMenu',
  4160. Scroll: 'ScrollLock',
  4161. MozPrintableKey: 'Unidentified'
  4162. };
  4163. /**
  4164. * Translation from legacy `keyCode` to HTML5 `key`
  4165. * Only special keys supported, all others depend on keyboard layout or browser
  4166. * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
  4167. */
  4168. var translateToKey = {
  4169. '8': 'Backspace',
  4170. '9': 'Tab',
  4171. '12': 'Clear',
  4172. '13': 'Enter',
  4173. '16': 'Shift',
  4174. '17': 'Control',
  4175. '18': 'Alt',
  4176. '19': 'Pause',
  4177. '20': 'CapsLock',
  4178. '27': 'Escape',
  4179. '32': ' ',
  4180. '33': 'PageUp',
  4181. '34': 'PageDown',
  4182. '35': 'End',
  4183. '36': 'Home',
  4184. '37': 'ArrowLeft',
  4185. '38': 'ArrowUp',
  4186. '39': 'ArrowRight',
  4187. '40': 'ArrowDown',
  4188. '45': 'Insert',
  4189. '46': 'Delete',
  4190. '112': 'F1',
  4191. '113': 'F2',
  4192. '114': 'F3',
  4193. '115': 'F4',
  4194. '116': 'F5',
  4195. '117': 'F6',
  4196. '118': 'F7',
  4197. '119': 'F8',
  4198. '120': 'F9',
  4199. '121': 'F10',
  4200. '122': 'F11',
  4201. '123': 'F12',
  4202. '144': 'NumLock',
  4203. '145': 'ScrollLock',
  4204. '224': 'Meta'
  4205. };
  4206. /**
  4207. * @param {object} nativeEvent Native browser event.
  4208. * @return {string} Normalized `key` property.
  4209. */
  4210. function getEventKey(nativeEvent) {
  4211. if (nativeEvent.key) {
  4212. // Normalize inconsistent values reported by browsers due to
  4213. // implementations of a working draft specification.
  4214. // FireFox implements `key` but returns `MozPrintableKey` for all
  4215. // printable characters (normalized to `Unidentified`), ignore it.
  4216. var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
  4217. if (key !== 'Unidentified') {
  4218. return key;
  4219. }
  4220. }
  4221. // Browser does not implement `key`, polyfill as much of it as we can.
  4222. if (nativeEvent.type === 'keypress') {
  4223. var charCode = getEventCharCode(nativeEvent);
  4224. // The enter-key is technically both printable and non-printable and can
  4225. // thus be captured by `keypress`, no other non-printable key should.
  4226. return charCode === 13 ? 'Enter' : String.fromCharCode(charCode);
  4227. }
  4228. if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {
  4229. // While user keyboard layout determines the actual meaning of each
  4230. // `keyCode` value, almost all function keys have a universal value.
  4231. return translateToKey[nativeEvent.keyCode] || 'Unidentified';
  4232. }
  4233. return '';
  4234. }
  4235. /**
  4236. * @interface KeyboardEvent
  4237. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  4238. */
  4239. var SyntheticKeyboardEvent = SyntheticUIEvent.extend({
  4240. key: getEventKey,
  4241. location: null,
  4242. ctrlKey: null,
  4243. shiftKey: null,
  4244. altKey: null,
  4245. metaKey: null,
  4246. repeat: null,
  4247. locale: null,
  4248. getModifierState: getEventModifierState,
  4249. // Legacy Interface
  4250. charCode: function (event) {
  4251. // `charCode` is the result of a KeyPress event and represents the value of
  4252. // the actual printable character.
  4253. // KeyPress is deprecated, but its replacement is not yet final and not
  4254. // implemented in any major browser. Only KeyPress has charCode.
  4255. if (event.type === 'keypress') {
  4256. return getEventCharCode(event);
  4257. }
  4258. return 0;
  4259. },
  4260. keyCode: function (event) {
  4261. // `keyCode` is the result of a KeyDown/Up event and represents the value of
  4262. // physical keyboard key.
  4263. // The actual meaning of the value depends on the users' keyboard layout
  4264. // which cannot be detected. Assuming that it is a US keyboard layout
  4265. // provides a surprisingly accurate mapping for US and European users.
  4266. // Due to this, it is left to the user to implement at this time.
  4267. if (event.type === 'keydown' || event.type === 'keyup') {
  4268. return event.keyCode;
  4269. }
  4270. return 0;
  4271. },
  4272. which: function (event) {
  4273. // `which` is an alias for either `keyCode` or `charCode` depending on the
  4274. // type of the event.
  4275. if (event.type === 'keypress') {
  4276. return getEventCharCode(event);
  4277. }
  4278. if (event.type === 'keydown' || event.type === 'keyup') {
  4279. return event.keyCode;
  4280. }
  4281. return 0;
  4282. }
  4283. });
  4284. /**
  4285. * @interface DragEvent
  4286. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  4287. */
  4288. var SyntheticDragEvent = SyntheticMouseEvent.extend({
  4289. dataTransfer: null
  4290. });
  4291. /**
  4292. * @interface TouchEvent
  4293. * @see http://www.w3.org/TR/touch-events/
  4294. */
  4295. var SyntheticTouchEvent = SyntheticUIEvent.extend({
  4296. touches: null,
  4297. targetTouches: null,
  4298. changedTouches: null,
  4299. altKey: null,
  4300. metaKey: null,
  4301. ctrlKey: null,
  4302. shiftKey: null,
  4303. getModifierState: getEventModifierState
  4304. });
  4305. /**
  4306. * @interface Event
  4307. * @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events-
  4308. * @see https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent
  4309. */
  4310. var SyntheticTransitionEvent = SyntheticEvent.extend({
  4311. propertyName: null,
  4312. elapsedTime: null,
  4313. pseudoElement: null
  4314. });
  4315. /**
  4316. * @interface WheelEvent
  4317. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  4318. */
  4319. var SyntheticWheelEvent = SyntheticMouseEvent.extend({
  4320. deltaX: function (event) {
  4321. return 'deltaX' in event ? event.deltaX : // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
  4322. 'wheelDeltaX' in event ? -event.wheelDeltaX : 0;
  4323. },
  4324. deltaY: function (event) {
  4325. return 'deltaY' in event ? event.deltaY : // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
  4326. 'wheelDeltaY' in event ? -event.wheelDeltaY : // Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
  4327. 'wheelDelta' in event ? -event.wheelDelta : 0;
  4328. },
  4329. deltaZ: null,
  4330. // Browsers without "deltaMode" is reporting in raw wheel delta where one
  4331. // notch on the scroll is always +/- 120, roughly equivalent to pixels.
  4332. // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or
  4333. // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size.
  4334. deltaMode: null
  4335. });
  4336. /**
  4337. * Turns
  4338. * ['abort', ...]
  4339. * into
  4340. * eventTypes = {
  4341. * 'abort': {
  4342. * phasedRegistrationNames: {
  4343. * bubbled: 'onAbort',
  4344. * captured: 'onAbortCapture',
  4345. * },
  4346. * dependencies: [TOP_ABORT],
  4347. * },
  4348. * ...
  4349. * };
  4350. * topLevelEventsToDispatchConfig = new Map([
  4351. * [TOP_ABORT, { sameConfig }],
  4352. * ]);
  4353. */
  4354. var interactiveEventTypeNames = [[TOP_BLUR, 'blur'], [TOP_CANCEL, 'cancel'], [TOP_CLICK, 'click'], [TOP_CLOSE, 'close'], [TOP_CONTEXT_MENU, 'contextMenu'], [TOP_COPY, 'copy'], [TOP_CUT, 'cut'], [TOP_AUX_CLICK, 'auxClick'], [TOP_DOUBLE_CLICK, 'doubleClick'], [TOP_DRAG_END, 'dragEnd'], [TOP_DRAG_START, 'dragStart'], [TOP_DROP, 'drop'], [TOP_FOCUS, 'focus'], [TOP_INPUT, 'input'], [TOP_INVALID, 'invalid'], [TOP_KEY_DOWN, 'keyDown'], [TOP_KEY_PRESS, 'keyPress'], [TOP_KEY_UP, 'keyUp'], [TOP_MOUSE_DOWN, 'mouseDown'], [TOP_MOUSE_UP, 'mouseUp'], [TOP_PASTE, 'paste'], [TOP_PAUSE, 'pause'], [TOP_PLAY, 'play'], [TOP_POINTER_CANCEL, 'pointerCancel'], [TOP_POINTER_DOWN, 'pointerDown'], [TOP_POINTER_UP, 'pointerUp'], [TOP_RATE_CHANGE, 'rateChange'], [TOP_RESET, 'reset'], [TOP_SEEKED, 'seeked'], [TOP_SUBMIT, 'submit'], [TOP_TOUCH_CANCEL, 'touchCancel'], [TOP_TOUCH_END, 'touchEnd'], [TOP_TOUCH_START, 'touchStart'], [TOP_VOLUME_CHANGE, 'volumeChange']];
  4355. var nonInteractiveEventTypeNames = [[TOP_ABORT, 'abort'], [TOP_ANIMATION_END, 'animationEnd'], [TOP_ANIMATION_ITERATION, 'animationIteration'], [TOP_ANIMATION_START, 'animationStart'], [TOP_CAN_PLAY, 'canPlay'], [TOP_CAN_PLAY_THROUGH, 'canPlayThrough'], [TOP_DRAG, 'drag'], [TOP_DRAG_ENTER, 'dragEnter'], [TOP_DRAG_EXIT, 'dragExit'], [TOP_DRAG_LEAVE, 'dragLeave'], [TOP_DRAG_OVER, 'dragOver'], [TOP_DURATION_CHANGE, 'durationChange'], [TOP_EMPTIED, 'emptied'], [TOP_ENCRYPTED, 'encrypted'], [TOP_ENDED, 'ended'], [TOP_ERROR, 'error'], [TOP_GOT_POINTER_CAPTURE, 'gotPointerCapture'], [TOP_LOAD, 'load'], [TOP_LOADED_DATA, 'loadedData'], [TOP_LOADED_METADATA, 'loadedMetadata'], [TOP_LOAD_START, 'loadStart'], [TOP_LOST_POINTER_CAPTURE, 'lostPointerCapture'], [TOP_MOUSE_MOVE, 'mouseMove'], [TOP_MOUSE_OUT, 'mouseOut'], [TOP_MOUSE_OVER, 'mouseOver'], [TOP_PLAYING, 'playing'], [TOP_POINTER_MOVE, 'pointerMove'], [TOP_POINTER_OUT, 'pointerOut'], [TOP_POINTER_OVER, 'pointerOver'], [TOP_PROGRESS, 'progress'], [TOP_SCROLL, 'scroll'], [TOP_SEEKING, 'seeking'], [TOP_STALLED, 'stalled'], [TOP_SUSPEND, 'suspend'], [TOP_TIME_UPDATE, 'timeUpdate'], [TOP_TOGGLE, 'toggle'], [TOP_TOUCH_MOVE, 'touchMove'], [TOP_TRANSITION_END, 'transitionEnd'], [TOP_WAITING, 'waiting'], [TOP_WHEEL, 'wheel']];
  4356. var eventTypes$4 = {};
  4357. var topLevelEventsToDispatchConfig = {};
  4358. function addEventTypeNameToConfig(_ref, isInteractive) {
  4359. var topEvent = _ref[0],
  4360. event = _ref[1];
  4361. var capitalizedEvent = event[0].toUpperCase() + event.slice(1);
  4362. var onEvent = 'on' + capitalizedEvent;
  4363. var type = {
  4364. phasedRegistrationNames: {
  4365. bubbled: onEvent,
  4366. captured: onEvent + 'Capture'
  4367. },
  4368. dependencies: [topEvent],
  4369. isInteractive: isInteractive
  4370. };
  4371. eventTypes$4[event] = type;
  4372. topLevelEventsToDispatchConfig[topEvent] = type;
  4373. }
  4374. interactiveEventTypeNames.forEach(function (eventTuple) {
  4375. addEventTypeNameToConfig(eventTuple, true);
  4376. });
  4377. nonInteractiveEventTypeNames.forEach(function (eventTuple) {
  4378. addEventTypeNameToConfig(eventTuple, false);
  4379. });
  4380. // Only used in DEV for exhaustiveness validation.
  4381. 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];
  4382. var SimpleEventPlugin = {
  4383. eventTypes: eventTypes$4,
  4384. isInteractiveTopLevelEventType: function (topLevelType) {
  4385. var config = topLevelEventsToDispatchConfig[topLevelType];
  4386. return config !== undefined && config.isInteractive === true;
  4387. },
  4388. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  4389. var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType];
  4390. if (!dispatchConfig) {
  4391. return null;
  4392. }
  4393. var EventConstructor = void 0;
  4394. switch (topLevelType) {
  4395. case TOP_KEY_PRESS:
  4396. // Firefox creates a keypress event for function keys too. This removes
  4397. // the unwanted keypress events. Enter is however both printable and
  4398. // non-printable. One would expect Tab to be as well (but it isn't).
  4399. if (getEventCharCode(nativeEvent) === 0) {
  4400. return null;
  4401. }
  4402. /* falls through */
  4403. case TOP_KEY_DOWN:
  4404. case TOP_KEY_UP:
  4405. EventConstructor = SyntheticKeyboardEvent;
  4406. break;
  4407. case TOP_BLUR:
  4408. case TOP_FOCUS:
  4409. EventConstructor = SyntheticFocusEvent;
  4410. break;
  4411. case TOP_CLICK:
  4412. // Firefox creates a click event on right mouse clicks. This removes the
  4413. // unwanted click events.
  4414. if (nativeEvent.button === 2) {
  4415. return null;
  4416. }
  4417. /* falls through */
  4418. case TOP_AUX_CLICK:
  4419. case TOP_DOUBLE_CLICK:
  4420. case TOP_MOUSE_DOWN:
  4421. case TOP_MOUSE_MOVE:
  4422. case TOP_MOUSE_UP:
  4423. // TODO: Disabled elements should not respond to mouse events
  4424. /* falls through */
  4425. case TOP_MOUSE_OUT:
  4426. case TOP_MOUSE_OVER:
  4427. case TOP_CONTEXT_MENU:
  4428. EventConstructor = SyntheticMouseEvent;
  4429. break;
  4430. case TOP_DRAG:
  4431. case TOP_DRAG_END:
  4432. case TOP_DRAG_ENTER:
  4433. case TOP_DRAG_EXIT:
  4434. case TOP_DRAG_LEAVE:
  4435. case TOP_DRAG_OVER:
  4436. case TOP_DRAG_START:
  4437. case TOP_DROP:
  4438. EventConstructor = SyntheticDragEvent;
  4439. break;
  4440. case TOP_TOUCH_CANCEL:
  4441. case TOP_TOUCH_END:
  4442. case TOP_TOUCH_MOVE:
  4443. case TOP_TOUCH_START:
  4444. EventConstructor = SyntheticTouchEvent;
  4445. break;
  4446. case TOP_ANIMATION_END:
  4447. case TOP_ANIMATION_ITERATION:
  4448. case TOP_ANIMATION_START:
  4449. EventConstructor = SyntheticAnimationEvent;
  4450. break;
  4451. case TOP_TRANSITION_END:
  4452. EventConstructor = SyntheticTransitionEvent;
  4453. break;
  4454. case TOP_SCROLL:
  4455. EventConstructor = SyntheticUIEvent;
  4456. break;
  4457. case TOP_WHEEL:
  4458. EventConstructor = SyntheticWheelEvent;
  4459. break;
  4460. case TOP_COPY:
  4461. case TOP_CUT:
  4462. case TOP_PASTE:
  4463. EventConstructor = SyntheticClipboardEvent;
  4464. break;
  4465. case TOP_GOT_POINTER_CAPTURE:
  4466. case TOP_LOST_POINTER_CAPTURE:
  4467. case TOP_POINTER_CANCEL:
  4468. case TOP_POINTER_DOWN:
  4469. case TOP_POINTER_MOVE:
  4470. case TOP_POINTER_OUT:
  4471. case TOP_POINTER_OVER:
  4472. case TOP_POINTER_UP:
  4473. EventConstructor = SyntheticPointerEvent;
  4474. break;
  4475. default:
  4476. {
  4477. if (knownHTMLTopLevelTypes.indexOf(topLevelType) === -1) {
  4478. warningWithoutStack$1(false, 'SimpleEventPlugin: Unhandled event type, `%s`. This warning ' + 'is likely caused by a bug in React. Please file an issue.', topLevelType);
  4479. }
  4480. }
  4481. // HTML Events
  4482. // @see http://www.w3.org/TR/html5/index.html#events-0
  4483. EventConstructor = SyntheticEvent;
  4484. break;
  4485. }
  4486. var event = EventConstructor.getPooled(dispatchConfig, targetInst, nativeEvent, nativeEventTarget);
  4487. accumulateTwoPhaseDispatches(event);
  4488. return event;
  4489. }
  4490. };
  4491. var isInteractiveTopLevelEventType = SimpleEventPlugin.isInteractiveTopLevelEventType;
  4492. var CALLBACK_BOOKKEEPING_POOL_SIZE = 10;
  4493. var callbackBookkeepingPool = [];
  4494. /**
  4495. * Find the deepest React component completely containing the root of the
  4496. * passed-in instance (for use when entire React trees are nested within each
  4497. * other). If React trees are not nested, returns null.
  4498. */
  4499. function findRootContainerNode(inst) {
  4500. // TODO: It may be a good idea to cache this to prevent unnecessary DOM
  4501. // traversal, but caching is difficult to do correctly without using a
  4502. // mutation observer to listen for all DOM changes.
  4503. while (inst.return) {
  4504. inst = inst.return;
  4505. }
  4506. if (inst.tag !== HostRoot) {
  4507. // This can happen if we're in a detached tree.
  4508. return null;
  4509. }
  4510. return inst.stateNode.containerInfo;
  4511. }
  4512. // Used to store ancestor hierarchy in top level callback
  4513. function getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst) {
  4514. if (callbackBookkeepingPool.length) {
  4515. var instance = callbackBookkeepingPool.pop();
  4516. instance.topLevelType = topLevelType;
  4517. instance.nativeEvent = nativeEvent;
  4518. instance.targetInst = targetInst;
  4519. return instance;
  4520. }
  4521. return {
  4522. topLevelType: topLevelType,
  4523. nativeEvent: nativeEvent,
  4524. targetInst: targetInst,
  4525. ancestors: []
  4526. };
  4527. }
  4528. function releaseTopLevelCallbackBookKeeping(instance) {
  4529. instance.topLevelType = null;
  4530. instance.nativeEvent = null;
  4531. instance.targetInst = null;
  4532. instance.ancestors.length = 0;
  4533. if (callbackBookkeepingPool.length < CALLBACK_BOOKKEEPING_POOL_SIZE) {
  4534. callbackBookkeepingPool.push(instance);
  4535. }
  4536. }
  4537. function handleTopLevel(bookKeeping) {
  4538. var targetInst = bookKeeping.targetInst;
  4539. // Loop through the hierarchy, in case there's any nested components.
  4540. // It's important that we build the array of ancestors before calling any
  4541. // event handlers, because event handlers can modify the DOM, leading to
  4542. // inconsistencies with ReactMount's node cache. See #1105.
  4543. var ancestor = targetInst;
  4544. do {
  4545. if (!ancestor) {
  4546. bookKeeping.ancestors.push(ancestor);
  4547. break;
  4548. }
  4549. var root = findRootContainerNode(ancestor);
  4550. if (!root) {
  4551. break;
  4552. }
  4553. bookKeeping.ancestors.push(ancestor);
  4554. ancestor = getClosestInstanceFromNode(root);
  4555. } while (ancestor);
  4556. for (var i = 0; i < bookKeeping.ancestors.length; i++) {
  4557. targetInst = bookKeeping.ancestors[i];
  4558. runExtractedEventsInBatch(bookKeeping.topLevelType, targetInst, bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
  4559. }
  4560. }
  4561. // TODO: can we stop exporting these?
  4562. var _enabled = true;
  4563. function setEnabled(enabled) {
  4564. _enabled = !!enabled;
  4565. }
  4566. function isEnabled() {
  4567. return _enabled;
  4568. }
  4569. /**
  4570. * Traps top-level events by using event bubbling.
  4571. *
  4572. * @param {number} topLevelType Number from `TopLevelEventTypes`.
  4573. * @param {object} element Element on which to attach listener.
  4574. * @return {?object} An object with a remove function which will forcefully
  4575. * remove the listener.
  4576. * @internal
  4577. */
  4578. function trapBubbledEvent(topLevelType, element) {
  4579. if (!element) {
  4580. return null;
  4581. }
  4582. var dispatch = isInteractiveTopLevelEventType(topLevelType) ? dispatchInteractiveEvent : dispatchEvent;
  4583. addEventBubbleListener(element, getRawEventName(topLevelType),
  4584. // Check if interactive and wrap in interactiveUpdates
  4585. dispatch.bind(null, topLevelType));
  4586. }
  4587. /**
  4588. * Traps a top-level event by using event capturing.
  4589. *
  4590. * @param {number} topLevelType Number from `TopLevelEventTypes`.
  4591. * @param {object} element Element on which to attach listener.
  4592. * @return {?object} An object with a remove function which will forcefully
  4593. * remove the listener.
  4594. * @internal
  4595. */
  4596. function trapCapturedEvent(topLevelType, element) {
  4597. if (!element) {
  4598. return null;
  4599. }
  4600. var dispatch = isInteractiveTopLevelEventType(topLevelType) ? dispatchInteractiveEvent : dispatchEvent;
  4601. addEventCaptureListener(element, getRawEventName(topLevelType),
  4602. // Check if interactive and wrap in interactiveUpdates
  4603. dispatch.bind(null, topLevelType));
  4604. }
  4605. function dispatchInteractiveEvent(topLevelType, nativeEvent) {
  4606. interactiveUpdates(dispatchEvent, topLevelType, nativeEvent);
  4607. }
  4608. function dispatchEvent(topLevelType, nativeEvent) {
  4609. if (!_enabled) {
  4610. return;
  4611. }
  4612. var nativeEventTarget = getEventTarget(nativeEvent);
  4613. var targetInst = getClosestInstanceFromNode(nativeEventTarget);
  4614. if (targetInst !== null && typeof targetInst.tag === 'number' && !isFiberMounted(targetInst)) {
  4615. // If we get an event (ex: img onload) before committing that
  4616. // component's mount, ignore it for now (that is, treat it as if it was an
  4617. // event on a non-React tree). We might also consider queueing events and
  4618. // dispatching them after the mount.
  4619. targetInst = null;
  4620. }
  4621. var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst);
  4622. try {
  4623. // Event queue being processed in the same cycle allows
  4624. // `preventDefault`.
  4625. batchedUpdates(handleTopLevel, bookKeeping);
  4626. } finally {
  4627. releaseTopLevelCallbackBookKeeping(bookKeeping);
  4628. }
  4629. }
  4630. /**
  4631. * Summary of `ReactBrowserEventEmitter` event handling:
  4632. *
  4633. * - Top-level delegation is used to trap most native browser events. This
  4634. * may only occur in the main thread and is the responsibility of
  4635. * ReactDOMEventListener, which is injected and can therefore support
  4636. * pluggable event sources. This is the only work that occurs in the main
  4637. * thread.
  4638. *
  4639. * - We normalize and de-duplicate events to account for browser quirks. This
  4640. * may be done in the worker thread.
  4641. *
  4642. * - Forward these native events (with the associated top-level type used to
  4643. * trap it) to `EventPluginHub`, which in turn will ask plugins if they want
  4644. * to extract any synthetic events.
  4645. *
  4646. * - The `EventPluginHub` will then process each event by annotating them with
  4647. * "dispatches", a sequence of listeners and IDs that care about that event.
  4648. *
  4649. * - The `EventPluginHub` then dispatches the events.
  4650. *
  4651. * Overview of React and the event system:
  4652. *
  4653. * +------------+ .
  4654. * | DOM | .
  4655. * +------------+ .
  4656. * | .
  4657. * v .
  4658. * +------------+ .
  4659. * | ReactEvent | .
  4660. * | Listener | .
  4661. * +------------+ . +-----------+
  4662. * | . +--------+|SimpleEvent|
  4663. * | . | |Plugin |
  4664. * +-----|------+ . v +-----------+
  4665. * | | | . +--------------+ +------------+
  4666. * | +-----------.--->|EventPluginHub| | Event |
  4667. * | | . | | +-----------+ | Propagators|
  4668. * | ReactEvent | . | | |TapEvent | |------------|
  4669. * | Emitter | . | |<---+|Plugin | |other plugin|
  4670. * | | . | | +-----------+ | utilities |
  4671. * | +-----------.--->| | +------------+
  4672. * | | | . +--------------+
  4673. * +-----|------+ . ^ +-----------+
  4674. * | . | |Enter/Leave|
  4675. * + . +-------+|Plugin |
  4676. * +-------------+ . +-----------+
  4677. * | application | .
  4678. * |-------------| .
  4679. * | | .
  4680. * | | .
  4681. * +-------------+ .
  4682. * .
  4683. * React Core . General Purpose Event Plugin System
  4684. */
  4685. var alreadyListeningTo = {};
  4686. var reactTopListenersCounter = 0;
  4687. /**
  4688. * To ensure no conflicts with other potential React instances on the page
  4689. */
  4690. var topListenersIDKey = '_reactListenersID' + ('' + Math.random()).slice(2);
  4691. function getListeningForDocument(mountAt) {
  4692. // In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty`
  4693. // directly.
  4694. if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) {
  4695. mountAt[topListenersIDKey] = reactTopListenersCounter++;
  4696. alreadyListeningTo[mountAt[topListenersIDKey]] = {};
  4697. }
  4698. return alreadyListeningTo[mountAt[topListenersIDKey]];
  4699. }
  4700. /**
  4701. * We listen for bubbled touch events on the document object.
  4702. *
  4703. * Firefox v8.01 (and possibly others) exhibited strange behavior when
  4704. * mounting `onmousemove` events at some node that was not the document
  4705. * element. The symptoms were that if your mouse is not moving over something
  4706. * contained within that mount point (for example on the background) the
  4707. * top-level listeners for `onmousemove` won't be called. However, if you
  4708. * register the `mousemove` on the document object, then it will of course
  4709. * catch all `mousemove`s. This along with iOS quirks, justifies restricting
  4710. * top-level listeners to the document object only, at least for these
  4711. * movement types of events and possibly all events.
  4712. *
  4713. * @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
  4714. *
  4715. * Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but
  4716. * they bubble to document.
  4717. *
  4718. * @param {string} registrationName Name of listener (e.g. `onClick`).
  4719. * @param {object} mountAt Container where to mount the listener
  4720. */
  4721. function listenTo(registrationName, mountAt) {
  4722. var isListening = getListeningForDocument(mountAt);
  4723. var dependencies = registrationNameDependencies[registrationName];
  4724. for (var i = 0; i < dependencies.length; i++) {
  4725. var dependency = dependencies[i];
  4726. if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) {
  4727. switch (dependency) {
  4728. case TOP_SCROLL:
  4729. trapCapturedEvent(TOP_SCROLL, mountAt);
  4730. break;
  4731. case TOP_FOCUS:
  4732. case TOP_BLUR:
  4733. trapCapturedEvent(TOP_FOCUS, mountAt);
  4734. trapCapturedEvent(TOP_BLUR, mountAt);
  4735. // We set the flag for a single dependency later in this function,
  4736. // but this ensures we mark both as attached rather than just one.
  4737. isListening[TOP_BLUR] = true;
  4738. isListening[TOP_FOCUS] = true;
  4739. break;
  4740. case TOP_CANCEL:
  4741. case TOP_CLOSE:
  4742. if (isEventSupported(getRawEventName(dependency))) {
  4743. trapCapturedEvent(dependency, mountAt);
  4744. }
  4745. break;
  4746. case TOP_INVALID:
  4747. case TOP_SUBMIT:
  4748. case TOP_RESET:
  4749. // We listen to them on the target DOM elements.
  4750. // Some of them bubble so we don't want them to fire twice.
  4751. break;
  4752. default:
  4753. // By default, listen on the top level to all non-media events.
  4754. // Media events don't bubble so adding the listener wouldn't do anything.
  4755. var isMediaEvent = mediaEventTypes.indexOf(dependency) !== -1;
  4756. if (!isMediaEvent) {
  4757. trapBubbledEvent(dependency, mountAt);
  4758. }
  4759. break;
  4760. }
  4761. isListening[dependency] = true;
  4762. }
  4763. }
  4764. }
  4765. function isListeningToAllDependencies(registrationName, mountAt) {
  4766. var isListening = getListeningForDocument(mountAt);
  4767. var dependencies = registrationNameDependencies[registrationName];
  4768. for (var i = 0; i < dependencies.length; i++) {
  4769. var dependency = dependencies[i];
  4770. if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) {
  4771. return false;
  4772. }
  4773. }
  4774. return true;
  4775. }
  4776. function getActiveElement(doc) {
  4777. doc = doc || (typeof document !== 'undefined' ? document : undefined);
  4778. if (typeof doc === 'undefined') {
  4779. return null;
  4780. }
  4781. try {
  4782. return doc.activeElement || doc.body;
  4783. } catch (e) {
  4784. return doc.body;
  4785. }
  4786. }
  4787. /**
  4788. * Given any node return the first leaf node without children.
  4789. *
  4790. * @param {DOMElement|DOMTextNode} node
  4791. * @return {DOMElement|DOMTextNode}
  4792. */
  4793. function getLeafNode(node) {
  4794. while (node && node.firstChild) {
  4795. node = node.firstChild;
  4796. }
  4797. return node;
  4798. }
  4799. /**
  4800. * Get the next sibling within a container. This will walk up the
  4801. * DOM if a node's siblings have been exhausted.
  4802. *
  4803. * @param {DOMElement|DOMTextNode} node
  4804. * @return {?DOMElement|DOMTextNode}
  4805. */
  4806. function getSiblingNode(node) {
  4807. while (node) {
  4808. if (node.nextSibling) {
  4809. return node.nextSibling;
  4810. }
  4811. node = node.parentNode;
  4812. }
  4813. }
  4814. /**
  4815. * Get object describing the nodes which contain characters at offset.
  4816. *
  4817. * @param {DOMElement|DOMTextNode} root
  4818. * @param {number} offset
  4819. * @return {?object}
  4820. */
  4821. function getNodeForCharacterOffset(root, offset) {
  4822. var node = getLeafNode(root);
  4823. var nodeStart = 0;
  4824. var nodeEnd = 0;
  4825. while (node) {
  4826. if (node.nodeType === TEXT_NODE) {
  4827. nodeEnd = nodeStart + node.textContent.length;
  4828. if (nodeStart <= offset && nodeEnd >= offset) {
  4829. return {
  4830. node: node,
  4831. offset: offset - nodeStart
  4832. };
  4833. }
  4834. nodeStart = nodeEnd;
  4835. }
  4836. node = getLeafNode(getSiblingNode(node));
  4837. }
  4838. }
  4839. /**
  4840. * @param {DOMElement} outerNode
  4841. * @return {?object}
  4842. */
  4843. function getOffsets(outerNode) {
  4844. var ownerDocument = outerNode.ownerDocument;
  4845. var win = ownerDocument && ownerDocument.defaultView || window;
  4846. var selection = win.getSelection && win.getSelection();
  4847. if (!selection || selection.rangeCount === 0) {
  4848. return null;
  4849. }
  4850. var anchorNode = selection.anchorNode,
  4851. anchorOffset = selection.anchorOffset,
  4852. focusNode = selection.focusNode,
  4853. focusOffset = selection.focusOffset;
  4854. // In Firefox, anchorNode and focusNode can be "anonymous divs", e.g. the
  4855. // up/down buttons on an <input type="number">. Anonymous divs do not seem to
  4856. // expose properties, triggering a "Permission denied error" if any of its
  4857. // properties are accessed. The only seemingly possible way to avoid erroring
  4858. // is to access a property that typically works for non-anonymous divs and
  4859. // catch any error that may otherwise arise. See
  4860. // https://bugzilla.mozilla.org/show_bug.cgi?id=208427
  4861. try {
  4862. /* eslint-disable no-unused-expressions */
  4863. anchorNode.nodeType;
  4864. focusNode.nodeType;
  4865. /* eslint-enable no-unused-expressions */
  4866. } catch (e) {
  4867. return null;
  4868. }
  4869. return getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset);
  4870. }
  4871. /**
  4872. * Returns {start, end} where `start` is the character/codepoint index of
  4873. * (anchorNode, anchorOffset) within the textContent of `outerNode`, and
  4874. * `end` is the index of (focusNode, focusOffset).
  4875. *
  4876. * Returns null if you pass in garbage input but we should probably just crash.
  4877. *
  4878. * Exported only for testing.
  4879. */
  4880. function getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset) {
  4881. var length = 0;
  4882. var start = -1;
  4883. var end = -1;
  4884. var indexWithinAnchor = 0;
  4885. var indexWithinFocus = 0;
  4886. var node = outerNode;
  4887. var parentNode = null;
  4888. outer: while (true) {
  4889. var next = null;
  4890. while (true) {
  4891. if (node === anchorNode && (anchorOffset === 0 || node.nodeType === TEXT_NODE)) {
  4892. start = length + anchorOffset;
  4893. }
  4894. if (node === focusNode && (focusOffset === 0 || node.nodeType === TEXT_NODE)) {
  4895. end = length + focusOffset;
  4896. }
  4897. if (node.nodeType === TEXT_NODE) {
  4898. length += node.nodeValue.length;
  4899. }
  4900. if ((next = node.firstChild) === null) {
  4901. break;
  4902. }
  4903. // Moving from `node` to its first child `next`.
  4904. parentNode = node;
  4905. node = next;
  4906. }
  4907. while (true) {
  4908. if (node === outerNode) {
  4909. // If `outerNode` has children, this is always the second time visiting
  4910. // it. If it has no children, this is still the first loop, and the only
  4911. // valid selection is anchorNode and focusNode both equal to this node
  4912. // and both offsets 0, in which case we will have handled above.
  4913. break outer;
  4914. }
  4915. if (parentNode === anchorNode && ++indexWithinAnchor === anchorOffset) {
  4916. start = length;
  4917. }
  4918. if (parentNode === focusNode && ++indexWithinFocus === focusOffset) {
  4919. end = length;
  4920. }
  4921. if ((next = node.nextSibling) !== null) {
  4922. break;
  4923. }
  4924. node = parentNode;
  4925. parentNode = node.parentNode;
  4926. }
  4927. // Moving from `node` to its next sibling `next`.
  4928. node = next;
  4929. }
  4930. if (start === -1 || end === -1) {
  4931. // This should never happen. (Would happen if the anchor/focus nodes aren't
  4932. // actually inside the passed-in node.)
  4933. return null;
  4934. }
  4935. return {
  4936. start: start,
  4937. end: end
  4938. };
  4939. }
  4940. /**
  4941. * In modern non-IE browsers, we can support both forward and backward
  4942. * selections.
  4943. *
  4944. * Note: IE10+ supports the Selection object, but it does not support
  4945. * the `extend` method, which means that even in modern IE, it's not possible
  4946. * to programmatically create a backward selection. Thus, for all IE
  4947. * versions, we use the old IE API to create our selections.
  4948. *
  4949. * @param {DOMElement|DOMTextNode} node
  4950. * @param {object} offsets
  4951. */
  4952. function setOffsets(node, offsets) {
  4953. var doc = node.ownerDocument || document;
  4954. var win = doc && doc.defaultView || window;
  4955. // Edge fails with "Object expected" in some scenarios.
  4956. // (For instance: TinyMCE editor used in a list component that supports pasting to add more,
  4957. // fails when pasting 100+ items)
  4958. if (!win.getSelection) {
  4959. return;
  4960. }
  4961. var selection = win.getSelection();
  4962. var length = node.textContent.length;
  4963. var start = Math.min(offsets.start, length);
  4964. var end = offsets.end === undefined ? start : Math.min(offsets.end, length);
  4965. // IE 11 uses modern selection, but doesn't support the extend method.
  4966. // Flip backward selections, so we can set with a single range.
  4967. if (!selection.extend && start > end) {
  4968. var temp = end;
  4969. end = start;
  4970. start = temp;
  4971. }
  4972. var startMarker = getNodeForCharacterOffset(node, start);
  4973. var endMarker = getNodeForCharacterOffset(node, end);
  4974. if (startMarker && endMarker) {
  4975. if (selection.rangeCount === 1 && selection.anchorNode === startMarker.node && selection.anchorOffset === startMarker.offset && selection.focusNode === endMarker.node && selection.focusOffset === endMarker.offset) {
  4976. return;
  4977. }
  4978. var range = doc.createRange();
  4979. range.setStart(startMarker.node, startMarker.offset);
  4980. selection.removeAllRanges();
  4981. if (start > end) {
  4982. selection.addRange(range);
  4983. selection.extend(endMarker.node, endMarker.offset);
  4984. } else {
  4985. range.setEnd(endMarker.node, endMarker.offset);
  4986. selection.addRange(range);
  4987. }
  4988. }
  4989. }
  4990. function isTextNode(node) {
  4991. return node && node.nodeType === TEXT_NODE;
  4992. }
  4993. function containsNode(outerNode, innerNode) {
  4994. if (!outerNode || !innerNode) {
  4995. return false;
  4996. } else if (outerNode === innerNode) {
  4997. return true;
  4998. } else if (isTextNode(outerNode)) {
  4999. return false;
  5000. } else if (isTextNode(innerNode)) {
  5001. return containsNode(outerNode, innerNode.parentNode);
  5002. } else if ('contains' in outerNode) {
  5003. return outerNode.contains(innerNode);
  5004. } else if (outerNode.compareDocumentPosition) {
  5005. return !!(outerNode.compareDocumentPosition(innerNode) & 16);
  5006. } else {
  5007. return false;
  5008. }
  5009. }
  5010. function isInDocument(node) {
  5011. return node && node.ownerDocument && containsNode(node.ownerDocument.documentElement, node);
  5012. }
  5013. function getActiveElementDeep() {
  5014. var win = window;
  5015. var element = getActiveElement();
  5016. while (element instanceof win.HTMLIFrameElement) {
  5017. // Accessing the contentDocument of a HTMLIframeElement can cause the browser
  5018. // to throw, e.g. if it has a cross-origin src attribute
  5019. try {
  5020. win = element.contentDocument.defaultView;
  5021. } catch (e) {
  5022. return element;
  5023. }
  5024. element = getActiveElement(win.document);
  5025. }
  5026. return element;
  5027. }
  5028. /**
  5029. * @ReactInputSelection: React input selection module. Based on Selection.js,
  5030. * but modified to be suitable for react and has a couple of bug fixes (doesn't
  5031. * assume buttons have range selections allowed).
  5032. * Input selection module for React.
  5033. */
  5034. /**
  5035. * @hasSelectionCapabilities: we get the element types that support selection
  5036. * from https://html.spec.whatwg.org/#do-not-apply, looking at `selectionStart`
  5037. * and `selectionEnd` rows.
  5038. */
  5039. function hasSelectionCapabilities(elem) {
  5040. var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
  5041. return nodeName && (nodeName === 'input' && (elem.type === 'text' || elem.type === 'search' || elem.type === 'tel' || elem.type === 'url' || elem.type === 'password') || nodeName === 'textarea' || elem.contentEditable === 'true');
  5042. }
  5043. function getSelectionInformation() {
  5044. var focusedElem = getActiveElementDeep();
  5045. return {
  5046. focusedElem: focusedElem,
  5047. selectionRange: hasSelectionCapabilities(focusedElem) ? getSelection$1(focusedElem) : null
  5048. };
  5049. }
  5050. /**
  5051. * @restoreSelection: If any selection information was potentially lost,
  5052. * restore it. This is useful when performing operations that could remove dom
  5053. * nodes and place them back in, resulting in focus being lost.
  5054. */
  5055. function restoreSelection(priorSelectionInformation) {
  5056. var curFocusedElem = getActiveElementDeep();
  5057. var priorFocusedElem = priorSelectionInformation.focusedElem;
  5058. var priorSelectionRange = priorSelectionInformation.selectionRange;
  5059. if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) {
  5060. if (priorSelectionRange !== null && hasSelectionCapabilities(priorFocusedElem)) {
  5061. setSelection(priorFocusedElem, priorSelectionRange);
  5062. }
  5063. // Focusing a node can change the scroll position, which is undesirable
  5064. var ancestors = [];
  5065. var ancestor = priorFocusedElem;
  5066. while (ancestor = ancestor.parentNode) {
  5067. if (ancestor.nodeType === ELEMENT_NODE) {
  5068. ancestors.push({
  5069. element: ancestor,
  5070. left: ancestor.scrollLeft,
  5071. top: ancestor.scrollTop
  5072. });
  5073. }
  5074. }
  5075. if (typeof priorFocusedElem.focus === 'function') {
  5076. priorFocusedElem.focus();
  5077. }
  5078. for (var i = 0; i < ancestors.length; i++) {
  5079. var info = ancestors[i];
  5080. info.element.scrollLeft = info.left;
  5081. info.element.scrollTop = info.top;
  5082. }
  5083. }
  5084. }
  5085. /**
  5086. * @getSelection: Gets the selection bounds of a focused textarea, input or
  5087. * contentEditable node.
  5088. * -@input: Look up selection bounds of this input
  5089. * -@return {start: selectionStart, end: selectionEnd}
  5090. */
  5091. function getSelection$1(input) {
  5092. var selection = void 0;
  5093. if ('selectionStart' in input) {
  5094. // Modern browser with input or textarea.
  5095. selection = {
  5096. start: input.selectionStart,
  5097. end: input.selectionEnd
  5098. };
  5099. } else {
  5100. // Content editable or old IE textarea.
  5101. selection = getOffsets(input);
  5102. }
  5103. return selection || { start: 0, end: 0 };
  5104. }
  5105. /**
  5106. * @setSelection: Sets the selection bounds of a textarea or input and focuses
  5107. * the input.
  5108. * -@input Set selection bounds of this input or textarea
  5109. * -@offsets Object of same form that is returned from get*
  5110. */
  5111. function setSelection(input, offsets) {
  5112. var start = offsets.start,
  5113. end = offsets.end;
  5114. if (end === undefined) {
  5115. end = start;
  5116. }
  5117. if ('selectionStart' in input) {
  5118. input.selectionStart = start;
  5119. input.selectionEnd = Math.min(end, input.value.length);
  5120. } else {
  5121. setOffsets(input, offsets);
  5122. }
  5123. }
  5124. var skipSelectionChangeEvent = canUseDOM && 'documentMode' in document && document.documentMode <= 11;
  5125. var eventTypes$3 = {
  5126. select: {
  5127. phasedRegistrationNames: {
  5128. bubbled: 'onSelect',
  5129. captured: 'onSelectCapture'
  5130. },
  5131. 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]
  5132. }
  5133. };
  5134. var activeElement$1 = null;
  5135. var activeElementInst$1 = null;
  5136. var lastSelection = null;
  5137. var mouseDown = false;
  5138. /**
  5139. * Get an object which is a unique representation of the current selection.
  5140. *
  5141. * The return value will not be consistent across nodes or browsers, but
  5142. * two identical selections on the same node will return identical objects.
  5143. *
  5144. * @param {DOMElement} node
  5145. * @return {object}
  5146. */
  5147. function getSelection(node) {
  5148. if ('selectionStart' in node && hasSelectionCapabilities(node)) {
  5149. return {
  5150. start: node.selectionStart,
  5151. end: node.selectionEnd
  5152. };
  5153. } else {
  5154. var win = node.ownerDocument && node.ownerDocument.defaultView || window;
  5155. var selection = win.getSelection();
  5156. return {
  5157. anchorNode: selection.anchorNode,
  5158. anchorOffset: selection.anchorOffset,
  5159. focusNode: selection.focusNode,
  5160. focusOffset: selection.focusOffset
  5161. };
  5162. }
  5163. }
  5164. /**
  5165. * Get document associated with the event target.
  5166. *
  5167. * @param {object} nativeEventTarget
  5168. * @return {Document}
  5169. */
  5170. function getEventTargetDocument(eventTarget) {
  5171. return eventTarget.window === eventTarget ? eventTarget.document : eventTarget.nodeType === DOCUMENT_NODE ? eventTarget : eventTarget.ownerDocument;
  5172. }
  5173. /**
  5174. * Poll selection to see whether it's changed.
  5175. *
  5176. * @param {object} nativeEvent
  5177. * @param {object} nativeEventTarget
  5178. * @return {?SyntheticEvent}
  5179. */
  5180. function constructSelectEvent(nativeEvent, nativeEventTarget) {
  5181. // Ensure we have the right element, and that the user is not dragging a
  5182. // selection (this matches native `select` event behavior). In HTML5, select
  5183. // fires only on input and textarea thus if there's no focused element we
  5184. // won't dispatch.
  5185. var doc = getEventTargetDocument(nativeEventTarget);
  5186. if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement(doc)) {
  5187. return null;
  5188. }
  5189. // Only fire when selection has actually changed.
  5190. var currentSelection = getSelection(activeElement$1);
  5191. if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
  5192. lastSelection = currentSelection;
  5193. var syntheticEvent = SyntheticEvent.getPooled(eventTypes$3.select, activeElementInst$1, nativeEvent, nativeEventTarget);
  5194. syntheticEvent.type = 'select';
  5195. syntheticEvent.target = activeElement$1;
  5196. accumulateTwoPhaseDispatches(syntheticEvent);
  5197. return syntheticEvent;
  5198. }
  5199. return null;
  5200. }
  5201. /**
  5202. * This plugin creates an `onSelect` event that normalizes select events
  5203. * across form elements.
  5204. *
  5205. * Supported elements are:
  5206. * - input (see `isTextInputElement`)
  5207. * - textarea
  5208. * - contentEditable
  5209. *
  5210. * This differs from native browser implementations in the following ways:
  5211. * - Fires on contentEditable fields as well as inputs.
  5212. * - Fires for collapsed selection.
  5213. * - Fires after user input.
  5214. */
  5215. var SelectEventPlugin = {
  5216. eventTypes: eventTypes$3,
  5217. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  5218. var doc = getEventTargetDocument(nativeEventTarget);
  5219. // Track whether all listeners exists for this plugin. If none exist, we do
  5220. // not extract events. See #3639.
  5221. if (!doc || !isListeningToAllDependencies('onSelect', doc)) {
  5222. return null;
  5223. }
  5224. var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window;
  5225. switch (topLevelType) {
  5226. // Track the input node that has focus.
  5227. case TOP_FOCUS:
  5228. if (isTextInputElement(targetNode) || targetNode.contentEditable === 'true') {
  5229. activeElement$1 = targetNode;
  5230. activeElementInst$1 = targetInst;
  5231. lastSelection = null;
  5232. }
  5233. break;
  5234. case TOP_BLUR:
  5235. activeElement$1 = null;
  5236. activeElementInst$1 = null;
  5237. lastSelection = null;
  5238. break;
  5239. // Don't fire the event while the user is dragging. This matches the
  5240. // semantics of the native select event.
  5241. case TOP_MOUSE_DOWN:
  5242. mouseDown = true;
  5243. break;
  5244. case TOP_CONTEXT_MENU:
  5245. case TOP_MOUSE_UP:
  5246. case TOP_DRAG_END:
  5247. mouseDown = false;
  5248. return constructSelectEvent(nativeEvent, nativeEventTarget);
  5249. // Chrome and IE fire non-standard event when selection is changed (and
  5250. // sometimes when it hasn't). IE's event fires out of order with respect
  5251. // to key and input events on deletion, so we discard it.
  5252. //
  5253. // Firefox doesn't support selectionchange, so check selection status
  5254. // after each key entry. The selection changes after keydown and before
  5255. // keyup, but we check on keydown as well in the case of holding down a
  5256. // key, when multiple keydown events are fired but only one keyup is.
  5257. // This is also our approach for IE handling, for the reason above.
  5258. case TOP_SELECTION_CHANGE:
  5259. if (skipSelectionChangeEvent) {
  5260. break;
  5261. }
  5262. // falls through
  5263. case TOP_KEY_DOWN:
  5264. case TOP_KEY_UP:
  5265. return constructSelectEvent(nativeEvent, nativeEventTarget);
  5266. }
  5267. return null;
  5268. }
  5269. };
  5270. /**
  5271. * Inject modules for resolving DOM hierarchy and plugin ordering.
  5272. */
  5273. injection.injectEventPluginOrder(DOMEventPluginOrder);
  5274. setComponentTree(getFiberCurrentPropsFromNode$1, getInstanceFromNode$1, getNodeFromInstance$1);
  5275. /**
  5276. * Some important event plugins included by default (without having to require
  5277. * them).
  5278. */
  5279. injection.injectEventPluginsByName({
  5280. SimpleEventPlugin: SimpleEventPlugin,
  5281. EnterLeaveEventPlugin: EnterLeaveEventPlugin,
  5282. ChangeEventPlugin: ChangeEventPlugin,
  5283. SelectEventPlugin: SelectEventPlugin,
  5284. BeforeInputEventPlugin: BeforeInputEventPlugin
  5285. });
  5286. var didWarnSelectedSetOnOption = false;
  5287. var didWarnInvalidChild = false;
  5288. function flattenChildren(children) {
  5289. var content = '';
  5290. // Flatten children. We'll warn if they are invalid
  5291. // during validateProps() which runs for hydration too.
  5292. // Note that this would throw on non-element objects.
  5293. // Elements are stringified (which is normally irrelevant
  5294. // but matters for <fbt>).
  5295. React.Children.forEach(children, function (child) {
  5296. if (child == null) {
  5297. return;
  5298. }
  5299. content += child;
  5300. // Note: we don't warn about invalid children here.
  5301. // Instead, this is done separately below so that
  5302. // it happens during the hydration codepath too.
  5303. });
  5304. return content;
  5305. }
  5306. /**
  5307. * Implements an <option> host component that warns when `selected` is set.
  5308. */
  5309. function validateProps(element, props) {
  5310. {
  5311. // This mirrors the codepath above, but runs for hydration too.
  5312. // Warn about invalid children here so that client and hydration are consistent.
  5313. // TODO: this seems like it could cause a DEV-only throw for hydration
  5314. // if children contains a non-element object. We should try to avoid that.
  5315. if (typeof props.children === 'object' && props.children !== null) {
  5316. React.Children.forEach(props.children, function (child) {
  5317. if (child == null) {
  5318. return;
  5319. }
  5320. if (typeof child === 'string' || typeof child === 'number') {
  5321. return;
  5322. }
  5323. if (typeof child.type !== 'string') {
  5324. return;
  5325. }
  5326. if (!didWarnInvalidChild) {
  5327. didWarnInvalidChild = true;
  5328. warning$1(false, 'Only strings and numbers are supported as <option> children.');
  5329. }
  5330. });
  5331. }
  5332. // TODO: Remove support for `selected` in <option>.
  5333. if (props.selected != null && !didWarnSelectedSetOnOption) {
  5334. warning$1(false, 'Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.');
  5335. didWarnSelectedSetOnOption = true;
  5336. }
  5337. }
  5338. }
  5339. function postMountWrapper$1(element, props) {
  5340. // value="" should make a value attribute (#6219)
  5341. if (props.value != null) {
  5342. element.setAttribute('value', toString(getToStringValue(props.value)));
  5343. }
  5344. }
  5345. function getHostProps$1(element, props) {
  5346. var hostProps = _assign({ children: undefined }, props);
  5347. var content = flattenChildren(props.children);
  5348. if (content) {
  5349. hostProps.children = content;
  5350. }
  5351. return hostProps;
  5352. }
  5353. // TODO: direct imports like some-package/src/* are bad. Fix me.
  5354. var didWarnValueDefaultValue$1 = void 0;
  5355. {
  5356. didWarnValueDefaultValue$1 = false;
  5357. }
  5358. function getDeclarationErrorAddendum() {
  5359. var ownerName = getCurrentFiberOwnerNameInDevOrNull();
  5360. if (ownerName) {
  5361. return '\n\nCheck the render method of `' + ownerName + '`.';
  5362. }
  5363. return '';
  5364. }
  5365. var valuePropNames = ['value', 'defaultValue'];
  5366. /**
  5367. * Validation function for `value` and `defaultValue`.
  5368. */
  5369. function checkSelectPropTypes(props) {
  5370. ReactControlledValuePropTypes.checkPropTypes('select', props);
  5371. for (var i = 0; i < valuePropNames.length; i++) {
  5372. var propName = valuePropNames[i];
  5373. if (props[propName] == null) {
  5374. continue;
  5375. }
  5376. var isArray = Array.isArray(props[propName]);
  5377. if (props.multiple && !isArray) {
  5378. warning$1(false, 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum());
  5379. } else if (!props.multiple && isArray) {
  5380. warning$1(false, 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum());
  5381. }
  5382. }
  5383. }
  5384. function updateOptions(node, multiple, propValue, setDefaultSelected) {
  5385. var options = node.options;
  5386. if (multiple) {
  5387. var selectedValues = propValue;
  5388. var selectedValue = {};
  5389. for (var i = 0; i < selectedValues.length; i++) {
  5390. // Prefix to avoid chaos with special keys.
  5391. selectedValue['$' + selectedValues[i]] = true;
  5392. }
  5393. for (var _i = 0; _i < options.length; _i++) {
  5394. var selected = selectedValue.hasOwnProperty('$' + options[_i].value);
  5395. if (options[_i].selected !== selected) {
  5396. options[_i].selected = selected;
  5397. }
  5398. if (selected && setDefaultSelected) {
  5399. options[_i].defaultSelected = true;
  5400. }
  5401. }
  5402. } else {
  5403. // Do not set `select.value` as exact behavior isn't consistent across all
  5404. // browsers for all cases.
  5405. var _selectedValue = toString(getToStringValue(propValue));
  5406. var defaultSelected = null;
  5407. for (var _i2 = 0; _i2 < options.length; _i2++) {
  5408. if (options[_i2].value === _selectedValue) {
  5409. options[_i2].selected = true;
  5410. if (setDefaultSelected) {
  5411. options[_i2].defaultSelected = true;
  5412. }
  5413. return;
  5414. }
  5415. if (defaultSelected === null && !options[_i2].disabled) {
  5416. defaultSelected = options[_i2];
  5417. }
  5418. }
  5419. if (defaultSelected !== null) {
  5420. defaultSelected.selected = true;
  5421. }
  5422. }
  5423. }
  5424. /**
  5425. * Implements a <select> host component that allows optionally setting the
  5426. * props `value` and `defaultValue`. If `multiple` is false, the prop must be a
  5427. * stringable. If `multiple` is true, the prop must be an array of stringables.
  5428. *
  5429. * If `value` is not supplied (or null/undefined), user actions that change the
  5430. * selected option will trigger updates to the rendered options.
  5431. *
  5432. * If it is supplied (and not null/undefined), the rendered options will not
  5433. * update in response to user actions. Instead, the `value` prop must change in
  5434. * order for the rendered options to update.
  5435. *
  5436. * If `defaultValue` is provided, any options with the supplied values will be
  5437. * selected.
  5438. */
  5439. function getHostProps$2(element, props) {
  5440. return _assign({}, props, {
  5441. value: undefined
  5442. });
  5443. }
  5444. function initWrapperState$1(element, props) {
  5445. var node = element;
  5446. {
  5447. checkSelectPropTypes(props);
  5448. }
  5449. node._wrapperState = {
  5450. wasMultiple: !!props.multiple
  5451. };
  5452. {
  5453. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue$1) {
  5454. 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');
  5455. didWarnValueDefaultValue$1 = true;
  5456. }
  5457. }
  5458. }
  5459. function postMountWrapper$2(element, props) {
  5460. var node = element;
  5461. node.multiple = !!props.multiple;
  5462. var value = props.value;
  5463. if (value != null) {
  5464. updateOptions(node, !!props.multiple, value, false);
  5465. } else if (props.defaultValue != null) {
  5466. updateOptions(node, !!props.multiple, props.defaultValue, true);
  5467. }
  5468. }
  5469. function postUpdateWrapper(element, props) {
  5470. var node = element;
  5471. var wasMultiple = node._wrapperState.wasMultiple;
  5472. node._wrapperState.wasMultiple = !!props.multiple;
  5473. var value = props.value;
  5474. if (value != null) {
  5475. updateOptions(node, !!props.multiple, value, false);
  5476. } else if (wasMultiple !== !!props.multiple) {
  5477. // For simplicity, reapply `defaultValue` if `multiple` is toggled.
  5478. if (props.defaultValue != null) {
  5479. updateOptions(node, !!props.multiple, props.defaultValue, true);
  5480. } else {
  5481. // Revert the select back to its default unselected state.
  5482. updateOptions(node, !!props.multiple, props.multiple ? [] : '', false);
  5483. }
  5484. }
  5485. }
  5486. function restoreControlledState$2(element, props) {
  5487. var node = element;
  5488. var value = props.value;
  5489. if (value != null) {
  5490. updateOptions(node, !!props.multiple, value, false);
  5491. }
  5492. }
  5493. var didWarnValDefaultVal = false;
  5494. /**
  5495. * Implements a <textarea> host component that allows setting `value`, and
  5496. * `defaultValue`. This differs from the traditional DOM API because value is
  5497. * usually set as PCDATA children.
  5498. *
  5499. * If `value` is not supplied (or null/undefined), user actions that affect the
  5500. * value will trigger updates to the element.
  5501. *
  5502. * If `value` is supplied (and not null/undefined), the rendered element will
  5503. * not trigger updates to the element. Instead, the `value` prop must change in
  5504. * order for the rendered element to be updated.
  5505. *
  5506. * The rendered element will be initialized with an empty value, the prop
  5507. * `defaultValue` if specified, or the children content (deprecated).
  5508. */
  5509. function getHostProps$3(element, props) {
  5510. var node = element;
  5511. !(props.dangerouslySetInnerHTML == null) ? invariant(false, '`dangerouslySetInnerHTML` does not make sense on <textarea>.') : void 0;
  5512. // Always set children to the same thing. In IE9, the selection range will
  5513. // get reset if `textContent` is mutated. We could add a check in setTextContent
  5514. // to only set the value if/when the value differs from the node value (which would
  5515. // completely solve this IE9 bug), but Sebastian+Sophie seemed to like this
  5516. // solution. The value can be a boolean or object so that's why it's forced
  5517. // to be a string.
  5518. var hostProps = _assign({}, props, {
  5519. value: undefined,
  5520. defaultValue: undefined,
  5521. children: toString(node._wrapperState.initialValue)
  5522. });
  5523. return hostProps;
  5524. }
  5525. function initWrapperState$2(element, props) {
  5526. var node = element;
  5527. {
  5528. ReactControlledValuePropTypes.checkPropTypes('textarea', props);
  5529. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) {
  5530. 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');
  5531. didWarnValDefaultVal = true;
  5532. }
  5533. }
  5534. var initialValue = props.value;
  5535. // Only bother fetching default value if we're going to use it
  5536. if (initialValue == null) {
  5537. var defaultValue = props.defaultValue;
  5538. // TODO (yungsters): Remove support for children content in <textarea>.
  5539. var children = props.children;
  5540. if (children != null) {
  5541. {
  5542. warning$1(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.');
  5543. }
  5544. !(defaultValue == null) ? invariant(false, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : void 0;
  5545. if (Array.isArray(children)) {
  5546. !(children.length <= 1) ? invariant(false, '<textarea> can only have at most one child.') : void 0;
  5547. children = children[0];
  5548. }
  5549. defaultValue = children;
  5550. }
  5551. if (defaultValue == null) {
  5552. defaultValue = '';
  5553. }
  5554. initialValue = defaultValue;
  5555. }
  5556. node._wrapperState = {
  5557. initialValue: getToStringValue(initialValue)
  5558. };
  5559. }
  5560. function updateWrapper$1(element, props) {
  5561. var node = element;
  5562. var value = getToStringValue(props.value);
  5563. var defaultValue = getToStringValue(props.defaultValue);
  5564. if (value != null) {
  5565. // Cast `value` to a string to ensure the value is set correctly. While
  5566. // browsers typically do this as necessary, jsdom doesn't.
  5567. var newValue = toString(value);
  5568. // To avoid side effects (such as losing text selection), only set value if changed
  5569. if (newValue !== node.value) {
  5570. node.value = newValue;
  5571. }
  5572. if (props.defaultValue == null && node.defaultValue !== newValue) {
  5573. node.defaultValue = newValue;
  5574. }
  5575. }
  5576. if (defaultValue != null) {
  5577. node.defaultValue = toString(defaultValue);
  5578. }
  5579. }
  5580. function postMountWrapper$3(element, props) {
  5581. var node = element;
  5582. // This is in postMount because we need access to the DOM node, which is not
  5583. // available until after the component has mounted.
  5584. var textContent = node.textContent;
  5585. // Only set node.value if textContent is equal to the expected
  5586. // initial value. In IE10/IE11 there is a bug where the placeholder attribute
  5587. // will populate textContent as well.
  5588. // https://developer.microsoft.com/microsoft-edge/platform/issues/101525/
  5589. if (textContent === node._wrapperState.initialValue) {
  5590. node.value = textContent;
  5591. }
  5592. }
  5593. function restoreControlledState$3(element, props) {
  5594. // DOM component is still mounted; update
  5595. updateWrapper$1(element, props);
  5596. }
  5597. var HTML_NAMESPACE$1 = 'http://www.w3.org/1999/xhtml';
  5598. var MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
  5599. var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
  5600. var Namespaces = {
  5601. html: HTML_NAMESPACE$1,
  5602. mathml: MATH_NAMESPACE,
  5603. svg: SVG_NAMESPACE
  5604. };
  5605. // Assumes there is no parent namespace.
  5606. function getIntrinsicNamespace(type) {
  5607. switch (type) {
  5608. case 'svg':
  5609. return SVG_NAMESPACE;
  5610. case 'math':
  5611. return MATH_NAMESPACE;
  5612. default:
  5613. return HTML_NAMESPACE$1;
  5614. }
  5615. }
  5616. function getChildNamespace(parentNamespace, type) {
  5617. if (parentNamespace == null || parentNamespace === HTML_NAMESPACE$1) {
  5618. // No (or default) parent namespace: potential entry point.
  5619. return getIntrinsicNamespace(type);
  5620. }
  5621. if (parentNamespace === SVG_NAMESPACE && type === 'foreignObject') {
  5622. // We're leaving SVG.
  5623. return HTML_NAMESPACE$1;
  5624. }
  5625. // By default, pass namespace below.
  5626. return parentNamespace;
  5627. }
  5628. /* globals MSApp */
  5629. /**
  5630. * Create a function which has 'unsafe' privileges (required by windows8 apps)
  5631. */
  5632. var createMicrosoftUnsafeLocalFunction = function (func) {
  5633. if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
  5634. return function (arg0, arg1, arg2, arg3) {
  5635. MSApp.execUnsafeLocalFunction(function () {
  5636. return func(arg0, arg1, arg2, arg3);
  5637. });
  5638. };
  5639. } else {
  5640. return func;
  5641. }
  5642. };
  5643. // SVG temp container for IE lacking innerHTML
  5644. var reusableSVGContainer = void 0;
  5645. /**
  5646. * Set the innerHTML property of a node
  5647. *
  5648. * @param {DOMElement} node
  5649. * @param {string} html
  5650. * @internal
  5651. */
  5652. var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) {
  5653. // IE does not have innerHTML for SVG nodes, so instead we inject the
  5654. // new markup in a temp node and then move the child nodes across into
  5655. // the target node
  5656. if (node.namespaceURI === Namespaces.svg && !('innerHTML' in node)) {
  5657. reusableSVGContainer = reusableSVGContainer || document.createElement('div');
  5658. reusableSVGContainer.innerHTML = '<svg>' + html + '</svg>';
  5659. var svgNode = reusableSVGContainer.firstChild;
  5660. while (node.firstChild) {
  5661. node.removeChild(node.firstChild);
  5662. }
  5663. while (svgNode.firstChild) {
  5664. node.appendChild(svgNode.firstChild);
  5665. }
  5666. } else {
  5667. node.innerHTML = html;
  5668. }
  5669. });
  5670. /**
  5671. * Set the textContent property of a node. For text updates, it's faster
  5672. * to set the `nodeValue` of the Text node directly instead of using
  5673. * `.textContent` which will remove the existing node and create a new one.
  5674. *
  5675. * @param {DOMElement} node
  5676. * @param {string} text
  5677. * @internal
  5678. */
  5679. var setTextContent = function (node, text) {
  5680. if (text) {
  5681. var firstChild = node.firstChild;
  5682. if (firstChild && firstChild === node.lastChild && firstChild.nodeType === TEXT_NODE) {
  5683. firstChild.nodeValue = text;
  5684. return;
  5685. }
  5686. }
  5687. node.textContent = text;
  5688. };
  5689. /**
  5690. * CSS properties which accept numbers but are not in units of "px".
  5691. */
  5692. var isUnitlessNumber = {
  5693. animationIterationCount: true,
  5694. borderImageOutset: true,
  5695. borderImageSlice: true,
  5696. borderImageWidth: true,
  5697. boxFlex: true,
  5698. boxFlexGroup: true,
  5699. boxOrdinalGroup: true,
  5700. columnCount: true,
  5701. columns: true,
  5702. flex: true,
  5703. flexGrow: true,
  5704. flexPositive: true,
  5705. flexShrink: true,
  5706. flexNegative: true,
  5707. flexOrder: true,
  5708. gridArea: true,
  5709. gridRow: true,
  5710. gridRowEnd: true,
  5711. gridRowSpan: true,
  5712. gridRowStart: true,
  5713. gridColumn: true,
  5714. gridColumnEnd: true,
  5715. gridColumnSpan: true,
  5716. gridColumnStart: true,
  5717. fontWeight: true,
  5718. lineClamp: true,
  5719. lineHeight: true,
  5720. opacity: true,
  5721. order: true,
  5722. orphans: true,
  5723. tabSize: true,
  5724. widows: true,
  5725. zIndex: true,
  5726. zoom: true,
  5727. // SVG-related properties
  5728. fillOpacity: true,
  5729. floodOpacity: true,
  5730. stopOpacity: true,
  5731. strokeDasharray: true,
  5732. strokeDashoffset: true,
  5733. strokeMiterlimit: true,
  5734. strokeOpacity: true,
  5735. strokeWidth: true
  5736. };
  5737. /**
  5738. * @param {string} prefix vendor-specific prefix, eg: Webkit
  5739. * @param {string} key style name, eg: transitionDuration
  5740. * @return {string} style name prefixed with `prefix`, properly camelCased, eg:
  5741. * WebkitTransitionDuration
  5742. */
  5743. function prefixKey(prefix, key) {
  5744. return prefix + key.charAt(0).toUpperCase() + key.substring(1);
  5745. }
  5746. /**
  5747. * Support style names that may come passed in prefixed by adding permutations
  5748. * of vendor prefixes.
  5749. */
  5750. var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
  5751. // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
  5752. // infinite loop, because it iterates over the newly added props too.
  5753. Object.keys(isUnitlessNumber).forEach(function (prop) {
  5754. prefixes.forEach(function (prefix) {
  5755. isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
  5756. });
  5757. });
  5758. /**
  5759. * Convert a value into the proper css writable value. The style name `name`
  5760. * should be logical (no hyphens), as specified
  5761. * in `CSSProperty.isUnitlessNumber`.
  5762. *
  5763. * @param {string} name CSS property name such as `topMargin`.
  5764. * @param {*} value CSS property value such as `10px`.
  5765. * @return {string} Normalized style value with dimensions applied.
  5766. */
  5767. function dangerousStyleValue(name, value, isCustomProperty) {
  5768. // Note that we've removed escapeTextForBrowser() calls here since the
  5769. // whole string will be escaped when the attribute is injected into
  5770. // the markup. If you provide unsafe user data here they can inject
  5771. // arbitrary CSS which may be problematic (I couldn't repro this):
  5772. // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
  5773. // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
  5774. // This is not an XSS hole but instead a potential CSS injection issue
  5775. // which has lead to a greater discussion about how we're going to
  5776. // trust URLs moving forward. See #2115901
  5777. var isEmpty = value == null || typeof value === 'boolean' || value === '';
  5778. if (isEmpty) {
  5779. return '';
  5780. }
  5781. if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) {
  5782. return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers
  5783. }
  5784. return ('' + value).trim();
  5785. }
  5786. var uppercasePattern = /([A-Z])/g;
  5787. var msPattern = /^ms-/;
  5788. /**
  5789. * Hyphenates a camelcased CSS property name, for example:
  5790. *
  5791. * > hyphenateStyleName('backgroundColor')
  5792. * < "background-color"
  5793. * > hyphenateStyleName('MozTransition')
  5794. * < "-moz-transition"
  5795. * > hyphenateStyleName('msTransition')
  5796. * < "-ms-transition"
  5797. *
  5798. * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
  5799. * is converted to `-ms-`.
  5800. */
  5801. function hyphenateStyleName(name) {
  5802. return name.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern, '-ms-');
  5803. }
  5804. var warnValidStyle = function () {};
  5805. {
  5806. // 'msTransform' is correct, but the other prefixes should be capitalized
  5807. var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
  5808. var msPattern$1 = /^-ms-/;
  5809. var hyphenPattern = /-(.)/g;
  5810. // style values shouldn't contain a semicolon
  5811. var badStyleValueWithSemicolonPattern = /;\s*$/;
  5812. var warnedStyleNames = {};
  5813. var warnedStyleValues = {};
  5814. var warnedForNaNValue = false;
  5815. var warnedForInfinityValue = false;
  5816. var camelize = function (string) {
  5817. return string.replace(hyphenPattern, function (_, character) {
  5818. return character.toUpperCase();
  5819. });
  5820. };
  5821. var warnHyphenatedStyleName = function (name) {
  5822. if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
  5823. return;
  5824. }
  5825. warnedStyleNames[name] = true;
  5826. warning$1(false, 'Unsupported style property %s. Did you mean %s?', name,
  5827. // As Andi Smith suggests
  5828. // (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
  5829. // is converted to lowercase `ms`.
  5830. camelize(name.replace(msPattern$1, 'ms-')));
  5831. };
  5832. var warnBadVendoredStyleName = function (name) {
  5833. if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
  5834. return;
  5835. }
  5836. warnedStyleNames[name] = true;
  5837. warning$1(false, 'Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1));
  5838. };
  5839. var warnStyleValueWithSemicolon = function (name, value) {
  5840. if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
  5841. return;
  5842. }
  5843. warnedStyleValues[value] = true;
  5844. warning$1(false, "Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, ''));
  5845. };
  5846. var warnStyleValueIsNaN = function (name, value) {
  5847. if (warnedForNaNValue) {
  5848. return;
  5849. }
  5850. warnedForNaNValue = true;
  5851. warning$1(false, '`NaN` is an invalid value for the `%s` css style property.', name);
  5852. };
  5853. var warnStyleValueIsInfinity = function (name, value) {
  5854. if (warnedForInfinityValue) {
  5855. return;
  5856. }
  5857. warnedForInfinityValue = true;
  5858. warning$1(false, '`Infinity` is an invalid value for the `%s` css style property.', name);
  5859. };
  5860. warnValidStyle = function (name, value) {
  5861. if (name.indexOf('-') > -1) {
  5862. warnHyphenatedStyleName(name);
  5863. } else if (badVendoredStyleNamePattern.test(name)) {
  5864. warnBadVendoredStyleName(name);
  5865. } else if (badStyleValueWithSemicolonPattern.test(value)) {
  5866. warnStyleValueWithSemicolon(name, value);
  5867. }
  5868. if (typeof value === 'number') {
  5869. if (isNaN(value)) {
  5870. warnStyleValueIsNaN(name, value);
  5871. } else if (!isFinite(value)) {
  5872. warnStyleValueIsInfinity(name, value);
  5873. }
  5874. }
  5875. };
  5876. }
  5877. var warnValidStyle$1 = warnValidStyle;
  5878. /**
  5879. * Operations for dealing with CSS properties.
  5880. */
  5881. /**
  5882. * This creates a string that is expected to be equivalent to the style
  5883. * attribute generated by server-side rendering. It by-passes warnings and
  5884. * security checks so it's not safe to use this value for anything other than
  5885. * comparison. It is only used in DEV for SSR validation.
  5886. */
  5887. function createDangerousStringForStyles(styles) {
  5888. {
  5889. var serialized = '';
  5890. var delimiter = '';
  5891. for (var styleName in styles) {
  5892. if (!styles.hasOwnProperty(styleName)) {
  5893. continue;
  5894. }
  5895. var styleValue = styles[styleName];
  5896. if (styleValue != null) {
  5897. var isCustomProperty = styleName.indexOf('--') === 0;
  5898. serialized += delimiter + hyphenateStyleName(styleName) + ':';
  5899. serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty);
  5900. delimiter = ';';
  5901. }
  5902. }
  5903. return serialized || null;
  5904. }
  5905. }
  5906. /**
  5907. * Sets the value for multiple styles on a node. If a value is specified as
  5908. * '' (empty string), the corresponding style property will be unset.
  5909. *
  5910. * @param {DOMElement} node
  5911. * @param {object} styles
  5912. */
  5913. function setValueForStyles(node, styles) {
  5914. var style = node.style;
  5915. for (var styleName in styles) {
  5916. if (!styles.hasOwnProperty(styleName)) {
  5917. continue;
  5918. }
  5919. var isCustomProperty = styleName.indexOf('--') === 0;
  5920. {
  5921. if (!isCustomProperty) {
  5922. warnValidStyle$1(styleName, styles[styleName]);
  5923. }
  5924. }
  5925. var styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty);
  5926. if (styleName === 'float') {
  5927. styleName = 'cssFloat';
  5928. }
  5929. if (isCustomProperty) {
  5930. style.setProperty(styleName, styleValue);
  5931. } else {
  5932. style[styleName] = styleValue;
  5933. }
  5934. }
  5935. }
  5936. // For HTML, certain tags should omit their close tag. We keep a whitelist for
  5937. // those special-case tags.
  5938. var omittedCloseTags = {
  5939. area: true,
  5940. base: true,
  5941. br: true,
  5942. col: true,
  5943. embed: true,
  5944. hr: true,
  5945. img: true,
  5946. input: true,
  5947. keygen: true,
  5948. link: true,
  5949. meta: true,
  5950. param: true,
  5951. source: true,
  5952. track: true,
  5953. wbr: true
  5954. // NOTE: menuitem's close tag should be omitted, but that causes problems.
  5955. };
  5956. // For HTML, certain tags cannot have children. This has the same purpose as
  5957. // `omittedCloseTags` except that `menuitem` should still have its closing tag.
  5958. var voidElementTags = _assign({
  5959. menuitem: true
  5960. }, omittedCloseTags);
  5961. // TODO: We can remove this if we add invariantWithStack()
  5962. // or add stack by default to invariants where possible.
  5963. var HTML$1 = '__html';
  5964. var ReactDebugCurrentFrame$2 = null;
  5965. {
  5966. ReactDebugCurrentFrame$2 = ReactSharedInternals.ReactDebugCurrentFrame;
  5967. }
  5968. function assertValidProps(tag, props) {
  5969. if (!props) {
  5970. return;
  5971. }
  5972. // Note the use of `==` which checks for null or undefined.
  5973. if (voidElementTags[tag]) {
  5974. !(props.children == null && props.dangerouslySetInnerHTML == null) ? invariant(false, '%s is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`.%s', tag, ReactDebugCurrentFrame$2.getStackAddendum()) : void 0;
  5975. }
  5976. if (props.dangerouslySetInnerHTML != null) {
  5977. !(props.children == null) ? invariant(false, 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.') : void 0;
  5978. !(typeof props.dangerouslySetInnerHTML === 'object' && HTML$1 in props.dangerouslySetInnerHTML) ? invariant(false, '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://fb.me/react-invariant-dangerously-set-inner-html for more information.') : void 0;
  5979. }
  5980. {
  5981. !(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;
  5982. }
  5983. !(props.style == null || typeof props.style === 'object') ? invariant(false, 'The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + \'em\'}} when using JSX.%s', ReactDebugCurrentFrame$2.getStackAddendum()) : void 0;
  5984. }
  5985. function isCustomComponent(tagName, props) {
  5986. if (tagName.indexOf('-') === -1) {
  5987. return typeof props.is === 'string';
  5988. }
  5989. switch (tagName) {
  5990. // These are reserved SVG and MathML elements.
  5991. // We don't mind this whitelist too much because we expect it to never grow.
  5992. // The alternative is to track the namespace in a few places which is convoluted.
  5993. // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
  5994. case 'annotation-xml':
  5995. case 'color-profile':
  5996. case 'font-face':
  5997. case 'font-face-src':
  5998. case 'font-face-uri':
  5999. case 'font-face-format':
  6000. case 'font-face-name':
  6001. case 'missing-glyph':
  6002. return false;
  6003. default:
  6004. return true;
  6005. }
  6006. }
  6007. // When adding attributes to the HTML or SVG whitelist, be sure to
  6008. // also add them to this module to ensure casing and incorrect name
  6009. // warnings.
  6010. var possibleStandardNames = {
  6011. // HTML
  6012. accept: 'accept',
  6013. acceptcharset: 'acceptCharset',
  6014. 'accept-charset': 'acceptCharset',
  6015. accesskey: 'accessKey',
  6016. action: 'action',
  6017. allowfullscreen: 'allowFullScreen',
  6018. alt: 'alt',
  6019. as: 'as',
  6020. async: 'async',
  6021. autocapitalize: 'autoCapitalize',
  6022. autocomplete: 'autoComplete',
  6023. autocorrect: 'autoCorrect',
  6024. autofocus: 'autoFocus',
  6025. autoplay: 'autoPlay',
  6026. autosave: 'autoSave',
  6027. capture: 'capture',
  6028. cellpadding: 'cellPadding',
  6029. cellspacing: 'cellSpacing',
  6030. challenge: 'challenge',
  6031. charset: 'charSet',
  6032. checked: 'checked',
  6033. children: 'children',
  6034. cite: 'cite',
  6035. class: 'className',
  6036. classid: 'classID',
  6037. classname: 'className',
  6038. cols: 'cols',
  6039. colspan: 'colSpan',
  6040. content: 'content',
  6041. contenteditable: 'contentEditable',
  6042. contextmenu: 'contextMenu',
  6043. controls: 'controls',
  6044. controlslist: 'controlsList',
  6045. coords: 'coords',
  6046. crossorigin: 'crossOrigin',
  6047. dangerouslysetinnerhtml: 'dangerouslySetInnerHTML',
  6048. data: 'data',
  6049. datetime: 'dateTime',
  6050. default: 'default',
  6051. defaultchecked: 'defaultChecked',
  6052. defaultvalue: 'defaultValue',
  6053. defer: 'defer',
  6054. dir: 'dir',
  6055. disabled: 'disabled',
  6056. download: 'download',
  6057. draggable: 'draggable',
  6058. enctype: 'encType',
  6059. for: 'htmlFor',
  6060. form: 'form',
  6061. formmethod: 'formMethod',
  6062. formaction: 'formAction',
  6063. formenctype: 'formEncType',
  6064. formnovalidate: 'formNoValidate',
  6065. formtarget: 'formTarget',
  6066. frameborder: 'frameBorder',
  6067. headers: 'headers',
  6068. height: 'height',
  6069. hidden: 'hidden',
  6070. high: 'high',
  6071. href: 'href',
  6072. hreflang: 'hrefLang',
  6073. htmlfor: 'htmlFor',
  6074. httpequiv: 'httpEquiv',
  6075. 'http-equiv': 'httpEquiv',
  6076. icon: 'icon',
  6077. id: 'id',
  6078. innerhtml: 'innerHTML',
  6079. inputmode: 'inputMode',
  6080. integrity: 'integrity',
  6081. is: 'is',
  6082. itemid: 'itemID',
  6083. itemprop: 'itemProp',
  6084. itemref: 'itemRef',
  6085. itemscope: 'itemScope',
  6086. itemtype: 'itemType',
  6087. keyparams: 'keyParams',
  6088. keytype: 'keyType',
  6089. kind: 'kind',
  6090. label: 'label',
  6091. lang: 'lang',
  6092. list: 'list',
  6093. loop: 'loop',
  6094. low: 'low',
  6095. manifest: 'manifest',
  6096. marginwidth: 'marginWidth',
  6097. marginheight: 'marginHeight',
  6098. max: 'max',
  6099. maxlength: 'maxLength',
  6100. media: 'media',
  6101. mediagroup: 'mediaGroup',
  6102. method: 'method',
  6103. min: 'min',
  6104. minlength: 'minLength',
  6105. multiple: 'multiple',
  6106. muted: 'muted',
  6107. name: 'name',
  6108. nomodule: 'noModule',
  6109. nonce: 'nonce',
  6110. novalidate: 'noValidate',
  6111. open: 'open',
  6112. optimum: 'optimum',
  6113. pattern: 'pattern',
  6114. placeholder: 'placeholder',
  6115. playsinline: 'playsInline',
  6116. poster: 'poster',
  6117. preload: 'preload',
  6118. profile: 'profile',
  6119. radiogroup: 'radioGroup',
  6120. readonly: 'readOnly',
  6121. referrerpolicy: 'referrerPolicy',
  6122. rel: 'rel',
  6123. required: 'required',
  6124. reversed: 'reversed',
  6125. role: 'role',
  6126. rows: 'rows',
  6127. rowspan: 'rowSpan',
  6128. sandbox: 'sandbox',
  6129. scope: 'scope',
  6130. scoped: 'scoped',
  6131. scrolling: 'scrolling',
  6132. seamless: 'seamless',
  6133. selected: 'selected',
  6134. shape: 'shape',
  6135. size: 'size',
  6136. sizes: 'sizes',
  6137. span: 'span',
  6138. spellcheck: 'spellCheck',
  6139. src: 'src',
  6140. srcdoc: 'srcDoc',
  6141. srclang: 'srcLang',
  6142. srcset: 'srcSet',
  6143. start: 'start',
  6144. step: 'step',
  6145. style: 'style',
  6146. summary: 'summary',
  6147. tabindex: 'tabIndex',
  6148. target: 'target',
  6149. title: 'title',
  6150. type: 'type',
  6151. usemap: 'useMap',
  6152. value: 'value',
  6153. width: 'width',
  6154. wmode: 'wmode',
  6155. wrap: 'wrap',
  6156. // SVG
  6157. about: 'about',
  6158. accentheight: 'accentHeight',
  6159. 'accent-height': 'accentHeight',
  6160. accumulate: 'accumulate',
  6161. additive: 'additive',
  6162. alignmentbaseline: 'alignmentBaseline',
  6163. 'alignment-baseline': 'alignmentBaseline',
  6164. allowreorder: 'allowReorder',
  6165. alphabetic: 'alphabetic',
  6166. amplitude: 'amplitude',
  6167. arabicform: 'arabicForm',
  6168. 'arabic-form': 'arabicForm',
  6169. ascent: 'ascent',
  6170. attributename: 'attributeName',
  6171. attributetype: 'attributeType',
  6172. autoreverse: 'autoReverse',
  6173. azimuth: 'azimuth',
  6174. basefrequency: 'baseFrequency',
  6175. baselineshift: 'baselineShift',
  6176. 'baseline-shift': 'baselineShift',
  6177. baseprofile: 'baseProfile',
  6178. bbox: 'bbox',
  6179. begin: 'begin',
  6180. bias: 'bias',
  6181. by: 'by',
  6182. calcmode: 'calcMode',
  6183. capheight: 'capHeight',
  6184. 'cap-height': 'capHeight',
  6185. clip: 'clip',
  6186. clippath: 'clipPath',
  6187. 'clip-path': 'clipPath',
  6188. clippathunits: 'clipPathUnits',
  6189. cliprule: 'clipRule',
  6190. 'clip-rule': 'clipRule',
  6191. color: 'color',
  6192. colorinterpolation: 'colorInterpolation',
  6193. 'color-interpolation': 'colorInterpolation',
  6194. colorinterpolationfilters: 'colorInterpolationFilters',
  6195. 'color-interpolation-filters': 'colorInterpolationFilters',
  6196. colorprofile: 'colorProfile',
  6197. 'color-profile': 'colorProfile',
  6198. colorrendering: 'colorRendering',
  6199. 'color-rendering': 'colorRendering',
  6200. contentscripttype: 'contentScriptType',
  6201. contentstyletype: 'contentStyleType',
  6202. cursor: 'cursor',
  6203. cx: 'cx',
  6204. cy: 'cy',
  6205. d: 'd',
  6206. datatype: 'datatype',
  6207. decelerate: 'decelerate',
  6208. descent: 'descent',
  6209. diffuseconstant: 'diffuseConstant',
  6210. direction: 'direction',
  6211. display: 'display',
  6212. divisor: 'divisor',
  6213. dominantbaseline: 'dominantBaseline',
  6214. 'dominant-baseline': 'dominantBaseline',
  6215. dur: 'dur',
  6216. dx: 'dx',
  6217. dy: 'dy',
  6218. edgemode: 'edgeMode',
  6219. elevation: 'elevation',
  6220. enablebackground: 'enableBackground',
  6221. 'enable-background': 'enableBackground',
  6222. end: 'end',
  6223. exponent: 'exponent',
  6224. externalresourcesrequired: 'externalResourcesRequired',
  6225. fill: 'fill',
  6226. fillopacity: 'fillOpacity',
  6227. 'fill-opacity': 'fillOpacity',
  6228. fillrule: 'fillRule',
  6229. 'fill-rule': 'fillRule',
  6230. filter: 'filter',
  6231. filterres: 'filterRes',
  6232. filterunits: 'filterUnits',
  6233. floodopacity: 'floodOpacity',
  6234. 'flood-opacity': 'floodOpacity',
  6235. floodcolor: 'floodColor',
  6236. 'flood-color': 'floodColor',
  6237. focusable: 'focusable',
  6238. fontfamily: 'fontFamily',
  6239. 'font-family': 'fontFamily',
  6240. fontsize: 'fontSize',
  6241. 'font-size': 'fontSize',
  6242. fontsizeadjust: 'fontSizeAdjust',
  6243. 'font-size-adjust': 'fontSizeAdjust',
  6244. fontstretch: 'fontStretch',
  6245. 'font-stretch': 'fontStretch',
  6246. fontstyle: 'fontStyle',
  6247. 'font-style': 'fontStyle',
  6248. fontvariant: 'fontVariant',
  6249. 'font-variant': 'fontVariant',
  6250. fontweight: 'fontWeight',
  6251. 'font-weight': 'fontWeight',
  6252. format: 'format',
  6253. from: 'from',
  6254. fx: 'fx',
  6255. fy: 'fy',
  6256. g1: 'g1',
  6257. g2: 'g2',
  6258. glyphname: 'glyphName',
  6259. 'glyph-name': 'glyphName',
  6260. glyphorientationhorizontal: 'glyphOrientationHorizontal',
  6261. 'glyph-orientation-horizontal': 'glyphOrientationHorizontal',
  6262. glyphorientationvertical: 'glyphOrientationVertical',
  6263. 'glyph-orientation-vertical': 'glyphOrientationVertical',
  6264. glyphref: 'glyphRef',
  6265. gradienttransform: 'gradientTransform',
  6266. gradientunits: 'gradientUnits',
  6267. hanging: 'hanging',
  6268. horizadvx: 'horizAdvX',
  6269. 'horiz-adv-x': 'horizAdvX',
  6270. horizoriginx: 'horizOriginX',
  6271. 'horiz-origin-x': 'horizOriginX',
  6272. ideographic: 'ideographic',
  6273. imagerendering: 'imageRendering',
  6274. 'image-rendering': 'imageRendering',
  6275. in2: 'in2',
  6276. in: 'in',
  6277. inlist: 'inlist',
  6278. intercept: 'intercept',
  6279. k1: 'k1',
  6280. k2: 'k2',
  6281. k3: 'k3',
  6282. k4: 'k4',
  6283. k: 'k',
  6284. kernelmatrix: 'kernelMatrix',
  6285. kernelunitlength: 'kernelUnitLength',
  6286. kerning: 'kerning',
  6287. keypoints: 'keyPoints',
  6288. keysplines: 'keySplines',
  6289. keytimes: 'keyTimes',
  6290. lengthadjust: 'lengthAdjust',
  6291. letterspacing: 'letterSpacing',
  6292. 'letter-spacing': 'letterSpacing',
  6293. lightingcolor: 'lightingColor',
  6294. 'lighting-color': 'lightingColor',
  6295. limitingconeangle: 'limitingConeAngle',
  6296. local: 'local',
  6297. markerend: 'markerEnd',
  6298. 'marker-end': 'markerEnd',
  6299. markerheight: 'markerHeight',
  6300. markermid: 'markerMid',
  6301. 'marker-mid': 'markerMid',
  6302. markerstart: 'markerStart',
  6303. 'marker-start': 'markerStart',
  6304. markerunits: 'markerUnits',
  6305. markerwidth: 'markerWidth',
  6306. mask: 'mask',
  6307. maskcontentunits: 'maskContentUnits',
  6308. maskunits: 'maskUnits',
  6309. mathematical: 'mathematical',
  6310. mode: 'mode',
  6311. numoctaves: 'numOctaves',
  6312. offset: 'offset',
  6313. opacity: 'opacity',
  6314. operator: 'operator',
  6315. order: 'order',
  6316. orient: 'orient',
  6317. orientation: 'orientation',
  6318. origin: 'origin',
  6319. overflow: 'overflow',
  6320. overlineposition: 'overlinePosition',
  6321. 'overline-position': 'overlinePosition',
  6322. overlinethickness: 'overlineThickness',
  6323. 'overline-thickness': 'overlineThickness',
  6324. paintorder: 'paintOrder',
  6325. 'paint-order': 'paintOrder',
  6326. panose1: 'panose1',
  6327. 'panose-1': 'panose1',
  6328. pathlength: 'pathLength',
  6329. patterncontentunits: 'patternContentUnits',
  6330. patterntransform: 'patternTransform',
  6331. patternunits: 'patternUnits',
  6332. pointerevents: 'pointerEvents',
  6333. 'pointer-events': 'pointerEvents',
  6334. points: 'points',
  6335. pointsatx: 'pointsAtX',
  6336. pointsaty: 'pointsAtY',
  6337. pointsatz: 'pointsAtZ',
  6338. prefix: 'prefix',
  6339. preservealpha: 'preserveAlpha',
  6340. preserveaspectratio: 'preserveAspectRatio',
  6341. primitiveunits: 'primitiveUnits',
  6342. property: 'property',
  6343. r: 'r',
  6344. radius: 'radius',
  6345. refx: 'refX',
  6346. refy: 'refY',
  6347. renderingintent: 'renderingIntent',
  6348. 'rendering-intent': 'renderingIntent',
  6349. repeatcount: 'repeatCount',
  6350. repeatdur: 'repeatDur',
  6351. requiredextensions: 'requiredExtensions',
  6352. requiredfeatures: 'requiredFeatures',
  6353. resource: 'resource',
  6354. restart: 'restart',
  6355. result: 'result',
  6356. results: 'results',
  6357. rotate: 'rotate',
  6358. rx: 'rx',
  6359. ry: 'ry',
  6360. scale: 'scale',
  6361. security: 'security',
  6362. seed: 'seed',
  6363. shaperendering: 'shapeRendering',
  6364. 'shape-rendering': 'shapeRendering',
  6365. slope: 'slope',
  6366. spacing: 'spacing',
  6367. specularconstant: 'specularConstant',
  6368. specularexponent: 'specularExponent',
  6369. speed: 'speed',
  6370. spreadmethod: 'spreadMethod',
  6371. startoffset: 'startOffset',
  6372. stddeviation: 'stdDeviation',
  6373. stemh: 'stemh',
  6374. stemv: 'stemv',
  6375. stitchtiles: 'stitchTiles',
  6376. stopcolor: 'stopColor',
  6377. 'stop-color': 'stopColor',
  6378. stopopacity: 'stopOpacity',
  6379. 'stop-opacity': 'stopOpacity',
  6380. strikethroughposition: 'strikethroughPosition',
  6381. 'strikethrough-position': 'strikethroughPosition',
  6382. strikethroughthickness: 'strikethroughThickness',
  6383. 'strikethrough-thickness': 'strikethroughThickness',
  6384. string: 'string',
  6385. stroke: 'stroke',
  6386. strokedasharray: 'strokeDasharray',
  6387. 'stroke-dasharray': 'strokeDasharray',
  6388. strokedashoffset: 'strokeDashoffset',
  6389. 'stroke-dashoffset': 'strokeDashoffset',
  6390. strokelinecap: 'strokeLinecap',
  6391. 'stroke-linecap': 'strokeLinecap',
  6392. strokelinejoin: 'strokeLinejoin',
  6393. 'stroke-linejoin': 'strokeLinejoin',
  6394. strokemiterlimit: 'strokeMiterlimit',
  6395. 'stroke-miterlimit': 'strokeMiterlimit',
  6396. strokewidth: 'strokeWidth',
  6397. 'stroke-width': 'strokeWidth',
  6398. strokeopacity: 'strokeOpacity',
  6399. 'stroke-opacity': 'strokeOpacity',
  6400. suppresscontenteditablewarning: 'suppressContentEditableWarning',
  6401. suppresshydrationwarning: 'suppressHydrationWarning',
  6402. surfacescale: 'surfaceScale',
  6403. systemlanguage: 'systemLanguage',
  6404. tablevalues: 'tableValues',
  6405. targetx: 'targetX',
  6406. targety: 'targetY',
  6407. textanchor: 'textAnchor',
  6408. 'text-anchor': 'textAnchor',
  6409. textdecoration: 'textDecoration',
  6410. 'text-decoration': 'textDecoration',
  6411. textlength: 'textLength',
  6412. textrendering: 'textRendering',
  6413. 'text-rendering': 'textRendering',
  6414. to: 'to',
  6415. transform: 'transform',
  6416. typeof: 'typeof',
  6417. u1: 'u1',
  6418. u2: 'u2',
  6419. underlineposition: 'underlinePosition',
  6420. 'underline-position': 'underlinePosition',
  6421. underlinethickness: 'underlineThickness',
  6422. 'underline-thickness': 'underlineThickness',
  6423. unicode: 'unicode',
  6424. unicodebidi: 'unicodeBidi',
  6425. 'unicode-bidi': 'unicodeBidi',
  6426. unicoderange: 'unicodeRange',
  6427. 'unicode-range': 'unicodeRange',
  6428. unitsperem: 'unitsPerEm',
  6429. 'units-per-em': 'unitsPerEm',
  6430. unselectable: 'unselectable',
  6431. valphabetic: 'vAlphabetic',
  6432. 'v-alphabetic': 'vAlphabetic',
  6433. values: 'values',
  6434. vectoreffect: 'vectorEffect',
  6435. 'vector-effect': 'vectorEffect',
  6436. version: 'version',
  6437. vertadvy: 'vertAdvY',
  6438. 'vert-adv-y': 'vertAdvY',
  6439. vertoriginx: 'vertOriginX',
  6440. 'vert-origin-x': 'vertOriginX',
  6441. vertoriginy: 'vertOriginY',
  6442. 'vert-origin-y': 'vertOriginY',
  6443. vhanging: 'vHanging',
  6444. 'v-hanging': 'vHanging',
  6445. videographic: 'vIdeographic',
  6446. 'v-ideographic': 'vIdeographic',
  6447. viewbox: 'viewBox',
  6448. viewtarget: 'viewTarget',
  6449. visibility: 'visibility',
  6450. vmathematical: 'vMathematical',
  6451. 'v-mathematical': 'vMathematical',
  6452. vocab: 'vocab',
  6453. widths: 'widths',
  6454. wordspacing: 'wordSpacing',
  6455. 'word-spacing': 'wordSpacing',
  6456. writingmode: 'writingMode',
  6457. 'writing-mode': 'writingMode',
  6458. x1: 'x1',
  6459. x2: 'x2',
  6460. x: 'x',
  6461. xchannelselector: 'xChannelSelector',
  6462. xheight: 'xHeight',
  6463. 'x-height': 'xHeight',
  6464. xlinkactuate: 'xlinkActuate',
  6465. 'xlink:actuate': 'xlinkActuate',
  6466. xlinkarcrole: 'xlinkArcrole',
  6467. 'xlink:arcrole': 'xlinkArcrole',
  6468. xlinkhref: 'xlinkHref',
  6469. 'xlink:href': 'xlinkHref',
  6470. xlinkrole: 'xlinkRole',
  6471. 'xlink:role': 'xlinkRole',
  6472. xlinkshow: 'xlinkShow',
  6473. 'xlink:show': 'xlinkShow',
  6474. xlinktitle: 'xlinkTitle',
  6475. 'xlink:title': 'xlinkTitle',
  6476. xlinktype: 'xlinkType',
  6477. 'xlink:type': 'xlinkType',
  6478. xmlbase: 'xmlBase',
  6479. 'xml:base': 'xmlBase',
  6480. xmllang: 'xmlLang',
  6481. 'xml:lang': 'xmlLang',
  6482. xmlns: 'xmlns',
  6483. 'xml:space': 'xmlSpace',
  6484. xmlnsxlink: 'xmlnsXlink',
  6485. 'xmlns:xlink': 'xmlnsXlink',
  6486. xmlspace: 'xmlSpace',
  6487. y1: 'y1',
  6488. y2: 'y2',
  6489. y: 'y',
  6490. ychannelselector: 'yChannelSelector',
  6491. z: 'z',
  6492. zoomandpan: 'zoomAndPan'
  6493. };
  6494. var ariaProperties = {
  6495. 'aria-current': 0, // state
  6496. 'aria-details': 0,
  6497. 'aria-disabled': 0, // state
  6498. 'aria-hidden': 0, // state
  6499. 'aria-invalid': 0, // state
  6500. 'aria-keyshortcuts': 0,
  6501. 'aria-label': 0,
  6502. 'aria-roledescription': 0,
  6503. // Widget Attributes
  6504. 'aria-autocomplete': 0,
  6505. 'aria-checked': 0,
  6506. 'aria-expanded': 0,
  6507. 'aria-haspopup': 0,
  6508. 'aria-level': 0,
  6509. 'aria-modal': 0,
  6510. 'aria-multiline': 0,
  6511. 'aria-multiselectable': 0,
  6512. 'aria-orientation': 0,
  6513. 'aria-placeholder': 0,
  6514. 'aria-pressed': 0,
  6515. 'aria-readonly': 0,
  6516. 'aria-required': 0,
  6517. 'aria-selected': 0,
  6518. 'aria-sort': 0,
  6519. 'aria-valuemax': 0,
  6520. 'aria-valuemin': 0,
  6521. 'aria-valuenow': 0,
  6522. 'aria-valuetext': 0,
  6523. // Live Region Attributes
  6524. 'aria-atomic': 0,
  6525. 'aria-busy': 0,
  6526. 'aria-live': 0,
  6527. 'aria-relevant': 0,
  6528. // Drag-and-Drop Attributes
  6529. 'aria-dropeffect': 0,
  6530. 'aria-grabbed': 0,
  6531. // Relationship Attributes
  6532. 'aria-activedescendant': 0,
  6533. 'aria-colcount': 0,
  6534. 'aria-colindex': 0,
  6535. 'aria-colspan': 0,
  6536. 'aria-controls': 0,
  6537. 'aria-describedby': 0,
  6538. 'aria-errormessage': 0,
  6539. 'aria-flowto': 0,
  6540. 'aria-labelledby': 0,
  6541. 'aria-owns': 0,
  6542. 'aria-posinset': 0,
  6543. 'aria-rowcount': 0,
  6544. 'aria-rowindex': 0,
  6545. 'aria-rowspan': 0,
  6546. 'aria-setsize': 0
  6547. };
  6548. var warnedProperties = {};
  6549. var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
  6550. var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
  6551. var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
  6552. function validateProperty(tagName, name) {
  6553. if (hasOwnProperty$2.call(warnedProperties, name) && warnedProperties[name]) {
  6554. return true;
  6555. }
  6556. if (rARIACamel.test(name)) {
  6557. var ariaName = 'aria-' + name.slice(4).toLowerCase();
  6558. var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null;
  6559. // If this is an aria-* attribute, but is not listed in the known DOM
  6560. // DOM properties, then it is an invalid aria-* attribute.
  6561. if (correctName == null) {
  6562. warning$1(false, 'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.', name);
  6563. warnedProperties[name] = true;
  6564. return true;
  6565. }
  6566. // aria-* attributes should be lowercase; suggest the lowercase version.
  6567. if (name !== correctName) {
  6568. warning$1(false, 'Invalid ARIA attribute `%s`. Did you mean `%s`?', name, correctName);
  6569. warnedProperties[name] = true;
  6570. return true;
  6571. }
  6572. }
  6573. if (rARIA.test(name)) {
  6574. var lowerCasedName = name.toLowerCase();
  6575. var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null;
  6576. // If this is an aria-* attribute, but is not listed in the known DOM
  6577. // DOM properties, then it is an invalid aria-* attribute.
  6578. if (standardName == null) {
  6579. warnedProperties[name] = true;
  6580. return false;
  6581. }
  6582. // aria-* attributes should be lowercase; suggest the lowercase version.
  6583. if (name !== standardName) {
  6584. warning$1(false, 'Unknown ARIA attribute `%s`. Did you mean `%s`?', name, standardName);
  6585. warnedProperties[name] = true;
  6586. return true;
  6587. }
  6588. }
  6589. return true;
  6590. }
  6591. function warnInvalidARIAProps(type, props) {
  6592. var invalidProps = [];
  6593. for (var key in props) {
  6594. var isValid = validateProperty(type, key);
  6595. if (!isValid) {
  6596. invalidProps.push(key);
  6597. }
  6598. }
  6599. var unknownPropString = invalidProps.map(function (prop) {
  6600. return '`' + prop + '`';
  6601. }).join(', ');
  6602. if (invalidProps.length === 1) {
  6603. warning$1(false, 'Invalid aria prop %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop', unknownPropString, type);
  6604. } else if (invalidProps.length > 1) {
  6605. warning$1(false, 'Invalid aria props %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop', unknownPropString, type);
  6606. }
  6607. }
  6608. function validateProperties(type, props) {
  6609. if (isCustomComponent(type, props)) {
  6610. return;
  6611. }
  6612. warnInvalidARIAProps(type, props);
  6613. }
  6614. var didWarnValueNull = false;
  6615. function validateProperties$1(type, props) {
  6616. if (type !== 'input' && type !== 'textarea' && type !== 'select') {
  6617. return;
  6618. }
  6619. if (props != null && props.value === null && !didWarnValueNull) {
  6620. didWarnValueNull = true;
  6621. if (type === 'select' && props.multiple) {
  6622. 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);
  6623. } else {
  6624. 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);
  6625. }
  6626. }
  6627. }
  6628. var validateProperty$1 = function () {};
  6629. {
  6630. var warnedProperties$1 = {};
  6631. var _hasOwnProperty = Object.prototype.hasOwnProperty;
  6632. var EVENT_NAME_REGEX = /^on./;
  6633. var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/;
  6634. var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
  6635. var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
  6636. validateProperty$1 = function (tagName, name, value, canUseEventSystem) {
  6637. if (_hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) {
  6638. return true;
  6639. }
  6640. var lowerCasedName = name.toLowerCase();
  6641. if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') {
  6642. 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.');
  6643. warnedProperties$1[name] = true;
  6644. return true;
  6645. }
  6646. // We can't rely on the event system being injected on the server.
  6647. if (canUseEventSystem) {
  6648. if (registrationNameModules.hasOwnProperty(name)) {
  6649. return true;
  6650. }
  6651. var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null;
  6652. if (registrationName != null) {
  6653. warning$1(false, 'Invalid event handler property `%s`. Did you mean `%s`?', name, registrationName);
  6654. warnedProperties$1[name] = true;
  6655. return true;
  6656. }
  6657. if (EVENT_NAME_REGEX.test(name)) {
  6658. warning$1(false, 'Unknown event handler property `%s`. It will be ignored.', name);
  6659. warnedProperties$1[name] = true;
  6660. return true;
  6661. }
  6662. } else if (EVENT_NAME_REGEX.test(name)) {
  6663. // If no event plugins have been injected, we are in a server environment.
  6664. // So we can't tell if the event name is correct for sure, but we can filter
  6665. // out known bad ones like `onclick`. We can't suggest a specific replacement though.
  6666. if (INVALID_EVENT_NAME_REGEX.test(name)) {
  6667. warning$1(false, 'Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.', name);
  6668. }
  6669. warnedProperties$1[name] = true;
  6670. return true;
  6671. }
  6672. // Let the ARIA attribute hook validate ARIA attributes
  6673. if (rARIA$1.test(name) || rARIACamel$1.test(name)) {
  6674. return true;
  6675. }
  6676. if (lowerCasedName === 'innerhtml') {
  6677. warning$1(false, 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.');
  6678. warnedProperties$1[name] = true;
  6679. return true;
  6680. }
  6681. if (lowerCasedName === 'aria') {
  6682. warning$1(false, 'The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.');
  6683. warnedProperties$1[name] = true;
  6684. return true;
  6685. }
  6686. if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') {
  6687. warning$1(false, 'Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.', typeof value);
  6688. warnedProperties$1[name] = true;
  6689. return true;
  6690. }
  6691. if (typeof value === 'number' && isNaN(value)) {
  6692. warning$1(false, 'Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.', name);
  6693. warnedProperties$1[name] = true;
  6694. return true;
  6695. }
  6696. var propertyInfo = getPropertyInfo(name);
  6697. var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED;
  6698. // Known attributes should match the casing specified in the property config.
  6699. if (possibleStandardNames.hasOwnProperty(lowerCasedName)) {
  6700. var standardName = possibleStandardNames[lowerCasedName];
  6701. if (standardName !== name) {
  6702. warning$1(false, 'Invalid DOM property `%s`. Did you mean `%s`?', name, standardName);
  6703. warnedProperties$1[name] = true;
  6704. return true;
  6705. }
  6706. } else if (!isReserved && name !== lowerCasedName) {
  6707. // Unknown attributes should have lowercase casing since that's how they
  6708. // will be cased anyway with server rendering.
  6709. 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);
  6710. warnedProperties$1[name] = true;
  6711. return true;
  6712. }
  6713. if (typeof value === 'boolean' && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
  6714. if (value) {
  6715. 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);
  6716. } else {
  6717. 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);
  6718. }
  6719. warnedProperties$1[name] = true;
  6720. return true;
  6721. }
  6722. // Now that we've validated casing, do not validate
  6723. // data types for reserved props
  6724. if (isReserved) {
  6725. return true;
  6726. }
  6727. // Warn when a known attribute is a bad type
  6728. if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
  6729. warnedProperties$1[name] = true;
  6730. return false;
  6731. }
  6732. // Warn when passing the strings 'false' or 'true' into a boolean prop
  6733. if ((value === 'false' || value === 'true') && propertyInfo !== null && propertyInfo.type === BOOLEAN) {
  6734. 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);
  6735. warnedProperties$1[name] = true;
  6736. return true;
  6737. }
  6738. return true;
  6739. };
  6740. }
  6741. var warnUnknownProperties = function (type, props, canUseEventSystem) {
  6742. var unknownProps = [];
  6743. for (var key in props) {
  6744. var isValid = validateProperty$1(type, key, props[key], canUseEventSystem);
  6745. if (!isValid) {
  6746. unknownProps.push(key);
  6747. }
  6748. }
  6749. var unknownPropString = unknownProps.map(function (prop) {
  6750. return '`' + prop + '`';
  6751. }).join(', ');
  6752. if (unknownProps.length === 1) {
  6753. 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);
  6754. } else if (unknownProps.length > 1) {
  6755. 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);
  6756. }
  6757. };
  6758. function validateProperties$2(type, props, canUseEventSystem) {
  6759. if (isCustomComponent(type, props)) {
  6760. return;
  6761. }
  6762. warnUnknownProperties(type, props, canUseEventSystem);
  6763. }
  6764. // TODO: direct imports like some-package/src/* are bad. Fix me.
  6765. var didWarnInvalidHydration = false;
  6766. var didWarnShadyDOM = false;
  6767. var DANGEROUSLY_SET_INNER_HTML = 'dangerouslySetInnerHTML';
  6768. var SUPPRESS_CONTENT_EDITABLE_WARNING = 'suppressContentEditableWarning';
  6769. var SUPPRESS_HYDRATION_WARNING$1 = 'suppressHydrationWarning';
  6770. var AUTOFOCUS = 'autoFocus';
  6771. var CHILDREN = 'children';
  6772. var STYLE$1 = 'style';
  6773. var HTML = '__html';
  6774. var HTML_NAMESPACE = Namespaces.html;
  6775. var warnedUnknownTags = void 0;
  6776. var suppressHydrationWarning = void 0;
  6777. var validatePropertiesInDevelopment = void 0;
  6778. var warnForTextDifference = void 0;
  6779. var warnForPropDifference = void 0;
  6780. var warnForExtraAttributes = void 0;
  6781. var warnForInvalidEventListener = void 0;
  6782. var canDiffStyleForHydrationWarning = void 0;
  6783. var normalizeMarkupForTextOrAttribute = void 0;
  6784. var normalizeHTML = void 0;
  6785. {
  6786. warnedUnknownTags = {
  6787. // Chrome is the only major browser not shipping <time>. But as of July
  6788. // 2017 it intends to ship it due to widespread usage. We intentionally
  6789. // *don't* warn for <time> even if it's unrecognized by Chrome because
  6790. // it soon will be, and many apps have been using it anyway.
  6791. time: true,
  6792. // There are working polyfills for <dialog>. Let people use it.
  6793. dialog: true,
  6794. // Electron ships a custom <webview> tag to display external web content in
  6795. // an isolated frame and process.
  6796. // This tag is not present in non Electron environments such as JSDom which
  6797. // is often used for testing purposes.
  6798. // @see https://electronjs.org/docs/api/webview-tag
  6799. webview: true
  6800. };
  6801. validatePropertiesInDevelopment = function (type, props) {
  6802. validateProperties(type, props);
  6803. validateProperties$1(type, props);
  6804. validateProperties$2(type, props, /* canUseEventSystem */true);
  6805. };
  6806. // IE 11 parses & normalizes the style attribute as opposed to other
  6807. // browsers. It adds spaces and sorts the properties in some
  6808. // non-alphabetical order. Handling that would require sorting CSS
  6809. // properties in the client & server versions or applying
  6810. // `expectedStyle` to a temporary DOM node to read its `style` attribute
  6811. // normalized. Since it only affects IE, we're skipping style warnings
  6812. // in that browser completely in favor of doing all that work.
  6813. // See https://github.com/facebook/react/issues/11807
  6814. canDiffStyleForHydrationWarning = canUseDOM && !document.documentMode;
  6815. // HTML parsing normalizes CR and CRLF to LF.
  6816. // It also can turn \u0000 into \uFFFD inside attributes.
  6817. // https://www.w3.org/TR/html5/single-page.html#preprocessing-the-input-stream
  6818. // If we have a mismatch, it might be caused by that.
  6819. // We will still patch up in this case but not fire the warning.
  6820. var NORMALIZE_NEWLINES_REGEX = /\r\n?/g;
  6821. var NORMALIZE_NULL_AND_REPLACEMENT_REGEX = /\u0000|\uFFFD/g;
  6822. normalizeMarkupForTextOrAttribute = function (markup) {
  6823. var markupString = typeof markup === 'string' ? markup : '' + markup;
  6824. return markupString.replace(NORMALIZE_NEWLINES_REGEX, '\n').replace(NORMALIZE_NULL_AND_REPLACEMENT_REGEX, '');
  6825. };
  6826. warnForTextDifference = function (serverText, clientText) {
  6827. if (didWarnInvalidHydration) {
  6828. return;
  6829. }
  6830. var normalizedClientText = normalizeMarkupForTextOrAttribute(clientText);
  6831. var normalizedServerText = normalizeMarkupForTextOrAttribute(serverText);
  6832. if (normalizedServerText === normalizedClientText) {
  6833. return;
  6834. }
  6835. didWarnInvalidHydration = true;
  6836. warningWithoutStack$1(false, 'Text content did not match. Server: "%s" Client: "%s"', normalizedServerText, normalizedClientText);
  6837. };
  6838. warnForPropDifference = function (propName, serverValue, clientValue) {
  6839. if (didWarnInvalidHydration) {
  6840. return;
  6841. }
  6842. var normalizedClientValue = normalizeMarkupForTextOrAttribute(clientValue);
  6843. var normalizedServerValue = normalizeMarkupForTextOrAttribute(serverValue);
  6844. if (normalizedServerValue === normalizedClientValue) {
  6845. return;
  6846. }
  6847. didWarnInvalidHydration = true;
  6848. warningWithoutStack$1(false, 'Prop `%s` did not match. Server: %s Client: %s', propName, JSON.stringify(normalizedServerValue), JSON.stringify(normalizedClientValue));
  6849. };
  6850. warnForExtraAttributes = function (attributeNames) {
  6851. if (didWarnInvalidHydration) {
  6852. return;
  6853. }
  6854. didWarnInvalidHydration = true;
  6855. var names = [];
  6856. attributeNames.forEach(function (name) {
  6857. names.push(name);
  6858. });
  6859. warningWithoutStack$1(false, 'Extra attributes from the server: %s', names);
  6860. };
  6861. warnForInvalidEventListener = function (registrationName, listener) {
  6862. if (listener === false) {
  6863. 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);
  6864. } else {
  6865. warning$1(false, 'Expected `%s` listener to be a function, instead got a value of `%s` type.', registrationName, typeof listener);
  6866. }
  6867. };
  6868. // Parse the HTML and read it back to normalize the HTML string so that it
  6869. // can be used for comparison.
  6870. normalizeHTML = function (parent, html) {
  6871. // We could have created a separate document here to avoid
  6872. // re-initializing custom elements if they exist. But this breaks
  6873. // how <noscript> is being handled. So we use the same document.
  6874. // See the discussion in https://github.com/facebook/react/pull/11157.
  6875. var testElement = parent.namespaceURI === HTML_NAMESPACE ? parent.ownerDocument.createElement(parent.tagName) : parent.ownerDocument.createElementNS(parent.namespaceURI, parent.tagName);
  6876. testElement.innerHTML = html;
  6877. return testElement.innerHTML;
  6878. };
  6879. }
  6880. function ensureListeningTo(rootContainerElement, registrationName) {
  6881. var isDocumentOrFragment = rootContainerElement.nodeType === DOCUMENT_NODE || rootContainerElement.nodeType === DOCUMENT_FRAGMENT_NODE;
  6882. var doc = isDocumentOrFragment ? rootContainerElement : rootContainerElement.ownerDocument;
  6883. listenTo(registrationName, doc);
  6884. }
  6885. function getOwnerDocumentFromRootContainer(rootContainerElement) {
  6886. return rootContainerElement.nodeType === DOCUMENT_NODE ? rootContainerElement : rootContainerElement.ownerDocument;
  6887. }
  6888. function noop() {}
  6889. function trapClickOnNonInteractiveElement(node) {
  6890. // Mobile Safari does not fire properly bubble click events on
  6891. // non-interactive elements, which means delegated click listeners do not
  6892. // fire. The workaround for this bug involves attaching an empty click
  6893. // listener on the target node.
  6894. // http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
  6895. // Just set it using the onclick property so that we don't have to manage any
  6896. // bookkeeping for it. Not sure if we need to clear it when the listener is
  6897. // removed.
  6898. // TODO: Only do this for the relevant Safaris maybe?
  6899. node.onclick = noop;
  6900. }
  6901. function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) {
  6902. for (var propKey in nextProps) {
  6903. if (!nextProps.hasOwnProperty(propKey)) {
  6904. continue;
  6905. }
  6906. var nextProp = nextProps[propKey];
  6907. if (propKey === STYLE$1) {
  6908. {
  6909. if (nextProp) {
  6910. // Freeze the next style object so that we can assume it won't be
  6911. // mutated. We have already warned for this in the past.
  6912. Object.freeze(nextProp);
  6913. }
  6914. }
  6915. // Relies on `updateStylesByID` not mutating `styleUpdates`.
  6916. setValueForStyles(domElement, nextProp);
  6917. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  6918. var nextHtml = nextProp ? nextProp[HTML] : undefined;
  6919. if (nextHtml != null) {
  6920. setInnerHTML(domElement, nextHtml);
  6921. }
  6922. } else if (propKey === CHILDREN) {
  6923. if (typeof nextProp === 'string') {
  6924. // Avoid setting initial textContent when the text is empty. In IE11 setting
  6925. // textContent on a <textarea> will cause the placeholder to not
  6926. // show within the <textarea> until it has been focused and blurred again.
  6927. // https://github.com/facebook/react/issues/6731#issuecomment-254874553
  6928. var canSetTextContent = tag !== 'textarea' || nextProp !== '';
  6929. if (canSetTextContent) {
  6930. setTextContent(domElement, nextProp);
  6931. }
  6932. } else if (typeof nextProp === 'number') {
  6933. setTextContent(domElement, '' + nextProp);
  6934. }
  6935. } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {
  6936. // Noop
  6937. } else if (propKey === AUTOFOCUS) {
  6938. // We polyfill it separately on the client during commit.
  6939. // We could have excluded it in the property list instead of
  6940. // adding a special case here, but then it wouldn't be emitted
  6941. // on server rendering (but we *do* want to emit it in SSR).
  6942. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  6943. if (nextProp != null) {
  6944. if ( true && typeof nextProp !== 'function') {
  6945. warnForInvalidEventListener(propKey, nextProp);
  6946. }
  6947. ensureListeningTo(rootContainerElement, propKey);
  6948. }
  6949. } else if (nextProp != null) {
  6950. setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag);
  6951. }
  6952. }
  6953. }
  6954. function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) {
  6955. // TODO: Handle wasCustomComponentTag
  6956. for (var i = 0; i < updatePayload.length; i += 2) {
  6957. var propKey = updatePayload[i];
  6958. var propValue = updatePayload[i + 1];
  6959. if (propKey === STYLE$1) {
  6960. setValueForStyles(domElement, propValue);
  6961. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  6962. setInnerHTML(domElement, propValue);
  6963. } else if (propKey === CHILDREN) {
  6964. setTextContent(domElement, propValue);
  6965. } else {
  6966. setValueForProperty(domElement, propKey, propValue, isCustomComponentTag);
  6967. }
  6968. }
  6969. }
  6970. function createElement(type, props, rootContainerElement, parentNamespace) {
  6971. var isCustomComponentTag = void 0;
  6972. // We create tags in the namespace of their parent container, except HTML
  6973. // tags get no namespace.
  6974. var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement);
  6975. var domElement = void 0;
  6976. var namespaceURI = parentNamespace;
  6977. if (namespaceURI === HTML_NAMESPACE) {
  6978. namespaceURI = getIntrinsicNamespace(type);
  6979. }
  6980. if (namespaceURI === HTML_NAMESPACE) {
  6981. {
  6982. isCustomComponentTag = isCustomComponent(type, props);
  6983. // Should this check be gated by parent namespace? Not sure we want to
  6984. // allow <SVG> or <mATH>.
  6985. !(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;
  6986. }
  6987. if (type === 'script') {
  6988. // Create the script via .innerHTML so its "parser-inserted" flag is
  6989. // set to true and it does not execute
  6990. var div = ownerDocument.createElement('div');
  6991. div.innerHTML = '<script><' + '/script>'; // eslint-disable-line
  6992. // This is guaranteed to yield a script element.
  6993. var firstChild = div.firstChild;
  6994. domElement = div.removeChild(firstChild);
  6995. } else if (typeof props.is === 'string') {
  6996. // $FlowIssue `createElement` should be updated for Web Components
  6997. domElement = ownerDocument.createElement(type, { is: props.is });
  6998. } else {
  6999. // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug.
  7000. // See discussion in https://github.com/facebook/react/pull/6896
  7001. // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
  7002. domElement = ownerDocument.createElement(type);
  7003. // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple`
  7004. // attribute on `select`s needs to be added before `option`s are inserted. This prevents
  7005. // a bug where the `select` does not scroll to the correct option because singular
  7006. // `select` elements automatically pick the first item.
  7007. // See https://github.com/facebook/react/issues/13222
  7008. if (type === 'select' && props.multiple) {
  7009. var node = domElement;
  7010. node.multiple = true;
  7011. }
  7012. }
  7013. } else {
  7014. domElement = ownerDocument.createElementNS(namespaceURI, type);
  7015. }
  7016. {
  7017. if (namespaceURI === HTML_NAMESPACE) {
  7018. if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) {
  7019. warnedUnknownTags[type] = true;
  7020. 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);
  7021. }
  7022. }
  7023. }
  7024. return domElement;
  7025. }
  7026. function createTextNode(text, rootContainerElement) {
  7027. return getOwnerDocumentFromRootContainer(rootContainerElement).createTextNode(text);
  7028. }
  7029. function setInitialProperties(domElement, tag, rawProps, rootContainerElement) {
  7030. var isCustomComponentTag = isCustomComponent(tag, rawProps);
  7031. {
  7032. validatePropertiesInDevelopment(tag, rawProps);
  7033. if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) {
  7034. warning$1(false, '%s is using shady DOM. Using shady DOM with React can ' + 'cause things to break subtly.', getCurrentFiberOwnerNameInDevOrNull() || 'A component');
  7035. didWarnShadyDOM = true;
  7036. }
  7037. }
  7038. // TODO: Make sure that we check isMounted before firing any of these events.
  7039. var props = void 0;
  7040. switch (tag) {
  7041. case 'iframe':
  7042. case 'object':
  7043. trapBubbledEvent(TOP_LOAD, domElement);
  7044. props = rawProps;
  7045. break;
  7046. case 'video':
  7047. case 'audio':
  7048. // Create listener for each media event
  7049. for (var i = 0; i < mediaEventTypes.length; i++) {
  7050. trapBubbledEvent(mediaEventTypes[i], domElement);
  7051. }
  7052. props = rawProps;
  7053. break;
  7054. case 'source':
  7055. trapBubbledEvent(TOP_ERROR, domElement);
  7056. props = rawProps;
  7057. break;
  7058. case 'img':
  7059. case 'image':
  7060. case 'link':
  7061. trapBubbledEvent(TOP_ERROR, domElement);
  7062. trapBubbledEvent(TOP_LOAD, domElement);
  7063. props = rawProps;
  7064. break;
  7065. case 'form':
  7066. trapBubbledEvent(TOP_RESET, domElement);
  7067. trapBubbledEvent(TOP_SUBMIT, domElement);
  7068. props = rawProps;
  7069. break;
  7070. case 'details':
  7071. trapBubbledEvent(TOP_TOGGLE, domElement);
  7072. props = rawProps;
  7073. break;
  7074. case 'input':
  7075. initWrapperState(domElement, rawProps);
  7076. props = getHostProps(domElement, rawProps);
  7077. trapBubbledEvent(TOP_INVALID, domElement);
  7078. // For controlled components we always need to ensure we're listening
  7079. // to onChange. Even if there is no listener.
  7080. ensureListeningTo(rootContainerElement, 'onChange');
  7081. break;
  7082. case 'option':
  7083. validateProps(domElement, rawProps);
  7084. props = getHostProps$1(domElement, rawProps);
  7085. break;
  7086. case 'select':
  7087. initWrapperState$1(domElement, rawProps);
  7088. props = getHostProps$2(domElement, rawProps);
  7089. trapBubbledEvent(TOP_INVALID, domElement);
  7090. // For controlled components we always need to ensure we're listening
  7091. // to onChange. Even if there is no listener.
  7092. ensureListeningTo(rootContainerElement, 'onChange');
  7093. break;
  7094. case 'textarea':
  7095. initWrapperState$2(domElement, rawProps);
  7096. props = getHostProps$3(domElement, rawProps);
  7097. trapBubbledEvent(TOP_INVALID, domElement);
  7098. // For controlled components we always need to ensure we're listening
  7099. // to onChange. Even if there is no listener.
  7100. ensureListeningTo(rootContainerElement, 'onChange');
  7101. break;
  7102. default:
  7103. props = rawProps;
  7104. }
  7105. assertValidProps(tag, props);
  7106. setInitialDOMProperties(tag, domElement, rootContainerElement, props, isCustomComponentTag);
  7107. switch (tag) {
  7108. case 'input':
  7109. // TODO: Make sure we check if this is still unmounted or do any clean
  7110. // up necessary since we never stop tracking anymore.
  7111. track(domElement);
  7112. postMountWrapper(domElement, rawProps, false);
  7113. break;
  7114. case 'textarea':
  7115. // TODO: Make sure we check if this is still unmounted or do any clean
  7116. // up necessary since we never stop tracking anymore.
  7117. track(domElement);
  7118. postMountWrapper$3(domElement, rawProps);
  7119. break;
  7120. case 'option':
  7121. postMountWrapper$1(domElement, rawProps);
  7122. break;
  7123. case 'select':
  7124. postMountWrapper$2(domElement, rawProps);
  7125. break;
  7126. default:
  7127. if (typeof props.onClick === 'function') {
  7128. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  7129. trapClickOnNonInteractiveElement(domElement);
  7130. }
  7131. break;
  7132. }
  7133. }
  7134. // Calculate the diff between the two objects.
  7135. function diffProperties(domElement, tag, lastRawProps, nextRawProps, rootContainerElement) {
  7136. {
  7137. validatePropertiesInDevelopment(tag, nextRawProps);
  7138. }
  7139. var updatePayload = null;
  7140. var lastProps = void 0;
  7141. var nextProps = void 0;
  7142. switch (tag) {
  7143. case 'input':
  7144. lastProps = getHostProps(domElement, lastRawProps);
  7145. nextProps = getHostProps(domElement, nextRawProps);
  7146. updatePayload = [];
  7147. break;
  7148. case 'option':
  7149. lastProps = getHostProps$1(domElement, lastRawProps);
  7150. nextProps = getHostProps$1(domElement, nextRawProps);
  7151. updatePayload = [];
  7152. break;
  7153. case 'select':
  7154. lastProps = getHostProps$2(domElement, lastRawProps);
  7155. nextProps = getHostProps$2(domElement, nextRawProps);
  7156. updatePayload = [];
  7157. break;
  7158. case 'textarea':
  7159. lastProps = getHostProps$3(domElement, lastRawProps);
  7160. nextProps = getHostProps$3(domElement, nextRawProps);
  7161. updatePayload = [];
  7162. break;
  7163. default:
  7164. lastProps = lastRawProps;
  7165. nextProps = nextRawProps;
  7166. if (typeof lastProps.onClick !== 'function' && typeof nextProps.onClick === 'function') {
  7167. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  7168. trapClickOnNonInteractiveElement(domElement);
  7169. }
  7170. break;
  7171. }
  7172. assertValidProps(tag, nextProps);
  7173. var propKey = void 0;
  7174. var styleName = void 0;
  7175. var styleUpdates = null;
  7176. for (propKey in lastProps) {
  7177. if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) {
  7178. continue;
  7179. }
  7180. if (propKey === STYLE$1) {
  7181. var lastStyle = lastProps[propKey];
  7182. for (styleName in lastStyle) {
  7183. if (lastStyle.hasOwnProperty(styleName)) {
  7184. if (!styleUpdates) {
  7185. styleUpdates = {};
  7186. }
  7187. styleUpdates[styleName] = '';
  7188. }
  7189. }
  7190. } else if (propKey === DANGEROUSLY_SET_INNER_HTML || propKey === CHILDREN) {
  7191. // Noop. This is handled by the clear text mechanism.
  7192. } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {
  7193. // Noop
  7194. } else if (propKey === AUTOFOCUS) {
  7195. // Noop. It doesn't work on updates anyway.
  7196. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  7197. // This is a special case. If any listener updates we need to ensure
  7198. // that the "current" fiber pointer gets updated so we need a commit
  7199. // to update this element.
  7200. if (!updatePayload) {
  7201. updatePayload = [];
  7202. }
  7203. } else {
  7204. // For all other deleted properties we add it to the queue. We use
  7205. // the whitelist in the commit phase instead.
  7206. (updatePayload = updatePayload || []).push(propKey, null);
  7207. }
  7208. }
  7209. for (propKey in nextProps) {
  7210. var nextProp = nextProps[propKey];
  7211. var lastProp = lastProps != null ? lastProps[propKey] : undefined;
  7212. if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) {
  7213. continue;
  7214. }
  7215. if (propKey === STYLE$1) {
  7216. {
  7217. if (nextProp) {
  7218. // Freeze the next style object so that we can assume it won't be
  7219. // mutated. We have already warned for this in the past.
  7220. Object.freeze(nextProp);
  7221. }
  7222. }
  7223. if (lastProp) {
  7224. // Unset styles on `lastProp` but not on `nextProp`.
  7225. for (styleName in lastProp) {
  7226. if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) {
  7227. if (!styleUpdates) {
  7228. styleUpdates = {};
  7229. }
  7230. styleUpdates[styleName] = '';
  7231. }
  7232. }
  7233. // Update styles that changed since `lastProp`.
  7234. for (styleName in nextProp) {
  7235. if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) {
  7236. if (!styleUpdates) {
  7237. styleUpdates = {};
  7238. }
  7239. styleUpdates[styleName] = nextProp[styleName];
  7240. }
  7241. }
  7242. } else {
  7243. // Relies on `updateStylesByID` not mutating `styleUpdates`.
  7244. if (!styleUpdates) {
  7245. if (!updatePayload) {
  7246. updatePayload = [];
  7247. }
  7248. updatePayload.push(propKey, styleUpdates);
  7249. }
  7250. styleUpdates = nextProp;
  7251. }
  7252. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  7253. var nextHtml = nextProp ? nextProp[HTML] : undefined;
  7254. var lastHtml = lastProp ? lastProp[HTML] : undefined;
  7255. if (nextHtml != null) {
  7256. if (lastHtml !== nextHtml) {
  7257. (updatePayload = updatePayload || []).push(propKey, '' + nextHtml);
  7258. }
  7259. } else {
  7260. // TODO: It might be too late to clear this if we have children
  7261. // inserted already.
  7262. }
  7263. } else if (propKey === CHILDREN) {
  7264. if (lastProp !== nextProp && (typeof nextProp === 'string' || typeof nextProp === 'number')) {
  7265. (updatePayload = updatePayload || []).push(propKey, '' + nextProp);
  7266. }
  7267. } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {
  7268. // Noop
  7269. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  7270. if (nextProp != null) {
  7271. // We eagerly listen to this even though we haven't committed yet.
  7272. if ( true && typeof nextProp !== 'function') {
  7273. warnForInvalidEventListener(propKey, nextProp);
  7274. }
  7275. ensureListeningTo(rootContainerElement, propKey);
  7276. }
  7277. if (!updatePayload && lastProp !== nextProp) {
  7278. // This is a special case. If any listener updates we need to ensure
  7279. // that the "current" props pointer gets updated so we need a commit
  7280. // to update this element.
  7281. updatePayload = [];
  7282. }
  7283. } else {
  7284. // For any other property we always add it to the queue and then we
  7285. // filter it out using the whitelist during the commit.
  7286. (updatePayload = updatePayload || []).push(propKey, nextProp);
  7287. }
  7288. }
  7289. if (styleUpdates) {
  7290. (updatePayload = updatePayload || []).push(STYLE$1, styleUpdates);
  7291. }
  7292. return updatePayload;
  7293. }
  7294. // Apply the diff.
  7295. function updateProperties(domElement, updatePayload, tag, lastRawProps, nextRawProps) {
  7296. // Update checked *before* name.
  7297. // In the middle of an update, it is possible to have multiple checked.
  7298. // When a checked radio tries to change name, browser makes another radio's checked false.
  7299. if (tag === 'input' && nextRawProps.type === 'radio' && nextRawProps.name != null) {
  7300. updateChecked(domElement, nextRawProps);
  7301. }
  7302. var wasCustomComponentTag = isCustomComponent(tag, lastRawProps);
  7303. var isCustomComponentTag = isCustomComponent(tag, nextRawProps);
  7304. // Apply the diff.
  7305. updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag);
  7306. // TODO: Ensure that an update gets scheduled if any of the special props
  7307. // changed.
  7308. switch (tag) {
  7309. case 'input':
  7310. // Update the wrapper around inputs *after* updating props. This has to
  7311. // happen after `updateDOMProperties`. Otherwise HTML5 input validations
  7312. // raise warnings and prevent the new value from being assigned.
  7313. updateWrapper(domElement, nextRawProps);
  7314. break;
  7315. case 'textarea':
  7316. updateWrapper$1(domElement, nextRawProps);
  7317. break;
  7318. case 'select':
  7319. // <select> value update needs to occur after <option> children
  7320. // reconciliation
  7321. postUpdateWrapper(domElement, nextRawProps);
  7322. break;
  7323. }
  7324. }
  7325. function getPossibleStandardName(propName) {
  7326. {
  7327. var lowerCasedName = propName.toLowerCase();
  7328. if (!possibleStandardNames.hasOwnProperty(lowerCasedName)) {
  7329. return null;
  7330. }
  7331. return possibleStandardNames[lowerCasedName] || null;
  7332. }
  7333. return null;
  7334. }
  7335. function diffHydratedProperties(domElement, tag, rawProps, parentNamespace, rootContainerElement) {
  7336. var isCustomComponentTag = void 0;
  7337. var extraAttributeNames = void 0;
  7338. {
  7339. suppressHydrationWarning = rawProps[SUPPRESS_HYDRATION_WARNING$1] === true;
  7340. isCustomComponentTag = isCustomComponent(tag, rawProps);
  7341. validatePropertiesInDevelopment(tag, rawProps);
  7342. if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) {
  7343. warning$1(false, '%s is using shady DOM. Using shady DOM with React can ' + 'cause things to break subtly.', getCurrentFiberOwnerNameInDevOrNull() || 'A component');
  7344. didWarnShadyDOM = true;
  7345. }
  7346. }
  7347. // TODO: Make sure that we check isMounted before firing any of these events.
  7348. switch (tag) {
  7349. case 'iframe':
  7350. case 'object':
  7351. trapBubbledEvent(TOP_LOAD, domElement);
  7352. break;
  7353. case 'video':
  7354. case 'audio':
  7355. // Create listener for each media event
  7356. for (var i = 0; i < mediaEventTypes.length; i++) {
  7357. trapBubbledEvent(mediaEventTypes[i], domElement);
  7358. }
  7359. break;
  7360. case 'source':
  7361. trapBubbledEvent(TOP_ERROR, domElement);
  7362. break;
  7363. case 'img':
  7364. case 'image':
  7365. case 'link':
  7366. trapBubbledEvent(TOP_ERROR, domElement);
  7367. trapBubbledEvent(TOP_LOAD, domElement);
  7368. break;
  7369. case 'form':
  7370. trapBubbledEvent(TOP_RESET, domElement);
  7371. trapBubbledEvent(TOP_SUBMIT, domElement);
  7372. break;
  7373. case 'details':
  7374. trapBubbledEvent(TOP_TOGGLE, domElement);
  7375. break;
  7376. case 'input':
  7377. initWrapperState(domElement, rawProps);
  7378. trapBubbledEvent(TOP_INVALID, domElement);
  7379. // For controlled components we always need to ensure we're listening
  7380. // to onChange. Even if there is no listener.
  7381. ensureListeningTo(rootContainerElement, 'onChange');
  7382. break;
  7383. case 'option':
  7384. validateProps(domElement, rawProps);
  7385. break;
  7386. case 'select':
  7387. initWrapperState$1(domElement, rawProps);
  7388. trapBubbledEvent(TOP_INVALID, domElement);
  7389. // For controlled components we always need to ensure we're listening
  7390. // to onChange. Even if there is no listener.
  7391. ensureListeningTo(rootContainerElement, 'onChange');
  7392. break;
  7393. case 'textarea':
  7394. initWrapperState$2(domElement, rawProps);
  7395. trapBubbledEvent(TOP_INVALID, domElement);
  7396. // For controlled components we always need to ensure we're listening
  7397. // to onChange. Even if there is no listener.
  7398. ensureListeningTo(rootContainerElement, 'onChange');
  7399. break;
  7400. }
  7401. assertValidProps(tag, rawProps);
  7402. {
  7403. extraAttributeNames = new Set();
  7404. var attributes = domElement.attributes;
  7405. for (var _i = 0; _i < attributes.length; _i++) {
  7406. var name = attributes[_i].name.toLowerCase();
  7407. switch (name) {
  7408. // Built-in SSR attribute is whitelisted
  7409. case 'data-reactroot':
  7410. break;
  7411. // Controlled attributes are not validated
  7412. // TODO: Only ignore them on controlled tags.
  7413. case 'value':
  7414. break;
  7415. case 'checked':
  7416. break;
  7417. case 'selected':
  7418. break;
  7419. default:
  7420. // Intentionally use the original name.
  7421. // See discussion in https://github.com/facebook/react/pull/10676.
  7422. extraAttributeNames.add(attributes[_i].name);
  7423. }
  7424. }
  7425. }
  7426. var updatePayload = null;
  7427. for (var propKey in rawProps) {
  7428. if (!rawProps.hasOwnProperty(propKey)) {
  7429. continue;
  7430. }
  7431. var nextProp = rawProps[propKey];
  7432. if (propKey === CHILDREN) {
  7433. // For text content children we compare against textContent. This
  7434. // might match additional HTML that is hidden when we read it using
  7435. // textContent. E.g. "foo" will match "f<span>oo</span>" but that still
  7436. // satisfies our requirement. Our requirement is not to produce perfect
  7437. // HTML and attributes. Ideally we should preserve structure but it's
  7438. // ok not to if the visible content is still enough to indicate what
  7439. // even listeners these nodes might be wired up to.
  7440. // TODO: Warn if there is more than a single textNode as a child.
  7441. // TODO: Should we use domElement.firstChild.nodeValue to compare?
  7442. if (typeof nextProp === 'string') {
  7443. if (domElement.textContent !== nextProp) {
  7444. if ( true && !suppressHydrationWarning) {
  7445. warnForTextDifference(domElement.textContent, nextProp);
  7446. }
  7447. updatePayload = [CHILDREN, nextProp];
  7448. }
  7449. } else if (typeof nextProp === 'number') {
  7450. if (domElement.textContent !== '' + nextProp) {
  7451. if ( true && !suppressHydrationWarning) {
  7452. warnForTextDifference(domElement.textContent, nextProp);
  7453. }
  7454. updatePayload = [CHILDREN, '' + nextProp];
  7455. }
  7456. }
  7457. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  7458. if (nextProp != null) {
  7459. if ( true && typeof nextProp !== 'function') {
  7460. warnForInvalidEventListener(propKey, nextProp);
  7461. }
  7462. ensureListeningTo(rootContainerElement, propKey);
  7463. }
  7464. } else if ( true &&
  7465. // Convince Flow we've calculated it (it's DEV-only in this method.)
  7466. typeof isCustomComponentTag === 'boolean') {
  7467. // Validate that the properties correspond to their expected values.
  7468. var serverValue = void 0;
  7469. var propertyInfo = getPropertyInfo(propKey);
  7470. if (suppressHydrationWarning) {
  7471. // Don't bother comparing. We're ignoring all these warnings.
  7472. } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1 ||
  7473. // Controlled attributes are not validated
  7474. // TODO: Only ignore them on controlled tags.
  7475. propKey === 'value' || propKey === 'checked' || propKey === 'selected') {
  7476. // Noop
  7477. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  7478. var serverHTML = domElement.innerHTML;
  7479. var nextHtml = nextProp ? nextProp[HTML] : undefined;
  7480. var expectedHTML = normalizeHTML(domElement, nextHtml != null ? nextHtml : '');
  7481. if (expectedHTML !== serverHTML) {
  7482. warnForPropDifference(propKey, serverHTML, expectedHTML);
  7483. }
  7484. } else if (propKey === STYLE$1) {
  7485. // $FlowFixMe - Should be inferred as not undefined.
  7486. extraAttributeNames.delete(propKey);
  7487. if (canDiffStyleForHydrationWarning) {
  7488. var expectedStyle = createDangerousStringForStyles(nextProp);
  7489. serverValue = domElement.getAttribute('style');
  7490. if (expectedStyle !== serverValue) {
  7491. warnForPropDifference(propKey, serverValue, expectedStyle);
  7492. }
  7493. }
  7494. } else if (isCustomComponentTag) {
  7495. // $FlowFixMe - Should be inferred as not undefined.
  7496. extraAttributeNames.delete(propKey.toLowerCase());
  7497. serverValue = getValueForAttribute(domElement, propKey, nextProp);
  7498. if (nextProp !== serverValue) {
  7499. warnForPropDifference(propKey, serverValue, nextProp);
  7500. }
  7501. } else if (!shouldIgnoreAttribute(propKey, propertyInfo, isCustomComponentTag) && !shouldRemoveAttribute(propKey, nextProp, propertyInfo, isCustomComponentTag)) {
  7502. var isMismatchDueToBadCasing = false;
  7503. if (propertyInfo !== null) {
  7504. // $FlowFixMe - Should be inferred as not undefined.
  7505. extraAttributeNames.delete(propertyInfo.attributeName);
  7506. serverValue = getValueForProperty(domElement, propKey, nextProp, propertyInfo);
  7507. } else {
  7508. var ownNamespace = parentNamespace;
  7509. if (ownNamespace === HTML_NAMESPACE) {
  7510. ownNamespace = getIntrinsicNamespace(tag);
  7511. }
  7512. if (ownNamespace === HTML_NAMESPACE) {
  7513. // $FlowFixMe - Should be inferred as not undefined.
  7514. extraAttributeNames.delete(propKey.toLowerCase());
  7515. } else {
  7516. var standardName = getPossibleStandardName(propKey);
  7517. if (standardName !== null && standardName !== propKey) {
  7518. // If an SVG prop is supplied with bad casing, it will
  7519. // be successfully parsed from HTML, but will produce a mismatch
  7520. // (and would be incorrectly rendered on the client).
  7521. // However, we already warn about bad casing elsewhere.
  7522. // So we'll skip the misleading extra mismatch warning in this case.
  7523. isMismatchDueToBadCasing = true;
  7524. // $FlowFixMe - Should be inferred as not undefined.
  7525. extraAttributeNames.delete(standardName);
  7526. }
  7527. // $FlowFixMe - Should be inferred as not undefined.
  7528. extraAttributeNames.delete(propKey);
  7529. }
  7530. serverValue = getValueForAttribute(domElement, propKey, nextProp);
  7531. }
  7532. if (nextProp !== serverValue && !isMismatchDueToBadCasing) {
  7533. warnForPropDifference(propKey, serverValue, nextProp);
  7534. }
  7535. }
  7536. }
  7537. }
  7538. {
  7539. // $FlowFixMe - Should be inferred as not undefined.
  7540. if (extraAttributeNames.size > 0 && !suppressHydrationWarning) {
  7541. // $FlowFixMe - Should be inferred as not undefined.
  7542. warnForExtraAttributes(extraAttributeNames);
  7543. }
  7544. }
  7545. switch (tag) {
  7546. case 'input':
  7547. // TODO: Make sure we check if this is still unmounted or do any clean
  7548. // up necessary since we never stop tracking anymore.
  7549. track(domElement);
  7550. postMountWrapper(domElement, rawProps, true);
  7551. break;
  7552. case 'textarea':
  7553. // TODO: Make sure we check if this is still unmounted or do any clean
  7554. // up necessary since we never stop tracking anymore.
  7555. track(domElement);
  7556. postMountWrapper$3(domElement, rawProps);
  7557. break;
  7558. case 'select':
  7559. case 'option':
  7560. // For input and textarea we current always set the value property at
  7561. // post mount to force it to diverge from attributes. However, for
  7562. // option and select we don't quite do the same thing and select
  7563. // is not resilient to the DOM state changing so we don't do that here.
  7564. // TODO: Consider not doing this for input and textarea.
  7565. break;
  7566. default:
  7567. if (typeof rawProps.onClick === 'function') {
  7568. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  7569. trapClickOnNonInteractiveElement(domElement);
  7570. }
  7571. break;
  7572. }
  7573. return updatePayload;
  7574. }
  7575. function diffHydratedText(textNode, text) {
  7576. var isDifferent = textNode.nodeValue !== text;
  7577. return isDifferent;
  7578. }
  7579. function warnForUnmatchedText(textNode, text) {
  7580. {
  7581. warnForTextDifference(textNode.nodeValue, text);
  7582. }
  7583. }
  7584. function warnForDeletedHydratableElement(parentNode, child) {
  7585. {
  7586. if (didWarnInvalidHydration) {
  7587. return;
  7588. }
  7589. didWarnInvalidHydration = true;
  7590. warningWithoutStack$1(false, 'Did not expect server HTML to contain a <%s> in <%s>.', child.nodeName.toLowerCase(), parentNode.nodeName.toLowerCase());
  7591. }
  7592. }
  7593. function warnForDeletedHydratableText(parentNode, child) {
  7594. {
  7595. if (didWarnInvalidHydration) {
  7596. return;
  7597. }
  7598. didWarnInvalidHydration = true;
  7599. warningWithoutStack$1(false, 'Did not expect server HTML to contain the text node "%s" in <%s>.', child.nodeValue, parentNode.nodeName.toLowerCase());
  7600. }
  7601. }
  7602. function warnForInsertedHydratedElement(parentNode, tag, props) {
  7603. {
  7604. if (didWarnInvalidHydration) {
  7605. return;
  7606. }
  7607. didWarnInvalidHydration = true;
  7608. warningWithoutStack$1(false, 'Expected server HTML to contain a matching <%s> in <%s>.', tag, parentNode.nodeName.toLowerCase());
  7609. }
  7610. }
  7611. function warnForInsertedHydratedText(parentNode, text) {
  7612. {
  7613. if (text === '') {
  7614. // We expect to insert empty text nodes since they're not represented in
  7615. // the HTML.
  7616. // TODO: Remove this special case if we can just avoid inserting empty
  7617. // text nodes.
  7618. return;
  7619. }
  7620. if (didWarnInvalidHydration) {
  7621. return;
  7622. }
  7623. didWarnInvalidHydration = true;
  7624. warningWithoutStack$1(false, 'Expected server HTML to contain a matching text node for "%s" in <%s>.', text, parentNode.nodeName.toLowerCase());
  7625. }
  7626. }
  7627. function restoreControlledState$1(domElement, tag, props) {
  7628. switch (tag) {
  7629. case 'input':
  7630. restoreControlledState(domElement, props);
  7631. return;
  7632. case 'textarea':
  7633. restoreControlledState$3(domElement, props);
  7634. return;
  7635. case 'select':
  7636. restoreControlledState$2(domElement, props);
  7637. return;
  7638. }
  7639. }
  7640. // TODO: direct imports like some-package/src/* are bad. Fix me.
  7641. var validateDOMNesting = function () {};
  7642. var updatedAncestorInfo = function () {};
  7643. {
  7644. // This validation code was written based on the HTML5 parsing spec:
  7645. // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope
  7646. //
  7647. // Note: this does not catch all invalid nesting, nor does it try to (as it's
  7648. // not clear what practical benefit doing so provides); instead, we warn only
  7649. // for cases where the parser will give a parse tree differing from what React
  7650. // intended. For example, <b><div></div></b> is invalid but we don't warn
  7651. // because it still parses correctly; we do warn for other cases like nested
  7652. // <p> tags where the beginning of the second element implicitly closes the
  7653. // first, causing a confusing mess.
  7654. // https://html.spec.whatwg.org/multipage/syntax.html#special
  7655. 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'];
  7656. // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope
  7657. var inScopeTags = ['applet', 'caption', 'html', 'table', 'td', 'th', 'marquee', 'object', 'template',
  7658. // https://html.spec.whatwg.org/multipage/syntax.html#html-integration-point
  7659. // TODO: Distinguish by namespace here -- for <title>, including it here
  7660. // errs on the side of fewer warnings
  7661. 'foreignObject', 'desc', 'title'];
  7662. // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-button-scope
  7663. var buttonScopeTags = inScopeTags.concat(['button']);
  7664. // https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags
  7665. var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt'];
  7666. var emptyAncestorInfo = {
  7667. current: null,
  7668. formTag: null,
  7669. aTagInScope: null,
  7670. buttonTagInScope: null,
  7671. nobrTagInScope: null,
  7672. pTagInButtonScope: null,
  7673. listItemTagAutoclosing: null,
  7674. dlItemTagAutoclosing: null
  7675. };
  7676. updatedAncestorInfo = function (oldInfo, tag) {
  7677. var ancestorInfo = _assign({}, oldInfo || emptyAncestorInfo);
  7678. var info = { tag: tag };
  7679. if (inScopeTags.indexOf(tag) !== -1) {
  7680. ancestorInfo.aTagInScope = null;
  7681. ancestorInfo.buttonTagInScope = null;
  7682. ancestorInfo.nobrTagInScope = null;
  7683. }
  7684. if (buttonScopeTags.indexOf(tag) !== -1) {
  7685. ancestorInfo.pTagInButtonScope = null;
  7686. }
  7687. // See rules for 'li', 'dd', 'dt' start tags in
  7688. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
  7689. if (specialTags.indexOf(tag) !== -1 && tag !== 'address' && tag !== 'div' && tag !== 'p') {
  7690. ancestorInfo.listItemTagAutoclosing = null;
  7691. ancestorInfo.dlItemTagAutoclosing = null;
  7692. }
  7693. ancestorInfo.current = info;
  7694. if (tag === 'form') {
  7695. ancestorInfo.formTag = info;
  7696. }
  7697. if (tag === 'a') {
  7698. ancestorInfo.aTagInScope = info;
  7699. }
  7700. if (tag === 'button') {
  7701. ancestorInfo.buttonTagInScope = info;
  7702. }
  7703. if (tag === 'nobr') {
  7704. ancestorInfo.nobrTagInScope = info;
  7705. }
  7706. if (tag === 'p') {
  7707. ancestorInfo.pTagInButtonScope = info;
  7708. }
  7709. if (tag === 'li') {
  7710. ancestorInfo.listItemTagAutoclosing = info;
  7711. }
  7712. if (tag === 'dd' || tag === 'dt') {
  7713. ancestorInfo.dlItemTagAutoclosing = info;
  7714. }
  7715. return ancestorInfo;
  7716. };
  7717. /**
  7718. * Returns whether
  7719. */
  7720. var isTagValidWithParent = function (tag, parentTag) {
  7721. // First, let's check if we're in an unusual parsing mode...
  7722. switch (parentTag) {
  7723. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect
  7724. case 'select':
  7725. return tag === 'option' || tag === 'optgroup' || tag === '#text';
  7726. case 'optgroup':
  7727. return tag === 'option' || tag === '#text';
  7728. // Strictly speaking, seeing an <option> doesn't mean we're in a <select>
  7729. // but
  7730. case 'option':
  7731. return tag === '#text';
  7732. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd
  7733. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption
  7734. // No special behavior since these rules fall back to "in body" mode for
  7735. // all except special table nodes which cause bad parsing behavior anyway.
  7736. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr
  7737. case 'tr':
  7738. return tag === 'th' || tag === 'td' || tag === 'style' || tag === 'script' || tag === 'template';
  7739. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody
  7740. case 'tbody':
  7741. case 'thead':
  7742. case 'tfoot':
  7743. return tag === 'tr' || tag === 'style' || tag === 'script' || tag === 'template';
  7744. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup
  7745. case 'colgroup':
  7746. return tag === 'col' || tag === 'template';
  7747. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable
  7748. case 'table':
  7749. return tag === 'caption' || tag === 'colgroup' || tag === 'tbody' || tag === 'tfoot' || tag === 'thead' || tag === 'style' || tag === 'script' || tag === 'template';
  7750. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead
  7751. case 'head':
  7752. return tag === 'base' || tag === 'basefont' || tag === 'bgsound' || tag === 'link' || tag === 'meta' || tag === 'title' || tag === 'noscript' || tag === 'noframes' || tag === 'style' || tag === 'script' || tag === 'template';
  7753. // https://html.spec.whatwg.org/multipage/semantics.html#the-html-element
  7754. case 'html':
  7755. return tag === 'head' || tag === 'body';
  7756. case '#document':
  7757. return tag === 'html';
  7758. }
  7759. // Probably in the "in body" parsing mode, so we outlaw only tag combos
  7760. // where the parsing rules cause implicit opens or closes to be added.
  7761. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
  7762. switch (tag) {
  7763. case 'h1':
  7764. case 'h2':
  7765. case 'h3':
  7766. case 'h4':
  7767. case 'h5':
  7768. case 'h6':
  7769. return parentTag !== 'h1' && parentTag !== 'h2' && parentTag !== 'h3' && parentTag !== 'h4' && parentTag !== 'h5' && parentTag !== 'h6';
  7770. case 'rp':
  7771. case 'rt':
  7772. return impliedEndTags.indexOf(parentTag) === -1;
  7773. case 'body':
  7774. case 'caption':
  7775. case 'col':
  7776. case 'colgroup':
  7777. case 'frame':
  7778. case 'head':
  7779. case 'html':
  7780. case 'tbody':
  7781. case 'td':
  7782. case 'tfoot':
  7783. case 'th':
  7784. case 'thead':
  7785. case 'tr':
  7786. // These tags are only valid with a few parents that have special child
  7787. // parsing rules -- if we're down here, then none of those matched and
  7788. // so we allow it only if we don't know what the parent is, as all other
  7789. // cases are invalid.
  7790. return parentTag == null;
  7791. }
  7792. return true;
  7793. };
  7794. /**
  7795. * Returns whether
  7796. */
  7797. var findInvalidAncestorForTag = function (tag, ancestorInfo) {
  7798. switch (tag) {
  7799. case 'address':
  7800. case 'article':
  7801. case 'aside':
  7802. case 'blockquote':
  7803. case 'center':
  7804. case 'details':
  7805. case 'dialog':
  7806. case 'dir':
  7807. case 'div':
  7808. case 'dl':
  7809. case 'fieldset':
  7810. case 'figcaption':
  7811. case 'figure':
  7812. case 'footer':
  7813. case 'header':
  7814. case 'hgroup':
  7815. case 'main':
  7816. case 'menu':
  7817. case 'nav':
  7818. case 'ol':
  7819. case 'p':
  7820. case 'section':
  7821. case 'summary':
  7822. case 'ul':
  7823. case 'pre':
  7824. case 'listing':
  7825. case 'table':
  7826. case 'hr':
  7827. case 'xmp':
  7828. case 'h1':
  7829. case 'h2':
  7830. case 'h3':
  7831. case 'h4':
  7832. case 'h5':
  7833. case 'h6':
  7834. return ancestorInfo.pTagInButtonScope;
  7835. case 'form':
  7836. return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope;
  7837. case 'li':
  7838. return ancestorInfo.listItemTagAutoclosing;
  7839. case 'dd':
  7840. case 'dt':
  7841. return ancestorInfo.dlItemTagAutoclosing;
  7842. case 'button':
  7843. return ancestorInfo.buttonTagInScope;
  7844. case 'a':
  7845. // Spec says something about storing a list of markers, but it sounds
  7846. // equivalent to this check.
  7847. return ancestorInfo.aTagInScope;
  7848. case 'nobr':
  7849. return ancestorInfo.nobrTagInScope;
  7850. }
  7851. return null;
  7852. };
  7853. var didWarn = {};
  7854. validateDOMNesting = function (childTag, childText, ancestorInfo) {
  7855. ancestorInfo = ancestorInfo || emptyAncestorInfo;
  7856. var parentInfo = ancestorInfo.current;
  7857. var parentTag = parentInfo && parentInfo.tag;
  7858. if (childText != null) {
  7859. !(childTag == null) ? warningWithoutStack$1(false, 'validateDOMNesting: when childText is passed, childTag should be null') : void 0;
  7860. childTag = '#text';
  7861. }
  7862. var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo;
  7863. var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo);
  7864. var invalidParentOrAncestor = invalidParent || invalidAncestor;
  7865. if (!invalidParentOrAncestor) {
  7866. return;
  7867. }
  7868. var ancestorTag = invalidParentOrAncestor.tag;
  7869. var addendum = getCurrentFiberStackInDev();
  7870. var warnKey = !!invalidParent + '|' + childTag + '|' + ancestorTag + '|' + addendum;
  7871. if (didWarn[warnKey]) {
  7872. return;
  7873. }
  7874. didWarn[warnKey] = true;
  7875. var tagDisplayName = childTag;
  7876. var whitespaceInfo = '';
  7877. if (childTag === '#text') {
  7878. if (/\S/.test(childText)) {
  7879. tagDisplayName = 'Text nodes';
  7880. } else {
  7881. tagDisplayName = 'Whitespace text nodes';
  7882. whitespaceInfo = " Make sure you don't have any extra whitespace between tags on " + 'each line of your source code.';
  7883. }
  7884. } else {
  7885. tagDisplayName = '<' + childTag + '>';
  7886. }
  7887. if (invalidParent) {
  7888. var info = '';
  7889. if (ancestorTag === 'table' && childTag === 'tr') {
  7890. info += ' Add a <tbody> to your code to match the DOM tree generated by ' + 'the browser.';
  7891. }
  7892. warningWithoutStack$1(false, 'validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s%s', tagDisplayName, ancestorTag, whitespaceInfo, info, addendum);
  7893. } else {
  7894. warningWithoutStack$1(false, 'validateDOMNesting(...): %s cannot appear as a descendant of ' + '<%s>.%s', tagDisplayName, ancestorTag, addendum);
  7895. }
  7896. };
  7897. }
  7898. // Renderers that don't support persistence
  7899. // can re-export everything from this module.
  7900. function shim() {
  7901. invariant(false, 'The current renderer does not support persistence. This error is likely caused by a bug in React. Please file an issue.');
  7902. }
  7903. // Persistence (when unsupported)
  7904. var supportsPersistence = false;
  7905. var cloneInstance = shim;
  7906. var createContainerChildSet = shim;
  7907. var appendChildToContainerChildSet = shim;
  7908. var finalizeContainerChildren = shim;
  7909. var replaceContainerChildren = shim;
  7910. var cloneHiddenInstance = shim;
  7911. var cloneUnhiddenInstance = shim;
  7912. var createHiddenTextInstance = shim;
  7913. var SUPPRESS_HYDRATION_WARNING = void 0;
  7914. {
  7915. SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning';
  7916. }
  7917. var STYLE = 'style';
  7918. var eventsEnabled = null;
  7919. var selectionInformation = null;
  7920. function shouldAutoFocusHostComponent(type, props) {
  7921. switch (type) {
  7922. case 'button':
  7923. case 'input':
  7924. case 'select':
  7925. case 'textarea':
  7926. return !!props.autoFocus;
  7927. }
  7928. return false;
  7929. }
  7930. function getRootHostContext(rootContainerInstance) {
  7931. var type = void 0;
  7932. var namespace = void 0;
  7933. var nodeType = rootContainerInstance.nodeType;
  7934. switch (nodeType) {
  7935. case DOCUMENT_NODE:
  7936. case DOCUMENT_FRAGMENT_NODE:
  7937. {
  7938. type = nodeType === DOCUMENT_NODE ? '#document' : '#fragment';
  7939. var root = rootContainerInstance.documentElement;
  7940. namespace = root ? root.namespaceURI : getChildNamespace(null, '');
  7941. break;
  7942. }
  7943. default:
  7944. {
  7945. var container = nodeType === COMMENT_NODE ? rootContainerInstance.parentNode : rootContainerInstance;
  7946. var ownNamespace = container.namespaceURI || null;
  7947. type = container.tagName;
  7948. namespace = getChildNamespace(ownNamespace, type);
  7949. break;
  7950. }
  7951. }
  7952. {
  7953. var validatedTag = type.toLowerCase();
  7954. var _ancestorInfo = updatedAncestorInfo(null, validatedTag);
  7955. return { namespace: namespace, ancestorInfo: _ancestorInfo };
  7956. }
  7957. return namespace;
  7958. }
  7959. function getChildHostContext(parentHostContext, type, rootContainerInstance) {
  7960. {
  7961. var parentHostContextDev = parentHostContext;
  7962. var _namespace = getChildNamespace(parentHostContextDev.namespace, type);
  7963. var _ancestorInfo2 = updatedAncestorInfo(parentHostContextDev.ancestorInfo, type);
  7964. return { namespace: _namespace, ancestorInfo: _ancestorInfo2 };
  7965. }
  7966. var parentNamespace = parentHostContext;
  7967. return getChildNamespace(parentNamespace, type);
  7968. }
  7969. function getPublicInstance(instance) {
  7970. return instance;
  7971. }
  7972. function prepareForCommit(containerInfo) {
  7973. eventsEnabled = isEnabled();
  7974. selectionInformation = getSelectionInformation();
  7975. setEnabled(false);
  7976. }
  7977. function resetAfterCommit(containerInfo) {
  7978. restoreSelection(selectionInformation);
  7979. selectionInformation = null;
  7980. setEnabled(eventsEnabled);
  7981. eventsEnabled = null;
  7982. }
  7983. function createInstance(type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
  7984. var parentNamespace = void 0;
  7985. {
  7986. // TODO: take namespace into account when validating.
  7987. var hostContextDev = hostContext;
  7988. validateDOMNesting(type, null, hostContextDev.ancestorInfo);
  7989. if (typeof props.children === 'string' || typeof props.children === 'number') {
  7990. var string = '' + props.children;
  7991. var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type);
  7992. validateDOMNesting(null, string, ownAncestorInfo);
  7993. }
  7994. parentNamespace = hostContextDev.namespace;
  7995. }
  7996. var domElement = createElement(type, props, rootContainerInstance, parentNamespace);
  7997. precacheFiberNode(internalInstanceHandle, domElement);
  7998. updateFiberProps(domElement, props);
  7999. return domElement;
  8000. }
  8001. function appendInitialChild(parentInstance, child) {
  8002. parentInstance.appendChild(child);
  8003. }
  8004. function finalizeInitialChildren(domElement, type, props, rootContainerInstance, hostContext) {
  8005. setInitialProperties(domElement, type, props, rootContainerInstance);
  8006. return shouldAutoFocusHostComponent(type, props);
  8007. }
  8008. function prepareUpdate(domElement, type, oldProps, newProps, rootContainerInstance, hostContext) {
  8009. {
  8010. var hostContextDev = hostContext;
  8011. if (typeof newProps.children !== typeof oldProps.children && (typeof newProps.children === 'string' || typeof newProps.children === 'number')) {
  8012. var string = '' + newProps.children;
  8013. var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type);
  8014. validateDOMNesting(null, string, ownAncestorInfo);
  8015. }
  8016. }
  8017. return diffProperties(domElement, type, oldProps, newProps, rootContainerInstance);
  8018. }
  8019. function shouldSetTextContent(type, props) {
  8020. 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;
  8021. }
  8022. function shouldDeprioritizeSubtree(type, props) {
  8023. return !!props.hidden;
  8024. }
  8025. function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) {
  8026. {
  8027. var hostContextDev = hostContext;
  8028. validateDOMNesting(null, text, hostContextDev.ancestorInfo);
  8029. }
  8030. var textNode = createTextNode(text, rootContainerInstance);
  8031. precacheFiberNode(internalInstanceHandle, textNode);
  8032. return textNode;
  8033. }
  8034. var isPrimaryRenderer = true;
  8035. // This initialization code may run even on server environments
  8036. // if a component just imports ReactDOM (e.g. for findDOMNode).
  8037. // Some environments might not have setTimeout or clearTimeout.
  8038. var scheduleTimeout = typeof setTimeout === 'function' ? setTimeout : undefined;
  8039. var cancelTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined;
  8040. var noTimeout = -1;
  8041. // -------------------
  8042. // Mutation
  8043. // -------------------
  8044. var supportsMutation = true;
  8045. function commitMount(domElement, type, newProps, internalInstanceHandle) {
  8046. // Despite the naming that might imply otherwise, this method only
  8047. // fires if there is an `Update` effect scheduled during mounting.
  8048. // This happens if `finalizeInitialChildren` returns `true` (which it
  8049. // does to implement the `autoFocus` attribute on the client). But
  8050. // there are also other cases when this might happen (such as patching
  8051. // up text content during hydration mismatch). So we'll check this again.
  8052. if (shouldAutoFocusHostComponent(type, newProps)) {
  8053. domElement.focus();
  8054. }
  8055. }
  8056. function commitUpdate(domElement, updatePayload, type, oldProps, newProps, internalInstanceHandle) {
  8057. // Update the props handle so that we know which props are the ones with
  8058. // with current event handlers.
  8059. updateFiberProps(domElement, newProps);
  8060. // Apply the diff to the DOM node.
  8061. updateProperties(domElement, updatePayload, type, oldProps, newProps);
  8062. }
  8063. function resetTextContent(domElement) {
  8064. setTextContent(domElement, '');
  8065. }
  8066. function commitTextUpdate(textInstance, oldText, newText) {
  8067. textInstance.nodeValue = newText;
  8068. }
  8069. function appendChild(parentInstance, child) {
  8070. parentInstance.appendChild(child);
  8071. }
  8072. function appendChildToContainer(container, child) {
  8073. var parentNode = void 0;
  8074. if (container.nodeType === COMMENT_NODE) {
  8075. parentNode = container.parentNode;
  8076. parentNode.insertBefore(child, container);
  8077. } else {
  8078. parentNode = container;
  8079. parentNode.appendChild(child);
  8080. }
  8081. // This container might be used for a portal.
  8082. // If something inside a portal is clicked, that click should bubble
  8083. // through the React tree. However, on Mobile Safari the click would
  8084. // never bubble through the *DOM* tree unless an ancestor with onclick
  8085. // event exists. So we wouldn't see it and dispatch it.
  8086. // This is why we ensure that non React root containers have inline onclick
  8087. // defined.
  8088. // https://github.com/facebook/react/issues/11918
  8089. var reactRootContainer = container._reactRootContainer;
  8090. if ((reactRootContainer === null || reactRootContainer === undefined) && parentNode.onclick === null) {
  8091. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  8092. trapClickOnNonInteractiveElement(parentNode);
  8093. }
  8094. }
  8095. function insertBefore(parentInstance, child, beforeChild) {
  8096. parentInstance.insertBefore(child, beforeChild);
  8097. }
  8098. function insertInContainerBefore(container, child, beforeChild) {
  8099. if (container.nodeType === COMMENT_NODE) {
  8100. container.parentNode.insertBefore(child, beforeChild);
  8101. } else {
  8102. container.insertBefore(child, beforeChild);
  8103. }
  8104. }
  8105. function removeChild(parentInstance, child) {
  8106. parentInstance.removeChild(child);
  8107. }
  8108. function removeChildFromContainer(container, child) {
  8109. if (container.nodeType === COMMENT_NODE) {
  8110. container.parentNode.removeChild(child);
  8111. } else {
  8112. container.removeChild(child);
  8113. }
  8114. }
  8115. function hideInstance(instance) {
  8116. // TODO: Does this work for all element types? What about MathML? Should we
  8117. // pass host context to this method?
  8118. instance = instance;
  8119. instance.style.display = 'none';
  8120. }
  8121. function hideTextInstance(textInstance) {
  8122. textInstance.nodeValue = '';
  8123. }
  8124. function unhideInstance(instance, props) {
  8125. instance = instance;
  8126. var styleProp = props[STYLE];
  8127. var display = styleProp !== undefined && styleProp !== null && styleProp.hasOwnProperty('display') ? styleProp.display : null;
  8128. instance.style.display = dangerousStyleValue('display', display);
  8129. }
  8130. function unhideTextInstance(textInstance, text) {
  8131. textInstance.nodeValue = text;
  8132. }
  8133. // -------------------
  8134. // Hydration
  8135. // -------------------
  8136. var supportsHydration = true;
  8137. function canHydrateInstance(instance, type, props) {
  8138. if (instance.nodeType !== ELEMENT_NODE || type.toLowerCase() !== instance.nodeName.toLowerCase()) {
  8139. return null;
  8140. }
  8141. // This has now been refined to an element node.
  8142. return instance;
  8143. }
  8144. function canHydrateTextInstance(instance, text) {
  8145. if (text === '' || instance.nodeType !== TEXT_NODE) {
  8146. // Empty strings are not parsed by HTML so there won't be a correct match here.
  8147. return null;
  8148. }
  8149. // This has now been refined to a text node.
  8150. return instance;
  8151. }
  8152. function getNextHydratableSibling(instance) {
  8153. var node = instance.nextSibling;
  8154. // Skip non-hydratable nodes.
  8155. while (node && node.nodeType !== ELEMENT_NODE && node.nodeType !== TEXT_NODE) {
  8156. node = node.nextSibling;
  8157. }
  8158. return node;
  8159. }
  8160. function getFirstHydratableChild(parentInstance) {
  8161. var next = parentInstance.firstChild;
  8162. // Skip non-hydratable nodes.
  8163. while (next && next.nodeType !== ELEMENT_NODE && next.nodeType !== TEXT_NODE) {
  8164. next = next.nextSibling;
  8165. }
  8166. return next;
  8167. }
  8168. function hydrateInstance(instance, type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
  8169. precacheFiberNode(internalInstanceHandle, instance);
  8170. // TODO: Possibly defer this until the commit phase where all the events
  8171. // get attached.
  8172. updateFiberProps(instance, props);
  8173. var parentNamespace = void 0;
  8174. {
  8175. var hostContextDev = hostContext;
  8176. parentNamespace = hostContextDev.namespace;
  8177. }
  8178. return diffHydratedProperties(instance, type, props, parentNamespace, rootContainerInstance);
  8179. }
  8180. function hydrateTextInstance(textInstance, text, internalInstanceHandle) {
  8181. precacheFiberNode(internalInstanceHandle, textInstance);
  8182. return diffHydratedText(textInstance, text);
  8183. }
  8184. function didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, text) {
  8185. {
  8186. warnForUnmatchedText(textInstance, text);
  8187. }
  8188. }
  8189. function didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, text) {
  8190. if ( true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  8191. warnForUnmatchedText(textInstance, text);
  8192. }
  8193. }
  8194. function didNotHydrateContainerInstance(parentContainer, instance) {
  8195. {
  8196. if (instance.nodeType === ELEMENT_NODE) {
  8197. warnForDeletedHydratableElement(parentContainer, instance);
  8198. } else {
  8199. warnForDeletedHydratableText(parentContainer, instance);
  8200. }
  8201. }
  8202. }
  8203. function didNotHydrateInstance(parentType, parentProps, parentInstance, instance) {
  8204. if ( true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  8205. if (instance.nodeType === ELEMENT_NODE) {
  8206. warnForDeletedHydratableElement(parentInstance, instance);
  8207. } else {
  8208. warnForDeletedHydratableText(parentInstance, instance);
  8209. }
  8210. }
  8211. }
  8212. function didNotFindHydratableContainerInstance(parentContainer, type, props) {
  8213. {
  8214. warnForInsertedHydratedElement(parentContainer, type, props);
  8215. }
  8216. }
  8217. function didNotFindHydratableContainerTextInstance(parentContainer, text) {
  8218. {
  8219. warnForInsertedHydratedText(parentContainer, text);
  8220. }
  8221. }
  8222. function didNotFindHydratableInstance(parentType, parentProps, parentInstance, type, props) {
  8223. if ( true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  8224. warnForInsertedHydratedElement(parentInstance, type, props);
  8225. }
  8226. }
  8227. function didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, text) {
  8228. if ( true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  8229. warnForInsertedHydratedText(parentInstance, text);
  8230. }
  8231. }
  8232. // Prefix measurements so that it's possible to filter them.
  8233. // Longer prefixes are hard to read in DevTools.
  8234. var reactEmoji = '\u269B';
  8235. var warningEmoji = '\u26D4';
  8236. var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';
  8237. // Keep track of current fiber so that we know the path to unwind on pause.
  8238. // TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them?
  8239. var currentFiber = null;
  8240. // If we're in the middle of user code, which fiber and method is it?
  8241. // Reusing `currentFiber` would be confusing for this because user code fiber
  8242. // can change during commit phase too, but we don't need to unwind it (since
  8243. // lifecycles in the commit phase don't resemble a tree).
  8244. var currentPhase = null;
  8245. var currentPhaseFiber = null;
  8246. // Did lifecycle hook schedule an update? This is often a performance problem,
  8247. // so we will keep track of it, and include it in the report.
  8248. // Track commits caused by cascading updates.
  8249. var isCommitting = false;
  8250. var hasScheduledUpdateInCurrentCommit = false;
  8251. var hasScheduledUpdateInCurrentPhase = false;
  8252. var commitCountInCurrentWorkLoop = 0;
  8253. var effectCountInCurrentCommit = 0;
  8254. var isWaitingForCallback = false;
  8255. // During commits, we only show a measurement once per method name
  8256. // to avoid stretch the commit phase with measurement overhead.
  8257. var labelsInCurrentCommit = new Set();
  8258. var formatMarkName = function (markName) {
  8259. return reactEmoji + ' ' + markName;
  8260. };
  8261. var formatLabel = function (label, warning) {
  8262. var prefix = warning ? warningEmoji + ' ' : reactEmoji + ' ';
  8263. var suffix = warning ? ' Warning: ' + warning : '';
  8264. return '' + prefix + label + suffix;
  8265. };
  8266. var beginMark = function (markName) {
  8267. performance.mark(formatMarkName(markName));
  8268. };
  8269. var clearMark = function (markName) {
  8270. performance.clearMarks(formatMarkName(markName));
  8271. };
  8272. var endMark = function (label, markName, warning) {
  8273. var formattedMarkName = formatMarkName(markName);
  8274. var formattedLabel = formatLabel(label, warning);
  8275. try {
  8276. performance.measure(formattedLabel, formattedMarkName);
  8277. } catch (err) {}
  8278. // If previous mark was missing for some reason, this will throw.
  8279. // This could only happen if React crashed in an unexpected place earlier.
  8280. // Don't pile on with more errors.
  8281. // Clear marks immediately to avoid growing buffer.
  8282. performance.clearMarks(formattedMarkName);
  8283. performance.clearMeasures(formattedLabel);
  8284. };
  8285. var getFiberMarkName = function (label, debugID) {
  8286. return label + ' (#' + debugID + ')';
  8287. };
  8288. var getFiberLabel = function (componentName, isMounted, phase) {
  8289. if (phase === null) {
  8290. // These are composite component total time measurements.
  8291. return componentName + ' [' + (isMounted ? 'update' : 'mount') + ']';
  8292. } else {
  8293. // Composite component methods.
  8294. return componentName + '.' + phase;
  8295. }
  8296. };
  8297. var beginFiberMark = function (fiber, phase) {
  8298. var componentName = getComponentName(fiber.type) || 'Unknown';
  8299. var debugID = fiber._debugID;
  8300. var isMounted = fiber.alternate !== null;
  8301. var label = getFiberLabel(componentName, isMounted, phase);
  8302. if (isCommitting && labelsInCurrentCommit.has(label)) {
  8303. // During the commit phase, we don't show duplicate labels because
  8304. // there is a fixed overhead for every measurement, and we don't
  8305. // want to stretch the commit phase beyond necessary.
  8306. return false;
  8307. }
  8308. labelsInCurrentCommit.add(label);
  8309. var markName = getFiberMarkName(label, debugID);
  8310. beginMark(markName);
  8311. return true;
  8312. };
  8313. var clearFiberMark = function (fiber, phase) {
  8314. var componentName = getComponentName(fiber.type) || 'Unknown';
  8315. var debugID = fiber._debugID;
  8316. var isMounted = fiber.alternate !== null;
  8317. var label = getFiberLabel(componentName, isMounted, phase);
  8318. var markName = getFiberMarkName(label, debugID);
  8319. clearMark(markName);
  8320. };
  8321. var endFiberMark = function (fiber, phase, warning) {
  8322. var componentName = getComponentName(fiber.type) || 'Unknown';
  8323. var debugID = fiber._debugID;
  8324. var isMounted = fiber.alternate !== null;
  8325. var label = getFiberLabel(componentName, isMounted, phase);
  8326. var markName = getFiberMarkName(label, debugID);
  8327. endMark(label, markName, warning);
  8328. };
  8329. var shouldIgnoreFiber = function (fiber) {
  8330. // Host components should be skipped in the timeline.
  8331. // We could check typeof fiber.type, but does this work with RN?
  8332. switch (fiber.tag) {
  8333. case HostRoot:
  8334. case HostComponent:
  8335. case HostText:
  8336. case HostPortal:
  8337. case Fragment:
  8338. case ContextProvider:
  8339. case ContextConsumer:
  8340. case Mode:
  8341. return true;
  8342. default:
  8343. return false;
  8344. }
  8345. };
  8346. var clearPendingPhaseMeasurement = function () {
  8347. if (currentPhase !== null && currentPhaseFiber !== null) {
  8348. clearFiberMark(currentPhaseFiber, currentPhase);
  8349. }
  8350. currentPhaseFiber = null;
  8351. currentPhase = null;
  8352. hasScheduledUpdateInCurrentPhase = false;
  8353. };
  8354. var pauseTimers = function () {
  8355. // Stops all currently active measurements so that they can be resumed
  8356. // if we continue in a later deferred loop from the same unit of work.
  8357. var fiber = currentFiber;
  8358. while (fiber) {
  8359. if (fiber._debugIsCurrentlyTiming) {
  8360. endFiberMark(fiber, null, null);
  8361. }
  8362. fiber = fiber.return;
  8363. }
  8364. };
  8365. var resumeTimersRecursively = function (fiber) {
  8366. if (fiber.return !== null) {
  8367. resumeTimersRecursively(fiber.return);
  8368. }
  8369. if (fiber._debugIsCurrentlyTiming) {
  8370. beginFiberMark(fiber, null);
  8371. }
  8372. };
  8373. var resumeTimers = function () {
  8374. // Resumes all measurements that were active during the last deferred loop.
  8375. if (currentFiber !== null) {
  8376. resumeTimersRecursively(currentFiber);
  8377. }
  8378. };
  8379. function recordEffect() {
  8380. if (enableUserTimingAPI) {
  8381. effectCountInCurrentCommit++;
  8382. }
  8383. }
  8384. function recordScheduleUpdate() {
  8385. if (enableUserTimingAPI) {
  8386. if (isCommitting) {
  8387. hasScheduledUpdateInCurrentCommit = true;
  8388. }
  8389. if (currentPhase !== null && currentPhase !== 'componentWillMount' && currentPhase !== 'componentWillReceiveProps') {
  8390. hasScheduledUpdateInCurrentPhase = true;
  8391. }
  8392. }
  8393. }
  8394. function startRequestCallbackTimer() {
  8395. if (enableUserTimingAPI) {
  8396. if (supportsUserTiming && !isWaitingForCallback) {
  8397. isWaitingForCallback = true;
  8398. beginMark('(Waiting for async callback...)');
  8399. }
  8400. }
  8401. }
  8402. function stopRequestCallbackTimer(didExpire, expirationTime) {
  8403. if (enableUserTimingAPI) {
  8404. if (supportsUserTiming) {
  8405. isWaitingForCallback = false;
  8406. var warning = didExpire ? 'React was blocked by main thread' : null;
  8407. endMark('(Waiting for async callback... will force flush in ' + expirationTime + ' ms)', '(Waiting for async callback...)', warning);
  8408. }
  8409. }
  8410. }
  8411. function startWorkTimer(fiber) {
  8412. if (enableUserTimingAPI) {
  8413. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  8414. return;
  8415. }
  8416. // If we pause, this is the fiber to unwind from.
  8417. currentFiber = fiber;
  8418. if (!beginFiberMark(fiber, null)) {
  8419. return;
  8420. }
  8421. fiber._debugIsCurrentlyTiming = true;
  8422. }
  8423. }
  8424. function cancelWorkTimer(fiber) {
  8425. if (enableUserTimingAPI) {
  8426. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  8427. return;
  8428. }
  8429. // Remember we shouldn't complete measurement for this fiber.
  8430. // Otherwise flamechart will be deep even for small updates.
  8431. fiber._debugIsCurrentlyTiming = false;
  8432. clearFiberMark(fiber, null);
  8433. }
  8434. }
  8435. function stopWorkTimer(fiber) {
  8436. if (enableUserTimingAPI) {
  8437. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  8438. return;
  8439. }
  8440. // If we pause, its parent is the fiber to unwind from.
  8441. currentFiber = fiber.return;
  8442. if (!fiber._debugIsCurrentlyTiming) {
  8443. return;
  8444. }
  8445. fiber._debugIsCurrentlyTiming = false;
  8446. endFiberMark(fiber, null, null);
  8447. }
  8448. }
  8449. function stopFailedWorkTimer(fiber) {
  8450. if (enableUserTimingAPI) {
  8451. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  8452. return;
  8453. }
  8454. // If we pause, its parent is the fiber to unwind from.
  8455. currentFiber = fiber.return;
  8456. if (!fiber._debugIsCurrentlyTiming) {
  8457. return;
  8458. }
  8459. fiber._debugIsCurrentlyTiming = false;
  8460. var warning = fiber.tag === SuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
  8461. endFiberMark(fiber, null, warning);
  8462. }
  8463. }
  8464. function startPhaseTimer(fiber, phase) {
  8465. if (enableUserTimingAPI) {
  8466. if (!supportsUserTiming) {
  8467. return;
  8468. }
  8469. clearPendingPhaseMeasurement();
  8470. if (!beginFiberMark(fiber, phase)) {
  8471. return;
  8472. }
  8473. currentPhaseFiber = fiber;
  8474. currentPhase = phase;
  8475. }
  8476. }
  8477. function stopPhaseTimer() {
  8478. if (enableUserTimingAPI) {
  8479. if (!supportsUserTiming) {
  8480. return;
  8481. }
  8482. if (currentPhase !== null && currentPhaseFiber !== null) {
  8483. var warning = hasScheduledUpdateInCurrentPhase ? 'Scheduled a cascading update' : null;
  8484. endFiberMark(currentPhaseFiber, currentPhase, warning);
  8485. }
  8486. currentPhase = null;
  8487. currentPhaseFiber = null;
  8488. }
  8489. }
  8490. function startWorkLoopTimer(nextUnitOfWork) {
  8491. if (enableUserTimingAPI) {
  8492. currentFiber = nextUnitOfWork;
  8493. if (!supportsUserTiming) {
  8494. return;
  8495. }
  8496. commitCountInCurrentWorkLoop = 0;
  8497. // This is top level call.
  8498. // Any other measurements are performed within.
  8499. beginMark('(React Tree Reconciliation)');
  8500. // Resume any measurements that were in progress during the last loop.
  8501. resumeTimers();
  8502. }
  8503. }
  8504. function stopWorkLoopTimer(interruptedBy, didCompleteRoot) {
  8505. if (enableUserTimingAPI) {
  8506. if (!supportsUserTiming) {
  8507. return;
  8508. }
  8509. var warning = null;
  8510. if (interruptedBy !== null) {
  8511. if (interruptedBy.tag === HostRoot) {
  8512. warning = 'A top-level update interrupted the previous render';
  8513. } else {
  8514. var componentName = getComponentName(interruptedBy.type) || 'Unknown';
  8515. warning = 'An update to ' + componentName + ' interrupted the previous render';
  8516. }
  8517. } else if (commitCountInCurrentWorkLoop > 1) {
  8518. warning = 'There were cascading updates';
  8519. }
  8520. commitCountInCurrentWorkLoop = 0;
  8521. var label = didCompleteRoot ? '(React Tree Reconciliation: Completed Root)' : '(React Tree Reconciliation: Yielded)';
  8522. // Pause any measurements until the next loop.
  8523. pauseTimers();
  8524. endMark(label, '(React Tree Reconciliation)', warning);
  8525. }
  8526. }
  8527. function startCommitTimer() {
  8528. if (enableUserTimingAPI) {
  8529. if (!supportsUserTiming) {
  8530. return;
  8531. }
  8532. isCommitting = true;
  8533. hasScheduledUpdateInCurrentCommit = false;
  8534. labelsInCurrentCommit.clear();
  8535. beginMark('(Committing Changes)');
  8536. }
  8537. }
  8538. function stopCommitTimer() {
  8539. if (enableUserTimingAPI) {
  8540. if (!supportsUserTiming) {
  8541. return;
  8542. }
  8543. var warning = null;
  8544. if (hasScheduledUpdateInCurrentCommit) {
  8545. warning = 'Lifecycle hook scheduled a cascading update';
  8546. } else if (commitCountInCurrentWorkLoop > 0) {
  8547. warning = 'Caused by a cascading update in earlier commit';
  8548. }
  8549. hasScheduledUpdateInCurrentCommit = false;
  8550. commitCountInCurrentWorkLoop++;
  8551. isCommitting = false;
  8552. labelsInCurrentCommit.clear();
  8553. endMark('(Committing Changes)', '(Committing Changes)', warning);
  8554. }
  8555. }
  8556. function startCommitSnapshotEffectsTimer() {
  8557. if (enableUserTimingAPI) {
  8558. if (!supportsUserTiming) {
  8559. return;
  8560. }
  8561. effectCountInCurrentCommit = 0;
  8562. beginMark('(Committing Snapshot Effects)');
  8563. }
  8564. }
  8565. function stopCommitSnapshotEffectsTimer() {
  8566. if (enableUserTimingAPI) {
  8567. if (!supportsUserTiming) {
  8568. return;
  8569. }
  8570. var count = effectCountInCurrentCommit;
  8571. effectCountInCurrentCommit = 0;
  8572. endMark('(Committing Snapshot Effects: ' + count + ' Total)', '(Committing Snapshot Effects)', null);
  8573. }
  8574. }
  8575. function startCommitHostEffectsTimer() {
  8576. if (enableUserTimingAPI) {
  8577. if (!supportsUserTiming) {
  8578. return;
  8579. }
  8580. effectCountInCurrentCommit = 0;
  8581. beginMark('(Committing Host Effects)');
  8582. }
  8583. }
  8584. function stopCommitHostEffectsTimer() {
  8585. if (enableUserTimingAPI) {
  8586. if (!supportsUserTiming) {
  8587. return;
  8588. }
  8589. var count = effectCountInCurrentCommit;
  8590. effectCountInCurrentCommit = 0;
  8591. endMark('(Committing Host Effects: ' + count + ' Total)', '(Committing Host Effects)', null);
  8592. }
  8593. }
  8594. function startCommitLifeCyclesTimer() {
  8595. if (enableUserTimingAPI) {
  8596. if (!supportsUserTiming) {
  8597. return;
  8598. }
  8599. effectCountInCurrentCommit = 0;
  8600. beginMark('(Calling Lifecycle Methods)');
  8601. }
  8602. }
  8603. function stopCommitLifeCyclesTimer() {
  8604. if (enableUserTimingAPI) {
  8605. if (!supportsUserTiming) {
  8606. return;
  8607. }
  8608. var count = effectCountInCurrentCommit;
  8609. effectCountInCurrentCommit = 0;
  8610. endMark('(Calling Lifecycle Methods: ' + count + ' Total)', '(Calling Lifecycle Methods)', null);
  8611. }
  8612. }
  8613. var valueStack = [];
  8614. var fiberStack = void 0;
  8615. {
  8616. fiberStack = [];
  8617. }
  8618. var index = -1;
  8619. function createCursor(defaultValue) {
  8620. return {
  8621. current: defaultValue
  8622. };
  8623. }
  8624. function pop(cursor, fiber) {
  8625. if (index < 0) {
  8626. {
  8627. warningWithoutStack$1(false, 'Unexpected pop.');
  8628. }
  8629. return;
  8630. }
  8631. {
  8632. if (fiber !== fiberStack[index]) {
  8633. warningWithoutStack$1(false, 'Unexpected Fiber popped.');
  8634. }
  8635. }
  8636. cursor.current = valueStack[index];
  8637. valueStack[index] = null;
  8638. {
  8639. fiberStack[index] = null;
  8640. }
  8641. index--;
  8642. }
  8643. function push(cursor, value, fiber) {
  8644. index++;
  8645. valueStack[index] = cursor.current;
  8646. {
  8647. fiberStack[index] = fiber;
  8648. }
  8649. cursor.current = value;
  8650. }
  8651. function checkThatStackIsEmpty() {
  8652. {
  8653. if (index !== -1) {
  8654. warningWithoutStack$1(false, 'Expected an empty stack. Something was not reset properly.');
  8655. }
  8656. }
  8657. }
  8658. function resetStackAfterFatalErrorInDev() {
  8659. {
  8660. index = -1;
  8661. valueStack.length = 0;
  8662. fiberStack.length = 0;
  8663. }
  8664. }
  8665. var warnedAboutMissingGetChildContext = void 0;
  8666. {
  8667. warnedAboutMissingGetChildContext = {};
  8668. }
  8669. var emptyContextObject = {};
  8670. {
  8671. Object.freeze(emptyContextObject);
  8672. }
  8673. // A cursor to the current merged context object on the stack.
  8674. var contextStackCursor = createCursor(emptyContextObject);
  8675. // A cursor to a boolean indicating whether the context has changed.
  8676. var didPerformWorkStackCursor = createCursor(false);
  8677. // Keep track of the previous context object that was on the stack.
  8678. // We use this to get access to the parent context after we have already
  8679. // pushed the next context provider, and now need to merge their contexts.
  8680. var previousContext = emptyContextObject;
  8681. function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) {
  8682. if (didPushOwnContextIfProvider && isContextProvider(Component)) {
  8683. // If the fiber is a context provider itself, when we read its context
  8684. // we may have already pushed its own child context on the stack. A context
  8685. // provider should not "see" its own child context. Therefore we read the
  8686. // previous (parent) context instead for a context provider.
  8687. return previousContext;
  8688. }
  8689. return contextStackCursor.current;
  8690. }
  8691. function cacheContext(workInProgress, unmaskedContext, maskedContext) {
  8692. var instance = workInProgress.stateNode;
  8693. instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
  8694. instance.__reactInternalMemoizedMaskedChildContext = maskedContext;
  8695. }
  8696. function getMaskedContext(workInProgress, unmaskedContext) {
  8697. var type = workInProgress.type;
  8698. var contextTypes = type.contextTypes;
  8699. if (!contextTypes) {
  8700. return emptyContextObject;
  8701. }
  8702. // Avoid recreating masked context unless unmasked context has changed.
  8703. // Failing to do this will result in unnecessary calls to componentWillReceiveProps.
  8704. // This may trigger infinite loops if componentWillReceiveProps calls setState.
  8705. var instance = workInProgress.stateNode;
  8706. if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
  8707. return instance.__reactInternalMemoizedMaskedChildContext;
  8708. }
  8709. var context = {};
  8710. for (var key in contextTypes) {
  8711. context[key] = unmaskedContext[key];
  8712. }
  8713. {
  8714. var name = getComponentName(type) || 'Unknown';
  8715. checkPropTypes(contextTypes, context, 'context', name, getCurrentFiberStackInDev);
  8716. }
  8717. // Cache unmasked context so we can avoid recreating masked context unless necessary.
  8718. // Context is created before the class component is instantiated so check for instance.
  8719. if (instance) {
  8720. cacheContext(workInProgress, unmaskedContext, context);
  8721. }
  8722. return context;
  8723. }
  8724. function hasContextChanged() {
  8725. return didPerformWorkStackCursor.current;
  8726. }
  8727. function isContextProvider(type) {
  8728. var childContextTypes = type.childContextTypes;
  8729. return childContextTypes !== null && childContextTypes !== undefined;
  8730. }
  8731. function popContext(fiber) {
  8732. pop(didPerformWorkStackCursor, fiber);
  8733. pop(contextStackCursor, fiber);
  8734. }
  8735. function popTopLevelContextObject(fiber) {
  8736. pop(didPerformWorkStackCursor, fiber);
  8737. pop(contextStackCursor, fiber);
  8738. }
  8739. function pushTopLevelContextObject(fiber, context, didChange) {
  8740. !(contextStackCursor.current === emptyContextObject) ? invariant(false, 'Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  8741. push(contextStackCursor, context, fiber);
  8742. push(didPerformWorkStackCursor, didChange, fiber);
  8743. }
  8744. function processChildContext(fiber, type, parentContext) {
  8745. var instance = fiber.stateNode;
  8746. var childContextTypes = type.childContextTypes;
  8747. // TODO (bvaughn) Replace this behavior with an invariant() in the future.
  8748. // It has only been added in Fiber to match the (unintentional) behavior in Stack.
  8749. if (typeof instance.getChildContext !== 'function') {
  8750. {
  8751. var componentName = getComponentName(type) || 'Unknown';
  8752. if (!warnedAboutMissingGetChildContext[componentName]) {
  8753. warnedAboutMissingGetChildContext[componentName] = true;
  8754. 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);
  8755. }
  8756. }
  8757. return parentContext;
  8758. }
  8759. var childContext = void 0;
  8760. {
  8761. setCurrentPhase('getChildContext');
  8762. }
  8763. startPhaseTimer(fiber, 'getChildContext');
  8764. childContext = instance.getChildContext();
  8765. stopPhaseTimer();
  8766. {
  8767. setCurrentPhase(null);
  8768. }
  8769. for (var contextKey in childContext) {
  8770. !(contextKey in childContextTypes) ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', getComponentName(type) || 'Unknown', contextKey) : void 0;
  8771. }
  8772. {
  8773. var name = getComponentName(type) || 'Unknown';
  8774. checkPropTypes(childContextTypes, childContext, 'child context', name,
  8775. // In practice, there is one case in which we won't get a stack. It's when
  8776. // somebody calls unstable_renderSubtreeIntoContainer() and we process
  8777. // context from the parent component instance. The stack will be missing
  8778. // because it's outside of the reconciliation, and so the pointer has not
  8779. // been set. This is rare and doesn't matter. We'll also remove that API.
  8780. getCurrentFiberStackInDev);
  8781. }
  8782. return _assign({}, parentContext, childContext);
  8783. }
  8784. function pushContextProvider(workInProgress) {
  8785. var instance = workInProgress.stateNode;
  8786. // We push the context as early as possible to ensure stack integrity.
  8787. // If the instance does not exist yet, we will push null at first,
  8788. // and replace it on the stack later when invalidating the context.
  8789. var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject;
  8790. // Remember the parent context so we can merge with it later.
  8791. // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates.
  8792. previousContext = contextStackCursor.current;
  8793. push(contextStackCursor, memoizedMergedChildContext, workInProgress);
  8794. push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress);
  8795. return true;
  8796. }
  8797. function invalidateContextProvider(workInProgress, type, didChange) {
  8798. var instance = workInProgress.stateNode;
  8799. !instance ? invariant(false, 'Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  8800. if (didChange) {
  8801. // Merge parent and own context.
  8802. // Skip this if we're not updating due to sCU.
  8803. // This avoids unnecessarily recomputing memoized values.
  8804. var mergedContext = processChildContext(workInProgress, type, previousContext);
  8805. instance.__reactInternalMemoizedMergedChildContext = mergedContext;
  8806. // Replace the old (or empty) context with the new one.
  8807. // It is important to unwind the context in the reverse order.
  8808. pop(didPerformWorkStackCursor, workInProgress);
  8809. pop(contextStackCursor, workInProgress);
  8810. // Now push the new context and mark that it has changed.
  8811. push(contextStackCursor, mergedContext, workInProgress);
  8812. push(didPerformWorkStackCursor, didChange, workInProgress);
  8813. } else {
  8814. pop(didPerformWorkStackCursor, workInProgress);
  8815. push(didPerformWorkStackCursor, didChange, workInProgress);
  8816. }
  8817. }
  8818. function findCurrentUnmaskedContext(fiber) {
  8819. // Currently this is only used with renderSubtreeIntoContainer; not sure if it
  8820. // makes sense elsewhere
  8821. !(isFiberMounted(fiber) && fiber.tag === ClassComponent) ? invariant(false, 'Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  8822. var node = fiber;
  8823. do {
  8824. switch (node.tag) {
  8825. case HostRoot:
  8826. return node.stateNode.context;
  8827. case ClassComponent:
  8828. {
  8829. var Component = node.type;
  8830. if (isContextProvider(Component)) {
  8831. return node.stateNode.__reactInternalMemoizedMergedChildContext;
  8832. }
  8833. break;
  8834. }
  8835. }
  8836. node = node.return;
  8837. } while (node !== null);
  8838. invariant(false, 'Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue.');
  8839. }
  8840. var onCommitFiberRoot = null;
  8841. var onCommitFiberUnmount = null;
  8842. var hasLoggedError = false;
  8843. function catchErrors(fn) {
  8844. return function (arg) {
  8845. try {
  8846. return fn(arg);
  8847. } catch (err) {
  8848. if ( true && !hasLoggedError) {
  8849. hasLoggedError = true;
  8850. warningWithoutStack$1(false, 'React DevTools encountered an error: %s', err);
  8851. }
  8852. }
  8853. };
  8854. }
  8855. var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined';
  8856. function injectInternals(internals) {
  8857. if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
  8858. // No DevTools
  8859. return false;
  8860. }
  8861. var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
  8862. if (hook.isDisabled) {
  8863. // This isn't a real property on the hook, but it can be set to opt out
  8864. // of DevTools integration and associated warnings and logs.
  8865. // https://github.com/facebook/react/issues/3877
  8866. return true;
  8867. }
  8868. if (!hook.supportsFiber) {
  8869. {
  8870. 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');
  8871. }
  8872. // DevTools exists, even though it doesn't support Fiber.
  8873. return true;
  8874. }
  8875. try {
  8876. var rendererID = hook.inject(internals);
  8877. // We have successfully injected, so now it is safe to set up hooks.
  8878. onCommitFiberRoot = catchErrors(function (root) {
  8879. return hook.onCommitFiberRoot(rendererID, root);
  8880. });
  8881. onCommitFiberUnmount = catchErrors(function (fiber) {
  8882. return hook.onCommitFiberUnmount(rendererID, fiber);
  8883. });
  8884. } catch (err) {
  8885. // Catch all errors because it is unsafe to throw during initialization.
  8886. {
  8887. warningWithoutStack$1(false, 'React DevTools encountered an error: %s.', err);
  8888. }
  8889. }
  8890. // DevTools exists
  8891. return true;
  8892. }
  8893. function onCommitRoot(root) {
  8894. if (typeof onCommitFiberRoot === 'function') {
  8895. onCommitFiberRoot(root);
  8896. }
  8897. }
  8898. function onCommitUnmount(fiber) {
  8899. if (typeof onCommitFiberUnmount === 'function') {
  8900. onCommitFiberUnmount(fiber);
  8901. }
  8902. }
  8903. // Max 31 bit integer. The max integer size in V8 for 32-bit systems.
  8904. // Math.pow(2, 30) - 1
  8905. // 0b111111111111111111111111111111
  8906. var maxSigned31BitInt = 1073741823;
  8907. var NoWork = 0;
  8908. var Never = 1;
  8909. var Sync = maxSigned31BitInt;
  8910. var UNIT_SIZE = 10;
  8911. var MAGIC_NUMBER_OFFSET = maxSigned31BitInt - 1;
  8912. // 1 unit of expiration time represents 10ms.
  8913. function msToExpirationTime(ms) {
  8914. // Always add an offset so that we don't clash with the magic number for NoWork.
  8915. return MAGIC_NUMBER_OFFSET - (ms / UNIT_SIZE | 0);
  8916. }
  8917. function expirationTimeToMs(expirationTime) {
  8918. return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE;
  8919. }
  8920. function ceiling(num, precision) {
  8921. return ((num / precision | 0) + 1) * precision;
  8922. }
  8923. function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) {
  8924. return MAGIC_NUMBER_OFFSET - ceiling(MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE);
  8925. }
  8926. var LOW_PRIORITY_EXPIRATION = 5000;
  8927. var LOW_PRIORITY_BATCH_SIZE = 250;
  8928. function computeAsyncExpiration(currentTime) {
  8929. return computeExpirationBucket(currentTime, LOW_PRIORITY_EXPIRATION, LOW_PRIORITY_BATCH_SIZE);
  8930. }
  8931. // We intentionally set a higher expiration time for interactive updates in
  8932. // dev than in production.
  8933. //
  8934. // If the main thread is being blocked so long that you hit the expiration,
  8935. // it's a problem that could be solved with better scheduling.
  8936. //
  8937. // People will be more likely to notice this and fix it with the long
  8938. // expiration time in development.
  8939. //
  8940. // In production we opt for better UX at the risk of masking scheduling
  8941. // problems, by expiring fast.
  8942. var HIGH_PRIORITY_EXPIRATION = 500;
  8943. var HIGH_PRIORITY_BATCH_SIZE = 100;
  8944. function computeInteractiveExpiration(currentTime) {
  8945. return computeExpirationBucket(currentTime, HIGH_PRIORITY_EXPIRATION, HIGH_PRIORITY_BATCH_SIZE);
  8946. }
  8947. var NoContext = 0;
  8948. var ConcurrentMode = 1;
  8949. var StrictMode = 2;
  8950. var ProfileMode = 4;
  8951. var hasBadMapPolyfill = void 0;
  8952. {
  8953. hasBadMapPolyfill = false;
  8954. try {
  8955. var nonExtensibleObject = Object.preventExtensions({});
  8956. var testMap = new Map([[nonExtensibleObject, null]]);
  8957. var testSet = new Set([nonExtensibleObject]);
  8958. // This is necessary for Rollup to not consider these unused.
  8959. // https://github.com/rollup/rollup/issues/1771
  8960. // TODO: we can remove these if Rollup fixes the bug.
  8961. testMap.set(0, 0);
  8962. testSet.add(0);
  8963. } catch (e) {
  8964. // TODO: Consider warning about bad polyfills
  8965. hasBadMapPolyfill = true;
  8966. }
  8967. }
  8968. // A Fiber is work on a Component that needs to be done or was done. There can
  8969. // be more than one per component.
  8970. var debugCounter = void 0;
  8971. {
  8972. debugCounter = 1;
  8973. }
  8974. function FiberNode(tag, pendingProps, key, mode) {
  8975. // Instance
  8976. this.tag = tag;
  8977. this.key = key;
  8978. this.elementType = null;
  8979. this.type = null;
  8980. this.stateNode = null;
  8981. // Fiber
  8982. this.return = null;
  8983. this.child = null;
  8984. this.sibling = null;
  8985. this.index = 0;
  8986. this.ref = null;
  8987. this.pendingProps = pendingProps;
  8988. this.memoizedProps = null;
  8989. this.updateQueue = null;
  8990. this.memoizedState = null;
  8991. this.firstContextDependency = null;
  8992. this.mode = mode;
  8993. // Effects
  8994. this.effectTag = NoEffect;
  8995. this.nextEffect = null;
  8996. this.firstEffect = null;
  8997. this.lastEffect = null;
  8998. this.expirationTime = NoWork;
  8999. this.childExpirationTime = NoWork;
  9000. this.alternate = null;
  9001. if (enableProfilerTimer) {
  9002. this.actualDuration = 0;
  9003. this.actualStartTime = -1;
  9004. this.selfBaseDuration = 0;
  9005. this.treeBaseDuration = 0;
  9006. }
  9007. {
  9008. this._debugID = debugCounter++;
  9009. this._debugSource = null;
  9010. this._debugOwner = null;
  9011. this._debugIsCurrentlyTiming = false;
  9012. if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
  9013. Object.preventExtensions(this);
  9014. }
  9015. }
  9016. }
  9017. // This is a constructor function, rather than a POJO constructor, still
  9018. // please ensure we do the following:
  9019. // 1) Nobody should add any instance methods on this. Instance methods can be
  9020. // more difficult to predict when they get optimized and they are almost
  9021. // never inlined properly in static compilers.
  9022. // 2) Nobody should rely on `instanceof Fiber` for type testing. We should
  9023. // always know when it is a fiber.
  9024. // 3) We might want to experiment with using numeric keys since they are easier
  9025. // to optimize in a non-JIT environment.
  9026. // 4) We can easily go from a constructor to a createFiber object literal if that
  9027. // is faster.
  9028. // 5) It should be easy to port this to a C struct and keep a C implementation
  9029. // compatible.
  9030. var createFiber = function (tag, pendingProps, key, mode) {
  9031. // $FlowFixMe: the shapes are exact here but Flow doesn't like constructors
  9032. return new FiberNode(tag, pendingProps, key, mode);
  9033. };
  9034. function shouldConstruct(Component) {
  9035. var prototype = Component.prototype;
  9036. return !!(prototype && prototype.isReactComponent);
  9037. }
  9038. function isSimpleFunctionComponent(type) {
  9039. return typeof type === 'function' && !shouldConstruct(type) && type.defaultProps === undefined;
  9040. }
  9041. function resolveLazyComponentTag(Component) {
  9042. if (typeof Component === 'function') {
  9043. return shouldConstruct(Component) ? ClassComponent : FunctionComponent;
  9044. } else if (Component !== undefined && Component !== null) {
  9045. var $$typeof = Component.$$typeof;
  9046. if ($$typeof === REACT_FORWARD_REF_TYPE) {
  9047. return ForwardRef;
  9048. }
  9049. if ($$typeof === REACT_MEMO_TYPE) {
  9050. return MemoComponent;
  9051. }
  9052. }
  9053. return IndeterminateComponent;
  9054. }
  9055. // This is used to create an alternate fiber to do work on.
  9056. function createWorkInProgress(current, pendingProps, expirationTime) {
  9057. var workInProgress = current.alternate;
  9058. if (workInProgress === null) {
  9059. // We use a double buffering pooling technique because we know that we'll
  9060. // only ever need at most two versions of a tree. We pool the "other" unused
  9061. // node that we're free to reuse. This is lazily created to avoid allocating
  9062. // extra objects for things that are never updated. It also allow us to
  9063. // reclaim the extra memory if needed.
  9064. workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
  9065. workInProgress.elementType = current.elementType;
  9066. workInProgress.type = current.type;
  9067. workInProgress.stateNode = current.stateNode;
  9068. {
  9069. // DEV-only fields
  9070. workInProgress._debugID = current._debugID;
  9071. workInProgress._debugSource = current._debugSource;
  9072. workInProgress._debugOwner = current._debugOwner;
  9073. }
  9074. workInProgress.alternate = current;
  9075. current.alternate = workInProgress;
  9076. } else {
  9077. workInProgress.pendingProps = pendingProps;
  9078. // We already have an alternate.
  9079. // Reset the effect tag.
  9080. workInProgress.effectTag = NoEffect;
  9081. // The effect list is no longer valid.
  9082. workInProgress.nextEffect = null;
  9083. workInProgress.firstEffect = null;
  9084. workInProgress.lastEffect = null;
  9085. if (enableProfilerTimer) {
  9086. // We intentionally reset, rather than copy, actualDuration & actualStartTime.
  9087. // This prevents time from endlessly accumulating in new commits.
  9088. // This has the downside of resetting values for different priority renders,
  9089. // But works for yielding (the common case) and should support resuming.
  9090. workInProgress.actualDuration = 0;
  9091. workInProgress.actualStartTime = -1;
  9092. }
  9093. }
  9094. workInProgress.childExpirationTime = current.childExpirationTime;
  9095. workInProgress.expirationTime = current.expirationTime;
  9096. workInProgress.child = current.child;
  9097. workInProgress.memoizedProps = current.memoizedProps;
  9098. workInProgress.memoizedState = current.memoizedState;
  9099. workInProgress.updateQueue = current.updateQueue;
  9100. workInProgress.firstContextDependency = current.firstContextDependency;
  9101. // These will be overridden during the parent's reconciliation
  9102. workInProgress.sibling = current.sibling;
  9103. workInProgress.index = current.index;
  9104. workInProgress.ref = current.ref;
  9105. if (enableProfilerTimer) {
  9106. workInProgress.selfBaseDuration = current.selfBaseDuration;
  9107. workInProgress.treeBaseDuration = current.treeBaseDuration;
  9108. }
  9109. return workInProgress;
  9110. }
  9111. function createHostRootFiber(isConcurrent) {
  9112. var mode = isConcurrent ? ConcurrentMode | StrictMode : NoContext;
  9113. if (enableProfilerTimer && isDevToolsPresent) {
  9114. // Always collect profile timings when DevTools are present.
  9115. // This enables DevTools to start capturing timing at any point–
  9116. // Without some nodes in the tree having empty base times.
  9117. mode |= ProfileMode;
  9118. }
  9119. return createFiber(HostRoot, null, null, mode);
  9120. }
  9121. function createFiberFromTypeAndProps(type, // React$ElementType
  9122. key, pendingProps, owner, mode, expirationTime) {
  9123. var fiber = void 0;
  9124. var fiberTag = IndeterminateComponent;
  9125. // The resolved type is set if we know what the final type will be. I.e. it's not lazy.
  9126. var resolvedType = type;
  9127. if (typeof type === 'function') {
  9128. if (shouldConstruct(type)) {
  9129. fiberTag = ClassComponent;
  9130. }
  9131. } else if (typeof type === 'string') {
  9132. fiberTag = HostComponent;
  9133. } else {
  9134. getTag: switch (type) {
  9135. case REACT_FRAGMENT_TYPE:
  9136. return createFiberFromFragment(pendingProps.children, mode, expirationTime, key);
  9137. case REACT_CONCURRENT_MODE_TYPE:
  9138. return createFiberFromMode(pendingProps, mode | ConcurrentMode | StrictMode, expirationTime, key);
  9139. case REACT_STRICT_MODE_TYPE:
  9140. return createFiberFromMode(pendingProps, mode | StrictMode, expirationTime, key);
  9141. case REACT_PROFILER_TYPE:
  9142. return createFiberFromProfiler(pendingProps, mode, expirationTime, key);
  9143. case REACT_SUSPENSE_TYPE:
  9144. return createFiberFromSuspense(pendingProps, mode, expirationTime, key);
  9145. default:
  9146. {
  9147. if (typeof type === 'object' && type !== null) {
  9148. switch (type.$$typeof) {
  9149. case REACT_PROVIDER_TYPE:
  9150. fiberTag = ContextProvider;
  9151. break getTag;
  9152. case REACT_CONTEXT_TYPE:
  9153. // This is a consumer
  9154. fiberTag = ContextConsumer;
  9155. break getTag;
  9156. case REACT_FORWARD_REF_TYPE:
  9157. fiberTag = ForwardRef;
  9158. break getTag;
  9159. case REACT_MEMO_TYPE:
  9160. fiberTag = MemoComponent;
  9161. break getTag;
  9162. case REACT_LAZY_TYPE:
  9163. fiberTag = LazyComponent;
  9164. resolvedType = null;
  9165. break getTag;
  9166. }
  9167. }
  9168. var info = '';
  9169. {
  9170. if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
  9171. 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.';
  9172. }
  9173. var ownerName = owner ? getComponentName(owner.type) : null;
  9174. if (ownerName) {
  9175. info += '\n\nCheck the render method of `' + ownerName + '`.';
  9176. }
  9177. }
  9178. invariant(false, 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s', type == null ? type : typeof type, info);
  9179. }
  9180. }
  9181. }
  9182. fiber = createFiber(fiberTag, pendingProps, key, mode);
  9183. fiber.elementType = type;
  9184. fiber.type = resolvedType;
  9185. fiber.expirationTime = expirationTime;
  9186. return fiber;
  9187. }
  9188. function createFiberFromElement(element, mode, expirationTime) {
  9189. var owner = null;
  9190. {
  9191. owner = element._owner;
  9192. }
  9193. var type = element.type;
  9194. var key = element.key;
  9195. var pendingProps = element.props;
  9196. var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, expirationTime);
  9197. {
  9198. fiber._debugSource = element._source;
  9199. fiber._debugOwner = element._owner;
  9200. }
  9201. return fiber;
  9202. }
  9203. function createFiberFromFragment(elements, mode, expirationTime, key) {
  9204. var fiber = createFiber(Fragment, elements, key, mode);
  9205. fiber.expirationTime = expirationTime;
  9206. return fiber;
  9207. }
  9208. function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
  9209. {
  9210. if (typeof pendingProps.id !== 'string' || typeof pendingProps.onRender !== 'function') {
  9211. warningWithoutStack$1(false, 'Profiler must specify an "id" string and "onRender" function as props');
  9212. }
  9213. }
  9214. var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode);
  9215. // TODO: The Profiler fiber shouldn't have a type. It has a tag.
  9216. fiber.elementType = REACT_PROFILER_TYPE;
  9217. fiber.type = REACT_PROFILER_TYPE;
  9218. fiber.expirationTime = expirationTime;
  9219. return fiber;
  9220. }
  9221. function createFiberFromMode(pendingProps, mode, expirationTime, key) {
  9222. var fiber = createFiber(Mode, pendingProps, key, mode);
  9223. // TODO: The Mode fiber shouldn't have a type. It has a tag.
  9224. var type = (mode & ConcurrentMode) === NoContext ? REACT_STRICT_MODE_TYPE : REACT_CONCURRENT_MODE_TYPE;
  9225. fiber.elementType = type;
  9226. fiber.type = type;
  9227. fiber.expirationTime = expirationTime;
  9228. return fiber;
  9229. }
  9230. function createFiberFromSuspense(pendingProps, mode, expirationTime, key) {
  9231. var fiber = createFiber(SuspenseComponent, pendingProps, key, mode);
  9232. // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag.
  9233. var type = REACT_SUSPENSE_TYPE;
  9234. fiber.elementType = type;
  9235. fiber.type = type;
  9236. fiber.expirationTime = expirationTime;
  9237. return fiber;
  9238. }
  9239. function createFiberFromText(content, mode, expirationTime) {
  9240. var fiber = createFiber(HostText, content, null, mode);
  9241. fiber.expirationTime = expirationTime;
  9242. return fiber;
  9243. }
  9244. function createFiberFromHostInstanceForDeletion() {
  9245. var fiber = createFiber(HostComponent, null, null, NoContext);
  9246. // TODO: These should not need a type.
  9247. fiber.elementType = 'DELETED';
  9248. fiber.type = 'DELETED';
  9249. return fiber;
  9250. }
  9251. function createFiberFromPortal(portal, mode, expirationTime) {
  9252. var pendingProps = portal.children !== null ? portal.children : [];
  9253. var fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
  9254. fiber.expirationTime = expirationTime;
  9255. fiber.stateNode = {
  9256. containerInfo: portal.containerInfo,
  9257. pendingChildren: null, // Used by persistent updates
  9258. implementation: portal.implementation
  9259. };
  9260. return fiber;
  9261. }
  9262. // Used for stashing WIP properties to replay failed work in DEV.
  9263. function assignFiberPropertiesInDEV(target, source) {
  9264. if (target === null) {
  9265. // This Fiber's initial properties will always be overwritten.
  9266. // We only use a Fiber to ensure the same hidden class so DEV isn't slow.
  9267. target = createFiber(IndeterminateComponent, null, null, NoContext);
  9268. }
  9269. // This is intentionally written as a list of all properties.
  9270. // We tried to use Object.assign() instead but this is called in
  9271. // the hottest path, and Object.assign() was too slow:
  9272. // https://github.com/facebook/react/issues/12502
  9273. // This code is DEV-only so size is not a concern.
  9274. target.tag = source.tag;
  9275. target.key = source.key;
  9276. target.elementType = source.elementType;
  9277. target.type = source.type;
  9278. target.stateNode = source.stateNode;
  9279. target.return = source.return;
  9280. target.child = source.child;
  9281. target.sibling = source.sibling;
  9282. target.index = source.index;
  9283. target.ref = source.ref;
  9284. target.pendingProps = source.pendingProps;
  9285. target.memoizedProps = source.memoizedProps;
  9286. target.updateQueue = source.updateQueue;
  9287. target.memoizedState = source.memoizedState;
  9288. target.firstContextDependency = source.firstContextDependency;
  9289. target.mode = source.mode;
  9290. target.effectTag = source.effectTag;
  9291. target.nextEffect = source.nextEffect;
  9292. target.firstEffect = source.firstEffect;
  9293. target.lastEffect = source.lastEffect;
  9294. target.expirationTime = source.expirationTime;
  9295. target.childExpirationTime = source.childExpirationTime;
  9296. target.alternate = source.alternate;
  9297. if (enableProfilerTimer) {
  9298. target.actualDuration = source.actualDuration;
  9299. target.actualStartTime = source.actualStartTime;
  9300. target.selfBaseDuration = source.selfBaseDuration;
  9301. target.treeBaseDuration = source.treeBaseDuration;
  9302. }
  9303. target._debugID = source._debugID;
  9304. target._debugSource = source._debugSource;
  9305. target._debugOwner = source._debugOwner;
  9306. target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
  9307. return target;
  9308. }
  9309. // TODO: This should be lifted into the renderer.
  9310. // The following attributes are only used by interaction tracing builds.
  9311. // They enable interactions to be associated with their async work,
  9312. // And expose interaction metadata to the React DevTools Profiler plugin.
  9313. // Note that these attributes are only defined when the enableSchedulerTracing flag is enabled.
  9314. // Exported FiberRoot type includes all properties,
  9315. // To avoid requiring potentially error-prone :any casts throughout the project.
  9316. // Profiling properties are only safe to access in profiling builds (when enableSchedulerTracing is true).
  9317. // The types are defined separately within this file to ensure they stay in sync.
  9318. // (We don't have to use an inline :any cast when enableSchedulerTracing is disabled.)
  9319. function createFiberRoot(containerInfo, isConcurrent, hydrate) {
  9320. // Cyclic construction. This cheats the type system right now because
  9321. // stateNode is any.
  9322. var uninitializedFiber = createHostRootFiber(isConcurrent);
  9323. var root = void 0;
  9324. if (enableSchedulerTracing) {
  9325. root = {
  9326. current: uninitializedFiber,
  9327. containerInfo: containerInfo,
  9328. pendingChildren: null,
  9329. earliestPendingTime: NoWork,
  9330. latestPendingTime: NoWork,
  9331. earliestSuspendedTime: NoWork,
  9332. latestSuspendedTime: NoWork,
  9333. latestPingedTime: NoWork,
  9334. didError: false,
  9335. pendingCommitExpirationTime: NoWork,
  9336. finishedWork: null,
  9337. timeoutHandle: noTimeout,
  9338. context: null,
  9339. pendingContext: null,
  9340. hydrate: hydrate,
  9341. nextExpirationTimeToWorkOn: NoWork,
  9342. expirationTime: NoWork,
  9343. firstBatch: null,
  9344. nextScheduledRoot: null,
  9345. interactionThreadID: tracing.unstable_getThreadID(),
  9346. memoizedInteractions: new Set(),
  9347. pendingInteractionMap: new Map()
  9348. };
  9349. } else {
  9350. root = {
  9351. current: uninitializedFiber,
  9352. containerInfo: containerInfo,
  9353. pendingChildren: null,
  9354. earliestPendingTime: NoWork,
  9355. latestPendingTime: NoWork,
  9356. earliestSuspendedTime: NoWork,
  9357. latestSuspendedTime: NoWork,
  9358. latestPingedTime: NoWork,
  9359. didError: false,
  9360. pendingCommitExpirationTime: NoWork,
  9361. finishedWork: null,
  9362. timeoutHandle: noTimeout,
  9363. context: null,
  9364. pendingContext: null,
  9365. hydrate: hydrate,
  9366. nextExpirationTimeToWorkOn: NoWork,
  9367. expirationTime: NoWork,
  9368. firstBatch: null,
  9369. nextScheduledRoot: null
  9370. };
  9371. }
  9372. uninitializedFiber.stateNode = root;
  9373. // The reason for the way the Flow types are structured in this file,
  9374. // Is to avoid needing :any casts everywhere interaction tracing fields are used.
  9375. // Unfortunately that requires an :any cast for non-interaction tracing capable builds.
  9376. // $FlowFixMe Remove this :any cast and replace it with something better.
  9377. return root;
  9378. }
  9379. /**
  9380. * Forked from fbjs/warning:
  9381. * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
  9382. *
  9383. * Only change is we use console.warn instead of console.error,
  9384. * and do nothing when 'console' is not supported.
  9385. * This really simplifies the code.
  9386. * ---
  9387. * Similar to invariant but only logs a warning if the condition is not met.
  9388. * This can be used to log issues in development environments in critical
  9389. * paths. Removing the logging code for production environments will keep the
  9390. * same logic and follow the same code paths.
  9391. */
  9392. var lowPriorityWarning = function () {};
  9393. {
  9394. var printWarning = function (format) {
  9395. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  9396. args[_key - 1] = arguments[_key];
  9397. }
  9398. var argIndex = 0;
  9399. var message = 'Warning: ' + format.replace(/%s/g, function () {
  9400. return args[argIndex++];
  9401. });
  9402. if (typeof console !== 'undefined') {
  9403. console.warn(message);
  9404. }
  9405. try {
  9406. // --- Welcome to debugging React ---
  9407. // This error was thrown as a convenience so that you can use this stack
  9408. // to find the callsite that caused this warning to fire.
  9409. throw new Error(message);
  9410. } catch (x) {}
  9411. };
  9412. lowPriorityWarning = function (condition, format) {
  9413. if (format === undefined) {
  9414. throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
  9415. }
  9416. if (!condition) {
  9417. for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  9418. args[_key2 - 2] = arguments[_key2];
  9419. }
  9420. printWarning.apply(undefined, [format].concat(args));
  9421. }
  9422. };
  9423. }
  9424. var lowPriorityWarning$1 = lowPriorityWarning;
  9425. var ReactStrictModeWarnings = {
  9426. discardPendingWarnings: function () {},
  9427. flushPendingDeprecationWarnings: function () {},
  9428. flushPendingUnsafeLifecycleWarnings: function () {},
  9429. recordDeprecationWarnings: function (fiber, instance) {},
  9430. recordUnsafeLifecycleWarnings: function (fiber, instance) {},
  9431. recordLegacyContextWarning: function (fiber, instance) {},
  9432. flushLegacyContextWarning: function () {}
  9433. };
  9434. {
  9435. var LIFECYCLE_SUGGESTIONS = {
  9436. UNSAFE_componentWillMount: 'componentDidMount',
  9437. UNSAFE_componentWillReceiveProps: 'static getDerivedStateFromProps',
  9438. UNSAFE_componentWillUpdate: 'componentDidUpdate'
  9439. };
  9440. var pendingComponentWillMountWarnings = [];
  9441. var pendingComponentWillReceivePropsWarnings = [];
  9442. var pendingComponentWillUpdateWarnings = [];
  9443. var pendingUnsafeLifecycleWarnings = new Map();
  9444. var pendingLegacyContextWarning = new Map();
  9445. // Tracks components we have already warned about.
  9446. var didWarnAboutDeprecatedLifecycles = new Set();
  9447. var didWarnAboutUnsafeLifecycles = new Set();
  9448. var didWarnAboutLegacyContext = new Set();
  9449. var setToSortedString = function (set) {
  9450. var array = [];
  9451. set.forEach(function (value) {
  9452. array.push(value);
  9453. });
  9454. return array.sort().join(', ');
  9455. };
  9456. ReactStrictModeWarnings.discardPendingWarnings = function () {
  9457. pendingComponentWillMountWarnings = [];
  9458. pendingComponentWillReceivePropsWarnings = [];
  9459. pendingComponentWillUpdateWarnings = [];
  9460. pendingUnsafeLifecycleWarnings = new Map();
  9461. pendingLegacyContextWarning = new Map();
  9462. };
  9463. ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () {
  9464. pendingUnsafeLifecycleWarnings.forEach(function (lifecycleWarningsMap, strictRoot) {
  9465. var lifecyclesWarningMesages = [];
  9466. Object.keys(lifecycleWarningsMap).forEach(function (lifecycle) {
  9467. var lifecycleWarnings = lifecycleWarningsMap[lifecycle];
  9468. if (lifecycleWarnings.length > 0) {
  9469. var componentNames = new Set();
  9470. lifecycleWarnings.forEach(function (fiber) {
  9471. componentNames.add(getComponentName(fiber.type) || 'Component');
  9472. didWarnAboutUnsafeLifecycles.add(fiber.type);
  9473. });
  9474. var formatted = lifecycle.replace('UNSAFE_', '');
  9475. var suggestion = LIFECYCLE_SUGGESTIONS[lifecycle];
  9476. var sortedComponentNames = setToSortedString(componentNames);
  9477. lifecyclesWarningMesages.push(formatted + ': Please update the following components to use ' + (suggestion + ' instead: ' + sortedComponentNames));
  9478. }
  9479. });
  9480. if (lifecyclesWarningMesages.length > 0) {
  9481. var strictRootComponentStack = getStackByFiberInDevAndProd(strictRoot);
  9482. warningWithoutStack$1(false, 'Unsafe lifecycle methods were found within a strict-mode tree:%s' + '\n\n%s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-strict-mode-warnings', strictRootComponentStack, lifecyclesWarningMesages.join('\n\n'));
  9483. }
  9484. });
  9485. pendingUnsafeLifecycleWarnings = new Map();
  9486. };
  9487. var findStrictRoot = function (fiber) {
  9488. var maybeStrictRoot = null;
  9489. var node = fiber;
  9490. while (node !== null) {
  9491. if (node.mode & StrictMode) {
  9492. maybeStrictRoot = node;
  9493. }
  9494. node = node.return;
  9495. }
  9496. return maybeStrictRoot;
  9497. };
  9498. ReactStrictModeWarnings.flushPendingDeprecationWarnings = function () {
  9499. if (pendingComponentWillMountWarnings.length > 0) {
  9500. var uniqueNames = new Set();
  9501. pendingComponentWillMountWarnings.forEach(function (fiber) {
  9502. uniqueNames.add(getComponentName(fiber.type) || 'Component');
  9503. didWarnAboutDeprecatedLifecycles.add(fiber.type);
  9504. });
  9505. var sortedNames = setToSortedString(uniqueNames);
  9506. lowPriorityWarning$1(false, 'componentWillMount is deprecated and will be removed in the next major version. ' + 'Use componentDidMount instead. As a temporary workaround, ' + 'you can rename to UNSAFE_componentWillMount.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-async-component-lifecycle-hooks', sortedNames);
  9507. pendingComponentWillMountWarnings = [];
  9508. }
  9509. if (pendingComponentWillReceivePropsWarnings.length > 0) {
  9510. var _uniqueNames = new Set();
  9511. pendingComponentWillReceivePropsWarnings.forEach(function (fiber) {
  9512. _uniqueNames.add(getComponentName(fiber.type) || 'Component');
  9513. didWarnAboutDeprecatedLifecycles.add(fiber.type);
  9514. });
  9515. var _sortedNames = setToSortedString(_uniqueNames);
  9516. lowPriorityWarning$1(false, 'componentWillReceiveProps is deprecated and will be removed in the next major version. ' + 'Use static getDerivedStateFromProps instead.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-async-component-lifecycle-hooks', _sortedNames);
  9517. pendingComponentWillReceivePropsWarnings = [];
  9518. }
  9519. if (pendingComponentWillUpdateWarnings.length > 0) {
  9520. var _uniqueNames2 = new Set();
  9521. pendingComponentWillUpdateWarnings.forEach(function (fiber) {
  9522. _uniqueNames2.add(getComponentName(fiber.type) || 'Component');
  9523. didWarnAboutDeprecatedLifecycles.add(fiber.type);
  9524. });
  9525. var _sortedNames2 = setToSortedString(_uniqueNames2);
  9526. lowPriorityWarning$1(false, 'componentWillUpdate is deprecated and will be removed in the next major version. ' + 'Use componentDidUpdate instead. As a temporary workaround, ' + 'you can rename to UNSAFE_componentWillUpdate.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-async-component-lifecycle-hooks', _sortedNames2);
  9527. pendingComponentWillUpdateWarnings = [];
  9528. }
  9529. };
  9530. ReactStrictModeWarnings.recordDeprecationWarnings = function (fiber, instance) {
  9531. // Dedup strategy: Warn once per component.
  9532. if (didWarnAboutDeprecatedLifecycles.has(fiber.type)) {
  9533. return;
  9534. }
  9535. // Don't warn about react-lifecycles-compat polyfilled components.
  9536. if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
  9537. pendingComponentWillMountWarnings.push(fiber);
  9538. }
  9539. if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
  9540. pendingComponentWillReceivePropsWarnings.push(fiber);
  9541. }
  9542. if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
  9543. pendingComponentWillUpdateWarnings.push(fiber);
  9544. }
  9545. };
  9546. ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) {
  9547. var strictRoot = findStrictRoot(fiber);
  9548. if (strictRoot === null) {
  9549. 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.');
  9550. return;
  9551. }
  9552. // Dedup strategy: Warn once per component.
  9553. // This is difficult to track any other way since component names
  9554. // are often vague and are likely to collide between 3rd party libraries.
  9555. // An expand property is probably okay to use here since it's DEV-only,
  9556. // and will only be set in the event of serious warnings.
  9557. if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
  9558. return;
  9559. }
  9560. var warningsForRoot = void 0;
  9561. if (!pendingUnsafeLifecycleWarnings.has(strictRoot)) {
  9562. warningsForRoot = {
  9563. UNSAFE_componentWillMount: [],
  9564. UNSAFE_componentWillReceiveProps: [],
  9565. UNSAFE_componentWillUpdate: []
  9566. };
  9567. pendingUnsafeLifecycleWarnings.set(strictRoot, warningsForRoot);
  9568. } else {
  9569. warningsForRoot = pendingUnsafeLifecycleWarnings.get(strictRoot);
  9570. }
  9571. var unsafeLifecycles = [];
  9572. if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true || typeof instance.UNSAFE_componentWillMount === 'function') {
  9573. unsafeLifecycles.push('UNSAFE_componentWillMount');
  9574. }
  9575. if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true || typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  9576. unsafeLifecycles.push('UNSAFE_componentWillReceiveProps');
  9577. }
  9578. if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true || typeof instance.UNSAFE_componentWillUpdate === 'function') {
  9579. unsafeLifecycles.push('UNSAFE_componentWillUpdate');
  9580. }
  9581. if (unsafeLifecycles.length > 0) {
  9582. unsafeLifecycles.forEach(function (lifecycle) {
  9583. warningsForRoot[lifecycle].push(fiber);
  9584. });
  9585. }
  9586. };
  9587. ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) {
  9588. var strictRoot = findStrictRoot(fiber);
  9589. if (strictRoot === null) {
  9590. 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.');
  9591. return;
  9592. }
  9593. // Dedup strategy: Warn once per component.
  9594. if (didWarnAboutLegacyContext.has(fiber.type)) {
  9595. return;
  9596. }
  9597. var warningsForRoot = pendingLegacyContextWarning.get(strictRoot);
  9598. if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') {
  9599. if (warningsForRoot === undefined) {
  9600. warningsForRoot = [];
  9601. pendingLegacyContextWarning.set(strictRoot, warningsForRoot);
  9602. }
  9603. warningsForRoot.push(fiber);
  9604. }
  9605. };
  9606. ReactStrictModeWarnings.flushLegacyContextWarning = function () {
  9607. pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) {
  9608. var uniqueNames = new Set();
  9609. fiberArray.forEach(function (fiber) {
  9610. uniqueNames.add(getComponentName(fiber.type) || 'Component');
  9611. didWarnAboutLegacyContext.add(fiber.type);
  9612. });
  9613. var sortedNames = setToSortedString(uniqueNames);
  9614. var strictRootComponentStack = getStackByFiberInDevAndProd(strictRoot);
  9615. warningWithoutStack$1(false, 'Legacy context API has been detected within a strict-mode tree: %s' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-strict-mode-warnings', strictRootComponentStack, sortedNames);
  9616. });
  9617. };
  9618. }
  9619. // This lets us hook into Fiber to debug what it's doing.
  9620. // See https://github.com/facebook/react/pull/8033.
  9621. // This is not part of the public API, not even for React DevTools.
  9622. // You may only inject a debugTool if you work on React Fiber itself.
  9623. var ReactFiberInstrumentation = {
  9624. debugTool: null
  9625. };
  9626. var ReactFiberInstrumentation_1 = ReactFiberInstrumentation;
  9627. // TODO: Offscreen updates should never suspend. However, a promise that
  9628. // suspended inside an offscreen subtree should be able to ping at the priority
  9629. // of the outer render.
  9630. function markPendingPriorityLevel(root, expirationTime) {
  9631. // If there's a gap between completing a failed root and retrying it,
  9632. // additional updates may be scheduled. Clear `didError`, in case the update
  9633. // is sufficient to fix the error.
  9634. root.didError = false;
  9635. // Update the latest and earliest pending times
  9636. var earliestPendingTime = root.earliestPendingTime;
  9637. if (earliestPendingTime === NoWork) {
  9638. // No other pending updates.
  9639. root.earliestPendingTime = root.latestPendingTime = expirationTime;
  9640. } else {
  9641. if (earliestPendingTime < expirationTime) {
  9642. // This is the earliest pending update.
  9643. root.earliestPendingTime = expirationTime;
  9644. } else {
  9645. var latestPendingTime = root.latestPendingTime;
  9646. if (latestPendingTime > expirationTime) {
  9647. // This is the latest pending update
  9648. root.latestPendingTime = expirationTime;
  9649. }
  9650. }
  9651. }
  9652. findNextExpirationTimeToWorkOn(expirationTime, root);
  9653. }
  9654. function markCommittedPriorityLevels(root, earliestRemainingTime) {
  9655. root.didError = false;
  9656. if (earliestRemainingTime === NoWork) {
  9657. // Fast path. There's no remaining work. Clear everything.
  9658. root.earliestPendingTime = NoWork;
  9659. root.latestPendingTime = NoWork;
  9660. root.earliestSuspendedTime = NoWork;
  9661. root.latestSuspendedTime = NoWork;
  9662. root.latestPingedTime = NoWork;
  9663. findNextExpirationTimeToWorkOn(NoWork, root);
  9664. return;
  9665. }
  9666. // Let's see if the previous latest known pending level was just flushed.
  9667. var latestPendingTime = root.latestPendingTime;
  9668. if (latestPendingTime !== NoWork) {
  9669. if (latestPendingTime > earliestRemainingTime) {
  9670. // We've flushed all the known pending levels.
  9671. root.earliestPendingTime = root.latestPendingTime = NoWork;
  9672. } else {
  9673. var earliestPendingTime = root.earliestPendingTime;
  9674. if (earliestPendingTime > earliestRemainingTime) {
  9675. // We've flushed the earliest known pending level. Set this to the
  9676. // latest pending time.
  9677. root.earliestPendingTime = root.latestPendingTime;
  9678. }
  9679. }
  9680. }
  9681. // Now let's handle the earliest remaining level in the whole tree. We need to
  9682. // decide whether to treat it as a pending level or as suspended. Check
  9683. // it falls within the range of known suspended levels.
  9684. var earliestSuspendedTime = root.earliestSuspendedTime;
  9685. if (earliestSuspendedTime === NoWork) {
  9686. // There's no suspended work. Treat the earliest remaining level as a
  9687. // pending level.
  9688. markPendingPriorityLevel(root, earliestRemainingTime);
  9689. findNextExpirationTimeToWorkOn(NoWork, root);
  9690. return;
  9691. }
  9692. var latestSuspendedTime = root.latestSuspendedTime;
  9693. if (earliestRemainingTime < latestSuspendedTime) {
  9694. // The earliest remaining level is later than all the suspended work. That
  9695. // means we've flushed all the suspended work.
  9696. root.earliestSuspendedTime = NoWork;
  9697. root.latestSuspendedTime = NoWork;
  9698. root.latestPingedTime = NoWork;
  9699. // There's no suspended work. Treat the earliest remaining level as a
  9700. // pending level.
  9701. markPendingPriorityLevel(root, earliestRemainingTime);
  9702. findNextExpirationTimeToWorkOn(NoWork, root);
  9703. return;
  9704. }
  9705. if (earliestRemainingTime > earliestSuspendedTime) {
  9706. // The earliest remaining time is earlier than all the suspended work.
  9707. // Treat it as a pending update.
  9708. markPendingPriorityLevel(root, earliestRemainingTime);
  9709. findNextExpirationTimeToWorkOn(NoWork, root);
  9710. return;
  9711. }
  9712. // The earliest remaining time falls within the range of known suspended
  9713. // levels. We should treat this as suspended work.
  9714. findNextExpirationTimeToWorkOn(NoWork, root);
  9715. }
  9716. function hasLowerPriorityWork(root, erroredExpirationTime) {
  9717. var latestPendingTime = root.latestPendingTime;
  9718. var latestSuspendedTime = root.latestSuspendedTime;
  9719. var latestPingedTime = root.latestPingedTime;
  9720. return latestPendingTime !== NoWork && latestPendingTime < erroredExpirationTime || latestSuspendedTime !== NoWork && latestSuspendedTime < erroredExpirationTime || latestPingedTime !== NoWork && latestPingedTime < erroredExpirationTime;
  9721. }
  9722. function isPriorityLevelSuspended(root, expirationTime) {
  9723. var earliestSuspendedTime = root.earliestSuspendedTime;
  9724. var latestSuspendedTime = root.latestSuspendedTime;
  9725. return earliestSuspendedTime !== NoWork && expirationTime <= earliestSuspendedTime && expirationTime >= latestSuspendedTime;
  9726. }
  9727. function markSuspendedPriorityLevel(root, suspendedTime) {
  9728. root.didError = false;
  9729. clearPing(root, suspendedTime);
  9730. // First, check the known pending levels and update them if needed.
  9731. var earliestPendingTime = root.earliestPendingTime;
  9732. var latestPendingTime = root.latestPendingTime;
  9733. if (earliestPendingTime === suspendedTime) {
  9734. if (latestPendingTime === suspendedTime) {
  9735. // Both known pending levels were suspended. Clear them.
  9736. root.earliestPendingTime = root.latestPendingTime = NoWork;
  9737. } else {
  9738. // The earliest pending level was suspended. Clear by setting it to the
  9739. // latest pending level.
  9740. root.earliestPendingTime = latestPendingTime;
  9741. }
  9742. } else if (latestPendingTime === suspendedTime) {
  9743. // The latest pending level was suspended. Clear by setting it to the
  9744. // latest pending level.
  9745. root.latestPendingTime = earliestPendingTime;
  9746. }
  9747. // Finally, update the known suspended levels.
  9748. var earliestSuspendedTime = root.earliestSuspendedTime;
  9749. var latestSuspendedTime = root.latestSuspendedTime;
  9750. if (earliestSuspendedTime === NoWork) {
  9751. // No other suspended levels.
  9752. root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime;
  9753. } else {
  9754. if (earliestSuspendedTime < suspendedTime) {
  9755. // This is the earliest suspended level.
  9756. root.earliestSuspendedTime = suspendedTime;
  9757. } else if (latestSuspendedTime > suspendedTime) {
  9758. // This is the latest suspended level
  9759. root.latestSuspendedTime = suspendedTime;
  9760. }
  9761. }
  9762. findNextExpirationTimeToWorkOn(suspendedTime, root);
  9763. }
  9764. function markPingedPriorityLevel(root, pingedTime) {
  9765. root.didError = false;
  9766. // TODO: When we add back resuming, we need to ensure the progressed work
  9767. // is thrown out and not reused during the restarted render. One way to
  9768. // invalidate the progressed work is to restart at expirationTime + 1.
  9769. var latestPingedTime = root.latestPingedTime;
  9770. if (latestPingedTime === NoWork || latestPingedTime > pingedTime) {
  9771. root.latestPingedTime = pingedTime;
  9772. }
  9773. findNextExpirationTimeToWorkOn(pingedTime, root);
  9774. }
  9775. function clearPing(root, completedTime) {
  9776. // TODO: Track whether the root was pinged during the render phase. If so,
  9777. // we need to make sure we don't lose track of it.
  9778. var latestPingedTime = root.latestPingedTime;
  9779. if (latestPingedTime !== NoWork && latestPingedTime >= completedTime) {
  9780. root.latestPingedTime = NoWork;
  9781. }
  9782. }
  9783. function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) {
  9784. var earliestExpirationTime = renderExpirationTime;
  9785. var earliestPendingTime = root.earliestPendingTime;
  9786. var earliestSuspendedTime = root.earliestSuspendedTime;
  9787. if (earliestPendingTime > earliestExpirationTime) {
  9788. earliestExpirationTime = earliestPendingTime;
  9789. }
  9790. if (earliestSuspendedTime > earliestExpirationTime) {
  9791. earliestExpirationTime = earliestSuspendedTime;
  9792. }
  9793. return earliestExpirationTime;
  9794. }
  9795. function didExpireAtExpirationTime(root, currentTime) {
  9796. var expirationTime = root.expirationTime;
  9797. if (expirationTime !== NoWork && currentTime <= expirationTime) {
  9798. // The root has expired. Flush all work up to the current time.
  9799. root.nextExpirationTimeToWorkOn = currentTime;
  9800. }
  9801. }
  9802. function findNextExpirationTimeToWorkOn(completedExpirationTime, root) {
  9803. var earliestSuspendedTime = root.earliestSuspendedTime;
  9804. var latestSuspendedTime = root.latestSuspendedTime;
  9805. var earliestPendingTime = root.earliestPendingTime;
  9806. var latestPingedTime = root.latestPingedTime;
  9807. // Work on the earliest pending time. Failing that, work on the latest
  9808. // pinged time.
  9809. var nextExpirationTimeToWorkOn = earliestPendingTime !== NoWork ? earliestPendingTime : latestPingedTime;
  9810. // If there is no pending or pinged work, check if there's suspended work
  9811. // that's lower priority than what we just completed.
  9812. if (nextExpirationTimeToWorkOn === NoWork && (completedExpirationTime === NoWork || latestSuspendedTime < completedExpirationTime)) {
  9813. // The lowest priority suspended work is the work most likely to be
  9814. // committed next. Let's start rendering it again, so that if it times out,
  9815. // it's ready to commit.
  9816. nextExpirationTimeToWorkOn = latestSuspendedTime;
  9817. }
  9818. var expirationTime = nextExpirationTimeToWorkOn;
  9819. if (expirationTime !== NoWork && earliestSuspendedTime > expirationTime) {
  9820. // Expire using the earliest known expiration time.
  9821. expirationTime = earliestSuspendedTime;
  9822. }
  9823. root.nextExpirationTimeToWorkOn = nextExpirationTimeToWorkOn;
  9824. root.expirationTime = expirationTime;
  9825. }
  9826. // UpdateQueue is a linked list of prioritized updates.
  9827. //
  9828. // Like fibers, update queues come in pairs: a current queue, which represents
  9829. // the visible state of the screen, and a work-in-progress queue, which is
  9830. // can be mutated and processed asynchronously before it is committed — a form
  9831. // of double buffering. If a work-in-progress render is discarded before
  9832. // finishing, we create a new work-in-progress by cloning the current queue.
  9833. //
  9834. // Both queues share a persistent, singly-linked list structure. To schedule an
  9835. // update, we append it to the end of both queues. Each queue maintains a
  9836. // pointer to first update in the persistent list that hasn't been processed.
  9837. // The work-in-progress pointer always has a position equal to or greater than
  9838. // the current queue, since we always work on that one. The current queue's
  9839. // pointer is only updated during the commit phase, when we swap in the
  9840. // work-in-progress.
  9841. //
  9842. // For example:
  9843. //
  9844. // Current pointer: A - B - C - D - E - F
  9845. // Work-in-progress pointer: D - E - F
  9846. // ^
  9847. // The work-in-progress queue has
  9848. // processed more updates than current.
  9849. //
  9850. // The reason we append to both queues is because otherwise we might drop
  9851. // updates without ever processing them. For example, if we only add updates to
  9852. // the work-in-progress queue, some updates could be lost whenever a work-in
  9853. // -progress render restarts by cloning from current. Similarly, if we only add
  9854. // updates to the current queue, the updates will be lost whenever an already
  9855. // in-progress queue commits and swaps with the current queue. However, by
  9856. // adding to both queues, we guarantee that the update will be part of the next
  9857. // work-in-progress. (And because the work-in-progress queue becomes the
  9858. // current queue once it commits, there's no danger of applying the same
  9859. // update twice.)
  9860. //
  9861. // Prioritization
  9862. // --------------
  9863. //
  9864. // Updates are not sorted by priority, but by insertion; new updates are always
  9865. // appended to the end of the list.
  9866. //
  9867. // The priority is still important, though. When processing the update queue
  9868. // during the render phase, only the updates with sufficient priority are
  9869. // included in the result. If we skip an update because it has insufficient
  9870. // priority, it remains in the queue to be processed later, during a lower
  9871. // priority render. Crucially, all updates subsequent to a skipped update also
  9872. // remain in the queue *regardless of their priority*. That means high priority
  9873. // updates are sometimes processed twice, at two separate priorities. We also
  9874. // keep track of a base state, that represents the state before the first
  9875. // update in the queue is applied.
  9876. //
  9877. // For example:
  9878. //
  9879. // Given a base state of '', and the following queue of updates
  9880. //
  9881. // A1 - B2 - C1 - D2
  9882. //
  9883. // where the number indicates the priority, and the update is applied to the
  9884. // previous state by appending a letter, React will process these updates as
  9885. // two separate renders, one per distinct priority level:
  9886. //
  9887. // First render, at priority 1:
  9888. // Base state: ''
  9889. // Updates: [A1, C1]
  9890. // Result state: 'AC'
  9891. //
  9892. // Second render, at priority 2:
  9893. // Base state: 'A' <- The base state does not include C1,
  9894. // because B2 was skipped.
  9895. // Updates: [B2, C1, D2] <- C1 was rebased on top of B2
  9896. // Result state: 'ABCD'
  9897. //
  9898. // Because we process updates in insertion order, and rebase high priority
  9899. // updates when preceding updates are skipped, the final result is deterministic
  9900. // regardless of priority. Intermediate state may vary according to system
  9901. // resources, but the final state is always the same.
  9902. var UpdateState = 0;
  9903. var ReplaceState = 1;
  9904. var ForceUpdate = 2;
  9905. var CaptureUpdate = 3;
  9906. // Global state that is reset at the beginning of calling `processUpdateQueue`.
  9907. // It should only be read right after calling `processUpdateQueue`, via
  9908. // `checkHasForceUpdateAfterProcessing`.
  9909. var hasForceUpdate = false;
  9910. var didWarnUpdateInsideUpdate = void 0;
  9911. var currentlyProcessingQueue = void 0;
  9912. var resetCurrentlyProcessingQueue = void 0;
  9913. {
  9914. didWarnUpdateInsideUpdate = false;
  9915. currentlyProcessingQueue = null;
  9916. resetCurrentlyProcessingQueue = function () {
  9917. currentlyProcessingQueue = null;
  9918. };
  9919. }
  9920. function createUpdateQueue(baseState) {
  9921. var queue = {
  9922. baseState: baseState,
  9923. firstUpdate: null,
  9924. lastUpdate: null,
  9925. firstCapturedUpdate: null,
  9926. lastCapturedUpdate: null,
  9927. firstEffect: null,
  9928. lastEffect: null,
  9929. firstCapturedEffect: null,
  9930. lastCapturedEffect: null
  9931. };
  9932. return queue;
  9933. }
  9934. function cloneUpdateQueue(currentQueue) {
  9935. var queue = {
  9936. baseState: currentQueue.baseState,
  9937. firstUpdate: currentQueue.firstUpdate,
  9938. lastUpdate: currentQueue.lastUpdate,
  9939. // TODO: With resuming, if we bail out and resuse the child tree, we should
  9940. // keep these effects.
  9941. firstCapturedUpdate: null,
  9942. lastCapturedUpdate: null,
  9943. firstEffect: null,
  9944. lastEffect: null,
  9945. firstCapturedEffect: null,
  9946. lastCapturedEffect: null
  9947. };
  9948. return queue;
  9949. }
  9950. function createUpdate(expirationTime) {
  9951. return {
  9952. expirationTime: expirationTime,
  9953. tag: UpdateState,
  9954. payload: null,
  9955. callback: null,
  9956. next: null,
  9957. nextEffect: null
  9958. };
  9959. }
  9960. function appendUpdateToQueue(queue, update) {
  9961. // Append the update to the end of the list.
  9962. if (queue.lastUpdate === null) {
  9963. // Queue is empty
  9964. queue.firstUpdate = queue.lastUpdate = update;
  9965. } else {
  9966. queue.lastUpdate.next = update;
  9967. queue.lastUpdate = update;
  9968. }
  9969. }
  9970. function enqueueUpdate(fiber, update) {
  9971. // Update queues are created lazily.
  9972. var alternate = fiber.alternate;
  9973. var queue1 = void 0;
  9974. var queue2 = void 0;
  9975. if (alternate === null) {
  9976. // There's only one fiber.
  9977. queue1 = fiber.updateQueue;
  9978. queue2 = null;
  9979. if (queue1 === null) {
  9980. queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState);
  9981. }
  9982. } else {
  9983. // There are two owners.
  9984. queue1 = fiber.updateQueue;
  9985. queue2 = alternate.updateQueue;
  9986. if (queue1 === null) {
  9987. if (queue2 === null) {
  9988. // Neither fiber has an update queue. Create new ones.
  9989. queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState);
  9990. queue2 = alternate.updateQueue = createUpdateQueue(alternate.memoizedState);
  9991. } else {
  9992. // Only one fiber has an update queue. Clone to create a new one.
  9993. queue1 = fiber.updateQueue = cloneUpdateQueue(queue2);
  9994. }
  9995. } else {
  9996. if (queue2 === null) {
  9997. // Only one fiber has an update queue. Clone to create a new one.
  9998. queue2 = alternate.updateQueue = cloneUpdateQueue(queue1);
  9999. } else {
  10000. // Both owners have an update queue.
  10001. }
  10002. }
  10003. }
  10004. if (queue2 === null || queue1 === queue2) {
  10005. // There's only a single queue.
  10006. appendUpdateToQueue(queue1, update);
  10007. } else {
  10008. // There are two queues. We need to append the update to both queues,
  10009. // while accounting for the persistent structure of the list — we don't
  10010. // want the same update to be added multiple times.
  10011. if (queue1.lastUpdate === null || queue2.lastUpdate === null) {
  10012. // One of the queues is not empty. We must add the update to both queues.
  10013. appendUpdateToQueue(queue1, update);
  10014. appendUpdateToQueue(queue2, update);
  10015. } else {
  10016. // Both queues are non-empty. The last update is the same in both lists,
  10017. // because of structural sharing. So, only append to one of the lists.
  10018. appendUpdateToQueue(queue1, update);
  10019. // But we still need to update the `lastUpdate` pointer of queue2.
  10020. queue2.lastUpdate = update;
  10021. }
  10022. }
  10023. {
  10024. if (fiber.tag === ClassComponent && (currentlyProcessingQueue === queue1 || queue2 !== null && currentlyProcessingQueue === queue2) && !didWarnUpdateInsideUpdate) {
  10025. 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.');
  10026. didWarnUpdateInsideUpdate = true;
  10027. }
  10028. }
  10029. }
  10030. function enqueueCapturedUpdate(workInProgress, update) {
  10031. // Captured updates go into a separate list, and only on the work-in-
  10032. // progress queue.
  10033. var workInProgressQueue = workInProgress.updateQueue;
  10034. if (workInProgressQueue === null) {
  10035. workInProgressQueue = workInProgress.updateQueue = createUpdateQueue(workInProgress.memoizedState);
  10036. } else {
  10037. // TODO: I put this here rather than createWorkInProgress so that we don't
  10038. // clone the queue unnecessarily. There's probably a better way to
  10039. // structure this.
  10040. workInProgressQueue = ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue);
  10041. }
  10042. // Append the update to the end of the list.
  10043. if (workInProgressQueue.lastCapturedUpdate === null) {
  10044. // This is the first render phase update
  10045. workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update;
  10046. } else {
  10047. workInProgressQueue.lastCapturedUpdate.next = update;
  10048. workInProgressQueue.lastCapturedUpdate = update;
  10049. }
  10050. }
  10051. function ensureWorkInProgressQueueIsAClone(workInProgress, queue) {
  10052. var current = workInProgress.alternate;
  10053. if (current !== null) {
  10054. // If the work-in-progress queue is equal to the current queue,
  10055. // we need to clone it first.
  10056. if (queue === current.updateQueue) {
  10057. queue = workInProgress.updateQueue = cloneUpdateQueue(queue);
  10058. }
  10059. }
  10060. return queue;
  10061. }
  10062. function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) {
  10063. switch (update.tag) {
  10064. case ReplaceState:
  10065. {
  10066. var _payload = update.payload;
  10067. if (typeof _payload === 'function') {
  10068. // Updater function
  10069. {
  10070. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  10071. _payload.call(instance, prevState, nextProps);
  10072. }
  10073. }
  10074. return _payload.call(instance, prevState, nextProps);
  10075. }
  10076. // State object
  10077. return _payload;
  10078. }
  10079. case CaptureUpdate:
  10080. {
  10081. workInProgress.effectTag = workInProgress.effectTag & ~ShouldCapture | DidCapture;
  10082. }
  10083. // Intentional fallthrough
  10084. case UpdateState:
  10085. {
  10086. var _payload2 = update.payload;
  10087. var partialState = void 0;
  10088. if (typeof _payload2 === 'function') {
  10089. // Updater function
  10090. {
  10091. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  10092. _payload2.call(instance, prevState, nextProps);
  10093. }
  10094. }
  10095. partialState = _payload2.call(instance, prevState, nextProps);
  10096. } else {
  10097. // Partial state object
  10098. partialState = _payload2;
  10099. }
  10100. if (partialState === null || partialState === undefined) {
  10101. // Null and undefined are treated as no-ops.
  10102. return prevState;
  10103. }
  10104. // Merge the partial state and the previous state.
  10105. return _assign({}, prevState, partialState);
  10106. }
  10107. case ForceUpdate:
  10108. {
  10109. hasForceUpdate = true;
  10110. return prevState;
  10111. }
  10112. }
  10113. return prevState;
  10114. }
  10115. function processUpdateQueue(workInProgress, queue, props, instance, renderExpirationTime) {
  10116. hasForceUpdate = false;
  10117. queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue);
  10118. {
  10119. currentlyProcessingQueue = queue;
  10120. }
  10121. // These values may change as we process the queue.
  10122. var newBaseState = queue.baseState;
  10123. var newFirstUpdate = null;
  10124. var newExpirationTime = NoWork;
  10125. // Iterate through the list of updates to compute the result.
  10126. var update = queue.firstUpdate;
  10127. var resultState = newBaseState;
  10128. while (update !== null) {
  10129. var updateExpirationTime = update.expirationTime;
  10130. if (updateExpirationTime < renderExpirationTime) {
  10131. // This update does not have sufficient priority. Skip it.
  10132. if (newFirstUpdate === null) {
  10133. // This is the first skipped update. It will be the first update in
  10134. // the new list.
  10135. newFirstUpdate = update;
  10136. // Since this is the first update that was skipped, the current result
  10137. // is the new base state.
  10138. newBaseState = resultState;
  10139. }
  10140. // Since this update will remain in the list, update the remaining
  10141. // expiration time.
  10142. if (newExpirationTime < updateExpirationTime) {
  10143. newExpirationTime = updateExpirationTime;
  10144. }
  10145. } else {
  10146. // This update does have sufficient priority. Process it and compute
  10147. // a new result.
  10148. resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance);
  10149. var _callback = update.callback;
  10150. if (_callback !== null) {
  10151. workInProgress.effectTag |= Callback;
  10152. // Set this to null, in case it was mutated during an aborted render.
  10153. update.nextEffect = null;
  10154. if (queue.lastEffect === null) {
  10155. queue.firstEffect = queue.lastEffect = update;
  10156. } else {
  10157. queue.lastEffect.nextEffect = update;
  10158. queue.lastEffect = update;
  10159. }
  10160. }
  10161. }
  10162. // Continue to the next update.
  10163. update = update.next;
  10164. }
  10165. // Separately, iterate though the list of captured updates.
  10166. var newFirstCapturedUpdate = null;
  10167. update = queue.firstCapturedUpdate;
  10168. while (update !== null) {
  10169. var _updateExpirationTime = update.expirationTime;
  10170. if (_updateExpirationTime < renderExpirationTime) {
  10171. // This update does not have sufficient priority. Skip it.
  10172. if (newFirstCapturedUpdate === null) {
  10173. // This is the first skipped captured update. It will be the first
  10174. // update in the new list.
  10175. newFirstCapturedUpdate = update;
  10176. // If this is the first update that was skipped, the current result is
  10177. // the new base state.
  10178. if (newFirstUpdate === null) {
  10179. newBaseState = resultState;
  10180. }
  10181. }
  10182. // Since this update will remain in the list, update the remaining
  10183. // expiration time.
  10184. if (newExpirationTime < _updateExpirationTime) {
  10185. newExpirationTime = _updateExpirationTime;
  10186. }
  10187. } else {
  10188. // This update does have sufficient priority. Process it and compute
  10189. // a new result.
  10190. resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance);
  10191. var _callback2 = update.callback;
  10192. if (_callback2 !== null) {
  10193. workInProgress.effectTag |= Callback;
  10194. // Set this to null, in case it was mutated during an aborted render.
  10195. update.nextEffect = null;
  10196. if (queue.lastCapturedEffect === null) {
  10197. queue.firstCapturedEffect = queue.lastCapturedEffect = update;
  10198. } else {
  10199. queue.lastCapturedEffect.nextEffect = update;
  10200. queue.lastCapturedEffect = update;
  10201. }
  10202. }
  10203. }
  10204. update = update.next;
  10205. }
  10206. if (newFirstUpdate === null) {
  10207. queue.lastUpdate = null;
  10208. }
  10209. if (newFirstCapturedUpdate === null) {
  10210. queue.lastCapturedUpdate = null;
  10211. } else {
  10212. workInProgress.effectTag |= Callback;
  10213. }
  10214. if (newFirstUpdate === null && newFirstCapturedUpdate === null) {
  10215. // We processed every update, without skipping. That means the new base
  10216. // state is the same as the result state.
  10217. newBaseState = resultState;
  10218. }
  10219. queue.baseState = newBaseState;
  10220. queue.firstUpdate = newFirstUpdate;
  10221. queue.firstCapturedUpdate = newFirstCapturedUpdate;
  10222. // Set the remaining expiration time to be whatever is remaining in the queue.
  10223. // This should be fine because the only two other things that contribute to
  10224. // expiration time are props and context. We're already in the middle of the
  10225. // begin phase by the time we start processing the queue, so we've already
  10226. // dealt with the props. Context in components that specify
  10227. // shouldComponentUpdate is tricky; but we'll have to account for
  10228. // that regardless.
  10229. workInProgress.expirationTime = newExpirationTime;
  10230. workInProgress.memoizedState = resultState;
  10231. {
  10232. currentlyProcessingQueue = null;
  10233. }
  10234. }
  10235. function callCallback(callback, context) {
  10236. !(typeof callback === 'function') ? invariant(false, 'Invalid argument passed as callback. Expected a function. Instead received: %s', callback) : void 0;
  10237. callback.call(context);
  10238. }
  10239. function resetHasForceUpdateBeforeProcessing() {
  10240. hasForceUpdate = false;
  10241. }
  10242. function checkHasForceUpdateAfterProcessing() {
  10243. return hasForceUpdate;
  10244. }
  10245. function commitUpdateQueue(finishedWork, finishedQueue, instance, renderExpirationTime) {
  10246. // If the finished render included captured updates, and there are still
  10247. // lower priority updates left over, we need to keep the captured updates
  10248. // in the queue so that they are rebased and not dropped once we process the
  10249. // queue again at the lower priority.
  10250. if (finishedQueue.firstCapturedUpdate !== null) {
  10251. // Join the captured update list to the end of the normal list.
  10252. if (finishedQueue.lastUpdate !== null) {
  10253. finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate;
  10254. finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate;
  10255. }
  10256. // Clear the list of captured updates.
  10257. finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null;
  10258. }
  10259. // Commit the effects
  10260. commitUpdateEffects(finishedQueue.firstEffect, instance);
  10261. finishedQueue.firstEffect = finishedQueue.lastEffect = null;
  10262. commitUpdateEffects(finishedQueue.firstCapturedEffect, instance);
  10263. finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null;
  10264. }
  10265. function commitUpdateEffects(effect, instance) {
  10266. while (effect !== null) {
  10267. var _callback3 = effect.callback;
  10268. if (_callback3 !== null) {
  10269. effect.callback = null;
  10270. callCallback(_callback3, instance);
  10271. }
  10272. effect = effect.nextEffect;
  10273. }
  10274. }
  10275. function createCapturedValue(value, source) {
  10276. // If the value is an error, call this function immediately after it is thrown
  10277. // so the stack is accurate.
  10278. return {
  10279. value: value,
  10280. source: source,
  10281. stack: getStackByFiberInDevAndProd(source)
  10282. };
  10283. }
  10284. var valueCursor = createCursor(null);
  10285. var rendererSigil = void 0;
  10286. {
  10287. // Use this to detect multiple renderers using the same context
  10288. rendererSigil = {};
  10289. }
  10290. var currentlyRenderingFiber = null;
  10291. var lastContextDependency = null;
  10292. var lastContextWithAllBitsObserved = null;
  10293. function resetContextDependences() {
  10294. // This is called right before React yields execution, to ensure `readContext`
  10295. // cannot be called outside the render phase.
  10296. currentlyRenderingFiber = null;
  10297. lastContextDependency = null;
  10298. lastContextWithAllBitsObserved = null;
  10299. }
  10300. function pushProvider(providerFiber, nextValue) {
  10301. var context = providerFiber.type._context;
  10302. if (isPrimaryRenderer) {
  10303. push(valueCursor, context._currentValue, providerFiber);
  10304. context._currentValue = nextValue;
  10305. {
  10306. !(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;
  10307. context._currentRenderer = rendererSigil;
  10308. }
  10309. } else {
  10310. push(valueCursor, context._currentValue2, providerFiber);
  10311. context._currentValue2 = nextValue;
  10312. {
  10313. !(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;
  10314. context._currentRenderer2 = rendererSigil;
  10315. }
  10316. }
  10317. }
  10318. function popProvider(providerFiber) {
  10319. var currentValue = valueCursor.current;
  10320. pop(valueCursor, providerFiber);
  10321. var context = providerFiber.type._context;
  10322. if (isPrimaryRenderer) {
  10323. context._currentValue = currentValue;
  10324. } else {
  10325. context._currentValue2 = currentValue;
  10326. }
  10327. }
  10328. function calculateChangedBits(context, newValue, oldValue) {
  10329. // Use Object.is to compare the new context value to the old value. Inlined
  10330. // Object.is polyfill.
  10331. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  10332. if (oldValue === newValue && (oldValue !== 0 || 1 / oldValue === 1 / newValue) || oldValue !== oldValue && newValue !== newValue // eslint-disable-line no-self-compare
  10333. ) {
  10334. // No change
  10335. return 0;
  10336. } else {
  10337. var changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : maxSigned31BitInt;
  10338. {
  10339. !((changedBits & maxSigned31BitInt) === changedBits) ? warning$1(false, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits) : void 0;
  10340. }
  10341. return changedBits | 0;
  10342. }
  10343. }
  10344. function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
  10345. var fiber = workInProgress.child;
  10346. if (fiber !== null) {
  10347. // Set the return pointer of the child to the work-in-progress fiber.
  10348. fiber.return = workInProgress;
  10349. }
  10350. while (fiber !== null) {
  10351. var nextFiber = void 0;
  10352. // Visit this fiber.
  10353. var dependency = fiber.firstContextDependency;
  10354. if (dependency !== null) {
  10355. do {
  10356. // Check if the context matches.
  10357. if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) {
  10358. // Match! Schedule an update on this fiber.
  10359. if (fiber.tag === ClassComponent) {
  10360. // Schedule a force update on the work-in-progress.
  10361. var update = createUpdate(renderExpirationTime);
  10362. update.tag = ForceUpdate;
  10363. // TODO: Because we don't have a work-in-progress, this will add the
  10364. // update to the current fiber, too, which means it will persist even if
  10365. // this render is thrown away. Since it's a race condition, not sure it's
  10366. // worth fixing.
  10367. enqueueUpdate(fiber, update);
  10368. }
  10369. if (fiber.expirationTime < renderExpirationTime) {
  10370. fiber.expirationTime = renderExpirationTime;
  10371. }
  10372. var alternate = fiber.alternate;
  10373. if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
  10374. alternate.expirationTime = renderExpirationTime;
  10375. }
  10376. // Update the child expiration time of all the ancestors, including
  10377. // the alternates.
  10378. var node = fiber.return;
  10379. while (node !== null) {
  10380. alternate = node.alternate;
  10381. if (node.childExpirationTime < renderExpirationTime) {
  10382. node.childExpirationTime = renderExpirationTime;
  10383. if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
  10384. alternate.childExpirationTime = renderExpirationTime;
  10385. }
  10386. } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
  10387. alternate.childExpirationTime = renderExpirationTime;
  10388. } else {
  10389. // Neither alternate was updated, which means the rest of the
  10390. // ancestor path already has sufficient priority.
  10391. break;
  10392. }
  10393. node = node.return;
  10394. }
  10395. }
  10396. nextFiber = fiber.child;
  10397. dependency = dependency.next;
  10398. } while (dependency !== null);
  10399. } else if (fiber.tag === ContextProvider) {
  10400. // Don't scan deeper if this is a matching provider
  10401. nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
  10402. } else {
  10403. // Traverse down.
  10404. nextFiber = fiber.child;
  10405. }
  10406. if (nextFiber !== null) {
  10407. // Set the return pointer of the child to the work-in-progress fiber.
  10408. nextFiber.return = fiber;
  10409. } else {
  10410. // No child. Traverse to next sibling.
  10411. nextFiber = fiber;
  10412. while (nextFiber !== null) {
  10413. if (nextFiber === workInProgress) {
  10414. // We're back to the root of this subtree. Exit.
  10415. nextFiber = null;
  10416. break;
  10417. }
  10418. var sibling = nextFiber.sibling;
  10419. if (sibling !== null) {
  10420. // Set the return pointer of the sibling to the work-in-progress fiber.
  10421. sibling.return = nextFiber.return;
  10422. nextFiber = sibling;
  10423. break;
  10424. }
  10425. // No more siblings. Traverse up.
  10426. nextFiber = nextFiber.return;
  10427. }
  10428. }
  10429. fiber = nextFiber;
  10430. }
  10431. }
  10432. function prepareToReadContext(workInProgress, renderExpirationTime) {
  10433. currentlyRenderingFiber = workInProgress;
  10434. lastContextDependency = null;
  10435. lastContextWithAllBitsObserved = null;
  10436. // Reset the work-in-progress list
  10437. workInProgress.firstContextDependency = null;
  10438. }
  10439. function readContext(context, observedBits) {
  10440. if (lastContextWithAllBitsObserved === context) {
  10441. // Nothing to do. We already observe everything in this context.
  10442. } else if (observedBits === false || observedBits === 0) {
  10443. // Do not observe any updates.
  10444. } else {
  10445. var resolvedObservedBits = void 0; // Avoid deopting on observable arguments or heterogeneous types.
  10446. if (typeof observedBits !== 'number' || observedBits === maxSigned31BitInt) {
  10447. // Observe all updates.
  10448. lastContextWithAllBitsObserved = context;
  10449. resolvedObservedBits = maxSigned31BitInt;
  10450. } else {
  10451. resolvedObservedBits = observedBits;
  10452. }
  10453. var contextItem = {
  10454. context: context,
  10455. observedBits: resolvedObservedBits,
  10456. next: null
  10457. };
  10458. if (lastContextDependency === null) {
  10459. !(currentlyRenderingFiber !== null) ? invariant(false, 'Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps.') : void 0;
  10460. // This is the first dependency in the list
  10461. currentlyRenderingFiber.firstContextDependency = lastContextDependency = contextItem;
  10462. } else {
  10463. // Append a new context item.
  10464. lastContextDependency = lastContextDependency.next = contextItem;
  10465. }
  10466. }
  10467. return isPrimaryRenderer ? context._currentValue : context._currentValue2;
  10468. }
  10469. var NoEffect$1 = /* */0;
  10470. var UnmountSnapshot = /* */2;
  10471. var UnmountMutation = /* */4;
  10472. var MountMutation = /* */8;
  10473. var UnmountLayout = /* */16;
  10474. var MountLayout = /* */32;
  10475. var MountPassive = /* */64;
  10476. var UnmountPassive = /* */128;
  10477. function areHookInputsEqual(arr1, arr2) {
  10478. // Don't bother comparing lengths in prod because these arrays should be
  10479. // passed inline.
  10480. {
  10481. !(arr1.length === arr2.length) ? warning$1(false, 'Detected a variable number of hook dependencies. The length of the ' + 'dependencies array should be constant between renders.\n\n' + 'Previous: %s\n' + 'Incoming: %s', arr1.join(', '), arr2.join(', ')) : void 0;
  10482. }
  10483. for (var i = 0; i < arr1.length; i++) {
  10484. // Inlined Object.is polyfill.
  10485. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  10486. var val1 = arr1[i];
  10487. var val2 = arr2[i];
  10488. if (val1 === val2 && (val1 !== 0 || 1 / val1 === 1 / val2) || val1 !== val1 && val2 !== val2 // eslint-disable-line no-self-compare
  10489. ) {
  10490. continue;
  10491. }
  10492. return false;
  10493. }
  10494. return true;
  10495. }
  10496. // These are set right before calling the component.
  10497. var renderExpirationTime = NoWork;
  10498. // The work-in-progress fiber. I've named it differently to distinguish it from
  10499. // the work-in-progress hook.
  10500. var currentlyRenderingFiber$1 = null;
  10501. // Hooks are stored as a linked list on the fiber's memoizedState field. The
  10502. // current hook list is the list that belongs to the current fiber. The
  10503. // work-in-progress hook list is a new list that will be added to the
  10504. // work-in-progress fiber.
  10505. var firstCurrentHook = null;
  10506. var currentHook = null;
  10507. var firstWorkInProgressHook = null;
  10508. var workInProgressHook = null;
  10509. var remainingExpirationTime = NoWork;
  10510. var componentUpdateQueue = null;
  10511. // Updates scheduled during render will trigger an immediate re-render at the
  10512. // end of the current pass. We can't store these updates on the normal queue,
  10513. // because if the work is aborted, they should be discarded. Because this is
  10514. // a relatively rare case, we also don't want to add an additional field to
  10515. // either the hook or queue object types. So we store them in a lazily create
  10516. // map of queue -> render-phase updates, which are discarded once the component
  10517. // completes without re-rendering.
  10518. // Whether the work-in-progress hook is a re-rendered hook
  10519. var isReRender = false;
  10520. // Whether an update was scheduled during the currently executing render pass.
  10521. var didScheduleRenderPhaseUpdate = false;
  10522. // Lazily created map of render-phase updates
  10523. var renderPhaseUpdates = null;
  10524. // Counter to prevent infinite loops.
  10525. var numberOfReRenders = 0;
  10526. var RE_RENDER_LIMIT = 25;
  10527. function resolveCurrentlyRenderingFiber() {
  10528. !(currentlyRenderingFiber$1 !== null) ? invariant(false, 'Hooks can only be called inside the body of a function component.') : void 0;
  10529. return currentlyRenderingFiber$1;
  10530. }
  10531. function prepareToUseHooks(current, workInProgress, nextRenderExpirationTime) {
  10532. if (!enableHooks) {
  10533. return;
  10534. }
  10535. renderExpirationTime = nextRenderExpirationTime;
  10536. currentlyRenderingFiber$1 = workInProgress;
  10537. firstCurrentHook = current !== null ? current.memoizedState : null;
  10538. // The following should have already been reset
  10539. // currentHook = null;
  10540. // workInProgressHook = null;
  10541. // remainingExpirationTime = NoWork;
  10542. // componentUpdateQueue = null;
  10543. // isReRender = false;
  10544. // didScheduleRenderPhaseUpdate = false;
  10545. // renderPhaseUpdates = null;
  10546. // numberOfReRenders = 0;
  10547. }
  10548. function finishHooks(Component, props, children, refOrContext) {
  10549. if (!enableHooks) {
  10550. return children;
  10551. }
  10552. // This must be called after every function component to prevent hooks from
  10553. // being used in classes.
  10554. while (didScheduleRenderPhaseUpdate) {
  10555. // Updates were scheduled during the render phase. They are stored in
  10556. // the `renderPhaseUpdates` map. Call the component again, reusing the
  10557. // work-in-progress hooks and applying the additional updates on top. Keep
  10558. // restarting until no more updates are scheduled.
  10559. didScheduleRenderPhaseUpdate = false;
  10560. numberOfReRenders += 1;
  10561. // Start over from the beginning of the list
  10562. currentHook = null;
  10563. workInProgressHook = null;
  10564. componentUpdateQueue = null;
  10565. children = Component(props, refOrContext);
  10566. }
  10567. renderPhaseUpdates = null;
  10568. numberOfReRenders = 0;
  10569. var renderedWork = currentlyRenderingFiber$1;
  10570. renderedWork.memoizedState = firstWorkInProgressHook;
  10571. renderedWork.expirationTime = remainingExpirationTime;
  10572. renderedWork.updateQueue = componentUpdateQueue;
  10573. var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
  10574. renderExpirationTime = NoWork;
  10575. currentlyRenderingFiber$1 = null;
  10576. firstCurrentHook = null;
  10577. currentHook = null;
  10578. firstWorkInProgressHook = null;
  10579. workInProgressHook = null;
  10580. remainingExpirationTime = NoWork;
  10581. componentUpdateQueue = null;
  10582. // Always set during createWorkInProgress
  10583. // isReRender = false;
  10584. // These were reset above
  10585. // didScheduleRenderPhaseUpdate = false;
  10586. // renderPhaseUpdates = null;
  10587. // numberOfReRenders = 0;
  10588. !!didRenderTooFewHooks ? invariant(false, 'Rendered fewer hooks than expected. This may be caused by an accidental early return statement.') : void 0;
  10589. return children;
  10590. }
  10591. function resetHooks() {
  10592. if (!enableHooks) {
  10593. return;
  10594. }
  10595. // This is called instead of `finishHooks` if the component throws. It's also
  10596. // called inside mountIndeterminateComponent if we determine the component
  10597. // is a module-style component.
  10598. renderExpirationTime = NoWork;
  10599. currentlyRenderingFiber$1 = null;
  10600. firstCurrentHook = null;
  10601. currentHook = null;
  10602. firstWorkInProgressHook = null;
  10603. workInProgressHook = null;
  10604. remainingExpirationTime = NoWork;
  10605. componentUpdateQueue = null;
  10606. // Always set during createWorkInProgress
  10607. // isReRender = false;
  10608. didScheduleRenderPhaseUpdate = false;
  10609. renderPhaseUpdates = null;
  10610. numberOfReRenders = 0;
  10611. }
  10612. function createHook() {
  10613. return {
  10614. memoizedState: null,
  10615. baseState: null,
  10616. queue: null,
  10617. baseUpdate: null,
  10618. next: null
  10619. };
  10620. }
  10621. function cloneHook(hook) {
  10622. return {
  10623. memoizedState: hook.memoizedState,
  10624. baseState: hook.memoizedState,
  10625. queue: hook.queue,
  10626. baseUpdate: hook.baseUpdate,
  10627. next: null
  10628. };
  10629. }
  10630. function createWorkInProgressHook() {
  10631. if (workInProgressHook === null) {
  10632. // This is the first hook in the list
  10633. if (firstWorkInProgressHook === null) {
  10634. isReRender = false;
  10635. currentHook = firstCurrentHook;
  10636. if (currentHook === null) {
  10637. // This is a newly mounted hook
  10638. workInProgressHook = createHook();
  10639. } else {
  10640. // Clone the current hook.
  10641. workInProgressHook = cloneHook(currentHook);
  10642. }
  10643. firstWorkInProgressHook = workInProgressHook;
  10644. } else {
  10645. // There's already a work-in-progress. Reuse it.
  10646. isReRender = true;
  10647. currentHook = firstCurrentHook;
  10648. workInProgressHook = firstWorkInProgressHook;
  10649. }
  10650. } else {
  10651. if (workInProgressHook.next === null) {
  10652. isReRender = false;
  10653. var hook = void 0;
  10654. if (currentHook === null) {
  10655. // This is a newly mounted hook
  10656. hook = createHook();
  10657. } else {
  10658. currentHook = currentHook.next;
  10659. if (currentHook === null) {
  10660. // This is a newly mounted hook
  10661. hook = createHook();
  10662. } else {
  10663. // Clone the current hook.
  10664. hook = cloneHook(currentHook);
  10665. }
  10666. }
  10667. // Append to the end of the list
  10668. workInProgressHook = workInProgressHook.next = hook;
  10669. } else {
  10670. // There's already a work-in-progress. Reuse it.
  10671. isReRender = true;
  10672. workInProgressHook = workInProgressHook.next;
  10673. currentHook = currentHook !== null ? currentHook.next : null;
  10674. }
  10675. }
  10676. return workInProgressHook;
  10677. }
  10678. function createFunctionComponentUpdateQueue() {
  10679. return {
  10680. lastEffect: null
  10681. };
  10682. }
  10683. function basicStateReducer(state, action) {
  10684. return typeof action === 'function' ? action(state) : action;
  10685. }
  10686. function useContext(context, observedBits) {
  10687. // Ensure we're in a function component (class components support only the
  10688. // .unstable_read() form)
  10689. resolveCurrentlyRenderingFiber();
  10690. return readContext(context, observedBits);
  10691. }
  10692. function useState(initialState) {
  10693. return useReducer(basicStateReducer,
  10694. // useReducer has a special case to support lazy useState initializers
  10695. initialState);
  10696. }
  10697. function useReducer(reducer, initialState, initialAction) {
  10698. currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber();
  10699. workInProgressHook = createWorkInProgressHook();
  10700. var queue = workInProgressHook.queue;
  10701. if (queue !== null) {
  10702. // Already have a queue, so this is an update.
  10703. if (isReRender) {
  10704. // This is a re-render. Apply the new render phase updates to the previous
  10705. var _dispatch2 = queue.dispatch;
  10706. if (renderPhaseUpdates !== null) {
  10707. // Render phase updates are stored in a map of queue -> linked list
  10708. var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
  10709. if (firstRenderPhaseUpdate !== undefined) {
  10710. renderPhaseUpdates.delete(queue);
  10711. var newState = workInProgressHook.memoizedState;
  10712. var update = firstRenderPhaseUpdate;
  10713. do {
  10714. // Process this render phase update. We don't have to check the
  10715. // priority because it will always be the same as the current
  10716. // render's.
  10717. var _action = update.action;
  10718. newState = reducer(newState, _action);
  10719. update = update.next;
  10720. } while (update !== null);
  10721. workInProgressHook.memoizedState = newState;
  10722. // Don't persist the state accumlated from the render phase updates to
  10723. // the base state unless the queue is empty.
  10724. // TODO: Not sure if this is the desired semantics, but it's what we
  10725. // do for gDSFP. I can't remember why.
  10726. if (workInProgressHook.baseUpdate === queue.last) {
  10727. workInProgressHook.baseState = newState;
  10728. }
  10729. return [newState, _dispatch2];
  10730. }
  10731. }
  10732. return [workInProgressHook.memoizedState, _dispatch2];
  10733. }
  10734. // The last update in the entire queue
  10735. var _last = queue.last;
  10736. // The last update that is part of the base state.
  10737. var _baseUpdate = workInProgressHook.baseUpdate;
  10738. // Find the first unprocessed update.
  10739. var first = void 0;
  10740. if (_baseUpdate !== null) {
  10741. if (_last !== null) {
  10742. // For the first update, the queue is a circular linked list where
  10743. // `queue.last.next = queue.first`. Once the first update commits, and
  10744. // the `baseUpdate` is no longer empty, we can unravel the list.
  10745. _last.next = null;
  10746. }
  10747. first = _baseUpdate.next;
  10748. } else {
  10749. first = _last !== null ? _last.next : null;
  10750. }
  10751. if (first !== null) {
  10752. var _newState = workInProgressHook.baseState;
  10753. var newBaseState = null;
  10754. var newBaseUpdate = null;
  10755. var prevUpdate = _baseUpdate;
  10756. var _update = first;
  10757. var didSkip = false;
  10758. do {
  10759. var updateExpirationTime = _update.expirationTime;
  10760. if (updateExpirationTime < renderExpirationTime) {
  10761. // Priority is insufficient. Skip this update. If this is the first
  10762. // skipped update, the previous update/state is the new base
  10763. // update/state.
  10764. if (!didSkip) {
  10765. didSkip = true;
  10766. newBaseUpdate = prevUpdate;
  10767. newBaseState = _newState;
  10768. }
  10769. // Update the remaining priority in the queue.
  10770. if (updateExpirationTime > remainingExpirationTime) {
  10771. remainingExpirationTime = updateExpirationTime;
  10772. }
  10773. } else {
  10774. // Process this update.
  10775. var _action2 = _update.action;
  10776. _newState = reducer(_newState, _action2);
  10777. }
  10778. prevUpdate = _update;
  10779. _update = _update.next;
  10780. } while (_update !== null && _update !== first);
  10781. if (!didSkip) {
  10782. newBaseUpdate = prevUpdate;
  10783. newBaseState = _newState;
  10784. }
  10785. workInProgressHook.memoizedState = _newState;
  10786. workInProgressHook.baseUpdate = newBaseUpdate;
  10787. workInProgressHook.baseState = newBaseState;
  10788. }
  10789. var _dispatch = queue.dispatch;
  10790. return [workInProgressHook.memoizedState, _dispatch];
  10791. }
  10792. // There's no existing queue, so this is the initial render.
  10793. if (reducer === basicStateReducer) {
  10794. // Special case for `useState`.
  10795. if (typeof initialState === 'function') {
  10796. initialState = initialState();
  10797. }
  10798. } else if (initialAction !== undefined && initialAction !== null) {
  10799. initialState = reducer(initialState, initialAction);
  10800. }
  10801. workInProgressHook.memoizedState = workInProgressHook.baseState = initialState;
  10802. queue = workInProgressHook.queue = {
  10803. last: null,
  10804. dispatch: null
  10805. };
  10806. var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue);
  10807. return [workInProgressHook.memoizedState, dispatch];
  10808. }
  10809. function pushEffect(tag, create, destroy, inputs) {
  10810. var effect = {
  10811. tag: tag,
  10812. create: create,
  10813. destroy: destroy,
  10814. inputs: inputs,
  10815. // Circular
  10816. next: null
  10817. };
  10818. if (componentUpdateQueue === null) {
  10819. componentUpdateQueue = createFunctionComponentUpdateQueue();
  10820. componentUpdateQueue.lastEffect = effect.next = effect;
  10821. } else {
  10822. var _lastEffect = componentUpdateQueue.lastEffect;
  10823. if (_lastEffect === null) {
  10824. componentUpdateQueue.lastEffect = effect.next = effect;
  10825. } else {
  10826. var firstEffect = _lastEffect.next;
  10827. _lastEffect.next = effect;
  10828. effect.next = firstEffect;
  10829. componentUpdateQueue.lastEffect = effect;
  10830. }
  10831. }
  10832. return effect;
  10833. }
  10834. function useRef(initialValue) {
  10835. currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber();
  10836. workInProgressHook = createWorkInProgressHook();
  10837. var ref = void 0;
  10838. if (workInProgressHook.memoizedState === null) {
  10839. ref = { current: initialValue };
  10840. {
  10841. Object.seal(ref);
  10842. }
  10843. workInProgressHook.memoizedState = ref;
  10844. } else {
  10845. ref = workInProgressHook.memoizedState;
  10846. }
  10847. return ref;
  10848. }
  10849. function useMutationEffect(create, inputs) {
  10850. useEffectImpl(Snapshot | Update, UnmountSnapshot | MountMutation, create, inputs);
  10851. }
  10852. function useLayoutEffect(create, inputs) {
  10853. useEffectImpl(Update, UnmountMutation | MountLayout, create, inputs);
  10854. }
  10855. function useEffect(create, inputs) {
  10856. useEffectImpl(Update | Passive, UnmountPassive | MountPassive, create, inputs);
  10857. }
  10858. function useEffectImpl(fiberEffectTag, hookEffectTag, create, inputs) {
  10859. currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber();
  10860. workInProgressHook = createWorkInProgressHook();
  10861. var nextInputs = inputs !== undefined && inputs !== null ? inputs : [create];
  10862. var destroy = null;
  10863. if (currentHook !== null) {
  10864. var prevEffect = currentHook.memoizedState;
  10865. destroy = prevEffect.destroy;
  10866. if (areHookInputsEqual(nextInputs, prevEffect.inputs)) {
  10867. pushEffect(NoEffect$1, create, destroy, nextInputs);
  10868. return;
  10869. }
  10870. }
  10871. currentlyRenderingFiber$1.effectTag |= fiberEffectTag;
  10872. workInProgressHook.memoizedState = pushEffect(hookEffectTag, create, destroy, nextInputs);
  10873. }
  10874. function useImperativeMethods(ref, create, inputs) {
  10875. // TODO: If inputs are provided, should we skip comparing the ref itself?
  10876. var nextInputs = inputs !== null && inputs !== undefined ? inputs.concat([ref]) : [ref, create];
  10877. // TODO: I've implemented this on top of useEffect because it's almost the
  10878. // same thing, and it would require an equal amount of code. It doesn't seem
  10879. // like a common enough use case to justify the additional size.
  10880. useEffectImpl(Update, UnmountMutation | MountLayout, function () {
  10881. if (typeof ref === 'function') {
  10882. var refCallback = ref;
  10883. var _inst = create();
  10884. refCallback(_inst);
  10885. return function () {
  10886. return refCallback(null);
  10887. };
  10888. } else if (ref !== null && ref !== undefined) {
  10889. var refObject = ref;
  10890. var _inst2 = create();
  10891. refObject.current = _inst2;
  10892. return function () {
  10893. refObject.current = null;
  10894. };
  10895. }
  10896. }, nextInputs);
  10897. }
  10898. function useCallback(callback, inputs) {
  10899. currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber();
  10900. workInProgressHook = createWorkInProgressHook();
  10901. var nextInputs = inputs !== undefined && inputs !== null ? inputs : [callback];
  10902. var prevState = workInProgressHook.memoizedState;
  10903. if (prevState !== null) {
  10904. var prevInputs = prevState[1];
  10905. if (areHookInputsEqual(nextInputs, prevInputs)) {
  10906. return prevState[0];
  10907. }
  10908. }
  10909. workInProgressHook.memoizedState = [callback, nextInputs];
  10910. return callback;
  10911. }
  10912. function useMemo(nextCreate, inputs) {
  10913. currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber();
  10914. workInProgressHook = createWorkInProgressHook();
  10915. var nextInputs = inputs !== undefined && inputs !== null ? inputs : [nextCreate];
  10916. var prevState = workInProgressHook.memoizedState;
  10917. if (prevState !== null) {
  10918. var prevInputs = prevState[1];
  10919. if (areHookInputsEqual(nextInputs, prevInputs)) {
  10920. return prevState[0];
  10921. }
  10922. }
  10923. var nextValue = nextCreate();
  10924. workInProgressHook.memoizedState = [nextValue, nextInputs];
  10925. return nextValue;
  10926. }
  10927. function dispatchAction(fiber, queue, action) {
  10928. !(numberOfReRenders < RE_RENDER_LIMIT) ? invariant(false, 'Too many re-renders. React limits the number of renders to prevent an infinite loop.') : void 0;
  10929. var alternate = fiber.alternate;
  10930. if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) {
  10931. // This is a render phase update. Stash it in a lazily-created map of
  10932. // queue -> linked list of updates. After this render pass, we'll restart
  10933. // and apply the stashed updates on top of the work-in-progress hook.
  10934. didScheduleRenderPhaseUpdate = true;
  10935. var update = {
  10936. expirationTime: renderExpirationTime,
  10937. action: action,
  10938. next: null
  10939. };
  10940. if (renderPhaseUpdates === null) {
  10941. renderPhaseUpdates = new Map();
  10942. }
  10943. var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
  10944. if (firstRenderPhaseUpdate === undefined) {
  10945. renderPhaseUpdates.set(queue, update);
  10946. } else {
  10947. // Append the update to the end of the list.
  10948. var lastRenderPhaseUpdate = firstRenderPhaseUpdate;
  10949. while (lastRenderPhaseUpdate.next !== null) {
  10950. lastRenderPhaseUpdate = lastRenderPhaseUpdate.next;
  10951. }
  10952. lastRenderPhaseUpdate.next = update;
  10953. }
  10954. } else {
  10955. var currentTime = requestCurrentTime();
  10956. var _expirationTime = computeExpirationForFiber(currentTime, fiber);
  10957. var _update2 = {
  10958. expirationTime: _expirationTime,
  10959. action: action,
  10960. next: null
  10961. };
  10962. flushPassiveEffects();
  10963. // Append the update to the end of the list.
  10964. var _last2 = queue.last;
  10965. if (_last2 === null) {
  10966. // This is the first update. Create a circular list.
  10967. _update2.next = _update2;
  10968. } else {
  10969. var first = _last2.next;
  10970. if (first !== null) {
  10971. // Still circular.
  10972. _update2.next = first;
  10973. }
  10974. _last2.next = _update2;
  10975. }
  10976. queue.last = _update2;
  10977. scheduleWork(fiber, _expirationTime);
  10978. }
  10979. }
  10980. var NO_CONTEXT = {};
  10981. var contextStackCursor$1 = createCursor(NO_CONTEXT);
  10982. var contextFiberStackCursor = createCursor(NO_CONTEXT);
  10983. var rootInstanceStackCursor = createCursor(NO_CONTEXT);
  10984. function requiredContext(c) {
  10985. !(c !== NO_CONTEXT) ? invariant(false, 'Expected host context to exist. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  10986. return c;
  10987. }
  10988. function getRootHostContainer() {
  10989. var rootInstance = requiredContext(rootInstanceStackCursor.current);
  10990. return rootInstance;
  10991. }
  10992. function pushHostContainer(fiber, nextRootInstance) {
  10993. // Push current root instance onto the stack;
  10994. // This allows us to reset root when portals are popped.
  10995. push(rootInstanceStackCursor, nextRootInstance, fiber);
  10996. // Track the context and the Fiber that provided it.
  10997. // This enables us to pop only Fibers that provide unique contexts.
  10998. push(contextFiberStackCursor, fiber, fiber);
  10999. // Finally, we need to push the host context to the stack.
  11000. // However, we can't just call getRootHostContext() and push it because
  11001. // we'd have a different number of entries on the stack depending on
  11002. // whether getRootHostContext() throws somewhere in renderer code or not.
  11003. // So we push an empty value first. This lets us safely unwind on errors.
  11004. push(contextStackCursor$1, NO_CONTEXT, fiber);
  11005. var nextRootContext = getRootHostContext(nextRootInstance);
  11006. // Now that we know this function doesn't throw, replace it.
  11007. pop(contextStackCursor$1, fiber);
  11008. push(contextStackCursor$1, nextRootContext, fiber);
  11009. }
  11010. function popHostContainer(fiber) {
  11011. pop(contextStackCursor$1, fiber);
  11012. pop(contextFiberStackCursor, fiber);
  11013. pop(rootInstanceStackCursor, fiber);
  11014. }
  11015. function getHostContext() {
  11016. var context = requiredContext(contextStackCursor$1.current);
  11017. return context;
  11018. }
  11019. function pushHostContext(fiber) {
  11020. var rootInstance = requiredContext(rootInstanceStackCursor.current);
  11021. var context = requiredContext(contextStackCursor$1.current);
  11022. var nextContext = getChildHostContext(context, fiber.type, rootInstance);
  11023. // Don't push this Fiber's context unless it's unique.
  11024. if (context === nextContext) {
  11025. return;
  11026. }
  11027. // Track the context and the Fiber that provided it.
  11028. // This enables us to pop only Fibers that provide unique contexts.
  11029. push(contextFiberStackCursor, fiber, fiber);
  11030. push(contextStackCursor$1, nextContext, fiber);
  11031. }
  11032. function popHostContext(fiber) {
  11033. // Do not pop unless this Fiber provided the current context.
  11034. // pushHostContext() only pushes Fibers that provide unique contexts.
  11035. if (contextFiberStackCursor.current !== fiber) {
  11036. return;
  11037. }
  11038. pop(contextStackCursor$1, fiber);
  11039. pop(contextFiberStackCursor, fiber);
  11040. }
  11041. var commitTime = 0;
  11042. var profilerStartTime = -1;
  11043. function getCommitTime() {
  11044. return commitTime;
  11045. }
  11046. function recordCommitTime() {
  11047. if (!enableProfilerTimer) {
  11048. return;
  11049. }
  11050. commitTime = scheduler.unstable_now();
  11051. }
  11052. function startProfilerTimer(fiber) {
  11053. if (!enableProfilerTimer) {
  11054. return;
  11055. }
  11056. profilerStartTime = scheduler.unstable_now();
  11057. if (fiber.actualStartTime < 0) {
  11058. fiber.actualStartTime = scheduler.unstable_now();
  11059. }
  11060. }
  11061. function stopProfilerTimerIfRunning(fiber) {
  11062. if (!enableProfilerTimer) {
  11063. return;
  11064. }
  11065. profilerStartTime = -1;
  11066. }
  11067. function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
  11068. if (!enableProfilerTimer) {
  11069. return;
  11070. }
  11071. if (profilerStartTime >= 0) {
  11072. var elapsedTime = scheduler.unstable_now() - profilerStartTime;
  11073. fiber.actualDuration += elapsedTime;
  11074. if (overrideBaseTime) {
  11075. fiber.selfBaseDuration = elapsedTime;
  11076. }
  11077. profilerStartTime = -1;
  11078. }
  11079. }
  11080. function resolveDefaultProps(Component, baseProps) {
  11081. if (Component && Component.defaultProps) {
  11082. // Resolve default props. Taken from ReactElement
  11083. var props = _assign({}, baseProps);
  11084. var defaultProps = Component.defaultProps;
  11085. for (var propName in defaultProps) {
  11086. if (props[propName] === undefined) {
  11087. props[propName] = defaultProps[propName];
  11088. }
  11089. }
  11090. return props;
  11091. }
  11092. return baseProps;
  11093. }
  11094. function readLazyComponentType(lazyComponent) {
  11095. var status = lazyComponent._status;
  11096. var result = lazyComponent._result;
  11097. switch (status) {
  11098. case Resolved:
  11099. {
  11100. var Component = result;
  11101. return Component;
  11102. }
  11103. case Rejected:
  11104. {
  11105. var error = result;
  11106. throw error;
  11107. }
  11108. case Pending:
  11109. {
  11110. var thenable = result;
  11111. throw thenable;
  11112. }
  11113. default:
  11114. {
  11115. lazyComponent._status = Pending;
  11116. var ctor = lazyComponent._ctor;
  11117. var _thenable = ctor();
  11118. _thenable.then(function (moduleObject) {
  11119. if (lazyComponent._status === Pending) {
  11120. var defaultExport = moduleObject.default;
  11121. {
  11122. if (defaultExport === undefined) {
  11123. 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);
  11124. }
  11125. }
  11126. lazyComponent._status = Resolved;
  11127. lazyComponent._result = defaultExport;
  11128. }
  11129. }, function (error) {
  11130. if (lazyComponent._status === Pending) {
  11131. lazyComponent._status = Rejected;
  11132. lazyComponent._result = error;
  11133. }
  11134. });
  11135. lazyComponent._result = _thenable;
  11136. throw _thenable;
  11137. }
  11138. }
  11139. }
  11140. var ReactCurrentOwner$4 = ReactSharedInternals.ReactCurrentOwner;
  11141. function readContext$1(contextType) {
  11142. var dispatcher = ReactCurrentOwner$4.currentDispatcher;
  11143. return dispatcher.readContext(contextType);
  11144. }
  11145. var fakeInternalInstance = {};
  11146. var isArray$1 = Array.isArray;
  11147. // React.Component uses a shared frozen object by default.
  11148. // We'll use it to determine whether we need to initialize legacy refs.
  11149. var emptyRefsObject = new React.Component().refs;
  11150. var didWarnAboutStateAssignmentForComponent = void 0;
  11151. var didWarnAboutUninitializedState = void 0;
  11152. var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = void 0;
  11153. var didWarnAboutLegacyLifecyclesAndDerivedState = void 0;
  11154. var didWarnAboutUndefinedDerivedState = void 0;
  11155. var warnOnUndefinedDerivedState = void 0;
  11156. var warnOnInvalidCallback$1 = void 0;
  11157. var didWarnAboutDirectlyAssigningPropsToState = void 0;
  11158. var didWarnAboutContextTypeAndContextTypes = void 0;
  11159. var didWarnAboutInvalidateContextType = void 0;
  11160. {
  11161. didWarnAboutStateAssignmentForComponent = new Set();
  11162. didWarnAboutUninitializedState = new Set();
  11163. didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set();
  11164. didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
  11165. didWarnAboutDirectlyAssigningPropsToState = new Set();
  11166. didWarnAboutUndefinedDerivedState = new Set();
  11167. didWarnAboutContextTypeAndContextTypes = new Set();
  11168. didWarnAboutInvalidateContextType = new Set();
  11169. var didWarnOnInvalidCallback = new Set();
  11170. warnOnInvalidCallback$1 = function (callback, callerName) {
  11171. if (callback === null || typeof callback === 'function') {
  11172. return;
  11173. }
  11174. var key = callerName + '_' + callback;
  11175. if (!didWarnOnInvalidCallback.has(key)) {
  11176. didWarnOnInvalidCallback.add(key);
  11177. warningWithoutStack$1(false, '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
  11178. }
  11179. };
  11180. warnOnUndefinedDerivedState = function (type, partialState) {
  11181. if (partialState === undefined) {
  11182. var componentName = getComponentName(type) || 'Component';
  11183. if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
  11184. didWarnAboutUndefinedDerivedState.add(componentName);
  11185. warningWithoutStack$1(false, '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
  11186. }
  11187. }
  11188. };
  11189. // This is so gross but it's at least non-critical and can be removed if
  11190. // it causes problems. This is meant to give a nicer error message for
  11191. // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component,
  11192. // ...)) which otherwise throws a "_processChildContext is not a function"
  11193. // exception.
  11194. Object.defineProperty(fakeInternalInstance, '_processChildContext', {
  11195. enumerable: false,
  11196. value: function () {
  11197. invariant(false, '_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).');
  11198. }
  11199. });
  11200. Object.freeze(fakeInternalInstance);
  11201. }
  11202. function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) {
  11203. var prevState = workInProgress.memoizedState;
  11204. {
  11205. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  11206. // Invoke the function an extra time to help detect side-effects.
  11207. getDerivedStateFromProps(nextProps, prevState);
  11208. }
  11209. }
  11210. var partialState = getDerivedStateFromProps(nextProps, prevState);
  11211. {
  11212. warnOnUndefinedDerivedState(ctor, partialState);
  11213. }
  11214. // Merge the partial state and the previous state.
  11215. var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState);
  11216. workInProgress.memoizedState = memoizedState;
  11217. // Once the update queue is empty, persist the derived state onto the
  11218. // base state.
  11219. var updateQueue = workInProgress.updateQueue;
  11220. if (updateQueue !== null && workInProgress.expirationTime === NoWork) {
  11221. updateQueue.baseState = memoizedState;
  11222. }
  11223. }
  11224. var classComponentUpdater = {
  11225. isMounted: isMounted,
  11226. enqueueSetState: function (inst, payload, callback) {
  11227. var fiber = get(inst);
  11228. var currentTime = requestCurrentTime();
  11229. var expirationTime = computeExpirationForFiber(currentTime, fiber);
  11230. var update = createUpdate(expirationTime);
  11231. update.payload = payload;
  11232. if (callback !== undefined && callback !== null) {
  11233. {
  11234. warnOnInvalidCallback$1(callback, 'setState');
  11235. }
  11236. update.callback = callback;
  11237. }
  11238. flushPassiveEffects();
  11239. enqueueUpdate(fiber, update);
  11240. scheduleWork(fiber, expirationTime);
  11241. },
  11242. enqueueReplaceState: function (inst, payload, callback) {
  11243. var fiber = get(inst);
  11244. var currentTime = requestCurrentTime();
  11245. var expirationTime = computeExpirationForFiber(currentTime, fiber);
  11246. var update = createUpdate(expirationTime);
  11247. update.tag = ReplaceState;
  11248. update.payload = payload;
  11249. if (callback !== undefined && callback !== null) {
  11250. {
  11251. warnOnInvalidCallback$1(callback, 'replaceState');
  11252. }
  11253. update.callback = callback;
  11254. }
  11255. flushPassiveEffects();
  11256. enqueueUpdate(fiber, update);
  11257. scheduleWork(fiber, expirationTime);
  11258. },
  11259. enqueueForceUpdate: function (inst, callback) {
  11260. var fiber = get(inst);
  11261. var currentTime = requestCurrentTime();
  11262. var expirationTime = computeExpirationForFiber(currentTime, fiber);
  11263. var update = createUpdate(expirationTime);
  11264. update.tag = ForceUpdate;
  11265. if (callback !== undefined && callback !== null) {
  11266. {
  11267. warnOnInvalidCallback$1(callback, 'forceUpdate');
  11268. }
  11269. update.callback = callback;
  11270. }
  11271. flushPassiveEffects();
  11272. enqueueUpdate(fiber, update);
  11273. scheduleWork(fiber, expirationTime);
  11274. }
  11275. };
  11276. function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) {
  11277. var instance = workInProgress.stateNode;
  11278. if (typeof instance.shouldComponentUpdate === 'function') {
  11279. startPhaseTimer(workInProgress, 'shouldComponentUpdate');
  11280. var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext);
  11281. stopPhaseTimer();
  11282. {
  11283. !(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;
  11284. }
  11285. return shouldUpdate;
  11286. }
  11287. if (ctor.prototype && ctor.prototype.isPureReactComponent) {
  11288. return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
  11289. }
  11290. return true;
  11291. }
  11292. function checkClassInstance(workInProgress, ctor, newProps) {
  11293. var instance = workInProgress.stateNode;
  11294. {
  11295. var name = getComponentName(ctor) || 'Component';
  11296. var renderPresent = instance.render;
  11297. if (!renderPresent) {
  11298. if (ctor.prototype && typeof ctor.prototype.render === 'function') {
  11299. warningWithoutStack$1(false, '%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
  11300. } else {
  11301. warningWithoutStack$1(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
  11302. }
  11303. }
  11304. var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state;
  11305. !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;
  11306. var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved;
  11307. !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;
  11308. var noInstancePropTypes = !instance.propTypes;
  11309. !noInstancePropTypes ? warningWithoutStack$1(false, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name) : void 0;
  11310. var noInstanceContextType = !instance.contextType;
  11311. !noInstanceContextType ? warningWithoutStack$1(false, 'contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name) : void 0;
  11312. var noInstanceContextTypes = !instance.contextTypes;
  11313. !noInstanceContextTypes ? warningWithoutStack$1(false, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name) : void 0;
  11314. if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
  11315. didWarnAboutContextTypeAndContextTypes.add(ctor);
  11316. warningWithoutStack$1(false, '%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
  11317. }
  11318. var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';
  11319. !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;
  11320. if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
  11321. 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');
  11322. }
  11323. var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';
  11324. !noComponentDidUnmount ? warningWithoutStack$1(false, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name) : void 0;
  11325. var noComponentDidReceiveProps = typeof instance.componentDidReceiveProps !== 'function';
  11326. !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;
  11327. var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';
  11328. !noComponentWillRecieveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name) : void 0;
  11329. var noUnsafeComponentWillRecieveProps = typeof instance.UNSAFE_componentWillRecieveProps !== 'function';
  11330. !noUnsafeComponentWillRecieveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name) : void 0;
  11331. var hasMutatedProps = instance.props !== newProps;
  11332. !(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;
  11333. var noInstanceDefaultProps = !instance.defaultProps;
  11334. !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;
  11335. if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) {
  11336. didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor);
  11337. warningWithoutStack$1(false, '%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(ctor));
  11338. }
  11339. var noInstanceGetDerivedStateFromProps = typeof instance.getDerivedStateFromProps !== 'function';
  11340. !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;
  11341. var noInstanceGetDerivedStateFromCatch = typeof instance.getDerivedStateFromError !== 'function';
  11342. !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;
  11343. var noStaticGetSnapshotBeforeUpdate = typeof ctor.getSnapshotBeforeUpdate !== 'function';
  11344. !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;
  11345. var _state = instance.state;
  11346. if (_state && (typeof _state !== 'object' || isArray$1(_state))) {
  11347. warningWithoutStack$1(false, '%s.state: must be set to an object or null', name);
  11348. }
  11349. if (typeof instance.getChildContext === 'function') {
  11350. !(typeof ctor.childContextTypes === 'object') ? warningWithoutStack$1(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name) : void 0;
  11351. }
  11352. }
  11353. }
  11354. function adoptClassInstance(workInProgress, instance) {
  11355. instance.updater = classComponentUpdater;
  11356. workInProgress.stateNode = instance;
  11357. // The instance needs access to the fiber so that it can schedule updates
  11358. set(instance, workInProgress);
  11359. {
  11360. instance._reactInternalInstance = fakeInternalInstance;
  11361. }
  11362. }
  11363. function constructClassInstance(workInProgress, ctor, props, renderExpirationTime) {
  11364. var isLegacyContextConsumer = false;
  11365. var unmaskedContext = emptyContextObject;
  11366. var context = null;
  11367. var contextType = ctor.contextType;
  11368. if (typeof contextType === 'object' && contextType !== null) {
  11369. {
  11370. if (contextType.$$typeof !== REACT_CONTEXT_TYPE && !didWarnAboutInvalidateContextType.has(ctor)) {
  11371. didWarnAboutInvalidateContextType.add(ctor);
  11372. warningWithoutStack$1(false, '%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext(). ' + 'Did you accidentally pass the Context.Provider instead?', getComponentName(ctor) || 'Component');
  11373. }
  11374. }
  11375. context = readContext$1(contextType);
  11376. } else {
  11377. unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  11378. var contextTypes = ctor.contextTypes;
  11379. isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined;
  11380. context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject;
  11381. }
  11382. // Instantiate twice to help detect side-effects.
  11383. {
  11384. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  11385. new ctor(props, context); // eslint-disable-line no-new
  11386. }
  11387. }
  11388. var instance = new ctor(props, context);
  11389. var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null;
  11390. adoptClassInstance(workInProgress, instance);
  11391. {
  11392. if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) {
  11393. var componentName = getComponentName(ctor) || 'Component';
  11394. if (!didWarnAboutUninitializedState.has(componentName)) {
  11395. didWarnAboutUninitializedState.add(componentName);
  11396. 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);
  11397. }
  11398. }
  11399. // If new component APIs are defined, "unsafe" lifecycles won't be called.
  11400. // Warn about these lifecycles if they are present.
  11401. // Don't warn about react-lifecycles-compat polyfilled methods though.
  11402. if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') {
  11403. var foundWillMountName = null;
  11404. var foundWillReceivePropsName = null;
  11405. var foundWillUpdateName = null;
  11406. if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
  11407. foundWillMountName = 'componentWillMount';
  11408. } else if (typeof instance.UNSAFE_componentWillMount === 'function') {
  11409. foundWillMountName = 'UNSAFE_componentWillMount';
  11410. }
  11411. if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
  11412. foundWillReceivePropsName = 'componentWillReceiveProps';
  11413. } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  11414. foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
  11415. }
  11416. if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
  11417. foundWillUpdateName = 'componentWillUpdate';
  11418. } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
  11419. foundWillUpdateName = 'UNSAFE_componentWillUpdate';
  11420. }
  11421. if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
  11422. var _componentName = getComponentName(ctor) || 'Component';
  11423. var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()';
  11424. if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) {
  11425. didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName);
  11426. 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-async-component-lifecycle-hooks', _componentName, newApiName, foundWillMountName !== null ? '\n ' + foundWillMountName : '', foundWillReceivePropsName !== null ? '\n ' + foundWillReceivePropsName : '', foundWillUpdateName !== null ? '\n ' + foundWillUpdateName : '');
  11427. }
  11428. }
  11429. }
  11430. }
  11431. // Cache unmasked context so we can avoid recreating masked context unless necessary.
  11432. // ReactFiberContext usually updates this cache but can't for newly-created instances.
  11433. if (isLegacyContextConsumer) {
  11434. cacheContext(workInProgress, unmaskedContext, context);
  11435. }
  11436. return instance;
  11437. }
  11438. function callComponentWillMount(workInProgress, instance) {
  11439. startPhaseTimer(workInProgress, 'componentWillMount');
  11440. var oldState = instance.state;
  11441. if (typeof instance.componentWillMount === 'function') {
  11442. instance.componentWillMount();
  11443. }
  11444. if (typeof instance.UNSAFE_componentWillMount === 'function') {
  11445. instance.UNSAFE_componentWillMount();
  11446. }
  11447. stopPhaseTimer();
  11448. if (oldState !== instance.state) {
  11449. {
  11450. 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');
  11451. }
  11452. classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
  11453. }
  11454. }
  11455. function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) {
  11456. var oldState = instance.state;
  11457. startPhaseTimer(workInProgress, 'componentWillReceiveProps');
  11458. if (typeof instance.componentWillReceiveProps === 'function') {
  11459. instance.componentWillReceiveProps(newProps, nextContext);
  11460. }
  11461. if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  11462. instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
  11463. }
  11464. stopPhaseTimer();
  11465. if (instance.state !== oldState) {
  11466. {
  11467. var componentName = getComponentName(workInProgress.type) || 'Component';
  11468. if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
  11469. didWarnAboutStateAssignmentForComponent.add(componentName);
  11470. warningWithoutStack$1(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName);
  11471. }
  11472. }
  11473. classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
  11474. }
  11475. }
  11476. // Invokes the mount life-cycles on a previously never rendered instance.
  11477. function mountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
  11478. {
  11479. checkClassInstance(workInProgress, ctor, newProps);
  11480. }
  11481. var instance = workInProgress.stateNode;
  11482. instance.props = newProps;
  11483. instance.state = workInProgress.memoizedState;
  11484. instance.refs = emptyRefsObject;
  11485. var contextType = ctor.contextType;
  11486. if (typeof contextType === 'object' && contextType !== null) {
  11487. instance.context = readContext$1(contextType);
  11488. } else {
  11489. var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  11490. instance.context = getMaskedContext(workInProgress, unmaskedContext);
  11491. }
  11492. {
  11493. if (instance.state === newProps) {
  11494. var componentName = getComponentName(ctor) || 'Component';
  11495. if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) {
  11496. didWarnAboutDirectlyAssigningPropsToState.add(componentName);
  11497. 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);
  11498. }
  11499. }
  11500. if (workInProgress.mode & StrictMode) {
  11501. ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance);
  11502. ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance);
  11503. }
  11504. if (warnAboutDeprecatedLifecycles) {
  11505. ReactStrictModeWarnings.recordDeprecationWarnings(workInProgress, instance);
  11506. }
  11507. }
  11508. var updateQueue = workInProgress.updateQueue;
  11509. if (updateQueue !== null) {
  11510. processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
  11511. instance.state = workInProgress.memoizedState;
  11512. }
  11513. var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
  11514. if (typeof getDerivedStateFromProps === 'function') {
  11515. applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
  11516. instance.state = workInProgress.memoizedState;
  11517. }
  11518. // In order to support react-lifecycles-compat polyfilled components,
  11519. // Unsafe lifecycles should not be invoked for components using the new APIs.
  11520. if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
  11521. callComponentWillMount(workInProgress, instance);
  11522. // If we had additional state updates during this life-cycle, let's
  11523. // process them now.
  11524. updateQueue = workInProgress.updateQueue;
  11525. if (updateQueue !== null) {
  11526. processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
  11527. instance.state = workInProgress.memoizedState;
  11528. }
  11529. }
  11530. if (typeof instance.componentDidMount === 'function') {
  11531. workInProgress.effectTag |= Update;
  11532. }
  11533. }
  11534. function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
  11535. var instance = workInProgress.stateNode;
  11536. var oldProps = workInProgress.memoizedProps;
  11537. instance.props = oldProps;
  11538. var oldContext = instance.context;
  11539. var contextType = ctor.contextType;
  11540. var nextContext = void 0;
  11541. if (typeof contextType === 'object' && contextType !== null) {
  11542. nextContext = readContext$1(contextType);
  11543. } else {
  11544. var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  11545. nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext);
  11546. }
  11547. var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
  11548. var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
  11549. // Note: During these life-cycles, instance.props/instance.state are what
  11550. // ever the previously attempted to render - not the "current". However,
  11551. // during componentDidUpdate we pass the "current" props.
  11552. // In order to support react-lifecycles-compat polyfilled components,
  11553. // Unsafe lifecycles should not be invoked for components using the new APIs.
  11554. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
  11555. if (oldProps !== newProps || oldContext !== nextContext) {
  11556. callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
  11557. }
  11558. }
  11559. resetHasForceUpdateBeforeProcessing();
  11560. var oldState = workInProgress.memoizedState;
  11561. var newState = instance.state = oldState;
  11562. var updateQueue = workInProgress.updateQueue;
  11563. if (updateQueue !== null) {
  11564. processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
  11565. newState = workInProgress.memoizedState;
  11566. }
  11567. if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
  11568. // If an update was already in progress, we should schedule an Update
  11569. // effect even though we're bailing out, so that cWU/cDU are called.
  11570. if (typeof instance.componentDidMount === 'function') {
  11571. workInProgress.effectTag |= Update;
  11572. }
  11573. return false;
  11574. }
  11575. if (typeof getDerivedStateFromProps === 'function') {
  11576. applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
  11577. newState = workInProgress.memoizedState;
  11578. }
  11579. var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
  11580. if (shouldUpdate) {
  11581. // In order to support react-lifecycles-compat polyfilled components,
  11582. // Unsafe lifecycles should not be invoked for components using the new APIs.
  11583. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
  11584. startPhaseTimer(workInProgress, 'componentWillMount');
  11585. if (typeof instance.componentWillMount === 'function') {
  11586. instance.componentWillMount();
  11587. }
  11588. if (typeof instance.UNSAFE_componentWillMount === 'function') {
  11589. instance.UNSAFE_componentWillMount();
  11590. }
  11591. stopPhaseTimer();
  11592. }
  11593. if (typeof instance.componentDidMount === 'function') {
  11594. workInProgress.effectTag |= Update;
  11595. }
  11596. } else {
  11597. // If an update was already in progress, we should schedule an Update
  11598. // effect even though we're bailing out, so that cWU/cDU are called.
  11599. if (typeof instance.componentDidMount === 'function') {
  11600. workInProgress.effectTag |= Update;
  11601. }
  11602. // If shouldComponentUpdate returned false, we should still update the
  11603. // memoized state to indicate that this work can be reused.
  11604. workInProgress.memoizedProps = newProps;
  11605. workInProgress.memoizedState = newState;
  11606. }
  11607. // Update the existing instance's state, props, and context pointers even
  11608. // if shouldComponentUpdate returns false.
  11609. instance.props = newProps;
  11610. instance.state = newState;
  11611. instance.context = nextContext;
  11612. return shouldUpdate;
  11613. }
  11614. // Invokes the update life-cycles and returns false if it shouldn't rerender.
  11615. function updateClassInstance(current, workInProgress, ctor, newProps, renderExpirationTime) {
  11616. var instance = workInProgress.stateNode;
  11617. var oldProps = workInProgress.memoizedProps;
  11618. instance.props = workInProgress.type === workInProgress.elementType ? oldProps : resolveDefaultProps(workInProgress.type, oldProps);
  11619. var oldContext = instance.context;
  11620. var contextType = ctor.contextType;
  11621. var nextContext = void 0;
  11622. if (typeof contextType === 'object' && contextType !== null) {
  11623. nextContext = readContext$1(contextType);
  11624. } else {
  11625. var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  11626. nextContext = getMaskedContext(workInProgress, nextUnmaskedContext);
  11627. }
  11628. var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
  11629. var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
  11630. // Note: During these life-cycles, instance.props/instance.state are what
  11631. // ever the previously attempted to render - not the "current". However,
  11632. // during componentDidUpdate we pass the "current" props.
  11633. // In order to support react-lifecycles-compat polyfilled components,
  11634. // Unsafe lifecycles should not be invoked for components using the new APIs.
  11635. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
  11636. if (oldProps !== newProps || oldContext !== nextContext) {
  11637. callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
  11638. }
  11639. }
  11640. resetHasForceUpdateBeforeProcessing();
  11641. var oldState = workInProgress.memoizedState;
  11642. var newState = instance.state = oldState;
  11643. var updateQueue = workInProgress.updateQueue;
  11644. if (updateQueue !== null) {
  11645. processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
  11646. newState = workInProgress.memoizedState;
  11647. }
  11648. if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
  11649. // If an update was already in progress, we should schedule an Update
  11650. // effect even though we're bailing out, so that cWU/cDU are called.
  11651. if (typeof instance.componentDidUpdate === 'function') {
  11652. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  11653. workInProgress.effectTag |= Update;
  11654. }
  11655. }
  11656. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  11657. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  11658. workInProgress.effectTag |= Snapshot;
  11659. }
  11660. }
  11661. return false;
  11662. }
  11663. if (typeof getDerivedStateFromProps === 'function') {
  11664. applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
  11665. newState = workInProgress.memoizedState;
  11666. }
  11667. var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
  11668. if (shouldUpdate) {
  11669. // In order to support react-lifecycles-compat polyfilled components,
  11670. // Unsafe lifecycles should not be invoked for components using the new APIs.
  11671. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) {
  11672. startPhaseTimer(workInProgress, 'componentWillUpdate');
  11673. if (typeof instance.componentWillUpdate === 'function') {
  11674. instance.componentWillUpdate(newProps, newState, nextContext);
  11675. }
  11676. if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
  11677. instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext);
  11678. }
  11679. stopPhaseTimer();
  11680. }
  11681. if (typeof instance.componentDidUpdate === 'function') {
  11682. workInProgress.effectTag |= Update;
  11683. }
  11684. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  11685. workInProgress.effectTag |= Snapshot;
  11686. }
  11687. } else {
  11688. // If an update was already in progress, we should schedule an Update
  11689. // effect even though we're bailing out, so that cWU/cDU are called.
  11690. if (typeof instance.componentDidUpdate === 'function') {
  11691. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  11692. workInProgress.effectTag |= Update;
  11693. }
  11694. }
  11695. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  11696. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  11697. workInProgress.effectTag |= Snapshot;
  11698. }
  11699. }
  11700. // If shouldComponentUpdate returned false, we should still update the
  11701. // memoized props/state to indicate that this work can be reused.
  11702. workInProgress.memoizedProps = newProps;
  11703. workInProgress.memoizedState = newState;
  11704. }
  11705. // Update the existing instance's state, props, and context pointers even
  11706. // if shouldComponentUpdate returns false.
  11707. instance.props = newProps;
  11708. instance.state = newState;
  11709. instance.context = nextContext;
  11710. return shouldUpdate;
  11711. }
  11712. var didWarnAboutMaps = void 0;
  11713. var didWarnAboutGenerators = void 0;
  11714. var didWarnAboutStringRefInStrictMode = void 0;
  11715. var ownerHasKeyUseWarning = void 0;
  11716. var ownerHasFunctionTypeWarning = void 0;
  11717. var warnForMissingKey = function (child) {};
  11718. {
  11719. didWarnAboutMaps = false;
  11720. didWarnAboutGenerators = false;
  11721. didWarnAboutStringRefInStrictMode = {};
  11722. /**
  11723. * Warn if there's no key explicitly set on dynamic arrays of children or
  11724. * object keys are not valid. This allows us to keep track of children between
  11725. * updates.
  11726. */
  11727. ownerHasKeyUseWarning = {};
  11728. ownerHasFunctionTypeWarning = {};
  11729. warnForMissingKey = function (child) {
  11730. if (child === null || typeof child !== 'object') {
  11731. return;
  11732. }
  11733. if (!child._store || child._store.validated || child.key != null) {
  11734. return;
  11735. }
  11736. !(typeof child._store === 'object') ? invariant(false, 'React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  11737. child._store.validated = true;
  11738. var currentComponentErrorInfo = 'Each child in an array or iterator should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.' + getCurrentFiberStackInDev();
  11739. if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
  11740. return;
  11741. }
  11742. ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
  11743. warning$1(false, 'Each child in an array or iterator should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.');
  11744. };
  11745. }
  11746. var isArray = Array.isArray;
  11747. function coerceRef(returnFiber, current$$1, element) {
  11748. var mixedRef = element.ref;
  11749. if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') {
  11750. {
  11751. if (returnFiber.mode & StrictMode) {
  11752. var componentName = getComponentName(returnFiber.type) || 'Component';
  11753. if (!didWarnAboutStringRefInStrictMode[componentName]) {
  11754. 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 createRef() instead.' + '\n%s' + '\n\nLearn more about using refs safely here:' + '\nhttps://fb.me/react-strict-mode-string-ref', mixedRef, getStackByFiberInDevAndProd(returnFiber));
  11755. didWarnAboutStringRefInStrictMode[componentName] = true;
  11756. }
  11757. }
  11758. }
  11759. if (element._owner) {
  11760. var owner = element._owner;
  11761. var inst = void 0;
  11762. if (owner) {
  11763. var ownerFiber = owner;
  11764. !(ownerFiber.tag === ClassComponent) ? invariant(false, 'Function components cannot have refs.') : void 0;
  11765. inst = ownerFiber.stateNode;
  11766. }
  11767. !inst ? invariant(false, 'Missing owner for string ref %s. This error is likely caused by a bug in React. Please file an issue.', mixedRef) : void 0;
  11768. var stringRef = '' + mixedRef;
  11769. // Check if previous string ref matches new string ref
  11770. if (current$$1 !== null && current$$1.ref !== null && typeof current$$1.ref === 'function' && current$$1.ref._stringRef === stringRef) {
  11771. return current$$1.ref;
  11772. }
  11773. var ref = function (value) {
  11774. var refs = inst.refs;
  11775. if (refs === emptyRefsObject) {
  11776. // This is a lazy pooled frozen object, so we need to initialize.
  11777. refs = inst.refs = {};
  11778. }
  11779. if (value === null) {
  11780. delete refs[stringRef];
  11781. } else {
  11782. refs[stringRef] = value;
  11783. }
  11784. };
  11785. ref._stringRef = stringRef;
  11786. return ref;
  11787. } else {
  11788. !(typeof mixedRef === 'string') ? invariant(false, 'Expected ref to be a function, a string, an object returned by React.createRef(), or null.') : void 0;
  11789. !element._owner ? invariant(false, 'Element ref was specified as a string (%s) 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.', mixedRef) : void 0;
  11790. }
  11791. }
  11792. return mixedRef;
  11793. }
  11794. function throwOnInvalidObjectType(returnFiber, newChild) {
  11795. if (returnFiber.type !== 'textarea') {
  11796. var addendum = '';
  11797. {
  11798. addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + getCurrentFiberStackInDev();
  11799. }
  11800. invariant(false, 'Objects are not valid as a React child (found: %s).%s', Object.prototype.toString.call(newChild) === '[object Object]' ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' : newChild, addendum);
  11801. }
  11802. }
  11803. function warnOnFunctionType() {
  11804. 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();
  11805. if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) {
  11806. return;
  11807. }
  11808. ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true;
  11809. 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.');
  11810. }
  11811. // This wrapper function exists because I expect to clone the code in each path
  11812. // to be able to optimize each path individually by branching early. This needs
  11813. // a compiler or we can do it manually. Helpers that don't need this branching
  11814. // live outside of this function.
  11815. function ChildReconciler(shouldTrackSideEffects) {
  11816. function deleteChild(returnFiber, childToDelete) {
  11817. if (!shouldTrackSideEffects) {
  11818. // Noop.
  11819. return;
  11820. }
  11821. // Deletions are added in reversed order so we add it to the front.
  11822. // At this point, the return fiber's effect list is empty except for
  11823. // deletions, so we can just append the deletion to the list. The remaining
  11824. // effects aren't added until the complete phase. Once we implement
  11825. // resuming, this may not be true.
  11826. var last = returnFiber.lastEffect;
  11827. if (last !== null) {
  11828. last.nextEffect = childToDelete;
  11829. returnFiber.lastEffect = childToDelete;
  11830. } else {
  11831. returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
  11832. }
  11833. childToDelete.nextEffect = null;
  11834. childToDelete.effectTag = Deletion;
  11835. }
  11836. function deleteRemainingChildren(returnFiber, currentFirstChild) {
  11837. if (!shouldTrackSideEffects) {
  11838. // Noop.
  11839. return null;
  11840. }
  11841. // TODO: For the shouldClone case, this could be micro-optimized a bit by
  11842. // assuming that after the first child we've already added everything.
  11843. var childToDelete = currentFirstChild;
  11844. while (childToDelete !== null) {
  11845. deleteChild(returnFiber, childToDelete);
  11846. childToDelete = childToDelete.sibling;
  11847. }
  11848. return null;
  11849. }
  11850. function mapRemainingChildren(returnFiber, currentFirstChild) {
  11851. // Add the remaining children to a temporary map so that we can find them by
  11852. // keys quickly. Implicit (null) keys get added to this set with their index
  11853. var existingChildren = new Map();
  11854. var existingChild = currentFirstChild;
  11855. while (existingChild !== null) {
  11856. if (existingChild.key !== null) {
  11857. existingChildren.set(existingChild.key, existingChild);
  11858. } else {
  11859. existingChildren.set(existingChild.index, existingChild);
  11860. }
  11861. existingChild = existingChild.sibling;
  11862. }
  11863. return existingChildren;
  11864. }
  11865. function useFiber(fiber, pendingProps, expirationTime) {
  11866. // We currently set sibling to null and index to 0 here because it is easy
  11867. // to forget to do before returning it. E.g. for the single child case.
  11868. var clone = createWorkInProgress(fiber, pendingProps, expirationTime);
  11869. clone.index = 0;
  11870. clone.sibling = null;
  11871. return clone;
  11872. }
  11873. function placeChild(newFiber, lastPlacedIndex, newIndex) {
  11874. newFiber.index = newIndex;
  11875. if (!shouldTrackSideEffects) {
  11876. // Noop.
  11877. return lastPlacedIndex;
  11878. }
  11879. var current$$1 = newFiber.alternate;
  11880. if (current$$1 !== null) {
  11881. var oldIndex = current$$1.index;
  11882. if (oldIndex < lastPlacedIndex) {
  11883. // This is a move.
  11884. newFiber.effectTag = Placement;
  11885. return lastPlacedIndex;
  11886. } else {
  11887. // This item can stay in place.
  11888. return oldIndex;
  11889. }
  11890. } else {
  11891. // This is an insertion.
  11892. newFiber.effectTag = Placement;
  11893. return lastPlacedIndex;
  11894. }
  11895. }
  11896. function placeSingleChild(newFiber) {
  11897. // This is simpler for the single child case. We only need to do a
  11898. // placement for inserting new children.
  11899. if (shouldTrackSideEffects && newFiber.alternate === null) {
  11900. newFiber.effectTag = Placement;
  11901. }
  11902. return newFiber;
  11903. }
  11904. function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {
  11905. if (current$$1 === null || current$$1.tag !== HostText) {
  11906. // Insert
  11907. var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
  11908. created.return = returnFiber;
  11909. return created;
  11910. } else {
  11911. // Update
  11912. var existing = useFiber(current$$1, textContent, expirationTime);
  11913. existing.return = returnFiber;
  11914. return existing;
  11915. }
  11916. }
  11917. function updateElement(returnFiber, current$$1, element, expirationTime) {
  11918. if (current$$1 !== null && current$$1.elementType === element.type) {
  11919. // Move based on index
  11920. var existing = useFiber(current$$1, element.props, expirationTime);
  11921. existing.ref = coerceRef(returnFiber, current$$1, element);
  11922. existing.return = returnFiber;
  11923. {
  11924. existing._debugSource = element._source;
  11925. existing._debugOwner = element._owner;
  11926. }
  11927. return existing;
  11928. } else {
  11929. // Insert
  11930. var created = createFiberFromElement(element, returnFiber.mode, expirationTime);
  11931. created.ref = coerceRef(returnFiber, current$$1, element);
  11932. created.return = returnFiber;
  11933. return created;
  11934. }
  11935. }
  11936. function updatePortal(returnFiber, current$$1, portal, expirationTime) {
  11937. if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {
  11938. // Insert
  11939. var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
  11940. created.return = returnFiber;
  11941. return created;
  11942. } else {
  11943. // Update
  11944. var existing = useFiber(current$$1, portal.children || [], expirationTime);
  11945. existing.return = returnFiber;
  11946. return existing;
  11947. }
  11948. }
  11949. function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {
  11950. if (current$$1 === null || current$$1.tag !== Fragment) {
  11951. // Insert
  11952. var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);
  11953. created.return = returnFiber;
  11954. return created;
  11955. } else {
  11956. // Update
  11957. var existing = useFiber(current$$1, fragment, expirationTime);
  11958. existing.return = returnFiber;
  11959. return existing;
  11960. }
  11961. }
  11962. function createChild(returnFiber, newChild, expirationTime) {
  11963. if (typeof newChild === 'string' || typeof newChild === 'number') {
  11964. // Text nodes don't have keys. If the previous node is implicitly keyed
  11965. // we can continue to replace it without aborting even if it is not a text
  11966. // node.
  11967. var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);
  11968. created.return = returnFiber;
  11969. return created;
  11970. }
  11971. if (typeof newChild === 'object' && newChild !== null) {
  11972. switch (newChild.$$typeof) {
  11973. case REACT_ELEMENT_TYPE:
  11974. {
  11975. var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);
  11976. _created.ref = coerceRef(returnFiber, null, newChild);
  11977. _created.return = returnFiber;
  11978. return _created;
  11979. }
  11980. case REACT_PORTAL_TYPE:
  11981. {
  11982. var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);
  11983. _created2.return = returnFiber;
  11984. return _created2;
  11985. }
  11986. }
  11987. if (isArray(newChild) || getIteratorFn(newChild)) {
  11988. var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);
  11989. _created3.return = returnFiber;
  11990. return _created3;
  11991. }
  11992. throwOnInvalidObjectType(returnFiber, newChild);
  11993. }
  11994. {
  11995. if (typeof newChild === 'function') {
  11996. warnOnFunctionType();
  11997. }
  11998. }
  11999. return null;
  12000. }
  12001. function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
  12002. // Update the fiber if the keys match, otherwise return null.
  12003. var key = oldFiber !== null ? oldFiber.key : null;
  12004. if (typeof newChild === 'string' || typeof newChild === 'number') {
  12005. // Text nodes don't have keys. If the previous node is implicitly keyed
  12006. // we can continue to replace it without aborting even if it is not a text
  12007. // node.
  12008. if (key !== null) {
  12009. return null;
  12010. }
  12011. return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);
  12012. }
  12013. if (typeof newChild === 'object' && newChild !== null) {
  12014. switch (newChild.$$typeof) {
  12015. case REACT_ELEMENT_TYPE:
  12016. {
  12017. if (newChild.key === key) {
  12018. if (newChild.type === REACT_FRAGMENT_TYPE) {
  12019. return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);
  12020. }
  12021. return updateElement(returnFiber, oldFiber, newChild, expirationTime);
  12022. } else {
  12023. return null;
  12024. }
  12025. }
  12026. case REACT_PORTAL_TYPE:
  12027. {
  12028. if (newChild.key === key) {
  12029. return updatePortal(returnFiber, oldFiber, newChild, expirationTime);
  12030. } else {
  12031. return null;
  12032. }
  12033. }
  12034. }
  12035. if (isArray(newChild) || getIteratorFn(newChild)) {
  12036. if (key !== null) {
  12037. return null;
  12038. }
  12039. return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);
  12040. }
  12041. throwOnInvalidObjectType(returnFiber, newChild);
  12042. }
  12043. {
  12044. if (typeof newChild === 'function') {
  12045. warnOnFunctionType();
  12046. }
  12047. }
  12048. return null;
  12049. }
  12050. function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {
  12051. if (typeof newChild === 'string' || typeof newChild === 'number') {
  12052. // Text nodes don't have keys, so we neither have to check the old nor
  12053. // new node for the key. If both are text nodes, they match.
  12054. var matchedFiber = existingChildren.get(newIdx) || null;
  12055. return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);
  12056. }
  12057. if (typeof newChild === 'object' && newChild !== null) {
  12058. switch (newChild.$$typeof) {
  12059. case REACT_ELEMENT_TYPE:
  12060. {
  12061. var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
  12062. if (newChild.type === REACT_FRAGMENT_TYPE) {
  12063. return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);
  12064. }
  12065. return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);
  12066. }
  12067. case REACT_PORTAL_TYPE:
  12068. {
  12069. var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
  12070. return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);
  12071. }
  12072. }
  12073. if (isArray(newChild) || getIteratorFn(newChild)) {
  12074. var _matchedFiber3 = existingChildren.get(newIdx) || null;
  12075. return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
  12076. }
  12077. throwOnInvalidObjectType(returnFiber, newChild);
  12078. }
  12079. {
  12080. if (typeof newChild === 'function') {
  12081. warnOnFunctionType();
  12082. }
  12083. }
  12084. return null;
  12085. }
  12086. /**
  12087. * Warns if there is a duplicate or missing key
  12088. */
  12089. function warnOnInvalidKey(child, knownKeys) {
  12090. {
  12091. if (typeof child !== 'object' || child === null) {
  12092. return knownKeys;
  12093. }
  12094. switch (child.$$typeof) {
  12095. case REACT_ELEMENT_TYPE:
  12096. case REACT_PORTAL_TYPE:
  12097. warnForMissingKey(child);
  12098. var key = child.key;
  12099. if (typeof key !== 'string') {
  12100. break;
  12101. }
  12102. if (knownKeys === null) {
  12103. knownKeys = new Set();
  12104. knownKeys.add(key);
  12105. break;
  12106. }
  12107. if (!knownKeys.has(key)) {
  12108. knownKeys.add(key);
  12109. break;
  12110. }
  12111. 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);
  12112. break;
  12113. default:
  12114. break;
  12115. }
  12116. }
  12117. return knownKeys;
  12118. }
  12119. function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
  12120. // This algorithm can't optimize by searching from boths ends since we
  12121. // don't have backpointers on fibers. I'm trying to see how far we can get
  12122. // with that model. If it ends up not being worth the tradeoffs, we can
  12123. // add it later.
  12124. // Even with a two ended optimization, we'd want to optimize for the case
  12125. // where there are few changes and brute force the comparison instead of
  12126. // going for the Map. It'd like to explore hitting that path first in
  12127. // forward-only mode and only go for the Map once we notice that we need
  12128. // lots of look ahead. This doesn't handle reversal as well as two ended
  12129. // search but that's unusual. Besides, for the two ended optimization to
  12130. // work on Iterables, we'd need to copy the whole set.
  12131. // In this first iteration, we'll just live with hitting the bad case
  12132. // (adding everything to a Map) in for every insert/move.
  12133. // If you change this code, also update reconcileChildrenIterator() which
  12134. // uses the same algorithm.
  12135. {
  12136. // First, validate keys.
  12137. var knownKeys = null;
  12138. for (var i = 0; i < newChildren.length; i++) {
  12139. var child = newChildren[i];
  12140. knownKeys = warnOnInvalidKey(child, knownKeys);
  12141. }
  12142. }
  12143. var resultingFirstChild = null;
  12144. var previousNewFiber = null;
  12145. var oldFiber = currentFirstChild;
  12146. var lastPlacedIndex = 0;
  12147. var newIdx = 0;
  12148. var nextOldFiber = null;
  12149. for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {
  12150. if (oldFiber.index > newIdx) {
  12151. nextOldFiber = oldFiber;
  12152. oldFiber = null;
  12153. } else {
  12154. nextOldFiber = oldFiber.sibling;
  12155. }
  12156. var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);
  12157. if (newFiber === null) {
  12158. // TODO: This breaks on empty slots like null children. That's
  12159. // unfortunate because it triggers the slow path all the time. We need
  12160. // a better way to communicate whether this was a miss or null,
  12161. // boolean, undefined, etc.
  12162. if (oldFiber === null) {
  12163. oldFiber = nextOldFiber;
  12164. }
  12165. break;
  12166. }
  12167. if (shouldTrackSideEffects) {
  12168. if (oldFiber && newFiber.alternate === null) {
  12169. // We matched the slot, but we didn't reuse the existing fiber, so we
  12170. // need to delete the existing child.
  12171. deleteChild(returnFiber, oldFiber);
  12172. }
  12173. }
  12174. lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
  12175. if (previousNewFiber === null) {
  12176. // TODO: Move out of the loop. This only happens for the first run.
  12177. resultingFirstChild = newFiber;
  12178. } else {
  12179. // TODO: Defer siblings if we're not at the right index for this slot.
  12180. // I.e. if we had null values before, then we want to defer this
  12181. // for each null value. However, we also don't want to call updateSlot
  12182. // with the previous one.
  12183. previousNewFiber.sibling = newFiber;
  12184. }
  12185. previousNewFiber = newFiber;
  12186. oldFiber = nextOldFiber;
  12187. }
  12188. if (newIdx === newChildren.length) {
  12189. // We've reached the end of the new children. We can delete the rest.
  12190. deleteRemainingChildren(returnFiber, oldFiber);
  12191. return resultingFirstChild;
  12192. }
  12193. if (oldFiber === null) {
  12194. // If we don't have any more existing children we can choose a fast path
  12195. // since the rest will all be insertions.
  12196. for (; newIdx < newChildren.length; newIdx++) {
  12197. var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);
  12198. if (!_newFiber) {
  12199. continue;
  12200. }
  12201. lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);
  12202. if (previousNewFiber === null) {
  12203. // TODO: Move out of the loop. This only happens for the first run.
  12204. resultingFirstChild = _newFiber;
  12205. } else {
  12206. previousNewFiber.sibling = _newFiber;
  12207. }
  12208. previousNewFiber = _newFiber;
  12209. }
  12210. return resultingFirstChild;
  12211. }
  12212. // Add all children to a key map for quick lookups.
  12213. var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
  12214. // Keep scanning and use the map to restore deleted items as moves.
  12215. for (; newIdx < newChildren.length; newIdx++) {
  12216. var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);
  12217. if (_newFiber2) {
  12218. if (shouldTrackSideEffects) {
  12219. if (_newFiber2.alternate !== null) {
  12220. // The new fiber is a work in progress, but if there exists a
  12221. // current, that means that we reused the fiber. We need to delete
  12222. // it from the child list so that we don't add it to the deletion
  12223. // list.
  12224. existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);
  12225. }
  12226. }
  12227. lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);
  12228. if (previousNewFiber === null) {
  12229. resultingFirstChild = _newFiber2;
  12230. } else {
  12231. previousNewFiber.sibling = _newFiber2;
  12232. }
  12233. previousNewFiber = _newFiber2;
  12234. }
  12235. }
  12236. if (shouldTrackSideEffects) {
  12237. // Any existing children that weren't consumed above were deleted. We need
  12238. // to add them to the deletion list.
  12239. existingChildren.forEach(function (child) {
  12240. return deleteChild(returnFiber, child);
  12241. });
  12242. }
  12243. return resultingFirstChild;
  12244. }
  12245. function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {
  12246. // This is the same implementation as reconcileChildrenArray(),
  12247. // but using the iterator instead.
  12248. var iteratorFn = getIteratorFn(newChildrenIterable);
  12249. !(typeof iteratorFn === 'function') ? invariant(false, 'An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  12250. {
  12251. // We don't support rendering Generators because it's a mutation.
  12252. // See https://github.com/facebook/react/issues/12995
  12253. if (typeof Symbol === 'function' &&
  12254. // $FlowFixMe Flow doesn't know about toStringTag
  12255. newChildrenIterable[Symbol.toStringTag] === 'Generator') {
  12256. !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;
  12257. didWarnAboutGenerators = true;
  12258. }
  12259. // Warn about using Maps as children
  12260. if (newChildrenIterable.entries === iteratorFn) {
  12261. !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;
  12262. didWarnAboutMaps = true;
  12263. }
  12264. // First, validate keys.
  12265. // We'll get a different iterator later for the main pass.
  12266. var _newChildren = iteratorFn.call(newChildrenIterable);
  12267. if (_newChildren) {
  12268. var knownKeys = null;
  12269. var _step = _newChildren.next();
  12270. for (; !_step.done; _step = _newChildren.next()) {
  12271. var child = _step.value;
  12272. knownKeys = warnOnInvalidKey(child, knownKeys);
  12273. }
  12274. }
  12275. }
  12276. var newChildren = iteratorFn.call(newChildrenIterable);
  12277. !(newChildren != null) ? invariant(false, 'An iterable object provided no iterator.') : void 0;
  12278. var resultingFirstChild = null;
  12279. var previousNewFiber = null;
  12280. var oldFiber = currentFirstChild;
  12281. var lastPlacedIndex = 0;
  12282. var newIdx = 0;
  12283. var nextOldFiber = null;
  12284. var step = newChildren.next();
  12285. for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {
  12286. if (oldFiber.index > newIdx) {
  12287. nextOldFiber = oldFiber;
  12288. oldFiber = null;
  12289. } else {
  12290. nextOldFiber = oldFiber.sibling;
  12291. }
  12292. var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);
  12293. if (newFiber === null) {
  12294. // TODO: This breaks on empty slots like null children. That's
  12295. // unfortunate because it triggers the slow path all the time. We need
  12296. // a better way to communicate whether this was a miss or null,
  12297. // boolean, undefined, etc.
  12298. if (!oldFiber) {
  12299. oldFiber = nextOldFiber;
  12300. }
  12301. break;
  12302. }
  12303. if (shouldTrackSideEffects) {
  12304. if (oldFiber && newFiber.alternate === null) {
  12305. // We matched the slot, but we didn't reuse the existing fiber, so we
  12306. // need to delete the existing child.
  12307. deleteChild(returnFiber, oldFiber);
  12308. }
  12309. }
  12310. lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
  12311. if (previousNewFiber === null) {
  12312. // TODO: Move out of the loop. This only happens for the first run.
  12313. resultingFirstChild = newFiber;
  12314. } else {
  12315. // TODO: Defer siblings if we're not at the right index for this slot.
  12316. // I.e. if we had null values before, then we want to defer this
  12317. // for each null value. However, we also don't want to call updateSlot
  12318. // with the previous one.
  12319. previousNewFiber.sibling = newFiber;
  12320. }
  12321. previousNewFiber = newFiber;
  12322. oldFiber = nextOldFiber;
  12323. }
  12324. if (step.done) {
  12325. // We've reached the end of the new children. We can delete the rest.
  12326. deleteRemainingChildren(returnFiber, oldFiber);
  12327. return resultingFirstChild;
  12328. }
  12329. if (oldFiber === null) {
  12330. // If we don't have any more existing children we can choose a fast path
  12331. // since the rest will all be insertions.
  12332. for (; !step.done; newIdx++, step = newChildren.next()) {
  12333. var _newFiber3 = createChild(returnFiber, step.value, expirationTime);
  12334. if (_newFiber3 === null) {
  12335. continue;
  12336. }
  12337. lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);
  12338. if (previousNewFiber === null) {
  12339. // TODO: Move out of the loop. This only happens for the first run.
  12340. resultingFirstChild = _newFiber3;
  12341. } else {
  12342. previousNewFiber.sibling = _newFiber3;
  12343. }
  12344. previousNewFiber = _newFiber3;
  12345. }
  12346. return resultingFirstChild;
  12347. }
  12348. // Add all children to a key map for quick lookups.
  12349. var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
  12350. // Keep scanning and use the map to restore deleted items as moves.
  12351. for (; !step.done; newIdx++, step = newChildren.next()) {
  12352. var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);
  12353. if (_newFiber4 !== null) {
  12354. if (shouldTrackSideEffects) {
  12355. if (_newFiber4.alternate !== null) {
  12356. // The new fiber is a work in progress, but if there exists a
  12357. // current, that means that we reused the fiber. We need to delete
  12358. // it from the child list so that we don't add it to the deletion
  12359. // list.
  12360. existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);
  12361. }
  12362. }
  12363. lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);
  12364. if (previousNewFiber === null) {
  12365. resultingFirstChild = _newFiber4;
  12366. } else {
  12367. previousNewFiber.sibling = _newFiber4;
  12368. }
  12369. previousNewFiber = _newFiber4;
  12370. }
  12371. }
  12372. if (shouldTrackSideEffects) {
  12373. // Any existing children that weren't consumed above were deleted. We need
  12374. // to add them to the deletion list.
  12375. existingChildren.forEach(function (child) {
  12376. return deleteChild(returnFiber, child);
  12377. });
  12378. }
  12379. return resultingFirstChild;
  12380. }
  12381. function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {
  12382. // There's no need to check for keys on text nodes since we don't have a
  12383. // way to define them.
  12384. if (currentFirstChild !== null && currentFirstChild.tag === HostText) {
  12385. // We already have an existing node so let's just update it and delete
  12386. // the rest.
  12387. deleteRemainingChildren(returnFiber, currentFirstChild.sibling);
  12388. var existing = useFiber(currentFirstChild, textContent, expirationTime);
  12389. existing.return = returnFiber;
  12390. return existing;
  12391. }
  12392. // The existing first child is not a text node so we need to create one
  12393. // and delete the existing ones.
  12394. deleteRemainingChildren(returnFiber, currentFirstChild);
  12395. var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
  12396. created.return = returnFiber;
  12397. return created;
  12398. }
  12399. function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {
  12400. var key = element.key;
  12401. var child = currentFirstChild;
  12402. while (child !== null) {
  12403. // TODO: If key === null and child.key === null, then this only applies to
  12404. // the first item in the list.
  12405. if (child.key === key) {
  12406. if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type) {
  12407. deleteRemainingChildren(returnFiber, child.sibling);
  12408. var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);
  12409. existing.ref = coerceRef(returnFiber, child, element);
  12410. existing.return = returnFiber;
  12411. {
  12412. existing._debugSource = element._source;
  12413. existing._debugOwner = element._owner;
  12414. }
  12415. return existing;
  12416. } else {
  12417. deleteRemainingChildren(returnFiber, child);
  12418. break;
  12419. }
  12420. } else {
  12421. deleteChild(returnFiber, child);
  12422. }
  12423. child = child.sibling;
  12424. }
  12425. if (element.type === REACT_FRAGMENT_TYPE) {
  12426. var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);
  12427. created.return = returnFiber;
  12428. return created;
  12429. } else {
  12430. var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);
  12431. _created4.ref = coerceRef(returnFiber, currentFirstChild, element);
  12432. _created4.return = returnFiber;
  12433. return _created4;
  12434. }
  12435. }
  12436. function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {
  12437. var key = portal.key;
  12438. var child = currentFirstChild;
  12439. while (child !== null) {
  12440. // TODO: If key === null and child.key === null, then this only applies to
  12441. // the first item in the list.
  12442. if (child.key === key) {
  12443. if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {
  12444. deleteRemainingChildren(returnFiber, child.sibling);
  12445. var existing = useFiber(child, portal.children || [], expirationTime);
  12446. existing.return = returnFiber;
  12447. return existing;
  12448. } else {
  12449. deleteRemainingChildren(returnFiber, child);
  12450. break;
  12451. }
  12452. } else {
  12453. deleteChild(returnFiber, child);
  12454. }
  12455. child = child.sibling;
  12456. }
  12457. var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
  12458. created.return = returnFiber;
  12459. return created;
  12460. }
  12461. // This API will tag the children with the side-effect of the reconciliation
  12462. // itself. They will be added to the side-effect list as we pass through the
  12463. // children and the parent.
  12464. function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {
  12465. // This function is not recursive.
  12466. // If the top level item is an array, we treat it as a set of children,
  12467. // not as a fragment. Nested arrays on the other hand will be treated as
  12468. // fragment nodes. Recursion happens at the normal flow.
  12469. // Handle top level unkeyed fragments as if they were arrays.
  12470. // This leads to an ambiguity between <>{[...]}</> and <>...</>.
  12471. // We treat the ambiguous cases above the same.
  12472. var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;
  12473. if (isUnkeyedTopLevelFragment) {
  12474. newChild = newChild.props.children;
  12475. }
  12476. // Handle object types
  12477. var isObject = typeof newChild === 'object' && newChild !== null;
  12478. if (isObject) {
  12479. switch (newChild.$$typeof) {
  12480. case REACT_ELEMENT_TYPE:
  12481. return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));
  12482. case REACT_PORTAL_TYPE:
  12483. return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));
  12484. }
  12485. }
  12486. if (typeof newChild === 'string' || typeof newChild === 'number') {
  12487. return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));
  12488. }
  12489. if (isArray(newChild)) {
  12490. return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);
  12491. }
  12492. if (getIteratorFn(newChild)) {
  12493. return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);
  12494. }
  12495. if (isObject) {
  12496. throwOnInvalidObjectType(returnFiber, newChild);
  12497. }
  12498. {
  12499. if (typeof newChild === 'function') {
  12500. warnOnFunctionType();
  12501. }
  12502. }
  12503. if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {
  12504. // If the new child is undefined, and the return fiber is a composite
  12505. // component, throw an error. If Fiber return types are disabled,
  12506. // we already threw above.
  12507. switch (returnFiber.tag) {
  12508. case ClassComponent:
  12509. {
  12510. {
  12511. var instance = returnFiber.stateNode;
  12512. if (instance.render._isMockFunction) {
  12513. // We allow auto-mocks to proceed as if they're returning null.
  12514. break;
  12515. }
  12516. }
  12517. }
  12518. // Intentionally fall through to the next case, which handles both
  12519. // functions and classes
  12520. // eslint-disable-next-lined no-fallthrough
  12521. case FunctionComponent:
  12522. {
  12523. var Component = returnFiber.type;
  12524. invariant(false, '%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.', Component.displayName || Component.name || 'Component');
  12525. }
  12526. }
  12527. }
  12528. // Remaining cases are all treated as empty.
  12529. return deleteRemainingChildren(returnFiber, currentFirstChild);
  12530. }
  12531. return reconcileChildFibers;
  12532. }
  12533. var reconcileChildFibers = ChildReconciler(true);
  12534. var mountChildFibers = ChildReconciler(false);
  12535. function cloneChildFibers(current$$1, workInProgress) {
  12536. !(current$$1 === null || workInProgress.child === current$$1.child) ? invariant(false, 'Resuming work not yet implemented.') : void 0;
  12537. if (workInProgress.child === null) {
  12538. return;
  12539. }
  12540. var currentChild = workInProgress.child;
  12541. var newChild = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
  12542. workInProgress.child = newChild;
  12543. newChild.return = workInProgress;
  12544. while (currentChild.sibling !== null) {
  12545. currentChild = currentChild.sibling;
  12546. newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
  12547. newChild.return = workInProgress;
  12548. }
  12549. newChild.sibling = null;
  12550. }
  12551. // The deepest Fiber on the stack involved in a hydration context.
  12552. // This may have been an insertion or a hydration.
  12553. var hydrationParentFiber = null;
  12554. var nextHydratableInstance = null;
  12555. var isHydrating = false;
  12556. function enterHydrationState(fiber) {
  12557. if (!supportsHydration) {
  12558. return false;
  12559. }
  12560. var parentInstance = fiber.stateNode.containerInfo;
  12561. nextHydratableInstance = getFirstHydratableChild(parentInstance);
  12562. hydrationParentFiber = fiber;
  12563. isHydrating = true;
  12564. return true;
  12565. }
  12566. function deleteHydratableInstance(returnFiber, instance) {
  12567. {
  12568. switch (returnFiber.tag) {
  12569. case HostRoot:
  12570. didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance);
  12571. break;
  12572. case HostComponent:
  12573. didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance);
  12574. break;
  12575. }
  12576. }
  12577. var childToDelete = createFiberFromHostInstanceForDeletion();
  12578. childToDelete.stateNode = instance;
  12579. childToDelete.return = returnFiber;
  12580. childToDelete.effectTag = Deletion;
  12581. // This might seem like it belongs on progressedFirstDeletion. However,
  12582. // these children are not part of the reconciliation list of children.
  12583. // Even if we abort and rereconcile the children, that will try to hydrate
  12584. // again and the nodes are still in the host tree so these will be
  12585. // recreated.
  12586. if (returnFiber.lastEffect !== null) {
  12587. returnFiber.lastEffect.nextEffect = childToDelete;
  12588. returnFiber.lastEffect = childToDelete;
  12589. } else {
  12590. returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
  12591. }
  12592. }
  12593. function insertNonHydratedInstance(returnFiber, fiber) {
  12594. fiber.effectTag |= Placement;
  12595. {
  12596. switch (returnFiber.tag) {
  12597. case HostRoot:
  12598. {
  12599. var parentContainer = returnFiber.stateNode.containerInfo;
  12600. switch (fiber.tag) {
  12601. case HostComponent:
  12602. var type = fiber.type;
  12603. var props = fiber.pendingProps;
  12604. didNotFindHydratableContainerInstance(parentContainer, type, props);
  12605. break;
  12606. case HostText:
  12607. var text = fiber.pendingProps;
  12608. didNotFindHydratableContainerTextInstance(parentContainer, text);
  12609. break;
  12610. }
  12611. break;
  12612. }
  12613. case HostComponent:
  12614. {
  12615. var parentType = returnFiber.type;
  12616. var parentProps = returnFiber.memoizedProps;
  12617. var parentInstance = returnFiber.stateNode;
  12618. switch (fiber.tag) {
  12619. case HostComponent:
  12620. var _type = fiber.type;
  12621. var _props = fiber.pendingProps;
  12622. didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type, _props);
  12623. break;
  12624. case HostText:
  12625. var _text = fiber.pendingProps;
  12626. didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text);
  12627. break;
  12628. }
  12629. break;
  12630. }
  12631. default:
  12632. return;
  12633. }
  12634. }
  12635. }
  12636. function tryHydrate(fiber, nextInstance) {
  12637. switch (fiber.tag) {
  12638. case HostComponent:
  12639. {
  12640. var type = fiber.type;
  12641. var props = fiber.pendingProps;
  12642. var instance = canHydrateInstance(nextInstance, type, props);
  12643. if (instance !== null) {
  12644. fiber.stateNode = instance;
  12645. return true;
  12646. }
  12647. return false;
  12648. }
  12649. case HostText:
  12650. {
  12651. var text = fiber.pendingProps;
  12652. var textInstance = canHydrateTextInstance(nextInstance, text);
  12653. if (textInstance !== null) {
  12654. fiber.stateNode = textInstance;
  12655. return true;
  12656. }
  12657. return false;
  12658. }
  12659. default:
  12660. return false;
  12661. }
  12662. }
  12663. function tryToClaimNextHydratableInstance(fiber) {
  12664. if (!isHydrating) {
  12665. return;
  12666. }
  12667. var nextInstance = nextHydratableInstance;
  12668. if (!nextInstance) {
  12669. // Nothing to hydrate. Make it an insertion.
  12670. insertNonHydratedInstance(hydrationParentFiber, fiber);
  12671. isHydrating = false;
  12672. hydrationParentFiber = fiber;
  12673. return;
  12674. }
  12675. var firstAttemptedInstance = nextInstance;
  12676. if (!tryHydrate(fiber, nextInstance)) {
  12677. // If we can't hydrate this instance let's try the next one.
  12678. // We use this as a heuristic. It's based on intuition and not data so it
  12679. // might be flawed or unnecessary.
  12680. nextInstance = getNextHydratableSibling(firstAttemptedInstance);
  12681. if (!nextInstance || !tryHydrate(fiber, nextInstance)) {
  12682. // Nothing to hydrate. Make it an insertion.
  12683. insertNonHydratedInstance(hydrationParentFiber, fiber);
  12684. isHydrating = false;
  12685. hydrationParentFiber = fiber;
  12686. return;
  12687. }
  12688. // We matched the next one, we'll now assume that the first one was
  12689. // superfluous and we'll delete it. Since we can't eagerly delete it
  12690. // we'll have to schedule a deletion. To do that, this node needs a dummy
  12691. // fiber associated with it.
  12692. deleteHydratableInstance(hydrationParentFiber, firstAttemptedInstance);
  12693. }
  12694. hydrationParentFiber = fiber;
  12695. nextHydratableInstance = getFirstHydratableChild(nextInstance);
  12696. }
  12697. function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) {
  12698. if (!supportsHydration) {
  12699. invariant(false, 'Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.');
  12700. }
  12701. var instance = fiber.stateNode;
  12702. var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber);
  12703. // TODO: Type this specific to this type of component.
  12704. fiber.updateQueue = updatePayload;
  12705. // If the update payload indicates that there is a change or if there
  12706. // is a new ref we mark this as an update.
  12707. if (updatePayload !== null) {
  12708. return true;
  12709. }
  12710. return false;
  12711. }
  12712. function prepareToHydrateHostTextInstance(fiber) {
  12713. if (!supportsHydration) {
  12714. invariant(false, 'Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.');
  12715. }
  12716. var textInstance = fiber.stateNode;
  12717. var textContent = fiber.memoizedProps;
  12718. var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber);
  12719. {
  12720. if (shouldUpdate) {
  12721. // We assume that prepareToHydrateHostTextInstance is called in a context where the
  12722. // hydration parent is the parent host component of this host text.
  12723. var returnFiber = hydrationParentFiber;
  12724. if (returnFiber !== null) {
  12725. switch (returnFiber.tag) {
  12726. case HostRoot:
  12727. {
  12728. var parentContainer = returnFiber.stateNode.containerInfo;
  12729. didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent);
  12730. break;
  12731. }
  12732. case HostComponent:
  12733. {
  12734. var parentType = returnFiber.type;
  12735. var parentProps = returnFiber.memoizedProps;
  12736. var parentInstance = returnFiber.stateNode;
  12737. didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent);
  12738. break;
  12739. }
  12740. }
  12741. }
  12742. }
  12743. }
  12744. return shouldUpdate;
  12745. }
  12746. function popToNextHostParent(fiber) {
  12747. var parent = fiber.return;
  12748. while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot) {
  12749. parent = parent.return;
  12750. }
  12751. hydrationParentFiber = parent;
  12752. }
  12753. function popHydrationState(fiber) {
  12754. if (!supportsHydration) {
  12755. return false;
  12756. }
  12757. if (fiber !== hydrationParentFiber) {
  12758. // We're deeper than the current hydration context, inside an inserted
  12759. // tree.
  12760. return false;
  12761. }
  12762. if (!isHydrating) {
  12763. // If we're not currently hydrating but we're in a hydration context, then
  12764. // we were an insertion and now need to pop up reenter hydration of our
  12765. // siblings.
  12766. popToNextHostParent(fiber);
  12767. isHydrating = true;
  12768. return false;
  12769. }
  12770. var type = fiber.type;
  12771. // If we have any remaining hydratable nodes, we need to delete them now.
  12772. // We only do this deeper than head and body since they tend to have random
  12773. // other nodes in them. We also ignore components with pure text content in
  12774. // side of them.
  12775. // TODO: Better heuristic.
  12776. if (fiber.tag !== HostComponent || type !== 'head' && type !== 'body' && !shouldSetTextContent(type, fiber.memoizedProps)) {
  12777. var nextInstance = nextHydratableInstance;
  12778. while (nextInstance) {
  12779. deleteHydratableInstance(fiber, nextInstance);
  12780. nextInstance = getNextHydratableSibling(nextInstance);
  12781. }
  12782. }
  12783. popToNextHostParent(fiber);
  12784. nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null;
  12785. return true;
  12786. }
  12787. function resetHydrationState() {
  12788. if (!supportsHydration) {
  12789. return;
  12790. }
  12791. hydrationParentFiber = null;
  12792. nextHydratableInstance = null;
  12793. isHydrating = false;
  12794. }
  12795. var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner;
  12796. var didWarnAboutBadClass = void 0;
  12797. var didWarnAboutContextTypeOnFunctionComponent = void 0;
  12798. var didWarnAboutGetDerivedStateOnFunctionComponent = void 0;
  12799. var didWarnAboutFunctionRefs = void 0;
  12800. {
  12801. didWarnAboutBadClass = {};
  12802. didWarnAboutContextTypeOnFunctionComponent = {};
  12803. didWarnAboutGetDerivedStateOnFunctionComponent = {};
  12804. didWarnAboutFunctionRefs = {};
  12805. }
  12806. function reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime) {
  12807. if (current$$1 === null) {
  12808. // If this is a fresh new component that hasn't been rendered yet, we
  12809. // won't update its child set by applying minimal side-effects. Instead,
  12810. // we will add them all to the child before it gets rendered. That means
  12811. // we can optimize this reconciliation pass by not tracking side-effects.
  12812. workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  12813. } else {
  12814. // If the current child is the same as the work in progress, it means that
  12815. // we haven't yet started any work on these children. Therefore, we use
  12816. // the clone algorithm to create a copy of all the current children.
  12817. // If we had any progressed work already, that is invalid at this point so
  12818. // let's throw it out.
  12819. workInProgress.child = reconcileChildFibers(workInProgress, current$$1.child, nextChildren, renderExpirationTime);
  12820. }
  12821. }
  12822. function forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildren, renderExpirationTime) {
  12823. // This function is fork of reconcileChildren. It's used in cases where we
  12824. // want to reconcile without matching against the existing set. This has the
  12825. // effect of all current children being unmounted; even if the type and key
  12826. // are the same, the old child is unmounted and a new child is created.
  12827. //
  12828. // To do this, we're going to go through the reconcile algorithm twice. In
  12829. // the first pass, we schedule a deletion for all the current children by
  12830. // passing null.
  12831. workInProgress.child = reconcileChildFibers(workInProgress, current$$1.child, null, renderExpirationTime);
  12832. // In the second pass, we mount the new children. The trick here is that we
  12833. // pass null in place of where we usually pass the current child set. This has
  12834. // the effect of remounting all children regardless of whether their their
  12835. // identity matches.
  12836. workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  12837. }
  12838. function updateForwardRef(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
  12839. var render = Component.render;
  12840. var ref = workInProgress.ref;
  12841. // The rest is a fork of updateFunctionComponent
  12842. var nextChildren = void 0;
  12843. prepareToReadContext(workInProgress, renderExpirationTime);
  12844. prepareToUseHooks(current$$1, workInProgress, renderExpirationTime);
  12845. {
  12846. ReactCurrentOwner$3.current = workInProgress;
  12847. setCurrentPhase('render');
  12848. nextChildren = render(nextProps, ref);
  12849. setCurrentPhase(null);
  12850. }
  12851. nextChildren = finishHooks(render, nextProps, nextChildren, ref);
  12852. // React DevTools reads this flag.
  12853. workInProgress.effectTag |= PerformedWork;
  12854. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  12855. return workInProgress.child;
  12856. }
  12857. function updateMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
  12858. if (current$$1 === null) {
  12859. var type = Component.type;
  12860. if (isSimpleFunctionComponent(type) && Component.compare === null) {
  12861. // If this is a plain function component without default props,
  12862. // and with only the default shallow comparison, we upgrade it
  12863. // to a SimpleMemoComponent to allow fast path updates.
  12864. workInProgress.tag = SimpleMemoComponent;
  12865. workInProgress.type = type;
  12866. return updateSimpleMemoComponent(current$$1, workInProgress, type, nextProps, updateExpirationTime, renderExpirationTime);
  12867. }
  12868. var child = createFiberFromTypeAndProps(Component.type, null, nextProps, null, workInProgress.mode, renderExpirationTime);
  12869. child.ref = workInProgress.ref;
  12870. child.return = workInProgress;
  12871. workInProgress.child = child;
  12872. return child;
  12873. }
  12874. var currentChild = current$$1.child; // This is always exactly one child
  12875. if (updateExpirationTime < renderExpirationTime) {
  12876. // This will be the props with resolved defaultProps,
  12877. // unlike current.memoizedProps which will be the unresolved ones.
  12878. var prevProps = currentChild.memoizedProps;
  12879. // Default to shallow comparison
  12880. var compare = Component.compare;
  12881. compare = compare !== null ? compare : shallowEqual;
  12882. if (compare(prevProps, nextProps) && current$$1.ref === workInProgress.ref) {
  12883. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  12884. }
  12885. }
  12886. // React DevTools reads this flag.
  12887. workInProgress.effectTag |= PerformedWork;
  12888. var newChild = createWorkInProgress(currentChild, nextProps, renderExpirationTime);
  12889. newChild.ref = workInProgress.ref;
  12890. newChild.return = workInProgress;
  12891. workInProgress.child = newChild;
  12892. return newChild;
  12893. }
  12894. function updateSimpleMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
  12895. if (current$$1 !== null && updateExpirationTime < renderExpirationTime) {
  12896. var prevProps = current$$1.memoizedProps;
  12897. if (shallowEqual(prevProps, nextProps) && current$$1.ref === workInProgress.ref) {
  12898. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  12899. }
  12900. }
  12901. return updateFunctionComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime);
  12902. }
  12903. function updateFragment(current$$1, workInProgress, renderExpirationTime) {
  12904. var nextChildren = workInProgress.pendingProps;
  12905. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  12906. return workInProgress.child;
  12907. }
  12908. function updateMode(current$$1, workInProgress, renderExpirationTime) {
  12909. var nextChildren = workInProgress.pendingProps.children;
  12910. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  12911. return workInProgress.child;
  12912. }
  12913. function updateProfiler(current$$1, workInProgress, renderExpirationTime) {
  12914. if (enableProfilerTimer) {
  12915. workInProgress.effectTag |= Update;
  12916. }
  12917. var nextProps = workInProgress.pendingProps;
  12918. var nextChildren = nextProps.children;
  12919. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  12920. return workInProgress.child;
  12921. }
  12922. function markRef(current$$1, workInProgress) {
  12923. var ref = workInProgress.ref;
  12924. if (current$$1 === null && ref !== null || current$$1 !== null && current$$1.ref !== ref) {
  12925. // Schedule a Ref effect
  12926. workInProgress.effectTag |= Ref;
  12927. }
  12928. }
  12929. function updateFunctionComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
  12930. var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
  12931. var context = getMaskedContext(workInProgress, unmaskedContext);
  12932. var nextChildren = void 0;
  12933. prepareToReadContext(workInProgress, renderExpirationTime);
  12934. prepareToUseHooks(current$$1, workInProgress, renderExpirationTime);
  12935. {
  12936. ReactCurrentOwner$3.current = workInProgress;
  12937. setCurrentPhase('render');
  12938. nextChildren = Component(nextProps, context);
  12939. setCurrentPhase(null);
  12940. }
  12941. nextChildren = finishHooks(Component, nextProps, nextChildren, context);
  12942. // React DevTools reads this flag.
  12943. workInProgress.effectTag |= PerformedWork;
  12944. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  12945. return workInProgress.child;
  12946. }
  12947. function updateClassComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
  12948. // Push context providers early to prevent context stack mismatches.
  12949. // During mounting we don't know the child context yet as the instance doesn't exist.
  12950. // We will invalidate the child context in finishClassComponent() right after rendering.
  12951. var hasContext = void 0;
  12952. if (isContextProvider(Component)) {
  12953. hasContext = true;
  12954. pushContextProvider(workInProgress);
  12955. } else {
  12956. hasContext = false;
  12957. }
  12958. prepareToReadContext(workInProgress, renderExpirationTime);
  12959. var instance = workInProgress.stateNode;
  12960. var shouldUpdate = void 0;
  12961. if (instance === null) {
  12962. if (current$$1 !== null) {
  12963. // An class component without an instance only mounts if it suspended
  12964. // inside a non- concurrent tree, in an inconsistent state. We want to
  12965. // tree it like a new mount, even though an empty version of it already
  12966. // committed. Disconnect the alternate pointers.
  12967. current$$1.alternate = null;
  12968. workInProgress.alternate = null;
  12969. // Since this is conceptually a new fiber, schedule a Placement effect
  12970. workInProgress.effectTag |= Placement;
  12971. }
  12972. // In the initial pass we might need to construct the instance.
  12973. constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  12974. mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  12975. shouldUpdate = true;
  12976. } else if (current$$1 === null) {
  12977. // In a resume, we'll already have an instance we can reuse.
  12978. shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  12979. } else {
  12980. shouldUpdate = updateClassInstance(current$$1, workInProgress, Component, nextProps, renderExpirationTime);
  12981. }
  12982. return finishClassComponent(current$$1, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime);
  12983. }
  12984. function finishClassComponent(current$$1, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime) {
  12985. // Refs should update even if shouldComponentUpdate returns false
  12986. markRef(current$$1, workInProgress);
  12987. var didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect;
  12988. if (!shouldUpdate && !didCaptureError) {
  12989. // Context providers should defer to sCU for rendering
  12990. if (hasContext) {
  12991. invalidateContextProvider(workInProgress, Component, false);
  12992. }
  12993. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  12994. }
  12995. var instance = workInProgress.stateNode;
  12996. // Rerender
  12997. ReactCurrentOwner$3.current = workInProgress;
  12998. var nextChildren = void 0;
  12999. if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') {
  13000. // If we captured an error, but getDerivedStateFrom catch is not defined,
  13001. // unmount all the children. componentDidCatch will schedule an update to
  13002. // re-render a fallback. This is temporary until we migrate everyone to
  13003. // the new API.
  13004. // TODO: Warn in a future release.
  13005. nextChildren = null;
  13006. if (enableProfilerTimer) {
  13007. stopProfilerTimerIfRunning(workInProgress);
  13008. }
  13009. } else {
  13010. {
  13011. setCurrentPhase('render');
  13012. nextChildren = instance.render();
  13013. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  13014. instance.render();
  13015. }
  13016. setCurrentPhase(null);
  13017. }
  13018. }
  13019. // React DevTools reads this flag.
  13020. workInProgress.effectTag |= PerformedWork;
  13021. if (current$$1 !== null && didCaptureError) {
  13022. // If we're recovering from an error, reconcile without reusing any of
  13023. // the existing children. Conceptually, the normal children and the children
  13024. // that are shown on error are two different sets, so we shouldn't reuse
  13025. // normal children even if their identities match.
  13026. forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildren, renderExpirationTime);
  13027. } else {
  13028. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  13029. }
  13030. // Memoize state using the values we just used to render.
  13031. // TODO: Restructure so we never read values from the instance.
  13032. workInProgress.memoizedState = instance.state;
  13033. // The context might have changed so we need to recalculate it.
  13034. if (hasContext) {
  13035. invalidateContextProvider(workInProgress, Component, true);
  13036. }
  13037. return workInProgress.child;
  13038. }
  13039. function pushHostRootContext(workInProgress) {
  13040. var root = workInProgress.stateNode;
  13041. if (root.pendingContext) {
  13042. pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context);
  13043. } else if (root.context) {
  13044. // Should always be set
  13045. pushTopLevelContextObject(workInProgress, root.context, false);
  13046. }
  13047. pushHostContainer(workInProgress, root.containerInfo);
  13048. }
  13049. function updateHostRoot(current$$1, workInProgress, renderExpirationTime) {
  13050. pushHostRootContext(workInProgress);
  13051. var updateQueue = workInProgress.updateQueue;
  13052. !(updateQueue !== null) ? invariant(false, '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.') : void 0;
  13053. var nextProps = workInProgress.pendingProps;
  13054. var prevState = workInProgress.memoizedState;
  13055. var prevChildren = prevState !== null ? prevState.element : null;
  13056. processUpdateQueue(workInProgress, updateQueue, nextProps, null, renderExpirationTime);
  13057. var nextState = workInProgress.memoizedState;
  13058. // Caution: React DevTools currently depends on this property
  13059. // being called "element".
  13060. var nextChildren = nextState.element;
  13061. if (nextChildren === prevChildren) {
  13062. // If the state is the same as before, that's a bailout because we had
  13063. // no work that expires at this time.
  13064. resetHydrationState();
  13065. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  13066. }
  13067. var root = workInProgress.stateNode;
  13068. if ((current$$1 === null || current$$1.child === null) && root.hydrate && enterHydrationState(workInProgress)) {
  13069. // If we don't have any current children this might be the first pass.
  13070. // We always try to hydrate. If this isn't a hydration pass there won't
  13071. // be any children to hydrate which is effectively the same thing as
  13072. // not hydrating.
  13073. // This is a bit of a hack. We track the host root as a placement to
  13074. // know that we're currently in a mounting state. That way isMounted
  13075. // works as expected. We must reset this before committing.
  13076. // TODO: Delete this when we delete isMounted and findDOMNode.
  13077. workInProgress.effectTag |= Placement;
  13078. // Ensure that children mount into this root without tracking
  13079. // side-effects. This ensures that we don't store Placement effects on
  13080. // nodes that will be hydrated.
  13081. workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  13082. } else {
  13083. // Otherwise reset hydration state in case we aborted and resumed another
  13084. // root.
  13085. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  13086. resetHydrationState();
  13087. }
  13088. return workInProgress.child;
  13089. }
  13090. function updateHostComponent(current$$1, workInProgress, renderExpirationTime) {
  13091. pushHostContext(workInProgress);
  13092. if (current$$1 === null) {
  13093. tryToClaimNextHydratableInstance(workInProgress);
  13094. }
  13095. var type = workInProgress.type;
  13096. var nextProps = workInProgress.pendingProps;
  13097. var prevProps = current$$1 !== null ? current$$1.memoizedProps : null;
  13098. var nextChildren = nextProps.children;
  13099. var isDirectTextChild = shouldSetTextContent(type, nextProps);
  13100. if (isDirectTextChild) {
  13101. // We special case a direct text child of a host node. This is a common
  13102. // case. We won't handle it as a reified child. We will instead handle
  13103. // this in the host environment that also have access to this prop. That
  13104. // avoids allocating another HostText fiber and traversing it.
  13105. nextChildren = null;
  13106. } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) {
  13107. // If we're switching from a direct text child to a normal child, or to
  13108. // empty, we need to schedule the text content to be reset.
  13109. workInProgress.effectTag |= ContentReset;
  13110. }
  13111. markRef(current$$1, workInProgress);
  13112. // Check the host config to see if the children are offscreen/hidden.
  13113. if (renderExpirationTime !== Never && workInProgress.mode & ConcurrentMode && shouldDeprioritizeSubtree(type, nextProps)) {
  13114. // Schedule this fiber to re-render at offscreen priority. Then bailout.
  13115. workInProgress.expirationTime = Never;
  13116. return null;
  13117. }
  13118. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  13119. return workInProgress.child;
  13120. }
  13121. function updateHostText(current$$1, workInProgress) {
  13122. if (current$$1 === null) {
  13123. tryToClaimNextHydratableInstance(workInProgress);
  13124. }
  13125. // Nothing to do here. This is terminal. We'll do the completion step
  13126. // immediately after.
  13127. return null;
  13128. }
  13129. function mountLazyComponent(_current, workInProgress, elementType, updateExpirationTime, renderExpirationTime) {
  13130. if (_current !== null) {
  13131. // An lazy component only mounts if it suspended inside a non-
  13132. // concurrent tree, in an inconsistent state. We want to treat it like
  13133. // a new mount, even though an empty version of it already committed.
  13134. // Disconnect the alternate pointers.
  13135. _current.alternate = null;
  13136. workInProgress.alternate = null;
  13137. // Since this is conceptually a new fiber, schedule a Placement effect
  13138. workInProgress.effectTag |= Placement;
  13139. }
  13140. var props = workInProgress.pendingProps;
  13141. // We can't start a User Timing measurement with correct label yet.
  13142. // Cancel and resume right after we know the tag.
  13143. cancelWorkTimer(workInProgress);
  13144. var Component = readLazyComponentType(elementType);
  13145. // Store the unwrapped component in the type.
  13146. workInProgress.type = Component;
  13147. var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component);
  13148. startWorkTimer(workInProgress);
  13149. var resolvedProps = resolveDefaultProps(Component, props);
  13150. var child = void 0;
  13151. switch (resolvedTag) {
  13152. case FunctionComponent:
  13153. {
  13154. child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
  13155. break;
  13156. }
  13157. case ClassComponent:
  13158. {
  13159. child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
  13160. break;
  13161. }
  13162. case ForwardRef:
  13163. {
  13164. child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderExpirationTime);
  13165. break;
  13166. }
  13167. case MemoComponent:
  13168. {
  13169. child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too
  13170. updateExpirationTime, renderExpirationTime);
  13171. break;
  13172. }
  13173. default:
  13174. {
  13175. // This message intentionally doesn't mention ForwardRef or MemoComponent
  13176. // because the fact that it's a separate type of work is an
  13177. // implementation detail.
  13178. invariant(false, 'Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.', Component);
  13179. }
  13180. }
  13181. return child;
  13182. }
  13183. function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderExpirationTime) {
  13184. if (_current !== null) {
  13185. // An incomplete component only mounts if it suspended inside a non-
  13186. // concurrent tree, in an inconsistent state. We want to treat it like
  13187. // a new mount, even though an empty version of it already committed.
  13188. // Disconnect the alternate pointers.
  13189. _current.alternate = null;
  13190. workInProgress.alternate = null;
  13191. // Since this is conceptually a new fiber, schedule a Placement effect
  13192. workInProgress.effectTag |= Placement;
  13193. }
  13194. // Promote the fiber to a class and try rendering again.
  13195. workInProgress.tag = ClassComponent;
  13196. // The rest of this function is a fork of `updateClassComponent`
  13197. // Push context providers early to prevent context stack mismatches.
  13198. // During mounting we don't know the child context yet as the instance doesn't exist.
  13199. // We will invalidate the child context in finishClassComponent() right after rendering.
  13200. var hasContext = void 0;
  13201. if (isContextProvider(Component)) {
  13202. hasContext = true;
  13203. pushContextProvider(workInProgress);
  13204. } else {
  13205. hasContext = false;
  13206. }
  13207. prepareToReadContext(workInProgress, renderExpirationTime);
  13208. constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  13209. mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  13210. return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
  13211. }
  13212. function mountIndeterminateComponent(_current, workInProgress, Component, renderExpirationTime) {
  13213. if (_current !== null) {
  13214. // An indeterminate component only mounts if it suspended inside a non-
  13215. // concurrent tree, in an inconsistent state. We want to treat it like
  13216. // a new mount, even though an empty version of it already committed.
  13217. // Disconnect the alternate pointers.
  13218. _current.alternate = null;
  13219. workInProgress.alternate = null;
  13220. // Since this is conceptually a new fiber, schedule a Placement effect
  13221. workInProgress.effectTag |= Placement;
  13222. }
  13223. var props = workInProgress.pendingProps;
  13224. var unmaskedContext = getUnmaskedContext(workInProgress, Component, false);
  13225. var context = getMaskedContext(workInProgress, unmaskedContext);
  13226. prepareToReadContext(workInProgress, renderExpirationTime);
  13227. prepareToUseHooks(null, workInProgress, renderExpirationTime);
  13228. var value = void 0;
  13229. {
  13230. if (Component.prototype && typeof Component.prototype.render === 'function') {
  13231. var componentName = getComponentName(Component) || 'Unknown';
  13232. if (!didWarnAboutBadClass[componentName]) {
  13233. 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);
  13234. didWarnAboutBadClass[componentName] = true;
  13235. }
  13236. }
  13237. if (workInProgress.mode & StrictMode) {
  13238. ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
  13239. }
  13240. ReactCurrentOwner$3.current = workInProgress;
  13241. value = Component(props, context);
  13242. }
  13243. // React DevTools reads this flag.
  13244. workInProgress.effectTag |= PerformedWork;
  13245. if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
  13246. // Proceed under the assumption that this is a class instance
  13247. workInProgress.tag = ClassComponent;
  13248. // Throw out any hooks that were used.
  13249. resetHooks();
  13250. // Push context providers early to prevent context stack mismatches.
  13251. // During mounting we don't know the child context yet as the instance doesn't exist.
  13252. // We will invalidate the child context in finishClassComponent() right after rendering.
  13253. var hasContext = false;
  13254. if (isContextProvider(Component)) {
  13255. hasContext = true;
  13256. pushContextProvider(workInProgress);
  13257. } else {
  13258. hasContext = false;
  13259. }
  13260. workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null;
  13261. var getDerivedStateFromProps = Component.getDerivedStateFromProps;
  13262. if (typeof getDerivedStateFromProps === 'function') {
  13263. applyDerivedStateFromProps(workInProgress, Component, getDerivedStateFromProps, props);
  13264. }
  13265. adoptClassInstance(workInProgress, value);
  13266. mountClassInstance(workInProgress, Component, props, renderExpirationTime);
  13267. return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
  13268. } else {
  13269. // Proceed under the assumption that this is a function component
  13270. workInProgress.tag = FunctionComponent;
  13271. value = finishHooks(Component, props, value, context);
  13272. {
  13273. if (Component) {
  13274. !!Component.childContextTypes ? warningWithoutStack$1(false, '%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component') : void 0;
  13275. }
  13276. if (workInProgress.ref !== null) {
  13277. var info = '';
  13278. var ownerName = getCurrentFiberOwnerNameInDevOrNull();
  13279. if (ownerName) {
  13280. info += '\n\nCheck the render method of `' + ownerName + '`.';
  13281. }
  13282. var warningKey = ownerName || workInProgress._debugID || '';
  13283. var debugSource = workInProgress._debugSource;
  13284. if (debugSource) {
  13285. warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
  13286. }
  13287. if (!didWarnAboutFunctionRefs[warningKey]) {
  13288. didWarnAboutFunctionRefs[warningKey] = true;
  13289. warning$1(false, 'Function components cannot be given refs. ' + 'Attempts to access this ref will fail.%s', info);
  13290. }
  13291. }
  13292. if (typeof Component.getDerivedStateFromProps === 'function') {
  13293. var _componentName = getComponentName(Component) || 'Unknown';
  13294. if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName]) {
  13295. warningWithoutStack$1(false, '%s: Function components do not support getDerivedStateFromProps.', _componentName);
  13296. didWarnAboutGetDerivedStateOnFunctionComponent[_componentName] = true;
  13297. }
  13298. }
  13299. if (typeof Component.contextType === 'object' && Component.contextType !== null) {
  13300. var _componentName2 = getComponentName(Component) || 'Unknown';
  13301. if (!didWarnAboutContextTypeOnFunctionComponent[_componentName2]) {
  13302. warningWithoutStack$1(false, '%s: Function components do not support contextType.', _componentName2);
  13303. didWarnAboutContextTypeOnFunctionComponent[_componentName2] = true;
  13304. }
  13305. }
  13306. }
  13307. reconcileChildren(null, workInProgress, value, renderExpirationTime);
  13308. return workInProgress.child;
  13309. }
  13310. }
  13311. function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime) {
  13312. var mode = workInProgress.mode;
  13313. var nextProps = workInProgress.pendingProps;
  13314. // We should attempt to render the primary children unless this boundary
  13315. // already suspended during this render (`alreadyCaptured` is true).
  13316. var nextState = workInProgress.memoizedState;
  13317. var nextDidTimeout = void 0;
  13318. if ((workInProgress.effectTag & DidCapture) === NoEffect) {
  13319. // This is the first attempt.
  13320. nextState = null;
  13321. nextDidTimeout = false;
  13322. } else {
  13323. // Something in this boundary's subtree already suspended. Switch to
  13324. // rendering the fallback children.
  13325. nextState = {
  13326. timedOutAt: nextState !== null ? nextState.timedOutAt : NoWork
  13327. };
  13328. nextDidTimeout = true;
  13329. workInProgress.effectTag &= ~DidCapture;
  13330. }
  13331. // This next part is a bit confusing. If the children timeout, we switch to
  13332. // showing the fallback children in place of the "primary" children.
  13333. // However, we don't want to delete the primary children because then their
  13334. // state will be lost (both the React state and the host state, e.g.
  13335. // uncontrolled form inputs). Instead we keep them mounted and hide them.
  13336. // Both the fallback children AND the primary children are rendered at the
  13337. // same time. Once the primary children are un-suspended, we can delete
  13338. // the fallback children — don't need to preserve their state.
  13339. //
  13340. // The two sets of children are siblings in the host environment, but
  13341. // semantically, for purposes of reconciliation, they are two separate sets.
  13342. // So we store them using two fragment fibers.
  13343. //
  13344. // However, we want to avoid allocating extra fibers for every placeholder.
  13345. // They're only necessary when the children time out, because that's the
  13346. // only time when both sets are mounted.
  13347. //
  13348. // So, the extra fragment fibers are only used if the children time out.
  13349. // Otherwise, we render the primary children directly. This requires some
  13350. // custom reconciliation logic to preserve the state of the primary
  13351. // children. It's essentially a very basic form of re-parenting.
  13352. // `child` points to the child fiber. In the normal case, this is the first
  13353. // fiber of the primary children set. In the timed-out case, it's a
  13354. // a fragment fiber containing the primary children.
  13355. var child = void 0;
  13356. // `next` points to the next fiber React should render. In the normal case,
  13357. // it's the same as `child`: the first fiber of the primary children set.
  13358. // In the timed-out case, it's a fragment fiber containing the *fallback*
  13359. // children -- we skip over the primary children entirely.
  13360. var next = void 0;
  13361. if (current$$1 === null) {
  13362. // This is the initial mount. This branch is pretty simple because there's
  13363. // no previous state that needs to be preserved.
  13364. if (nextDidTimeout) {
  13365. // Mount separate fragments for primary and fallback children.
  13366. var nextFallbackChildren = nextProps.fallback;
  13367. var primaryChildFragment = createFiberFromFragment(null, mode, NoWork, null);
  13368. if ((workInProgress.mode & ConcurrentMode) === NoContext) {
  13369. // Outside of concurrent mode, we commit the effects from the
  13370. var progressedState = workInProgress.memoizedState;
  13371. var progressedPrimaryChild = progressedState !== null ? workInProgress.child.child : workInProgress.child;
  13372. primaryChildFragment.child = progressedPrimaryChild;
  13373. }
  13374. var fallbackChildFragment = createFiberFromFragment(nextFallbackChildren, mode, renderExpirationTime, null);
  13375. primaryChildFragment.sibling = fallbackChildFragment;
  13376. child = primaryChildFragment;
  13377. // Skip the primary children, and continue working on the
  13378. // fallback children.
  13379. next = fallbackChildFragment;
  13380. child.return = next.return = workInProgress;
  13381. } else {
  13382. // Mount the primary children without an intermediate fragment fiber.
  13383. var nextPrimaryChildren = nextProps.children;
  13384. child = next = mountChildFibers(workInProgress, null, nextPrimaryChildren, renderExpirationTime);
  13385. }
  13386. } else {
  13387. // This is an update. This branch is more complicated because we need to
  13388. // ensure the state of the primary children is preserved.
  13389. var prevState = current$$1.memoizedState;
  13390. var prevDidTimeout = prevState !== null;
  13391. if (prevDidTimeout) {
  13392. // The current tree already timed out. That means each child set is
  13393. var currentPrimaryChildFragment = current$$1.child;
  13394. var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
  13395. if (nextDidTimeout) {
  13396. // Still timed out. Reuse the current primary children by cloning
  13397. // its fragment. We're going to skip over these entirely.
  13398. var _nextFallbackChildren = nextProps.fallback;
  13399. var _primaryChildFragment = createWorkInProgress(currentPrimaryChildFragment, currentPrimaryChildFragment.pendingProps, NoWork);
  13400. if ((workInProgress.mode & ConcurrentMode) === NoContext) {
  13401. // Outside of concurrent mode, we commit the effects from the
  13402. var _progressedState = workInProgress.memoizedState;
  13403. var _progressedPrimaryChild = _progressedState !== null ? workInProgress.child.child : workInProgress.child;
  13404. if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) {
  13405. _primaryChildFragment.child = _progressedPrimaryChild;
  13406. }
  13407. }
  13408. // Because primaryChildFragment is a new fiber that we're inserting as the
  13409. // parent of a new tree, we need to set its treeBaseDuration.
  13410. if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
  13411. // treeBaseDuration is the sum of all the child tree base durations.
  13412. var treeBaseDuration = 0;
  13413. var hiddenChild = _primaryChildFragment.child;
  13414. while (hiddenChild !== null) {
  13415. treeBaseDuration += hiddenChild.treeBaseDuration;
  13416. hiddenChild = hiddenChild.sibling;
  13417. }
  13418. _primaryChildFragment.treeBaseDuration = treeBaseDuration;
  13419. }
  13420. // Clone the fallback child fragment, too. These we'll continue
  13421. // working on.
  13422. var _fallbackChildFragment = _primaryChildFragment.sibling = createWorkInProgress(currentFallbackChildFragment, _nextFallbackChildren, currentFallbackChildFragment.expirationTime);
  13423. child = _primaryChildFragment;
  13424. _primaryChildFragment.childExpirationTime = NoWork;
  13425. // Skip the primary children, and continue working on the
  13426. // fallback children.
  13427. next = _fallbackChildFragment;
  13428. child.return = next.return = workInProgress;
  13429. } else {
  13430. // No longer suspended. Switch back to showing the primary children,
  13431. // and remove the intermediate fragment fiber.
  13432. var _nextPrimaryChildren = nextProps.children;
  13433. var currentPrimaryChild = currentPrimaryChildFragment.child;
  13434. var primaryChild = reconcileChildFibers(workInProgress, currentPrimaryChild, _nextPrimaryChildren, renderExpirationTime);
  13435. // If this render doesn't suspend, we need to delete the fallback
  13436. // children. Wait until the complete phase, after we've confirmed the
  13437. // fallback is no longer needed.
  13438. // TODO: Would it be better to store the fallback fragment on
  13439. // the stateNode?
  13440. // Continue rendering the children, like we normally do.
  13441. child = next = primaryChild;
  13442. }
  13443. } else {
  13444. // The current tree has not already timed out. That means the primary
  13445. // children are not wrapped in a fragment fiber.
  13446. var _currentPrimaryChild = current$$1.child;
  13447. if (nextDidTimeout) {
  13448. // Timed out. Wrap the children in a fragment fiber to keep them
  13449. // separate from the fallback children.
  13450. var _nextFallbackChildren2 = nextProps.fallback;
  13451. var _primaryChildFragment2 = createFiberFromFragment(
  13452. // It shouldn't matter what the pending props are because we aren't
  13453. // going to render this fragment.
  13454. null, mode, NoWork, null);
  13455. _primaryChildFragment2.child = _currentPrimaryChild;
  13456. // Even though we're creating a new fiber, there are no new children,
  13457. // because we're reusing an already mounted tree. So we don't need to
  13458. // schedule a placement.
  13459. // primaryChildFragment.effectTag |= Placement;
  13460. if ((workInProgress.mode & ConcurrentMode) === NoContext) {
  13461. // Outside of concurrent mode, we commit the effects from the
  13462. var _progressedState2 = workInProgress.memoizedState;
  13463. var _progressedPrimaryChild2 = _progressedState2 !== null ? workInProgress.child.child : workInProgress.child;
  13464. _primaryChildFragment2.child = _progressedPrimaryChild2;
  13465. }
  13466. // Because primaryChildFragment is a new fiber that we're inserting as the
  13467. // parent of a new tree, we need to set its treeBaseDuration.
  13468. if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
  13469. // treeBaseDuration is the sum of all the child tree base durations.
  13470. var _treeBaseDuration = 0;
  13471. var _hiddenChild = _primaryChildFragment2.child;
  13472. while (_hiddenChild !== null) {
  13473. _treeBaseDuration += _hiddenChild.treeBaseDuration;
  13474. _hiddenChild = _hiddenChild.sibling;
  13475. }
  13476. _primaryChildFragment2.treeBaseDuration = _treeBaseDuration;
  13477. }
  13478. // Create a fragment from the fallback children, too.
  13479. var _fallbackChildFragment2 = _primaryChildFragment2.sibling = createFiberFromFragment(_nextFallbackChildren2, mode, renderExpirationTime, null);
  13480. _fallbackChildFragment2.effectTag |= Placement;
  13481. child = _primaryChildFragment2;
  13482. _primaryChildFragment2.childExpirationTime = NoWork;
  13483. // Skip the primary children, and continue working on the
  13484. // fallback children.
  13485. next = _fallbackChildFragment2;
  13486. child.return = next.return = workInProgress;
  13487. } else {
  13488. // Still haven't timed out. Continue rendering the children, like we
  13489. // normally do.
  13490. var _nextPrimaryChildren2 = nextProps.children;
  13491. next = child = reconcileChildFibers(workInProgress, _currentPrimaryChild, _nextPrimaryChildren2, renderExpirationTime);
  13492. }
  13493. }
  13494. }
  13495. workInProgress.memoizedState = nextState;
  13496. workInProgress.child = child;
  13497. return next;
  13498. }
  13499. function updatePortalComponent(current$$1, workInProgress, renderExpirationTime) {
  13500. pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
  13501. var nextChildren = workInProgress.pendingProps;
  13502. if (current$$1 === null) {
  13503. // Portals are special because we don't append the children during mount
  13504. // but at commit. Therefore we need to track insertions which the normal
  13505. // flow doesn't do during mount. This doesn't happen at the root because
  13506. // the root always starts with a "current" with a null child.
  13507. // TODO: Consider unifying this with how the root works.
  13508. workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  13509. } else {
  13510. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  13511. }
  13512. return workInProgress.child;
  13513. }
  13514. function updateContextProvider(current$$1, workInProgress, renderExpirationTime) {
  13515. var providerType = workInProgress.type;
  13516. var context = providerType._context;
  13517. var newProps = workInProgress.pendingProps;
  13518. var oldProps = workInProgress.memoizedProps;
  13519. var newValue = newProps.value;
  13520. {
  13521. var providerPropTypes = workInProgress.type.propTypes;
  13522. if (providerPropTypes) {
  13523. checkPropTypes(providerPropTypes, newProps, 'prop', 'Context.Provider', getCurrentFiberStackInDev);
  13524. }
  13525. }
  13526. pushProvider(workInProgress, newValue);
  13527. if (oldProps !== null) {
  13528. var oldValue = oldProps.value;
  13529. var changedBits = calculateChangedBits(context, newValue, oldValue);
  13530. if (changedBits === 0) {
  13531. // No change. Bailout early if children are the same.
  13532. if (oldProps.children === newProps.children && !hasContextChanged()) {
  13533. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  13534. }
  13535. } else {
  13536. // The context value changed. Search for matching consumers and schedule
  13537. // them to update.
  13538. propagateContextChange(workInProgress, context, changedBits, renderExpirationTime);
  13539. }
  13540. }
  13541. var newChildren = newProps.children;
  13542. reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
  13543. return workInProgress.child;
  13544. }
  13545. var hasWarnedAboutUsingContextAsConsumer = false;
  13546. function updateContextConsumer(current$$1, workInProgress, renderExpirationTime) {
  13547. var context = workInProgress.type;
  13548. // The logic below for Context differs depending on PROD or DEV mode. In
  13549. // DEV mode, we create a separate object for Context.Consumer that acts
  13550. // like a proxy to Context. This proxy object adds unnecessary code in PROD
  13551. // so we use the old behaviour (Context.Consumer references Context) to
  13552. // reduce size and overhead. The separate object references context via
  13553. // a property called "_context", which also gives us the ability to check
  13554. // in DEV mode if this property exists or not and warn if it does not.
  13555. {
  13556. if (context._context === undefined) {
  13557. // This may be because it's a Context (rather than a Consumer).
  13558. // Or it may be because it's older React where they're the same thing.
  13559. // We only want to warn if we're sure it's a new React.
  13560. if (context !== context.Consumer) {
  13561. if (!hasWarnedAboutUsingContextAsConsumer) {
  13562. hasWarnedAboutUsingContextAsConsumer = true;
  13563. 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?');
  13564. }
  13565. }
  13566. } else {
  13567. context = context._context;
  13568. }
  13569. }
  13570. var newProps = workInProgress.pendingProps;
  13571. var render = newProps.children;
  13572. {
  13573. !(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;
  13574. }
  13575. prepareToReadContext(workInProgress, renderExpirationTime);
  13576. var newValue = readContext(context, newProps.unstable_observedBits);
  13577. var newChildren = void 0;
  13578. {
  13579. ReactCurrentOwner$3.current = workInProgress;
  13580. setCurrentPhase('render');
  13581. newChildren = render(newValue);
  13582. setCurrentPhase(null);
  13583. }
  13584. // React DevTools reads this flag.
  13585. workInProgress.effectTag |= PerformedWork;
  13586. reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
  13587. return workInProgress.child;
  13588. }
  13589. function bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime) {
  13590. cancelWorkTimer(workInProgress);
  13591. if (current$$1 !== null) {
  13592. // Reuse previous context list
  13593. workInProgress.firstContextDependency = current$$1.firstContextDependency;
  13594. }
  13595. if (enableProfilerTimer) {
  13596. // Don't update "base" render times for bailouts.
  13597. stopProfilerTimerIfRunning(workInProgress);
  13598. }
  13599. // Check if the children have any pending work.
  13600. var childExpirationTime = workInProgress.childExpirationTime;
  13601. if (childExpirationTime < renderExpirationTime) {
  13602. // The children don't have any work either. We can skip them.
  13603. // TODO: Once we add back resuming, we should check if the children are
  13604. // a work-in-progress set. If so, we need to transfer their effects.
  13605. return null;
  13606. } else {
  13607. // This fiber doesn't have work, but its subtree does. Clone the child
  13608. // fibers and continue.
  13609. cloneChildFibers(current$$1, workInProgress);
  13610. return workInProgress.child;
  13611. }
  13612. }
  13613. function beginWork(current$$1, workInProgress, renderExpirationTime) {
  13614. var updateExpirationTime = workInProgress.expirationTime;
  13615. if (current$$1 !== null) {
  13616. var oldProps = current$$1.memoizedProps;
  13617. var newProps = workInProgress.pendingProps;
  13618. if (oldProps === newProps && !hasContextChanged() && updateExpirationTime < renderExpirationTime) {
  13619. // This fiber does not have any pending work. Bailout without entering
  13620. // the begin phase. There's still some bookkeeping we that needs to be done
  13621. // in this optimized path, mostly pushing stuff onto the stack.
  13622. switch (workInProgress.tag) {
  13623. case HostRoot:
  13624. pushHostRootContext(workInProgress);
  13625. resetHydrationState();
  13626. break;
  13627. case HostComponent:
  13628. pushHostContext(workInProgress);
  13629. break;
  13630. case ClassComponent:
  13631. {
  13632. var Component = workInProgress.type;
  13633. if (isContextProvider(Component)) {
  13634. pushContextProvider(workInProgress);
  13635. }
  13636. break;
  13637. }
  13638. case HostPortal:
  13639. pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
  13640. break;
  13641. case ContextProvider:
  13642. {
  13643. var newValue = workInProgress.memoizedProps.value;
  13644. pushProvider(workInProgress, newValue);
  13645. break;
  13646. }
  13647. case Profiler:
  13648. if (enableProfilerTimer) {
  13649. workInProgress.effectTag |= Update;
  13650. }
  13651. break;
  13652. case SuspenseComponent:
  13653. {
  13654. var state = workInProgress.memoizedState;
  13655. var didTimeout = state !== null;
  13656. if (didTimeout) {
  13657. // If this boundary is currently timed out, we need to decide
  13658. // whether to retry the primary children, or to skip over it and
  13659. // go straight to the fallback. Check the priority of the primary
  13660. var primaryChildFragment = workInProgress.child;
  13661. var primaryChildExpirationTime = primaryChildFragment.childExpirationTime;
  13662. if (primaryChildExpirationTime !== NoWork && primaryChildExpirationTime >= renderExpirationTime) {
  13663. // The primary children have pending work. Use the normal path
  13664. // to attempt to render the primary children again.
  13665. return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
  13666. } else {
  13667. // The primary children do not have pending work with sufficient
  13668. // priority. Bailout.
  13669. var child = bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  13670. if (child !== null) {
  13671. // The fallback children have pending work. Skip over the
  13672. // primary children and work on the fallback.
  13673. return child.sibling;
  13674. } else {
  13675. return null;
  13676. }
  13677. }
  13678. }
  13679. break;
  13680. }
  13681. }
  13682. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  13683. }
  13684. }
  13685. // Before entering the begin phase, clear the expiration time.
  13686. workInProgress.expirationTime = NoWork;
  13687. switch (workInProgress.tag) {
  13688. case IndeterminateComponent:
  13689. {
  13690. var elementType = workInProgress.elementType;
  13691. return mountIndeterminateComponent(current$$1, workInProgress, elementType, renderExpirationTime);
  13692. }
  13693. case LazyComponent:
  13694. {
  13695. var _elementType = workInProgress.elementType;
  13696. return mountLazyComponent(current$$1, workInProgress, _elementType, updateExpirationTime, renderExpirationTime);
  13697. }
  13698. case FunctionComponent:
  13699. {
  13700. var _Component = workInProgress.type;
  13701. var unresolvedProps = workInProgress.pendingProps;
  13702. var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps);
  13703. return updateFunctionComponent(current$$1, workInProgress, _Component, resolvedProps, renderExpirationTime);
  13704. }
  13705. case ClassComponent:
  13706. {
  13707. var _Component2 = workInProgress.type;
  13708. var _unresolvedProps = workInProgress.pendingProps;
  13709. var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps);
  13710. return updateClassComponent(current$$1, workInProgress, _Component2, _resolvedProps, renderExpirationTime);
  13711. }
  13712. case HostRoot:
  13713. return updateHostRoot(current$$1, workInProgress, renderExpirationTime);
  13714. case HostComponent:
  13715. return updateHostComponent(current$$1, workInProgress, renderExpirationTime);
  13716. case HostText:
  13717. return updateHostText(current$$1, workInProgress);
  13718. case SuspenseComponent:
  13719. return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
  13720. case HostPortal:
  13721. return updatePortalComponent(current$$1, workInProgress, renderExpirationTime);
  13722. case ForwardRef:
  13723. {
  13724. var type = workInProgress.type;
  13725. var _unresolvedProps2 = workInProgress.pendingProps;
  13726. var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
  13727. return updateForwardRef(current$$1, workInProgress, type, _resolvedProps2, renderExpirationTime);
  13728. }
  13729. case Fragment:
  13730. return updateFragment(current$$1, workInProgress, renderExpirationTime);
  13731. case Mode:
  13732. return updateMode(current$$1, workInProgress, renderExpirationTime);
  13733. case Profiler:
  13734. return updateProfiler(current$$1, workInProgress, renderExpirationTime);
  13735. case ContextProvider:
  13736. return updateContextProvider(current$$1, workInProgress, renderExpirationTime);
  13737. case ContextConsumer:
  13738. return updateContextConsumer(current$$1, workInProgress, renderExpirationTime);
  13739. case MemoComponent:
  13740. {
  13741. var _type = workInProgress.type;
  13742. var _unresolvedProps3 = workInProgress.pendingProps;
  13743. var _resolvedProps3 = resolveDefaultProps(_type.type, _unresolvedProps3);
  13744. return updateMemoComponent(current$$1, workInProgress, _type, _resolvedProps3, updateExpirationTime, renderExpirationTime);
  13745. }
  13746. case SimpleMemoComponent:
  13747. {
  13748. return updateSimpleMemoComponent(current$$1, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime);
  13749. }
  13750. case IncompleteClassComponent:
  13751. {
  13752. var _Component3 = workInProgress.type;
  13753. var _unresolvedProps4 = workInProgress.pendingProps;
  13754. var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
  13755. return mountIncompleteClassComponent(current$$1, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);
  13756. }
  13757. default:
  13758. invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
  13759. }
  13760. }
  13761. function markUpdate(workInProgress) {
  13762. // Tag the fiber with an update effect. This turns a Placement into
  13763. // a PlacementAndUpdate.
  13764. workInProgress.effectTag |= Update;
  13765. }
  13766. function markRef$1(workInProgress) {
  13767. workInProgress.effectTag |= Ref;
  13768. }
  13769. var appendAllChildren = void 0;
  13770. var updateHostContainer = void 0;
  13771. var updateHostComponent$1 = void 0;
  13772. var updateHostText$1 = void 0;
  13773. if (supportsMutation) {
  13774. // Mutation mode
  13775. appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
  13776. // We only have the top Fiber that was created but we need recurse down its
  13777. // children to find all the terminal nodes.
  13778. var node = workInProgress.child;
  13779. while (node !== null) {
  13780. if (node.tag === HostComponent || node.tag === HostText) {
  13781. appendInitialChild(parent, node.stateNode);
  13782. } else if (node.tag === HostPortal) {
  13783. // If we have a portal child, then we don't want to traverse
  13784. // down its children. Instead, we'll get insertions from each child in
  13785. // the portal directly.
  13786. } else if (node.child !== null) {
  13787. node.child.return = node;
  13788. node = node.child;
  13789. continue;
  13790. }
  13791. if (node === workInProgress) {
  13792. return;
  13793. }
  13794. while (node.sibling === null) {
  13795. if (node.return === null || node.return === workInProgress) {
  13796. return;
  13797. }
  13798. node = node.return;
  13799. }
  13800. node.sibling.return = node.return;
  13801. node = node.sibling;
  13802. }
  13803. };
  13804. updateHostContainer = function (workInProgress) {
  13805. // Noop
  13806. };
  13807. updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
  13808. // If we have an alternate, that means this is an update and we need to
  13809. // schedule a side-effect to do the updates.
  13810. var oldProps = current.memoizedProps;
  13811. if (oldProps === newProps) {
  13812. // In mutation mode, this is sufficient for a bailout because
  13813. // we won't touch this node even if children changed.
  13814. return;
  13815. }
  13816. // If we get updated because one of our children updated, we don't
  13817. // have newProps so we'll have to reuse them.
  13818. // TODO: Split the update API as separate for the props vs. children.
  13819. // Even better would be if children weren't special cased at all tho.
  13820. var instance = workInProgress.stateNode;
  13821. var currentHostContext = getHostContext();
  13822. // TODO: Experiencing an error where oldProps is null. Suggests a host
  13823. // component is hitting the resume path. Figure out why. Possibly
  13824. // related to `hidden`.
  13825. var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext);
  13826. // TODO: Type this specific to this type of component.
  13827. workInProgress.updateQueue = updatePayload;
  13828. // If the update payload indicates that there is a change or if there
  13829. // is a new ref we mark this as an update. All the work is done in commitWork.
  13830. if (updatePayload) {
  13831. markUpdate(workInProgress);
  13832. }
  13833. };
  13834. updateHostText$1 = function (current, workInProgress, oldText, newText) {
  13835. // If the text differs, mark it as an update. All the work in done in commitWork.
  13836. if (oldText !== newText) {
  13837. markUpdate(workInProgress);
  13838. }
  13839. };
  13840. } else if (supportsPersistence) {
  13841. // Persistent host tree mode
  13842. appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
  13843. // We only have the top Fiber that was created but we need recurse down its
  13844. // children to find all the terminal nodes.
  13845. var node = workInProgress.child;
  13846. while (node !== null) {
  13847. // eslint-disable-next-line no-labels
  13848. branches: if (node.tag === HostComponent) {
  13849. var instance = node.stateNode;
  13850. if (needsVisibilityToggle) {
  13851. var props = node.memoizedProps;
  13852. var type = node.type;
  13853. if (isHidden) {
  13854. // This child is inside a timed out tree. Hide it.
  13855. instance = cloneHiddenInstance(instance, type, props, node);
  13856. } else {
  13857. // This child was previously inside a timed out tree. If it was not
  13858. // updated during this render, it may need to be unhidden. Clone
  13859. // again to be sure.
  13860. instance = cloneUnhiddenInstance(instance, type, props, node);
  13861. }
  13862. node.stateNode = instance;
  13863. }
  13864. appendInitialChild(parent, instance);
  13865. } else if (node.tag === HostText) {
  13866. var _instance = node.stateNode;
  13867. if (needsVisibilityToggle) {
  13868. var text = node.memoizedProps;
  13869. var rootContainerInstance = getRootHostContainer();
  13870. var currentHostContext = getHostContext();
  13871. if (isHidden) {
  13872. _instance = createHiddenTextInstance(text, rootContainerInstance, currentHostContext, workInProgress);
  13873. } else {
  13874. _instance = createTextInstance(text, rootContainerInstance, currentHostContext, workInProgress);
  13875. }
  13876. node.stateNode = _instance;
  13877. }
  13878. appendInitialChild(parent, _instance);
  13879. } else if (node.tag === HostPortal) {
  13880. // If we have a portal child, then we don't want to traverse
  13881. // down its children. Instead, we'll get insertions from each child in
  13882. // the portal directly.
  13883. } else if (node.tag === SuspenseComponent) {
  13884. var current = node.alternate;
  13885. if (current !== null) {
  13886. var oldState = current.memoizedState;
  13887. var newState = node.memoizedState;
  13888. var oldIsHidden = oldState !== null;
  13889. var newIsHidden = newState !== null;
  13890. if (oldIsHidden !== newIsHidden) {
  13891. // The placeholder either just timed out or switched back to the normal
  13892. // children after having previously timed out. Toggle the visibility of
  13893. // the direct host children.
  13894. var primaryChildParent = newIsHidden ? node.child : node;
  13895. if (primaryChildParent !== null) {
  13896. appendAllChildren(parent, primaryChildParent, true, newIsHidden);
  13897. }
  13898. // eslint-disable-next-line no-labels
  13899. break branches;
  13900. }
  13901. }
  13902. if (node.child !== null) {
  13903. // Continue traversing like normal
  13904. node.child.return = node;
  13905. node = node.child;
  13906. continue;
  13907. }
  13908. } else if (node.child !== null) {
  13909. node.child.return = node;
  13910. node = node.child;
  13911. continue;
  13912. }
  13913. // $FlowFixMe This is correct but Flow is confused by the labeled break.
  13914. node = node;
  13915. if (node === workInProgress) {
  13916. return;
  13917. }
  13918. while (node.sibling === null) {
  13919. if (node.return === null || node.return === workInProgress) {
  13920. return;
  13921. }
  13922. node = node.return;
  13923. }
  13924. node.sibling.return = node.return;
  13925. node = node.sibling;
  13926. }
  13927. };
  13928. // An unfortunate fork of appendAllChildren because we have two different parent types.
  13929. var appendAllChildrenToContainer = function (containerChildSet, workInProgress, needsVisibilityToggle, isHidden) {
  13930. // We only have the top Fiber that was created but we need recurse down its
  13931. // children to find all the terminal nodes.
  13932. var node = workInProgress.child;
  13933. while (node !== null) {
  13934. // eslint-disable-next-line no-labels
  13935. branches: if (node.tag === HostComponent) {
  13936. var instance = node.stateNode;
  13937. if (needsVisibilityToggle) {
  13938. var props = node.memoizedProps;
  13939. var type = node.type;
  13940. if (isHidden) {
  13941. // This child is inside a timed out tree. Hide it.
  13942. instance = cloneHiddenInstance(instance, type, props, node);
  13943. } else {
  13944. // This child was previously inside a timed out tree. If it was not
  13945. // updated during this render, it may need to be unhidden. Clone
  13946. // again to be sure.
  13947. instance = cloneUnhiddenInstance(instance, type, props, node);
  13948. }
  13949. node.stateNode = instance;
  13950. }
  13951. appendChildToContainerChildSet(containerChildSet, instance);
  13952. } else if (node.tag === HostText) {
  13953. var _instance2 = node.stateNode;
  13954. if (needsVisibilityToggle) {
  13955. var text = node.memoizedProps;
  13956. var rootContainerInstance = getRootHostContainer();
  13957. var currentHostContext = getHostContext();
  13958. if (isHidden) {
  13959. _instance2 = createHiddenTextInstance(text, rootContainerInstance, currentHostContext, workInProgress);
  13960. } else {
  13961. _instance2 = createTextInstance(text, rootContainerInstance, currentHostContext, workInProgress);
  13962. }
  13963. node.stateNode = _instance2;
  13964. }
  13965. appendChildToContainerChildSet(containerChildSet, _instance2);
  13966. } else if (node.tag === HostPortal) {
  13967. // If we have a portal child, then we don't want to traverse
  13968. // down its children. Instead, we'll get insertions from each child in
  13969. // the portal directly.
  13970. } else if (node.tag === SuspenseComponent) {
  13971. var current = node.alternate;
  13972. if (current !== null) {
  13973. var oldState = current.memoizedState;
  13974. var newState = node.memoizedState;
  13975. var oldIsHidden = oldState !== null;
  13976. var newIsHidden = newState !== null;
  13977. if (oldIsHidden !== newIsHidden) {
  13978. // The placeholder either just timed out or switched back to the normal
  13979. // children after having previously timed out. Toggle the visibility of
  13980. // the direct host children.
  13981. var primaryChildParent = newIsHidden ? node.child : node;
  13982. if (primaryChildParent !== null) {
  13983. appendAllChildrenToContainer(containerChildSet, primaryChildParent, true, newIsHidden);
  13984. }
  13985. // eslint-disable-next-line no-labels
  13986. break branches;
  13987. }
  13988. }
  13989. if (node.child !== null) {
  13990. // Continue traversing like normal
  13991. node.child.return = node;
  13992. node = node.child;
  13993. continue;
  13994. }
  13995. } else if (node.child !== null) {
  13996. node.child.return = node;
  13997. node = node.child;
  13998. continue;
  13999. }
  14000. // $FlowFixMe This is correct but Flow is confused by the labeled break.
  14001. node = node;
  14002. if (node === workInProgress) {
  14003. return;
  14004. }
  14005. while (node.sibling === null) {
  14006. if (node.return === null || node.return === workInProgress) {
  14007. return;
  14008. }
  14009. node = node.return;
  14010. }
  14011. node.sibling.return = node.return;
  14012. node = node.sibling;
  14013. }
  14014. };
  14015. updateHostContainer = function (workInProgress) {
  14016. var portalOrRoot = workInProgress.stateNode;
  14017. var childrenUnchanged = workInProgress.firstEffect === null;
  14018. if (childrenUnchanged) {
  14019. // No changes, just reuse the existing instance.
  14020. } else {
  14021. var container = portalOrRoot.containerInfo;
  14022. var newChildSet = createContainerChildSet(container);
  14023. // If children might have changed, we have to add them all to the set.
  14024. appendAllChildrenToContainer(newChildSet, workInProgress, false, false);
  14025. portalOrRoot.pendingChildren = newChildSet;
  14026. // Schedule an update on the container to swap out the container.
  14027. markUpdate(workInProgress);
  14028. finalizeContainerChildren(container, newChildSet);
  14029. }
  14030. };
  14031. updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
  14032. var currentInstance = current.stateNode;
  14033. var oldProps = current.memoizedProps;
  14034. // If there are no effects associated with this node, then none of our children had any updates.
  14035. // This guarantees that we can reuse all of them.
  14036. var childrenUnchanged = workInProgress.firstEffect === null;
  14037. if (childrenUnchanged && oldProps === newProps) {
  14038. // No changes, just reuse the existing instance.
  14039. // Note that this might release a previous clone.
  14040. workInProgress.stateNode = currentInstance;
  14041. return;
  14042. }
  14043. var recyclableInstance = workInProgress.stateNode;
  14044. var currentHostContext = getHostContext();
  14045. var updatePayload = null;
  14046. if (oldProps !== newProps) {
  14047. updatePayload = prepareUpdate(recyclableInstance, type, oldProps, newProps, rootContainerInstance, currentHostContext);
  14048. }
  14049. if (childrenUnchanged && updatePayload === null) {
  14050. // No changes, just reuse the existing instance.
  14051. // Note that this might release a previous clone.
  14052. workInProgress.stateNode = currentInstance;
  14053. return;
  14054. }
  14055. var newInstance = cloneInstance(currentInstance, updatePayload, type, oldProps, newProps, workInProgress, childrenUnchanged, recyclableInstance);
  14056. if (finalizeInitialChildren(newInstance, type, newProps, rootContainerInstance, currentHostContext)) {
  14057. markUpdate(workInProgress);
  14058. }
  14059. workInProgress.stateNode = newInstance;
  14060. if (childrenUnchanged) {
  14061. // If there are no other effects in this tree, we need to flag this node as having one.
  14062. // Even though we're not going to use it for anything.
  14063. // Otherwise parents won't know that there are new children to propagate upwards.
  14064. markUpdate(workInProgress);
  14065. } else {
  14066. // If children might have changed, we have to add them all to the set.
  14067. appendAllChildren(newInstance, workInProgress, false, false);
  14068. }
  14069. };
  14070. updateHostText$1 = function (current, workInProgress, oldText, newText) {
  14071. if (oldText !== newText) {
  14072. // If the text content differs, we'll create a new text instance for it.
  14073. var rootContainerInstance = getRootHostContainer();
  14074. var currentHostContext = getHostContext();
  14075. workInProgress.stateNode = createTextInstance(newText, rootContainerInstance, currentHostContext, workInProgress);
  14076. // We'll have to mark it as having an effect, even though we won't use the effect for anything.
  14077. // This lets the parents know that at least one of their children has changed.
  14078. markUpdate(workInProgress);
  14079. }
  14080. };
  14081. } else {
  14082. // No host operations
  14083. updateHostContainer = function (workInProgress) {
  14084. // Noop
  14085. };
  14086. updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
  14087. // Noop
  14088. };
  14089. updateHostText$1 = function (current, workInProgress, oldText, newText) {
  14090. // Noop
  14091. };
  14092. }
  14093. function completeWork(current, workInProgress, renderExpirationTime) {
  14094. var newProps = workInProgress.pendingProps;
  14095. switch (workInProgress.tag) {
  14096. case IndeterminateComponent:
  14097. break;
  14098. case LazyComponent:
  14099. break;
  14100. case SimpleMemoComponent:
  14101. case FunctionComponent:
  14102. break;
  14103. case ClassComponent:
  14104. {
  14105. var Component = workInProgress.type;
  14106. if (isContextProvider(Component)) {
  14107. popContext(workInProgress);
  14108. }
  14109. break;
  14110. }
  14111. case HostRoot:
  14112. {
  14113. popHostContainer(workInProgress);
  14114. popTopLevelContextObject(workInProgress);
  14115. var fiberRoot = workInProgress.stateNode;
  14116. if (fiberRoot.pendingContext) {
  14117. fiberRoot.context = fiberRoot.pendingContext;
  14118. fiberRoot.pendingContext = null;
  14119. }
  14120. if (current === null || current.child === null) {
  14121. // If we hydrated, pop so that we can delete any remaining children
  14122. // that weren't hydrated.
  14123. popHydrationState(workInProgress);
  14124. // This resets the hacky state to fix isMounted before committing.
  14125. // TODO: Delete this when we delete isMounted and findDOMNode.
  14126. workInProgress.effectTag &= ~Placement;
  14127. }
  14128. updateHostContainer(workInProgress);
  14129. break;
  14130. }
  14131. case HostComponent:
  14132. {
  14133. popHostContext(workInProgress);
  14134. var rootContainerInstance = getRootHostContainer();
  14135. var type = workInProgress.type;
  14136. if (current !== null && workInProgress.stateNode != null) {
  14137. updateHostComponent$1(current, workInProgress, type, newProps, rootContainerInstance);
  14138. if (current.ref !== workInProgress.ref) {
  14139. markRef$1(workInProgress);
  14140. }
  14141. } else {
  14142. if (!newProps) {
  14143. !(workInProgress.stateNode !== null) ? invariant(false, 'We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  14144. // This can happen when we abort work.
  14145. break;
  14146. }
  14147. var currentHostContext = getHostContext();
  14148. // TODO: Move createInstance to beginWork and keep it on a context
  14149. // "stack" as the parent. Then append children as we go in beginWork
  14150. // or completeWork depending on we want to add then top->down or
  14151. // bottom->up. Top->down is faster in IE11.
  14152. var wasHydrated = popHydrationState(workInProgress);
  14153. if (wasHydrated) {
  14154. // TODO: Move this and createInstance step into the beginPhase
  14155. // to consolidate.
  14156. if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, currentHostContext)) {
  14157. // If changes to the hydrated node needs to be applied at the
  14158. // commit-phase we mark this as such.
  14159. markUpdate(workInProgress);
  14160. }
  14161. } else {
  14162. var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress);
  14163. appendAllChildren(instance, workInProgress, false, false);
  14164. // Certain renderers require commit-time effects for initial mount.
  14165. // (eg DOM renderer supports auto-focus for certain elements).
  14166. // Make sure such renderers get scheduled for later work.
  14167. if (finalizeInitialChildren(instance, type, newProps, rootContainerInstance, currentHostContext)) {
  14168. markUpdate(workInProgress);
  14169. }
  14170. workInProgress.stateNode = instance;
  14171. }
  14172. if (workInProgress.ref !== null) {
  14173. // If there is a ref on a host node we need to schedule a callback
  14174. markRef$1(workInProgress);
  14175. }
  14176. }
  14177. break;
  14178. }
  14179. case HostText:
  14180. {
  14181. var newText = newProps;
  14182. if (current && workInProgress.stateNode != null) {
  14183. var oldText = current.memoizedProps;
  14184. // If we have an alternate, that means this is an update and we need
  14185. // to schedule a side-effect to do the updates.
  14186. updateHostText$1(current, workInProgress, oldText, newText);
  14187. } else {
  14188. if (typeof newText !== 'string') {
  14189. !(workInProgress.stateNode !== null) ? invariant(false, 'We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  14190. // This can happen when we abort work.
  14191. }
  14192. var _rootContainerInstance = getRootHostContainer();
  14193. var _currentHostContext = getHostContext();
  14194. var _wasHydrated = popHydrationState(workInProgress);
  14195. if (_wasHydrated) {
  14196. if (prepareToHydrateHostTextInstance(workInProgress)) {
  14197. markUpdate(workInProgress);
  14198. }
  14199. } else {
  14200. workInProgress.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext, workInProgress);
  14201. }
  14202. }
  14203. break;
  14204. }
  14205. case ForwardRef:
  14206. break;
  14207. case SuspenseComponent:
  14208. {
  14209. var nextState = workInProgress.memoizedState;
  14210. if ((workInProgress.effectTag & DidCapture) !== NoEffect) {
  14211. // Something suspended. Re-render with the fallback children.
  14212. workInProgress.expirationTime = renderExpirationTime;
  14213. // Do not reset the effect list.
  14214. return workInProgress;
  14215. }
  14216. var nextDidTimeout = nextState !== null;
  14217. var prevDidTimeout = current !== null && current.memoizedState !== null;
  14218. if (current !== null && !nextDidTimeout && prevDidTimeout) {
  14219. // We just switched from the fallback to the normal children. Delete
  14220. // the fallback.
  14221. // TODO: Would it be better to store the fallback fragment on
  14222. var currentFallbackChild = current.child.sibling;
  14223. if (currentFallbackChild !== null) {
  14224. // Deletions go at the beginning of the return fiber's effect list
  14225. var first = workInProgress.firstEffect;
  14226. if (first !== null) {
  14227. workInProgress.firstEffect = currentFallbackChild;
  14228. currentFallbackChild.nextEffect = first;
  14229. } else {
  14230. workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild;
  14231. currentFallbackChild.nextEffect = null;
  14232. }
  14233. currentFallbackChild.effectTag = Deletion;
  14234. }
  14235. }
  14236. // The children either timed out after previously being visible, or
  14237. // were restored after previously being hidden. Schedule an effect
  14238. // to update their visiblity.
  14239. if (
  14240. //
  14241. nextDidTimeout !== prevDidTimeout ||
  14242. // Outside concurrent mode, the primary children commit in an
  14243. // inconsistent state, even if they are hidden. So if they are hidden,
  14244. // we need to schedule an effect to re-hide them, just in case.
  14245. (workInProgress.effectTag & ConcurrentMode) === NoContext && nextDidTimeout) {
  14246. workInProgress.effectTag |= Update;
  14247. }
  14248. break;
  14249. }
  14250. case Fragment:
  14251. break;
  14252. case Mode:
  14253. break;
  14254. case Profiler:
  14255. break;
  14256. case HostPortal:
  14257. popHostContainer(workInProgress);
  14258. updateHostContainer(workInProgress);
  14259. break;
  14260. case ContextProvider:
  14261. // Pop provider fiber
  14262. popProvider(workInProgress);
  14263. break;
  14264. case ContextConsumer:
  14265. break;
  14266. case MemoComponent:
  14267. break;
  14268. case IncompleteClassComponent:
  14269. {
  14270. // Same as class component case. I put it down here so that the tags are
  14271. // sequential to ensure this switch is compiled to a jump table.
  14272. var _Component = workInProgress.type;
  14273. if (isContextProvider(_Component)) {
  14274. popContext(workInProgress);
  14275. }
  14276. break;
  14277. }
  14278. default:
  14279. invariant(false, 'Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.');
  14280. }
  14281. return null;
  14282. }
  14283. function shouldCaptureSuspense(current, workInProgress) {
  14284. // In order to capture, the Suspense component must have a fallback prop.
  14285. if (workInProgress.memoizedProps.fallback === undefined) {
  14286. return false;
  14287. }
  14288. // If it was the primary children that just suspended, capture and render the
  14289. // fallback. Otherwise, don't capture and bubble to the next boundary.
  14290. var nextState = workInProgress.memoizedState;
  14291. return nextState === null;
  14292. }
  14293. // This module is forked in different environments.
  14294. // By default, return `true` to log errors to the console.
  14295. // Forks can return `false` if this isn't desirable.
  14296. function showErrorDialog(capturedError) {
  14297. return true;
  14298. }
  14299. function logCapturedError(capturedError) {
  14300. var logError = showErrorDialog(capturedError);
  14301. // Allow injected showErrorDialog() to prevent default console.error logging.
  14302. // This enables renderers like ReactNative to better manage redbox behavior.
  14303. if (logError === false) {
  14304. return;
  14305. }
  14306. var error = capturedError.error;
  14307. {
  14308. var componentName = capturedError.componentName,
  14309. componentStack = capturedError.componentStack,
  14310. errorBoundaryName = capturedError.errorBoundaryName,
  14311. errorBoundaryFound = capturedError.errorBoundaryFound,
  14312. willRetry = capturedError.willRetry;
  14313. // Browsers support silencing uncaught errors by calling
  14314. // `preventDefault()` in window `error` handler.
  14315. // We record this information as an expando on the error.
  14316. if (error != null && error._suppressLogging) {
  14317. if (errorBoundaryFound && willRetry) {
  14318. // The error is recoverable and was silenced.
  14319. // Ignore it and don't print the stack addendum.
  14320. // This is handy for testing error boundaries without noise.
  14321. return;
  14322. }
  14323. // The error is fatal. Since the silencing might have
  14324. // been accidental, we'll surface it anyway.
  14325. // However, the browser would have silenced the original error
  14326. // so we'll print it first, and then print the stack addendum.
  14327. console.error(error);
  14328. // For a more detailed description of this block, see:
  14329. // https://github.com/facebook/react/pull/13384
  14330. }
  14331. var componentNameMessage = componentName ? 'The above error occurred in the <' + componentName + '> component:' : 'The above error occurred in one of your React components:';
  14332. var errorBoundaryMessage = void 0;
  14333. // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow.
  14334. if (errorBoundaryFound && errorBoundaryName) {
  14335. if (willRetry) {
  14336. errorBoundaryMessage = 'React will try to recreate this component tree from scratch ' + ('using the error boundary you provided, ' + errorBoundaryName + '.');
  14337. } else {
  14338. errorBoundaryMessage = 'This error was initially handled by the error boundary ' + errorBoundaryName + '.\n' + 'Recreating the tree from scratch failed so React will unmount the tree.';
  14339. }
  14340. } else {
  14341. 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.';
  14342. }
  14343. var combinedMessage = '' + componentNameMessage + componentStack + '\n\n' + ('' + errorBoundaryMessage);
  14344. // In development, we provide our own message with just the component stack.
  14345. // We don't include the original error message and JS stack because the browser
  14346. // has already printed it. Even if the application swallows the error, it is still
  14347. // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils.
  14348. console.error(combinedMessage);
  14349. }
  14350. }
  14351. var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
  14352. {
  14353. didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
  14354. }
  14355. function logError(boundary, errorInfo) {
  14356. var source = errorInfo.source;
  14357. var stack = errorInfo.stack;
  14358. if (stack === null && source !== null) {
  14359. stack = getStackByFiberInDevAndProd(source);
  14360. }
  14361. var capturedError = {
  14362. componentName: source !== null ? getComponentName(source.type) : null,
  14363. componentStack: stack !== null ? stack : '',
  14364. error: errorInfo.value,
  14365. errorBoundary: null,
  14366. errorBoundaryName: null,
  14367. errorBoundaryFound: false,
  14368. willRetry: false
  14369. };
  14370. if (boundary !== null && boundary.tag === ClassComponent) {
  14371. capturedError.errorBoundary = boundary.stateNode;
  14372. capturedError.errorBoundaryName = getComponentName(boundary.type);
  14373. capturedError.errorBoundaryFound = true;
  14374. capturedError.willRetry = true;
  14375. }
  14376. try {
  14377. logCapturedError(capturedError);
  14378. } catch (e) {
  14379. // This method must not throw, or React internal state will get messed up.
  14380. // If console.error is overridden, or logCapturedError() shows a dialog that throws,
  14381. // we want to report this error outside of the normal stack as a last resort.
  14382. // https://github.com/facebook/react/issues/13188
  14383. setTimeout(function () {
  14384. throw e;
  14385. });
  14386. }
  14387. }
  14388. var callComponentWillUnmountWithTimer = function (current$$1, instance) {
  14389. startPhaseTimer(current$$1, 'componentWillUnmount');
  14390. instance.props = current$$1.memoizedProps;
  14391. instance.state = current$$1.memoizedState;
  14392. instance.componentWillUnmount();
  14393. stopPhaseTimer();
  14394. };
  14395. // Capture errors so they don't interrupt unmounting.
  14396. function safelyCallComponentWillUnmount(current$$1, instance) {
  14397. {
  14398. invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current$$1, instance);
  14399. if (hasCaughtError()) {
  14400. var unmountError = clearCaughtError();
  14401. captureCommitPhaseError(current$$1, unmountError);
  14402. }
  14403. }
  14404. }
  14405. function safelyDetachRef(current$$1) {
  14406. var ref = current$$1.ref;
  14407. if (ref !== null) {
  14408. if (typeof ref === 'function') {
  14409. {
  14410. invokeGuardedCallback(null, ref, null, null);
  14411. if (hasCaughtError()) {
  14412. var refError = clearCaughtError();
  14413. captureCommitPhaseError(current$$1, refError);
  14414. }
  14415. }
  14416. } else {
  14417. ref.current = null;
  14418. }
  14419. }
  14420. }
  14421. function safelyCallDestroy(current$$1, destroy) {
  14422. {
  14423. invokeGuardedCallback(null, destroy, null);
  14424. if (hasCaughtError()) {
  14425. var error = clearCaughtError();
  14426. captureCommitPhaseError(current$$1, error);
  14427. }
  14428. }
  14429. }
  14430. function commitBeforeMutationLifeCycles(current$$1, finishedWork) {
  14431. switch (finishedWork.tag) {
  14432. case FunctionComponent:
  14433. case ForwardRef:
  14434. case SimpleMemoComponent:
  14435. {
  14436. commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork);
  14437. return;
  14438. }
  14439. case ClassComponent:
  14440. {
  14441. if (finishedWork.effectTag & Snapshot) {
  14442. if (current$$1 !== null) {
  14443. var prevProps = current$$1.memoizedProps;
  14444. var prevState = current$$1.memoizedState;
  14445. startPhaseTimer(finishedWork, 'getSnapshotBeforeUpdate');
  14446. var instance = finishedWork.stateNode;
  14447. // We could update instance props and state here,
  14448. // but instead we rely on them being set during last render.
  14449. // TODO: revisit this when we implement resuming.
  14450. {
  14451. if (finishedWork.type === finishedWork.elementType) {
  14452. !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected instance props to match memoized props before ' + 'getSnapshotBeforeUpdate. This is likely due to a bug in React. ' + 'Please file an issue.') : void 0;
  14453. !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected instance state to match memoized state before ' + 'getSnapshotBeforeUpdate. This is likely due to a bug in React. ' + 'Please file an issue.') : void 0;
  14454. }
  14455. }
  14456. var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState);
  14457. {
  14458. var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate;
  14459. if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
  14460. didWarnSet.add(finishedWork.type);
  14461. warningWithoutStack$1(false, '%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork.type));
  14462. }
  14463. }
  14464. instance.__reactInternalSnapshotBeforeUpdate = snapshot;
  14465. stopPhaseTimer();
  14466. }
  14467. }
  14468. return;
  14469. }
  14470. case HostRoot:
  14471. case HostComponent:
  14472. case HostText:
  14473. case HostPortal:
  14474. case IncompleteClassComponent:
  14475. // Nothing to do for these component types
  14476. return;
  14477. default:
  14478. {
  14479. invariant(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.');
  14480. }
  14481. }
  14482. }
  14483. function commitHookEffectList(unmountTag, mountTag, finishedWork) {
  14484. if (!enableHooks) {
  14485. return;
  14486. }
  14487. var updateQueue = finishedWork.updateQueue;
  14488. var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
  14489. if (lastEffect !== null) {
  14490. var firstEffect = lastEffect.next;
  14491. var effect = firstEffect;
  14492. do {
  14493. if ((effect.tag & unmountTag) !== NoEffect$1) {
  14494. // Unmount
  14495. var destroy = effect.destroy;
  14496. effect.destroy = null;
  14497. if (destroy !== null) {
  14498. destroy();
  14499. }
  14500. }
  14501. if ((effect.tag & mountTag) !== NoEffect$1) {
  14502. // Mount
  14503. var create = effect.create;
  14504. var _destroy = create();
  14505. if (typeof _destroy !== 'function') {
  14506. {
  14507. if (_destroy !== null && _destroy !== undefined) {
  14508. warningWithoutStack$1(false, 'useEffect function must return a cleanup function or ' + 'nothing.%s%s', typeof _destroy.then === 'function' ? ' Promises and useEffect(async () => ...) are not ' + 'supported, but you can call an async function inside an ' + 'effect.' : '', getStackByFiberInDevAndProd(finishedWork));
  14509. }
  14510. }
  14511. _destroy = null;
  14512. }
  14513. effect.destroy = _destroy;
  14514. }
  14515. effect = effect.next;
  14516. } while (effect !== firstEffect);
  14517. }
  14518. }
  14519. function commitPassiveHookEffects(finishedWork) {
  14520. commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork);
  14521. commitHookEffectList(NoEffect$1, MountPassive, finishedWork);
  14522. }
  14523. function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpirationTime) {
  14524. switch (finishedWork.tag) {
  14525. case FunctionComponent:
  14526. case ForwardRef:
  14527. case SimpleMemoComponent:
  14528. {
  14529. commitHookEffectList(UnmountLayout, MountLayout, finishedWork);
  14530. break;
  14531. }
  14532. case ClassComponent:
  14533. {
  14534. var instance = finishedWork.stateNode;
  14535. if (finishedWork.effectTag & Update) {
  14536. if (current$$1 === null) {
  14537. startPhaseTimer(finishedWork, 'componentDidMount');
  14538. // We could update instance props and state here,
  14539. // but instead we rely on them being set during last render.
  14540. // TODO: revisit this when we implement resuming.
  14541. {
  14542. if (finishedWork.type === finishedWork.elementType) {
  14543. !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected instance props to match memoized props before ' + 'componentDidMount. This is likely due to a bug in React. ' + 'Please file an issue.') : void 0;
  14544. !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected instance state to match memoized state before ' + 'componentDidMount. This is likely due to a bug in React. ' + 'Please file an issue.') : void 0;
  14545. }
  14546. }
  14547. instance.componentDidMount();
  14548. stopPhaseTimer();
  14549. } else {
  14550. var prevProps = finishedWork.elementType === finishedWork.type ? current$$1.memoizedProps : resolveDefaultProps(finishedWork.type, current$$1.memoizedProps);
  14551. var prevState = current$$1.memoizedState;
  14552. startPhaseTimer(finishedWork, 'componentDidUpdate');
  14553. // We could update instance props and state here,
  14554. // but instead we rely on them being set during last render.
  14555. // TODO: revisit this when we implement resuming.
  14556. {
  14557. if (finishedWork.type === finishedWork.elementType) {
  14558. !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected instance props to match memoized props before ' + 'componentDidUpdate. This is likely due to a bug in React. ' + 'Please file an issue.') : void 0;
  14559. !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected instance state to match memoized state before ' + 'componentDidUpdate. This is likely due to a bug in React. ' + 'Please file an issue.') : void 0;
  14560. }
  14561. }
  14562. instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate);
  14563. stopPhaseTimer();
  14564. }
  14565. }
  14566. var updateQueue = finishedWork.updateQueue;
  14567. if (updateQueue !== null) {
  14568. {
  14569. if (finishedWork.type === finishedWork.elementType) {
  14570. !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected instance props to match memoized props before ' + 'processing the update queue. This is likely due to a bug in React. ' + 'Please file an issue.') : void 0;
  14571. !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected instance state to match memoized state before ' + 'processing the update queue. This is likely due to a bug in React. ' + 'Please file an issue.') : void 0;
  14572. }
  14573. }
  14574. // We could update instance props and state here,
  14575. // but instead we rely on them being set during last render.
  14576. // TODO: revisit this when we implement resuming.
  14577. commitUpdateQueue(finishedWork, updateQueue, instance, committedExpirationTime);
  14578. }
  14579. return;
  14580. }
  14581. case HostRoot:
  14582. {
  14583. var _updateQueue = finishedWork.updateQueue;
  14584. if (_updateQueue !== null) {
  14585. var _instance = null;
  14586. if (finishedWork.child !== null) {
  14587. switch (finishedWork.child.tag) {
  14588. case HostComponent:
  14589. _instance = getPublicInstance(finishedWork.child.stateNode);
  14590. break;
  14591. case ClassComponent:
  14592. _instance = finishedWork.child.stateNode;
  14593. break;
  14594. }
  14595. }
  14596. commitUpdateQueue(finishedWork, _updateQueue, _instance, committedExpirationTime);
  14597. }
  14598. return;
  14599. }
  14600. case HostComponent:
  14601. {
  14602. var _instance2 = finishedWork.stateNode;
  14603. // Renderers may schedule work to be done after host components are mounted
  14604. // (eg DOM renderer may schedule auto-focus for inputs and form controls).
  14605. // These effects should only be committed when components are first mounted,
  14606. // aka when there is no current/alternate.
  14607. if (current$$1 === null && finishedWork.effectTag & Update) {
  14608. var type = finishedWork.type;
  14609. var props = finishedWork.memoizedProps;
  14610. commitMount(_instance2, type, props, finishedWork);
  14611. }
  14612. return;
  14613. }
  14614. case HostText:
  14615. {
  14616. // We have no life-cycles associated with text.
  14617. return;
  14618. }
  14619. case HostPortal:
  14620. {
  14621. // We have no life-cycles associated with portals.
  14622. return;
  14623. }
  14624. case Profiler:
  14625. {
  14626. if (enableProfilerTimer) {
  14627. var onRender = finishedWork.memoizedProps.onRender;
  14628. if (enableSchedulerTracing) {
  14629. onRender(finishedWork.memoizedProps.id, current$$1 === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime(), finishedRoot.memoizedInteractions);
  14630. } else {
  14631. onRender(finishedWork.memoizedProps.id, current$$1 === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime());
  14632. }
  14633. }
  14634. return;
  14635. }
  14636. case SuspenseComponent:
  14637. break;
  14638. case IncompleteClassComponent:
  14639. break;
  14640. default:
  14641. {
  14642. invariant(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.');
  14643. }
  14644. }
  14645. }
  14646. function hideOrUnhideAllChildren(finishedWork, isHidden) {
  14647. if (supportsMutation) {
  14648. // We only have the top Fiber that was inserted but we need recurse down its
  14649. var node = finishedWork;
  14650. while (true) {
  14651. if (node.tag === HostComponent) {
  14652. var instance = node.stateNode;
  14653. if (isHidden) {
  14654. hideInstance(instance);
  14655. } else {
  14656. unhideInstance(node.stateNode, node.memoizedProps);
  14657. }
  14658. } else if (node.tag === HostText) {
  14659. var _instance3 = node.stateNode;
  14660. if (isHidden) {
  14661. hideTextInstance(_instance3);
  14662. } else {
  14663. unhideTextInstance(_instance3, node.memoizedProps);
  14664. }
  14665. } else if (node.tag === SuspenseComponent && node.memoizedState !== null) {
  14666. // Found a nested Suspense component that timed out. Skip over the
  14667. var fallbackChildFragment = node.child.sibling;
  14668. fallbackChildFragment.return = node;
  14669. node = fallbackChildFragment;
  14670. continue;
  14671. } else if (node.child !== null) {
  14672. node.child.return = node;
  14673. node = node.child;
  14674. continue;
  14675. }
  14676. if (node === finishedWork) {
  14677. return;
  14678. }
  14679. while (node.sibling === null) {
  14680. if (node.return === null || node.return === finishedWork) {
  14681. return;
  14682. }
  14683. node = node.return;
  14684. }
  14685. node.sibling.return = node.return;
  14686. node = node.sibling;
  14687. }
  14688. }
  14689. }
  14690. function commitAttachRef(finishedWork) {
  14691. var ref = finishedWork.ref;
  14692. if (ref !== null) {
  14693. var instance = finishedWork.stateNode;
  14694. var instanceToUse = void 0;
  14695. switch (finishedWork.tag) {
  14696. case HostComponent:
  14697. instanceToUse = getPublicInstance(instance);
  14698. break;
  14699. default:
  14700. instanceToUse = instance;
  14701. }
  14702. if (typeof ref === 'function') {
  14703. ref(instanceToUse);
  14704. } else {
  14705. {
  14706. if (!ref.hasOwnProperty('current')) {
  14707. warningWithoutStack$1(false, 'Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().%s', getComponentName(finishedWork.type), getStackByFiberInDevAndProd(finishedWork));
  14708. }
  14709. }
  14710. ref.current = instanceToUse;
  14711. }
  14712. }
  14713. }
  14714. function commitDetachRef(current$$1) {
  14715. var currentRef = current$$1.ref;
  14716. if (currentRef !== null) {
  14717. if (typeof currentRef === 'function') {
  14718. currentRef(null);
  14719. } else {
  14720. currentRef.current = null;
  14721. }
  14722. }
  14723. }
  14724. // User-originating errors (lifecycles and refs) should not interrupt
  14725. // deletion, so don't let them throw. Host-originating errors should
  14726. // interrupt deletion, so it's okay
  14727. function commitUnmount(current$$1) {
  14728. onCommitUnmount(current$$1);
  14729. switch (current$$1.tag) {
  14730. case FunctionComponent:
  14731. case ForwardRef:
  14732. case MemoComponent:
  14733. case SimpleMemoComponent:
  14734. {
  14735. var updateQueue = current$$1.updateQueue;
  14736. if (updateQueue !== null) {
  14737. var lastEffect = updateQueue.lastEffect;
  14738. if (lastEffect !== null) {
  14739. var firstEffect = lastEffect.next;
  14740. var effect = firstEffect;
  14741. do {
  14742. var destroy = effect.destroy;
  14743. if (destroy !== null) {
  14744. safelyCallDestroy(current$$1, destroy);
  14745. }
  14746. effect = effect.next;
  14747. } while (effect !== firstEffect);
  14748. }
  14749. }
  14750. break;
  14751. }
  14752. case ClassComponent:
  14753. {
  14754. safelyDetachRef(current$$1);
  14755. var instance = current$$1.stateNode;
  14756. if (typeof instance.componentWillUnmount === 'function') {
  14757. safelyCallComponentWillUnmount(current$$1, instance);
  14758. }
  14759. return;
  14760. }
  14761. case HostComponent:
  14762. {
  14763. safelyDetachRef(current$$1);
  14764. return;
  14765. }
  14766. case HostPortal:
  14767. {
  14768. // TODO: this is recursive.
  14769. // We are also not using this parent because
  14770. // the portal will get pushed immediately.
  14771. if (supportsMutation) {
  14772. unmountHostComponents(current$$1);
  14773. } else if (supportsPersistence) {
  14774. emptyPortalContainer(current$$1);
  14775. }
  14776. return;
  14777. }
  14778. }
  14779. }
  14780. function commitNestedUnmounts(root) {
  14781. // While we're inside a removed host node we don't want to call
  14782. // removeChild on the inner nodes because they're removed by the top
  14783. // call anyway. We also want to call componentWillUnmount on all
  14784. // composites before this host node is removed from the tree. Therefore
  14785. var node = root;
  14786. while (true) {
  14787. commitUnmount(node);
  14788. // Visit children because they may contain more composite or host nodes.
  14789. // Skip portals because commitUnmount() currently visits them recursively.
  14790. if (node.child !== null && (
  14791. // If we use mutation we drill down into portals using commitUnmount above.
  14792. // If we don't use mutation we drill down into portals here instead.
  14793. !supportsMutation || node.tag !== HostPortal)) {
  14794. node.child.return = node;
  14795. node = node.child;
  14796. continue;
  14797. }
  14798. if (node === root) {
  14799. return;
  14800. }
  14801. while (node.sibling === null) {
  14802. if (node.return === null || node.return === root) {
  14803. return;
  14804. }
  14805. node = node.return;
  14806. }
  14807. node.sibling.return = node.return;
  14808. node = node.sibling;
  14809. }
  14810. }
  14811. function detachFiber(current$$1) {
  14812. // Cut off the return pointers to disconnect it from the tree. Ideally, we
  14813. // should clear the child pointer of the parent alternate to let this
  14814. // get GC:ed but we don't know which for sure which parent is the current
  14815. // one so we'll settle for GC:ing the subtree of this child. This child
  14816. // itself will be GC:ed when the parent updates the next time.
  14817. current$$1.return = null;
  14818. current$$1.child = null;
  14819. if (current$$1.alternate) {
  14820. current$$1.alternate.child = null;
  14821. current$$1.alternate.return = null;
  14822. }
  14823. }
  14824. function emptyPortalContainer(current$$1) {
  14825. if (!supportsPersistence) {
  14826. return;
  14827. }
  14828. var portal = current$$1.stateNode;
  14829. var containerInfo = portal.containerInfo;
  14830. var emptyChildSet = createContainerChildSet(containerInfo);
  14831. replaceContainerChildren(containerInfo, emptyChildSet);
  14832. }
  14833. function commitContainer(finishedWork) {
  14834. if (!supportsPersistence) {
  14835. return;
  14836. }
  14837. switch (finishedWork.tag) {
  14838. case ClassComponent:
  14839. {
  14840. return;
  14841. }
  14842. case HostComponent:
  14843. {
  14844. return;
  14845. }
  14846. case HostText:
  14847. {
  14848. return;
  14849. }
  14850. case HostRoot:
  14851. case HostPortal:
  14852. {
  14853. var portalOrRoot = finishedWork.stateNode;
  14854. var containerInfo = portalOrRoot.containerInfo,
  14855. _pendingChildren = portalOrRoot.pendingChildren;
  14856. replaceContainerChildren(containerInfo, _pendingChildren);
  14857. return;
  14858. }
  14859. default:
  14860. {
  14861. invariant(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.');
  14862. }
  14863. }
  14864. }
  14865. function getHostParentFiber(fiber) {
  14866. var parent = fiber.return;
  14867. while (parent !== null) {
  14868. if (isHostParent(parent)) {
  14869. return parent;
  14870. }
  14871. parent = parent.return;
  14872. }
  14873. invariant(false, 'Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.');
  14874. }
  14875. function isHostParent(fiber) {
  14876. return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal;
  14877. }
  14878. function getHostSibling(fiber) {
  14879. // We're going to search forward into the tree until we find a sibling host
  14880. // node. Unfortunately, if multiple insertions are done in a row we have to
  14881. // search past them. This leads to exponential search for the next sibling.
  14882. var node = fiber;
  14883. siblings: while (true) {
  14884. // If we didn't find anything, let's try the next sibling.
  14885. while (node.sibling === null) {
  14886. if (node.return === null || isHostParent(node.return)) {
  14887. // If we pop out of the root or hit the parent the fiber we are the
  14888. // last sibling.
  14889. return null;
  14890. }
  14891. node = node.return;
  14892. }
  14893. node.sibling.return = node.return;
  14894. node = node.sibling;
  14895. while (node.tag !== HostComponent && node.tag !== HostText) {
  14896. // If it is not host node and, we might have a host node inside it.
  14897. // Try to search down until we find one.
  14898. if (node.effectTag & Placement) {
  14899. // If we don't have a child, try the siblings instead.
  14900. continue siblings;
  14901. }
  14902. // If we don't have a child, try the siblings instead.
  14903. // We also skip portals because they are not part of this host tree.
  14904. if (node.child === null || node.tag === HostPortal) {
  14905. continue siblings;
  14906. } else {
  14907. node.child.return = node;
  14908. node = node.child;
  14909. }
  14910. }
  14911. // Check if this host node is stable or about to be placed.
  14912. if (!(node.effectTag & Placement)) {
  14913. // Found it!
  14914. return node.stateNode;
  14915. }
  14916. }
  14917. }
  14918. function commitPlacement(finishedWork) {
  14919. if (!supportsMutation) {
  14920. return;
  14921. }
  14922. // Recursively insert all host nodes into the parent.
  14923. var parentFiber = getHostParentFiber(finishedWork);
  14924. // Note: these two variables *must* always be updated together.
  14925. var parent = void 0;
  14926. var isContainer = void 0;
  14927. switch (parentFiber.tag) {
  14928. case HostComponent:
  14929. parent = parentFiber.stateNode;
  14930. isContainer = false;
  14931. break;
  14932. case HostRoot:
  14933. parent = parentFiber.stateNode.containerInfo;
  14934. isContainer = true;
  14935. break;
  14936. case HostPortal:
  14937. parent = parentFiber.stateNode.containerInfo;
  14938. isContainer = true;
  14939. break;
  14940. default:
  14941. invariant(false, 'Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.');
  14942. }
  14943. if (parentFiber.effectTag & ContentReset) {
  14944. // Reset the text content of the parent before doing any insertions
  14945. resetTextContent(parent);
  14946. // Clear ContentReset from the effect tag
  14947. parentFiber.effectTag &= ~ContentReset;
  14948. }
  14949. var before = getHostSibling(finishedWork);
  14950. // We only have the top Fiber that was inserted but we need recurse down its
  14951. // children to find all the terminal nodes.
  14952. var node = finishedWork;
  14953. while (true) {
  14954. if (node.tag === HostComponent || node.tag === HostText) {
  14955. if (before) {
  14956. if (isContainer) {
  14957. insertInContainerBefore(parent, node.stateNode, before);
  14958. } else {
  14959. insertBefore(parent, node.stateNode, before);
  14960. }
  14961. } else {
  14962. if (isContainer) {
  14963. appendChildToContainer(parent, node.stateNode);
  14964. } else {
  14965. appendChild(parent, node.stateNode);
  14966. }
  14967. }
  14968. } else if (node.tag === HostPortal) {
  14969. // If the insertion itself is a portal, then we don't want to traverse
  14970. // down its children. Instead, we'll get insertions from each child in
  14971. // the portal directly.
  14972. } else if (node.child !== null) {
  14973. node.child.return = node;
  14974. node = node.child;
  14975. continue;
  14976. }
  14977. if (node === finishedWork) {
  14978. return;
  14979. }
  14980. while (node.sibling === null) {
  14981. if (node.return === null || node.return === finishedWork) {
  14982. return;
  14983. }
  14984. node = node.return;
  14985. }
  14986. node.sibling.return = node.return;
  14987. node = node.sibling;
  14988. }
  14989. }
  14990. function unmountHostComponents(current$$1) {
  14991. // We only have the top Fiber that was deleted but we need recurse down its
  14992. var node = current$$1;
  14993. // Each iteration, currentParent is populated with node's host parent if not
  14994. // currentParentIsValid.
  14995. var currentParentIsValid = false;
  14996. // Note: these two variables *must* always be updated together.
  14997. var currentParent = void 0;
  14998. var currentParentIsContainer = void 0;
  14999. while (true) {
  15000. if (!currentParentIsValid) {
  15001. var parent = node.return;
  15002. findParent: while (true) {
  15003. !(parent !== null) ? invariant(false, 'Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  15004. switch (parent.tag) {
  15005. case HostComponent:
  15006. currentParent = parent.stateNode;
  15007. currentParentIsContainer = false;
  15008. break findParent;
  15009. case HostRoot:
  15010. currentParent = parent.stateNode.containerInfo;
  15011. currentParentIsContainer = true;
  15012. break findParent;
  15013. case HostPortal:
  15014. currentParent = parent.stateNode.containerInfo;
  15015. currentParentIsContainer = true;
  15016. break findParent;
  15017. }
  15018. parent = parent.return;
  15019. }
  15020. currentParentIsValid = true;
  15021. }
  15022. if (node.tag === HostComponent || node.tag === HostText) {
  15023. commitNestedUnmounts(node);
  15024. // After all the children have unmounted, it is now safe to remove the
  15025. // node from the tree.
  15026. if (currentParentIsContainer) {
  15027. removeChildFromContainer(currentParent, node.stateNode);
  15028. } else {
  15029. removeChild(currentParent, node.stateNode);
  15030. }
  15031. // Don't visit children because we already visited them.
  15032. } else if (node.tag === HostPortal) {
  15033. // When we go into a portal, it becomes the parent to remove from.
  15034. // We will reassign it back when we pop the portal on the way up.
  15035. currentParent = node.stateNode.containerInfo;
  15036. currentParentIsContainer = true;
  15037. // Visit children because portals might contain host components.
  15038. if (node.child !== null) {
  15039. node.child.return = node;
  15040. node = node.child;
  15041. continue;
  15042. }
  15043. } else {
  15044. commitUnmount(node);
  15045. // Visit children because we may find more host components below.
  15046. if (node.child !== null) {
  15047. node.child.return = node;
  15048. node = node.child;
  15049. continue;
  15050. }
  15051. }
  15052. if (node === current$$1) {
  15053. return;
  15054. }
  15055. while (node.sibling === null) {
  15056. if (node.return === null || node.return === current$$1) {
  15057. return;
  15058. }
  15059. node = node.return;
  15060. if (node.tag === HostPortal) {
  15061. // When we go out of the portal, we need to restore the parent.
  15062. // Since we don't keep a stack of them, we will search for it.
  15063. currentParentIsValid = false;
  15064. }
  15065. }
  15066. node.sibling.return = node.return;
  15067. node = node.sibling;
  15068. }
  15069. }
  15070. function commitDeletion(current$$1) {
  15071. if (supportsMutation) {
  15072. // Recursively delete all host nodes from the parent.
  15073. // Detach refs and call componentWillUnmount() on the whole subtree.
  15074. unmountHostComponents(current$$1);
  15075. } else {
  15076. // Detach refs and call componentWillUnmount() on the whole subtree.
  15077. commitNestedUnmounts(current$$1);
  15078. }
  15079. detachFiber(current$$1);
  15080. }
  15081. function commitWork(current$$1, finishedWork) {
  15082. if (!supportsMutation) {
  15083. switch (finishedWork.tag) {
  15084. case FunctionComponent:
  15085. case ForwardRef:
  15086. case MemoComponent:
  15087. case SimpleMemoComponent:
  15088. {
  15089. commitHookEffectList(UnmountMutation, MountMutation, finishedWork);
  15090. return;
  15091. }
  15092. }
  15093. commitContainer(finishedWork);
  15094. return;
  15095. }
  15096. switch (finishedWork.tag) {
  15097. case FunctionComponent:
  15098. case ForwardRef:
  15099. case MemoComponent:
  15100. case SimpleMemoComponent:
  15101. {
  15102. commitHookEffectList(UnmountMutation, MountMutation, finishedWork);
  15103. return;
  15104. }
  15105. case ClassComponent:
  15106. {
  15107. return;
  15108. }
  15109. case HostComponent:
  15110. {
  15111. var instance = finishedWork.stateNode;
  15112. if (instance != null) {
  15113. // Commit the work prepared earlier.
  15114. var newProps = finishedWork.memoizedProps;
  15115. // For hydration we reuse the update path but we treat the oldProps
  15116. // as the newProps. The updatePayload will contain the real change in
  15117. // this case.
  15118. var oldProps = current$$1 !== null ? current$$1.memoizedProps : newProps;
  15119. var type = finishedWork.type;
  15120. // TODO: Type the updateQueue to be specific to host components.
  15121. var updatePayload = finishedWork.updateQueue;
  15122. finishedWork.updateQueue = null;
  15123. if (updatePayload !== null) {
  15124. commitUpdate(instance, updatePayload, type, oldProps, newProps, finishedWork);
  15125. }
  15126. }
  15127. return;
  15128. }
  15129. case HostText:
  15130. {
  15131. !(finishedWork.stateNode !== null) ? invariant(false, 'This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  15132. var textInstance = finishedWork.stateNode;
  15133. var newText = finishedWork.memoizedProps;
  15134. // For hydration we reuse the update path but we treat the oldProps
  15135. // as the newProps. The updatePayload will contain the real change in
  15136. // this case.
  15137. var oldText = current$$1 !== null ? current$$1.memoizedProps : newText;
  15138. commitTextUpdate(textInstance, oldText, newText);
  15139. return;
  15140. }
  15141. case HostRoot:
  15142. {
  15143. return;
  15144. }
  15145. case Profiler:
  15146. {
  15147. return;
  15148. }
  15149. case SuspenseComponent:
  15150. {
  15151. var newState = finishedWork.memoizedState;
  15152. var newDidTimeout = void 0;
  15153. var primaryChildParent = finishedWork;
  15154. if (newState === null) {
  15155. newDidTimeout = false;
  15156. } else {
  15157. newDidTimeout = true;
  15158. primaryChildParent = finishedWork.child;
  15159. if (newState.timedOutAt === NoWork) {
  15160. // If the children had not already timed out, record the time.
  15161. // This is used to compute the elapsed time during subsequent
  15162. // attempts to render the children.
  15163. newState.timedOutAt = requestCurrentTime();
  15164. }
  15165. }
  15166. if (primaryChildParent !== null) {
  15167. hideOrUnhideAllChildren(primaryChildParent, newDidTimeout);
  15168. }
  15169. return;
  15170. }
  15171. case IncompleteClassComponent:
  15172. {
  15173. return;
  15174. }
  15175. default:
  15176. {
  15177. invariant(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.');
  15178. }
  15179. }
  15180. }
  15181. function commitResetTextContent(current$$1) {
  15182. if (!supportsMutation) {
  15183. return;
  15184. }
  15185. resetTextContent(current$$1.stateNode);
  15186. }
  15187. function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
  15188. var update = createUpdate(expirationTime);
  15189. // Unmount the root by rendering null.
  15190. update.tag = CaptureUpdate;
  15191. // Caution: React DevTools currently depends on this property
  15192. // being called "element".
  15193. update.payload = { element: null };
  15194. var error = errorInfo.value;
  15195. update.callback = function () {
  15196. onUncaughtError(error);
  15197. logError(fiber, errorInfo);
  15198. };
  15199. return update;
  15200. }
  15201. function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
  15202. var update = createUpdate(expirationTime);
  15203. update.tag = CaptureUpdate;
  15204. var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
  15205. if (typeof getDerivedStateFromError === 'function') {
  15206. var error = errorInfo.value;
  15207. update.payload = function () {
  15208. return getDerivedStateFromError(error);
  15209. };
  15210. }
  15211. var inst = fiber.stateNode;
  15212. if (inst !== null && typeof inst.componentDidCatch === 'function') {
  15213. update.callback = function callback() {
  15214. if (typeof getDerivedStateFromError !== 'function') {
  15215. // To preserve the preexisting retry behavior of error boundaries,
  15216. // we keep track of which ones already failed during this batch.
  15217. // This gets reset before we yield back to the browser.
  15218. // TODO: Warn in strict mode if getDerivedStateFromError is
  15219. // not defined.
  15220. markLegacyErrorBoundaryAsFailed(this);
  15221. }
  15222. var error = errorInfo.value;
  15223. var stack = errorInfo.stack;
  15224. logError(fiber, errorInfo);
  15225. this.componentDidCatch(error, {
  15226. componentStack: stack !== null ? stack : ''
  15227. });
  15228. {
  15229. if (typeof getDerivedStateFromError !== 'function') {
  15230. // If componentDidCatch is the only error boundary method defined,
  15231. // then it needs to call setState to recover from errors.
  15232. // If no state update is scheduled then the boundary will swallow the error.
  15233. !(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;
  15234. }
  15235. }
  15236. };
  15237. }
  15238. return update;
  15239. }
  15240. function throwException(root, returnFiber, sourceFiber, value, renderExpirationTime) {
  15241. // The source fiber did not complete.
  15242. sourceFiber.effectTag |= Incomplete;
  15243. // Its effect list is no longer valid.
  15244. sourceFiber.firstEffect = sourceFiber.lastEffect = null;
  15245. if (value !== null && typeof value === 'object' && typeof value.then === 'function') {
  15246. // This is a thenable.
  15247. var thenable = value;
  15248. // Find the earliest timeout threshold of all the placeholders in the
  15249. // ancestor path. We could avoid this traversal by storing the thresholds on
  15250. // the stack, but we choose not to because we only hit this path if we're
  15251. // IO-bound (i.e. if something suspends). Whereas the stack is used even in
  15252. // the non-IO- bound case.
  15253. var _workInProgress = returnFiber;
  15254. var earliestTimeoutMs = -1;
  15255. var startTimeMs = -1;
  15256. do {
  15257. if (_workInProgress.tag === SuspenseComponent) {
  15258. var current$$1 = _workInProgress.alternate;
  15259. if (current$$1 !== null) {
  15260. var currentState = current$$1.memoizedState;
  15261. if (currentState !== null) {
  15262. // Reached a boundary that already timed out. Do not search
  15263. // any further.
  15264. var timedOutAt = currentState.timedOutAt;
  15265. startTimeMs = expirationTimeToMs(timedOutAt);
  15266. // Do not search any further.
  15267. break;
  15268. }
  15269. }
  15270. var timeoutPropMs = _workInProgress.pendingProps.maxDuration;
  15271. if (typeof timeoutPropMs === 'number') {
  15272. if (timeoutPropMs <= 0) {
  15273. earliestTimeoutMs = 0;
  15274. } else if (earliestTimeoutMs === -1 || timeoutPropMs < earliestTimeoutMs) {
  15275. earliestTimeoutMs = timeoutPropMs;
  15276. }
  15277. }
  15278. }
  15279. _workInProgress = _workInProgress.return;
  15280. } while (_workInProgress !== null);
  15281. // Schedule the nearest Suspense to re-render the timed out view.
  15282. _workInProgress = returnFiber;
  15283. do {
  15284. if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress.alternate, _workInProgress)) {
  15285. // Found the nearest boundary.
  15286. // If the boundary is not in concurrent mode, we should not suspend, and
  15287. // likewise, when the promise resolves, we should ping synchronously.
  15288. var pingTime = (_workInProgress.mode & ConcurrentMode) === NoEffect ? Sync : renderExpirationTime;
  15289. // Attach a listener to the promise to "ping" the root and retry.
  15290. var onResolveOrReject = retrySuspendedRoot.bind(null, root, _workInProgress, sourceFiber, pingTime);
  15291. if (enableSchedulerTracing) {
  15292. onResolveOrReject = tracing.unstable_wrap(onResolveOrReject);
  15293. }
  15294. thenable.then(onResolveOrReject, onResolveOrReject);
  15295. // If the boundary is outside of concurrent mode, we should *not*
  15296. // suspend the commit. Pretend as if the suspended component rendered
  15297. // null and keep rendering. In the commit phase, we'll schedule a
  15298. // subsequent synchronous update to re-render the Suspense.
  15299. //
  15300. // Note: It doesn't matter whether the component that suspended was
  15301. // inside a concurrent mode tree. If the Suspense is outside of it, we
  15302. // should *not* suspend the commit.
  15303. if ((_workInProgress.mode & ConcurrentMode) === NoEffect) {
  15304. _workInProgress.effectTag |= DidCapture;
  15305. // We're going to commit this fiber even though it didn't complete.
  15306. // But we shouldn't call any lifecycle methods or callbacks. Remove
  15307. // all lifecycle effect tags.
  15308. sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete);
  15309. if (sourceFiber.tag === ClassComponent) {
  15310. var _current = sourceFiber.alternate;
  15311. if (_current === null) {
  15312. // This is a new mount. Change the tag so it's not mistaken for a
  15313. // completed class component. For example, we should not call
  15314. // componentWillUnmount if it is deleted.
  15315. sourceFiber.tag = IncompleteClassComponent;
  15316. }
  15317. }
  15318. // The source fiber did not complete. Mark it with the current
  15319. // render priority to indicate that it still has pending work.
  15320. sourceFiber.expirationTime = renderExpirationTime;
  15321. // Exit without suspending.
  15322. return;
  15323. }
  15324. // Confirmed that the boundary is in a concurrent mode tree. Continue
  15325. // with the normal suspend path.
  15326. var absoluteTimeoutMs = void 0;
  15327. if (earliestTimeoutMs === -1) {
  15328. // If no explicit threshold is given, default to an abitrarily large
  15329. // value. The actual size doesn't matter because the threshold for the
  15330. // whole tree will be clamped to the expiration time.
  15331. absoluteTimeoutMs = maxSigned31BitInt;
  15332. } else {
  15333. if (startTimeMs === -1) {
  15334. // This suspend happened outside of any already timed-out
  15335. // placeholders. We don't know exactly when the update was
  15336. // scheduled, but we can infer an approximate start time from the
  15337. // expiration time. First, find the earliest uncommitted expiration
  15338. // time in the tree, including work that is suspended. Then subtract
  15339. // the offset used to compute an async update's expiration time.
  15340. // This will cause high priority (interactive) work to expire
  15341. // earlier than necessary, but we can account for this by adjusting
  15342. // for the Just Noticeable Difference.
  15343. var earliestExpirationTime = findEarliestOutstandingPriorityLevel(root, renderExpirationTime);
  15344. var earliestExpirationTimeMs = expirationTimeToMs(earliestExpirationTime);
  15345. startTimeMs = earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION;
  15346. }
  15347. absoluteTimeoutMs = startTimeMs + earliestTimeoutMs;
  15348. }
  15349. // Mark the earliest timeout in the suspended fiber's ancestor path.
  15350. // After completing the root, we'll take the largest of all the
  15351. // suspended fiber's timeouts and use it to compute a timeout for the
  15352. // whole tree.
  15353. renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime);
  15354. _workInProgress.effectTag |= ShouldCapture;
  15355. _workInProgress.expirationTime = renderExpirationTime;
  15356. return;
  15357. }
  15358. // This boundary already captured during this render. Continue to the next
  15359. // boundary.
  15360. _workInProgress = _workInProgress.return;
  15361. } while (_workInProgress !== null);
  15362. // No boundary was found. Fallthrough to error mode.
  15363. // TODO: Use invariant so the message is stripped in prod?
  15364. 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));
  15365. }
  15366. // We didn't find a boundary that could handle this type of exception. Start
  15367. // over and traverse parent path again, this time treating the exception
  15368. // as an error.
  15369. renderDidError();
  15370. value = createCapturedValue(value, sourceFiber);
  15371. var workInProgress = returnFiber;
  15372. do {
  15373. switch (workInProgress.tag) {
  15374. case HostRoot:
  15375. {
  15376. var _errorInfo = value;
  15377. workInProgress.effectTag |= ShouldCapture;
  15378. workInProgress.expirationTime = renderExpirationTime;
  15379. var update = createRootErrorUpdate(workInProgress, _errorInfo, renderExpirationTime);
  15380. enqueueCapturedUpdate(workInProgress, update);
  15381. return;
  15382. }
  15383. case ClassComponent:
  15384. // Capture and retry
  15385. var errorInfo = value;
  15386. var ctor = workInProgress.type;
  15387. var instance = workInProgress.stateNode;
  15388. if ((workInProgress.effectTag & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) {
  15389. workInProgress.effectTag |= ShouldCapture;
  15390. workInProgress.expirationTime = renderExpirationTime;
  15391. // Schedule the error boundary to re-render using updated state
  15392. var _update = createClassErrorUpdate(workInProgress, errorInfo, renderExpirationTime);
  15393. enqueueCapturedUpdate(workInProgress, _update);
  15394. return;
  15395. }
  15396. break;
  15397. default:
  15398. break;
  15399. }
  15400. workInProgress = workInProgress.return;
  15401. } while (workInProgress !== null);
  15402. }
  15403. function unwindWork(workInProgress, renderExpirationTime) {
  15404. switch (workInProgress.tag) {
  15405. case ClassComponent:
  15406. {
  15407. var Component = workInProgress.type;
  15408. if (isContextProvider(Component)) {
  15409. popContext(workInProgress);
  15410. }
  15411. var effectTag = workInProgress.effectTag;
  15412. if (effectTag & ShouldCapture) {
  15413. workInProgress.effectTag = effectTag & ~ShouldCapture | DidCapture;
  15414. return workInProgress;
  15415. }
  15416. return null;
  15417. }
  15418. case HostRoot:
  15419. {
  15420. popHostContainer(workInProgress);
  15421. popTopLevelContextObject(workInProgress);
  15422. var _effectTag = workInProgress.effectTag;
  15423. !((_effectTag & DidCapture) === NoEffect) ? invariant(false, 'The root failed to unmount after an error. This is likely a bug in React. Please file an issue.') : void 0;
  15424. workInProgress.effectTag = _effectTag & ~ShouldCapture | DidCapture;
  15425. return workInProgress;
  15426. }
  15427. case HostComponent:
  15428. {
  15429. popHostContext(workInProgress);
  15430. return null;
  15431. }
  15432. case SuspenseComponent:
  15433. {
  15434. var _effectTag2 = workInProgress.effectTag;
  15435. if (_effectTag2 & ShouldCapture) {
  15436. workInProgress.effectTag = _effectTag2 & ~ShouldCapture | DidCapture;
  15437. // Captured a suspense effect. Re-render the boundary.
  15438. return workInProgress;
  15439. }
  15440. return null;
  15441. }
  15442. case HostPortal:
  15443. popHostContainer(workInProgress);
  15444. return null;
  15445. case ContextProvider:
  15446. popProvider(workInProgress);
  15447. return null;
  15448. default:
  15449. return null;
  15450. }
  15451. }
  15452. function unwindInterruptedWork(interruptedWork) {
  15453. switch (interruptedWork.tag) {
  15454. case ClassComponent:
  15455. {
  15456. var childContextTypes = interruptedWork.type.childContextTypes;
  15457. if (childContextTypes !== null && childContextTypes !== undefined) {
  15458. popContext(interruptedWork);
  15459. }
  15460. break;
  15461. }
  15462. case HostRoot:
  15463. {
  15464. popHostContainer(interruptedWork);
  15465. popTopLevelContextObject(interruptedWork);
  15466. break;
  15467. }
  15468. case HostComponent:
  15469. {
  15470. popHostContext(interruptedWork);
  15471. break;
  15472. }
  15473. case HostPortal:
  15474. popHostContainer(interruptedWork);
  15475. break;
  15476. case ContextProvider:
  15477. popProvider(interruptedWork);
  15478. break;
  15479. default:
  15480. break;
  15481. }
  15482. }
  15483. var Dispatcher = {
  15484. readContext: readContext,
  15485. useCallback: useCallback,
  15486. useContext: useContext,
  15487. useEffect: useEffect,
  15488. useImperativeMethods: useImperativeMethods,
  15489. useLayoutEffect: useLayoutEffect,
  15490. useMemo: useMemo,
  15491. useMutationEffect: useMutationEffect,
  15492. useReducer: useReducer,
  15493. useRef: useRef,
  15494. useState: useState
  15495. };
  15496. var DispatcherWithoutHooks = {
  15497. readContext: readContext
  15498. };
  15499. var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner;
  15500. var didWarnAboutStateTransition = void 0;
  15501. var didWarnSetStateChildContext = void 0;
  15502. var warnAboutUpdateOnUnmounted = void 0;
  15503. var warnAboutInvalidUpdates = void 0;
  15504. if (enableSchedulerTracing) {
  15505. // Provide explicit error message when production+profiling bundle of e.g. react-dom
  15506. // is used with production (non-profiling) bundle of scheduler/tracing
  15507. !(tracing.__interactionsRef != null && tracing.__interactionsRef.current != null) ? invariant(false, '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') : void 0;
  15508. }
  15509. {
  15510. didWarnAboutStateTransition = false;
  15511. didWarnSetStateChildContext = false;
  15512. var didWarnStateUpdateForUnmountedComponent = {};
  15513. warnAboutUpdateOnUnmounted = function (fiber, isClass) {
  15514. // We show the whole stack but dedupe on the top component's name because
  15515. // the problematic code almost always lies inside that component.
  15516. var componentName = getComponentName(fiber.type) || 'ReactComponent';
  15517. if (didWarnStateUpdateForUnmountedComponent[componentName]) {
  15518. return;
  15519. }
  15520. 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', isClass ? 'the componentWillUnmount method' : 'a useEffect cleanup function', getStackByFiberInDevAndProd(fiber));
  15521. didWarnStateUpdateForUnmountedComponent[componentName] = true;
  15522. };
  15523. warnAboutInvalidUpdates = function (instance) {
  15524. switch (phase) {
  15525. case 'getChildContext':
  15526. if (didWarnSetStateChildContext) {
  15527. return;
  15528. }
  15529. warningWithoutStack$1(false, 'setState(...): Cannot call setState() inside getChildContext()');
  15530. didWarnSetStateChildContext = true;
  15531. break;
  15532. case 'render':
  15533. if (didWarnAboutStateTransition) {
  15534. return;
  15535. }
  15536. 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.');
  15537. didWarnAboutStateTransition = true;
  15538. break;
  15539. }
  15540. };
  15541. }
  15542. // Used to ensure computeUniqueAsyncExpiration is monotonically decreasing.
  15543. var lastUniqueAsyncExpiration = Sync - 1;
  15544. // Represents the expiration time that incoming updates should use. (If this
  15545. // is NoWork, use the default strategy: async updates in async mode, sync
  15546. // updates in sync mode.)
  15547. var expirationContext = NoWork;
  15548. var isWorking = false;
  15549. // The next work in progress fiber that we're currently working on.
  15550. var nextUnitOfWork = null;
  15551. var nextRoot = null;
  15552. // The time at which we're currently rendering work.
  15553. var nextRenderExpirationTime = NoWork;
  15554. var nextLatestAbsoluteTimeoutMs = -1;
  15555. var nextRenderDidError = false;
  15556. // The next fiber with an effect that we're currently committing.
  15557. var nextEffect = null;
  15558. var isCommitting$1 = false;
  15559. var rootWithPendingPassiveEffects = null;
  15560. var passiveEffectCallbackHandle = null;
  15561. var passiveEffectCallback = null;
  15562. var legacyErrorBoundariesThatAlreadyFailed = null;
  15563. // Used for performance tracking.
  15564. var interruptedBy = null;
  15565. var stashedWorkInProgressProperties = void 0;
  15566. var replayUnitOfWork = void 0;
  15567. var mayReplayFailedUnitOfWork = void 0;
  15568. var isReplayingFailedUnitOfWork = void 0;
  15569. var originalReplayError = void 0;
  15570. var rethrowOriginalError = void 0;
  15571. if ( true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
  15572. stashedWorkInProgressProperties = null;
  15573. mayReplayFailedUnitOfWork = true;
  15574. isReplayingFailedUnitOfWork = false;
  15575. originalReplayError = null;
  15576. replayUnitOfWork = function (failedUnitOfWork, thrownValue, isYieldy) {
  15577. if (thrownValue !== null && typeof thrownValue === 'object' && typeof thrownValue.then === 'function') {
  15578. // Don't replay promises. Treat everything else like an error.
  15579. // TODO: Need to figure out a different strategy if/when we add
  15580. // support for catching other types.
  15581. return;
  15582. }
  15583. // Restore the original state of the work-in-progress
  15584. if (stashedWorkInProgressProperties === null) {
  15585. // This should never happen. Don't throw because this code is DEV-only.
  15586. warningWithoutStack$1(false, 'Could not replay rendering after an error. This is likely a bug in React. ' + 'Please file an issue.');
  15587. return;
  15588. }
  15589. assignFiberPropertiesInDEV(failedUnitOfWork, stashedWorkInProgressProperties);
  15590. switch (failedUnitOfWork.tag) {
  15591. case HostRoot:
  15592. popHostContainer(failedUnitOfWork);
  15593. popTopLevelContextObject(failedUnitOfWork);
  15594. break;
  15595. case HostComponent:
  15596. popHostContext(failedUnitOfWork);
  15597. break;
  15598. case ClassComponent:
  15599. {
  15600. var Component = failedUnitOfWork.type;
  15601. if (isContextProvider(Component)) {
  15602. popContext(failedUnitOfWork);
  15603. }
  15604. break;
  15605. }
  15606. case HostPortal:
  15607. popHostContainer(failedUnitOfWork);
  15608. break;
  15609. case ContextProvider:
  15610. popProvider(failedUnitOfWork);
  15611. break;
  15612. }
  15613. // Replay the begin phase.
  15614. isReplayingFailedUnitOfWork = true;
  15615. originalReplayError = thrownValue;
  15616. invokeGuardedCallback(null, workLoop, null, isYieldy);
  15617. isReplayingFailedUnitOfWork = false;
  15618. originalReplayError = null;
  15619. if (hasCaughtError()) {
  15620. var replayError = clearCaughtError();
  15621. if (replayError != null && thrownValue != null) {
  15622. try {
  15623. // Reading the expando property is intentionally
  15624. // inside `try` because it might be a getter or Proxy.
  15625. if (replayError._suppressLogging) {
  15626. // Also suppress logging for the original error.
  15627. thrownValue._suppressLogging = true;
  15628. }
  15629. } catch (inner) {
  15630. // Ignore.
  15631. }
  15632. }
  15633. } else {
  15634. // If the begin phase did not fail the second time, set this pointer
  15635. // back to the original value.
  15636. nextUnitOfWork = failedUnitOfWork;
  15637. }
  15638. };
  15639. rethrowOriginalError = function () {
  15640. throw originalReplayError;
  15641. };
  15642. }
  15643. function resetStack() {
  15644. if (nextUnitOfWork !== null) {
  15645. var interruptedWork = nextUnitOfWork.return;
  15646. while (interruptedWork !== null) {
  15647. unwindInterruptedWork(interruptedWork);
  15648. interruptedWork = interruptedWork.return;
  15649. }
  15650. }
  15651. {
  15652. ReactStrictModeWarnings.discardPendingWarnings();
  15653. checkThatStackIsEmpty();
  15654. }
  15655. nextRoot = null;
  15656. nextRenderExpirationTime = NoWork;
  15657. nextLatestAbsoluteTimeoutMs = -1;
  15658. nextRenderDidError = false;
  15659. nextUnitOfWork = null;
  15660. }
  15661. function commitAllHostEffects() {
  15662. while (nextEffect !== null) {
  15663. {
  15664. setCurrentFiber(nextEffect);
  15665. }
  15666. recordEffect();
  15667. var effectTag = nextEffect.effectTag;
  15668. if (effectTag & ContentReset) {
  15669. commitResetTextContent(nextEffect);
  15670. }
  15671. if (effectTag & Ref) {
  15672. var current$$1 = nextEffect.alternate;
  15673. if (current$$1 !== null) {
  15674. commitDetachRef(current$$1);
  15675. }
  15676. }
  15677. // The following switch statement is only concerned about placement,
  15678. // updates, and deletions. To avoid needing to add a case for every
  15679. // possible bitmap value, we remove the secondary effects from the
  15680. // effect tag and switch on that value.
  15681. var primaryEffectTag = effectTag & (Placement | Update | Deletion);
  15682. switch (primaryEffectTag) {
  15683. case Placement:
  15684. {
  15685. commitPlacement(nextEffect);
  15686. // Clear the "placement" from effect tag so that we know that this is inserted, before
  15687. // any life-cycles like componentDidMount gets called.
  15688. // TODO: findDOMNode doesn't rely on this any more but isMounted
  15689. // does and isMounted is deprecated anyway so we should be able
  15690. // to kill this.
  15691. nextEffect.effectTag &= ~Placement;
  15692. break;
  15693. }
  15694. case PlacementAndUpdate:
  15695. {
  15696. // Placement
  15697. commitPlacement(nextEffect);
  15698. // Clear the "placement" from effect tag so that we know that this is inserted, before
  15699. // any life-cycles like componentDidMount gets called.
  15700. nextEffect.effectTag &= ~Placement;
  15701. // Update
  15702. var _current = nextEffect.alternate;
  15703. commitWork(_current, nextEffect);
  15704. break;
  15705. }
  15706. case Update:
  15707. {
  15708. var _current2 = nextEffect.alternate;
  15709. commitWork(_current2, nextEffect);
  15710. break;
  15711. }
  15712. case Deletion:
  15713. {
  15714. commitDeletion(nextEffect);
  15715. break;
  15716. }
  15717. }
  15718. nextEffect = nextEffect.nextEffect;
  15719. }
  15720. {
  15721. resetCurrentFiber();
  15722. }
  15723. }
  15724. function commitBeforeMutationLifecycles() {
  15725. while (nextEffect !== null) {
  15726. {
  15727. setCurrentFiber(nextEffect);
  15728. }
  15729. var effectTag = nextEffect.effectTag;
  15730. if (effectTag & Snapshot) {
  15731. recordEffect();
  15732. var current$$1 = nextEffect.alternate;
  15733. commitBeforeMutationLifeCycles(current$$1, nextEffect);
  15734. }
  15735. nextEffect = nextEffect.nextEffect;
  15736. }
  15737. {
  15738. resetCurrentFiber();
  15739. }
  15740. }
  15741. function commitAllLifeCycles(finishedRoot, committedExpirationTime) {
  15742. {
  15743. ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
  15744. ReactStrictModeWarnings.flushLegacyContextWarning();
  15745. if (warnAboutDeprecatedLifecycles) {
  15746. ReactStrictModeWarnings.flushPendingDeprecationWarnings();
  15747. }
  15748. }
  15749. while (nextEffect !== null) {
  15750. var effectTag = nextEffect.effectTag;
  15751. if (effectTag & (Update | Callback)) {
  15752. recordEffect();
  15753. var current$$1 = nextEffect.alternate;
  15754. commitLifeCycles(finishedRoot, current$$1, nextEffect, committedExpirationTime);
  15755. }
  15756. if (effectTag & Ref) {
  15757. recordEffect();
  15758. commitAttachRef(nextEffect);
  15759. }
  15760. if (enableHooks && effectTag & Passive) {
  15761. rootWithPendingPassiveEffects = finishedRoot;
  15762. }
  15763. nextEffect = nextEffect.nextEffect;
  15764. }
  15765. }
  15766. function commitPassiveEffects(root, firstEffect) {
  15767. rootWithPendingPassiveEffects = null;
  15768. passiveEffectCallbackHandle = null;
  15769. passiveEffectCallback = null;
  15770. // Set this to true to prevent re-entrancy
  15771. var previousIsRendering = isRendering;
  15772. isRendering = true;
  15773. var effect = firstEffect;
  15774. do {
  15775. if (effect.effectTag & Passive) {
  15776. var didError = false;
  15777. var error = void 0;
  15778. {
  15779. invokeGuardedCallback(null, commitPassiveHookEffects, null, effect);
  15780. if (hasCaughtError()) {
  15781. didError = true;
  15782. error = clearCaughtError();
  15783. }
  15784. }
  15785. if (didError) {
  15786. captureCommitPhaseError(effect, error);
  15787. }
  15788. }
  15789. effect = effect.nextEffect;
  15790. } while (effect !== null);
  15791. isRendering = previousIsRendering;
  15792. // Check if work was scheduled by one of the effects
  15793. var rootExpirationTime = root.expirationTime;
  15794. if (rootExpirationTime !== NoWork) {
  15795. requestWork(root, rootExpirationTime);
  15796. }
  15797. }
  15798. function isAlreadyFailedLegacyErrorBoundary(instance) {
  15799. return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance);
  15800. }
  15801. function markLegacyErrorBoundaryAsFailed(instance) {
  15802. if (legacyErrorBoundariesThatAlreadyFailed === null) {
  15803. legacyErrorBoundariesThatAlreadyFailed = new Set([instance]);
  15804. } else {
  15805. legacyErrorBoundariesThatAlreadyFailed.add(instance);
  15806. }
  15807. }
  15808. function flushPassiveEffects() {
  15809. if (passiveEffectCallback !== null) {
  15810. scheduler.unstable_cancelCallback(passiveEffectCallbackHandle);
  15811. // We call the scheduled callback instead of commitPassiveEffects directly
  15812. // to ensure tracing works correctly.
  15813. passiveEffectCallback();
  15814. }
  15815. }
  15816. function commitRoot(root, finishedWork) {
  15817. isWorking = true;
  15818. isCommitting$1 = true;
  15819. startCommitTimer();
  15820. !(root.current !== finishedWork) ? invariant(false, 'Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  15821. var committedExpirationTime = root.pendingCommitExpirationTime;
  15822. !(committedExpirationTime !== NoWork) ? invariant(false, 'Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  15823. root.pendingCommitExpirationTime = NoWork;
  15824. // Update the pending priority levels to account for the work that we are
  15825. // about to commit. This needs to happen before calling the lifecycles, since
  15826. // they may schedule additional updates.
  15827. var updateExpirationTimeBeforeCommit = finishedWork.expirationTime;
  15828. var childExpirationTimeBeforeCommit = finishedWork.childExpirationTime;
  15829. var earliestRemainingTimeBeforeCommit = childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit ? childExpirationTimeBeforeCommit : updateExpirationTimeBeforeCommit;
  15830. markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit);
  15831. var prevInteractions = null;
  15832. if (enableSchedulerTracing) {
  15833. // Restore any pending interactions at this point,
  15834. // So that cascading work triggered during the render phase will be accounted for.
  15835. prevInteractions = tracing.__interactionsRef.current;
  15836. tracing.__interactionsRef.current = root.memoizedInteractions;
  15837. }
  15838. // Reset this to null before calling lifecycles
  15839. ReactCurrentOwner$2.current = null;
  15840. var firstEffect = void 0;
  15841. if (finishedWork.effectTag > PerformedWork) {
  15842. // A fiber's effect list consists only of its children, not itself. So if
  15843. // the root has an effect, we need to add it to the end of the list. The
  15844. // resulting list is the set that would belong to the root's parent, if
  15845. // it had one; that is, all the effects in the tree including the root.
  15846. if (finishedWork.lastEffect !== null) {
  15847. finishedWork.lastEffect.nextEffect = finishedWork;
  15848. firstEffect = finishedWork.firstEffect;
  15849. } else {
  15850. firstEffect = finishedWork;
  15851. }
  15852. } else {
  15853. // There is no effect on the root.
  15854. firstEffect = finishedWork.firstEffect;
  15855. }
  15856. prepareForCommit(root.containerInfo);
  15857. // Invoke instances of getSnapshotBeforeUpdate before mutation.
  15858. nextEffect = firstEffect;
  15859. startCommitSnapshotEffectsTimer();
  15860. while (nextEffect !== null) {
  15861. var didError = false;
  15862. var error = void 0;
  15863. {
  15864. invokeGuardedCallback(null, commitBeforeMutationLifecycles, null);
  15865. if (hasCaughtError()) {
  15866. didError = true;
  15867. error = clearCaughtError();
  15868. }
  15869. }
  15870. if (didError) {
  15871. !(nextEffect !== null) ? invariant(false, 'Should have next effect. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  15872. captureCommitPhaseError(nextEffect, error);
  15873. // Clean-up
  15874. if (nextEffect !== null) {
  15875. nextEffect = nextEffect.nextEffect;
  15876. }
  15877. }
  15878. }
  15879. stopCommitSnapshotEffectsTimer();
  15880. if (enableProfilerTimer) {
  15881. // Mark the current commit time to be shared by all Profilers in this batch.
  15882. // This enables them to be grouped later.
  15883. recordCommitTime();
  15884. }
  15885. // Commit all the side-effects within a tree. We'll do this in two passes.
  15886. // The first pass performs all the host insertions, updates, deletions and
  15887. // ref unmounts.
  15888. nextEffect = firstEffect;
  15889. startCommitHostEffectsTimer();
  15890. while (nextEffect !== null) {
  15891. var _didError = false;
  15892. var _error = void 0;
  15893. {
  15894. invokeGuardedCallback(null, commitAllHostEffects, null);
  15895. if (hasCaughtError()) {
  15896. _didError = true;
  15897. _error = clearCaughtError();
  15898. }
  15899. }
  15900. if (_didError) {
  15901. !(nextEffect !== null) ? invariant(false, 'Should have next effect. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  15902. captureCommitPhaseError(nextEffect, _error);
  15903. // Clean-up
  15904. if (nextEffect !== null) {
  15905. nextEffect = nextEffect.nextEffect;
  15906. }
  15907. }
  15908. }
  15909. stopCommitHostEffectsTimer();
  15910. resetAfterCommit(root.containerInfo);
  15911. // The work-in-progress tree is now the current tree. This must come after
  15912. // the first pass of the commit phase, so that the previous tree is still
  15913. // current during componentWillUnmount, but before the second pass, so that
  15914. // the finished work is current during componentDidMount/Update.
  15915. root.current = finishedWork;
  15916. // In the second pass we'll perform all life-cycles and ref callbacks.
  15917. // Life-cycles happen as a separate pass so that all placements, updates,
  15918. // and deletions in the entire tree have already been invoked.
  15919. // This pass also triggers any renderer-specific initial effects.
  15920. nextEffect = firstEffect;
  15921. startCommitLifeCyclesTimer();
  15922. while (nextEffect !== null) {
  15923. var _didError2 = false;
  15924. var _error2 = void 0;
  15925. {
  15926. invokeGuardedCallback(null, commitAllLifeCycles, null, root, committedExpirationTime);
  15927. if (hasCaughtError()) {
  15928. _didError2 = true;
  15929. _error2 = clearCaughtError();
  15930. }
  15931. }
  15932. if (_didError2) {
  15933. !(nextEffect !== null) ? invariant(false, 'Should have next effect. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  15934. captureCommitPhaseError(nextEffect, _error2);
  15935. if (nextEffect !== null) {
  15936. nextEffect = nextEffect.nextEffect;
  15937. }
  15938. }
  15939. }
  15940. if (enableHooks && firstEffect !== null && rootWithPendingPassiveEffects !== null) {
  15941. // This commit included a passive effect. These do not need to fire until
  15942. // after the next paint. Schedule an callback to fire them in an async
  15943. // event. To ensure serial execution, the callback will be flushed early if
  15944. // we enter rootWithPendingPassiveEffects commit phase before then.
  15945. var callback = commitPassiveEffects.bind(null, root, firstEffect);
  15946. if (enableSchedulerTracing) {
  15947. // TODO: Avoid this extra callback by mutating the tracing ref directly,
  15948. // like we do at the beginning of commitRoot. I've opted not to do that
  15949. // here because that code is still in flux.
  15950. callback = tracing.unstable_wrap(callback);
  15951. }
  15952. passiveEffectCallbackHandle = scheduler.unstable_scheduleCallback(callback);
  15953. passiveEffectCallback = callback;
  15954. }
  15955. isCommitting$1 = false;
  15956. isWorking = false;
  15957. stopCommitLifeCyclesTimer();
  15958. stopCommitTimer();
  15959. onCommitRoot(finishedWork.stateNode);
  15960. if ( true && ReactFiberInstrumentation_1.debugTool) {
  15961. ReactFiberInstrumentation_1.debugTool.onCommitWork(finishedWork);
  15962. }
  15963. var updateExpirationTimeAfterCommit = finishedWork.expirationTime;
  15964. var childExpirationTimeAfterCommit = finishedWork.childExpirationTime;
  15965. var earliestRemainingTimeAfterCommit = childExpirationTimeAfterCommit > updateExpirationTimeAfterCommit ? childExpirationTimeAfterCommit : updateExpirationTimeAfterCommit;
  15966. if (earliestRemainingTimeAfterCommit === NoWork) {
  15967. // If there's no remaining work, we can clear the set of already failed
  15968. // error boundaries.
  15969. legacyErrorBoundariesThatAlreadyFailed = null;
  15970. }
  15971. onCommit(root, earliestRemainingTimeAfterCommit);
  15972. if (enableSchedulerTracing) {
  15973. tracing.__interactionsRef.current = prevInteractions;
  15974. var subscriber = void 0;
  15975. try {
  15976. subscriber = tracing.__subscriberRef.current;
  15977. if (subscriber !== null && root.memoizedInteractions.size > 0) {
  15978. var threadID = computeThreadID(committedExpirationTime, root.interactionThreadID);
  15979. subscriber.onWorkStopped(root.memoizedInteractions, threadID);
  15980. }
  15981. } catch (error) {
  15982. // It's not safe for commitRoot() to throw.
  15983. // Store the error for now and we'll re-throw in finishRendering().
  15984. if (!hasUnhandledError) {
  15985. hasUnhandledError = true;
  15986. unhandledError = error;
  15987. }
  15988. } finally {
  15989. // Clear completed interactions from the pending Map.
  15990. // Unless the render was suspended or cascading work was scheduled,
  15991. // In which case– leave pending interactions until the subsequent render.
  15992. var pendingInteractionMap = root.pendingInteractionMap;
  15993. pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
  15994. // Only decrement the pending interaction count if we're done.
  15995. // If there's still work at the current priority,
  15996. // That indicates that we are waiting for suspense data.
  15997. if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) {
  15998. pendingInteractionMap.delete(scheduledExpirationTime);
  15999. scheduledInteractions.forEach(function (interaction) {
  16000. interaction.__count--;
  16001. if (subscriber !== null && interaction.__count === 0) {
  16002. try {
  16003. subscriber.onInteractionScheduledWorkCompleted(interaction);
  16004. } catch (error) {
  16005. // It's not safe for commitRoot() to throw.
  16006. // Store the error for now and we'll re-throw in finishRendering().
  16007. if (!hasUnhandledError) {
  16008. hasUnhandledError = true;
  16009. unhandledError = error;
  16010. }
  16011. }
  16012. }
  16013. });
  16014. }
  16015. });
  16016. }
  16017. }
  16018. }
  16019. function resetChildExpirationTime(workInProgress, renderTime) {
  16020. if (renderTime !== Never && workInProgress.childExpirationTime === Never) {
  16021. // The children of this component are hidden. Don't bubble their
  16022. // expiration times.
  16023. return;
  16024. }
  16025. var newChildExpirationTime = NoWork;
  16026. // Bubble up the earliest expiration time.
  16027. if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
  16028. // We're in profiling mode.
  16029. // Let's use this same traversal to update the render durations.
  16030. var actualDuration = workInProgress.actualDuration;
  16031. var treeBaseDuration = workInProgress.selfBaseDuration;
  16032. // When a fiber is cloned, its actualDuration is reset to 0.
  16033. // This value will only be updated if work is done on the fiber (i.e. it doesn't bailout).
  16034. // When work is done, it should bubble to the parent's actualDuration.
  16035. // If the fiber has not been cloned though, (meaning no work was done),
  16036. // Then this value will reflect the amount of time spent working on a previous render.
  16037. // In that case it should not bubble.
  16038. // We determine whether it was cloned by comparing the child pointer.
  16039. var shouldBubbleActualDurations = workInProgress.alternate === null || workInProgress.child !== workInProgress.alternate.child;
  16040. var child = workInProgress.child;
  16041. while (child !== null) {
  16042. var childUpdateExpirationTime = child.expirationTime;
  16043. var childChildExpirationTime = child.childExpirationTime;
  16044. if (childUpdateExpirationTime > newChildExpirationTime) {
  16045. newChildExpirationTime = childUpdateExpirationTime;
  16046. }
  16047. if (childChildExpirationTime > newChildExpirationTime) {
  16048. newChildExpirationTime = childChildExpirationTime;
  16049. }
  16050. if (shouldBubbleActualDurations) {
  16051. actualDuration += child.actualDuration;
  16052. }
  16053. treeBaseDuration += child.treeBaseDuration;
  16054. child = child.sibling;
  16055. }
  16056. workInProgress.actualDuration = actualDuration;
  16057. workInProgress.treeBaseDuration = treeBaseDuration;
  16058. } else {
  16059. var _child = workInProgress.child;
  16060. while (_child !== null) {
  16061. var _childUpdateExpirationTime = _child.expirationTime;
  16062. var _childChildExpirationTime = _child.childExpirationTime;
  16063. if (_childUpdateExpirationTime > newChildExpirationTime) {
  16064. newChildExpirationTime = _childUpdateExpirationTime;
  16065. }
  16066. if (_childChildExpirationTime > newChildExpirationTime) {
  16067. newChildExpirationTime = _childChildExpirationTime;
  16068. }
  16069. _child = _child.sibling;
  16070. }
  16071. }
  16072. workInProgress.childExpirationTime = newChildExpirationTime;
  16073. }
  16074. function completeUnitOfWork(workInProgress) {
  16075. // Attempt to complete the current unit of work, then move to the
  16076. // next sibling. If there are no more siblings, return to the
  16077. // parent fiber.
  16078. while (true) {
  16079. // The current, flushed, state of this fiber is the alternate.
  16080. // Ideally nothing should rely on this, but relying on it here
  16081. // means that we don't need an additional field on the work in
  16082. // progress.
  16083. var current$$1 = workInProgress.alternate;
  16084. {
  16085. setCurrentFiber(workInProgress);
  16086. }
  16087. var returnFiber = workInProgress.return;
  16088. var siblingFiber = workInProgress.sibling;
  16089. if ((workInProgress.effectTag & Incomplete) === NoEffect) {
  16090. if ( true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
  16091. // Don't replay if it fails during completion phase.
  16092. mayReplayFailedUnitOfWork = false;
  16093. }
  16094. // This fiber completed.
  16095. // Remember we're completing this unit so we can find a boundary if it fails.
  16096. nextUnitOfWork = workInProgress;
  16097. if (enableProfilerTimer) {
  16098. if (workInProgress.mode & ProfileMode) {
  16099. startProfilerTimer(workInProgress);
  16100. }
  16101. nextUnitOfWork = completeWork(current$$1, workInProgress, nextRenderExpirationTime);
  16102. if (workInProgress.mode & ProfileMode) {
  16103. // Update render duration assuming we didn't error.
  16104. stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
  16105. }
  16106. } else {
  16107. nextUnitOfWork = completeWork(current$$1, workInProgress, nextRenderExpirationTime);
  16108. }
  16109. if ( true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
  16110. // We're out of completion phase so replaying is fine now.
  16111. mayReplayFailedUnitOfWork = true;
  16112. }
  16113. stopWorkTimer(workInProgress);
  16114. resetChildExpirationTime(workInProgress, nextRenderExpirationTime);
  16115. {
  16116. resetCurrentFiber();
  16117. }
  16118. if (nextUnitOfWork !== null) {
  16119. // Completing this fiber spawned new work. Work on that next.
  16120. return nextUnitOfWork;
  16121. }
  16122. if (returnFiber !== null &&
  16123. // Do not append effects to parents if a sibling failed to complete
  16124. (returnFiber.effectTag & Incomplete) === NoEffect) {
  16125. // Append all the effects of the subtree and this fiber onto the effect
  16126. // list of the parent. The completion order of the children affects the
  16127. // side-effect order.
  16128. if (returnFiber.firstEffect === null) {
  16129. returnFiber.firstEffect = workInProgress.firstEffect;
  16130. }
  16131. if (workInProgress.lastEffect !== null) {
  16132. if (returnFiber.lastEffect !== null) {
  16133. returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
  16134. }
  16135. returnFiber.lastEffect = workInProgress.lastEffect;
  16136. }
  16137. // If this fiber had side-effects, we append it AFTER the children's
  16138. // side-effects. We can perform certain side-effects earlier if
  16139. // needed, by doing multiple passes over the effect list. We don't want
  16140. // to schedule our own side-effect on our own list because if end up
  16141. // reusing children we'll schedule this effect onto itself since we're
  16142. // at the end.
  16143. var effectTag = workInProgress.effectTag;
  16144. // Skip both NoWork and PerformedWork tags when creating the effect list.
  16145. // PerformedWork effect is read by React DevTools but shouldn't be committed.
  16146. if (effectTag > PerformedWork) {
  16147. if (returnFiber.lastEffect !== null) {
  16148. returnFiber.lastEffect.nextEffect = workInProgress;
  16149. } else {
  16150. returnFiber.firstEffect = workInProgress;
  16151. }
  16152. returnFiber.lastEffect = workInProgress;
  16153. }
  16154. }
  16155. if ( true && ReactFiberInstrumentation_1.debugTool) {
  16156. ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
  16157. }
  16158. if (siblingFiber !== null) {
  16159. // If there is more work to do in this returnFiber, do that next.
  16160. return siblingFiber;
  16161. } else if (returnFiber !== null) {
  16162. // If there's no more work in this returnFiber. Complete the returnFiber.
  16163. workInProgress = returnFiber;
  16164. continue;
  16165. } else {
  16166. // We've reached the root.
  16167. return null;
  16168. }
  16169. } else {
  16170. if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
  16171. // Record the render duration for the fiber that errored.
  16172. stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
  16173. // Include the time spent working on failed children before continuing.
  16174. var actualDuration = workInProgress.actualDuration;
  16175. var child = workInProgress.child;
  16176. while (child !== null) {
  16177. actualDuration += child.actualDuration;
  16178. child = child.sibling;
  16179. }
  16180. workInProgress.actualDuration = actualDuration;
  16181. }
  16182. // This fiber did not complete because something threw. Pop values off
  16183. // the stack without entering the complete phase. If this is a boundary,
  16184. // capture values if possible.
  16185. var next = unwindWork(workInProgress, nextRenderExpirationTime);
  16186. // Because this fiber did not complete, don't reset its expiration time.
  16187. if (workInProgress.effectTag & DidCapture) {
  16188. // Restarting an error boundary
  16189. stopFailedWorkTimer(workInProgress);
  16190. } else {
  16191. stopWorkTimer(workInProgress);
  16192. }
  16193. {
  16194. resetCurrentFiber();
  16195. }
  16196. if (next !== null) {
  16197. stopWorkTimer(workInProgress);
  16198. if ( true && ReactFiberInstrumentation_1.debugTool) {
  16199. ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
  16200. }
  16201. // If completing this work spawned new work, do that next. We'll come
  16202. // back here again.
  16203. // Since we're restarting, remove anything that is not a host effect
  16204. // from the effect tag.
  16205. next.effectTag &= HostEffectMask;
  16206. return next;
  16207. }
  16208. if (returnFiber !== null) {
  16209. // Mark the parent fiber as incomplete and clear its effect list.
  16210. returnFiber.firstEffect = returnFiber.lastEffect = null;
  16211. returnFiber.effectTag |= Incomplete;
  16212. }
  16213. if ( true && ReactFiberInstrumentation_1.debugTool) {
  16214. ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
  16215. }
  16216. if (siblingFiber !== null) {
  16217. // If there is more work to do in this returnFiber, do that next.
  16218. return siblingFiber;
  16219. } else if (returnFiber !== null) {
  16220. // If there's no more work in this returnFiber. Complete the returnFiber.
  16221. workInProgress = returnFiber;
  16222. continue;
  16223. } else {
  16224. return null;
  16225. }
  16226. }
  16227. }
  16228. // Without this explicit null return Flow complains of invalid return type
  16229. // TODO Remove the above while(true) loop
  16230. // eslint-disable-next-line no-unreachable
  16231. return null;
  16232. }
  16233. function performUnitOfWork(workInProgress) {
  16234. // The current, flushed, state of this fiber is the alternate.
  16235. // Ideally nothing should rely on this, but relying on it here
  16236. // means that we don't need an additional field on the work in
  16237. // progress.
  16238. var current$$1 = workInProgress.alternate;
  16239. // See if beginning this work spawns more work.
  16240. startWorkTimer(workInProgress);
  16241. {
  16242. setCurrentFiber(workInProgress);
  16243. }
  16244. if ( true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
  16245. stashedWorkInProgressProperties = assignFiberPropertiesInDEV(stashedWorkInProgressProperties, workInProgress);
  16246. }
  16247. var next = void 0;
  16248. if (enableProfilerTimer) {
  16249. if (workInProgress.mode & ProfileMode) {
  16250. startProfilerTimer(workInProgress);
  16251. }
  16252. next = beginWork(current$$1, workInProgress, nextRenderExpirationTime);
  16253. workInProgress.memoizedProps = workInProgress.pendingProps;
  16254. if (workInProgress.mode & ProfileMode) {
  16255. // Record the render duration assuming we didn't bailout (or error).
  16256. stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true);
  16257. }
  16258. } else {
  16259. next = beginWork(current$$1, workInProgress, nextRenderExpirationTime);
  16260. workInProgress.memoizedProps = workInProgress.pendingProps;
  16261. }
  16262. {
  16263. resetCurrentFiber();
  16264. if (isReplayingFailedUnitOfWork) {
  16265. // Currently replaying a failed unit of work. This should be unreachable,
  16266. // because the render phase is meant to be idempotent, and it should
  16267. // have thrown again. Since it didn't, rethrow the original error, so
  16268. // React's internal stack is not misaligned.
  16269. rethrowOriginalError();
  16270. }
  16271. }
  16272. if ( true && ReactFiberInstrumentation_1.debugTool) {
  16273. ReactFiberInstrumentation_1.debugTool.onBeginWork(workInProgress);
  16274. }
  16275. if (next === null) {
  16276. // If this doesn't spawn new work, complete the current work.
  16277. next = completeUnitOfWork(workInProgress);
  16278. }
  16279. ReactCurrentOwner$2.current = null;
  16280. return next;
  16281. }
  16282. function workLoop(isYieldy) {
  16283. if (!isYieldy) {
  16284. // Flush work without yielding
  16285. while (nextUnitOfWork !== null) {
  16286. nextUnitOfWork = performUnitOfWork(nextUnitOfWork);
  16287. }
  16288. } else {
  16289. // Flush asynchronous work until there's a higher priority event
  16290. while (nextUnitOfWork !== null && !shouldYieldToRenderer()) {
  16291. nextUnitOfWork = performUnitOfWork(nextUnitOfWork);
  16292. }
  16293. }
  16294. }
  16295. function renderRoot(root, isYieldy) {
  16296. !!isWorking ? invariant(false, 'renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  16297. flushPassiveEffects();
  16298. isWorking = true;
  16299. if (enableHooks) {
  16300. ReactCurrentOwner$2.currentDispatcher = Dispatcher;
  16301. } else {
  16302. ReactCurrentOwner$2.currentDispatcher = DispatcherWithoutHooks;
  16303. }
  16304. var expirationTime = root.nextExpirationTimeToWorkOn;
  16305. // Check if we're starting from a fresh stack, or if we're resuming from
  16306. // previously yielded work.
  16307. if (expirationTime !== nextRenderExpirationTime || root !== nextRoot || nextUnitOfWork === null) {
  16308. // Reset the stack and start working from the root.
  16309. resetStack();
  16310. nextRoot = root;
  16311. nextRenderExpirationTime = expirationTime;
  16312. nextUnitOfWork = createWorkInProgress(nextRoot.current, null, nextRenderExpirationTime);
  16313. root.pendingCommitExpirationTime = NoWork;
  16314. if (enableSchedulerTracing) {
  16315. // Determine which interactions this batch of work currently includes,
  16316. // So that we can accurately attribute time spent working on it,
  16317. var interactions = new Set();
  16318. root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
  16319. if (scheduledExpirationTime >= expirationTime) {
  16320. scheduledInteractions.forEach(function (interaction) {
  16321. return interactions.add(interaction);
  16322. });
  16323. }
  16324. });
  16325. // Store the current set of interactions on the FiberRoot for a few reasons:
  16326. // We can re-use it in hot functions like renderRoot() without having to recalculate it.
  16327. // We will also use it in commitWork() to pass to any Profiler onRender() hooks.
  16328. // This also provides DevTools with a way to access it when the onCommitRoot() hook is called.
  16329. root.memoizedInteractions = interactions;
  16330. if (interactions.size > 0) {
  16331. var subscriber = tracing.__subscriberRef.current;
  16332. if (subscriber !== null) {
  16333. var threadID = computeThreadID(expirationTime, root.interactionThreadID);
  16334. try {
  16335. subscriber.onWorkStarted(interactions, threadID);
  16336. } catch (error) {
  16337. // Work thrown by an interaction tracing subscriber should be rethrown,
  16338. // But only once it's safe (to avoid leaveing the scheduler in an invalid state).
  16339. // Store the error for now and we'll re-throw in finishRendering().
  16340. if (!hasUnhandledError) {
  16341. hasUnhandledError = true;
  16342. unhandledError = error;
  16343. }
  16344. }
  16345. }
  16346. }
  16347. }
  16348. }
  16349. var prevInteractions = null;
  16350. if (enableSchedulerTracing) {
  16351. // We're about to start new traced work.
  16352. // Restore pending interactions so cascading work triggered during the render phase will be accounted for.
  16353. prevInteractions = tracing.__interactionsRef.current;
  16354. tracing.__interactionsRef.current = root.memoizedInteractions;
  16355. }
  16356. var didFatal = false;
  16357. startWorkLoopTimer(nextUnitOfWork);
  16358. do {
  16359. try {
  16360. workLoop(isYieldy);
  16361. } catch (thrownValue) {
  16362. resetContextDependences();
  16363. resetHooks();
  16364. // Reset in case completion throws.
  16365. // This is only used in DEV and when replaying is on.
  16366. var mayReplay = void 0;
  16367. if ( true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
  16368. mayReplay = mayReplayFailedUnitOfWork;
  16369. mayReplayFailedUnitOfWork = true;
  16370. }
  16371. if (nextUnitOfWork === null) {
  16372. // This is a fatal error.
  16373. didFatal = true;
  16374. onUncaughtError(thrownValue);
  16375. } else {
  16376. if (enableProfilerTimer && nextUnitOfWork.mode & ProfileMode) {
  16377. // Record the time spent rendering before an error was thrown.
  16378. // This avoids inaccurate Profiler durations in the case of a suspended render.
  16379. stopProfilerTimerIfRunningAndRecordDelta(nextUnitOfWork, true);
  16380. }
  16381. {
  16382. // Reset global debug state
  16383. // We assume this is defined in DEV
  16384. resetCurrentlyProcessingQueue();
  16385. }
  16386. if ( true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
  16387. if (mayReplay) {
  16388. var failedUnitOfWork = nextUnitOfWork;
  16389. replayUnitOfWork(failedUnitOfWork, thrownValue, isYieldy);
  16390. }
  16391. }
  16392. // TODO: we already know this isn't true in some cases.
  16393. // At least this shows a nicer error message until we figure out the cause.
  16394. // https://github.com/facebook/react/issues/12449#issuecomment-386727431
  16395. !(nextUnitOfWork !== null) ? invariant(false, 'Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it.') : void 0;
  16396. var sourceFiber = nextUnitOfWork;
  16397. var returnFiber = sourceFiber.return;
  16398. if (returnFiber === null) {
  16399. // This is the root. The root could capture its own errors. However,
  16400. // we don't know if it errors before or after we pushed the host
  16401. // context. This information is needed to avoid a stack mismatch.
  16402. // Because we're not sure, treat this as a fatal error. We could track
  16403. // which phase it fails in, but doesn't seem worth it. At least
  16404. // for now.
  16405. didFatal = true;
  16406. onUncaughtError(thrownValue);
  16407. } else {
  16408. throwException(root, returnFiber, sourceFiber, thrownValue, nextRenderExpirationTime);
  16409. nextUnitOfWork = completeUnitOfWork(sourceFiber);
  16410. continue;
  16411. }
  16412. }
  16413. }
  16414. break;
  16415. } while (true);
  16416. if (enableSchedulerTracing) {
  16417. // Traced work is done for now; restore the previous interactions.
  16418. tracing.__interactionsRef.current = prevInteractions;
  16419. }
  16420. // We're done performing work. Time to clean up.
  16421. isWorking = false;
  16422. ReactCurrentOwner$2.currentDispatcher = null;
  16423. resetContextDependences();
  16424. resetHooks();
  16425. // Yield back to main thread.
  16426. if (didFatal) {
  16427. var _didCompleteRoot = false;
  16428. stopWorkLoopTimer(interruptedBy, _didCompleteRoot);
  16429. interruptedBy = null;
  16430. // There was a fatal error.
  16431. {
  16432. resetStackAfterFatalErrorInDev();
  16433. }
  16434. // `nextRoot` points to the in-progress root. A non-null value indicates
  16435. // that we're in the middle of an async render. Set it to null to indicate
  16436. // there's no more work to be done in the current batch.
  16437. nextRoot = null;
  16438. onFatal(root);
  16439. return;
  16440. }
  16441. if (nextUnitOfWork !== null) {
  16442. // There's still remaining async work in this tree, but we ran out of time
  16443. // in the current frame. Yield back to the renderer. Unless we're
  16444. // interrupted by a higher priority update, we'll continue later from where
  16445. // we left off.
  16446. var _didCompleteRoot2 = false;
  16447. stopWorkLoopTimer(interruptedBy, _didCompleteRoot2);
  16448. interruptedBy = null;
  16449. onYield(root);
  16450. return;
  16451. }
  16452. // We completed the whole tree.
  16453. var didCompleteRoot = true;
  16454. stopWorkLoopTimer(interruptedBy, didCompleteRoot);
  16455. var rootWorkInProgress = root.current.alternate;
  16456. !(rootWorkInProgress !== null) ? invariant(false, 'Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  16457. // `nextRoot` points to the in-progress root. A non-null value indicates
  16458. // that we're in the middle of an async render. Set it to null to indicate
  16459. // there's no more work to be done in the current batch.
  16460. nextRoot = null;
  16461. interruptedBy = null;
  16462. if (nextRenderDidError) {
  16463. // There was an error
  16464. if (hasLowerPriorityWork(root, expirationTime)) {
  16465. // There's lower priority work. If so, it may have the effect of fixing
  16466. // the exception that was just thrown. Exit without committing. This is
  16467. // similar to a suspend, but without a timeout because we're not waiting
  16468. // for a promise to resolve. React will restart at the lower
  16469. // priority level.
  16470. markSuspendedPriorityLevel(root, expirationTime);
  16471. var suspendedExpirationTime = expirationTime;
  16472. var rootExpirationTime = root.expirationTime;
  16473. onSuspend(root, rootWorkInProgress, suspendedExpirationTime, rootExpirationTime, -1 // Indicates no timeout
  16474. );
  16475. return;
  16476. } else if (
  16477. // There's no lower priority work, but we're rendering asynchronously.
  16478. // Synchronsouly attempt to render the same level one more time. This is
  16479. // similar to a suspend, but without a timeout because we're not waiting
  16480. // for a promise to resolve.
  16481. !root.didError && isYieldy) {
  16482. root.didError = true;
  16483. var _suspendedExpirationTime = root.nextExpirationTimeToWorkOn = expirationTime;
  16484. var _rootExpirationTime = root.expirationTime = Sync;
  16485. onSuspend(root, rootWorkInProgress, _suspendedExpirationTime, _rootExpirationTime, -1 // Indicates no timeout
  16486. );
  16487. return;
  16488. }
  16489. }
  16490. if (isYieldy && nextLatestAbsoluteTimeoutMs !== -1) {
  16491. // The tree was suspended.
  16492. var _suspendedExpirationTime2 = expirationTime;
  16493. markSuspendedPriorityLevel(root, _suspendedExpirationTime2);
  16494. // Find the earliest uncommitted expiration time in the tree, including
  16495. // work that is suspended. The timeout threshold cannot be longer than
  16496. // the overall expiration.
  16497. var earliestExpirationTime = findEarliestOutstandingPriorityLevel(root, expirationTime);
  16498. var earliestExpirationTimeMs = expirationTimeToMs(earliestExpirationTime);
  16499. if (earliestExpirationTimeMs < nextLatestAbsoluteTimeoutMs) {
  16500. nextLatestAbsoluteTimeoutMs = earliestExpirationTimeMs;
  16501. }
  16502. // Subtract the current time from the absolute timeout to get the number
  16503. // of milliseconds until the timeout. In other words, convert an absolute
  16504. // timestamp to a relative time. This is the value that is passed
  16505. // to `setTimeout`.
  16506. var currentTimeMs = expirationTimeToMs(requestCurrentTime());
  16507. var msUntilTimeout = nextLatestAbsoluteTimeoutMs - currentTimeMs;
  16508. msUntilTimeout = msUntilTimeout < 0 ? 0 : msUntilTimeout;
  16509. // TODO: Account for the Just Noticeable Difference
  16510. var _rootExpirationTime2 = root.expirationTime;
  16511. onSuspend(root, rootWorkInProgress, _suspendedExpirationTime2, _rootExpirationTime2, msUntilTimeout);
  16512. return;
  16513. }
  16514. // Ready to commit.
  16515. onComplete(root, rootWorkInProgress, expirationTime);
  16516. }
  16517. function captureCommitPhaseError(sourceFiber, value) {
  16518. var expirationTime = Sync;
  16519. var fiber = sourceFiber.return;
  16520. while (fiber !== null) {
  16521. switch (fiber.tag) {
  16522. case ClassComponent:
  16523. var ctor = fiber.type;
  16524. var instance = fiber.stateNode;
  16525. if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) {
  16526. var errorInfo = createCapturedValue(value, sourceFiber);
  16527. var update = createClassErrorUpdate(fiber, errorInfo, expirationTime);
  16528. enqueueUpdate(fiber, update);
  16529. scheduleWork(fiber, expirationTime);
  16530. return;
  16531. }
  16532. break;
  16533. case HostRoot:
  16534. {
  16535. var _errorInfo = createCapturedValue(value, sourceFiber);
  16536. var _update = createRootErrorUpdate(fiber, _errorInfo, expirationTime);
  16537. enqueueUpdate(fiber, _update);
  16538. scheduleWork(fiber, expirationTime);
  16539. return;
  16540. }
  16541. }
  16542. fiber = fiber.return;
  16543. }
  16544. if (sourceFiber.tag === HostRoot) {
  16545. // Error was thrown at the root. There is no parent, so the root
  16546. // itself should capture it.
  16547. var rootFiber = sourceFiber;
  16548. var _errorInfo2 = createCapturedValue(value, rootFiber);
  16549. var _update2 = createRootErrorUpdate(rootFiber, _errorInfo2, expirationTime);
  16550. enqueueUpdate(rootFiber, _update2);
  16551. scheduleWork(rootFiber, expirationTime);
  16552. }
  16553. }
  16554. function computeThreadID(expirationTime, interactionThreadID) {
  16555. // Interaction threads are unique per root and expiration time.
  16556. return expirationTime * 1000 + interactionThreadID;
  16557. }
  16558. // Creates a unique async expiration time.
  16559. function computeUniqueAsyncExpiration() {
  16560. var currentTime = requestCurrentTime();
  16561. var result = computeAsyncExpiration(currentTime);
  16562. if (result >= lastUniqueAsyncExpiration) {
  16563. // Since we assume the current time monotonically increases, we only hit
  16564. // this branch when computeUniqueAsyncExpiration is fired multiple times
  16565. // within a 200ms window (or whatever the async bucket size is).
  16566. result = lastUniqueAsyncExpiration - 1;
  16567. }
  16568. lastUniqueAsyncExpiration = result;
  16569. return lastUniqueAsyncExpiration;
  16570. }
  16571. function computeExpirationForFiber(currentTime, fiber) {
  16572. var expirationTime = void 0;
  16573. if (expirationContext !== NoWork) {
  16574. // An explicit expiration context was set;
  16575. expirationTime = expirationContext;
  16576. } else if (isWorking) {
  16577. if (isCommitting$1) {
  16578. // Updates that occur during the commit phase should have sync priority
  16579. // by default.
  16580. expirationTime = Sync;
  16581. } else {
  16582. // Updates during the render phase should expire at the same time as
  16583. // the work that is being rendered.
  16584. expirationTime = nextRenderExpirationTime;
  16585. }
  16586. } else {
  16587. // No explicit expiration context was set, and we're not currently
  16588. // performing work. Calculate a new expiration time.
  16589. if (fiber.mode & ConcurrentMode) {
  16590. if (isBatchingInteractiveUpdates) {
  16591. // This is an interactive update
  16592. expirationTime = computeInteractiveExpiration(currentTime);
  16593. } else {
  16594. // This is an async update
  16595. expirationTime = computeAsyncExpiration(currentTime);
  16596. }
  16597. // If we're in the middle of rendering a tree, do not update at the same
  16598. // expiration time that is already rendering.
  16599. if (nextRoot !== null && expirationTime === nextRenderExpirationTime) {
  16600. expirationTime -= 1;
  16601. }
  16602. } else {
  16603. // This is a sync update
  16604. expirationTime = Sync;
  16605. }
  16606. }
  16607. if (isBatchingInteractiveUpdates) {
  16608. // This is an interactive update. Keep track of the lowest pending
  16609. // interactive expiration time. This allows us to synchronously flush
  16610. // all interactive updates when needed.
  16611. if (lowestPriorityPendingInteractiveExpirationTime === NoWork || expirationTime < lowestPriorityPendingInteractiveExpirationTime) {
  16612. lowestPriorityPendingInteractiveExpirationTime = expirationTime;
  16613. }
  16614. }
  16615. return expirationTime;
  16616. }
  16617. function renderDidSuspend(root, absoluteTimeoutMs, suspendedTime) {
  16618. // Schedule the timeout.
  16619. if (absoluteTimeoutMs >= 0 && nextLatestAbsoluteTimeoutMs < absoluteTimeoutMs) {
  16620. nextLatestAbsoluteTimeoutMs = absoluteTimeoutMs;
  16621. }
  16622. }
  16623. function renderDidError() {
  16624. nextRenderDidError = true;
  16625. }
  16626. function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) {
  16627. var retryTime = void 0;
  16628. if (isPriorityLevelSuspended(root, suspendedTime)) {
  16629. // Ping at the original level
  16630. retryTime = suspendedTime;
  16631. markPingedPriorityLevel(root, retryTime);
  16632. } else {
  16633. // Suspense already timed out. Compute a new expiration time
  16634. var currentTime = requestCurrentTime();
  16635. retryTime = computeExpirationForFiber(currentTime, boundaryFiber);
  16636. markPendingPriorityLevel(root, retryTime);
  16637. }
  16638. // TODO: If the suspense fiber has already rendered the primary children
  16639. // without suspending (that is, all of the promises have already resolved),
  16640. // we should not trigger another update here. One case this happens is when
  16641. // we are in sync mode and a single promise is thrown both on initial render
  16642. // and on update; we attach two .then(retrySuspendedRoot) callbacks and each
  16643. // one performs Sync work, rerendering the Suspense.
  16644. if ((boundaryFiber.mode & ConcurrentMode) !== NoContext) {
  16645. if (root === nextRoot && nextRenderExpirationTime === suspendedTime) {
  16646. // Received a ping at the same priority level at which we're currently
  16647. // rendering. Restart from the root.
  16648. nextRoot = null;
  16649. }
  16650. }
  16651. scheduleWorkToRoot(boundaryFiber, retryTime);
  16652. if ((boundaryFiber.mode & ConcurrentMode) === NoContext) {
  16653. // Outside of concurrent mode, we must schedule an update on the source
  16654. // fiber, too, since it already committed in an inconsistent state and
  16655. // therefore does not have any pending work.
  16656. scheduleWorkToRoot(sourceFiber, retryTime);
  16657. var sourceTag = sourceFiber.tag;
  16658. if (sourceTag === ClassComponent && sourceFiber.stateNode !== null) {
  16659. // When we try rendering again, we should not reuse the current fiber,
  16660. // since it's known to be in an inconsistent state. Use a force updte to
  16661. // prevent a bail out.
  16662. var update = createUpdate(retryTime);
  16663. update.tag = ForceUpdate;
  16664. enqueueUpdate(sourceFiber, update);
  16665. }
  16666. }
  16667. var rootExpirationTime = root.expirationTime;
  16668. if (rootExpirationTime !== NoWork) {
  16669. requestWork(root, rootExpirationTime);
  16670. }
  16671. }
  16672. function scheduleWorkToRoot(fiber, expirationTime) {
  16673. recordScheduleUpdate();
  16674. {
  16675. if (fiber.tag === ClassComponent) {
  16676. var instance = fiber.stateNode;
  16677. warnAboutInvalidUpdates(instance);
  16678. }
  16679. }
  16680. // Update the source fiber's expiration time
  16681. if (fiber.expirationTime < expirationTime) {
  16682. fiber.expirationTime = expirationTime;
  16683. }
  16684. var alternate = fiber.alternate;
  16685. if (alternate !== null && alternate.expirationTime < expirationTime) {
  16686. alternate.expirationTime = expirationTime;
  16687. }
  16688. // Walk the parent path to the root and update the child expiration time.
  16689. var node = fiber.return;
  16690. var root = null;
  16691. if (node === null && fiber.tag === HostRoot) {
  16692. root = fiber.stateNode;
  16693. } else {
  16694. while (node !== null) {
  16695. alternate = node.alternate;
  16696. if (node.childExpirationTime < expirationTime) {
  16697. node.childExpirationTime = expirationTime;
  16698. if (alternate !== null && alternate.childExpirationTime < expirationTime) {
  16699. alternate.childExpirationTime = expirationTime;
  16700. }
  16701. } else if (alternate !== null && alternate.childExpirationTime < expirationTime) {
  16702. alternate.childExpirationTime = expirationTime;
  16703. }
  16704. if (node.return === null && node.tag === HostRoot) {
  16705. root = node.stateNode;
  16706. break;
  16707. }
  16708. node = node.return;
  16709. }
  16710. }
  16711. if (enableSchedulerTracing) {
  16712. if (root !== null) {
  16713. var interactions = tracing.__interactionsRef.current;
  16714. if (interactions.size > 0) {
  16715. var pendingInteractionMap = root.pendingInteractionMap;
  16716. var pendingInteractions = pendingInteractionMap.get(expirationTime);
  16717. if (pendingInteractions != null) {
  16718. interactions.forEach(function (interaction) {
  16719. if (!pendingInteractions.has(interaction)) {
  16720. // Update the pending async work count for previously unscheduled interaction.
  16721. interaction.__count++;
  16722. }
  16723. pendingInteractions.add(interaction);
  16724. });
  16725. } else {
  16726. pendingInteractionMap.set(expirationTime, new Set(interactions));
  16727. // Update the pending async work count for the current interactions.
  16728. interactions.forEach(function (interaction) {
  16729. interaction.__count++;
  16730. });
  16731. }
  16732. var subscriber = tracing.__subscriberRef.current;
  16733. if (subscriber !== null) {
  16734. var threadID = computeThreadID(expirationTime, root.interactionThreadID);
  16735. subscriber.onWorkScheduled(interactions, threadID);
  16736. }
  16737. }
  16738. }
  16739. }
  16740. return root;
  16741. }
  16742. function scheduleWork(fiber, expirationTime) {
  16743. var root = scheduleWorkToRoot(fiber, expirationTime);
  16744. if (root === null) {
  16745. {
  16746. switch (fiber.tag) {
  16747. case ClassComponent:
  16748. warnAboutUpdateOnUnmounted(fiber, true);
  16749. break;
  16750. case FunctionComponent:
  16751. case ForwardRef:
  16752. case MemoComponent:
  16753. case SimpleMemoComponent:
  16754. warnAboutUpdateOnUnmounted(fiber, false);
  16755. break;
  16756. }
  16757. }
  16758. return;
  16759. }
  16760. if (!isWorking && nextRenderExpirationTime !== NoWork && expirationTime > nextRenderExpirationTime) {
  16761. // This is an interruption. (Used for performance tracking.)
  16762. interruptedBy = fiber;
  16763. resetStack();
  16764. }
  16765. markPendingPriorityLevel(root, expirationTime);
  16766. if (
  16767. // If we're in the render phase, we don't need to schedule this root
  16768. // for an update, because we'll do it before we exit...
  16769. !isWorking || isCommitting$1 ||
  16770. // ...unless this is a different root than the one we're rendering.
  16771. nextRoot !== root) {
  16772. var rootExpirationTime = root.expirationTime;
  16773. requestWork(root, rootExpirationTime);
  16774. }
  16775. if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
  16776. // Reset this back to zero so subsequent updates don't throw.
  16777. nestedUpdateCount = 0;
  16778. invariant(false, '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.');
  16779. }
  16780. }
  16781. function syncUpdates(fn, a, b, c, d) {
  16782. var previousExpirationContext = expirationContext;
  16783. expirationContext = Sync;
  16784. try {
  16785. return fn(a, b, c, d);
  16786. } finally {
  16787. expirationContext = previousExpirationContext;
  16788. }
  16789. }
  16790. // TODO: Everything below this is written as if it has been lifted to the
  16791. // renderers. I'll do this in a follow-up.
  16792. // Linked-list of roots
  16793. var firstScheduledRoot = null;
  16794. var lastScheduledRoot = null;
  16795. var callbackExpirationTime = NoWork;
  16796. var callbackID = void 0;
  16797. var isRendering = false;
  16798. var nextFlushedRoot = null;
  16799. var nextFlushedExpirationTime = NoWork;
  16800. var lowestPriorityPendingInteractiveExpirationTime = NoWork;
  16801. var hasUnhandledError = false;
  16802. var unhandledError = null;
  16803. var isBatchingUpdates = false;
  16804. var isUnbatchingUpdates = false;
  16805. var isBatchingInteractiveUpdates = false;
  16806. var completedBatches = null;
  16807. var originalStartTimeMs = scheduler.unstable_now();
  16808. var currentRendererTime = msToExpirationTime(originalStartTimeMs);
  16809. var currentSchedulerTime = currentRendererTime;
  16810. // Use these to prevent an infinite loop of nested updates
  16811. var NESTED_UPDATE_LIMIT = 50;
  16812. var nestedUpdateCount = 0;
  16813. var lastCommittedRootDuringThisBatch = null;
  16814. function recomputeCurrentRendererTime() {
  16815. var currentTimeMs = scheduler.unstable_now() - originalStartTimeMs;
  16816. currentRendererTime = msToExpirationTime(currentTimeMs);
  16817. }
  16818. function scheduleCallbackWithExpirationTime(root, expirationTime) {
  16819. if (callbackExpirationTime !== NoWork) {
  16820. // A callback is already scheduled. Check its expiration time (timeout).
  16821. if (expirationTime < callbackExpirationTime) {
  16822. // Existing callback has sufficient timeout. Exit.
  16823. return;
  16824. } else {
  16825. if (callbackID !== null) {
  16826. // Existing callback has insufficient timeout. Cancel and schedule a
  16827. // new one.
  16828. scheduler.unstable_cancelCallback(callbackID);
  16829. }
  16830. }
  16831. // The request callback timer is already running. Don't start a new one.
  16832. } else {
  16833. startRequestCallbackTimer();
  16834. }
  16835. callbackExpirationTime = expirationTime;
  16836. var currentMs = scheduler.unstable_now() - originalStartTimeMs;
  16837. var expirationTimeMs = expirationTimeToMs(expirationTime);
  16838. var timeout = expirationTimeMs - currentMs;
  16839. callbackID = scheduler.unstable_scheduleCallback(performAsyncWork, { timeout: timeout });
  16840. }
  16841. // For every call to renderRoot, one of onFatal, onComplete, onSuspend, and
  16842. // onYield is called upon exiting. We use these in lieu of returning a tuple.
  16843. // I've also chosen not to inline them into renderRoot because these will
  16844. // eventually be lifted into the renderer.
  16845. function onFatal(root) {
  16846. root.finishedWork = null;
  16847. }
  16848. function onComplete(root, finishedWork, expirationTime) {
  16849. root.pendingCommitExpirationTime = expirationTime;
  16850. root.finishedWork = finishedWork;
  16851. }
  16852. function onSuspend(root, finishedWork, suspendedExpirationTime, rootExpirationTime, msUntilTimeout) {
  16853. root.expirationTime = rootExpirationTime;
  16854. if (msUntilTimeout === 0 && !shouldYieldToRenderer()) {
  16855. // Don't wait an additional tick. Commit the tree immediately.
  16856. root.pendingCommitExpirationTime = suspendedExpirationTime;
  16857. root.finishedWork = finishedWork;
  16858. } else if (msUntilTimeout > 0) {
  16859. // Wait `msUntilTimeout` milliseconds before committing.
  16860. root.timeoutHandle = scheduleTimeout(onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), msUntilTimeout);
  16861. }
  16862. }
  16863. function onYield(root) {
  16864. root.finishedWork = null;
  16865. }
  16866. function onTimeout(root, finishedWork, suspendedExpirationTime) {
  16867. // The root timed out. Commit it.
  16868. root.pendingCommitExpirationTime = suspendedExpirationTime;
  16869. root.finishedWork = finishedWork;
  16870. // Read the current time before entering the commit phase. We can be
  16871. // certain this won't cause tearing related to batching of event updates
  16872. // because we're at the top of a timer event.
  16873. recomputeCurrentRendererTime();
  16874. currentSchedulerTime = currentRendererTime;
  16875. flushRoot(root, suspendedExpirationTime);
  16876. }
  16877. function onCommit(root, expirationTime) {
  16878. root.expirationTime = expirationTime;
  16879. root.finishedWork = null;
  16880. }
  16881. function requestCurrentTime() {
  16882. // requestCurrentTime is called by the scheduler to compute an expiration
  16883. // time.
  16884. //
  16885. // Expiration times are computed by adding to the current time (the start
  16886. // time). However, if two updates are scheduled within the same event, we
  16887. // should treat their start times as simultaneous, even if the actual clock
  16888. // time has advanced between the first and second call.
  16889. // In other words, because expiration times determine how updates are batched,
  16890. // we want all updates of like priority that occur within the same event to
  16891. // receive the same expiration time. Otherwise we get tearing.
  16892. //
  16893. // We keep track of two separate times: the current "renderer" time and the
  16894. // current "scheduler" time. The renderer time can be updated whenever; it
  16895. // only exists to minimize the calls performance.now.
  16896. //
  16897. // But the scheduler time can only be updated if there's no pending work, or
  16898. // if we know for certain that we're not in the middle of an event.
  16899. if (isRendering) {
  16900. // We're already rendering. Return the most recently read time.
  16901. return currentSchedulerTime;
  16902. }
  16903. // Check if there's pending work.
  16904. findHighestPriorityRoot();
  16905. if (nextFlushedExpirationTime === NoWork || nextFlushedExpirationTime === Never) {
  16906. // If there's no pending work, or if the pending work is offscreen, we can
  16907. // read the current time without risk of tearing.
  16908. recomputeCurrentRendererTime();
  16909. currentSchedulerTime = currentRendererTime;
  16910. return currentSchedulerTime;
  16911. }
  16912. // There's already pending work. We might be in the middle of a browser
  16913. // event. If we were to read the current time, it could cause multiple updates
  16914. // within the same event to receive different expiration times, leading to
  16915. // tearing. Return the last read time. During the next idle callback, the
  16916. // time will be updated.
  16917. return currentSchedulerTime;
  16918. }
  16919. // requestWork is called by the scheduler whenever a root receives an update.
  16920. // It's up to the renderer to call renderRoot at some point in the future.
  16921. function requestWork(root, expirationTime) {
  16922. addRootToSchedule(root, expirationTime);
  16923. if (isRendering) {
  16924. // Prevent reentrancy. Remaining work will be scheduled at the end of
  16925. // the currently rendering batch.
  16926. return;
  16927. }
  16928. if (isBatchingUpdates) {
  16929. // Flush work at the end of the batch.
  16930. if (isUnbatchingUpdates) {
  16931. // ...unless we're inside unbatchedUpdates, in which case we should
  16932. // flush it now.
  16933. nextFlushedRoot = root;
  16934. nextFlushedExpirationTime = Sync;
  16935. performWorkOnRoot(root, Sync, false);
  16936. }
  16937. return;
  16938. }
  16939. // TODO: Get rid of Sync and use current time?
  16940. if (expirationTime === Sync) {
  16941. performSyncWork();
  16942. } else {
  16943. scheduleCallbackWithExpirationTime(root, expirationTime);
  16944. }
  16945. }
  16946. function addRootToSchedule(root, expirationTime) {
  16947. // Add the root to the schedule.
  16948. // Check if this root is already part of the schedule.
  16949. if (root.nextScheduledRoot === null) {
  16950. // This root is not already scheduled. Add it.
  16951. root.expirationTime = expirationTime;
  16952. if (lastScheduledRoot === null) {
  16953. firstScheduledRoot = lastScheduledRoot = root;
  16954. root.nextScheduledRoot = root;
  16955. } else {
  16956. lastScheduledRoot.nextScheduledRoot = root;
  16957. lastScheduledRoot = root;
  16958. lastScheduledRoot.nextScheduledRoot = firstScheduledRoot;
  16959. }
  16960. } else {
  16961. // This root is already scheduled, but its priority may have increased.
  16962. var remainingExpirationTime = root.expirationTime;
  16963. if (expirationTime > remainingExpirationTime) {
  16964. // Update the priority.
  16965. root.expirationTime = expirationTime;
  16966. }
  16967. }
  16968. }
  16969. function findHighestPriorityRoot() {
  16970. var highestPriorityWork = NoWork;
  16971. var highestPriorityRoot = null;
  16972. if (lastScheduledRoot !== null) {
  16973. var previousScheduledRoot = lastScheduledRoot;
  16974. var root = firstScheduledRoot;
  16975. while (root !== null) {
  16976. var remainingExpirationTime = root.expirationTime;
  16977. if (remainingExpirationTime === NoWork) {
  16978. // This root no longer has work. Remove it from the scheduler.
  16979. // TODO: This check is redudant, but Flow is confused by the branch
  16980. // below where we set lastScheduledRoot to null, even though we break
  16981. // from the loop right after.
  16982. !(previousScheduledRoot !== null && lastScheduledRoot !== null) ? invariant(false, 'Should have a previous and last root. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  16983. if (root === root.nextScheduledRoot) {
  16984. // This is the only root in the list.
  16985. root.nextScheduledRoot = null;
  16986. firstScheduledRoot = lastScheduledRoot = null;
  16987. break;
  16988. } else if (root === firstScheduledRoot) {
  16989. // This is the first root in the list.
  16990. var next = root.nextScheduledRoot;
  16991. firstScheduledRoot = next;
  16992. lastScheduledRoot.nextScheduledRoot = next;
  16993. root.nextScheduledRoot = null;
  16994. } else if (root === lastScheduledRoot) {
  16995. // This is the last root in the list.
  16996. lastScheduledRoot = previousScheduledRoot;
  16997. lastScheduledRoot.nextScheduledRoot = firstScheduledRoot;
  16998. root.nextScheduledRoot = null;
  16999. break;
  17000. } else {
  17001. previousScheduledRoot.nextScheduledRoot = root.nextScheduledRoot;
  17002. root.nextScheduledRoot = null;
  17003. }
  17004. root = previousScheduledRoot.nextScheduledRoot;
  17005. } else {
  17006. if (remainingExpirationTime > highestPriorityWork) {
  17007. // Update the priority, if it's higher
  17008. highestPriorityWork = remainingExpirationTime;
  17009. highestPriorityRoot = root;
  17010. }
  17011. if (root === lastScheduledRoot) {
  17012. break;
  17013. }
  17014. if (highestPriorityWork === Sync) {
  17015. // Sync is highest priority by definition so
  17016. // we can stop searching.
  17017. break;
  17018. }
  17019. previousScheduledRoot = root;
  17020. root = root.nextScheduledRoot;
  17021. }
  17022. }
  17023. }
  17024. nextFlushedRoot = highestPriorityRoot;
  17025. nextFlushedExpirationTime = highestPriorityWork;
  17026. }
  17027. // TODO: This wrapper exists because many of the older tests (the ones that use
  17028. // flushDeferredPri) rely on the number of times `shouldYield` is called. We
  17029. // should get rid of it.
  17030. var didYield = false;
  17031. function shouldYieldToRenderer() {
  17032. if (didYield) {
  17033. return true;
  17034. }
  17035. if (scheduler.unstable_shouldYield()) {
  17036. didYield = true;
  17037. return true;
  17038. }
  17039. return false;
  17040. }
  17041. function performAsyncWork() {
  17042. try {
  17043. if (!shouldYieldToRenderer()) {
  17044. // The callback timed out. That means at least one update has expired.
  17045. // Iterate through the root schedule. If they contain expired work, set
  17046. // the next render expiration time to the current time. This has the effect
  17047. // of flushing all expired work in a single batch, instead of flushing each
  17048. // level one at a time.
  17049. if (firstScheduledRoot !== null) {
  17050. recomputeCurrentRendererTime();
  17051. var root = firstScheduledRoot;
  17052. do {
  17053. didExpireAtExpirationTime(root, currentRendererTime);
  17054. // The root schedule is circular, so this is never null.
  17055. root = root.nextScheduledRoot;
  17056. } while (root !== firstScheduledRoot);
  17057. }
  17058. }
  17059. performWork(NoWork, true);
  17060. } finally {
  17061. didYield = false;
  17062. }
  17063. }
  17064. function performSyncWork() {
  17065. performWork(Sync, false);
  17066. }
  17067. function performWork(minExpirationTime, isYieldy) {
  17068. // Keep working on roots until there's no more work, or until there's a higher
  17069. // priority event.
  17070. findHighestPriorityRoot();
  17071. if (isYieldy) {
  17072. recomputeCurrentRendererTime();
  17073. currentSchedulerTime = currentRendererTime;
  17074. if (enableUserTimingAPI) {
  17075. var didExpire = nextFlushedExpirationTime > currentRendererTime;
  17076. var timeout = expirationTimeToMs(nextFlushedExpirationTime);
  17077. stopRequestCallbackTimer(didExpire, timeout);
  17078. }
  17079. while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && minExpirationTime <= nextFlushedExpirationTime && !(didYield && currentRendererTime > nextFlushedExpirationTime)) {
  17080. performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, currentRendererTime > nextFlushedExpirationTime);
  17081. findHighestPriorityRoot();
  17082. recomputeCurrentRendererTime();
  17083. currentSchedulerTime = currentRendererTime;
  17084. }
  17085. } else {
  17086. while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && minExpirationTime <= nextFlushedExpirationTime) {
  17087. performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false);
  17088. findHighestPriorityRoot();
  17089. }
  17090. }
  17091. // We're done flushing work. Either we ran out of time in this callback,
  17092. // or there's no more work left with sufficient priority.
  17093. // If we're inside a callback, set this to false since we just completed it.
  17094. if (isYieldy) {
  17095. callbackExpirationTime = NoWork;
  17096. callbackID = null;
  17097. }
  17098. // If there's work left over, schedule a new callback.
  17099. if (nextFlushedExpirationTime !== NoWork) {
  17100. scheduleCallbackWithExpirationTime(nextFlushedRoot, nextFlushedExpirationTime);
  17101. }
  17102. // Clean-up.
  17103. finishRendering();
  17104. }
  17105. function flushRoot(root, expirationTime) {
  17106. !!isRendering ? invariant(false, 'work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method.') : void 0;
  17107. // Perform work on root as if the given expiration time is the current time.
  17108. // This has the effect of synchronously flushing all work up to and
  17109. // including the given time.
  17110. nextFlushedRoot = root;
  17111. nextFlushedExpirationTime = expirationTime;
  17112. performWorkOnRoot(root, expirationTime, false);
  17113. // Flush any sync work that was scheduled by lifecycles
  17114. performSyncWork();
  17115. }
  17116. function finishRendering() {
  17117. nestedUpdateCount = 0;
  17118. lastCommittedRootDuringThisBatch = null;
  17119. if (completedBatches !== null) {
  17120. var batches = completedBatches;
  17121. completedBatches = null;
  17122. for (var i = 0; i < batches.length; i++) {
  17123. var batch = batches[i];
  17124. try {
  17125. batch._onComplete();
  17126. } catch (error) {
  17127. if (!hasUnhandledError) {
  17128. hasUnhandledError = true;
  17129. unhandledError = error;
  17130. }
  17131. }
  17132. }
  17133. }
  17134. if (hasUnhandledError) {
  17135. var error = unhandledError;
  17136. unhandledError = null;
  17137. hasUnhandledError = false;
  17138. throw error;
  17139. }
  17140. }
  17141. function performWorkOnRoot(root, expirationTime, isYieldy) {
  17142. !!isRendering ? invariant(false, 'performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  17143. isRendering = true;
  17144. // Check if this is async work or sync/expired work.
  17145. if (!isYieldy) {
  17146. // Flush work without yielding.
  17147. // TODO: Non-yieldy work does not necessarily imply expired work. A renderer
  17148. // may want to perform some work without yielding, but also without
  17149. // requiring the root to complete (by triggering placeholders).
  17150. var finishedWork = root.finishedWork;
  17151. if (finishedWork !== null) {
  17152. // This root is already complete. We can commit it.
  17153. completeRoot(root, finishedWork, expirationTime);
  17154. } else {
  17155. root.finishedWork = null;
  17156. // If this root previously suspended, clear its existing timeout, since
  17157. // we're about to try rendering again.
  17158. var timeoutHandle = root.timeoutHandle;
  17159. if (timeoutHandle !== noTimeout) {
  17160. root.timeoutHandle = noTimeout;
  17161. // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
  17162. cancelTimeout(timeoutHandle);
  17163. }
  17164. renderRoot(root, isYieldy);
  17165. finishedWork = root.finishedWork;
  17166. if (finishedWork !== null) {
  17167. // We've completed the root. Commit it.
  17168. completeRoot(root, finishedWork, expirationTime);
  17169. }
  17170. }
  17171. } else {
  17172. // Flush async work.
  17173. var _finishedWork = root.finishedWork;
  17174. if (_finishedWork !== null) {
  17175. // This root is already complete. We can commit it.
  17176. completeRoot(root, _finishedWork, expirationTime);
  17177. } else {
  17178. root.finishedWork = null;
  17179. // If this root previously suspended, clear its existing timeout, since
  17180. // we're about to try rendering again.
  17181. var _timeoutHandle = root.timeoutHandle;
  17182. if (_timeoutHandle !== noTimeout) {
  17183. root.timeoutHandle = noTimeout;
  17184. // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
  17185. cancelTimeout(_timeoutHandle);
  17186. }
  17187. renderRoot(root, isYieldy);
  17188. _finishedWork = root.finishedWork;
  17189. if (_finishedWork !== null) {
  17190. // We've completed the root. Check the if we should yield one more time
  17191. // before committing.
  17192. if (!shouldYieldToRenderer()) {
  17193. // Still time left. Commit the root.
  17194. completeRoot(root, _finishedWork, expirationTime);
  17195. } else {
  17196. // There's no time left. Mark this root as complete. We'll come
  17197. // back and commit it later.
  17198. root.finishedWork = _finishedWork;
  17199. }
  17200. }
  17201. }
  17202. }
  17203. isRendering = false;
  17204. }
  17205. function completeRoot(root, finishedWork, expirationTime) {
  17206. // Check if there's a batch that matches this expiration time.
  17207. var firstBatch = root.firstBatch;
  17208. if (firstBatch !== null && firstBatch._expirationTime >= expirationTime) {
  17209. if (completedBatches === null) {
  17210. completedBatches = [firstBatch];
  17211. } else {
  17212. completedBatches.push(firstBatch);
  17213. }
  17214. if (firstBatch._defer) {
  17215. // This root is blocked from committing by a batch. Unschedule it until
  17216. // we receive another update.
  17217. root.finishedWork = finishedWork;
  17218. root.expirationTime = NoWork;
  17219. return;
  17220. }
  17221. }
  17222. // Commit the root.
  17223. root.finishedWork = null;
  17224. // Check if this is a nested update (a sync update scheduled during the
  17225. // commit phase).
  17226. if (root === lastCommittedRootDuringThisBatch) {
  17227. // If the next root is the same as the previous root, this is a nested
  17228. // update. To prevent an infinite loop, increment the nested update count.
  17229. nestedUpdateCount++;
  17230. } else {
  17231. // Reset whenever we switch roots.
  17232. lastCommittedRootDuringThisBatch = root;
  17233. nestedUpdateCount = 0;
  17234. }
  17235. commitRoot(root, finishedWork);
  17236. }
  17237. function onUncaughtError(error) {
  17238. !(nextFlushedRoot !== null) ? invariant(false, 'Should be working on a root. This error is likely caused by a bug in React. Please file an issue.') : void 0;
  17239. // Unschedule this root so we don't work on it again until there's
  17240. // another update.
  17241. nextFlushedRoot.expirationTime = NoWork;
  17242. if (!hasUnhandledError) {
  17243. hasUnhandledError = true;
  17244. unhandledError = error;
  17245. }
  17246. }
  17247. // TODO: Batching should be implemented at the renderer level, not inside
  17248. // the reconciler.
  17249. function batchedUpdates$1(fn, a) {
  17250. var previousIsBatchingUpdates = isBatchingUpdates;
  17251. isBatchingUpdates = true;
  17252. try {
  17253. return fn(a);
  17254. } finally {
  17255. isBatchingUpdates = previousIsBatchingUpdates;
  17256. if (!isBatchingUpdates && !isRendering) {
  17257. performSyncWork();
  17258. }
  17259. }
  17260. }
  17261. // TODO: Batching should be implemented at the renderer level, not inside
  17262. // the reconciler.
  17263. function unbatchedUpdates(fn, a) {
  17264. if (isBatchingUpdates && !isUnbatchingUpdates) {
  17265. isUnbatchingUpdates = true;
  17266. try {
  17267. return fn(a);
  17268. } finally {
  17269. isUnbatchingUpdates = false;
  17270. }
  17271. }
  17272. return fn(a);
  17273. }
  17274. // TODO: Batching should be implemented at the renderer level, not within
  17275. // the reconciler.
  17276. function flushSync(fn, a) {
  17277. !!isRendering ? invariant(false, 'flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering.') : void 0;
  17278. var previousIsBatchingUpdates = isBatchingUpdates;
  17279. isBatchingUpdates = true;
  17280. try {
  17281. return syncUpdates(fn, a);
  17282. } finally {
  17283. isBatchingUpdates = previousIsBatchingUpdates;
  17284. performSyncWork();
  17285. }
  17286. }
  17287. function interactiveUpdates$1(fn, a, b) {
  17288. if (isBatchingInteractiveUpdates) {
  17289. return fn(a, b);
  17290. }
  17291. // If there are any pending interactive updates, synchronously flush them.
  17292. // This needs to happen before we read any handlers, because the effect of
  17293. // the previous event may influence which handlers are called during
  17294. // this event.
  17295. if (!isBatchingUpdates && !isRendering && lowestPriorityPendingInteractiveExpirationTime !== NoWork) {
  17296. // Synchronously flush pending interactive updates.
  17297. performWork(lowestPriorityPendingInteractiveExpirationTime, false);
  17298. lowestPriorityPendingInteractiveExpirationTime = NoWork;
  17299. }
  17300. var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates;
  17301. var previousIsBatchingUpdates = isBatchingUpdates;
  17302. isBatchingInteractiveUpdates = true;
  17303. isBatchingUpdates = true;
  17304. try {
  17305. return fn(a, b);
  17306. } finally {
  17307. isBatchingInteractiveUpdates = previousIsBatchingInteractiveUpdates;
  17308. isBatchingUpdates = previousIsBatchingUpdates;
  17309. if (!isBatchingUpdates && !isRendering) {
  17310. performSyncWork();
  17311. }
  17312. }
  17313. }
  17314. function flushInteractiveUpdates$1() {
  17315. if (!isRendering && lowestPriorityPendingInteractiveExpirationTime !== NoWork) {
  17316. // Synchronously flush pending interactive updates.
  17317. performWork(lowestPriorityPendingInteractiveExpirationTime, false);
  17318. lowestPriorityPendingInteractiveExpirationTime = NoWork;
  17319. }
  17320. }
  17321. function flushControlled(fn) {
  17322. var previousIsBatchingUpdates = isBatchingUpdates;
  17323. isBatchingUpdates = true;
  17324. try {
  17325. syncUpdates(fn);
  17326. } finally {
  17327. isBatchingUpdates = previousIsBatchingUpdates;
  17328. if (!isBatchingUpdates && !isRendering) {
  17329. performSyncWork();
  17330. }
  17331. }
  17332. }
  17333. // 0 is PROD, 1 is DEV.
  17334. // Might add PROFILE later.
  17335. var didWarnAboutNestedUpdates = void 0;
  17336. var didWarnAboutFindNodeInStrictMode = void 0;
  17337. {
  17338. didWarnAboutNestedUpdates = false;
  17339. didWarnAboutFindNodeInStrictMode = {};
  17340. }
  17341. function getContextForSubtree(parentComponent) {
  17342. if (!parentComponent) {
  17343. return emptyContextObject;
  17344. }
  17345. var fiber = get(parentComponent);
  17346. var parentContext = findCurrentUnmaskedContext(fiber);
  17347. if (fiber.tag === ClassComponent) {
  17348. var Component = fiber.type;
  17349. if (isContextProvider(Component)) {
  17350. return processChildContext(fiber, Component, parentContext);
  17351. }
  17352. }
  17353. return parentContext;
  17354. }
  17355. function scheduleRootUpdate(current$$1, element, expirationTime, callback) {
  17356. {
  17357. if (phase === 'render' && current !== null && !didWarnAboutNestedUpdates) {
  17358. didWarnAboutNestedUpdates = true;
  17359. 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');
  17360. }
  17361. }
  17362. var update = createUpdate(expirationTime);
  17363. // Caution: React DevTools currently depends on this property
  17364. // being called "element".
  17365. update.payload = { element: element };
  17366. callback = callback === undefined ? null : callback;
  17367. if (callback !== null) {
  17368. !(typeof callback === 'function') ? warningWithoutStack$1(false, 'render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback) : void 0;
  17369. update.callback = callback;
  17370. }
  17371. flushPassiveEffects();
  17372. enqueueUpdate(current$$1, update);
  17373. scheduleWork(current$$1, expirationTime);
  17374. return expirationTime;
  17375. }
  17376. function updateContainerAtExpirationTime(element, container, parentComponent, expirationTime, callback) {
  17377. // TODO: If this is a nested container, this won't be the root.
  17378. var current$$1 = container.current;
  17379. {
  17380. if (ReactFiberInstrumentation_1.debugTool) {
  17381. if (current$$1.alternate === null) {
  17382. ReactFiberInstrumentation_1.debugTool.onMountContainer(container);
  17383. } else if (element === null) {
  17384. ReactFiberInstrumentation_1.debugTool.onUnmountContainer(container);
  17385. } else {
  17386. ReactFiberInstrumentation_1.debugTool.onUpdateContainer(container);
  17387. }
  17388. }
  17389. }
  17390. var context = getContextForSubtree(parentComponent);
  17391. if (container.context === null) {
  17392. container.context = context;
  17393. } else {
  17394. container.pendingContext = context;
  17395. }
  17396. return scheduleRootUpdate(current$$1, element, expirationTime, callback);
  17397. }
  17398. function findHostInstance(component) {
  17399. var fiber = get(component);
  17400. if (fiber === undefined) {
  17401. if (typeof component.render === 'function') {
  17402. invariant(false, 'Unable to find node on an unmounted component.');
  17403. } else {
  17404. invariant(false, 'Argument appears to not be a ReactComponent. Keys: %s', Object.keys(component));
  17405. }
  17406. }
  17407. var hostFiber = findCurrentHostFiber(fiber);
  17408. if (hostFiber === null) {
  17409. return null;
  17410. }
  17411. return hostFiber.stateNode;
  17412. }
  17413. function findHostInstanceWithWarning(component, methodName) {
  17414. {
  17415. var fiber = get(component);
  17416. if (fiber === undefined) {
  17417. if (typeof component.render === 'function') {
  17418. invariant(false, 'Unable to find node on an unmounted component.');
  17419. } else {
  17420. invariant(false, 'Argument appears to not be a ReactComponent. Keys: %s', Object.keys(component));
  17421. }
  17422. }
  17423. var hostFiber = findCurrentHostFiber(fiber);
  17424. if (hostFiber === null) {
  17425. return null;
  17426. }
  17427. if (hostFiber.mode & StrictMode) {
  17428. var componentName = getComponentName(fiber.type) || 'Component';
  17429. if (!didWarnAboutFindNodeInStrictMode[componentName]) {
  17430. didWarnAboutFindNodeInStrictMode[componentName] = true;
  17431. if (fiber.mode & StrictMode) {
  17432. 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.' + '\n%s' + '\n\nLearn more about using refs safely here:' + '\nhttps://fb.me/react-strict-mode-find-node', methodName, methodName, componentName, getStackByFiberInDevAndProd(hostFiber));
  17433. } else {
  17434. 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.' + '\n%s' + '\n\nLearn more about using refs safely here:' + '\nhttps://fb.me/react-strict-mode-find-node', methodName, methodName, componentName, getStackByFiberInDevAndProd(hostFiber));
  17435. }
  17436. }
  17437. }
  17438. return hostFiber.stateNode;
  17439. }
  17440. return findHostInstance(component);
  17441. }
  17442. function createContainer(containerInfo, isConcurrent, hydrate) {
  17443. return createFiberRoot(containerInfo, isConcurrent, hydrate);
  17444. }
  17445. function updateContainer(element, container, parentComponent, callback) {
  17446. var current$$1 = container.current;
  17447. var currentTime = requestCurrentTime();
  17448. var expirationTime = computeExpirationForFiber(currentTime, current$$1);
  17449. return updateContainerAtExpirationTime(element, container, parentComponent, expirationTime, callback);
  17450. }
  17451. function getPublicRootInstance(container) {
  17452. var containerFiber = container.current;
  17453. if (!containerFiber.child) {
  17454. return null;
  17455. }
  17456. switch (containerFiber.child.tag) {
  17457. case HostComponent:
  17458. return getPublicInstance(containerFiber.child.stateNode);
  17459. default:
  17460. return containerFiber.child.stateNode;
  17461. }
  17462. }
  17463. function findHostInstanceWithNoPortals(fiber) {
  17464. var hostFiber = findCurrentHostFiberWithNoPortals(fiber);
  17465. if (hostFiber === null) {
  17466. return null;
  17467. }
  17468. return hostFiber.stateNode;
  17469. }
  17470. function injectIntoDevTools(devToolsConfig) {
  17471. var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
  17472. return injectInternals(_assign({}, devToolsConfig, {
  17473. findHostInstanceByFiber: function (fiber) {
  17474. var hostFiber = findCurrentHostFiber(fiber);
  17475. if (hostFiber === null) {
  17476. return null;
  17477. }
  17478. return hostFiber.stateNode;
  17479. },
  17480. findFiberByHostInstance: function (instance) {
  17481. if (!findFiberByHostInstance) {
  17482. // Might not be implemented by the renderer.
  17483. return null;
  17484. }
  17485. return findFiberByHostInstance(instance);
  17486. }
  17487. }));
  17488. }
  17489. // This file intentionally does *not* have the Flow annotation.
  17490. // Don't add it. See `./inline-typed.js` for an explanation.
  17491. function createPortal$1(children, containerInfo,
  17492. // TODO: figure out the API for cross-renderer implementation.
  17493. implementation) {
  17494. var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  17495. return {
  17496. // This tag allow us to uniquely identify this as a React Portal
  17497. $$typeof: REACT_PORTAL_TYPE,
  17498. key: key == null ? null : '' + key,
  17499. children: children,
  17500. containerInfo: containerInfo,
  17501. implementation: implementation
  17502. };
  17503. }
  17504. // TODO: this is special because it gets imported during build.
  17505. var ReactVersion = '16.6.3';
  17506. // TODO: This type is shared between the reconciler and ReactDOM, but will
  17507. // eventually be lifted out to the renderer.
  17508. var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
  17509. var topLevelUpdateWarnings = void 0;
  17510. var warnOnInvalidCallback = void 0;
  17511. var didWarnAboutUnstableCreatePortal = false;
  17512. {
  17513. if (typeof Map !== 'function' ||
  17514. // $FlowIssue Flow incorrectly thinks Map has no prototype
  17515. Map.prototype == null || typeof Map.prototype.forEach !== 'function' || typeof Set !== 'function' ||
  17516. // $FlowIssue Flow incorrectly thinks Set has no prototype
  17517. Set.prototype == null || typeof Set.prototype.clear !== 'function' || typeof Set.prototype.forEach !== 'function') {
  17518. 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');
  17519. }
  17520. topLevelUpdateWarnings = function (container) {
  17521. if (container._reactRootContainer && container.nodeType !== COMMENT_NODE) {
  17522. var hostInstance = findHostInstanceWithNoPortals(container._reactRootContainer._internalRoot.current);
  17523. if (hostInstance) {
  17524. !(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;
  17525. }
  17526. }
  17527. var isRootRenderedBySomeReact = !!container._reactRootContainer;
  17528. var rootEl = getReactRootElementInContainer(container);
  17529. var hasNonRootReactChild = !!(rootEl && getInstanceFromNode$1(rootEl));
  17530. !(!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;
  17531. !(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;
  17532. };
  17533. warnOnInvalidCallback = function (callback, callerName) {
  17534. !(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;
  17535. };
  17536. }
  17537. setRestoreImplementation(restoreControlledState$1);
  17538. function ReactBatch(root) {
  17539. var expirationTime = computeUniqueAsyncExpiration();
  17540. this._expirationTime = expirationTime;
  17541. this._root = root;
  17542. this._next = null;
  17543. this._callbacks = null;
  17544. this._didComplete = false;
  17545. this._hasChildren = false;
  17546. this._children = null;
  17547. this._defer = true;
  17548. }
  17549. ReactBatch.prototype.render = function (children) {
  17550. !this._defer ? invariant(false, 'batch.render: Cannot render a batch that already committed.') : void 0;
  17551. this._hasChildren = true;
  17552. this._children = children;
  17553. var internalRoot = this._root._internalRoot;
  17554. var expirationTime = this._expirationTime;
  17555. var work = new ReactWork();
  17556. updateContainerAtExpirationTime(children, internalRoot, null, expirationTime, work._onCommit);
  17557. return work;
  17558. };
  17559. ReactBatch.prototype.then = function (onComplete) {
  17560. if (this._didComplete) {
  17561. onComplete();
  17562. return;
  17563. }
  17564. var callbacks = this._callbacks;
  17565. if (callbacks === null) {
  17566. callbacks = this._callbacks = [];
  17567. }
  17568. callbacks.push(onComplete);
  17569. };
  17570. ReactBatch.prototype.commit = function () {
  17571. var internalRoot = this._root._internalRoot;
  17572. var firstBatch = internalRoot.firstBatch;
  17573. !(this._defer && firstBatch !== null) ? invariant(false, 'batch.commit: Cannot commit a batch multiple times.') : void 0;
  17574. if (!this._hasChildren) {
  17575. // This batch is empty. Return.
  17576. this._next = null;
  17577. this._defer = false;
  17578. return;
  17579. }
  17580. var expirationTime = this._expirationTime;
  17581. // Ensure this is the first batch in the list.
  17582. if (firstBatch !== this) {
  17583. // This batch is not the earliest batch. We need to move it to the front.
  17584. // Update its expiration time to be the expiration time of the earliest
  17585. // batch, so that we can flush it without flushing the other batches.
  17586. if (this._hasChildren) {
  17587. expirationTime = this._expirationTime = firstBatch._expirationTime;
  17588. // Rendering this batch again ensures its children will be the final state
  17589. // when we flush (updates are processed in insertion order: last
  17590. // update wins).
  17591. // TODO: This forces a restart. Should we print a warning?
  17592. this.render(this._children);
  17593. }
  17594. // Remove the batch from the list.
  17595. var previous = null;
  17596. var batch = firstBatch;
  17597. while (batch !== this) {
  17598. previous = batch;
  17599. batch = batch._next;
  17600. }
  17601. !(previous !== null) ? invariant(false, 'batch.commit: Cannot commit a batch multiple times.') : void 0;
  17602. previous._next = batch._next;
  17603. // Add it to the front.
  17604. this._next = firstBatch;
  17605. firstBatch = internalRoot.firstBatch = this;
  17606. }
  17607. // Synchronously flush all the work up to this batch's expiration time.
  17608. this._defer = false;
  17609. flushRoot(internalRoot, expirationTime);
  17610. // Pop the batch from the list.
  17611. var next = this._next;
  17612. this._next = null;
  17613. firstBatch = internalRoot.firstBatch = next;
  17614. // Append the next earliest batch's children to the update queue.
  17615. if (firstBatch !== null && firstBatch._hasChildren) {
  17616. firstBatch.render(firstBatch._children);
  17617. }
  17618. };
  17619. ReactBatch.prototype._onComplete = function () {
  17620. if (this._didComplete) {
  17621. return;
  17622. }
  17623. this._didComplete = true;
  17624. var callbacks = this._callbacks;
  17625. if (callbacks === null) {
  17626. return;
  17627. }
  17628. // TODO: Error handling.
  17629. for (var i = 0; i < callbacks.length; i++) {
  17630. var _callback = callbacks[i];
  17631. _callback();
  17632. }
  17633. };
  17634. function ReactWork() {
  17635. this._callbacks = null;
  17636. this._didCommit = false;
  17637. // TODO: Avoid need to bind by replacing callbacks in the update queue with
  17638. // list of Work objects.
  17639. this._onCommit = this._onCommit.bind(this);
  17640. }
  17641. ReactWork.prototype.then = function (onCommit) {
  17642. if (this._didCommit) {
  17643. onCommit();
  17644. return;
  17645. }
  17646. var callbacks = this._callbacks;
  17647. if (callbacks === null) {
  17648. callbacks = this._callbacks = [];
  17649. }
  17650. callbacks.push(onCommit);
  17651. };
  17652. ReactWork.prototype._onCommit = function () {
  17653. if (this._didCommit) {
  17654. return;
  17655. }
  17656. this._didCommit = true;
  17657. var callbacks = this._callbacks;
  17658. if (callbacks === null) {
  17659. return;
  17660. }
  17661. // TODO: Error handling.
  17662. for (var i = 0; i < callbacks.length; i++) {
  17663. var _callback2 = callbacks[i];
  17664. !(typeof _callback2 === 'function') ? invariant(false, 'Invalid argument passed as callback. Expected a function. Instead received: %s', _callback2) : void 0;
  17665. _callback2();
  17666. }
  17667. };
  17668. function ReactRoot(container, isConcurrent, hydrate) {
  17669. var root = createContainer(container, isConcurrent, hydrate);
  17670. this._internalRoot = root;
  17671. }
  17672. ReactRoot.prototype.render = function (children, callback) {
  17673. var root = this._internalRoot;
  17674. var work = new ReactWork();
  17675. callback = callback === undefined ? null : callback;
  17676. {
  17677. warnOnInvalidCallback(callback, 'render');
  17678. }
  17679. if (callback !== null) {
  17680. work.then(callback);
  17681. }
  17682. updateContainer(children, root, null, work._onCommit);
  17683. return work;
  17684. };
  17685. ReactRoot.prototype.unmount = function (callback) {
  17686. var root = this._internalRoot;
  17687. var work = new ReactWork();
  17688. callback = callback === undefined ? null : callback;
  17689. {
  17690. warnOnInvalidCallback(callback, 'render');
  17691. }
  17692. if (callback !== null) {
  17693. work.then(callback);
  17694. }
  17695. updateContainer(null, root, null, work._onCommit);
  17696. return work;
  17697. };
  17698. ReactRoot.prototype.legacy_renderSubtreeIntoContainer = function (parentComponent, children, callback) {
  17699. var root = this._internalRoot;
  17700. var work = new ReactWork();
  17701. callback = callback === undefined ? null : callback;
  17702. {
  17703. warnOnInvalidCallback(callback, 'render');
  17704. }
  17705. if (callback !== null) {
  17706. work.then(callback);
  17707. }
  17708. updateContainer(children, root, parentComponent, work._onCommit);
  17709. return work;
  17710. };
  17711. ReactRoot.prototype.createBatch = function () {
  17712. var batch = new ReactBatch(this);
  17713. var expirationTime = batch._expirationTime;
  17714. var internalRoot = this._internalRoot;
  17715. var firstBatch = internalRoot.firstBatch;
  17716. if (firstBatch === null) {
  17717. internalRoot.firstBatch = batch;
  17718. batch._next = null;
  17719. } else {
  17720. // Insert sorted by expiration time then insertion order
  17721. var insertAfter = null;
  17722. var insertBefore = firstBatch;
  17723. while (insertBefore !== null && insertBefore._expirationTime >= expirationTime) {
  17724. insertAfter = insertBefore;
  17725. insertBefore = insertBefore._next;
  17726. }
  17727. batch._next = insertBefore;
  17728. if (insertAfter !== null) {
  17729. insertAfter._next = batch;
  17730. }
  17731. }
  17732. return batch;
  17733. };
  17734. /**
  17735. * True if the supplied DOM node is a valid node element.
  17736. *
  17737. * @param {?DOMElement} node The candidate DOM node.
  17738. * @return {boolean} True if the DOM is a valid DOM node.
  17739. * @internal
  17740. */
  17741. function isValidContainer(node) {
  17742. 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 '));
  17743. }
  17744. function getReactRootElementInContainer(container) {
  17745. if (!container) {
  17746. return null;
  17747. }
  17748. if (container.nodeType === DOCUMENT_NODE) {
  17749. return container.documentElement;
  17750. } else {
  17751. return container.firstChild;
  17752. }
  17753. }
  17754. function shouldHydrateDueToLegacyHeuristic(container) {
  17755. var rootElement = getReactRootElementInContainer(container);
  17756. return !!(rootElement && rootElement.nodeType === ELEMENT_NODE && rootElement.hasAttribute(ROOT_ATTRIBUTE_NAME));
  17757. }
  17758. setBatchingImplementation(batchedUpdates$1, interactiveUpdates$1, flushInteractiveUpdates$1);
  17759. var warnedAboutHydrateAPI = false;
  17760. function legacyCreateRootFromDOMContainer(container, forceHydrate) {
  17761. var shouldHydrate = forceHydrate || shouldHydrateDueToLegacyHeuristic(container);
  17762. // First clear any existing content.
  17763. if (!shouldHydrate) {
  17764. var warned = false;
  17765. var rootSibling = void 0;
  17766. while (rootSibling = container.lastChild) {
  17767. {
  17768. if (!warned && rootSibling.nodeType === ELEMENT_NODE && rootSibling.hasAttribute(ROOT_ATTRIBUTE_NAME)) {
  17769. warned = true;
  17770. 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.');
  17771. }
  17772. }
  17773. container.removeChild(rootSibling);
  17774. }
  17775. }
  17776. {
  17777. if (shouldHydrate && !forceHydrate && !warnedAboutHydrateAPI) {
  17778. warnedAboutHydrateAPI = true;
  17779. lowPriorityWarning$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.');
  17780. }
  17781. }
  17782. // Legacy roots are not async by default.
  17783. var isConcurrent = false;
  17784. return new ReactRoot(container, isConcurrent, shouldHydrate);
  17785. }
  17786. function legacyRenderSubtreeIntoContainer(parentComponent, children, container, forceHydrate, callback) {
  17787. // TODO: Ensure all entry points contain this check
  17788. !isValidContainer(container) ? invariant(false, 'Target container is not a DOM element.') : void 0;
  17789. {
  17790. topLevelUpdateWarnings(container);
  17791. }
  17792. // TODO: Without `any` type, Flow says "Property cannot be accessed on any
  17793. // member of intersection type." Whyyyyyy.
  17794. var root = container._reactRootContainer;
  17795. if (!root) {
  17796. // Initial mount
  17797. root = container._reactRootContainer = legacyCreateRootFromDOMContainer(container, forceHydrate);
  17798. if (typeof callback === 'function') {
  17799. var originalCallback = callback;
  17800. callback = function () {
  17801. var instance = getPublicRootInstance(root._internalRoot);
  17802. originalCallback.call(instance);
  17803. };
  17804. }
  17805. // Initial mount should not be batched.
  17806. unbatchedUpdates(function () {
  17807. if (parentComponent != null) {
  17808. root.legacy_renderSubtreeIntoContainer(parentComponent, children, callback);
  17809. } else {
  17810. root.render(children, callback);
  17811. }
  17812. });
  17813. } else {
  17814. if (typeof callback === 'function') {
  17815. var _originalCallback = callback;
  17816. callback = function () {
  17817. var instance = getPublicRootInstance(root._internalRoot);
  17818. _originalCallback.call(instance);
  17819. };
  17820. }
  17821. // Update
  17822. if (parentComponent != null) {
  17823. root.legacy_renderSubtreeIntoContainer(parentComponent, children, callback);
  17824. } else {
  17825. root.render(children, callback);
  17826. }
  17827. }
  17828. return getPublicRootInstance(root._internalRoot);
  17829. }
  17830. function createPortal(children, container) {
  17831. var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  17832. !isValidContainer(container) ? invariant(false, 'Target container is not a DOM element.') : void 0;
  17833. // TODO: pass ReactDOM portal implementation as third argument
  17834. return createPortal$1(children, container, null, key);
  17835. }
  17836. var ReactDOM = {
  17837. createPortal: createPortal,
  17838. findDOMNode: function (componentOrElement) {
  17839. {
  17840. var owner = ReactCurrentOwner.current;
  17841. if (owner !== null && owner.stateNode !== null) {
  17842. var warnedAboutRefsInRender = owner.stateNode._warnedAboutRefsInRender;
  17843. !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;
  17844. owner.stateNode._warnedAboutRefsInRender = true;
  17845. }
  17846. }
  17847. if (componentOrElement == null) {
  17848. return null;
  17849. }
  17850. if (componentOrElement.nodeType === ELEMENT_NODE) {
  17851. return componentOrElement;
  17852. }
  17853. {
  17854. return findHostInstanceWithWarning(componentOrElement, 'findDOMNode');
  17855. }
  17856. return findHostInstance(componentOrElement);
  17857. },
  17858. hydrate: function (element, container, callback) {
  17859. // TODO: throw or warn if we couldn't hydrate?
  17860. return legacyRenderSubtreeIntoContainer(null, element, container, true, callback);
  17861. },
  17862. render: function (element, container, callback) {
  17863. return legacyRenderSubtreeIntoContainer(null, element, container, false, callback);
  17864. },
  17865. unstable_renderSubtreeIntoContainer: function (parentComponent, element, containerNode, callback) {
  17866. !(parentComponent != null && has(parentComponent)) ? invariant(false, 'parentComponent must be a valid React Component') : void 0;
  17867. return legacyRenderSubtreeIntoContainer(parentComponent, element, containerNode, false, callback);
  17868. },
  17869. unmountComponentAtNode: function (container) {
  17870. !isValidContainer(container) ? invariant(false, 'unmountComponentAtNode(...): Target container is not a DOM element.') : void 0;
  17871. if (container._reactRootContainer) {
  17872. {
  17873. var rootEl = getReactRootElementInContainer(container);
  17874. var renderedByDifferentReact = rootEl && !getInstanceFromNode$1(rootEl);
  17875. !!renderedByDifferentReact ? warningWithoutStack$1(false, "unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by another copy of React.') : void 0;
  17876. }
  17877. // Unmount should not be batched.
  17878. unbatchedUpdates(function () {
  17879. legacyRenderSubtreeIntoContainer(null, null, container, false, function () {
  17880. container._reactRootContainer = null;
  17881. });
  17882. });
  17883. // If you call unmountComponentAtNode twice in quick succession, you'll
  17884. // get `true` twice. That's probably fine?
  17885. return true;
  17886. } else {
  17887. {
  17888. var _rootEl = getReactRootElementInContainer(container);
  17889. var hasNonRootReactChild = !!(_rootEl && getInstanceFromNode$1(_rootEl));
  17890. // Check if the container itself is a React root node.
  17891. var isContainerReactRoot = container.nodeType === ELEMENT_NODE && isValidContainer(container.parentNode) && !!container.parentNode._reactRootContainer;
  17892. !!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;
  17893. }
  17894. return false;
  17895. }
  17896. },
  17897. // Temporary alias since we already shipped React 16 RC with it.
  17898. // TODO: remove in React 17.
  17899. unstable_createPortal: function () {
  17900. if (!didWarnAboutUnstableCreatePortal) {
  17901. didWarnAboutUnstableCreatePortal = true;
  17902. lowPriorityWarning$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.');
  17903. }
  17904. return createPortal.apply(undefined, arguments);
  17905. },
  17906. unstable_batchedUpdates: batchedUpdates$1,
  17907. unstable_interactiveUpdates: interactiveUpdates$1,
  17908. flushSync: flushSync,
  17909. unstable_flushControlled: flushControlled,
  17910. __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
  17911. // Keep in sync with ReactDOMUnstableNativeDependencies.js
  17912. // and ReactTestUtils.js. This is an array for better minification.
  17913. Events: [getInstanceFromNode$1, getNodeFromInstance$1, getFiberCurrentPropsFromNode$1, injection.injectEventPluginsByName, eventNameDispatchConfigs, accumulateTwoPhaseDispatches, accumulateDirectDispatches, enqueueStateRestore, restoreStateIfNeeded, dispatchEvent, runEventsInBatch]
  17914. }
  17915. };
  17916. function createRoot(container, options) {
  17917. var functionName = enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot';
  17918. !isValidContainer(container) ? invariant(false, '%s(...): Target container is not a DOM element.', functionName) : void 0;
  17919. var hydrate = options != null && options.hydrate === true;
  17920. return new ReactRoot(container, true, hydrate);
  17921. }
  17922. if (enableStableConcurrentModeAPIs) {
  17923. ReactDOM.createRoot = createRoot;
  17924. } else {
  17925. ReactDOM.unstable_createRoot = createRoot;
  17926. }
  17927. var foundDevTools = injectIntoDevTools({
  17928. findFiberByHostInstance: getClosestInstanceFromNode,
  17929. bundleType: 1,
  17930. version: ReactVersion,
  17931. rendererPackageName: 'react-dom'
  17932. });
  17933. {
  17934. if (!foundDevTools && canUseDOM && window.top === window.self) {
  17935. // If we're in Chrome or Firefox, provide a download link if not installed.
  17936. if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) {
  17937. var protocol = window.location.protocol;
  17938. // Don't warn in exotic cases like chrome-extension://.
  17939. if (/^(https?|file):$/.test(protocol)) {
  17940. 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');
  17941. }
  17942. }
  17943. }
  17944. }
  17945. var ReactDOM$2 = Object.freeze({
  17946. default: ReactDOM
  17947. });
  17948. var ReactDOM$3 = ( ReactDOM$2 && ReactDOM ) || ReactDOM$2;
  17949. // TODO: decide on the top-level export form.
  17950. // This is hacky but makes it work with both Rollup and Jest.
  17951. var reactDom = ReactDOM$3.default || ReactDOM$3;
  17952. module.exports = reactDom;
  17953. })();
  17954. }
  17955. /***/ }),
  17956. /***/ "../../node_modules/react-dom/index.js":
  17957. /*!***********************************************************!*\
  17958. !*** D:/Repos/Babylon.js/node_modules/react-dom/index.js ***!
  17959. \***********************************************************/
  17960. /*! no static exports found */
  17961. /***/ (function(module, exports, __webpack_require__) {
  17962. "use strict";
  17963. function checkDCE() {
  17964. /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
  17965. if (
  17966. typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined' ||
  17967. typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== 'function'
  17968. ) {
  17969. return;
  17970. }
  17971. if (true) {
  17972. // This branch is unreachable because this function is only called
  17973. // in production, but the condition is true only in development.
  17974. // Therefore if the branch is still here, dead code elimination wasn't
  17975. // properly applied.
  17976. // Don't change the message. React DevTools relies on it. Also make sure
  17977. // this message doesn't occur elsewhere in this function, or it will cause
  17978. // a false positive.
  17979. throw new Error('^_^');
  17980. }
  17981. try {
  17982. // Verify that the code above has been dead code eliminated (DCE'd).
  17983. __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE);
  17984. } catch (err) {
  17985. // DevTools shouldn't crash React, no matter what.
  17986. // We should still report in case we break this code.
  17987. console.error(err);
  17988. }
  17989. }
  17990. if (false) {} else {
  17991. module.exports = __webpack_require__(/*! ./cjs/react-dom.development.js */ "../../node_modules/react-dom/cjs/react-dom.development.js");
  17992. }
  17993. /***/ }),
  17994. /***/ "../../node_modules/react/cjs/react.development.js":
  17995. /*!***********************************************************************!*\
  17996. !*** D:/Repos/Babylon.js/node_modules/react/cjs/react.development.js ***!
  17997. \***********************************************************************/
  17998. /*! no static exports found */
  17999. /***/ (function(module, exports, __webpack_require__) {
  18000. "use strict";
  18001. /** @license React v16.6.1
  18002. * react.development.js
  18003. *
  18004. * Copyright (c) Facebook, Inc. and its affiliates.
  18005. *
  18006. * This source code is licensed under the MIT license found in the
  18007. * LICENSE file in the root directory of this source tree.
  18008. */
  18009. if (true) {
  18010. (function() {
  18011. 'use strict';
  18012. var _assign = __webpack_require__(/*! object-assign */ "../../node_modules/object-assign/index.js");
  18013. var checkPropTypes = __webpack_require__(/*! prop-types/checkPropTypes */ "../../node_modules/prop-types/checkPropTypes.js");
  18014. // TODO: this is special because it gets imported during build.
  18015. var ReactVersion = '16.6.3';
  18016. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  18017. // nor polyfill, then a plain number is used for performance.
  18018. var hasSymbol = typeof Symbol === 'function' && Symbol.for;
  18019. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
  18020. var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
  18021. var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
  18022. var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
  18023. var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
  18024. var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
  18025. var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
  18026. var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
  18027. var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
  18028. var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
  18029. var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
  18030. var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
  18031. var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  18032. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  18033. function getIteratorFn(maybeIterable) {
  18034. if (maybeIterable === null || typeof maybeIterable !== 'object') {
  18035. return null;
  18036. }
  18037. var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
  18038. if (typeof maybeIterator === 'function') {
  18039. return maybeIterator;
  18040. }
  18041. return null;
  18042. }
  18043. var enableHooks = false;
  18044. // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
  18045. // In some cases, StrictMode should also double-render lifecycles.
  18046. // This can be confusing for tests though,
  18047. // And it can be bad for performance in production.
  18048. // This feature flag can be used to control the behavior:
  18049. // To preserve the "Pause on caught exceptions" behavior of the debugger, we
  18050. // replay the begin phase of a failed component inside invokeGuardedCallback.
  18051. // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
  18052. // Gather advanced timing metrics for Profiler subtrees.
  18053. // Trace which interactions trigger each commit.
  18054. // Only used in www builds.
  18055. // Only used in www builds.
  18056. // React Fire: prevent the value and checked attributes from syncing
  18057. // with their related DOM properties
  18058. // These APIs will no longer be "unstable" in the upcoming 16.7 release,
  18059. // Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
  18060. var enableStableConcurrentModeAPIs = false;
  18061. /**
  18062. * Use invariant() to assert state which your program assumes to be true.
  18063. *
  18064. * Provide sprintf-style format (only %s is supported) and arguments
  18065. * to provide information about what broke and what you were
  18066. * expecting.
  18067. *
  18068. * The invariant message will be stripped in production, but the invariant
  18069. * will remain to ensure logic does not differ in production.
  18070. */
  18071. var validateFormat = function () {};
  18072. {
  18073. validateFormat = function (format) {
  18074. if (format === undefined) {
  18075. throw new Error('invariant requires an error message argument');
  18076. }
  18077. };
  18078. }
  18079. function invariant(condition, format, a, b, c, d, e, f) {
  18080. validateFormat(format);
  18081. if (!condition) {
  18082. var error = void 0;
  18083. if (format === undefined) {
  18084. error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
  18085. } else {
  18086. var args = [a, b, c, d, e, f];
  18087. var argIndex = 0;
  18088. error = new Error(format.replace(/%s/g, function () {
  18089. return args[argIndex++];
  18090. }));
  18091. error.name = 'Invariant Violation';
  18092. }
  18093. error.framesToPop = 1; // we don't care about invariant's own frame
  18094. throw error;
  18095. }
  18096. }
  18097. // Relying on the `invariant()` implementation lets us
  18098. // preserve the format and params in the www builds.
  18099. /**
  18100. * Forked from fbjs/warning:
  18101. * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
  18102. *
  18103. * Only change is we use console.warn instead of console.error,
  18104. * and do nothing when 'console' is not supported.
  18105. * This really simplifies the code.
  18106. * ---
  18107. * Similar to invariant but only logs a warning if the condition is not met.
  18108. * This can be used to log issues in development environments in critical
  18109. * paths. Removing the logging code for production environments will keep the
  18110. * same logic and follow the same code paths.
  18111. */
  18112. var lowPriorityWarning = function () {};
  18113. {
  18114. var printWarning = function (format) {
  18115. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  18116. args[_key - 1] = arguments[_key];
  18117. }
  18118. var argIndex = 0;
  18119. var message = 'Warning: ' + format.replace(/%s/g, function () {
  18120. return args[argIndex++];
  18121. });
  18122. if (typeof console !== 'undefined') {
  18123. console.warn(message);
  18124. }
  18125. try {
  18126. // --- Welcome to debugging React ---
  18127. // This error was thrown as a convenience so that you can use this stack
  18128. // to find the callsite that caused this warning to fire.
  18129. throw new Error(message);
  18130. } catch (x) {}
  18131. };
  18132. lowPriorityWarning = function (condition, format) {
  18133. if (format === undefined) {
  18134. throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
  18135. }
  18136. if (!condition) {
  18137. for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  18138. args[_key2 - 2] = arguments[_key2];
  18139. }
  18140. printWarning.apply(undefined, [format].concat(args));
  18141. }
  18142. };
  18143. }
  18144. var lowPriorityWarning$1 = lowPriorityWarning;
  18145. /**
  18146. * Similar to invariant but only logs a warning if the condition is not met.
  18147. * This can be used to log issues in development environments in critical
  18148. * paths. Removing the logging code for production environments will keep the
  18149. * same logic and follow the same code paths.
  18150. */
  18151. var warningWithoutStack = function () {};
  18152. {
  18153. warningWithoutStack = function (condition, format) {
  18154. for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  18155. args[_key - 2] = arguments[_key];
  18156. }
  18157. if (format === undefined) {
  18158. throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
  18159. }
  18160. if (args.length > 8) {
  18161. // Check before the condition to catch violations early.
  18162. throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
  18163. }
  18164. if (condition) {
  18165. return;
  18166. }
  18167. if (typeof console !== 'undefined') {
  18168. var argsWithFormat = args.map(function (item) {
  18169. return '' + item;
  18170. });
  18171. argsWithFormat.unshift('Warning: ' + format);
  18172. // We intentionally don't use spread (or .apply) directly because it
  18173. // breaks IE9: https://github.com/facebook/react/issues/13610
  18174. Function.prototype.apply.call(console.error, console, argsWithFormat);
  18175. }
  18176. try {
  18177. // --- Welcome to debugging React ---
  18178. // This error was thrown as a convenience so that you can use this stack
  18179. // to find the callsite that caused this warning to fire.
  18180. var argIndex = 0;
  18181. var message = 'Warning: ' + format.replace(/%s/g, function () {
  18182. return args[argIndex++];
  18183. });
  18184. throw new Error(message);
  18185. } catch (x) {}
  18186. };
  18187. }
  18188. var warningWithoutStack$1 = warningWithoutStack;
  18189. var didWarnStateUpdateForUnmountedComponent = {};
  18190. function warnNoop(publicInstance, callerName) {
  18191. {
  18192. var _constructor = publicInstance.constructor;
  18193. var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
  18194. var warningKey = componentName + '.' + callerName;
  18195. if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
  18196. return;
  18197. }
  18198. warningWithoutStack$1(false, "Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName);
  18199. didWarnStateUpdateForUnmountedComponent[warningKey] = true;
  18200. }
  18201. }
  18202. /**
  18203. * This is the abstract API for an update queue.
  18204. */
  18205. var ReactNoopUpdateQueue = {
  18206. /**
  18207. * Checks whether or not this composite component is mounted.
  18208. * @param {ReactClass} publicInstance The instance we want to test.
  18209. * @return {boolean} True if mounted, false otherwise.
  18210. * @protected
  18211. * @final
  18212. */
  18213. isMounted: function (publicInstance) {
  18214. return false;
  18215. },
  18216. /**
  18217. * Forces an update. This should only be invoked when it is known with
  18218. * certainty that we are **not** in a DOM transaction.
  18219. *
  18220. * You may want to call this when you know that some deeper aspect of the
  18221. * component's state has changed but `setState` was not called.
  18222. *
  18223. * This will not invoke `shouldComponentUpdate`, but it will invoke
  18224. * `componentWillUpdate` and `componentDidUpdate`.
  18225. *
  18226. * @param {ReactClass} publicInstance The instance that should rerender.
  18227. * @param {?function} callback Called after component is updated.
  18228. * @param {?string} callerName name of the calling function in the public API.
  18229. * @internal
  18230. */
  18231. enqueueForceUpdate: function (publicInstance, callback, callerName) {
  18232. warnNoop(publicInstance, 'forceUpdate');
  18233. },
  18234. /**
  18235. * Replaces all of the state. Always use this or `setState` to mutate state.
  18236. * You should treat `this.state` as immutable.
  18237. *
  18238. * There is no guarantee that `this.state` will be immediately updated, so
  18239. * accessing `this.state` after calling this method may return the old value.
  18240. *
  18241. * @param {ReactClass} publicInstance The instance that should rerender.
  18242. * @param {object} completeState Next state.
  18243. * @param {?function} callback Called after component is updated.
  18244. * @param {?string} callerName name of the calling function in the public API.
  18245. * @internal
  18246. */
  18247. enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
  18248. warnNoop(publicInstance, 'replaceState');
  18249. },
  18250. /**
  18251. * Sets a subset of the state. This only exists because _pendingState is
  18252. * internal. This provides a merging strategy that is not available to deep
  18253. * properties which is confusing. TODO: Expose pendingState or don't use it
  18254. * during the merge.
  18255. *
  18256. * @param {ReactClass} publicInstance The instance that should rerender.
  18257. * @param {object} partialState Next partial state to be merged with state.
  18258. * @param {?function} callback Called after component is updated.
  18259. * @param {?string} Name of the calling function in the public API.
  18260. * @internal
  18261. */
  18262. enqueueSetState: function (publicInstance, partialState, callback, callerName) {
  18263. warnNoop(publicInstance, 'setState');
  18264. }
  18265. };
  18266. var emptyObject = {};
  18267. {
  18268. Object.freeze(emptyObject);
  18269. }
  18270. /**
  18271. * Base class helpers for the updating state of a component.
  18272. */
  18273. function Component(props, context, updater) {
  18274. this.props = props;
  18275. this.context = context;
  18276. // If a component has string refs, we will assign a different object later.
  18277. this.refs = emptyObject;
  18278. // We initialize the default updater but the real one gets injected by the
  18279. // renderer.
  18280. this.updater = updater || ReactNoopUpdateQueue;
  18281. }
  18282. Component.prototype.isReactComponent = {};
  18283. /**
  18284. * Sets a subset of the state. Always use this to mutate
  18285. * state. You should treat `this.state` as immutable.
  18286. *
  18287. * There is no guarantee that `this.state` will be immediately updated, so
  18288. * accessing `this.state` after calling this method may return the old value.
  18289. *
  18290. * There is no guarantee that calls to `setState` will run synchronously,
  18291. * as they may eventually be batched together. You can provide an optional
  18292. * callback that will be executed when the call to setState is actually
  18293. * completed.
  18294. *
  18295. * When a function is provided to setState, it will be called at some point in
  18296. * the future (not synchronously). It will be called with the up to date
  18297. * component arguments (state, props, context). These values can be different
  18298. * from this.* because your function may be called after receiveProps but before
  18299. * shouldComponentUpdate, and this new state, props, and context will not yet be
  18300. * assigned to this.
  18301. *
  18302. * @param {object|function} partialState Next partial state or function to
  18303. * produce next partial state to be merged with current state.
  18304. * @param {?function} callback Called after state is updated.
  18305. * @final
  18306. * @protected
  18307. */
  18308. Component.prototype.setState = function (partialState, callback) {
  18309. !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? invariant(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : void 0;
  18310. this.updater.enqueueSetState(this, partialState, callback, 'setState');
  18311. };
  18312. /**
  18313. * Forces an update. This should only be invoked when it is known with
  18314. * certainty that we are **not** in a DOM transaction.
  18315. *
  18316. * You may want to call this when you know that some deeper aspect of the
  18317. * component's state has changed but `setState` was not called.
  18318. *
  18319. * This will not invoke `shouldComponentUpdate`, but it will invoke
  18320. * `componentWillUpdate` and `componentDidUpdate`.
  18321. *
  18322. * @param {?function} callback Called after update is complete.
  18323. * @final
  18324. * @protected
  18325. */
  18326. Component.prototype.forceUpdate = function (callback) {
  18327. this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
  18328. };
  18329. /**
  18330. * Deprecated APIs. These APIs used to exist on classic React classes but since
  18331. * we would like to deprecate them, we're not going to move them over to this
  18332. * modern base class. Instead, we define a getter that warns if it's accessed.
  18333. */
  18334. {
  18335. var deprecatedAPIs = {
  18336. isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
  18337. replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
  18338. };
  18339. var defineDeprecationWarning = function (methodName, info) {
  18340. Object.defineProperty(Component.prototype, methodName, {
  18341. get: function () {
  18342. lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
  18343. return undefined;
  18344. }
  18345. });
  18346. };
  18347. for (var fnName in deprecatedAPIs) {
  18348. if (deprecatedAPIs.hasOwnProperty(fnName)) {
  18349. defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
  18350. }
  18351. }
  18352. }
  18353. function ComponentDummy() {}
  18354. ComponentDummy.prototype = Component.prototype;
  18355. /**
  18356. * Convenience component with default shallow equality check for sCU.
  18357. */
  18358. function PureComponent(props, context, updater) {
  18359. this.props = props;
  18360. this.context = context;
  18361. // If a component has string refs, we will assign a different object later.
  18362. this.refs = emptyObject;
  18363. this.updater = updater || ReactNoopUpdateQueue;
  18364. }
  18365. var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
  18366. pureComponentPrototype.constructor = PureComponent;
  18367. // Avoid an extra prototype jump for these methods.
  18368. _assign(pureComponentPrototype, Component.prototype);
  18369. pureComponentPrototype.isPureReactComponent = true;
  18370. // an immutable object with a single mutable value
  18371. function createRef() {
  18372. var refObject = {
  18373. current: null
  18374. };
  18375. {
  18376. Object.seal(refObject);
  18377. }
  18378. return refObject;
  18379. }
  18380. /**
  18381. * Keeps track of the current owner.
  18382. *
  18383. * The current owner is the component who should own any components that are
  18384. * currently being constructed.
  18385. */
  18386. var ReactCurrentOwner = {
  18387. /**
  18388. * @internal
  18389. * @type {ReactComponent}
  18390. */
  18391. current: null,
  18392. currentDispatcher: null
  18393. };
  18394. var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
  18395. var describeComponentFrame = function (name, source, ownerName) {
  18396. var sourceInfo = '';
  18397. if (source) {
  18398. var path = source.fileName;
  18399. var fileName = path.replace(BEFORE_SLASH_RE, '');
  18400. {
  18401. // In DEV, include code for a common special case:
  18402. // prefer "folder/index.js" instead of just "index.js".
  18403. if (/^index\./.test(fileName)) {
  18404. var match = path.match(BEFORE_SLASH_RE);
  18405. if (match) {
  18406. var pathBeforeSlash = match[1];
  18407. if (pathBeforeSlash) {
  18408. var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
  18409. fileName = folderName + '/' + fileName;
  18410. }
  18411. }
  18412. }
  18413. }
  18414. sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
  18415. } else if (ownerName) {
  18416. sourceInfo = ' (created by ' + ownerName + ')';
  18417. }
  18418. return '\n in ' + (name || 'Unknown') + sourceInfo;
  18419. };
  18420. var Resolved = 1;
  18421. function refineResolvedLazyComponent(lazyComponent) {
  18422. return lazyComponent._status === Resolved ? lazyComponent._result : null;
  18423. }
  18424. function getWrappedName(outerType, innerType, wrapperName) {
  18425. var functionName = innerType.displayName || innerType.name || '';
  18426. return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
  18427. }
  18428. function getComponentName(type) {
  18429. if (type == null) {
  18430. // Host root, text node or just invalid type.
  18431. return null;
  18432. }
  18433. {
  18434. if (typeof type.tag === 'number') {
  18435. warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
  18436. }
  18437. }
  18438. if (typeof type === 'function') {
  18439. return type.displayName || type.name || null;
  18440. }
  18441. if (typeof type === 'string') {
  18442. return type;
  18443. }
  18444. switch (type) {
  18445. case REACT_CONCURRENT_MODE_TYPE:
  18446. return 'ConcurrentMode';
  18447. case REACT_FRAGMENT_TYPE:
  18448. return 'Fragment';
  18449. case REACT_PORTAL_TYPE:
  18450. return 'Portal';
  18451. case REACT_PROFILER_TYPE:
  18452. return 'Profiler';
  18453. case REACT_STRICT_MODE_TYPE:
  18454. return 'StrictMode';
  18455. case REACT_SUSPENSE_TYPE:
  18456. return 'Suspense';
  18457. }
  18458. if (typeof type === 'object') {
  18459. switch (type.$$typeof) {
  18460. case REACT_CONTEXT_TYPE:
  18461. return 'Context.Consumer';
  18462. case REACT_PROVIDER_TYPE:
  18463. return 'Context.Provider';
  18464. case REACT_FORWARD_REF_TYPE:
  18465. return getWrappedName(type, type.render, 'ForwardRef');
  18466. case REACT_MEMO_TYPE:
  18467. return getComponentName(type.type);
  18468. case REACT_LAZY_TYPE:
  18469. {
  18470. var thenable = type;
  18471. var resolvedThenable = refineResolvedLazyComponent(thenable);
  18472. if (resolvedThenable) {
  18473. return getComponentName(resolvedThenable);
  18474. }
  18475. }
  18476. }
  18477. }
  18478. return null;
  18479. }
  18480. var ReactDebugCurrentFrame = {};
  18481. var currentlyValidatingElement = null;
  18482. function setCurrentlyValidatingElement(element) {
  18483. {
  18484. currentlyValidatingElement = element;
  18485. }
  18486. }
  18487. {
  18488. // Stack implementation injected by the current renderer.
  18489. ReactDebugCurrentFrame.getCurrentStack = null;
  18490. ReactDebugCurrentFrame.getStackAddendum = function () {
  18491. var stack = '';
  18492. // Add an extra top frame while an element is being validated
  18493. if (currentlyValidatingElement) {
  18494. var name = getComponentName(currentlyValidatingElement.type);
  18495. var owner = currentlyValidatingElement._owner;
  18496. stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
  18497. }
  18498. // Delegate to the injected renderer-specific implementation
  18499. var impl = ReactDebugCurrentFrame.getCurrentStack;
  18500. if (impl) {
  18501. stack += impl() || '';
  18502. }
  18503. return stack;
  18504. };
  18505. }
  18506. var ReactSharedInternals = {
  18507. ReactCurrentOwner: ReactCurrentOwner,
  18508. // Used by renderers to avoid bundling object-assign twice in UMD bundles:
  18509. assign: _assign
  18510. };
  18511. {
  18512. _assign(ReactSharedInternals, {
  18513. // These should not be included in production.
  18514. ReactDebugCurrentFrame: ReactDebugCurrentFrame,
  18515. // Shim for React DOM 16.0.0 which still destructured (but not used) this.
  18516. // TODO: remove in React 17.0.
  18517. ReactComponentTreeHook: {}
  18518. });
  18519. }
  18520. /**
  18521. * Similar to invariant but only logs a warning if the condition is not met.
  18522. * This can be used to log issues in development environments in critical
  18523. * paths. Removing the logging code for production environments will keep the
  18524. * same logic and follow the same code paths.
  18525. */
  18526. var warning = warningWithoutStack$1;
  18527. {
  18528. warning = function (condition, format) {
  18529. if (condition) {
  18530. return;
  18531. }
  18532. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  18533. var stack = ReactDebugCurrentFrame.getStackAddendum();
  18534. // eslint-disable-next-line react-internal/warning-and-invariant-args
  18535. for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  18536. args[_key - 2] = arguments[_key];
  18537. }
  18538. warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
  18539. };
  18540. }
  18541. var warning$1 = warning;
  18542. var hasOwnProperty = Object.prototype.hasOwnProperty;
  18543. var RESERVED_PROPS = {
  18544. key: true,
  18545. ref: true,
  18546. __self: true,
  18547. __source: true
  18548. };
  18549. var specialPropKeyWarningShown = void 0;
  18550. var specialPropRefWarningShown = void 0;
  18551. function hasValidRef(config) {
  18552. {
  18553. if (hasOwnProperty.call(config, 'ref')) {
  18554. var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
  18555. if (getter && getter.isReactWarning) {
  18556. return false;
  18557. }
  18558. }
  18559. }
  18560. return config.ref !== undefined;
  18561. }
  18562. function hasValidKey(config) {
  18563. {
  18564. if (hasOwnProperty.call(config, 'key')) {
  18565. var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
  18566. if (getter && getter.isReactWarning) {
  18567. return false;
  18568. }
  18569. }
  18570. }
  18571. return config.key !== undefined;
  18572. }
  18573. function defineKeyPropWarningGetter(props, displayName) {
  18574. var warnAboutAccessingKey = function () {
  18575. if (!specialPropKeyWarningShown) {
  18576. specialPropKeyWarningShown = true;
  18577. warningWithoutStack$1(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
  18578. }
  18579. };
  18580. warnAboutAccessingKey.isReactWarning = true;
  18581. Object.defineProperty(props, 'key', {
  18582. get: warnAboutAccessingKey,
  18583. configurable: true
  18584. });
  18585. }
  18586. function defineRefPropWarningGetter(props, displayName) {
  18587. var warnAboutAccessingRef = function () {
  18588. if (!specialPropRefWarningShown) {
  18589. specialPropRefWarningShown = true;
  18590. warningWithoutStack$1(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
  18591. }
  18592. };
  18593. warnAboutAccessingRef.isReactWarning = true;
  18594. Object.defineProperty(props, 'ref', {
  18595. get: warnAboutAccessingRef,
  18596. configurable: true
  18597. });
  18598. }
  18599. /**
  18600. * Factory method to create a new React element. This no longer adheres to
  18601. * the class pattern, so do not use new to call it. Also, no instanceof check
  18602. * will work. Instead test $$typeof field against Symbol.for('react.element') to check
  18603. * if something is a React Element.
  18604. *
  18605. * @param {*} type
  18606. * @param {*} key
  18607. * @param {string|object} ref
  18608. * @param {*} self A *temporary* helper to detect places where `this` is
  18609. * different from the `owner` when React.createElement is called, so that we
  18610. * can warn. We want to get rid of owner and replace string `ref`s with arrow
  18611. * functions, and as long as `this` and owner are the same, there will be no
  18612. * change in behavior.
  18613. * @param {*} source An annotation object (added by a transpiler or otherwise)
  18614. * indicating filename, line number, and/or other information.
  18615. * @param {*} owner
  18616. * @param {*} props
  18617. * @internal
  18618. */
  18619. var ReactElement = function (type, key, ref, self, source, owner, props) {
  18620. var element = {
  18621. // This tag allows us to uniquely identify this as a React Element
  18622. $$typeof: REACT_ELEMENT_TYPE,
  18623. // Built-in properties that belong on the element
  18624. type: type,
  18625. key: key,
  18626. ref: ref,
  18627. props: props,
  18628. // Record the component responsible for creating this element.
  18629. _owner: owner
  18630. };
  18631. {
  18632. // The validation flag is currently mutative. We put it on
  18633. // an external backing store so that we can freeze the whole object.
  18634. // This can be replaced with a WeakMap once they are implemented in
  18635. // commonly used development environments.
  18636. element._store = {};
  18637. // To make comparing ReactElements easier for testing purposes, we make
  18638. // the validation flag non-enumerable (where possible, which should
  18639. // include every environment we run tests in), so the test framework
  18640. // ignores it.
  18641. Object.defineProperty(element._store, 'validated', {
  18642. configurable: false,
  18643. enumerable: false,
  18644. writable: true,
  18645. value: false
  18646. });
  18647. // self and source are DEV only properties.
  18648. Object.defineProperty(element, '_self', {
  18649. configurable: false,
  18650. enumerable: false,
  18651. writable: false,
  18652. value: self
  18653. });
  18654. // Two elements created in two different places should be considered
  18655. // equal for testing purposes and therefore we hide it from enumeration.
  18656. Object.defineProperty(element, '_source', {
  18657. configurable: false,
  18658. enumerable: false,
  18659. writable: false,
  18660. value: source
  18661. });
  18662. if (Object.freeze) {
  18663. Object.freeze(element.props);
  18664. Object.freeze(element);
  18665. }
  18666. }
  18667. return element;
  18668. };
  18669. /**
  18670. * Create and return a new ReactElement of the given type.
  18671. * See https://reactjs.org/docs/react-api.html#createelement
  18672. */
  18673. function createElement(type, config, children) {
  18674. var propName = void 0;
  18675. // Reserved names are extracted
  18676. var props = {};
  18677. var key = null;
  18678. var ref = null;
  18679. var self = null;
  18680. var source = null;
  18681. if (config != null) {
  18682. if (hasValidRef(config)) {
  18683. ref = config.ref;
  18684. }
  18685. if (hasValidKey(config)) {
  18686. key = '' + config.key;
  18687. }
  18688. self = config.__self === undefined ? null : config.__self;
  18689. source = config.__source === undefined ? null : config.__source;
  18690. // Remaining properties are added to a new props object
  18691. for (propName in config) {
  18692. if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
  18693. props[propName] = config[propName];
  18694. }
  18695. }
  18696. }
  18697. // Children can be more than one argument, and those are transferred onto
  18698. // the newly allocated props object.
  18699. var childrenLength = arguments.length - 2;
  18700. if (childrenLength === 1) {
  18701. props.children = children;
  18702. } else if (childrenLength > 1) {
  18703. var childArray = Array(childrenLength);
  18704. for (var i = 0; i < childrenLength; i++) {
  18705. childArray[i] = arguments[i + 2];
  18706. }
  18707. {
  18708. if (Object.freeze) {
  18709. Object.freeze(childArray);
  18710. }
  18711. }
  18712. props.children = childArray;
  18713. }
  18714. // Resolve default props
  18715. if (type && type.defaultProps) {
  18716. var defaultProps = type.defaultProps;
  18717. for (propName in defaultProps) {
  18718. if (props[propName] === undefined) {
  18719. props[propName] = defaultProps[propName];
  18720. }
  18721. }
  18722. }
  18723. {
  18724. if (key || ref) {
  18725. var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
  18726. if (key) {
  18727. defineKeyPropWarningGetter(props, displayName);
  18728. }
  18729. if (ref) {
  18730. defineRefPropWarningGetter(props, displayName);
  18731. }
  18732. }
  18733. }
  18734. return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
  18735. }
  18736. /**
  18737. * Return a function that produces ReactElements of a given type.
  18738. * See https://reactjs.org/docs/react-api.html#createfactory
  18739. */
  18740. function cloneAndReplaceKey(oldElement, newKey) {
  18741. var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
  18742. return newElement;
  18743. }
  18744. /**
  18745. * Clone and return a new ReactElement using element as the starting point.
  18746. * See https://reactjs.org/docs/react-api.html#cloneelement
  18747. */
  18748. function cloneElement(element, config, children) {
  18749. !!(element === null || element === undefined) ? invariant(false, 'React.cloneElement(...): The argument must be a React element, but you passed %s.', element) : void 0;
  18750. var propName = void 0;
  18751. // Original props are copied
  18752. var props = _assign({}, element.props);
  18753. // Reserved names are extracted
  18754. var key = element.key;
  18755. var ref = element.ref;
  18756. // Self is preserved since the owner is preserved.
  18757. var self = element._self;
  18758. // Source is preserved since cloneElement is unlikely to be targeted by a
  18759. // transpiler, and the original source is probably a better indicator of the
  18760. // true owner.
  18761. var source = element._source;
  18762. // Owner will be preserved, unless ref is overridden
  18763. var owner = element._owner;
  18764. if (config != null) {
  18765. if (hasValidRef(config)) {
  18766. // Silently steal the ref from the parent.
  18767. ref = config.ref;
  18768. owner = ReactCurrentOwner.current;
  18769. }
  18770. if (hasValidKey(config)) {
  18771. key = '' + config.key;
  18772. }
  18773. // Remaining properties override existing props
  18774. var defaultProps = void 0;
  18775. if (element.type && element.type.defaultProps) {
  18776. defaultProps = element.type.defaultProps;
  18777. }
  18778. for (propName in config) {
  18779. if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
  18780. if (config[propName] === undefined && defaultProps !== undefined) {
  18781. // Resolve default props
  18782. props[propName] = defaultProps[propName];
  18783. } else {
  18784. props[propName] = config[propName];
  18785. }
  18786. }
  18787. }
  18788. }
  18789. // Children can be more than one argument, and those are transferred onto
  18790. // the newly allocated props object.
  18791. var childrenLength = arguments.length - 2;
  18792. if (childrenLength === 1) {
  18793. props.children = children;
  18794. } else if (childrenLength > 1) {
  18795. var childArray = Array(childrenLength);
  18796. for (var i = 0; i < childrenLength; i++) {
  18797. childArray[i] = arguments[i + 2];
  18798. }
  18799. props.children = childArray;
  18800. }
  18801. return ReactElement(element.type, key, ref, self, source, owner, props);
  18802. }
  18803. /**
  18804. * Verifies the object is a ReactElement.
  18805. * See https://reactjs.org/docs/react-api.html#isvalidelement
  18806. * @param {?object} object
  18807. * @return {boolean} True if `object` is a ReactElement.
  18808. * @final
  18809. */
  18810. function isValidElement(object) {
  18811. return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
  18812. }
  18813. var SEPARATOR = '.';
  18814. var SUBSEPARATOR = ':';
  18815. /**
  18816. * Escape and wrap key so it is safe to use as a reactid
  18817. *
  18818. * @param {string} key to be escaped.
  18819. * @return {string} the escaped key.
  18820. */
  18821. function escape(key) {
  18822. var escapeRegex = /[=:]/g;
  18823. var escaperLookup = {
  18824. '=': '=0',
  18825. ':': '=2'
  18826. };
  18827. var escapedString = ('' + key).replace(escapeRegex, function (match) {
  18828. return escaperLookup[match];
  18829. });
  18830. return '$' + escapedString;
  18831. }
  18832. /**
  18833. * TODO: Test that a single child and an array with one item have the same key
  18834. * pattern.
  18835. */
  18836. var didWarnAboutMaps = false;
  18837. var userProvidedKeyEscapeRegex = /\/+/g;
  18838. function escapeUserProvidedKey(text) {
  18839. return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
  18840. }
  18841. var POOL_SIZE = 10;
  18842. var traverseContextPool = [];
  18843. function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
  18844. if (traverseContextPool.length) {
  18845. var traverseContext = traverseContextPool.pop();
  18846. traverseContext.result = mapResult;
  18847. traverseContext.keyPrefix = keyPrefix;
  18848. traverseContext.func = mapFunction;
  18849. traverseContext.context = mapContext;
  18850. traverseContext.count = 0;
  18851. return traverseContext;
  18852. } else {
  18853. return {
  18854. result: mapResult,
  18855. keyPrefix: keyPrefix,
  18856. func: mapFunction,
  18857. context: mapContext,
  18858. count: 0
  18859. };
  18860. }
  18861. }
  18862. function releaseTraverseContext(traverseContext) {
  18863. traverseContext.result = null;
  18864. traverseContext.keyPrefix = null;
  18865. traverseContext.func = null;
  18866. traverseContext.context = null;
  18867. traverseContext.count = 0;
  18868. if (traverseContextPool.length < POOL_SIZE) {
  18869. traverseContextPool.push(traverseContext);
  18870. }
  18871. }
  18872. /**
  18873. * @param {?*} children Children tree container.
  18874. * @param {!string} nameSoFar Name of the key path so far.
  18875. * @param {!function} callback Callback to invoke with each child found.
  18876. * @param {?*} traverseContext Used to pass information throughout the traversal
  18877. * process.
  18878. * @return {!number} The number of children in this subtree.
  18879. */
  18880. function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
  18881. var type = typeof children;
  18882. if (type === 'undefined' || type === 'boolean') {
  18883. // All of the above are perceived as null.
  18884. children = null;
  18885. }
  18886. var invokeCallback = false;
  18887. if (children === null) {
  18888. invokeCallback = true;
  18889. } else {
  18890. switch (type) {
  18891. case 'string':
  18892. case 'number':
  18893. invokeCallback = true;
  18894. break;
  18895. case 'object':
  18896. switch (children.$$typeof) {
  18897. case REACT_ELEMENT_TYPE:
  18898. case REACT_PORTAL_TYPE:
  18899. invokeCallback = true;
  18900. }
  18901. }
  18902. }
  18903. if (invokeCallback) {
  18904. callback(traverseContext, children,
  18905. // If it's the only child, treat the name as if it was wrapped in an array
  18906. // so that it's consistent if the number of children grows.
  18907. nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
  18908. return 1;
  18909. }
  18910. var child = void 0;
  18911. var nextName = void 0;
  18912. var subtreeCount = 0; // Count of children found in the current subtree.
  18913. var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
  18914. if (Array.isArray(children)) {
  18915. for (var i = 0; i < children.length; i++) {
  18916. child = children[i];
  18917. nextName = nextNamePrefix + getComponentKey(child, i);
  18918. subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
  18919. }
  18920. } else {
  18921. var iteratorFn = getIteratorFn(children);
  18922. if (typeof iteratorFn === 'function') {
  18923. {
  18924. // Warn about using Maps as children
  18925. if (iteratorFn === children.entries) {
  18926. !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;
  18927. didWarnAboutMaps = true;
  18928. }
  18929. }
  18930. var iterator = iteratorFn.call(children);
  18931. var step = void 0;
  18932. var ii = 0;
  18933. while (!(step = iterator.next()).done) {
  18934. child = step.value;
  18935. nextName = nextNamePrefix + getComponentKey(child, ii++);
  18936. subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
  18937. }
  18938. } else if (type === 'object') {
  18939. var addendum = '';
  18940. {
  18941. addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
  18942. }
  18943. var childrenString = '' + children;
  18944. invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum);
  18945. }
  18946. }
  18947. return subtreeCount;
  18948. }
  18949. /**
  18950. * Traverses children that are typically specified as `props.children`, but
  18951. * might also be specified through attributes:
  18952. *
  18953. * - `traverseAllChildren(this.props.children, ...)`
  18954. * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
  18955. *
  18956. * The `traverseContext` is an optional argument that is passed through the
  18957. * entire traversal. It can be used to store accumulations or anything else that
  18958. * the callback might find relevant.
  18959. *
  18960. * @param {?*} children Children tree object.
  18961. * @param {!function} callback To invoke upon traversing each child.
  18962. * @param {?*} traverseContext Context for traversal.
  18963. * @return {!number} The number of children in this subtree.
  18964. */
  18965. function traverseAllChildren(children, callback, traverseContext) {
  18966. if (children == null) {
  18967. return 0;
  18968. }
  18969. return traverseAllChildrenImpl(children, '', callback, traverseContext);
  18970. }
  18971. /**
  18972. * Generate a key string that identifies a component within a set.
  18973. *
  18974. * @param {*} component A component that could contain a manual key.
  18975. * @param {number} index Index that is used if a manual key is not provided.
  18976. * @return {string}
  18977. */
  18978. function getComponentKey(component, index) {
  18979. // Do some typechecking here since we call this blindly. We want to ensure
  18980. // that we don't block potential future ES APIs.
  18981. if (typeof component === 'object' && component !== null && component.key != null) {
  18982. // Explicit key
  18983. return escape(component.key);
  18984. }
  18985. // Implicit key determined by the index in the set
  18986. return index.toString(36);
  18987. }
  18988. function forEachSingleChild(bookKeeping, child, name) {
  18989. var func = bookKeeping.func,
  18990. context = bookKeeping.context;
  18991. func.call(context, child, bookKeeping.count++);
  18992. }
  18993. /**
  18994. * Iterates through children that are typically specified as `props.children`.
  18995. *
  18996. * See https://reactjs.org/docs/react-api.html#reactchildrenforeach
  18997. *
  18998. * The provided forEachFunc(child, index) will be called for each
  18999. * leaf child.
  19000. *
  19001. * @param {?*} children Children tree container.
  19002. * @param {function(*, int)} forEachFunc
  19003. * @param {*} forEachContext Context for forEachContext.
  19004. */
  19005. function forEachChildren(children, forEachFunc, forEachContext) {
  19006. if (children == null) {
  19007. return children;
  19008. }
  19009. var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
  19010. traverseAllChildren(children, forEachSingleChild, traverseContext);
  19011. releaseTraverseContext(traverseContext);
  19012. }
  19013. function mapSingleChildIntoContext(bookKeeping, child, childKey) {
  19014. var result = bookKeeping.result,
  19015. keyPrefix = bookKeeping.keyPrefix,
  19016. func = bookKeeping.func,
  19017. context = bookKeeping.context;
  19018. var mappedChild = func.call(context, child, bookKeeping.count++);
  19019. if (Array.isArray(mappedChild)) {
  19020. mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) {
  19021. return c;
  19022. });
  19023. } else if (mappedChild != null) {
  19024. if (isValidElement(mappedChild)) {
  19025. mappedChild = cloneAndReplaceKey(mappedChild,
  19026. // Keep both the (mapped) and old keys if they differ, just as
  19027. // traverseAllChildren used to do for objects as children
  19028. keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
  19029. }
  19030. result.push(mappedChild);
  19031. }
  19032. }
  19033. function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
  19034. var escapedPrefix = '';
  19035. if (prefix != null) {
  19036. escapedPrefix = escapeUserProvidedKey(prefix) + '/';
  19037. }
  19038. var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
  19039. traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
  19040. releaseTraverseContext(traverseContext);
  19041. }
  19042. /**
  19043. * Maps children that are typically specified as `props.children`.
  19044. *
  19045. * See https://reactjs.org/docs/react-api.html#reactchildrenmap
  19046. *
  19047. * The provided mapFunction(child, key, index) will be called for each
  19048. * leaf child.
  19049. *
  19050. * @param {?*} children Children tree container.
  19051. * @param {function(*, int)} func The map function.
  19052. * @param {*} context Context for mapFunction.
  19053. * @return {object} Object containing the ordered map of results.
  19054. */
  19055. function mapChildren(children, func, context) {
  19056. if (children == null) {
  19057. return children;
  19058. }
  19059. var result = [];
  19060. mapIntoWithKeyPrefixInternal(children, result, null, func, context);
  19061. return result;
  19062. }
  19063. /**
  19064. * Count the number of children that are typically specified as
  19065. * `props.children`.
  19066. *
  19067. * See https://reactjs.org/docs/react-api.html#reactchildrencount
  19068. *
  19069. * @param {?*} children Children tree container.
  19070. * @return {number} The number of children.
  19071. */
  19072. function countChildren(children) {
  19073. return traverseAllChildren(children, function () {
  19074. return null;
  19075. }, null);
  19076. }
  19077. /**
  19078. * Flatten a children object (typically specified as `props.children`) and
  19079. * return an array with appropriately re-keyed children.
  19080. *
  19081. * See https://reactjs.org/docs/react-api.html#reactchildrentoarray
  19082. */
  19083. function toArray(children) {
  19084. var result = [];
  19085. mapIntoWithKeyPrefixInternal(children, result, null, function (child) {
  19086. return child;
  19087. });
  19088. return result;
  19089. }
  19090. /**
  19091. * Returns the first child in a collection of children and verifies that there
  19092. * is only one child in the collection.
  19093. *
  19094. * See https://reactjs.org/docs/react-api.html#reactchildrenonly
  19095. *
  19096. * The current implementation of this function assumes that a single child gets
  19097. * passed without a wrapper, but the purpose of this helper function is to
  19098. * abstract away the particular structure of children.
  19099. *
  19100. * @param {?object} children Child collection structure.
  19101. * @return {ReactElement} The first and only `ReactElement` contained in the
  19102. * structure.
  19103. */
  19104. function onlyChild(children) {
  19105. !isValidElement(children) ? invariant(false, 'React.Children.only expected to receive a single React element child.') : void 0;
  19106. return children;
  19107. }
  19108. function createContext(defaultValue, calculateChangedBits) {
  19109. if (calculateChangedBits === undefined) {
  19110. calculateChangedBits = null;
  19111. } else {
  19112. {
  19113. !(calculateChangedBits === null || typeof calculateChangedBits === 'function') ? warningWithoutStack$1(false, 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits) : void 0;
  19114. }
  19115. }
  19116. var context = {
  19117. $$typeof: REACT_CONTEXT_TYPE,
  19118. _calculateChangedBits: calculateChangedBits,
  19119. // As a workaround to support multiple concurrent renderers, we categorize
  19120. // some renderers as primary and others as secondary. We only expect
  19121. // there to be two concurrent renderers at most: React Native (primary) and
  19122. // Fabric (secondary); React DOM (primary) and React ART (secondary).
  19123. // Secondary renderers store their context values on separate fields.
  19124. _currentValue: defaultValue,
  19125. _currentValue2: defaultValue,
  19126. // Used to track how many concurrent renderers this context currently
  19127. // supports within in a single renderer. Such as parallel server rendering.
  19128. _threadCount: 0,
  19129. // These are circular
  19130. Provider: null,
  19131. Consumer: null
  19132. };
  19133. context.Provider = {
  19134. $$typeof: REACT_PROVIDER_TYPE,
  19135. _context: context
  19136. };
  19137. var hasWarnedAboutUsingNestedContextConsumers = false;
  19138. var hasWarnedAboutUsingConsumerProvider = false;
  19139. {
  19140. // A separate object, but proxies back to the original context object for
  19141. // backwards compatibility. It has a different $$typeof, so we can properly
  19142. // warn for the incorrect usage of Context as a Consumer.
  19143. var Consumer = {
  19144. $$typeof: REACT_CONTEXT_TYPE,
  19145. _context: context,
  19146. _calculateChangedBits: context._calculateChangedBits
  19147. };
  19148. // $FlowFixMe: Flow complains about not setting a value, which is intentional here
  19149. Object.defineProperties(Consumer, {
  19150. Provider: {
  19151. get: function () {
  19152. if (!hasWarnedAboutUsingConsumerProvider) {
  19153. hasWarnedAboutUsingConsumerProvider = true;
  19154. warning$1(false, 'Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?');
  19155. }
  19156. return context.Provider;
  19157. },
  19158. set: function (_Provider) {
  19159. context.Provider = _Provider;
  19160. }
  19161. },
  19162. _currentValue: {
  19163. get: function () {
  19164. return context._currentValue;
  19165. },
  19166. set: function (_currentValue) {
  19167. context._currentValue = _currentValue;
  19168. }
  19169. },
  19170. _currentValue2: {
  19171. get: function () {
  19172. return context._currentValue2;
  19173. },
  19174. set: function (_currentValue2) {
  19175. context._currentValue2 = _currentValue2;
  19176. }
  19177. },
  19178. _threadCount: {
  19179. get: function () {
  19180. return context._threadCount;
  19181. },
  19182. set: function (_threadCount) {
  19183. context._threadCount = _threadCount;
  19184. }
  19185. },
  19186. Consumer: {
  19187. get: function () {
  19188. if (!hasWarnedAboutUsingNestedContextConsumers) {
  19189. hasWarnedAboutUsingNestedContextConsumers = true;
  19190. warning$1(false, 'Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
  19191. }
  19192. return context.Consumer;
  19193. }
  19194. }
  19195. });
  19196. // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
  19197. context.Consumer = Consumer;
  19198. }
  19199. {
  19200. context._currentRenderer = null;
  19201. context._currentRenderer2 = null;
  19202. }
  19203. return context;
  19204. }
  19205. function lazy(ctor) {
  19206. return {
  19207. $$typeof: REACT_LAZY_TYPE,
  19208. _ctor: ctor,
  19209. // React uses these fields to store the result.
  19210. _status: -1,
  19211. _result: null
  19212. };
  19213. }
  19214. function forwardRef(render) {
  19215. {
  19216. if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
  19217. warningWithoutStack$1(false, 'forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
  19218. } else if (typeof render !== 'function') {
  19219. warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
  19220. } else {
  19221. !(
  19222. // Do not warn for 0 arguments because it could be due to usage of the 'arguments' object
  19223. render.length === 0 || render.length === 2) ? warningWithoutStack$1(false, 'forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.') : void 0;
  19224. }
  19225. if (render != null) {
  19226. !(render.defaultProps == null && render.propTypes == null) ? warningWithoutStack$1(false, 'forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?') : void 0;
  19227. }
  19228. }
  19229. return {
  19230. $$typeof: REACT_FORWARD_REF_TYPE,
  19231. render: render
  19232. };
  19233. }
  19234. function isValidElementType(type) {
  19235. return typeof type === 'string' || typeof type === 'function' ||
  19236. // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
  19237. type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
  19238. }
  19239. function memo(type, compare) {
  19240. {
  19241. if (!isValidElementType(type)) {
  19242. warningWithoutStack$1(false, 'memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
  19243. }
  19244. }
  19245. return {
  19246. $$typeof: REACT_MEMO_TYPE,
  19247. type: type,
  19248. compare: compare === undefined ? null : compare
  19249. };
  19250. }
  19251. function resolveDispatcher() {
  19252. var dispatcher = ReactCurrentOwner.currentDispatcher;
  19253. !(dispatcher !== null) ? invariant(false, 'Hooks can only be called inside the body of a function component.') : void 0;
  19254. return dispatcher;
  19255. }
  19256. function useContext(Context, observedBits) {
  19257. var dispatcher = resolveDispatcher();
  19258. {
  19259. // TODO: add a more generic warning for invalid values.
  19260. if (Context._context !== undefined) {
  19261. var realContext = Context._context;
  19262. // Don't deduplicate because this legitimately causes bugs
  19263. // and nobody should be using this in existing code.
  19264. if (realContext.Consumer === Context) {
  19265. warning$1(false, 'Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?');
  19266. } else if (realContext.Provider === Context) {
  19267. warning$1(false, 'Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
  19268. }
  19269. }
  19270. }
  19271. return dispatcher.useContext(Context, observedBits);
  19272. }
  19273. function useState(initialState) {
  19274. var dispatcher = resolveDispatcher();
  19275. return dispatcher.useState(initialState);
  19276. }
  19277. function useReducer(reducer, initialState, initialAction) {
  19278. var dispatcher = resolveDispatcher();
  19279. return dispatcher.useReducer(reducer, initialState, initialAction);
  19280. }
  19281. function useRef(initialValue) {
  19282. var dispatcher = resolveDispatcher();
  19283. return dispatcher.useRef(initialValue);
  19284. }
  19285. function useEffect(create, inputs) {
  19286. var dispatcher = resolveDispatcher();
  19287. return dispatcher.useEffect(create, inputs);
  19288. }
  19289. function useMutationEffect(create, inputs) {
  19290. var dispatcher = resolveDispatcher();
  19291. return dispatcher.useMutationEffect(create, inputs);
  19292. }
  19293. function useLayoutEffect(create, inputs) {
  19294. var dispatcher = resolveDispatcher();
  19295. return dispatcher.useLayoutEffect(create, inputs);
  19296. }
  19297. function useCallback(callback, inputs) {
  19298. var dispatcher = resolveDispatcher();
  19299. return dispatcher.useCallback(callback, inputs);
  19300. }
  19301. function useMemo(create, inputs) {
  19302. var dispatcher = resolveDispatcher();
  19303. return dispatcher.useMemo(create, inputs);
  19304. }
  19305. function useImperativeMethods(ref, create, inputs) {
  19306. var dispatcher = resolveDispatcher();
  19307. return dispatcher.useImperativeMethods(ref, create, inputs);
  19308. }
  19309. /**
  19310. * ReactElementValidator provides a wrapper around a element factory
  19311. * which validates the props passed to the element. This is intended to be
  19312. * used only in DEV and could be replaced by a static type checker for languages
  19313. * that support it.
  19314. */
  19315. var propTypesMisspellWarningShown = void 0;
  19316. {
  19317. propTypesMisspellWarningShown = false;
  19318. }
  19319. function getDeclarationErrorAddendum() {
  19320. if (ReactCurrentOwner.current) {
  19321. var name = getComponentName(ReactCurrentOwner.current.type);
  19322. if (name) {
  19323. return '\n\nCheck the render method of `' + name + '`.';
  19324. }
  19325. }
  19326. return '';
  19327. }
  19328. function getSourceInfoErrorAddendum(elementProps) {
  19329. if (elementProps !== null && elementProps !== undefined && elementProps.__source !== undefined) {
  19330. var source = elementProps.__source;
  19331. var fileName = source.fileName.replace(/^.*[\\\/]/, '');
  19332. var lineNumber = source.lineNumber;
  19333. return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
  19334. }
  19335. return '';
  19336. }
  19337. /**
  19338. * Warn if there's no key explicitly set on dynamic arrays of children or
  19339. * object keys are not valid. This allows us to keep track of children between
  19340. * updates.
  19341. */
  19342. var ownerHasKeyUseWarning = {};
  19343. function getCurrentComponentErrorInfo(parentType) {
  19344. var info = getDeclarationErrorAddendum();
  19345. if (!info) {
  19346. var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
  19347. if (parentName) {
  19348. info = '\n\nCheck the top-level render call using <' + parentName + '>.';
  19349. }
  19350. }
  19351. return info;
  19352. }
  19353. /**
  19354. * Warn if the element doesn't have an explicit key assigned to it.
  19355. * This element is in an array. The array could grow and shrink or be
  19356. * reordered. All children that haven't already been validated are required to
  19357. * have a "key" property assigned to it. Error statuses are cached so a warning
  19358. * will only be shown once.
  19359. *
  19360. * @internal
  19361. * @param {ReactElement} element Element that requires a key.
  19362. * @param {*} parentType element's parent's type.
  19363. */
  19364. function validateExplicitKey(element, parentType) {
  19365. if (!element._store || element._store.validated || element.key != null) {
  19366. return;
  19367. }
  19368. element._store.validated = true;
  19369. var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
  19370. if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
  19371. return;
  19372. }
  19373. ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
  19374. // Usually the current owner is the offender, but if it accepts children as a
  19375. // property, it may be the creator of the child that's responsible for
  19376. // assigning it a key.
  19377. var childOwner = '';
  19378. if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
  19379. // Give the component that originally created this child.
  19380. childOwner = ' It was passed a child from ' + getComponentName(element._owner.type) + '.';
  19381. }
  19382. setCurrentlyValidatingElement(element);
  19383. {
  19384. warning$1(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner);
  19385. }
  19386. setCurrentlyValidatingElement(null);
  19387. }
  19388. /**
  19389. * Ensure that every element either is passed in a static location, in an
  19390. * array with an explicit keys property defined, or in an object literal
  19391. * with valid key property.
  19392. *
  19393. * @internal
  19394. * @param {ReactNode} node Statically passed child of any type.
  19395. * @param {*} parentType node's parent's type.
  19396. */
  19397. function validateChildKeys(node, parentType) {
  19398. if (typeof node !== 'object') {
  19399. return;
  19400. }
  19401. if (Array.isArray(node)) {
  19402. for (var i = 0; i < node.length; i++) {
  19403. var child = node[i];
  19404. if (isValidElement(child)) {
  19405. validateExplicitKey(child, parentType);
  19406. }
  19407. }
  19408. } else if (isValidElement(node)) {
  19409. // This element was passed in a valid location.
  19410. if (node._store) {
  19411. node._store.validated = true;
  19412. }
  19413. } else if (node) {
  19414. var iteratorFn = getIteratorFn(node);
  19415. if (typeof iteratorFn === 'function') {
  19416. // Entry iterators used to provide implicit keys,
  19417. // but now we print a separate warning for them later.
  19418. if (iteratorFn !== node.entries) {
  19419. var iterator = iteratorFn.call(node);
  19420. var step = void 0;
  19421. while (!(step = iterator.next()).done) {
  19422. if (isValidElement(step.value)) {
  19423. validateExplicitKey(step.value, parentType);
  19424. }
  19425. }
  19426. }
  19427. }
  19428. }
  19429. }
  19430. /**
  19431. * Given an element, validate that its props follow the propTypes definition,
  19432. * provided by the type.
  19433. *
  19434. * @param {ReactElement} element
  19435. */
  19436. function validatePropTypes(element) {
  19437. var type = element.type;
  19438. var name = void 0,
  19439. propTypes = void 0;
  19440. if (typeof type === 'function') {
  19441. // Class or function component
  19442. name = type.displayName || type.name;
  19443. propTypes = type.propTypes;
  19444. } else if (typeof type === 'object' && type !== null && type.$$typeof === REACT_FORWARD_REF_TYPE) {
  19445. // ForwardRef
  19446. var functionName = type.render.displayName || type.render.name || '';
  19447. name = type.displayName || (functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef');
  19448. propTypes = type.propTypes;
  19449. } else {
  19450. return;
  19451. }
  19452. if (propTypes) {
  19453. setCurrentlyValidatingElement(element);
  19454. checkPropTypes(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
  19455. setCurrentlyValidatingElement(null);
  19456. } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
  19457. propTypesMisspellWarningShown = true;
  19458. warningWithoutStack$1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
  19459. }
  19460. if (typeof type.getDefaultProps === 'function') {
  19461. !type.getDefaultProps.isReactClassApproved ? warningWithoutStack$1(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
  19462. }
  19463. }
  19464. /**
  19465. * Given a fragment, validate that it can only be provided with fragment props
  19466. * @param {ReactElement} fragment
  19467. */
  19468. function validateFragmentProps(fragment) {
  19469. setCurrentlyValidatingElement(fragment);
  19470. var keys = Object.keys(fragment.props);
  19471. for (var i = 0; i < keys.length; i++) {
  19472. var key = keys[i];
  19473. if (key !== 'children' && key !== 'key') {
  19474. warning$1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
  19475. break;
  19476. }
  19477. }
  19478. if (fragment.ref !== null) {
  19479. warning$1(false, 'Invalid attribute `ref` supplied to `React.Fragment`.');
  19480. }
  19481. setCurrentlyValidatingElement(null);
  19482. }
  19483. function createElementWithValidation(type, props, children) {
  19484. var validType = isValidElementType(type);
  19485. // We warn in this case but don't throw. We expect the element creation to
  19486. // succeed and there will likely be errors in render.
  19487. if (!validType) {
  19488. var info = '';
  19489. if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
  19490. 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.";
  19491. }
  19492. var sourceInfo = getSourceInfoErrorAddendum(props);
  19493. if (sourceInfo) {
  19494. info += sourceInfo;
  19495. } else {
  19496. info += getDeclarationErrorAddendum();
  19497. }
  19498. var typeString = void 0;
  19499. if (type === null) {
  19500. typeString = 'null';
  19501. } else if (Array.isArray(type)) {
  19502. typeString = 'array';
  19503. } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
  19504. typeString = '<' + (getComponentName(type.type) || 'Unknown') + ' />';
  19505. info = ' Did you accidentally export a JSX literal instead of a component?';
  19506. } else {
  19507. typeString = typeof type;
  19508. }
  19509. warning$1(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
  19510. }
  19511. var element = createElement.apply(this, arguments);
  19512. // The result can be nullish if a mock or a custom function is used.
  19513. // TODO: Drop this when these are no longer allowed as the type argument.
  19514. if (element == null) {
  19515. return element;
  19516. }
  19517. // Skip key warning if the type isn't valid since our key validation logic
  19518. // doesn't expect a non-string/function type and can throw confusing errors.
  19519. // We don't want exception behavior to differ between dev and prod.
  19520. // (Rendering will throw with a helpful message and as soon as the type is
  19521. // fixed, the key warnings will appear.)
  19522. if (validType) {
  19523. for (var i = 2; i < arguments.length; i++) {
  19524. validateChildKeys(arguments[i], type);
  19525. }
  19526. }
  19527. if (type === REACT_FRAGMENT_TYPE) {
  19528. validateFragmentProps(element);
  19529. } else {
  19530. validatePropTypes(element);
  19531. }
  19532. return element;
  19533. }
  19534. function createFactoryWithValidation(type) {
  19535. var validatedFactory = createElementWithValidation.bind(null, type);
  19536. validatedFactory.type = type;
  19537. // Legacy hook: remove it
  19538. {
  19539. Object.defineProperty(validatedFactory, 'type', {
  19540. enumerable: false,
  19541. get: function () {
  19542. lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
  19543. Object.defineProperty(this, 'type', {
  19544. value: type
  19545. });
  19546. return type;
  19547. }
  19548. });
  19549. }
  19550. return validatedFactory;
  19551. }
  19552. function cloneElementWithValidation(element, props, children) {
  19553. var newElement = cloneElement.apply(this, arguments);
  19554. for (var i = 2; i < arguments.length; i++) {
  19555. validateChildKeys(arguments[i], newElement.type);
  19556. }
  19557. validatePropTypes(newElement);
  19558. return newElement;
  19559. }
  19560. var React = {
  19561. Children: {
  19562. map: mapChildren,
  19563. forEach: forEachChildren,
  19564. count: countChildren,
  19565. toArray: toArray,
  19566. only: onlyChild
  19567. },
  19568. createRef: createRef,
  19569. Component: Component,
  19570. PureComponent: PureComponent,
  19571. createContext: createContext,
  19572. forwardRef: forwardRef,
  19573. lazy: lazy,
  19574. memo: memo,
  19575. Fragment: REACT_FRAGMENT_TYPE,
  19576. StrictMode: REACT_STRICT_MODE_TYPE,
  19577. Suspense: REACT_SUSPENSE_TYPE,
  19578. createElement: createElementWithValidation,
  19579. cloneElement: cloneElementWithValidation,
  19580. createFactory: createFactoryWithValidation,
  19581. isValidElement: isValidElement,
  19582. version: ReactVersion,
  19583. __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals
  19584. };
  19585. if (enableStableConcurrentModeAPIs) {
  19586. React.ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
  19587. React.Profiler = REACT_PROFILER_TYPE;
  19588. } else {
  19589. React.unstable_ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
  19590. React.unstable_Profiler = REACT_PROFILER_TYPE;
  19591. }
  19592. if (enableHooks) {
  19593. React.useCallback = useCallback;
  19594. React.useContext = useContext;
  19595. React.useEffect = useEffect;
  19596. React.useImperativeMethods = useImperativeMethods;
  19597. React.useLayoutEffect = useLayoutEffect;
  19598. React.useMemo = useMemo;
  19599. React.useMutationEffect = useMutationEffect;
  19600. React.useReducer = useReducer;
  19601. React.useRef = useRef;
  19602. React.useState = useState;
  19603. }
  19604. var React$2 = Object.freeze({
  19605. default: React
  19606. });
  19607. var React$3 = ( React$2 && React ) || React$2;
  19608. // TODO: decide on the top-level export form.
  19609. // This is hacky but makes it work with both Rollup and Jest.
  19610. var react = React$3.default || React$3;
  19611. module.exports = react;
  19612. })();
  19613. }
  19614. /***/ }),
  19615. /***/ "../../node_modules/react/index.js":
  19616. /*!*******************************************************!*\
  19617. !*** D:/Repos/Babylon.js/node_modules/react/index.js ***!
  19618. \*******************************************************/
  19619. /*! no static exports found */
  19620. /***/ (function(module, exports, __webpack_require__) {
  19621. "use strict";
  19622. if (false) {} else {
  19623. module.exports = __webpack_require__(/*! ./cjs/react.development.js */ "../../node_modules/react/cjs/react.development.js");
  19624. }
  19625. /***/ }),
  19626. /***/ "../../node_modules/scheduler/cjs/scheduler-tracing.development.js":
  19627. /*!***************************************************************************************!*\
  19628. !*** D:/Repos/Babylon.js/node_modules/scheduler/cjs/scheduler-tracing.development.js ***!
  19629. \***************************************************************************************/
  19630. /*! no static exports found */
  19631. /***/ (function(module, exports, __webpack_require__) {
  19632. "use strict";
  19633. /** @license React v0.11.3
  19634. * scheduler-tracing.development.js
  19635. *
  19636. * Copyright (c) Facebook, Inc. and its affiliates.
  19637. *
  19638. * This source code is licensed under the MIT license found in the
  19639. * LICENSE file in the root directory of this source tree.
  19640. */
  19641. if (true) {
  19642. (function() {
  19643. 'use strict';
  19644. Object.defineProperty(exports, '__esModule', { value: true });
  19645. // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
  19646. // In some cases, StrictMode should also double-render lifecycles.
  19647. // This can be confusing for tests though,
  19648. // And it can be bad for performance in production.
  19649. // This feature flag can be used to control the behavior:
  19650. // To preserve the "Pause on caught exceptions" behavior of the debugger, we
  19651. // replay the begin phase of a failed component inside invokeGuardedCallback.
  19652. // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
  19653. // Gather advanced timing metrics for Profiler subtrees.
  19654. // Trace which interactions trigger each commit.
  19655. var enableSchedulerTracing = true;
  19656. // Only used in www builds.
  19657. // Only used in www builds.
  19658. // React Fire: prevent the value and checked attributes from syncing
  19659. // with their related DOM properties
  19660. // These APIs will no longer be "unstable" in the upcoming 16.7 release,
  19661. // Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
  19662. var DEFAULT_THREAD_ID = 0;
  19663. // Counters used to generate unique IDs.
  19664. var interactionIDCounter = 0;
  19665. var threadIDCounter = 0;
  19666. // Set of currently traced interactions.
  19667. // Interactions "stack"–
  19668. // Meaning that newly traced interactions are appended to the previously active set.
  19669. // When an interaction goes out of scope, the previous set (if any) is restored.
  19670. exports.__interactionsRef = null;
  19671. // Listener(s) to notify when interactions begin and end.
  19672. exports.__subscriberRef = null;
  19673. if (enableSchedulerTracing) {
  19674. exports.__interactionsRef = {
  19675. current: new Set()
  19676. };
  19677. exports.__subscriberRef = {
  19678. current: null
  19679. };
  19680. }
  19681. function unstable_clear(callback) {
  19682. if (!enableSchedulerTracing) {
  19683. return callback();
  19684. }
  19685. var prevInteractions = exports.__interactionsRef.current;
  19686. exports.__interactionsRef.current = new Set();
  19687. try {
  19688. return callback();
  19689. } finally {
  19690. exports.__interactionsRef.current = prevInteractions;
  19691. }
  19692. }
  19693. function unstable_getCurrent() {
  19694. if (!enableSchedulerTracing) {
  19695. return null;
  19696. } else {
  19697. return exports.__interactionsRef.current;
  19698. }
  19699. }
  19700. function unstable_getThreadID() {
  19701. return ++threadIDCounter;
  19702. }
  19703. function unstable_trace(name, timestamp, callback) {
  19704. var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID;
  19705. if (!enableSchedulerTracing) {
  19706. return callback();
  19707. }
  19708. var interaction = {
  19709. __count: 1,
  19710. id: interactionIDCounter++,
  19711. name: name,
  19712. timestamp: timestamp
  19713. };
  19714. var prevInteractions = exports.__interactionsRef.current;
  19715. // Traced interactions should stack/accumulate.
  19716. // To do that, clone the current interactions.
  19717. // The previous set will be restored upon completion.
  19718. var interactions = new Set(prevInteractions);
  19719. interactions.add(interaction);
  19720. exports.__interactionsRef.current = interactions;
  19721. var subscriber = exports.__subscriberRef.current;
  19722. var returnValue = void 0;
  19723. try {
  19724. if (subscriber !== null) {
  19725. subscriber.onInteractionTraced(interaction);
  19726. }
  19727. } finally {
  19728. try {
  19729. if (subscriber !== null) {
  19730. subscriber.onWorkStarted(interactions, threadID);
  19731. }
  19732. } finally {
  19733. try {
  19734. returnValue = callback();
  19735. } finally {
  19736. exports.__interactionsRef.current = prevInteractions;
  19737. try {
  19738. if (subscriber !== null) {
  19739. subscriber.onWorkStopped(interactions, threadID);
  19740. }
  19741. } finally {
  19742. interaction.__count--;
  19743. // If no async work was scheduled for this interaction,
  19744. // Notify subscribers that it's completed.
  19745. if (subscriber !== null && interaction.__count === 0) {
  19746. subscriber.onInteractionScheduledWorkCompleted(interaction);
  19747. }
  19748. }
  19749. }
  19750. }
  19751. }
  19752. return returnValue;
  19753. }
  19754. function unstable_wrap(callback) {
  19755. var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID;
  19756. if (!enableSchedulerTracing) {
  19757. return callback;
  19758. }
  19759. var wrappedInteractions = exports.__interactionsRef.current;
  19760. var subscriber = exports.__subscriberRef.current;
  19761. if (subscriber !== null) {
  19762. subscriber.onWorkScheduled(wrappedInteractions, threadID);
  19763. }
  19764. // Update the pending async work count for the current interactions.
  19765. // Update after calling subscribers in case of error.
  19766. wrappedInteractions.forEach(function (interaction) {
  19767. interaction.__count++;
  19768. });
  19769. var hasRun = false;
  19770. function wrapped() {
  19771. var prevInteractions = exports.__interactionsRef.current;
  19772. exports.__interactionsRef.current = wrappedInteractions;
  19773. subscriber = exports.__subscriberRef.current;
  19774. try {
  19775. var returnValue = void 0;
  19776. try {
  19777. if (subscriber !== null) {
  19778. subscriber.onWorkStarted(wrappedInteractions, threadID);
  19779. }
  19780. } finally {
  19781. try {
  19782. returnValue = callback.apply(undefined, arguments);
  19783. } finally {
  19784. exports.__interactionsRef.current = prevInteractions;
  19785. if (subscriber !== null) {
  19786. subscriber.onWorkStopped(wrappedInteractions, threadID);
  19787. }
  19788. }
  19789. }
  19790. return returnValue;
  19791. } finally {
  19792. if (!hasRun) {
  19793. // We only expect a wrapped function to be executed once,
  19794. // But in the event that it's executed more than once–
  19795. // Only decrement the outstanding interaction counts once.
  19796. hasRun = true;
  19797. // Update pending async counts for all wrapped interactions.
  19798. // If this was the last scheduled async work for any of them,
  19799. // Mark them as completed.
  19800. wrappedInteractions.forEach(function (interaction) {
  19801. interaction.__count--;
  19802. if (subscriber !== null && interaction.__count === 0) {
  19803. subscriber.onInteractionScheduledWorkCompleted(interaction);
  19804. }
  19805. });
  19806. }
  19807. }
  19808. }
  19809. wrapped.cancel = function cancel() {
  19810. subscriber = exports.__subscriberRef.current;
  19811. try {
  19812. if (subscriber !== null) {
  19813. subscriber.onWorkCanceled(wrappedInteractions, threadID);
  19814. }
  19815. } finally {
  19816. // Update pending async counts for all wrapped interactions.
  19817. // If this was the last scheduled async work for any of them,
  19818. // Mark them as completed.
  19819. wrappedInteractions.forEach(function (interaction) {
  19820. interaction.__count--;
  19821. if (subscriber && interaction.__count === 0) {
  19822. subscriber.onInteractionScheduledWorkCompleted(interaction);
  19823. }
  19824. });
  19825. }
  19826. };
  19827. return wrapped;
  19828. }
  19829. var subscribers = null;
  19830. if (enableSchedulerTracing) {
  19831. subscribers = new Set();
  19832. }
  19833. function unstable_subscribe(subscriber) {
  19834. if (enableSchedulerTracing) {
  19835. subscribers.add(subscriber);
  19836. if (subscribers.size === 1) {
  19837. exports.__subscriberRef.current = {
  19838. onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted,
  19839. onInteractionTraced: onInteractionTraced,
  19840. onWorkCanceled: onWorkCanceled,
  19841. onWorkScheduled: onWorkScheduled,
  19842. onWorkStarted: onWorkStarted,
  19843. onWorkStopped: onWorkStopped
  19844. };
  19845. }
  19846. }
  19847. }
  19848. function unstable_unsubscribe(subscriber) {
  19849. if (enableSchedulerTracing) {
  19850. subscribers.delete(subscriber);
  19851. if (subscribers.size === 0) {
  19852. exports.__subscriberRef.current = null;
  19853. }
  19854. }
  19855. }
  19856. function onInteractionTraced(interaction) {
  19857. var didCatchError = false;
  19858. var caughtError = null;
  19859. subscribers.forEach(function (subscriber) {
  19860. try {
  19861. subscriber.onInteractionTraced(interaction);
  19862. } catch (error) {
  19863. if (!didCatchError) {
  19864. didCatchError = true;
  19865. caughtError = error;
  19866. }
  19867. }
  19868. });
  19869. if (didCatchError) {
  19870. throw caughtError;
  19871. }
  19872. }
  19873. function onInteractionScheduledWorkCompleted(interaction) {
  19874. var didCatchError = false;
  19875. var caughtError = null;
  19876. subscribers.forEach(function (subscriber) {
  19877. try {
  19878. subscriber.onInteractionScheduledWorkCompleted(interaction);
  19879. } catch (error) {
  19880. if (!didCatchError) {
  19881. didCatchError = true;
  19882. caughtError = error;
  19883. }
  19884. }
  19885. });
  19886. if (didCatchError) {
  19887. throw caughtError;
  19888. }
  19889. }
  19890. function onWorkScheduled(interactions, threadID) {
  19891. var didCatchError = false;
  19892. var caughtError = null;
  19893. subscribers.forEach(function (subscriber) {
  19894. try {
  19895. subscriber.onWorkScheduled(interactions, threadID);
  19896. } catch (error) {
  19897. if (!didCatchError) {
  19898. didCatchError = true;
  19899. caughtError = error;
  19900. }
  19901. }
  19902. });
  19903. if (didCatchError) {
  19904. throw caughtError;
  19905. }
  19906. }
  19907. function onWorkStarted(interactions, threadID) {
  19908. var didCatchError = false;
  19909. var caughtError = null;
  19910. subscribers.forEach(function (subscriber) {
  19911. try {
  19912. subscriber.onWorkStarted(interactions, threadID);
  19913. } catch (error) {
  19914. if (!didCatchError) {
  19915. didCatchError = true;
  19916. caughtError = error;
  19917. }
  19918. }
  19919. });
  19920. if (didCatchError) {
  19921. throw caughtError;
  19922. }
  19923. }
  19924. function onWorkStopped(interactions, threadID) {
  19925. var didCatchError = false;
  19926. var caughtError = null;
  19927. subscribers.forEach(function (subscriber) {
  19928. try {
  19929. subscriber.onWorkStopped(interactions, threadID);
  19930. } catch (error) {
  19931. if (!didCatchError) {
  19932. didCatchError = true;
  19933. caughtError = error;
  19934. }
  19935. }
  19936. });
  19937. if (didCatchError) {
  19938. throw caughtError;
  19939. }
  19940. }
  19941. function onWorkCanceled(interactions, threadID) {
  19942. var didCatchError = false;
  19943. var caughtError = null;
  19944. subscribers.forEach(function (subscriber) {
  19945. try {
  19946. subscriber.onWorkCanceled(interactions, threadID);
  19947. } catch (error) {
  19948. if (!didCatchError) {
  19949. didCatchError = true;
  19950. caughtError = error;
  19951. }
  19952. }
  19953. });
  19954. if (didCatchError) {
  19955. throw caughtError;
  19956. }
  19957. }
  19958. exports.unstable_clear = unstable_clear;
  19959. exports.unstable_getCurrent = unstable_getCurrent;
  19960. exports.unstable_getThreadID = unstable_getThreadID;
  19961. exports.unstable_trace = unstable_trace;
  19962. exports.unstable_wrap = unstable_wrap;
  19963. exports.unstable_subscribe = unstable_subscribe;
  19964. exports.unstable_unsubscribe = unstable_unsubscribe;
  19965. })();
  19966. }
  19967. /***/ }),
  19968. /***/ "../../node_modules/scheduler/cjs/scheduler.development.js":
  19969. /*!*******************************************************************************!*\
  19970. !*** D:/Repos/Babylon.js/node_modules/scheduler/cjs/scheduler.development.js ***!
  19971. \*******************************************************************************/
  19972. /*! no static exports found */
  19973. /***/ (function(module, exports, __webpack_require__) {
  19974. "use strict";
  19975. /* WEBPACK VAR INJECTION */(function(global) {/** @license React v0.11.3
  19976. * scheduler.development.js
  19977. *
  19978. * Copyright (c) Facebook, Inc. and its affiliates.
  19979. *
  19980. * This source code is licensed under the MIT license found in the
  19981. * LICENSE file in the root directory of this source tree.
  19982. */
  19983. if (true) {
  19984. (function() {
  19985. 'use strict';
  19986. Object.defineProperty(exports, '__esModule', { value: true });
  19987. /* eslint-disable no-var */
  19988. // TODO: Use symbols?
  19989. var ImmediatePriority = 1;
  19990. var UserBlockingPriority = 2;
  19991. var NormalPriority = 3;
  19992. var LowPriority = 4;
  19993. var IdlePriority = 5;
  19994. // Max 31 bit integer. The max integer size in V8 for 32-bit systems.
  19995. // Math.pow(2, 30) - 1
  19996. // 0b111111111111111111111111111111
  19997. var maxSigned31BitInt = 1073741823;
  19998. // Times out immediately
  19999. var IMMEDIATE_PRIORITY_TIMEOUT = -1;
  20000. // Eventually times out
  20001. var USER_BLOCKING_PRIORITY = 250;
  20002. var NORMAL_PRIORITY_TIMEOUT = 5000;
  20003. var LOW_PRIORITY_TIMEOUT = 10000;
  20004. // Never times out
  20005. var IDLE_PRIORITY = maxSigned31BitInt;
  20006. // Callbacks are stored as a circular, doubly linked list.
  20007. var firstCallbackNode = null;
  20008. var currentDidTimeout = false;
  20009. var currentPriorityLevel = NormalPriority;
  20010. var currentEventStartTime = -1;
  20011. var currentExpirationTime = -1;
  20012. // This is set when a callback is being executed, to prevent re-entrancy.
  20013. var isExecutingCallback = false;
  20014. var isHostCallbackScheduled = false;
  20015. var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
  20016. function ensureHostCallbackIsScheduled() {
  20017. if (isExecutingCallback) {
  20018. // Don't schedule work yet; wait until the next time we yield.
  20019. return;
  20020. }
  20021. // Schedule the host callback using the earliest expiration in the list.
  20022. var expirationTime = firstCallbackNode.expirationTime;
  20023. if (!isHostCallbackScheduled) {
  20024. isHostCallbackScheduled = true;
  20025. } else {
  20026. // Cancel the existing host callback.
  20027. cancelHostCallback();
  20028. }
  20029. requestHostCallback(flushWork, expirationTime);
  20030. }
  20031. function flushFirstCallback() {
  20032. var flushedNode = firstCallbackNode;
  20033. // Remove the node from the list before calling the callback. That way the
  20034. // list is in a consistent state even if the callback throws.
  20035. var next = firstCallbackNode.next;
  20036. if (firstCallbackNode === next) {
  20037. // This is the last callback in the list.
  20038. firstCallbackNode = null;
  20039. next = null;
  20040. } else {
  20041. var lastCallbackNode = firstCallbackNode.previous;
  20042. firstCallbackNode = lastCallbackNode.next = next;
  20043. next.previous = lastCallbackNode;
  20044. }
  20045. flushedNode.next = flushedNode.previous = null;
  20046. // Now it's safe to call the callback.
  20047. var callback = flushedNode.callback;
  20048. var expirationTime = flushedNode.expirationTime;
  20049. var priorityLevel = flushedNode.priorityLevel;
  20050. var previousPriorityLevel = currentPriorityLevel;
  20051. var previousExpirationTime = currentExpirationTime;
  20052. currentPriorityLevel = priorityLevel;
  20053. currentExpirationTime = expirationTime;
  20054. var continuationCallback;
  20055. try {
  20056. continuationCallback = callback();
  20057. } finally {
  20058. currentPriorityLevel = previousPriorityLevel;
  20059. currentExpirationTime = previousExpirationTime;
  20060. }
  20061. // A callback may return a continuation. The continuation should be scheduled
  20062. // with the same priority and expiration as the just-finished callback.
  20063. if (typeof continuationCallback === 'function') {
  20064. var continuationNode = {
  20065. callback: continuationCallback,
  20066. priorityLevel: priorityLevel,
  20067. expirationTime: expirationTime,
  20068. next: null,
  20069. previous: null
  20070. };
  20071. // Insert the new callback into the list, sorted by its expiration. This is
  20072. // almost the same as the code in `scheduleCallback`, except the callback
  20073. // is inserted into the list *before* callbacks of equal expiration instead
  20074. // of after.
  20075. if (firstCallbackNode === null) {
  20076. // This is the first callback in the list.
  20077. firstCallbackNode = continuationNode.next = continuationNode.previous = continuationNode;
  20078. } else {
  20079. var nextAfterContinuation = null;
  20080. var node = firstCallbackNode;
  20081. do {
  20082. if (node.expirationTime >= expirationTime) {
  20083. // This callback expires at or after the continuation. We will insert
  20084. // the continuation *before* this callback.
  20085. nextAfterContinuation = node;
  20086. break;
  20087. }
  20088. node = node.next;
  20089. } while (node !== firstCallbackNode);
  20090. if (nextAfterContinuation === null) {
  20091. // No equal or lower priority callback was found, which means the new
  20092. // callback is the lowest priority callback in the list.
  20093. nextAfterContinuation = firstCallbackNode;
  20094. } else if (nextAfterContinuation === firstCallbackNode) {
  20095. // The new callback is the highest priority callback in the list.
  20096. firstCallbackNode = continuationNode;
  20097. ensureHostCallbackIsScheduled();
  20098. }
  20099. var previous = nextAfterContinuation.previous;
  20100. previous.next = nextAfterContinuation.previous = continuationNode;
  20101. continuationNode.next = nextAfterContinuation;
  20102. continuationNode.previous = previous;
  20103. }
  20104. }
  20105. }
  20106. function flushImmediateWork() {
  20107. if (
  20108. // Confirm we've exited the outer most event handler
  20109. currentEventStartTime === -1 && firstCallbackNode !== null && firstCallbackNode.priorityLevel === ImmediatePriority) {
  20110. isExecutingCallback = true;
  20111. try {
  20112. do {
  20113. flushFirstCallback();
  20114. } while (
  20115. // Keep flushing until there are no more immediate callbacks
  20116. firstCallbackNode !== null && firstCallbackNode.priorityLevel === ImmediatePriority);
  20117. } finally {
  20118. isExecutingCallback = false;
  20119. if (firstCallbackNode !== null) {
  20120. // There's still work remaining. Request another callback.
  20121. ensureHostCallbackIsScheduled();
  20122. } else {
  20123. isHostCallbackScheduled = false;
  20124. }
  20125. }
  20126. }
  20127. }
  20128. function flushWork(didTimeout) {
  20129. isExecutingCallback = true;
  20130. var previousDidTimeout = currentDidTimeout;
  20131. currentDidTimeout = didTimeout;
  20132. try {
  20133. if (didTimeout) {
  20134. // Flush all the expired callbacks without yielding.
  20135. while (firstCallbackNode !== null) {
  20136. // Read the current time. Flush all the callbacks that expire at or
  20137. // earlier than that time. Then read the current time again and repeat.
  20138. // This optimizes for as few performance.now calls as possible.
  20139. var currentTime = exports.unstable_now();
  20140. if (firstCallbackNode.expirationTime <= currentTime) {
  20141. do {
  20142. flushFirstCallback();
  20143. } while (firstCallbackNode !== null && firstCallbackNode.expirationTime <= currentTime);
  20144. continue;
  20145. }
  20146. break;
  20147. }
  20148. } else {
  20149. // Keep flushing callbacks until we run out of time in the frame.
  20150. if (firstCallbackNode !== null) {
  20151. do {
  20152. flushFirstCallback();
  20153. } while (firstCallbackNode !== null && !shouldYieldToHost());
  20154. }
  20155. }
  20156. } finally {
  20157. isExecutingCallback = false;
  20158. currentDidTimeout = previousDidTimeout;
  20159. if (firstCallbackNode !== null) {
  20160. // There's still work remaining. Request another callback.
  20161. ensureHostCallbackIsScheduled();
  20162. } else {
  20163. isHostCallbackScheduled = false;
  20164. }
  20165. // Before exiting, flush all the immediate work that was scheduled.
  20166. flushImmediateWork();
  20167. }
  20168. }
  20169. function unstable_runWithPriority(priorityLevel, eventHandler) {
  20170. switch (priorityLevel) {
  20171. case ImmediatePriority:
  20172. case UserBlockingPriority:
  20173. case NormalPriority:
  20174. case LowPriority:
  20175. case IdlePriority:
  20176. break;
  20177. default:
  20178. priorityLevel = NormalPriority;
  20179. }
  20180. var previousPriorityLevel = currentPriorityLevel;
  20181. var previousEventStartTime = currentEventStartTime;
  20182. currentPriorityLevel = priorityLevel;
  20183. currentEventStartTime = exports.unstable_now();
  20184. try {
  20185. return eventHandler();
  20186. } finally {
  20187. currentPriorityLevel = previousPriorityLevel;
  20188. currentEventStartTime = previousEventStartTime;
  20189. // Before exiting, flush all the immediate work that was scheduled.
  20190. flushImmediateWork();
  20191. }
  20192. }
  20193. function unstable_wrapCallback(callback) {
  20194. var parentPriorityLevel = currentPriorityLevel;
  20195. return function () {
  20196. // This is a fork of runWithPriority, inlined for performance.
  20197. var previousPriorityLevel = currentPriorityLevel;
  20198. var previousEventStartTime = currentEventStartTime;
  20199. currentPriorityLevel = parentPriorityLevel;
  20200. currentEventStartTime = exports.unstable_now();
  20201. try {
  20202. return callback.apply(this, arguments);
  20203. } finally {
  20204. currentPriorityLevel = previousPriorityLevel;
  20205. currentEventStartTime = previousEventStartTime;
  20206. flushImmediateWork();
  20207. }
  20208. };
  20209. }
  20210. function unstable_scheduleCallback(callback, deprecated_options) {
  20211. var startTime = currentEventStartTime !== -1 ? currentEventStartTime : exports.unstable_now();
  20212. var expirationTime;
  20213. if (typeof deprecated_options === 'object' && deprecated_options !== null && typeof deprecated_options.timeout === 'number') {
  20214. // FIXME: Remove this branch once we lift expiration times out of React.
  20215. expirationTime = startTime + deprecated_options.timeout;
  20216. } else {
  20217. switch (currentPriorityLevel) {
  20218. case ImmediatePriority:
  20219. expirationTime = startTime + IMMEDIATE_PRIORITY_TIMEOUT;
  20220. break;
  20221. case UserBlockingPriority:
  20222. expirationTime = startTime + USER_BLOCKING_PRIORITY;
  20223. break;
  20224. case IdlePriority:
  20225. expirationTime = startTime + IDLE_PRIORITY;
  20226. break;
  20227. case LowPriority:
  20228. expirationTime = startTime + LOW_PRIORITY_TIMEOUT;
  20229. break;
  20230. case NormalPriority:
  20231. default:
  20232. expirationTime = startTime + NORMAL_PRIORITY_TIMEOUT;
  20233. }
  20234. }
  20235. var newNode = {
  20236. callback: callback,
  20237. priorityLevel: currentPriorityLevel,
  20238. expirationTime: expirationTime,
  20239. next: null,
  20240. previous: null
  20241. };
  20242. // Insert the new callback into the list, ordered first by expiration, then
  20243. // by insertion. So the new callback is inserted any other callback with
  20244. // equal expiration.
  20245. if (firstCallbackNode === null) {
  20246. // This is the first callback in the list.
  20247. firstCallbackNode = newNode.next = newNode.previous = newNode;
  20248. ensureHostCallbackIsScheduled();
  20249. } else {
  20250. var next = null;
  20251. var node = firstCallbackNode;
  20252. do {
  20253. if (node.expirationTime > expirationTime) {
  20254. // The new callback expires before this one.
  20255. next = node;
  20256. break;
  20257. }
  20258. node = node.next;
  20259. } while (node !== firstCallbackNode);
  20260. if (next === null) {
  20261. // No callback with a later expiration was found, which means the new
  20262. // callback has the latest expiration in the list.
  20263. next = firstCallbackNode;
  20264. } else if (next === firstCallbackNode) {
  20265. // The new callback has the earliest expiration in the entire list.
  20266. firstCallbackNode = newNode;
  20267. ensureHostCallbackIsScheduled();
  20268. }
  20269. var previous = next.previous;
  20270. previous.next = next.previous = newNode;
  20271. newNode.next = next;
  20272. newNode.previous = previous;
  20273. }
  20274. return newNode;
  20275. }
  20276. function unstable_cancelCallback(callbackNode) {
  20277. var next = callbackNode.next;
  20278. if (next === null) {
  20279. // Already cancelled.
  20280. return;
  20281. }
  20282. if (next === callbackNode) {
  20283. // This is the only scheduled callback. Clear the list.
  20284. firstCallbackNode = null;
  20285. } else {
  20286. // Remove the callback from its position in the list.
  20287. if (callbackNode === firstCallbackNode) {
  20288. firstCallbackNode = next;
  20289. }
  20290. var previous = callbackNode.previous;
  20291. previous.next = next;
  20292. next.previous = previous;
  20293. }
  20294. callbackNode.next = callbackNode.previous = null;
  20295. }
  20296. function unstable_getCurrentPriorityLevel() {
  20297. return currentPriorityLevel;
  20298. }
  20299. function unstable_shouldYield() {
  20300. return !currentDidTimeout && (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime || shouldYieldToHost());
  20301. }
  20302. // The remaining code is essentially a polyfill for requestIdleCallback. It
  20303. // works by scheduling a requestAnimationFrame, storing the time for the start
  20304. // of the frame, then scheduling a postMessage which gets scheduled after paint.
  20305. // Within the postMessage handler do as much work as possible until time + frame
  20306. // rate. By separating the idle call into a separate event tick we ensure that
  20307. // layout, paint and other browser work is counted against the available time.
  20308. // The frame rate is dynamically adjusted.
  20309. // We capture a local reference to any global, in case it gets polyfilled after
  20310. // this module is initially evaluated. We want to be using a
  20311. // consistent implementation.
  20312. var localDate = Date;
  20313. // This initialization code may run even on server environments if a component
  20314. // just imports ReactDOM (e.g. for findDOMNode). Some environments might not
  20315. // have setTimeout or clearTimeout. However, we always expect them to be defined
  20316. // on the client. https://github.com/facebook/react/pull/13088
  20317. var localSetTimeout = typeof setTimeout === 'function' ? setTimeout : undefined;
  20318. var localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined;
  20319. // We don't expect either of these to necessarily be defined, but we will error
  20320. // later if they are missing on the client.
  20321. var localRequestAnimationFrame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : undefined;
  20322. var localCancelAnimationFrame = typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame : undefined;
  20323. // requestAnimationFrame does not run when the tab is in the background. If
  20324. // we're backgrounded we prefer for that work to happen so that the page
  20325. // continues to load in the background. So we also schedule a 'setTimeout' as
  20326. // a fallback.
  20327. // TODO: Need a better heuristic for backgrounded work.
  20328. var ANIMATION_FRAME_TIMEOUT = 100;
  20329. var rAFID;
  20330. var rAFTimeoutID;
  20331. var requestAnimationFrameWithTimeout = function (callback) {
  20332. // schedule rAF and also a setTimeout
  20333. rAFID = localRequestAnimationFrame(function (timestamp) {
  20334. // cancel the setTimeout
  20335. localClearTimeout(rAFTimeoutID);
  20336. callback(timestamp);
  20337. });
  20338. rAFTimeoutID = localSetTimeout(function () {
  20339. // cancel the requestAnimationFrame
  20340. localCancelAnimationFrame(rAFID);
  20341. callback(exports.unstable_now());
  20342. }, ANIMATION_FRAME_TIMEOUT);
  20343. };
  20344. if (hasNativePerformanceNow) {
  20345. var Performance = performance;
  20346. exports.unstable_now = function () {
  20347. return Performance.now();
  20348. };
  20349. } else {
  20350. exports.unstable_now = function () {
  20351. return localDate.now();
  20352. };
  20353. }
  20354. var requestHostCallback;
  20355. var cancelHostCallback;
  20356. var shouldYieldToHost;
  20357. var globalValue = null;
  20358. if (typeof window !== 'undefined') {
  20359. globalValue = window;
  20360. } else if (typeof global !== 'undefined') {
  20361. globalValue = global;
  20362. }
  20363. if (globalValue && globalValue._schedMock) {
  20364. // Dynamic injection, only for testing purposes.
  20365. var globalImpl = globalValue._schedMock;
  20366. requestHostCallback = globalImpl[0];
  20367. cancelHostCallback = globalImpl[1];
  20368. shouldYieldToHost = globalImpl[2];
  20369. exports.unstable_now = globalImpl[3];
  20370. } else if (
  20371. // If Scheduler runs in a non-DOM environment, it falls back to a naive
  20372. // implementation using setTimeout.
  20373. typeof window === 'undefined' ||
  20374. // Check if MessageChannel is supported, too.
  20375. typeof MessageChannel !== 'function') {
  20376. // If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore,
  20377. // fallback to a naive implementation.
  20378. var _callback = null;
  20379. var _flushCallback = function (didTimeout) {
  20380. if (_callback !== null) {
  20381. try {
  20382. _callback(didTimeout);
  20383. } finally {
  20384. _callback = null;
  20385. }
  20386. }
  20387. };
  20388. requestHostCallback = function (cb, ms) {
  20389. if (_callback !== null) {
  20390. // Protect against re-entrancy.
  20391. setTimeout(requestHostCallback, 0, cb);
  20392. } else {
  20393. _callback = cb;
  20394. setTimeout(_flushCallback, 0, false);
  20395. }
  20396. };
  20397. cancelHostCallback = function () {
  20398. _callback = null;
  20399. };
  20400. shouldYieldToHost = function () {
  20401. return false;
  20402. };
  20403. } else {
  20404. if (typeof console !== 'undefined') {
  20405. // TODO: Remove fb.me link
  20406. if (typeof localRequestAnimationFrame !== 'function') {
  20407. console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
  20408. }
  20409. if (typeof localCancelAnimationFrame !== 'function') {
  20410. console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
  20411. }
  20412. }
  20413. var scheduledHostCallback = null;
  20414. var isMessageEventScheduled = false;
  20415. var timeoutTime = -1;
  20416. var isAnimationFrameScheduled = false;
  20417. var isFlushingHostCallback = false;
  20418. var frameDeadline = 0;
  20419. // We start out assuming that we run at 30fps but then the heuristic tracking
  20420. // will adjust this value to a faster fps if we get more frequent animation
  20421. // frames.
  20422. var previousFrameTime = 33;
  20423. var activeFrameTime = 33;
  20424. shouldYieldToHost = function () {
  20425. return frameDeadline <= exports.unstable_now();
  20426. };
  20427. // We use the postMessage trick to defer idle work until after the repaint.
  20428. var channel = new MessageChannel();
  20429. var port = channel.port2;
  20430. channel.port1.onmessage = function (event) {
  20431. isMessageEventScheduled = false;
  20432. var prevScheduledCallback = scheduledHostCallback;
  20433. var prevTimeoutTime = timeoutTime;
  20434. scheduledHostCallback = null;
  20435. timeoutTime = -1;
  20436. var currentTime = exports.unstable_now();
  20437. var didTimeout = false;
  20438. if (frameDeadline - currentTime <= 0) {
  20439. // There's no time left in this idle period. Check if the callback has
  20440. // a timeout and whether it's been exceeded.
  20441. if (prevTimeoutTime !== -1 && prevTimeoutTime <= currentTime) {
  20442. // Exceeded the timeout. Invoke the callback even though there's no
  20443. // time left.
  20444. didTimeout = true;
  20445. } else {
  20446. // No timeout.
  20447. if (!isAnimationFrameScheduled) {
  20448. // Schedule another animation callback so we retry later.
  20449. isAnimationFrameScheduled = true;
  20450. requestAnimationFrameWithTimeout(animationTick);
  20451. }
  20452. // Exit without invoking the callback.
  20453. scheduledHostCallback = prevScheduledCallback;
  20454. timeoutTime = prevTimeoutTime;
  20455. return;
  20456. }
  20457. }
  20458. if (prevScheduledCallback !== null) {
  20459. isFlushingHostCallback = true;
  20460. try {
  20461. prevScheduledCallback(didTimeout);
  20462. } finally {
  20463. isFlushingHostCallback = false;
  20464. }
  20465. }
  20466. };
  20467. var animationTick = function (rafTime) {
  20468. if (scheduledHostCallback !== null) {
  20469. // Eagerly schedule the next animation callback at the beginning of the
  20470. // frame. If the scheduler queue is not empty at the end of the frame, it
  20471. // will continue flushing inside that callback. If the queue *is* empty,
  20472. // then it will exit immediately. Posting the callback at the start of the
  20473. // frame ensures it's fired within the earliest possible frame. If we
  20474. // waited until the end of the frame to post the callback, we risk the
  20475. // browser skipping a frame and not firing the callback until the frame
  20476. // after that.
  20477. requestAnimationFrameWithTimeout(animationTick);
  20478. } else {
  20479. // No pending work. Exit.
  20480. isAnimationFrameScheduled = false;
  20481. return;
  20482. }
  20483. var nextFrameTime = rafTime - frameDeadline + activeFrameTime;
  20484. if (nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime) {
  20485. if (nextFrameTime < 8) {
  20486. // Defensive coding. We don't support higher frame rates than 120hz.
  20487. // If the calculated frame time gets lower than 8, it is probably a bug.
  20488. nextFrameTime = 8;
  20489. }
  20490. // If one frame goes long, then the next one can be short to catch up.
  20491. // If two frames are short in a row, then that's an indication that we
  20492. // actually have a higher frame rate than what we're currently optimizing.
  20493. // We adjust our heuristic dynamically accordingly. For example, if we're
  20494. // running on 120hz display or 90hz VR display.
  20495. // Take the max of the two in case one of them was an anomaly due to
  20496. // missed frame deadlines.
  20497. activeFrameTime = nextFrameTime < previousFrameTime ? previousFrameTime : nextFrameTime;
  20498. } else {
  20499. previousFrameTime = nextFrameTime;
  20500. }
  20501. frameDeadline = rafTime + activeFrameTime;
  20502. if (!isMessageEventScheduled) {
  20503. isMessageEventScheduled = true;
  20504. port.postMessage(undefined);
  20505. }
  20506. };
  20507. requestHostCallback = function (callback, absoluteTimeout) {
  20508. scheduledHostCallback = callback;
  20509. timeoutTime = absoluteTimeout;
  20510. if (isFlushingHostCallback || absoluteTimeout < 0) {
  20511. // Don't wait for the next frame. Continue working ASAP, in a new event.
  20512. port.postMessage(undefined);
  20513. } else if (!isAnimationFrameScheduled) {
  20514. // If rAF didn't already schedule one, we need to schedule a frame.
  20515. // TODO: If this rAF doesn't materialize because the browser throttles, we
  20516. // might want to still have setTimeout trigger rIC as a backup to ensure
  20517. // that we keep performing work.
  20518. isAnimationFrameScheduled = true;
  20519. requestAnimationFrameWithTimeout(animationTick);
  20520. }
  20521. };
  20522. cancelHostCallback = function () {
  20523. scheduledHostCallback = null;
  20524. isMessageEventScheduled = false;
  20525. timeoutTime = -1;
  20526. };
  20527. }
  20528. exports.unstable_ImmediatePriority = ImmediatePriority;
  20529. exports.unstable_UserBlockingPriority = UserBlockingPriority;
  20530. exports.unstable_NormalPriority = NormalPriority;
  20531. exports.unstable_IdlePriority = IdlePriority;
  20532. exports.unstable_LowPriority = LowPriority;
  20533. exports.unstable_runWithPriority = unstable_runWithPriority;
  20534. exports.unstable_scheduleCallback = unstable_scheduleCallback;
  20535. exports.unstable_cancelCallback = unstable_cancelCallback;
  20536. exports.unstable_wrapCallback = unstable_wrapCallback;
  20537. exports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel;
  20538. exports.unstable_shouldYield = unstable_shouldYield;
  20539. })();
  20540. }
  20541. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  20542. /***/ }),
  20543. /***/ "../../node_modules/scheduler/index.js":
  20544. /*!***********************************************************!*\
  20545. !*** D:/Repos/Babylon.js/node_modules/scheduler/index.js ***!
  20546. \***********************************************************/
  20547. /*! no static exports found */
  20548. /***/ (function(module, exports, __webpack_require__) {
  20549. "use strict";
  20550. if (false) {} else {
  20551. module.exports = __webpack_require__(/*! ./cjs/scheduler.development.js */ "../../node_modules/scheduler/cjs/scheduler.development.js");
  20552. }
  20553. /***/ }),
  20554. /***/ "../../node_modules/scheduler/tracing.js":
  20555. /*!*************************************************************!*\
  20556. !*** D:/Repos/Babylon.js/node_modules/scheduler/tracing.js ***!
  20557. \*************************************************************/
  20558. /*! no static exports found */
  20559. /***/ (function(module, exports, __webpack_require__) {
  20560. "use strict";
  20561. if (false) {} else {
  20562. module.exports = __webpack_require__(/*! ./cjs/scheduler-tracing.development.js */ "../../node_modules/scheduler/cjs/scheduler-tracing.development.js");
  20563. }
  20564. /***/ }),
  20565. /***/ "../../node_modules/tslib/tslib.es6.js":
  20566. /*!***********************************************************!*\
  20567. !*** D:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  20568. \***********************************************************/
  20569. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  20570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20571. "use strict";
  20572. __webpack_require__.r(__webpack_exports__);
  20573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  20574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  20575. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  20576. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  20577. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  20578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  20579. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  20580. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  20581. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  20582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  20583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  20584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  20585. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  20586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  20587. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  20588. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  20589. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  20590. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  20591. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  20592. /*! *****************************************************************************
  20593. Copyright (c) Microsoft Corporation. All rights reserved.
  20594. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  20595. this file except in compliance with the License. You may obtain a copy of the
  20596. License at http://www.apache.org/licenses/LICENSE-2.0
  20597. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  20598. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  20599. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  20600. MERCHANTABLITY OR NON-INFRINGEMENT.
  20601. See the Apache Version 2.0 License for specific language governing permissions
  20602. and limitations under the License.
  20603. ***************************************************************************** */
  20604. /* global Reflect, Promise */
  20605. var extendStatics = function(d, b) {
  20606. extendStatics = Object.setPrototypeOf ||
  20607. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  20608. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  20609. return extendStatics(d, b);
  20610. };
  20611. function __extends(d, b) {
  20612. extendStatics(d, b);
  20613. function __() { this.constructor = d; }
  20614. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  20615. }
  20616. var __assign = function() {
  20617. __assign = Object.assign || function __assign(t) {
  20618. for (var s, i = 1, n = arguments.length; i < n; i++) {
  20619. s = arguments[i];
  20620. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  20621. }
  20622. return t;
  20623. }
  20624. return __assign.apply(this, arguments);
  20625. }
  20626. function __rest(s, e) {
  20627. var t = {};
  20628. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  20629. t[p] = s[p];
  20630. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  20631. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  20632. t[p[i]] = s[p[i]];
  20633. return t;
  20634. }
  20635. function __decorate(decorators, target, key, desc) {
  20636. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20637. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  20638. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  20639. return c > 3 && r && Object.defineProperty(target, key, r), r;
  20640. }
  20641. function __param(paramIndex, decorator) {
  20642. return function (target, key) { decorator(target, key, paramIndex); }
  20643. }
  20644. function __metadata(metadataKey, metadataValue) {
  20645. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  20646. }
  20647. function __awaiter(thisArg, _arguments, P, generator) {
  20648. return new (P || (P = Promise))(function (resolve, reject) {
  20649. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  20650. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  20651. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  20652. step((generator = generator.apply(thisArg, _arguments || [])).next());
  20653. });
  20654. }
  20655. function __generator(thisArg, body) {
  20656. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  20657. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  20658. function verb(n) { return function (v) { return step([n, v]); }; }
  20659. function step(op) {
  20660. if (f) throw new TypeError("Generator is already executing.");
  20661. while (_) try {
  20662. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  20663. if (y = 0, t) op = [op[0] & 2, t.value];
  20664. switch (op[0]) {
  20665. case 0: case 1: t = op; break;
  20666. case 4: _.label++; return { value: op[1], done: false };
  20667. case 5: _.label++; y = op[1]; op = [0]; continue;
  20668. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  20669. default:
  20670. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  20671. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  20672. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  20673. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  20674. if (t[2]) _.ops.pop();
  20675. _.trys.pop(); continue;
  20676. }
  20677. op = body.call(thisArg, _);
  20678. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  20679. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  20680. }
  20681. }
  20682. function __exportStar(m, exports) {
  20683. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  20684. }
  20685. function __values(o) {
  20686. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  20687. if (m) return m.call(o);
  20688. return {
  20689. next: function () {
  20690. if (o && i >= o.length) o = void 0;
  20691. return { value: o && o[i++], done: !o };
  20692. }
  20693. };
  20694. }
  20695. function __read(o, n) {
  20696. var m = typeof Symbol === "function" && o[Symbol.iterator];
  20697. if (!m) return o;
  20698. var i = m.call(o), r, ar = [], e;
  20699. try {
  20700. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  20701. }
  20702. catch (error) { e = { error: error }; }
  20703. finally {
  20704. try {
  20705. if (r && !r.done && (m = i["return"])) m.call(i);
  20706. }
  20707. finally { if (e) throw e.error; }
  20708. }
  20709. return ar;
  20710. }
  20711. function __spread() {
  20712. for (var ar = [], i = 0; i < arguments.length; i++)
  20713. ar = ar.concat(__read(arguments[i]));
  20714. return ar;
  20715. }
  20716. function __await(v) {
  20717. return this instanceof __await ? (this.v = v, this) : new __await(v);
  20718. }
  20719. function __asyncGenerator(thisArg, _arguments, generator) {
  20720. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  20721. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  20722. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  20723. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  20724. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  20725. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  20726. function fulfill(value) { resume("next", value); }
  20727. function reject(value) { resume("throw", value); }
  20728. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  20729. }
  20730. function __asyncDelegator(o) {
  20731. var i, p;
  20732. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  20733. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  20734. }
  20735. function __asyncValues(o) {
  20736. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  20737. var m = o[Symbol.asyncIterator], i;
  20738. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  20739. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  20740. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  20741. }
  20742. function __makeTemplateObject(cooked, raw) {
  20743. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  20744. return cooked;
  20745. };
  20746. function __importStar(mod) {
  20747. if (mod && mod.__esModule) return mod;
  20748. var result = {};
  20749. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  20750. result.default = mod;
  20751. return result;
  20752. }
  20753. function __importDefault(mod) {
  20754. return (mod && mod.__esModule) ? mod : { default: mod };
  20755. }
  20756. /***/ }),
  20757. /***/ "../../node_modules/webpack/buildin/global.js":
  20758. /*!***********************************!*\
  20759. !*** (webpack)/buildin/global.js ***!
  20760. \***********************************/
  20761. /*! no static exports found */
  20762. /***/ (function(module, exports) {
  20763. var g;
  20764. // This works in non-strict mode
  20765. g = (function() {
  20766. return this;
  20767. })();
  20768. try {
  20769. // This works if eval is allowed (see CSP)
  20770. g = g || new Function("return this")();
  20771. } catch (e) {
  20772. // This works if the window reference is available
  20773. if (typeof window === "object") g = window;
  20774. }
  20775. // g can still be undefined, but nothing to do about it...
  20776. // We return undefined, instead of nothing here, so it's
  20777. // easier to handle this case. if(!global) { ...}
  20778. module.exports = g;
  20779. /***/ }),
  20780. /***/ "./components/graphEditor.tsx":
  20781. /*!************************************!*\
  20782. !*** ./components/graphEditor.tsx ***!
  20783. \************************************/
  20784. /*! exports provided: GraphEditor */
  20785. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20786. "use strict";
  20787. __webpack_require__.r(__webpack_exports__);
  20788. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GraphEditor", function() { return GraphEditor; });
  20789. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  20790. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js");
  20791. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  20792. var GraphEditor = /** @class */ (function (_super) {
  20793. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GraphEditor, _super);
  20794. function GraphEditor(props) {
  20795. return _super.call(this, props) || this;
  20796. }
  20797. GraphEditor.prototype.render = function () {
  20798. return (react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", null));
  20799. };
  20800. return GraphEditor;
  20801. }(react__WEBPACK_IMPORTED_MODULE_1__["Component"]));
  20802. /***/ }),
  20803. /***/ "./globalState.ts":
  20804. /*!************************!*\
  20805. !*** ./globalState.ts ***!
  20806. \************************/
  20807. /*! exports provided: GlobalState */
  20808. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20809. "use strict";
  20810. __webpack_require__.r(__webpack_exports__);
  20811. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlobalState", function() { return GlobalState; });
  20812. var GlobalState = /** @class */ (function () {
  20813. function GlobalState() {
  20814. }
  20815. return GlobalState;
  20816. }());
  20817. /***/ }),
  20818. /***/ "./index.ts":
  20819. /*!******************!*\
  20820. !*** ./index.ts ***!
  20821. \******************/
  20822. /*! exports provided: NodeEditor */
  20823. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20824. "use strict";
  20825. __webpack_require__.r(__webpack_exports__);
  20826. /* harmony import */ var _nodeEditor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./nodeEditor */ "./nodeEditor.ts");
  20827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeEditor", function() { return _nodeEditor__WEBPACK_IMPORTED_MODULE_0__["NodeEditor"]; });
  20828. /***/ }),
  20829. /***/ "./legacy/legacy.ts":
  20830. /*!**************************!*\
  20831. !*** ./legacy/legacy.ts ***!
  20832. \**************************/
  20833. /*! exports provided: NodeEditor */
  20834. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20835. "use strict";
  20836. __webpack_require__.r(__webpack_exports__);
  20837. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  20838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NodeEditor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NodeEditor"]; });
  20839. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  20840. if (typeof globalObject !== "undefined") {
  20841. globalObject.BABYLON = globalObject.BABYLON || {};
  20842. globalObject.BABYLON.NodeEditor = _index__WEBPACK_IMPORTED_MODULE_0__["NodeEditor"];
  20843. }
  20844. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  20845. /***/ }),
  20846. /***/ "./nodeEditor.ts":
  20847. /*!***********************!*\
  20848. !*** ./nodeEditor.ts ***!
  20849. \***********************/
  20850. /*! exports provided: NodeEditor */
  20851. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20852. "use strict";
  20853. __webpack_require__.r(__webpack_exports__);
  20854. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NodeEditor", function() { return NodeEditor; });
  20855. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js");
  20856. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
  20857. /* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "../../node_modules/react-dom/index.js");
  20858. /* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_1__);
  20859. /* harmony import */ var _globalState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./globalState */ "./globalState.ts");
  20860. /* harmony import */ var _components_graphEditor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./components/graphEditor */ "./components/graphEditor.tsx");
  20861. /**
  20862. * Class used to create a node editor
  20863. */
  20864. var NodeEditor = /** @class */ (function () {
  20865. function NodeEditor() {
  20866. }
  20867. /**
  20868. * Show the node editor
  20869. * @param options defines the options to use to configure the node editor
  20870. */
  20871. NodeEditor.Show = function (options) {
  20872. var globalState = new _globalState__WEBPACK_IMPORTED_MODULE_2__["GlobalState"]();
  20873. var graphEditor = react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_components_graphEditor__WEBPACK_IMPORTED_MODULE_3__["GraphEditor"], {
  20874. globalState: globalState
  20875. });
  20876. react_dom__WEBPACK_IMPORTED_MODULE_1__["render"](graphEditor, options.hostElement);
  20877. };
  20878. return NodeEditor;
  20879. }());
  20880. /***/ })
  20881. /******/ });
  20882. });
  20883. //# sourceMappingURL=babylon.nodeEditor.max.js.map