babylon.sandbox.max.js 1.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs-loaders"), require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-sandbox", ["babylonjs-loaders", "babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-sandbox"] = factory(require("babylonjs-loaders"), require("babylonjs"));
  8. else
  9. root["SANDBOX"] = factory(root["BABYLON"], root["BABYLON"]);
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_babylonjs_loaders_glTF_glTFFileLoader__, __WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math_vector__) {
  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/css-loader/index.js!../../node_modules/sass-loader/dist/cjs.js!./scss/animationBar.scss":
  99. /*!*************************************************************************************************************************************!*\
  100. !*** D:/Repos/Babylon.js/node_modules/css-loader!D:/Repos/Babylon.js/node_modules/sass-loader/dist/cjs.js!./scss/animationBar.scss ***!
  101. \*************************************************************************************************************************************/
  102. /*! no static exports found */
  103. /***/ (function(module, exports, __webpack_require__) {
  104. exports = module.exports = __webpack_require__(/*! ../../../node_modules/css-loader/lib/css-base.js */ "../../node_modules/css-loader/lib/css-base.js")(false);
  105. // imports
  106. // module
  107. exports.push([module.i, ".animationBar {\n align-items: center;\n color: white;\n min-height: 30px;\n height: var(--footer-height);\n background-color: var(--footer-background);\n grid-column: 2;\n grid-row: 1;\n margin-left: 10px;\n display: flex;\n /*Chrome -webkit */\n /** FireFox -moz */\n /** IE -ms */ }\n .animationBar * {\n padding: 0px;\n margin: 0px; }\n .animationBar .row {\n display: flex;\n flex-direction: row;\n justify-content: center;\n flex-grow: 10;\n align-items: center; }\n .animationBar #playBtn {\n display: flex;\n align-items: center;\n height: var(--footer-height);\n width: var(--footer-height);\n border: none;\n background-color: inherit;\n cursor: pointer; }\n .animationBar #playBtn img {\n width: var(--footer-height);\n height: var(--footer-height); }\n .animationBar #playBtn:hover {\n background-color: var(--button-hover-color); }\n .animationBar #playBtn:active {\n background-color: var(--button-hover-background); }\n .animationBar #playBtn:focus {\n outline: none !important;\n border: none; }\n .animationBar .slider {\n -webkit-appearance: none;\n cursor: pointer;\n width: 100%;\n max-width: 820px;\n height: var(--footer-height);\n outline: none;\n margin-left: 20px;\n margin-right: 10px;\n background-color: transparent; }\n .animationBar .slider::-webkit-slider-thumb {\n -webkit-appearance: none;\n width: 20px;\n height: 20px;\n border: 2px solid white;\n border-radius: 50%;\n background: var(--footer-background);\n margin-top: -10px; }\n .animationBar .slider::-webkit-slider-runnable-track {\n height: 2px;\n -webkit-appearance: none;\n background-color: white; }\n .animationBar .slider::-moz-range-progress {\n background-color: white;\n height: 2px; }\n .animationBar .slider::-moz-range-thumb {\n width: 20px;\n height: 20px;\n border: 2px solid white;\n border-radius: 50%;\n background: var(--footer-background); }\n .animationBar .slider::-moz-range-track {\n background: white;\n height: 2px; }\n .animationBar .slider::-ms-track {\n height: 2px;\n /*remove bg colour from the track, we'll use ms-fill-lower and ms-fill-upper instead */\n background: transparent;\n /*leave room for the larger thumb to overflow with a transparent border */\n border-color: transparent;\n border-width: 10px 0;\n /*remove default tick marks*/\n color: transparent; }\n .animationBar .slider::-ms-fill-lower {\n background: white;\n border-radius: 5px; }\n .animationBar .slider::-ms-fill-upper {\n background: white;\n border-radius: 5px; }\n .animationBar .slider::-ms-thumb {\n width: 16px;\n height: 16px;\n border: 2px solid white;\n border-radius: 50%;\n background: var(--footer-background);\n margin-top: 0px; }\n", ""]);
  108. // exports
  109. /***/ }),
  110. /***/ "../../node_modules/css-loader/index.js!../../node_modules/sass-loader/dist/cjs.js!./scss/footer.scss":
  111. /*!*******************************************************************************************************************************!*\
  112. !*** D:/Repos/Babylon.js/node_modules/css-loader!D:/Repos/Babylon.js/node_modules/sass-loader/dist/cjs.js!./scss/footer.scss ***!
  113. \*******************************************************************************************************************************/
  114. /*! no static exports found */
  115. /***/ (function(module, exports, __webpack_require__) {
  116. exports = module.exports = __webpack_require__(/*! ../../../node_modules/css-loader/lib/css-base.js */ "../../node_modules/css-loader/lib/css-base.js")(false);
  117. // imports
  118. // module
  119. exports.push([module.i, ".footer {\n position: relative;\n width: 100%;\n height: var(--footer-height);\n margin: 0;\n padding: 0;\n background-color: var(--footer-background);\n font-size: 0;\n display: grid;\n grid-template-rows: 100%;\n grid-template-columns: 201px 1fr 210px; }\n .footer .footerLeft {\n display: grid;\n grid-column: 1;\n grid-row: 1;\n padding-left: 40px;\n align-content: center;\n overflow: hidden; }\n .footer .footerLeft #logoImg {\n height: var(--footer-height);\n width: 161px; }\n .footer .button {\n float: left;\n /* Float links side by side */\n width: var(--footer-height);\n height: var(--footer-height);\n margin: 0px;\n padding: 0;\n transition: all 0.3s ease;\n /* Add transition for hover effects */\n display: grid;\n align-content: center;\n justify-content: center;\n cursor: pointer; }\n .footer .button.long {\n width: 200px;\n grid-template-columns: var(--footer-height) calc(200px - var(--footer-height)); }\n .footer .button.long .button-icon {\n grid-row: 1;\n grid-column: 1; }\n .footer .button.long .button-text {\n grid-row: 1;\n grid-column: 2;\n align-self: center;\n justify-self: left;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: var(--font-size); }\n .footer .button.active {\n background-color: var(--button-hover-color); }\n .footer .button img {\n width: var(--footer-height);\n height: var(--footer-height); }\n .footer .button:hover {\n background-color: var(--button-hover-color); }\n .footer .button:active {\n background-color: var(--button-hover-background); }\n .footer .dropup {\n position: relative; }\n .footer .dropup .dropup-content {\n position: absolute;\n bottom: var(--footer-height);\n left: 0px;\n z-index: 100;\n width: calc(2 * var(--footer-height)); }\n .footer .dropup .dropup-content.long-mode {\n width: 200px; }\n .footer .dropup .dropup-content div {\n background-color: var(--button-hover-color);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: var(--font-size);\n width: 100%;\n color: white;\n cursor: pointer;\n height: 40px;\n box-sizing: border-box;\n padding: 0;\n margin: 0;\n display: grid;\n align-content: center;\n justify-content: center; }\n .footer .dropup .dropup-content div:hover {\n background-color: var(--button-hover-hover);\n transition: all 0.3s ease; }\n .footer .dropup .dropup-content div:active {\n background-color: var(--button-hover-background);\n transition: all 0.3s ease; }\n .footer .footerRight {\n display: flex;\n flex-direction: row-reverse;\n grid-column: 3;\n grid-row: 1; }\n .footer .footerRight .custom-upload {\n position: relative;\n background-position: center right;\n background-repeat: no-repeat;\n width: var(--footer-height);\n height: var(--footer-height);\n cursor: pointer;\n display: grid; }\n .footer .footerRight .custom-upload img {\n grid-row: 1;\n grid-column: 1;\n width: var(--footer-height);\n height: var(--footer-height);\n pointer-events: none; }\n .footer .footerRight .custom-upload:hover {\n background-color: var(--button-hover-color); }\n .footer .footerRight .custom-upload:active {\n background-color: var(--button-hover-background); }\n .footer .footerRight .custom-upload input[type=file] {\n grid-row: 1;\n grid-column: 1;\n outline: none;\n position: relative;\n text-align: right;\n -moz-opacity: 0;\n opacity: 0;\n z-index: 2;\n width: 100%;\n height: 100%;\n filter: alpha(opacity=0); }\n", ""]);
  120. // exports
  121. /***/ }),
  122. /***/ "../../node_modules/css-loader/index.js!../../node_modules/sass-loader/dist/cjs.js!./scss/main.scss":
  123. /*!*****************************************************************************************************************************!*\
  124. !*** D:/Repos/Babylon.js/node_modules/css-loader!D:/Repos/Babylon.js/node_modules/sass-loader/dist/cjs.js!./scss/main.scss ***!
  125. \*****************************************************************************************************************************/
  126. /*! no static exports found */
  127. /***/ (function(module, exports, __webpack_require__) {
  128. exports = module.exports = __webpack_require__(/*! ../../../node_modules/css-loader/lib/css-base.js */ "../../node_modules/css-loader/lib/css-base.js")(false);
  129. // imports
  130. // module
  131. exports.push([module.i, "html {\n --background: #2A2342;\n --footer-background: #201936;\n --footer-height: 70px;\n --button-hover-color: #BB464B;\n --button-hover-hover: #e0684b;\n --button-hover-background: #162D3A;\n --font-size: 20px; }\n\nhtml, body, #root {\n width: 100%;\n height: 100%;\n padding: 0;\n margin: 0;\n overflow: hidden;\n font-size: var(--font-size);\n background: var(--background);\n font-family: \"acumin-pro-condensed\";\n font-weight: normal; }\n\n.hidden {\n display: none !important; }\n\n.clickInterceptor {\n position: absolute;\n width: 100%;\n height: 100%;\n z-index: 99;\n top: 0;\n left: 0; }\n\n#droptext {\n position: absolute;\n text-align: center;\n color: #fff;\n height: 50px;\n width: 100%;\n bottom: 50px; }\n\n#logoContainer {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: calc(100% - 70px);\n pointer-events: none; }\n\n#logo {\n position: absolute;\n width: 20%;\n height: 20%;\n top: 40%;\n left: 40%;\n pointer-events: none; }\n\n#errorZone {\n position: absolute;\n width: 50%;\n left: 25%;\n bottom: 80px;\n background-color: #C73228;\n padding: 20px;\n border-radius: 5px;\n color: white;\n display: grid;\n grid-template-columns: 1fr 32px; }\n #errorZone .message {\n grid-column: 1;\n grid-row: 1;\n align-self: center; }\n #errorZone button {\n grid-column: 2;\n grid-row: 1;\n padding: 0;\n cursor: pointer;\n background: transparent;\n border: 0;\n -webkit-appearance: none;\n color: #000;\n text-shadow: 0 1px 0 #fff;\n opacity: .4;\n font-size: 1.8em; }\n #errorZone button:hover {\n transform: scale(1.2); }\n", ""]);
  132. // exports
  133. /***/ }),
  134. /***/ "../../node_modules/css-loader/index.js!../../node_modules/sass-loader/dist/cjs.js!./scss/renderingZone.scss":
  135. /*!**************************************************************************************************************************************!*\
  136. !*** D:/Repos/Babylon.js/node_modules/css-loader!D:/Repos/Babylon.js/node_modules/sass-loader/dist/cjs.js!./scss/renderingZone.scss ***!
  137. \**************************************************************************************************************************************/
  138. /*! no static exports found */
  139. /***/ (function(module, exports, __webpack_require__) {
  140. exports = module.exports = __webpack_require__(/*! ../../../node_modules/css-loader/lib/css-base.js */ "../../node_modules/css-loader/lib/css-base.js")(false);
  141. // imports
  142. // module
  143. exports.push([module.i, "#canvasZone {\n display: block;\n padding: 0;\n margin: 0;\n overflow: hidden;\n width: 100%;\n height: calc(100% - var(--footer-height)); }\n #canvasZone.expanded {\n height: 100%; }\n\n#renderCanvas {\n position: relative;\n overflow: hidden;\n width: 100%;\n height: 100%;\n margin: 0;\n padding: 0;\n touch-action: none;\n -ms-touch-action: none;\n display: block;\n border: 0;\n outline: 0; }\n", ""]);
  144. // exports
  145. /***/ }),
  146. /***/ "../../node_modules/css-loader/lib/css-base.js":
  147. /*!*******************************************************************!*\
  148. !*** D:/Repos/Babylon.js/node_modules/css-loader/lib/css-base.js ***!
  149. \*******************************************************************/
  150. /*! no static exports found */
  151. /***/ (function(module, exports) {
  152. /*
  153. MIT License http://www.opensource.org/licenses/mit-license.php
  154. Author Tobias Koppers @sokra
  155. */
  156. // css base code, injected by the css-loader
  157. module.exports = function(useSourceMap) {
  158. var list = [];
  159. // return the list of modules as css string
  160. list.toString = function toString() {
  161. return this.map(function (item) {
  162. var content = cssWithMappingToString(item, useSourceMap);
  163. if(item[2]) {
  164. return "@media " + item[2] + "{" + content + "}";
  165. } else {
  166. return content;
  167. }
  168. }).join("");
  169. };
  170. // import a list of modules into the list
  171. list.i = function(modules, mediaQuery) {
  172. if(typeof modules === "string")
  173. modules = [[null, modules, ""]];
  174. var alreadyImportedModules = {};
  175. for(var i = 0; i < this.length; i++) {
  176. var id = this[i][0];
  177. if(typeof id === "number")
  178. alreadyImportedModules[id] = true;
  179. }
  180. for(i = 0; i < modules.length; i++) {
  181. var item = modules[i];
  182. // skip already imported module
  183. // this implementation is not 100% perfect for weird media query combinations
  184. // when a module is imported multiple times with different media queries.
  185. // I hope this will never occur (Hey this way we have smaller bundles)
  186. if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
  187. if(mediaQuery && !item[2]) {
  188. item[2] = mediaQuery;
  189. } else if(mediaQuery) {
  190. item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
  191. }
  192. list.push(item);
  193. }
  194. }
  195. };
  196. return list;
  197. };
  198. function cssWithMappingToString(item, useSourceMap) {
  199. var content = item[1] || '';
  200. var cssMapping = item[3];
  201. if (!cssMapping) {
  202. return content;
  203. }
  204. if (useSourceMap && typeof btoa === 'function') {
  205. var sourceMapping = toComment(cssMapping);
  206. var sourceURLs = cssMapping.sources.map(function (source) {
  207. return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
  208. });
  209. return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
  210. }
  211. return [content].join('\n');
  212. }
  213. // Adapted from convert-source-map (MIT)
  214. function toComment(sourceMap) {
  215. // eslint-disable-next-line no-undef
  216. var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
  217. var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
  218. return '/*# ' + data + ' */';
  219. }
  220. /***/ }),
  221. /***/ "../../node_modules/object-assign/index.js":
  222. /*!***************************************************************!*\
  223. !*** D:/Repos/Babylon.js/node_modules/object-assign/index.js ***!
  224. \***************************************************************/
  225. /*! no static exports found */
  226. /***/ (function(module, exports, __webpack_require__) {
  227. "use strict";
  228. /*
  229. object-assign
  230. (c) Sindre Sorhus
  231. @license MIT
  232. */
  233. /* eslint-disable no-unused-vars */
  234. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  235. var hasOwnProperty = Object.prototype.hasOwnProperty;
  236. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  237. function toObject(val) {
  238. if (val === null || val === undefined) {
  239. throw new TypeError('Object.assign cannot be called with null or undefined');
  240. }
  241. return Object(val);
  242. }
  243. function shouldUseNative() {
  244. try {
  245. if (!Object.assign) {
  246. return false;
  247. }
  248. // Detect buggy property enumeration order in older V8 versions.
  249. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  250. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  251. test1[5] = 'de';
  252. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  253. return false;
  254. }
  255. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  256. var test2 = {};
  257. for (var i = 0; i < 10; i++) {
  258. test2['_' + String.fromCharCode(i)] = i;
  259. }
  260. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  261. return test2[n];
  262. });
  263. if (order2.join('') !== '0123456789') {
  264. return false;
  265. }
  266. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  267. var test3 = {};
  268. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  269. test3[letter] = letter;
  270. });
  271. if (Object.keys(Object.assign({}, test3)).join('') !==
  272. 'abcdefghijklmnopqrst') {
  273. return false;
  274. }
  275. return true;
  276. } catch (err) {
  277. // We don't expect any of the above to throw, but better to be safe.
  278. return false;
  279. }
  280. }
  281. module.exports = shouldUseNative() ? Object.assign : function (target, source) {
  282. var from;
  283. var to = toObject(target);
  284. var symbols;
  285. for (var s = 1; s < arguments.length; s++) {
  286. from = Object(arguments[s]);
  287. for (var key in from) {
  288. if (hasOwnProperty.call(from, key)) {
  289. to[key] = from[key];
  290. }
  291. }
  292. if (getOwnPropertySymbols) {
  293. symbols = getOwnPropertySymbols(from);
  294. for (var i = 0; i < symbols.length; i++) {
  295. if (propIsEnumerable.call(from, symbols[i])) {
  296. to[symbols[i]] = from[symbols[i]];
  297. }
  298. }
  299. }
  300. }
  301. return to;
  302. };
  303. /***/ }),
  304. /***/ "../../node_modules/prop-types/checkPropTypes.js":
  305. /*!*********************************************************************!*\
  306. !*** D:/Repos/Babylon.js/node_modules/prop-types/checkPropTypes.js ***!
  307. \*********************************************************************/
  308. /*! no static exports found */
  309. /***/ (function(module, exports, __webpack_require__) {
  310. "use strict";
  311. /**
  312. * Copyright (c) 2013-present, Facebook, Inc.
  313. *
  314. * This source code is licensed under the MIT license found in the
  315. * LICENSE file in the root directory of this source tree.
  316. */
  317. var printWarning = function() {};
  318. if (true) {
  319. var ReactPropTypesSecret = __webpack_require__(/*! ./lib/ReactPropTypesSecret */ "../../node_modules/prop-types/lib/ReactPropTypesSecret.js");
  320. var loggedTypeFailures = {};
  321. var has = Function.call.bind(Object.prototype.hasOwnProperty);
  322. printWarning = function(text) {
  323. var message = 'Warning: ' + text;
  324. if (typeof console !== 'undefined') {
  325. console.error(message);
  326. }
  327. try {
  328. // --- Welcome to debugging React ---
  329. // This error was thrown as a convenience so that you can use this stack
  330. // to find the callsite that caused this warning to fire.
  331. throw new Error(message);
  332. } catch (x) {}
  333. };
  334. }
  335. /**
  336. * Assert that the values match with the type specs.
  337. * Error messages are memorized and will only be shown once.
  338. *
  339. * @param {object} typeSpecs Map of name to a ReactPropType
  340. * @param {object} values Runtime values that need to be type-checked
  341. * @param {string} location e.g. "prop", "context", "child context"
  342. * @param {string} componentName Name of the component for error messages.
  343. * @param {?Function} getStack Returns the component stack.
  344. * @private
  345. */
  346. function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
  347. if (true) {
  348. for (var typeSpecName in typeSpecs) {
  349. if (has(typeSpecs, typeSpecName)) {
  350. var error;
  351. // Prop type validation may throw. In case they do, we don't want to
  352. // fail the render phase where it didn't fail before. So we log it.
  353. // After these have been cleaned up, we'll let them throw.
  354. try {
  355. // This is intentionally an invariant that gets caught. It's the same
  356. // behavior as without this statement except with a better message.
  357. if (typeof typeSpecs[typeSpecName] !== 'function') {
  358. var err = Error(
  359. (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
  360. 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
  361. );
  362. err.name = 'Invariant Violation';
  363. throw err;
  364. }
  365. error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
  366. } catch (ex) {
  367. error = ex;
  368. }
  369. if (error && !(error instanceof Error)) {
  370. printWarning(
  371. (componentName || 'React class') + ': type specification of ' +
  372. location + ' `' + typeSpecName + '` is invalid; the type checker ' +
  373. 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
  374. 'You may have forgotten to pass an argument to the type checker ' +
  375. 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
  376. 'shape all require an argument).'
  377. );
  378. }
  379. if (error instanceof Error && !(error.message in loggedTypeFailures)) {
  380. // Only monitor this failure once because there tends to be a lot of the
  381. // same error.
  382. loggedTypeFailures[error.message] = true;
  383. var stack = getStack ? getStack() : '';
  384. printWarning(
  385. 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
  386. );
  387. }
  388. }
  389. }
  390. }
  391. }
  392. /**
  393. * Resets warning cache when testing.
  394. *
  395. * @private
  396. */
  397. checkPropTypes.resetWarningCache = function() {
  398. if (true) {
  399. loggedTypeFailures = {};
  400. }
  401. }
  402. module.exports = checkPropTypes;
  403. /***/ }),
  404. /***/ "../../node_modules/prop-types/lib/ReactPropTypesSecret.js":
  405. /*!*******************************************************************************!*\
  406. !*** D:/Repos/Babylon.js/node_modules/prop-types/lib/ReactPropTypesSecret.js ***!
  407. \*******************************************************************************/
  408. /*! no static exports found */
  409. /***/ (function(module, exports, __webpack_require__) {
  410. "use strict";
  411. /**
  412. * Copyright (c) 2013-present, Facebook, Inc.
  413. *
  414. * This source code is licensed under the MIT license found in the
  415. * LICENSE file in the root directory of this source tree.
  416. */
  417. var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  418. module.exports = ReactPropTypesSecret;
  419. /***/ }),
  420. /***/ "../../node_modules/react-dom/cjs/react-dom.development.js":
  421. /*!*******************************************************************************!*\
  422. !*** D:/Repos/Babylon.js/node_modules/react-dom/cjs/react-dom.development.js ***!
  423. \*******************************************************************************/
  424. /*! no static exports found */
  425. /***/ (function(module, exports, __webpack_require__) {
  426. "use strict";
  427. /** @license React v16.9.0
  428. * react-dom.development.js
  429. *
  430. * Copyright (c) Facebook, Inc. and its affiliates.
  431. *
  432. * This source code is licensed under the MIT license found in the
  433. * LICENSE file in the root directory of this source tree.
  434. */
  435. if (true) {
  436. (function() {
  437. 'use strict';
  438. var React = __webpack_require__(/*! react */ "../../node_modules/react/index.js");
  439. var _assign = __webpack_require__(/*! object-assign */ "../../node_modules/object-assign/index.js");
  440. var checkPropTypes = __webpack_require__(/*! prop-types/checkPropTypes */ "../../node_modules/prop-types/checkPropTypes.js");
  441. var Scheduler = __webpack_require__(/*! scheduler */ "../../node_modules/scheduler/index.js");
  442. var tracing = __webpack_require__(/*! scheduler/tracing */ "../../node_modules/scheduler/tracing.js");
  443. // Do not require this module directly! Use normal `invariant` calls with
  444. // template literal strings. The messages will be converted to ReactError during
  445. // build, and in production they will be minified.
  446. // Do not require this module directly! Use normal `invariant` calls with
  447. // template literal strings. The messages will be converted to ReactError during
  448. // build, and in production they will be minified.
  449. function ReactError(error) {
  450. error.name = 'Invariant Violation';
  451. return error;
  452. }
  453. /**
  454. * Use invariant() to assert state which your program assumes to be true.
  455. *
  456. * Provide sprintf-style format (only %s is supported) and arguments
  457. * to provide information about what broke and what you were
  458. * expecting.
  459. *
  460. * The invariant message will be stripped in production, but the invariant
  461. * will remain to ensure logic does not differ in production.
  462. */
  463. (function () {
  464. if (!React) {
  465. {
  466. throw ReactError(Error('ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM.'));
  467. }
  468. }
  469. })();
  470. /**
  471. * Injectable ordering of event plugins.
  472. */
  473. var eventPluginOrder = null;
  474. /**
  475. * Injectable mapping from names to event plugin modules.
  476. */
  477. var namesToPlugins = {};
  478. /**
  479. * Recomputes the plugin list using the injected plugins and plugin ordering.
  480. *
  481. * @private
  482. */
  483. function recomputePluginOrdering() {
  484. if (!eventPluginOrder) {
  485. // Wait until an `eventPluginOrder` is injected.
  486. return;
  487. }
  488. for (var pluginName in namesToPlugins) {
  489. var pluginModule = namesToPlugins[pluginName];
  490. var pluginIndex = eventPluginOrder.indexOf(pluginName);
  491. (function () {
  492. if (!(pluginIndex > -1)) {
  493. {
  494. throw ReactError(Error('EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `' + pluginName + '`.'));
  495. }
  496. }
  497. })();
  498. if (plugins[pluginIndex]) {
  499. continue;
  500. }
  501. (function () {
  502. if (!pluginModule.extractEvents) {
  503. {
  504. throw ReactError(Error('EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `' + pluginName + '` does not.'));
  505. }
  506. }
  507. })();
  508. plugins[pluginIndex] = pluginModule;
  509. var publishedEvents = pluginModule.eventTypes;
  510. for (var eventName in publishedEvents) {
  511. (function () {
  512. if (!publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName)) {
  513. {
  514. throw ReactError(Error('EventPluginRegistry: Failed to publish event `' + eventName + '` for plugin `' + pluginName + '`.'));
  515. }
  516. }
  517. })();
  518. }
  519. }
  520. }
  521. /**
  522. * Publishes an event so that it can be dispatched by the supplied plugin.
  523. *
  524. * @param {object} dispatchConfig Dispatch configuration for the event.
  525. * @param {object} PluginModule Plugin publishing the event.
  526. * @return {boolean} True if the event was successfully published.
  527. * @private
  528. */
  529. function publishEventForPlugin(dispatchConfig, pluginModule, eventName) {
  530. (function () {
  531. if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) {
  532. {
  533. throw ReactError(Error('EventPluginHub: More than one plugin attempted to publish the same event name, `' + eventName + '`.'));
  534. }
  535. }
  536. })();
  537. eventNameDispatchConfigs[eventName] = dispatchConfig;
  538. var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
  539. if (phasedRegistrationNames) {
  540. for (var phaseName in phasedRegistrationNames) {
  541. if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
  542. var phasedRegistrationName = phasedRegistrationNames[phaseName];
  543. publishRegistrationName(phasedRegistrationName, pluginModule, eventName);
  544. }
  545. }
  546. return true;
  547. } else if (dispatchConfig.registrationName) {
  548. publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName);
  549. return true;
  550. }
  551. return false;
  552. }
  553. /**
  554. * Publishes a registration name that is used to identify dispatched events.
  555. *
  556. * @param {string} registrationName Registration name to add.
  557. * @param {object} PluginModule Plugin publishing the event.
  558. * @private
  559. */
  560. function publishRegistrationName(registrationName, pluginModule, eventName) {
  561. (function () {
  562. if (!!registrationNameModules[registrationName]) {
  563. {
  564. throw ReactError(Error('EventPluginHub: More than one plugin attempted to publish the same registration name, `' + registrationName + '`.'));
  565. }
  566. }
  567. })();
  568. registrationNameModules[registrationName] = pluginModule;
  569. registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies;
  570. {
  571. var lowerCasedName = registrationName.toLowerCase();
  572. possibleRegistrationNames[lowerCasedName] = registrationName;
  573. if (registrationName === 'onDoubleClick') {
  574. possibleRegistrationNames.ondblclick = registrationName;
  575. }
  576. }
  577. }
  578. /**
  579. * Registers plugins so that they can extract and dispatch events.
  580. *
  581. * @see {EventPluginHub}
  582. */
  583. /**
  584. * Ordered list of injected plugins.
  585. */
  586. var plugins = [];
  587. /**
  588. * Mapping from event name to dispatch config
  589. */
  590. var eventNameDispatchConfigs = {};
  591. /**
  592. * Mapping from registration name to plugin module
  593. */
  594. var registrationNameModules = {};
  595. /**
  596. * Mapping from registration name to event name
  597. */
  598. var registrationNameDependencies = {};
  599. /**
  600. * Mapping from lowercase registration names to the properly cased version,
  601. * used to warn in the case of missing event handlers. Available
  602. * only in true.
  603. * @type {Object}
  604. */
  605. var possibleRegistrationNames = {};
  606. // Trust the developer to only use possibleRegistrationNames in true
  607. /**
  608. * Injects an ordering of plugins (by plugin name). This allows the ordering
  609. * to be decoupled from injection of the actual plugins so that ordering is
  610. * always deterministic regardless of packaging, on-the-fly injection, etc.
  611. *
  612. * @param {array} InjectedEventPluginOrder
  613. * @internal
  614. * @see {EventPluginHub.injection.injectEventPluginOrder}
  615. */
  616. function injectEventPluginOrder(injectedEventPluginOrder) {
  617. (function () {
  618. if (!!eventPluginOrder) {
  619. {
  620. throw ReactError(Error('EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React.'));
  621. }
  622. }
  623. })();
  624. // Clone the ordering so it cannot be dynamically mutated.
  625. eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder);
  626. recomputePluginOrdering();
  627. }
  628. /**
  629. * Injects plugins to be used by `EventPluginHub`. The plugin names must be
  630. * in the ordering injected by `injectEventPluginOrder`.
  631. *
  632. * Plugins can be injected as part of page initialization or on-the-fly.
  633. *
  634. * @param {object} injectedNamesToPlugins Map from names to plugin modules.
  635. * @internal
  636. * @see {EventPluginHub.injection.injectEventPluginsByName}
  637. */
  638. function injectEventPluginsByName(injectedNamesToPlugins) {
  639. var isOrderingDirty = false;
  640. for (var pluginName in injectedNamesToPlugins) {
  641. if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
  642. continue;
  643. }
  644. var pluginModule = injectedNamesToPlugins[pluginName];
  645. if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule) {
  646. (function () {
  647. if (!!namesToPlugins[pluginName]) {
  648. {
  649. throw ReactError(Error('EventPluginRegistry: Cannot inject two different event plugins using the same name, `' + pluginName + '`.'));
  650. }
  651. }
  652. })();
  653. namesToPlugins[pluginName] = pluginModule;
  654. isOrderingDirty = true;
  655. }
  656. }
  657. if (isOrderingDirty) {
  658. recomputePluginOrdering();
  659. }
  660. }
  661. var invokeGuardedCallbackImpl = function (name, func, context, a, b, c, d, e, f) {
  662. var funcArgs = Array.prototype.slice.call(arguments, 3);
  663. try {
  664. func.apply(context, funcArgs);
  665. } catch (error) {
  666. this.onError(error);
  667. }
  668. };
  669. {
  670. // In DEV mode, we swap out invokeGuardedCallback for a special version
  671. // that plays more nicely with the browser's DevTools. The idea is to preserve
  672. // "Pause on exceptions" behavior. Because React wraps all user-provided
  673. // functions in invokeGuardedCallback, and the production version of
  674. // invokeGuardedCallback uses a try-catch, all user exceptions are treated
  675. // like caught exceptions, and the DevTools won't pause unless the developer
  676. // takes the extra step of enabling pause on caught exceptions. This is
  677. // unintuitive, though, because even though React has caught the error, from
  678. // the developer's perspective, the error is uncaught.
  679. //
  680. // To preserve the expected "Pause on exceptions" behavior, we don't use a
  681. // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake
  682. // DOM node, and call the user-provided callback from inside an event handler
  683. // for that fake event. If the callback throws, the error is "captured" using
  684. // a global event handler. But because the error happens in a different
  685. // event loop context, it does not interrupt the normal program flow.
  686. // Effectively, this gives us try-catch behavior without actually using
  687. // try-catch. Neat!
  688. // Check that the browser supports the APIs we need to implement our special
  689. // DEV version of invokeGuardedCallback
  690. if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
  691. var fakeNode = document.createElement('react');
  692. var invokeGuardedCallbackDev = function (name, func, context, a, b, c, d, e, f) {
  693. // If document doesn't exist we know for sure we will crash in this method
  694. // when we call document.createEvent(). However this can cause confusing
  695. // errors: https://github.com/facebookincubator/create-react-app/issues/3482
  696. // So we preemptively throw with a better message instead.
  697. (function () {
  698. if (!(typeof document !== 'undefined')) {
  699. {
  700. throw ReactError(Error('The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous.'));
  701. }
  702. }
  703. })();
  704. var evt = document.createEvent('Event');
  705. // Keeps track of whether the user-provided callback threw an error. We
  706. // set this to true at the beginning, then set it to false right after
  707. // calling the function. If the function errors, `didError` will never be
  708. // set to false. This strategy works even if the browser is flaky and
  709. // fails to call our global error handler, because it doesn't rely on
  710. // the error event at all.
  711. var didError = true;
  712. // Keeps track of the value of window.event so that we can reset it
  713. // during the callback to let user code access window.event in the
  714. // browsers that support it.
  715. var windowEvent = window.event;
  716. // Keeps track of the descriptor of window.event to restore it after event
  717. // dispatching: https://github.com/facebook/react/issues/13688
  718. var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event');
  719. // Create an event handler for our fake event. We will synchronously
  720. // dispatch our fake event using `dispatchEvent`. Inside the handler, we
  721. // call the user-provided callback.
  722. var funcArgs = Array.prototype.slice.call(arguments, 3);
  723. function callCallback() {
  724. // We immediately remove the callback from event listeners so that
  725. // nested `invokeGuardedCallback` calls do not clash. Otherwise, a
  726. // nested call would trigger the fake event handlers of any call higher
  727. // in the stack.
  728. fakeNode.removeEventListener(evtType, callCallback, false);
  729. // We check for window.hasOwnProperty('event') to prevent the
  730. // window.event assignment in both IE <= 10 as they throw an error
  731. // "Member not found" in strict mode, and in Firefox which does not
  732. // support window.event.
  733. if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) {
  734. window.event = windowEvent;
  735. }
  736. func.apply(context, funcArgs);
  737. didError = false;
  738. }
  739. // Create a global error event handler. We use this to capture the value
  740. // that was thrown. It's possible that this error handler will fire more
  741. // than once; for example, if non-React code also calls `dispatchEvent`
  742. // and a handler for that event throws. We should be resilient to most of
  743. // those cases. Even if our error event handler fires more than once, the
  744. // last error event is always used. If the callback actually does error,
  745. // we know that the last error event is the correct one, because it's not
  746. // possible for anything else to have happened in between our callback
  747. // erroring and the code that follows the `dispatchEvent` call below. If
  748. // the callback doesn't error, but the error event was fired, we know to
  749. // ignore it because `didError` will be false, as described above.
  750. var error = void 0;
  751. // Use this to track whether the error event is ever called.
  752. var didSetError = false;
  753. var isCrossOriginError = false;
  754. function handleWindowError(event) {
  755. error = event.error;
  756. didSetError = true;
  757. if (error === null && event.colno === 0 && event.lineno === 0) {
  758. isCrossOriginError = true;
  759. }
  760. if (event.defaultPrevented) {
  761. // Some other error handler has prevented default.
  762. // Browsers silence the error report if this happens.
  763. // We'll remember this to later decide whether to log it or not.
  764. if (error != null && typeof error === 'object') {
  765. try {
  766. error._suppressLogging = true;
  767. } catch (inner) {
  768. // Ignore.
  769. }
  770. }
  771. }
  772. }
  773. // Create a fake event type.
  774. var evtType = 'react-' + (name ? name : 'invokeguardedcallback');
  775. // Attach our event handlers
  776. window.addEventListener('error', handleWindowError);
  777. fakeNode.addEventListener(evtType, callCallback, false);
  778. // Synchronously dispatch our fake event. If the user-provided function
  779. // errors, it will trigger our global error handler.
  780. evt.initEvent(evtType, false, false);
  781. fakeNode.dispatchEvent(evt);
  782. if (windowEventDescriptor) {
  783. Object.defineProperty(window, 'event', windowEventDescriptor);
  784. }
  785. if (didError) {
  786. if (!didSetError) {
  787. // The callback errored, but the error event never fired.
  788. 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.');
  789. } else if (isCrossOriginError) {
  790. 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.');
  791. }
  792. this.onError(error);
  793. }
  794. // Remove our event listeners
  795. window.removeEventListener('error', handleWindowError);
  796. };
  797. invokeGuardedCallbackImpl = invokeGuardedCallbackDev;
  798. }
  799. }
  800. var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl;
  801. // Used by Fiber to simulate a try-catch.
  802. var hasError = false;
  803. var caughtError = null;
  804. // Used by event system to capture/rethrow the first error.
  805. var hasRethrowError = false;
  806. var rethrowError = null;
  807. var reporter = {
  808. onError: function (error) {
  809. hasError = true;
  810. caughtError = error;
  811. }
  812. };
  813. /**
  814. * Call a function while guarding against errors that happens within it.
  815. * Returns an error if it throws, otherwise null.
  816. *
  817. * In production, this is implemented using a try-catch. The reason we don't
  818. * use a try-catch directly is so that we can swap out a different
  819. * implementation in DEV mode.
  820. *
  821. * @param {String} name of the guard to use for logging or debugging
  822. * @param {Function} func The function to invoke
  823. * @param {*} context The context to use when calling the function
  824. * @param {...*} args Arguments for function
  825. */
  826. function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
  827. hasError = false;
  828. caughtError = null;
  829. invokeGuardedCallbackImpl$1.apply(reporter, arguments);
  830. }
  831. /**
  832. * Same as invokeGuardedCallback, but instead of returning an error, it stores
  833. * it in a global so it can be rethrown by `rethrowCaughtError` later.
  834. * TODO: See if caughtError and rethrowError can be unified.
  835. *
  836. * @param {String} name of the guard to use for logging or debugging
  837. * @param {Function} func The function to invoke
  838. * @param {*} context The context to use when calling the function
  839. * @param {...*} args Arguments for function
  840. */
  841. function invokeGuardedCallbackAndCatchFirstError(name, func, context, a, b, c, d, e, f) {
  842. invokeGuardedCallback.apply(this, arguments);
  843. if (hasError) {
  844. var error = clearCaughtError();
  845. if (!hasRethrowError) {
  846. hasRethrowError = true;
  847. rethrowError = error;
  848. }
  849. }
  850. }
  851. /**
  852. * During execution of guarded functions we will capture the first error which
  853. * we will rethrow to be handled by the top level error handler.
  854. */
  855. function rethrowCaughtError() {
  856. if (hasRethrowError) {
  857. var error = rethrowError;
  858. hasRethrowError = false;
  859. rethrowError = null;
  860. throw error;
  861. }
  862. }
  863. function hasCaughtError() {
  864. return hasError;
  865. }
  866. function clearCaughtError() {
  867. if (hasError) {
  868. var error = caughtError;
  869. hasError = false;
  870. caughtError = null;
  871. return error;
  872. } else {
  873. (function () {
  874. {
  875. {
  876. throw ReactError(Error('clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue.'));
  877. }
  878. }
  879. })();
  880. }
  881. }
  882. /**
  883. * Similar to invariant but only logs a warning if the condition is not met.
  884. * This can be used to log issues in development environments in critical
  885. * paths. Removing the logging code for production environments will keep the
  886. * same logic and follow the same code paths.
  887. */
  888. var warningWithoutStack = function () {};
  889. {
  890. warningWithoutStack = function (condition, format) {
  891. for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  892. args[_key - 2] = arguments[_key];
  893. }
  894. if (format === undefined) {
  895. throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
  896. }
  897. if (args.length > 8) {
  898. // Check before the condition to catch violations early.
  899. throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
  900. }
  901. if (condition) {
  902. return;
  903. }
  904. if (typeof console !== 'undefined') {
  905. var argsWithFormat = args.map(function (item) {
  906. return '' + item;
  907. });
  908. argsWithFormat.unshift('Warning: ' + format);
  909. // We intentionally don't use spread (or .apply) directly because it
  910. // breaks IE9: https://github.com/facebook/react/issues/13610
  911. Function.prototype.apply.call(console.error, console, argsWithFormat);
  912. }
  913. try {
  914. // --- Welcome to debugging React ---
  915. // This error was thrown as a convenience so that you can use this stack
  916. // to find the callsite that caused this warning to fire.
  917. var argIndex = 0;
  918. var message = 'Warning: ' + format.replace(/%s/g, function () {
  919. return args[argIndex++];
  920. });
  921. throw new Error(message);
  922. } catch (x) {}
  923. };
  924. }
  925. var warningWithoutStack$1 = warningWithoutStack;
  926. var getFiberCurrentPropsFromNode = null;
  927. var getInstanceFromNode = null;
  928. var getNodeFromInstance = null;
  929. function setComponentTree(getFiberCurrentPropsFromNodeImpl, getInstanceFromNodeImpl, getNodeFromInstanceImpl) {
  930. getFiberCurrentPropsFromNode = getFiberCurrentPropsFromNodeImpl;
  931. getInstanceFromNode = getInstanceFromNodeImpl;
  932. getNodeFromInstance = getNodeFromInstanceImpl;
  933. {
  934. !(getNodeFromInstance && getInstanceFromNode) ? warningWithoutStack$1(false, 'EventPluginUtils.setComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.') : void 0;
  935. }
  936. }
  937. var validateEventDispatches = void 0;
  938. {
  939. validateEventDispatches = function (event) {
  940. var dispatchListeners = event._dispatchListeners;
  941. var dispatchInstances = event._dispatchInstances;
  942. var listenersIsArr = Array.isArray(dispatchListeners);
  943. var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
  944. var instancesIsArr = Array.isArray(dispatchInstances);
  945. var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0;
  946. !(instancesIsArr === listenersIsArr && instancesLen === listenersLen) ? warningWithoutStack$1(false, 'EventPluginUtils: Invalid `event`.') : void 0;
  947. };
  948. }
  949. /**
  950. * Dispatch the event to the listener.
  951. * @param {SyntheticEvent} event SyntheticEvent to handle
  952. * @param {function} listener Application-level callback
  953. * @param {*} inst Internal component instance
  954. */
  955. function executeDispatch(event, listener, inst) {
  956. var type = event.type || 'unknown-event';
  957. event.currentTarget = getNodeFromInstance(inst);
  958. invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event);
  959. event.currentTarget = null;
  960. }
  961. /**
  962. * Standard/simple iteration through an event's collected dispatches.
  963. */
  964. function executeDispatchesInOrder(event) {
  965. var dispatchListeners = event._dispatchListeners;
  966. var dispatchInstances = event._dispatchInstances;
  967. {
  968. validateEventDispatches(event);
  969. }
  970. if (Array.isArray(dispatchListeners)) {
  971. for (var i = 0; i < dispatchListeners.length; i++) {
  972. if (event.isPropagationStopped()) {
  973. break;
  974. }
  975. // Listeners and Instances are two parallel arrays that are always in sync.
  976. executeDispatch(event, dispatchListeners[i], dispatchInstances[i]);
  977. }
  978. } else if (dispatchListeners) {
  979. executeDispatch(event, dispatchListeners, dispatchInstances);
  980. }
  981. event._dispatchListeners = null;
  982. event._dispatchInstances = null;
  983. }
  984. /**
  985. * @see executeDispatchesInOrderStopAtTrueImpl
  986. */
  987. /**
  988. * Execution of a "direct" dispatch - there must be at most one dispatch
  989. * accumulated on the event or it is considered an error. It doesn't really make
  990. * sense for an event with multiple dispatches (bubbled) to keep track of the
  991. * return values at each dispatch execution, but it does tend to make sense when
  992. * dealing with "direct" dispatches.
  993. *
  994. * @return {*} The return value of executing the single dispatch.
  995. */
  996. /**
  997. * @param {SyntheticEvent} event
  998. * @return {boolean} True iff number of dispatches accumulated is greater than 0.
  999. */
  1000. /**
  1001. * Accumulates items that must not be null or undefined into the first one. This
  1002. * is used to conserve memory by avoiding array allocations, and thus sacrifices
  1003. * API cleanness. Since `current` can be null before being passed in and not
  1004. * null after this function, make sure to assign it back to `current`:
  1005. *
  1006. * `a = accumulateInto(a, b);`
  1007. *
  1008. * This API should be sparingly used. Try `accumulate` for something cleaner.
  1009. *
  1010. * @return {*|array<*>} An accumulation of items.
  1011. */
  1012. function accumulateInto(current, next) {
  1013. (function () {
  1014. if (!(next != null)) {
  1015. {
  1016. throw ReactError(Error('accumulateInto(...): Accumulated items must not be null or undefined.'));
  1017. }
  1018. }
  1019. })();
  1020. if (current == null) {
  1021. return next;
  1022. }
  1023. // Both are not empty. Warning: Never call x.concat(y) when you are not
  1024. // certain that x is an Array (x could be a string with concat method).
  1025. if (Array.isArray(current)) {
  1026. if (Array.isArray(next)) {
  1027. current.push.apply(current, next);
  1028. return current;
  1029. }
  1030. current.push(next);
  1031. return current;
  1032. }
  1033. if (Array.isArray(next)) {
  1034. // A bit too dangerous to mutate `next`.
  1035. return [current].concat(next);
  1036. }
  1037. return [current, next];
  1038. }
  1039. /**
  1040. * @param {array} arr an "accumulation" of items which is either an Array or
  1041. * a single item. Useful when paired with the `accumulate` module. This is a
  1042. * simple utility that allows us to reason about a collection of items, but
  1043. * handling the case when there is exactly one item (and we do not need to
  1044. * allocate an array).
  1045. * @param {function} cb Callback invoked with each element or a collection.
  1046. * @param {?} [scope] Scope used as `this` in a callback.
  1047. */
  1048. function forEachAccumulated(arr, cb, scope) {
  1049. if (Array.isArray(arr)) {
  1050. arr.forEach(cb, scope);
  1051. } else if (arr) {
  1052. cb.call(scope, arr);
  1053. }
  1054. }
  1055. /**
  1056. * Internal queue of events that have accumulated their dispatches and are
  1057. * waiting to have their dispatches executed.
  1058. */
  1059. var eventQueue = null;
  1060. /**
  1061. * Dispatches an event and releases it back into the pool, unless persistent.
  1062. *
  1063. * @param {?object} event Synthetic event to be dispatched.
  1064. * @private
  1065. */
  1066. var executeDispatchesAndRelease = function (event) {
  1067. if (event) {
  1068. executeDispatchesInOrder(event);
  1069. if (!event.isPersistent()) {
  1070. event.constructor.release(event);
  1071. }
  1072. }
  1073. };
  1074. var executeDispatchesAndReleaseTopLevel = function (e) {
  1075. return executeDispatchesAndRelease(e);
  1076. };
  1077. function runEventsInBatch(events) {
  1078. if (events !== null) {
  1079. eventQueue = accumulateInto(eventQueue, events);
  1080. }
  1081. // Set `eventQueue` to null before processing it so that we can tell if more
  1082. // events get enqueued while processing.
  1083. var processingEventQueue = eventQueue;
  1084. eventQueue = null;
  1085. if (!processingEventQueue) {
  1086. return;
  1087. }
  1088. forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel);
  1089. (function () {
  1090. if (!!eventQueue) {
  1091. {
  1092. throw ReactError(Error('processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented.'));
  1093. }
  1094. }
  1095. })();
  1096. // This would be a good time to rethrow if any of the event handlers threw.
  1097. rethrowCaughtError();
  1098. }
  1099. function isInteractive(tag) {
  1100. return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea';
  1101. }
  1102. function shouldPreventMouseEvent(name, type, props) {
  1103. switch (name) {
  1104. case 'onClick':
  1105. case 'onClickCapture':
  1106. case 'onDoubleClick':
  1107. case 'onDoubleClickCapture':
  1108. case 'onMouseDown':
  1109. case 'onMouseDownCapture':
  1110. case 'onMouseMove':
  1111. case 'onMouseMoveCapture':
  1112. case 'onMouseUp':
  1113. case 'onMouseUpCapture':
  1114. return !!(props.disabled && isInteractive(type));
  1115. default:
  1116. return false;
  1117. }
  1118. }
  1119. /**
  1120. * This is a unified interface for event plugins to be installed and configured.
  1121. *
  1122. * Event plugins can implement the following properties:
  1123. *
  1124. * `extractEvents` {function(string, DOMEventTarget, string, object): *}
  1125. * Required. When a top-level event is fired, this method is expected to
  1126. * extract synthetic events that will in turn be queued and dispatched.
  1127. *
  1128. * `eventTypes` {object}
  1129. * Optional, plugins that fire events must publish a mapping of registration
  1130. * names that are used to register listeners. Values of this mapping must
  1131. * be objects that contain `registrationName` or `phasedRegistrationNames`.
  1132. *
  1133. * `executeDispatch` {function(object, function, string)}
  1134. * Optional, allows plugins to override how an event gets dispatched. By
  1135. * default, the listener is simply invoked.
  1136. *
  1137. * Each plugin that is injected into `EventsPluginHub` is immediately operable.
  1138. *
  1139. * @public
  1140. */
  1141. /**
  1142. * Methods for injecting dependencies.
  1143. */
  1144. var injection = {
  1145. /**
  1146. * @param {array} InjectedEventPluginOrder
  1147. * @public
  1148. */
  1149. injectEventPluginOrder: injectEventPluginOrder,
  1150. /**
  1151. * @param {object} injectedNamesToPlugins Map from names to plugin modules.
  1152. */
  1153. injectEventPluginsByName: injectEventPluginsByName
  1154. };
  1155. /**
  1156. * @param {object} inst The instance, which is the source of events.
  1157. * @param {string} registrationName Name of listener (e.g. `onClick`).
  1158. * @return {?function} The stored callback.
  1159. */
  1160. function getListener(inst, registrationName) {
  1161. var listener = void 0;
  1162. // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not
  1163. // live here; needs to be moved to a better place soon
  1164. var stateNode = inst.stateNode;
  1165. if (!stateNode) {
  1166. // Work in progress (ex: onload events in incremental mode).
  1167. return null;
  1168. }
  1169. var props = getFiberCurrentPropsFromNode(stateNode);
  1170. if (!props) {
  1171. // Work in progress.
  1172. return null;
  1173. }
  1174. listener = props[registrationName];
  1175. if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
  1176. return null;
  1177. }
  1178. (function () {
  1179. if (!(!listener || typeof listener === 'function')) {
  1180. {
  1181. throw ReactError(Error('Expected `' + registrationName + '` listener to be a function, instead got a value of `' + typeof listener + '` type.'));
  1182. }
  1183. }
  1184. })();
  1185. return listener;
  1186. }
  1187. /**
  1188. * Allows registered plugins an opportunity to extract events from top-level
  1189. * native browser events.
  1190. *
  1191. * @return {*} An accumulation of synthetic events.
  1192. * @internal
  1193. */
  1194. function extractPluginEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  1195. var events = null;
  1196. for (var i = 0; i < plugins.length; i++) {
  1197. // Not every plugin in the ordering may be loaded at runtime.
  1198. var possiblePlugin = plugins[i];
  1199. if (possiblePlugin) {
  1200. var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget);
  1201. if (extractedEvents) {
  1202. events = accumulateInto(events, extractedEvents);
  1203. }
  1204. }
  1205. }
  1206. return events;
  1207. }
  1208. function runExtractedPluginEventsInBatch(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  1209. var events = extractPluginEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget);
  1210. runEventsInBatch(events);
  1211. }
  1212. var FunctionComponent = 0;
  1213. var ClassComponent = 1;
  1214. var IndeterminateComponent = 2; // Before we know whether it is function or class
  1215. var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
  1216. var HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
  1217. var HostComponent = 5;
  1218. var HostText = 6;
  1219. var Fragment = 7;
  1220. var Mode = 8;
  1221. var ContextConsumer = 9;
  1222. var ContextProvider = 10;
  1223. var ForwardRef = 11;
  1224. var Profiler = 12;
  1225. var SuspenseComponent = 13;
  1226. var MemoComponent = 14;
  1227. var SimpleMemoComponent = 15;
  1228. var LazyComponent = 16;
  1229. var IncompleteClassComponent = 17;
  1230. var DehydratedSuspenseComponent = 18;
  1231. var SuspenseListComponent = 19;
  1232. var FundamentalComponent = 20;
  1233. var randomKey = Math.random().toString(36).slice(2);
  1234. var internalInstanceKey = '__reactInternalInstance$' + randomKey;
  1235. var internalEventHandlersKey = '__reactEventHandlers$' + randomKey;
  1236. function precacheFiberNode(hostInst, node) {
  1237. node[internalInstanceKey] = hostInst;
  1238. }
  1239. /**
  1240. * Given a DOM node, return the closest ReactDOMComponent or
  1241. * ReactDOMTextComponent instance ancestor.
  1242. */
  1243. function getClosestInstanceFromNode(node) {
  1244. if (node[internalInstanceKey]) {
  1245. return node[internalInstanceKey];
  1246. }
  1247. while (!node[internalInstanceKey]) {
  1248. if (node.parentNode) {
  1249. node = node.parentNode;
  1250. } else {
  1251. // Top of the tree. This node must not be part of a React tree (or is
  1252. // unmounted, potentially).
  1253. return null;
  1254. }
  1255. }
  1256. var inst = node[internalInstanceKey];
  1257. if (inst.tag === HostComponent || inst.tag === HostText) {
  1258. // In Fiber, this will always be the deepest root.
  1259. return inst;
  1260. }
  1261. return null;
  1262. }
  1263. /**
  1264. * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent
  1265. * instance, or null if the node was not rendered by this React.
  1266. */
  1267. function getInstanceFromNode$1(node) {
  1268. var inst = node[internalInstanceKey];
  1269. if (inst) {
  1270. if (inst.tag === HostComponent || inst.tag === HostText) {
  1271. return inst;
  1272. } else {
  1273. return null;
  1274. }
  1275. }
  1276. return null;
  1277. }
  1278. /**
  1279. * Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding
  1280. * DOM node.
  1281. */
  1282. function getNodeFromInstance$1(inst) {
  1283. if (inst.tag === HostComponent || inst.tag === HostText) {
  1284. // In Fiber this, is just the state node right now. We assume it will be
  1285. // a host component or host text.
  1286. return inst.stateNode;
  1287. }
  1288. // Without this first invariant, passing a non-DOM-component triggers the next
  1289. // invariant for a missing parent, which is super confusing.
  1290. (function () {
  1291. {
  1292. {
  1293. throw ReactError(Error('getNodeFromInstance: Invalid argument.'));
  1294. }
  1295. }
  1296. })();
  1297. }
  1298. function getFiberCurrentPropsFromNode$1(node) {
  1299. return node[internalEventHandlersKey] || null;
  1300. }
  1301. function updateFiberProps(node, props) {
  1302. node[internalEventHandlersKey] = props;
  1303. }
  1304. function getParent(inst) {
  1305. do {
  1306. inst = inst.return;
  1307. // TODO: If this is a HostRoot we might want to bail out.
  1308. // That is depending on if we want nested subtrees (layers) to bubble
  1309. // events to their parent. We could also go through parentNode on the
  1310. // host node but that wouldn't work for React Native and doesn't let us
  1311. // do the portal feature.
  1312. } while (inst && inst.tag !== HostComponent);
  1313. if (inst) {
  1314. return inst;
  1315. }
  1316. return null;
  1317. }
  1318. /**
  1319. * Return the lowest common ancestor of A and B, or null if they are in
  1320. * different trees.
  1321. */
  1322. function getLowestCommonAncestor(instA, instB) {
  1323. var depthA = 0;
  1324. for (var tempA = instA; tempA; tempA = getParent(tempA)) {
  1325. depthA++;
  1326. }
  1327. var depthB = 0;
  1328. for (var tempB = instB; tempB; tempB = getParent(tempB)) {
  1329. depthB++;
  1330. }
  1331. // If A is deeper, crawl up.
  1332. while (depthA - depthB > 0) {
  1333. instA = getParent(instA);
  1334. depthA--;
  1335. }
  1336. // If B is deeper, crawl up.
  1337. while (depthB - depthA > 0) {
  1338. instB = getParent(instB);
  1339. depthB--;
  1340. }
  1341. // Walk in lockstep until we find a match.
  1342. var depth = depthA;
  1343. while (depth--) {
  1344. if (instA === instB || instA === instB.alternate) {
  1345. return instA;
  1346. }
  1347. instA = getParent(instA);
  1348. instB = getParent(instB);
  1349. }
  1350. return null;
  1351. }
  1352. /**
  1353. * Return if A is an ancestor of B.
  1354. */
  1355. /**
  1356. * Return the parent instance of the passed-in instance.
  1357. */
  1358. /**
  1359. * Simulates the traversal of a two-phase, capture/bubble event dispatch.
  1360. */
  1361. function traverseTwoPhase(inst, fn, arg) {
  1362. var path = [];
  1363. while (inst) {
  1364. path.push(inst);
  1365. inst = getParent(inst);
  1366. }
  1367. var i = void 0;
  1368. for (i = path.length; i-- > 0;) {
  1369. fn(path[i], 'captured', arg);
  1370. }
  1371. for (i = 0; i < path.length; i++) {
  1372. fn(path[i], 'bubbled', arg);
  1373. }
  1374. }
  1375. /**
  1376. * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
  1377. * should would receive a `mouseEnter` or `mouseLeave` event.
  1378. *
  1379. * Does not invoke the callback on the nearest common ancestor because nothing
  1380. * "entered" or "left" that element.
  1381. */
  1382. function traverseEnterLeave(from, to, fn, argFrom, argTo) {
  1383. var common = from && to ? getLowestCommonAncestor(from, to) : null;
  1384. var pathFrom = [];
  1385. while (true) {
  1386. if (!from) {
  1387. break;
  1388. }
  1389. if (from === common) {
  1390. break;
  1391. }
  1392. var alternate = from.alternate;
  1393. if (alternate !== null && alternate === common) {
  1394. break;
  1395. }
  1396. pathFrom.push(from);
  1397. from = getParent(from);
  1398. }
  1399. var pathTo = [];
  1400. while (true) {
  1401. if (!to) {
  1402. break;
  1403. }
  1404. if (to === common) {
  1405. break;
  1406. }
  1407. var _alternate = to.alternate;
  1408. if (_alternate !== null && _alternate === common) {
  1409. break;
  1410. }
  1411. pathTo.push(to);
  1412. to = getParent(to);
  1413. }
  1414. for (var i = 0; i < pathFrom.length; i++) {
  1415. fn(pathFrom[i], 'bubbled', argFrom);
  1416. }
  1417. for (var _i = pathTo.length; _i-- > 0;) {
  1418. fn(pathTo[_i], 'captured', argTo);
  1419. }
  1420. }
  1421. /**
  1422. * Some event types have a notion of different registration names for different
  1423. * "phases" of propagation. This finds listeners by a given phase.
  1424. */
  1425. function listenerAtPhase(inst, event, propagationPhase) {
  1426. var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase];
  1427. return getListener(inst, registrationName);
  1428. }
  1429. /**
  1430. * A small set of propagation patterns, each of which will accept a small amount
  1431. * of information, and generate a set of "dispatch ready event objects" - which
  1432. * are sets of events that have already been annotated with a set of dispatched
  1433. * listener functions/ids. The API is designed this way to discourage these
  1434. * propagation strategies from actually executing the dispatches, since we
  1435. * always want to collect the entire set of dispatches before executing even a
  1436. * single one.
  1437. */
  1438. /**
  1439. * Tags a `SyntheticEvent` with dispatched listeners. Creating this function
  1440. * here, allows us to not have to bind or create functions for each event.
  1441. * Mutating the event's members allows us to not have to create a wrapping
  1442. * "dispatch" object that pairs the event with the listener.
  1443. */
  1444. function accumulateDirectionalDispatches(inst, phase, event) {
  1445. {
  1446. !inst ? warningWithoutStack$1(false, 'Dispatching inst must not be null') : void 0;
  1447. }
  1448. var listener = listenerAtPhase(inst, event, phase);
  1449. if (listener) {
  1450. event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
  1451. event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
  1452. }
  1453. }
  1454. /**
  1455. * Collect dispatches (must be entirely collected before dispatching - see unit
  1456. * tests). Lazily allocate the array to conserve memory. We must loop through
  1457. * each event and perform the traversal for each one. We cannot perform a
  1458. * single traversal for the entire collection of events because each event may
  1459. * have a different target.
  1460. */
  1461. function accumulateTwoPhaseDispatchesSingle(event) {
  1462. if (event && event.dispatchConfig.phasedRegistrationNames) {
  1463. traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
  1464. }
  1465. }
  1466. /**
  1467. * Accumulates without regard to direction, does not look for phased
  1468. * registration names. Same as `accumulateDirectDispatchesSingle` but without
  1469. * requiring that the `dispatchMarker` be the same as the dispatched ID.
  1470. */
  1471. function accumulateDispatches(inst, ignoredDirection, event) {
  1472. if (inst && event && event.dispatchConfig.registrationName) {
  1473. var registrationName = event.dispatchConfig.registrationName;
  1474. var listener = getListener(inst, registrationName);
  1475. if (listener) {
  1476. event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
  1477. event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
  1478. }
  1479. }
  1480. }
  1481. /**
  1482. * Accumulates dispatches on an `SyntheticEvent`, but only for the
  1483. * `dispatchMarker`.
  1484. * @param {SyntheticEvent} event
  1485. */
  1486. function accumulateDirectDispatchesSingle(event) {
  1487. if (event && event.dispatchConfig.registrationName) {
  1488. accumulateDispatches(event._targetInst, null, event);
  1489. }
  1490. }
  1491. function accumulateTwoPhaseDispatches(events) {
  1492. forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
  1493. }
  1494. function accumulateEnterLeaveDispatches(leave, enter, from, to) {
  1495. traverseEnterLeave(from, to, accumulateDispatches, leave, enter);
  1496. }
  1497. function accumulateDirectDispatches(events) {
  1498. forEachAccumulated(events, accumulateDirectDispatchesSingle);
  1499. }
  1500. var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
  1501. // Do not use the below two methods directly!
  1502. // Instead use constants exported from DOMTopLevelEventTypes in ReactDOM.
  1503. // (It is the only module that is allowed to access these methods.)
  1504. function unsafeCastStringToDOMTopLevelType(topLevelType) {
  1505. return topLevelType;
  1506. }
  1507. function unsafeCastDOMTopLevelTypeToString(topLevelType) {
  1508. return topLevelType;
  1509. }
  1510. /**
  1511. * Generate a mapping of standard vendor prefixes using the defined style property and event name.
  1512. *
  1513. * @param {string} styleProp
  1514. * @param {string} eventName
  1515. * @returns {object}
  1516. */
  1517. function makePrefixMap(styleProp, eventName) {
  1518. var prefixes = {};
  1519. prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
  1520. prefixes['Webkit' + styleProp] = 'webkit' + eventName;
  1521. prefixes['Moz' + styleProp] = 'moz' + eventName;
  1522. return prefixes;
  1523. }
  1524. /**
  1525. * A list of event names to a configurable list of vendor prefixes.
  1526. */
  1527. var vendorPrefixes = {
  1528. animationend: makePrefixMap('Animation', 'AnimationEnd'),
  1529. animationiteration: makePrefixMap('Animation', 'AnimationIteration'),
  1530. animationstart: makePrefixMap('Animation', 'AnimationStart'),
  1531. transitionend: makePrefixMap('Transition', 'TransitionEnd')
  1532. };
  1533. /**
  1534. * Event names that have already been detected and prefixed (if applicable).
  1535. */
  1536. var prefixedEventNames = {};
  1537. /**
  1538. * Element to check for prefixes on.
  1539. */
  1540. var style = {};
  1541. /**
  1542. * Bootstrap if a DOM exists.
  1543. */
  1544. if (canUseDOM) {
  1545. style = document.createElement('div').style;
  1546. // On some platforms, in particular some releases of Android 4.x,
  1547. // the un-prefixed "animation" and "transition" properties are defined on the
  1548. // style object but the events that fire will still be prefixed, so we need
  1549. // to check if the un-prefixed events are usable, and if not remove them from the map.
  1550. if (!('AnimationEvent' in window)) {
  1551. delete vendorPrefixes.animationend.animation;
  1552. delete vendorPrefixes.animationiteration.animation;
  1553. delete vendorPrefixes.animationstart.animation;
  1554. }
  1555. // Same as above
  1556. if (!('TransitionEvent' in window)) {
  1557. delete vendorPrefixes.transitionend.transition;
  1558. }
  1559. }
  1560. /**
  1561. * Attempts to determine the correct vendor prefixed event name.
  1562. *
  1563. * @param {string} eventName
  1564. * @returns {string}
  1565. */
  1566. function getVendorPrefixedEventName(eventName) {
  1567. if (prefixedEventNames[eventName]) {
  1568. return prefixedEventNames[eventName];
  1569. } else if (!vendorPrefixes[eventName]) {
  1570. return eventName;
  1571. }
  1572. var prefixMap = vendorPrefixes[eventName];
  1573. for (var styleProp in prefixMap) {
  1574. if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) {
  1575. return prefixedEventNames[eventName] = prefixMap[styleProp];
  1576. }
  1577. }
  1578. return eventName;
  1579. }
  1580. /**
  1581. * To identify top level events in ReactDOM, we use constants defined by this
  1582. * module. This is the only module that uses the unsafe* methods to express
  1583. * that the constants actually correspond to the browser event names. This lets
  1584. * us save some bundle size by avoiding a top level type -> event name map.
  1585. * The rest of ReactDOM code should import top level types from this file.
  1586. */
  1587. var TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort');
  1588. var TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationend'));
  1589. var TOP_ANIMATION_ITERATION = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationiteration'));
  1590. var TOP_ANIMATION_START = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('animationstart'));
  1591. var TOP_BLUR = unsafeCastStringToDOMTopLevelType('blur');
  1592. var TOP_CAN_PLAY = unsafeCastStringToDOMTopLevelType('canplay');
  1593. var TOP_CAN_PLAY_THROUGH = unsafeCastStringToDOMTopLevelType('canplaythrough');
  1594. var TOP_CANCEL = unsafeCastStringToDOMTopLevelType('cancel');
  1595. var TOP_CHANGE = unsafeCastStringToDOMTopLevelType('change');
  1596. var TOP_CLICK = unsafeCastStringToDOMTopLevelType('click');
  1597. var TOP_CLOSE = unsafeCastStringToDOMTopLevelType('close');
  1598. var TOP_COMPOSITION_END = unsafeCastStringToDOMTopLevelType('compositionend');
  1599. var TOP_COMPOSITION_START = unsafeCastStringToDOMTopLevelType('compositionstart');
  1600. var TOP_COMPOSITION_UPDATE = unsafeCastStringToDOMTopLevelType('compositionupdate');
  1601. var TOP_CONTEXT_MENU = unsafeCastStringToDOMTopLevelType('contextmenu');
  1602. var TOP_COPY = unsafeCastStringToDOMTopLevelType('copy');
  1603. var TOP_CUT = unsafeCastStringToDOMTopLevelType('cut');
  1604. var TOP_DOUBLE_CLICK = unsafeCastStringToDOMTopLevelType('dblclick');
  1605. var TOP_AUX_CLICK = unsafeCastStringToDOMTopLevelType('auxclick');
  1606. var TOP_DRAG = unsafeCastStringToDOMTopLevelType('drag');
  1607. var TOP_DRAG_END = unsafeCastStringToDOMTopLevelType('dragend');
  1608. var TOP_DRAG_ENTER = unsafeCastStringToDOMTopLevelType('dragenter');
  1609. var TOP_DRAG_EXIT = unsafeCastStringToDOMTopLevelType('dragexit');
  1610. var TOP_DRAG_LEAVE = unsafeCastStringToDOMTopLevelType('dragleave');
  1611. var TOP_DRAG_OVER = unsafeCastStringToDOMTopLevelType('dragover');
  1612. var TOP_DRAG_START = unsafeCastStringToDOMTopLevelType('dragstart');
  1613. var TOP_DROP = unsafeCastStringToDOMTopLevelType('drop');
  1614. var TOP_DURATION_CHANGE = unsafeCastStringToDOMTopLevelType('durationchange');
  1615. var TOP_EMPTIED = unsafeCastStringToDOMTopLevelType('emptied');
  1616. var TOP_ENCRYPTED = unsafeCastStringToDOMTopLevelType('encrypted');
  1617. var TOP_ENDED = unsafeCastStringToDOMTopLevelType('ended');
  1618. var TOP_ERROR = unsafeCastStringToDOMTopLevelType('error');
  1619. var TOP_FOCUS = unsafeCastStringToDOMTopLevelType('focus');
  1620. var TOP_GOT_POINTER_CAPTURE = unsafeCastStringToDOMTopLevelType('gotpointercapture');
  1621. var TOP_INPUT = unsafeCastStringToDOMTopLevelType('input');
  1622. var TOP_INVALID = unsafeCastStringToDOMTopLevelType('invalid');
  1623. var TOP_KEY_DOWN = unsafeCastStringToDOMTopLevelType('keydown');
  1624. var TOP_KEY_PRESS = unsafeCastStringToDOMTopLevelType('keypress');
  1625. var TOP_KEY_UP = unsafeCastStringToDOMTopLevelType('keyup');
  1626. var TOP_LOAD = unsafeCastStringToDOMTopLevelType('load');
  1627. var TOP_LOAD_START = unsafeCastStringToDOMTopLevelType('loadstart');
  1628. var TOP_LOADED_DATA = unsafeCastStringToDOMTopLevelType('loadeddata');
  1629. var TOP_LOADED_METADATA = unsafeCastStringToDOMTopLevelType('loadedmetadata');
  1630. var TOP_LOST_POINTER_CAPTURE = unsafeCastStringToDOMTopLevelType('lostpointercapture');
  1631. var TOP_MOUSE_DOWN = unsafeCastStringToDOMTopLevelType('mousedown');
  1632. var TOP_MOUSE_MOVE = unsafeCastStringToDOMTopLevelType('mousemove');
  1633. var TOP_MOUSE_OUT = unsafeCastStringToDOMTopLevelType('mouseout');
  1634. var TOP_MOUSE_OVER = unsafeCastStringToDOMTopLevelType('mouseover');
  1635. var TOP_MOUSE_UP = unsafeCastStringToDOMTopLevelType('mouseup');
  1636. var TOP_PASTE = unsafeCastStringToDOMTopLevelType('paste');
  1637. var TOP_PAUSE = unsafeCastStringToDOMTopLevelType('pause');
  1638. var TOP_PLAY = unsafeCastStringToDOMTopLevelType('play');
  1639. var TOP_PLAYING = unsafeCastStringToDOMTopLevelType('playing');
  1640. var TOP_POINTER_CANCEL = unsafeCastStringToDOMTopLevelType('pointercancel');
  1641. var TOP_POINTER_DOWN = unsafeCastStringToDOMTopLevelType('pointerdown');
  1642. var TOP_POINTER_MOVE = unsafeCastStringToDOMTopLevelType('pointermove');
  1643. var TOP_POINTER_OUT = unsafeCastStringToDOMTopLevelType('pointerout');
  1644. var TOP_POINTER_OVER = unsafeCastStringToDOMTopLevelType('pointerover');
  1645. var TOP_POINTER_UP = unsafeCastStringToDOMTopLevelType('pointerup');
  1646. var TOP_PROGRESS = unsafeCastStringToDOMTopLevelType('progress');
  1647. var TOP_RATE_CHANGE = unsafeCastStringToDOMTopLevelType('ratechange');
  1648. var TOP_RESET = unsafeCastStringToDOMTopLevelType('reset');
  1649. var TOP_SCROLL = unsafeCastStringToDOMTopLevelType('scroll');
  1650. var TOP_SEEKED = unsafeCastStringToDOMTopLevelType('seeked');
  1651. var TOP_SEEKING = unsafeCastStringToDOMTopLevelType('seeking');
  1652. var TOP_SELECTION_CHANGE = unsafeCastStringToDOMTopLevelType('selectionchange');
  1653. var TOP_STALLED = unsafeCastStringToDOMTopLevelType('stalled');
  1654. var TOP_SUBMIT = unsafeCastStringToDOMTopLevelType('submit');
  1655. var TOP_SUSPEND = unsafeCastStringToDOMTopLevelType('suspend');
  1656. var TOP_TEXT_INPUT = unsafeCastStringToDOMTopLevelType('textInput');
  1657. var TOP_TIME_UPDATE = unsafeCastStringToDOMTopLevelType('timeupdate');
  1658. var TOP_TOGGLE = unsafeCastStringToDOMTopLevelType('toggle');
  1659. var TOP_TOUCH_CANCEL = unsafeCastStringToDOMTopLevelType('touchcancel');
  1660. var TOP_TOUCH_END = unsafeCastStringToDOMTopLevelType('touchend');
  1661. var TOP_TOUCH_MOVE = unsafeCastStringToDOMTopLevelType('touchmove');
  1662. var TOP_TOUCH_START = unsafeCastStringToDOMTopLevelType('touchstart');
  1663. var TOP_TRANSITION_END = unsafeCastStringToDOMTopLevelType(getVendorPrefixedEventName('transitionend'));
  1664. var TOP_VOLUME_CHANGE = unsafeCastStringToDOMTopLevelType('volumechange');
  1665. var TOP_WAITING = unsafeCastStringToDOMTopLevelType('waiting');
  1666. var TOP_WHEEL = unsafeCastStringToDOMTopLevelType('wheel');
  1667. // List of events that need to be individually attached to media elements.
  1668. // Note that events in this list will *not* be listened to at the top level
  1669. // unless they're explicitly whitelisted in `ReactBrowserEventEmitter.listenTo`.
  1670. 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];
  1671. function getRawEventName(topLevelType) {
  1672. return unsafeCastDOMTopLevelTypeToString(topLevelType);
  1673. }
  1674. /**
  1675. * These variables store information about text content of a target node,
  1676. * allowing comparison of content before and after a given event.
  1677. *
  1678. * Identify the node where selection currently begins, then observe
  1679. * both its text content and its current position in the DOM. Since the
  1680. * browser may natively replace the target node during composition, we can
  1681. * use its position to find its replacement.
  1682. *
  1683. *
  1684. */
  1685. var root = null;
  1686. var startText = null;
  1687. var fallbackText = null;
  1688. function initialize(nativeEventTarget) {
  1689. root = nativeEventTarget;
  1690. startText = getText();
  1691. return true;
  1692. }
  1693. function reset() {
  1694. root = null;
  1695. startText = null;
  1696. fallbackText = null;
  1697. }
  1698. function getData() {
  1699. if (fallbackText) {
  1700. return fallbackText;
  1701. }
  1702. var start = void 0;
  1703. var startValue = startText;
  1704. var startLength = startValue.length;
  1705. var end = void 0;
  1706. var endValue = getText();
  1707. var endLength = endValue.length;
  1708. for (start = 0; start < startLength; start++) {
  1709. if (startValue[start] !== endValue[start]) {
  1710. break;
  1711. }
  1712. }
  1713. var minEnd = startLength - start;
  1714. for (end = 1; end <= minEnd; end++) {
  1715. if (startValue[startLength - end] !== endValue[endLength - end]) {
  1716. break;
  1717. }
  1718. }
  1719. var sliceTail = end > 1 ? 1 - end : undefined;
  1720. fallbackText = endValue.slice(start, sliceTail);
  1721. return fallbackText;
  1722. }
  1723. function getText() {
  1724. if ('value' in root) {
  1725. return root.value;
  1726. }
  1727. return root.textContent;
  1728. }
  1729. /* eslint valid-typeof: 0 */
  1730. var EVENT_POOL_SIZE = 10;
  1731. /**
  1732. * @interface Event
  1733. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  1734. */
  1735. var EventInterface = {
  1736. type: null,
  1737. target: null,
  1738. // currentTarget is set when dispatching; no use in copying it here
  1739. currentTarget: function () {
  1740. return null;
  1741. },
  1742. eventPhase: null,
  1743. bubbles: null,
  1744. cancelable: null,
  1745. timeStamp: function (event) {
  1746. return event.timeStamp || Date.now();
  1747. },
  1748. defaultPrevented: null,
  1749. isTrusted: null
  1750. };
  1751. function functionThatReturnsTrue() {
  1752. return true;
  1753. }
  1754. function functionThatReturnsFalse() {
  1755. return false;
  1756. }
  1757. /**
  1758. * Synthetic events are dispatched by event plugins, typically in response to a
  1759. * top-level event delegation handler.
  1760. *
  1761. * These systems should generally use pooling to reduce the frequency of garbage
  1762. * collection. The system should check `isPersistent` to determine whether the
  1763. * event should be released into the pool after being dispatched. Users that
  1764. * need a persisted event should invoke `persist`.
  1765. *
  1766. * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
  1767. * normalizing browser quirks. Subclasses do not necessarily have to implement a
  1768. * DOM interface; custom application-specific events can also subclass this.
  1769. *
  1770. * @param {object} dispatchConfig Configuration used to dispatch this event.
  1771. * @param {*} targetInst Marker identifying the event target.
  1772. * @param {object} nativeEvent Native browser event.
  1773. * @param {DOMEventTarget} nativeEventTarget Target node.
  1774. */
  1775. function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) {
  1776. {
  1777. // these have a getter/setter for warnings
  1778. delete this.nativeEvent;
  1779. delete this.preventDefault;
  1780. delete this.stopPropagation;
  1781. delete this.isDefaultPrevented;
  1782. delete this.isPropagationStopped;
  1783. }
  1784. this.dispatchConfig = dispatchConfig;
  1785. this._targetInst = targetInst;
  1786. this.nativeEvent = nativeEvent;
  1787. var Interface = this.constructor.Interface;
  1788. for (var propName in Interface) {
  1789. if (!Interface.hasOwnProperty(propName)) {
  1790. continue;
  1791. }
  1792. {
  1793. delete this[propName]; // this has a getter/setter for warnings
  1794. }
  1795. var normalize = Interface[propName];
  1796. if (normalize) {
  1797. this[propName] = normalize(nativeEvent);
  1798. } else {
  1799. if (propName === 'target') {
  1800. this.target = nativeEventTarget;
  1801. } else {
  1802. this[propName] = nativeEvent[propName];
  1803. }
  1804. }
  1805. }
  1806. var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
  1807. if (defaultPrevented) {
  1808. this.isDefaultPrevented = functionThatReturnsTrue;
  1809. } else {
  1810. this.isDefaultPrevented = functionThatReturnsFalse;
  1811. }
  1812. this.isPropagationStopped = functionThatReturnsFalse;
  1813. return this;
  1814. }
  1815. _assign(SyntheticEvent.prototype, {
  1816. preventDefault: function () {
  1817. this.defaultPrevented = true;
  1818. var event = this.nativeEvent;
  1819. if (!event) {
  1820. return;
  1821. }
  1822. if (event.preventDefault) {
  1823. event.preventDefault();
  1824. } else if (typeof event.returnValue !== 'unknown') {
  1825. event.returnValue = false;
  1826. }
  1827. this.isDefaultPrevented = functionThatReturnsTrue;
  1828. },
  1829. stopPropagation: function () {
  1830. var event = this.nativeEvent;
  1831. if (!event) {
  1832. return;
  1833. }
  1834. if (event.stopPropagation) {
  1835. event.stopPropagation();
  1836. } else if (typeof event.cancelBubble !== 'unknown') {
  1837. // The ChangeEventPlugin registers a "propertychange" event for
  1838. // IE. This event does not support bubbling or cancelling, and
  1839. // any references to cancelBubble throw "Member not found". A
  1840. // typeof check of "unknown" circumvents this issue (and is also
  1841. // IE specific).
  1842. event.cancelBubble = true;
  1843. }
  1844. this.isPropagationStopped = functionThatReturnsTrue;
  1845. },
  1846. /**
  1847. * We release all dispatched `SyntheticEvent`s after each event loop, adding
  1848. * them back into the pool. This allows a way to hold onto a reference that
  1849. * won't be added back into the pool.
  1850. */
  1851. persist: function () {
  1852. this.isPersistent = functionThatReturnsTrue;
  1853. },
  1854. /**
  1855. * Checks if this event should be released back into the pool.
  1856. *
  1857. * @return {boolean} True if this should not be released, false otherwise.
  1858. */
  1859. isPersistent: functionThatReturnsFalse,
  1860. /**
  1861. * `PooledClass` looks for `destructor` on each instance it releases.
  1862. */
  1863. destructor: function () {
  1864. var Interface = this.constructor.Interface;
  1865. for (var propName in Interface) {
  1866. {
  1867. Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName]));
  1868. }
  1869. }
  1870. this.dispatchConfig = null;
  1871. this._targetInst = null;
  1872. this.nativeEvent = null;
  1873. this.isDefaultPrevented = functionThatReturnsFalse;
  1874. this.isPropagationStopped = functionThatReturnsFalse;
  1875. this._dispatchListeners = null;
  1876. this._dispatchInstances = null;
  1877. {
  1878. Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
  1879. Object.defineProperty(this, 'isDefaultPrevented', getPooledWarningPropertyDefinition('isDefaultPrevented', functionThatReturnsFalse));
  1880. Object.defineProperty(this, 'isPropagationStopped', getPooledWarningPropertyDefinition('isPropagationStopped', functionThatReturnsFalse));
  1881. Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', function () {}));
  1882. Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', function () {}));
  1883. }
  1884. }
  1885. });
  1886. SyntheticEvent.Interface = EventInterface;
  1887. /**
  1888. * Helper to reduce boilerplate when creating subclasses.
  1889. */
  1890. SyntheticEvent.extend = function (Interface) {
  1891. var Super = this;
  1892. var E = function () {};
  1893. E.prototype = Super.prototype;
  1894. var prototype = new E();
  1895. function Class() {
  1896. return Super.apply(this, arguments);
  1897. }
  1898. _assign(prototype, Class.prototype);
  1899. Class.prototype = prototype;
  1900. Class.prototype.constructor = Class;
  1901. Class.Interface = _assign({}, Super.Interface, Interface);
  1902. Class.extend = Super.extend;
  1903. addEventPoolingTo(Class);
  1904. return Class;
  1905. };
  1906. addEventPoolingTo(SyntheticEvent);
  1907. /**
  1908. * Helper to nullify syntheticEvent instance properties when destructing
  1909. *
  1910. * @param {String} propName
  1911. * @param {?object} getVal
  1912. * @return {object} defineProperty object
  1913. */
  1914. function getPooledWarningPropertyDefinition(propName, getVal) {
  1915. var isFunction = typeof getVal === 'function';
  1916. return {
  1917. configurable: true,
  1918. set: set,
  1919. get: get
  1920. };
  1921. function set(val) {
  1922. var action = isFunction ? 'setting the method' : 'setting the property';
  1923. warn(action, 'This is effectively a no-op');
  1924. return val;
  1925. }
  1926. function get() {
  1927. var action = isFunction ? 'accessing the method' : 'accessing the property';
  1928. var result = isFunction ? 'This is a no-op function' : 'This is set to null';
  1929. warn(action, result);
  1930. return getVal;
  1931. }
  1932. function warn(action, result) {
  1933. var warningCondition = false;
  1934. !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;
  1935. }
  1936. }
  1937. function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
  1938. var EventConstructor = this;
  1939. if (EventConstructor.eventPool.length) {
  1940. var instance = EventConstructor.eventPool.pop();
  1941. EventConstructor.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst);
  1942. return instance;
  1943. }
  1944. return new EventConstructor(dispatchConfig, targetInst, nativeEvent, nativeInst);
  1945. }
  1946. function releasePooledEvent(event) {
  1947. var EventConstructor = this;
  1948. (function () {
  1949. if (!(event instanceof EventConstructor)) {
  1950. {
  1951. throw ReactError(Error('Trying to release an event instance into a pool of a different type.'));
  1952. }
  1953. }
  1954. })();
  1955. event.destructor();
  1956. if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) {
  1957. EventConstructor.eventPool.push(event);
  1958. }
  1959. }
  1960. function addEventPoolingTo(EventConstructor) {
  1961. EventConstructor.eventPool = [];
  1962. EventConstructor.getPooled = getPooledEvent;
  1963. EventConstructor.release = releasePooledEvent;
  1964. }
  1965. /**
  1966. * @interface Event
  1967. * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents
  1968. */
  1969. var SyntheticCompositionEvent = SyntheticEvent.extend({
  1970. data: null
  1971. });
  1972. /**
  1973. * @interface Event
  1974. * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105
  1975. * /#events-inputevents
  1976. */
  1977. var SyntheticInputEvent = SyntheticEvent.extend({
  1978. data: null
  1979. });
  1980. var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
  1981. var START_KEYCODE = 229;
  1982. var canUseCompositionEvent = canUseDOM && 'CompositionEvent' in window;
  1983. var documentMode = null;
  1984. if (canUseDOM && 'documentMode' in document) {
  1985. documentMode = document.documentMode;
  1986. }
  1987. // Webkit offers a very useful `textInput` event that can be used to
  1988. // directly represent `beforeInput`. The IE `textinput` event is not as
  1989. // useful, so we don't use it.
  1990. var canUseTextInputEvent = canUseDOM && 'TextEvent' in window && !documentMode;
  1991. // In IE9+, we have access to composition events, but the data supplied
  1992. // by the native compositionend event may be incorrect. Japanese ideographic
  1993. // spaces, for instance (\u3000) are not recorded correctly.
  1994. var useFallbackCompositionData = canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11);
  1995. var SPACEBAR_CODE = 32;
  1996. var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);
  1997. // Events and their corresponding property names.
  1998. var eventTypes = {
  1999. beforeInput: {
  2000. phasedRegistrationNames: {
  2001. bubbled: 'onBeforeInput',
  2002. captured: 'onBeforeInputCapture'
  2003. },
  2004. dependencies: [TOP_COMPOSITION_END, TOP_KEY_PRESS, TOP_TEXT_INPUT, TOP_PASTE]
  2005. },
  2006. compositionEnd: {
  2007. phasedRegistrationNames: {
  2008. bubbled: 'onCompositionEnd',
  2009. captured: 'onCompositionEndCapture'
  2010. },
  2011. dependencies: [TOP_BLUR, TOP_COMPOSITION_END, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN]
  2012. },
  2013. compositionStart: {
  2014. phasedRegistrationNames: {
  2015. bubbled: 'onCompositionStart',
  2016. captured: 'onCompositionStartCapture'
  2017. },
  2018. dependencies: [TOP_BLUR, TOP_COMPOSITION_START, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN]
  2019. },
  2020. compositionUpdate: {
  2021. phasedRegistrationNames: {
  2022. bubbled: 'onCompositionUpdate',
  2023. captured: 'onCompositionUpdateCapture'
  2024. },
  2025. dependencies: [TOP_BLUR, TOP_COMPOSITION_UPDATE, TOP_KEY_DOWN, TOP_KEY_PRESS, TOP_KEY_UP, TOP_MOUSE_DOWN]
  2026. }
  2027. };
  2028. // Track whether we've ever handled a keypress on the space key.
  2029. var hasSpaceKeypress = false;
  2030. /**
  2031. * Return whether a native keypress event is assumed to be a command.
  2032. * This is required because Firefox fires `keypress` events for key commands
  2033. * (cut, copy, select-all, etc.) even though no character is inserted.
  2034. */
  2035. function isKeypressCommand(nativeEvent) {
  2036. return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) &&
  2037. // ctrlKey && altKey is equivalent to AltGr, and is not a command.
  2038. !(nativeEvent.ctrlKey && nativeEvent.altKey);
  2039. }
  2040. /**
  2041. * Translate native top level events into event types.
  2042. *
  2043. * @param {string} topLevelType
  2044. * @return {object}
  2045. */
  2046. function getCompositionEventType(topLevelType) {
  2047. switch (topLevelType) {
  2048. case TOP_COMPOSITION_START:
  2049. return eventTypes.compositionStart;
  2050. case TOP_COMPOSITION_END:
  2051. return eventTypes.compositionEnd;
  2052. case TOP_COMPOSITION_UPDATE:
  2053. return eventTypes.compositionUpdate;
  2054. }
  2055. }
  2056. /**
  2057. * Does our fallback best-guess model think this event signifies that
  2058. * composition has begun?
  2059. *
  2060. * @param {string} topLevelType
  2061. * @param {object} nativeEvent
  2062. * @return {boolean}
  2063. */
  2064. function isFallbackCompositionStart(topLevelType, nativeEvent) {
  2065. return topLevelType === TOP_KEY_DOWN && nativeEvent.keyCode === START_KEYCODE;
  2066. }
  2067. /**
  2068. * Does our fallback mode think that this event is the end of composition?
  2069. *
  2070. * @param {string} topLevelType
  2071. * @param {object} nativeEvent
  2072. * @return {boolean}
  2073. */
  2074. function isFallbackCompositionEnd(topLevelType, nativeEvent) {
  2075. switch (topLevelType) {
  2076. case TOP_KEY_UP:
  2077. // Command keys insert or clear IME input.
  2078. return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1;
  2079. case TOP_KEY_DOWN:
  2080. // Expect IME keyCode on each keydown. If we get any other
  2081. // code we must have exited earlier.
  2082. return nativeEvent.keyCode !== START_KEYCODE;
  2083. case TOP_KEY_PRESS:
  2084. case TOP_MOUSE_DOWN:
  2085. case TOP_BLUR:
  2086. // Events are not possible without cancelling IME.
  2087. return true;
  2088. default:
  2089. return false;
  2090. }
  2091. }
  2092. /**
  2093. * Google Input Tools provides composition data via a CustomEvent,
  2094. * with the `data` property populated in the `detail` object. If this
  2095. * is available on the event object, use it. If not, this is a plain
  2096. * composition event and we have nothing special to extract.
  2097. *
  2098. * @param {object} nativeEvent
  2099. * @return {?string}
  2100. */
  2101. function getDataFromCustomEvent(nativeEvent) {
  2102. var detail = nativeEvent.detail;
  2103. if (typeof detail === 'object' && 'data' in detail) {
  2104. return detail.data;
  2105. }
  2106. return null;
  2107. }
  2108. /**
  2109. * Check if a composition event was triggered by Korean IME.
  2110. * Our fallback mode does not work well with IE's Korean IME,
  2111. * so just use native composition events when Korean IME is used.
  2112. * Although CompositionEvent.locale property is deprecated,
  2113. * it is available in IE, where our fallback mode is enabled.
  2114. *
  2115. * @param {object} nativeEvent
  2116. * @return {boolean}
  2117. */
  2118. function isUsingKoreanIME(nativeEvent) {
  2119. return nativeEvent.locale === 'ko';
  2120. }
  2121. // Track the current IME composition status, if any.
  2122. var isComposing = false;
  2123. /**
  2124. * @return {?object} A SyntheticCompositionEvent.
  2125. */
  2126. function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  2127. var eventType = void 0;
  2128. var fallbackData = void 0;
  2129. if (canUseCompositionEvent) {
  2130. eventType = getCompositionEventType(topLevelType);
  2131. } else if (!isComposing) {
  2132. if (isFallbackCompositionStart(topLevelType, nativeEvent)) {
  2133. eventType = eventTypes.compositionStart;
  2134. }
  2135. } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) {
  2136. eventType = eventTypes.compositionEnd;
  2137. }
  2138. if (!eventType) {
  2139. return null;
  2140. }
  2141. if (useFallbackCompositionData && !isUsingKoreanIME(nativeEvent)) {
  2142. // The current composition is stored statically and must not be
  2143. // overwritten while composition continues.
  2144. if (!isComposing && eventType === eventTypes.compositionStart) {
  2145. isComposing = initialize(nativeEventTarget);
  2146. } else if (eventType === eventTypes.compositionEnd) {
  2147. if (isComposing) {
  2148. fallbackData = getData();
  2149. }
  2150. }
  2151. }
  2152. var event = SyntheticCompositionEvent.getPooled(eventType, targetInst, nativeEvent, nativeEventTarget);
  2153. if (fallbackData) {
  2154. // Inject data generated from fallback path into the synthetic event.
  2155. // This matches the property of native CompositionEventInterface.
  2156. event.data = fallbackData;
  2157. } else {
  2158. var customData = getDataFromCustomEvent(nativeEvent);
  2159. if (customData !== null) {
  2160. event.data = customData;
  2161. }
  2162. }
  2163. accumulateTwoPhaseDispatches(event);
  2164. return event;
  2165. }
  2166. /**
  2167. * @param {TopLevelType} topLevelType Number from `TopLevelType`.
  2168. * @param {object} nativeEvent Native browser event.
  2169. * @return {?string} The string corresponding to this `beforeInput` event.
  2170. */
  2171. function getNativeBeforeInputChars(topLevelType, nativeEvent) {
  2172. switch (topLevelType) {
  2173. case TOP_COMPOSITION_END:
  2174. return getDataFromCustomEvent(nativeEvent);
  2175. case TOP_KEY_PRESS:
  2176. /**
  2177. * If native `textInput` events are available, our goal is to make
  2178. * use of them. However, there is a special case: the spacebar key.
  2179. * In Webkit, preventing default on a spacebar `textInput` event
  2180. * cancels character insertion, but it *also* causes the browser
  2181. * to fall back to its default spacebar behavior of scrolling the
  2182. * page.
  2183. *
  2184. * Tracking at:
  2185. * https://code.google.com/p/chromium/issues/detail?id=355103
  2186. *
  2187. * To avoid this issue, use the keypress event as if no `textInput`
  2188. * event is available.
  2189. */
  2190. var which = nativeEvent.which;
  2191. if (which !== SPACEBAR_CODE) {
  2192. return null;
  2193. }
  2194. hasSpaceKeypress = true;
  2195. return SPACEBAR_CHAR;
  2196. case TOP_TEXT_INPUT:
  2197. // Record the characters to be added to the DOM.
  2198. var chars = nativeEvent.data;
  2199. // If it's a spacebar character, assume that we have already handled
  2200. // it at the keypress level and bail immediately. Android Chrome
  2201. // doesn't give us keycodes, so we need to ignore it.
  2202. if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
  2203. return null;
  2204. }
  2205. return chars;
  2206. default:
  2207. // For other native event types, do nothing.
  2208. return null;
  2209. }
  2210. }
  2211. /**
  2212. * For browsers that do not provide the `textInput` event, extract the
  2213. * appropriate string to use for SyntheticInputEvent.
  2214. *
  2215. * @param {number} topLevelType Number from `TopLevelEventTypes`.
  2216. * @param {object} nativeEvent Native browser event.
  2217. * @return {?string} The fallback string for this `beforeInput` event.
  2218. */
  2219. function getFallbackBeforeInputChars(topLevelType, nativeEvent) {
  2220. // If we are currently composing (IME) and using a fallback to do so,
  2221. // try to extract the composed characters from the fallback object.
  2222. // If composition event is available, we extract a string only at
  2223. // compositionevent, otherwise extract it at fallback events.
  2224. if (isComposing) {
  2225. if (topLevelType === TOP_COMPOSITION_END || !canUseCompositionEvent && isFallbackCompositionEnd(topLevelType, nativeEvent)) {
  2226. var chars = getData();
  2227. reset();
  2228. isComposing = false;
  2229. return chars;
  2230. }
  2231. return null;
  2232. }
  2233. switch (topLevelType) {
  2234. case TOP_PASTE:
  2235. // If a paste event occurs after a keypress, throw out the input
  2236. // chars. Paste events should not lead to BeforeInput events.
  2237. return null;
  2238. case TOP_KEY_PRESS:
  2239. /**
  2240. * As of v27, Firefox may fire keypress events even when no character
  2241. * will be inserted. A few possibilities:
  2242. *
  2243. * - `which` is `0`. Arrow keys, Esc key, etc.
  2244. *
  2245. * - `which` is the pressed key code, but no char is available.
  2246. * Ex: 'AltGr + d` in Polish. There is no modified character for
  2247. * this key combination and no character is inserted into the
  2248. * document, but FF fires the keypress for char code `100` anyway.
  2249. * No `input` event will occur.
  2250. *
  2251. * - `which` is the pressed key code, but a command combination is
  2252. * being used. Ex: `Cmd+C`. No character is inserted, and no
  2253. * `input` event will occur.
  2254. */
  2255. if (!isKeypressCommand(nativeEvent)) {
  2256. // IE fires the `keypress` event when a user types an emoji via
  2257. // Touch keyboard of Windows. In such a case, the `char` property
  2258. // holds an emoji character like `\uD83D\uDE0A`. Because its length
  2259. // is 2, the property `which` does not represent an emoji correctly.
  2260. // In such a case, we directly return the `char` property instead of
  2261. // using `which`.
  2262. if (nativeEvent.char && nativeEvent.char.length > 1) {
  2263. return nativeEvent.char;
  2264. } else if (nativeEvent.which) {
  2265. return String.fromCharCode(nativeEvent.which);
  2266. }
  2267. }
  2268. return null;
  2269. case TOP_COMPOSITION_END:
  2270. return useFallbackCompositionData && !isUsingKoreanIME(nativeEvent) ? null : nativeEvent.data;
  2271. default:
  2272. return null;
  2273. }
  2274. }
  2275. /**
  2276. * Extract a SyntheticInputEvent for `beforeInput`, based on either native
  2277. * `textInput` or fallback behavior.
  2278. *
  2279. * @return {?object} A SyntheticInputEvent.
  2280. */
  2281. function extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  2282. var chars = void 0;
  2283. if (canUseTextInputEvent) {
  2284. chars = getNativeBeforeInputChars(topLevelType, nativeEvent);
  2285. } else {
  2286. chars = getFallbackBeforeInputChars(topLevelType, nativeEvent);
  2287. }
  2288. // If no characters are being inserted, no BeforeInput event should
  2289. // be fired.
  2290. if (!chars) {
  2291. return null;
  2292. }
  2293. var event = SyntheticInputEvent.getPooled(eventTypes.beforeInput, targetInst, nativeEvent, nativeEventTarget);
  2294. event.data = chars;
  2295. accumulateTwoPhaseDispatches(event);
  2296. return event;
  2297. }
  2298. /**
  2299. * Create an `onBeforeInput` event to match
  2300. * http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents.
  2301. *
  2302. * This event plugin is based on the native `textInput` event
  2303. * available in Chrome, Safari, Opera, and IE. This event fires after
  2304. * `onKeyPress` and `onCompositionEnd`, but before `onInput`.
  2305. *
  2306. * `beforeInput` is spec'd but not implemented in any browsers, and
  2307. * the `input` event does not provide any useful information about what has
  2308. * actually been added, contrary to the spec. Thus, `textInput` is the best
  2309. * available event to identify the characters that have actually been inserted
  2310. * into the target node.
  2311. *
  2312. * This plugin is also responsible for emitting `composition` events, thus
  2313. * allowing us to share composition fallback code for both `beforeInput` and
  2314. * `composition` event types.
  2315. */
  2316. var BeforeInputEventPlugin = {
  2317. eventTypes: eventTypes,
  2318. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  2319. var composition = extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget);
  2320. var beforeInput = extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget);
  2321. if (composition === null) {
  2322. return beforeInput;
  2323. }
  2324. if (beforeInput === null) {
  2325. return composition;
  2326. }
  2327. return [composition, beforeInput];
  2328. }
  2329. };
  2330. // Use to restore controlled state after a change event has fired.
  2331. var restoreImpl = null;
  2332. var restoreTarget = null;
  2333. var restoreQueue = null;
  2334. function restoreStateOfTarget(target) {
  2335. // We perform this translation at the end of the event loop so that we
  2336. // always receive the correct fiber here
  2337. var internalInstance = getInstanceFromNode(target);
  2338. if (!internalInstance) {
  2339. // Unmounted
  2340. return;
  2341. }
  2342. (function () {
  2343. if (!(typeof restoreImpl === 'function')) {
  2344. {
  2345. throw ReactError(Error('setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue.'));
  2346. }
  2347. }
  2348. })();
  2349. var props = getFiberCurrentPropsFromNode(internalInstance.stateNode);
  2350. restoreImpl(internalInstance.stateNode, internalInstance.type, props);
  2351. }
  2352. function setRestoreImplementation(impl) {
  2353. restoreImpl = impl;
  2354. }
  2355. function enqueueStateRestore(target) {
  2356. if (restoreTarget) {
  2357. if (restoreQueue) {
  2358. restoreQueue.push(target);
  2359. } else {
  2360. restoreQueue = [target];
  2361. }
  2362. } else {
  2363. restoreTarget = target;
  2364. }
  2365. }
  2366. function needsStateRestore() {
  2367. return restoreTarget !== null || restoreQueue !== null;
  2368. }
  2369. function restoreStateIfNeeded() {
  2370. if (!restoreTarget) {
  2371. return;
  2372. }
  2373. var target = restoreTarget;
  2374. var queuedTargets = restoreQueue;
  2375. restoreTarget = null;
  2376. restoreQueue = null;
  2377. restoreStateOfTarget(target);
  2378. if (queuedTargets) {
  2379. for (var i = 0; i < queuedTargets.length; i++) {
  2380. restoreStateOfTarget(queuedTargets[i]);
  2381. }
  2382. }
  2383. }
  2384. var enableUserTimingAPI = true;
  2385. // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
  2386. var debugRenderPhaseSideEffects = false;
  2387. // In some cases, StrictMode should also double-render lifecycles.
  2388. // This can be confusing for tests though,
  2389. // And it can be bad for performance in production.
  2390. // This feature flag can be used to control the behavior:
  2391. var debugRenderPhaseSideEffectsForStrictMode = true;
  2392. // To preserve the "Pause on caught exceptions" behavior of the debugger, we
  2393. // replay the begin phase of a failed component inside invokeGuardedCallback.
  2394. var replayFailedUnitOfWorkWithInvokeGuardedCallback = true;
  2395. // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
  2396. var warnAboutDeprecatedLifecycles = true;
  2397. // Gather advanced timing metrics for Profiler subtrees.
  2398. var enableProfilerTimer = true;
  2399. // Trace which interactions trigger each commit.
  2400. var enableSchedulerTracing = true;
  2401. // Only used in www builds.
  2402. var enableSuspenseServerRenderer = false; // TODO: true? Here it might just be false.
  2403. // Only used in www builds.
  2404. // Only used in www builds.
  2405. // Disable javascript: URL strings in href for XSS protection.
  2406. var disableJavaScriptURLs = false;
  2407. // React Fire: prevent the value and checked attributes from syncing
  2408. // with their related DOM properties
  2409. var disableInputAttributeSyncing = false;
  2410. // These APIs will no longer be "unstable" in the upcoming 16.7 release,
  2411. // Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
  2412. var enableStableConcurrentModeAPIs = false;
  2413. var warnAboutShorthandPropertyCollision = false;
  2414. // See https://github.com/react-native-community/discussions-and-proposals/issues/72 for more information
  2415. // This is a flag so we can fix warnings in RN core before turning it on
  2416. // Experimental React Flare event system and event components support.
  2417. var enableFlareAPI = false;
  2418. // Experimental Host Component support.
  2419. var enableFundamentalAPI = false;
  2420. // New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
  2421. // We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)
  2422. // Till then, we warn about the missing mock, but still fallback to a sync mode compatible version
  2423. var warnAboutUnmockedScheduler = false;
  2424. // Temporary flag to revert the fix in #15650
  2425. var revertPassiveEffectsChange = false;
  2426. // For tests, we flush suspense fallbacks in an act scope;
  2427. // *except* in some of our own tests, where we test incremental loading states.
  2428. var flushSuspenseFallbacksInTests = true;
  2429. // Changes priority of some events like mousemove to user-blocking priority,
  2430. // but without making them discrete. The flag exists in case it causes
  2431. // starvation problems.
  2432. var enableUserBlockingEvents = false;
  2433. // Add a callback property to suspense to notify which promises are currently
  2434. // in the update queue. This allows reporting and tracing of what is causing
  2435. // the user to see a loading state.
  2436. var enableSuspenseCallback = false;
  2437. // Part of the simplification of React.createElement so we can eventually move
  2438. // from React.createElement to React.jsx
  2439. // https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
  2440. var warnAboutDefaultPropsOnFunctionComponents = false;
  2441. var disableLegacyContext = false;
  2442. var disableSchedulerTimeoutBasedOnReactExpirationTime = false;
  2443. // Used as a way to call batchedUpdates when we don't have a reference to
  2444. // the renderer. Such as when we're dispatching events or if third party
  2445. // libraries need to call batchedUpdates. Eventually, this API will go away when
  2446. // everything is batched by default. We'll then have a similar API to opt-out of
  2447. // scheduled work and instead do synchronous work.
  2448. // Defaults
  2449. var batchedUpdatesImpl = function (fn, bookkeeping) {
  2450. return fn(bookkeeping);
  2451. };
  2452. var discreteUpdatesImpl = function (fn, a, b, c) {
  2453. return fn(a, b, c);
  2454. };
  2455. var flushDiscreteUpdatesImpl = function () {};
  2456. var batchedEventUpdatesImpl = batchedUpdatesImpl;
  2457. var isInsideEventHandler = false;
  2458. function finishEventHandler() {
  2459. // Here we wait until all updates have propagated, which is important
  2460. // when using controlled components within layers:
  2461. // https://github.com/facebook/react/issues/1698
  2462. // Then we restore state of any controlled component.
  2463. var controlledComponentsHavePendingUpdates = needsStateRestore();
  2464. if (controlledComponentsHavePendingUpdates) {
  2465. // If a controlled event was fired, we may need to restore the state of
  2466. // the DOM node back to the controlled value. This is necessary when React
  2467. // bails out of the update without touching the DOM.
  2468. flushDiscreteUpdatesImpl();
  2469. restoreStateIfNeeded();
  2470. }
  2471. }
  2472. function batchedUpdates(fn, bookkeeping) {
  2473. if (isInsideEventHandler) {
  2474. // If we are currently inside another batch, we need to wait until it
  2475. // fully completes before restoring state.
  2476. return fn(bookkeeping);
  2477. }
  2478. isInsideEventHandler = true;
  2479. try {
  2480. return batchedUpdatesImpl(fn, bookkeeping);
  2481. } finally {
  2482. isInsideEventHandler = false;
  2483. finishEventHandler();
  2484. }
  2485. }
  2486. function batchedEventUpdates(fn, a, b) {
  2487. if (isInsideEventHandler) {
  2488. // If we are currently inside another batch, we need to wait until it
  2489. // fully completes before restoring state.
  2490. return fn(a, b);
  2491. }
  2492. isInsideEventHandler = true;
  2493. try {
  2494. return batchedEventUpdatesImpl(fn, a, b);
  2495. } finally {
  2496. isInsideEventHandler = false;
  2497. finishEventHandler();
  2498. }
  2499. }
  2500. function discreteUpdates(fn, a, b, c) {
  2501. var prevIsInsideEventHandler = isInsideEventHandler;
  2502. isInsideEventHandler = true;
  2503. try {
  2504. return discreteUpdatesImpl(fn, a, b, c);
  2505. } finally {
  2506. isInsideEventHandler = prevIsInsideEventHandler;
  2507. if (!isInsideEventHandler) {
  2508. finishEventHandler();
  2509. }
  2510. }
  2511. }
  2512. var lastFlushedEventTimeStamp = 0;
  2513. function flushDiscreteUpdatesIfNeeded(timeStamp) {
  2514. // event.timeStamp isn't overly reliable due to inconsistencies in
  2515. // how different browsers have historically provided the time stamp.
  2516. // Some browsers provide high-resolution time stamps for all events,
  2517. // some provide low-resolution time stamps for all events. FF < 52
  2518. // even mixes both time stamps together. Some browsers even report
  2519. // negative time stamps or time stamps that are 0 (iOS9) in some cases.
  2520. // Given we are only comparing two time stamps with equality (!==),
  2521. // we are safe from the resolution differences. If the time stamp is 0
  2522. // we bail-out of preventing the flush, which can affect semantics,
  2523. // such as if an earlier flush removes or adds event listeners that
  2524. // are fired in the subsequent flush. However, this is the same
  2525. // behaviour as we had before this change, so the risks are low.
  2526. if (!isInsideEventHandler && (!enableFlareAPI || timeStamp === 0 || lastFlushedEventTimeStamp !== timeStamp)) {
  2527. lastFlushedEventTimeStamp = timeStamp;
  2528. flushDiscreteUpdatesImpl();
  2529. }
  2530. }
  2531. function setBatchingImplementation(_batchedUpdatesImpl, _discreteUpdatesImpl, _flushDiscreteUpdatesImpl, _batchedEventUpdatesImpl) {
  2532. batchedUpdatesImpl = _batchedUpdatesImpl;
  2533. discreteUpdatesImpl = _discreteUpdatesImpl;
  2534. flushDiscreteUpdatesImpl = _flushDiscreteUpdatesImpl;
  2535. batchedEventUpdatesImpl = _batchedEventUpdatesImpl;
  2536. }
  2537. /**
  2538. * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
  2539. */
  2540. var supportedInputTypes = {
  2541. color: true,
  2542. date: true,
  2543. datetime: true,
  2544. 'datetime-local': true,
  2545. email: true,
  2546. month: true,
  2547. number: true,
  2548. password: true,
  2549. range: true,
  2550. search: true,
  2551. tel: true,
  2552. text: true,
  2553. time: true,
  2554. url: true,
  2555. week: true
  2556. };
  2557. function isTextInputElement(elem) {
  2558. var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
  2559. if (nodeName === 'input') {
  2560. return !!supportedInputTypes[elem.type];
  2561. }
  2562. if (nodeName === 'textarea') {
  2563. return true;
  2564. }
  2565. return false;
  2566. }
  2567. /**
  2568. * HTML nodeType values that represent the type of the node
  2569. */
  2570. var ELEMENT_NODE = 1;
  2571. var TEXT_NODE = 3;
  2572. var COMMENT_NODE = 8;
  2573. var DOCUMENT_NODE = 9;
  2574. var DOCUMENT_FRAGMENT_NODE = 11;
  2575. /**
  2576. * Gets the target node from a native browser event by accounting for
  2577. * inconsistencies in browser DOM APIs.
  2578. *
  2579. * @param {object} nativeEvent Native browser event.
  2580. * @return {DOMEventTarget} Target node.
  2581. */
  2582. function getEventTarget(nativeEvent) {
  2583. // Fallback to nativeEvent.srcElement for IE9
  2584. // https://github.com/facebook/react/issues/12506
  2585. var target = nativeEvent.target || nativeEvent.srcElement || window;
  2586. // Normalize SVG <use> element events #4963
  2587. if (target.correspondingUseElement) {
  2588. target = target.correspondingUseElement;
  2589. }
  2590. // Safari may fire events on text nodes (Node.TEXT_NODE is 3).
  2591. // @see http://www.quirksmode.org/js/events_properties.html
  2592. return target.nodeType === TEXT_NODE ? target.parentNode : target;
  2593. }
  2594. /**
  2595. * Checks if an event is supported in the current execution environment.
  2596. *
  2597. * NOTE: This will not work correctly for non-generic events such as `change`,
  2598. * `reset`, `load`, `error`, and `select`.
  2599. *
  2600. * Borrows from Modernizr.
  2601. *
  2602. * @param {string} eventNameSuffix Event name, e.g. "click".
  2603. * @return {boolean} True if the event is supported.
  2604. * @internal
  2605. * @license Modernizr 3.0.0pre (Custom Build) | MIT
  2606. */
  2607. function isEventSupported(eventNameSuffix) {
  2608. if (!canUseDOM) {
  2609. return false;
  2610. }
  2611. var eventName = 'on' + eventNameSuffix;
  2612. var isSupported = eventName in document;
  2613. if (!isSupported) {
  2614. var element = document.createElement('div');
  2615. element.setAttribute(eventName, 'return;');
  2616. isSupported = typeof element[eventName] === 'function';
  2617. }
  2618. return isSupported;
  2619. }
  2620. function isCheckable(elem) {
  2621. var type = elem.type;
  2622. var nodeName = elem.nodeName;
  2623. return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio');
  2624. }
  2625. function getTracker(node) {
  2626. return node._valueTracker;
  2627. }
  2628. function detachTracker(node) {
  2629. node._valueTracker = null;
  2630. }
  2631. function getValueFromNode(node) {
  2632. var value = '';
  2633. if (!node) {
  2634. return value;
  2635. }
  2636. if (isCheckable(node)) {
  2637. value = node.checked ? 'true' : 'false';
  2638. } else {
  2639. value = node.value;
  2640. }
  2641. return value;
  2642. }
  2643. function trackValueOnNode(node) {
  2644. var valueField = isCheckable(node) ? 'checked' : 'value';
  2645. var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField);
  2646. var currentValue = '' + node[valueField];
  2647. // if someone has already defined a value or Safari, then bail
  2648. // and don't track value will cause over reporting of changes,
  2649. // but it's better then a hard failure
  2650. // (needed for certain tests that spyOn input values and Safari)
  2651. if (node.hasOwnProperty(valueField) || typeof descriptor === 'undefined' || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') {
  2652. return;
  2653. }
  2654. var get = descriptor.get,
  2655. set = descriptor.set;
  2656. Object.defineProperty(node, valueField, {
  2657. configurable: true,
  2658. get: function () {
  2659. return get.call(this);
  2660. },
  2661. set: function (value) {
  2662. currentValue = '' + value;
  2663. set.call(this, value);
  2664. }
  2665. });
  2666. // We could've passed this the first time
  2667. // but it triggers a bug in IE11 and Edge 14/15.
  2668. // Calling defineProperty() again should be equivalent.
  2669. // https://github.com/facebook/react/issues/11768
  2670. Object.defineProperty(node, valueField, {
  2671. enumerable: descriptor.enumerable
  2672. });
  2673. var tracker = {
  2674. getValue: function () {
  2675. return currentValue;
  2676. },
  2677. setValue: function (value) {
  2678. currentValue = '' + value;
  2679. },
  2680. stopTracking: function () {
  2681. detachTracker(node);
  2682. delete node[valueField];
  2683. }
  2684. };
  2685. return tracker;
  2686. }
  2687. function track(node) {
  2688. if (getTracker(node)) {
  2689. return;
  2690. }
  2691. // TODO: Once it's just Fiber we can move this to node._wrapperState
  2692. node._valueTracker = trackValueOnNode(node);
  2693. }
  2694. function updateValueIfChanged(node) {
  2695. if (!node) {
  2696. return false;
  2697. }
  2698. var tracker = getTracker(node);
  2699. // if there is no tracker at this point it's unlikely
  2700. // that trying again will succeed
  2701. if (!tracker) {
  2702. return true;
  2703. }
  2704. var lastValue = tracker.getValue();
  2705. var nextValue = getValueFromNode(node);
  2706. if (nextValue !== lastValue) {
  2707. tracker.setValue(nextValue);
  2708. return true;
  2709. }
  2710. return false;
  2711. }
  2712. var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
  2713. // Prevent newer renderers from RTE when used with older react package versions.
  2714. // Current owner and dispatcher used to share the same ref,
  2715. // but PR #14548 split them out to better support the react-debug-tools package.
  2716. if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
  2717. ReactSharedInternals.ReactCurrentDispatcher = {
  2718. current: null
  2719. };
  2720. }
  2721. if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
  2722. ReactSharedInternals.ReactCurrentBatchConfig = {
  2723. suspense: null
  2724. };
  2725. }
  2726. var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
  2727. var describeComponentFrame = function (name, source, ownerName) {
  2728. var sourceInfo = '';
  2729. if (source) {
  2730. var path = source.fileName;
  2731. var fileName = path.replace(BEFORE_SLASH_RE, '');
  2732. {
  2733. // In DEV, include code for a common special case:
  2734. // prefer "folder/index.js" instead of just "index.js".
  2735. if (/^index\./.test(fileName)) {
  2736. var match = path.match(BEFORE_SLASH_RE);
  2737. if (match) {
  2738. var pathBeforeSlash = match[1];
  2739. if (pathBeforeSlash) {
  2740. var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
  2741. fileName = folderName + '/' + fileName;
  2742. }
  2743. }
  2744. }
  2745. }
  2746. sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
  2747. } else if (ownerName) {
  2748. sourceInfo = ' (created by ' + ownerName + ')';
  2749. }
  2750. return '\n in ' + (name || 'Unknown') + sourceInfo;
  2751. };
  2752. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  2753. // nor polyfill, then a plain number is used for performance.
  2754. var hasSymbol = typeof Symbol === 'function' && Symbol.for;
  2755. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
  2756. var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
  2757. var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
  2758. var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
  2759. var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
  2760. var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
  2761. var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
  2762. // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
  2763. // (unstable) APIs that have been removed. Can we remove the symbols?
  2764. var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
  2765. var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
  2766. var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
  2767. var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
  2768. var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
  2769. var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
  2770. var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
  2771. var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
  2772. var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  2773. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  2774. function getIteratorFn(maybeIterable) {
  2775. if (maybeIterable === null || typeof maybeIterable !== 'object') {
  2776. return null;
  2777. }
  2778. var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
  2779. if (typeof maybeIterator === 'function') {
  2780. return maybeIterator;
  2781. }
  2782. return null;
  2783. }
  2784. var Pending = 0;
  2785. var Resolved = 1;
  2786. var Rejected = 2;
  2787. function refineResolvedLazyComponent(lazyComponent) {
  2788. return lazyComponent._status === Resolved ? lazyComponent._result : null;
  2789. }
  2790. function getWrappedName(outerType, innerType, wrapperName) {
  2791. var functionName = innerType.displayName || innerType.name || '';
  2792. return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
  2793. }
  2794. function getComponentName(type) {
  2795. if (type == null) {
  2796. // Host root, text node or just invalid type.
  2797. return null;
  2798. }
  2799. {
  2800. if (typeof type.tag === 'number') {
  2801. warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
  2802. }
  2803. }
  2804. if (typeof type === 'function') {
  2805. return type.displayName || type.name || null;
  2806. }
  2807. if (typeof type === 'string') {
  2808. return type;
  2809. }
  2810. switch (type) {
  2811. case REACT_FRAGMENT_TYPE:
  2812. return 'Fragment';
  2813. case REACT_PORTAL_TYPE:
  2814. return 'Portal';
  2815. case REACT_PROFILER_TYPE:
  2816. return 'Profiler';
  2817. case REACT_STRICT_MODE_TYPE:
  2818. return 'StrictMode';
  2819. case REACT_SUSPENSE_TYPE:
  2820. return 'Suspense';
  2821. case REACT_SUSPENSE_LIST_TYPE:
  2822. return 'SuspenseList';
  2823. }
  2824. if (typeof type === 'object') {
  2825. switch (type.$$typeof) {
  2826. case REACT_CONTEXT_TYPE:
  2827. return 'Context.Consumer';
  2828. case REACT_PROVIDER_TYPE:
  2829. return 'Context.Provider';
  2830. case REACT_FORWARD_REF_TYPE:
  2831. return getWrappedName(type, type.render, 'ForwardRef');
  2832. case REACT_MEMO_TYPE:
  2833. return getComponentName(type.type);
  2834. case REACT_LAZY_TYPE:
  2835. {
  2836. var thenable = type;
  2837. var resolvedThenable = refineResolvedLazyComponent(thenable);
  2838. if (resolvedThenable) {
  2839. return getComponentName(resolvedThenable);
  2840. }
  2841. break;
  2842. }
  2843. }
  2844. }
  2845. return null;
  2846. }
  2847. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  2848. function describeFiber(fiber) {
  2849. switch (fiber.tag) {
  2850. case HostRoot:
  2851. case HostPortal:
  2852. case HostText:
  2853. case Fragment:
  2854. case ContextProvider:
  2855. case ContextConsumer:
  2856. return '';
  2857. default:
  2858. var owner = fiber._debugOwner;
  2859. var source = fiber._debugSource;
  2860. var name = getComponentName(fiber.type);
  2861. var ownerName = null;
  2862. if (owner) {
  2863. ownerName = getComponentName(owner.type);
  2864. }
  2865. return describeComponentFrame(name, source, ownerName);
  2866. }
  2867. }
  2868. function getStackByFiberInDevAndProd(workInProgress) {
  2869. var info = '';
  2870. var node = workInProgress;
  2871. do {
  2872. info += describeFiber(node);
  2873. node = node.return;
  2874. } while (node);
  2875. return info;
  2876. }
  2877. var current = null;
  2878. var phase = null;
  2879. function getCurrentFiberOwnerNameInDevOrNull() {
  2880. {
  2881. if (current === null) {
  2882. return null;
  2883. }
  2884. var owner = current._debugOwner;
  2885. if (owner !== null && typeof owner !== 'undefined') {
  2886. return getComponentName(owner.type);
  2887. }
  2888. }
  2889. return null;
  2890. }
  2891. function getCurrentFiberStackInDev() {
  2892. {
  2893. if (current === null) {
  2894. return '';
  2895. }
  2896. // Safe because if current fiber exists, we are reconciling,
  2897. // and it is guaranteed to be the work-in-progress version.
  2898. return getStackByFiberInDevAndProd(current);
  2899. }
  2900. return '';
  2901. }
  2902. function resetCurrentFiber() {
  2903. {
  2904. ReactDebugCurrentFrame.getCurrentStack = null;
  2905. current = null;
  2906. phase = null;
  2907. }
  2908. }
  2909. function setCurrentFiber(fiber) {
  2910. {
  2911. ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev;
  2912. current = fiber;
  2913. phase = null;
  2914. }
  2915. }
  2916. function setCurrentPhase(lifeCyclePhase) {
  2917. {
  2918. phase = lifeCyclePhase;
  2919. }
  2920. }
  2921. /**
  2922. * Similar to invariant but only logs a warning if the condition is not met.
  2923. * This can be used to log issues in development environments in critical
  2924. * paths. Removing the logging code for production environments will keep the
  2925. * same logic and follow the same code paths.
  2926. */
  2927. var warning = warningWithoutStack$1;
  2928. {
  2929. warning = function (condition, format) {
  2930. if (condition) {
  2931. return;
  2932. }
  2933. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  2934. var stack = ReactDebugCurrentFrame.getStackAddendum();
  2935. // eslint-disable-next-line react-internal/warning-and-invariant-args
  2936. for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  2937. args[_key - 2] = arguments[_key];
  2938. }
  2939. warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
  2940. };
  2941. }
  2942. var warning$1 = warning;
  2943. // A reserved attribute.
  2944. // It is handled by React separately and shouldn't be written to the DOM.
  2945. var RESERVED = 0;
  2946. // A simple string attribute.
  2947. // Attributes that aren't in the whitelist are presumed to have this type.
  2948. var STRING = 1;
  2949. // A string attribute that accepts booleans in React. In HTML, these are called
  2950. // "enumerated" attributes with "true" and "false" as possible values.
  2951. // When true, it should be set to a "true" string.
  2952. // When false, it should be set to a "false" string.
  2953. var BOOLEANISH_STRING = 2;
  2954. // A real boolean attribute.
  2955. // When true, it should be present (set either to an empty string or its name).
  2956. // When false, it should be omitted.
  2957. var BOOLEAN = 3;
  2958. // An attribute that can be used as a flag as well as with a value.
  2959. // When true, it should be present (set either to an empty string or its name).
  2960. // When false, it should be omitted.
  2961. // For any other value, should be present with that value.
  2962. var OVERLOADED_BOOLEAN = 4;
  2963. // An attribute that must be numeric or parse as a numeric.
  2964. // When falsy, it should be removed.
  2965. var NUMERIC = 5;
  2966. // An attribute that must be positive numeric or parse as a positive numeric.
  2967. // When falsy, it should be removed.
  2968. var POSITIVE_NUMERIC = 6;
  2969. /* eslint-disable max-len */
  2970. 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';
  2971. /* eslint-enable max-len */
  2972. var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040';
  2973. var ROOT_ATTRIBUTE_NAME = 'data-reactroot';
  2974. var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$');
  2975. var hasOwnProperty = Object.prototype.hasOwnProperty;
  2976. var illegalAttributeNameCache = {};
  2977. var validatedAttributeNameCache = {};
  2978. function isAttributeNameSafe(attributeName) {
  2979. if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) {
  2980. return true;
  2981. }
  2982. if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) {
  2983. return false;
  2984. }
  2985. if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
  2986. validatedAttributeNameCache[attributeName] = true;
  2987. return true;
  2988. }
  2989. illegalAttributeNameCache[attributeName] = true;
  2990. {
  2991. warning$1(false, 'Invalid attribute name: `%s`', attributeName);
  2992. }
  2993. return false;
  2994. }
  2995. function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) {
  2996. if (propertyInfo !== null) {
  2997. return propertyInfo.type === RESERVED;
  2998. }
  2999. if (isCustomComponentTag) {
  3000. return false;
  3001. }
  3002. if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) {
  3003. return true;
  3004. }
  3005. return false;
  3006. }
  3007. function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) {
  3008. if (propertyInfo !== null && propertyInfo.type === RESERVED) {
  3009. return false;
  3010. }
  3011. switch (typeof value) {
  3012. case 'function':
  3013. // $FlowIssue symbol is perfectly valid here
  3014. case 'symbol':
  3015. // eslint-disable-line
  3016. return true;
  3017. case 'boolean':
  3018. {
  3019. if (isCustomComponentTag) {
  3020. return false;
  3021. }
  3022. if (propertyInfo !== null) {
  3023. return !propertyInfo.acceptsBooleans;
  3024. } else {
  3025. var prefix = name.toLowerCase().slice(0, 5);
  3026. return prefix !== 'data-' && prefix !== 'aria-';
  3027. }
  3028. }
  3029. default:
  3030. return false;
  3031. }
  3032. }
  3033. function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) {
  3034. if (value === null || typeof value === 'undefined') {
  3035. return true;
  3036. }
  3037. if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) {
  3038. return true;
  3039. }
  3040. if (isCustomComponentTag) {
  3041. return false;
  3042. }
  3043. if (propertyInfo !== null) {
  3044. switch (propertyInfo.type) {
  3045. case BOOLEAN:
  3046. return !value;
  3047. case OVERLOADED_BOOLEAN:
  3048. return value === false;
  3049. case NUMERIC:
  3050. return isNaN(value);
  3051. case POSITIVE_NUMERIC:
  3052. return isNaN(value) || value < 1;
  3053. }
  3054. }
  3055. return false;
  3056. }
  3057. function getPropertyInfo(name) {
  3058. return properties.hasOwnProperty(name) ? properties[name] : null;
  3059. }
  3060. function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL) {
  3061. this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN;
  3062. this.attributeName = attributeName;
  3063. this.attributeNamespace = attributeNamespace;
  3064. this.mustUseProperty = mustUseProperty;
  3065. this.propertyName = name;
  3066. this.type = type;
  3067. this.sanitizeURL = sanitizeURL;
  3068. }
  3069. // When adding attributes to this list, be sure to also add them to
  3070. // the `possibleStandardNames` module to ensure casing and incorrect
  3071. // name warnings.
  3072. var properties = {};
  3073. // These props are reserved by React. They shouldn't be written to the DOM.
  3074. ['children', 'dangerouslySetInnerHTML',
  3075. // TODO: This prevents the assignment of defaultValue to regular
  3076. // elements (not just inputs). Now that ReactDOMInput assigns to the
  3077. // defaultValue property -- do we need this?
  3078. 'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style'].forEach(function (name) {
  3079. properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty
  3080. name, // attributeName
  3081. null, // attributeNamespace
  3082. false);
  3083. } // sanitizeURL
  3084. );
  3085. // A few React string attributes have a different name.
  3086. // This is a mapping from React prop names to the attribute names.
  3087. [['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) {
  3088. var name = _ref[0],
  3089. attributeName = _ref[1];
  3090. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  3091. attributeName, // attributeName
  3092. null, // attributeNamespace
  3093. false);
  3094. } // sanitizeURL
  3095. );
  3096. // These are "enumerated" HTML attributes that accept "true" and "false".
  3097. // In React, we let users pass `true` and `false` even though technically
  3098. // these aren't boolean attributes (they are coerced to strings).
  3099. ['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) {
  3100. properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
  3101. name.toLowerCase(), // attributeName
  3102. null, // attributeNamespace
  3103. false);
  3104. } // sanitizeURL
  3105. );
  3106. // These are "enumerated" SVG attributes that accept "true" and "false".
  3107. // In React, we let users pass `true` and `false` even though technically
  3108. // these aren't boolean attributes (they are coerced to strings).
  3109. // Since these are SVG attributes, their attribute names are case-sensitive.
  3110. ['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) {
  3111. properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
  3112. name, // attributeName
  3113. null, // attributeNamespace
  3114. false);
  3115. } // sanitizeURL
  3116. );
  3117. // These are HTML boolean attributes.
  3118. ['allowFullScreen', 'async',
  3119. // Note: there is a special case that prevents it from being written to the DOM
  3120. // on the client side because the browsers are inconsistent. Instead we call focus().
  3121. 'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless',
  3122. // Microdata
  3123. 'itemScope'].forEach(function (name) {
  3124. properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty
  3125. name.toLowerCase(), // attributeName
  3126. null, // attributeNamespace
  3127. false);
  3128. } // sanitizeURL
  3129. );
  3130. // These are the few React props that we set as DOM properties
  3131. // rather than attributes. These are all booleans.
  3132. ['checked',
  3133. // Note: `option.selected` is not updated if `select.multiple` is
  3134. // disabled with `removeAttribute`. We have special logic for handling this.
  3135. 'multiple', 'muted', 'selected'].forEach(function (name) {
  3136. properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty
  3137. name, // attributeName
  3138. null, // attributeNamespace
  3139. false);
  3140. } // sanitizeURL
  3141. );
  3142. // These are HTML attributes that are "overloaded booleans": they behave like
  3143. // booleans, but can also accept a string value.
  3144. ['capture', 'download'].forEach(function (name) {
  3145. properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty
  3146. name, // attributeName
  3147. null, // attributeNamespace
  3148. false);
  3149. } // sanitizeURL
  3150. );
  3151. // These are HTML attributes that must be positive numbers.
  3152. ['cols', 'rows', 'size', 'span'].forEach(function (name) {
  3153. properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty
  3154. name, // attributeName
  3155. null, // attributeNamespace
  3156. false);
  3157. } // sanitizeURL
  3158. );
  3159. // These are HTML attributes that must be numbers.
  3160. ['rowSpan', 'start'].forEach(function (name) {
  3161. properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty
  3162. name.toLowerCase(), // attributeName
  3163. null, // attributeNamespace
  3164. false);
  3165. } // sanitizeURL
  3166. );
  3167. var CAMELIZE = /[\-\:]([a-z])/g;
  3168. var capitalize = function (token) {
  3169. return token[1].toUpperCase();
  3170. };
  3171. // This is a list of all SVG attributes that need special casing, namespacing,
  3172. // or boolean value assignment. Regular attributes that just accept strings
  3173. // and have the same names are omitted, just like in the HTML whitelist.
  3174. // Some of these attributes can be hard to find. This list was created by
  3175. // scrapping the MDN documentation.
  3176. ['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) {
  3177. var name = attributeName.replace(CAMELIZE, capitalize);
  3178. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  3179. attributeName, null, // attributeNamespace
  3180. false);
  3181. } // sanitizeURL
  3182. );
  3183. // String SVG attributes with the xlink namespace.
  3184. ['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type'].forEach(function (attributeName) {
  3185. var name = attributeName.replace(CAMELIZE, capitalize);
  3186. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  3187. attributeName, 'http://www.w3.org/1999/xlink', false);
  3188. } // sanitizeURL
  3189. );
  3190. // String SVG attributes with the xml namespace.
  3191. ['xml:base', 'xml:lang', 'xml:space'].forEach(function (attributeName) {
  3192. var name = attributeName.replace(CAMELIZE, capitalize);
  3193. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  3194. attributeName, 'http://www.w3.org/XML/1998/namespace', false);
  3195. } // sanitizeURL
  3196. );
  3197. // These attribute exists both in HTML and SVG.
  3198. // The attribute name is case-sensitive in SVG so we can't just use
  3199. // the React name like we do for attributes that exist only in HTML.
  3200. ['tabIndex', 'crossOrigin'].forEach(function (attributeName) {
  3201. properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
  3202. attributeName.toLowerCase(), // attributeName
  3203. null, // attributeNamespace
  3204. false);
  3205. } // sanitizeURL
  3206. );
  3207. // These attributes accept URLs. These must not allow javascript: URLS.
  3208. // These will also need to accept Trusted Types object in the future.
  3209. var xlinkHref = 'xlinkHref';
  3210. properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty
  3211. 'xlink:href', 'http://www.w3.org/1999/xlink', true);
  3212. ['src', 'href', 'action', 'formAction'].forEach(function (attributeName) {
  3213. properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
  3214. attributeName.toLowerCase(), // attributeName
  3215. null, // attributeNamespace
  3216. true);
  3217. } // sanitizeURL
  3218. );
  3219. var ReactDebugCurrentFrame$1 = null;
  3220. {
  3221. ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
  3222. }
  3223. // A javascript: URL can contain leading C0 control or \u0020 SPACE,
  3224. // and any newline or tab are filtered out as if they're not part of the URL.
  3225. // https://url.spec.whatwg.org/#url-parsing
  3226. // Tab or newline are defined as \r\n\t:
  3227. // https://infra.spec.whatwg.org/#ascii-tab-or-newline
  3228. // A C0 control is a code point in the range \u0000 NULL to \u001F
  3229. // INFORMATION SEPARATOR ONE, inclusive:
  3230. // https://infra.spec.whatwg.org/#c0-control-or-space
  3231. /* eslint-disable max-len */
  3232. var isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i;
  3233. var didWarn = false;
  3234. function sanitizeURL(url) {
  3235. if (disableJavaScriptURLs) {
  3236. (function () {
  3237. if (!!isJavaScriptProtocol.test(url)) {
  3238. {
  3239. throw ReactError(Error('React has blocked a javascript: URL as a security precaution.' + (ReactDebugCurrentFrame$1.getStackAddendum())));
  3240. }
  3241. }
  3242. })();
  3243. } else if ( true && !didWarn && isJavaScriptProtocol.test(url)) {
  3244. didWarn = true;
  3245. warning$1(false, 'A future version of React will block javascript: URLs as a security precaution. ' + 'Use event handlers instead if you can. If you need to generate unsafe HTML try ' + 'using dangerouslySetInnerHTML instead. React was passed %s.', JSON.stringify(url));
  3246. }
  3247. }
  3248. /**
  3249. * Get the value for a property on a node. Only used in DEV for SSR validation.
  3250. * The "expected" argument is used as a hint of what the expected value is.
  3251. * Some properties have multiple equivalent values.
  3252. */
  3253. function getValueForProperty(node, name, expected, propertyInfo) {
  3254. {
  3255. if (propertyInfo.mustUseProperty) {
  3256. var propertyName = propertyInfo.propertyName;
  3257. return node[propertyName];
  3258. } else {
  3259. if (!disableJavaScriptURLs && propertyInfo.sanitizeURL) {
  3260. // If we haven't fully disabled javascript: URLs, and if
  3261. // the hydration is successful of a javascript: URL, we
  3262. // still want to warn on the client.
  3263. sanitizeURL('' + expected);
  3264. }
  3265. var attributeName = propertyInfo.attributeName;
  3266. var stringValue = null;
  3267. if (propertyInfo.type === OVERLOADED_BOOLEAN) {
  3268. if (node.hasAttribute(attributeName)) {
  3269. var value = node.getAttribute(attributeName);
  3270. if (value === '') {
  3271. return true;
  3272. }
  3273. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  3274. return value;
  3275. }
  3276. if (value === '' + expected) {
  3277. return expected;
  3278. }
  3279. return value;
  3280. }
  3281. } else if (node.hasAttribute(attributeName)) {
  3282. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  3283. // We had an attribute but shouldn't have had one, so read it
  3284. // for the error message.
  3285. return node.getAttribute(attributeName);
  3286. }
  3287. if (propertyInfo.type === BOOLEAN) {
  3288. // If this was a boolean, it doesn't matter what the value is
  3289. // the fact that we have it is the same as the expected.
  3290. return expected;
  3291. }
  3292. // Even if this property uses a namespace we use getAttribute
  3293. // because we assume its namespaced name is the same as our config.
  3294. // To use getAttributeNS we need the local name which we don't have
  3295. // in our config atm.
  3296. stringValue = node.getAttribute(attributeName);
  3297. }
  3298. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  3299. return stringValue === null ? expected : stringValue;
  3300. } else if (stringValue === '' + expected) {
  3301. return expected;
  3302. } else {
  3303. return stringValue;
  3304. }
  3305. }
  3306. }
  3307. }
  3308. /**
  3309. * Get the value for a attribute on a node. Only used in DEV for SSR validation.
  3310. * The third argument is used as a hint of what the expected value is. Some
  3311. * attributes have multiple equivalent values.
  3312. */
  3313. function getValueForAttribute(node, name, expected) {
  3314. {
  3315. if (!isAttributeNameSafe(name)) {
  3316. return;
  3317. }
  3318. if (!node.hasAttribute(name)) {
  3319. return expected === undefined ? undefined : null;
  3320. }
  3321. var value = node.getAttribute(name);
  3322. if (value === '' + expected) {
  3323. return expected;
  3324. }
  3325. return value;
  3326. }
  3327. }
  3328. /**
  3329. * Sets the value for a property on a node.
  3330. *
  3331. * @param {DOMElement} node
  3332. * @param {string} name
  3333. * @param {*} value
  3334. */
  3335. function setValueForProperty(node, name, value, isCustomComponentTag) {
  3336. var propertyInfo = getPropertyInfo(name);
  3337. if (shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag)) {
  3338. return;
  3339. }
  3340. if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) {
  3341. value = null;
  3342. }
  3343. // If the prop isn't in the special list, treat it as a simple attribute.
  3344. if (isCustomComponentTag || propertyInfo === null) {
  3345. if (isAttributeNameSafe(name)) {
  3346. var _attributeName = name;
  3347. if (value === null) {
  3348. node.removeAttribute(_attributeName);
  3349. } else {
  3350. node.setAttribute(_attributeName, '' + value);
  3351. }
  3352. }
  3353. return;
  3354. }
  3355. var mustUseProperty = propertyInfo.mustUseProperty;
  3356. if (mustUseProperty) {
  3357. var propertyName = propertyInfo.propertyName;
  3358. if (value === null) {
  3359. var type = propertyInfo.type;
  3360. node[propertyName] = type === BOOLEAN ? false : '';
  3361. } else {
  3362. // Contrary to `setAttribute`, object properties are properly
  3363. // `toString`ed by IE8/9.
  3364. node[propertyName] = value;
  3365. }
  3366. return;
  3367. }
  3368. // The rest are treated as attributes with special cases.
  3369. var attributeName = propertyInfo.attributeName,
  3370. attributeNamespace = propertyInfo.attributeNamespace;
  3371. if (value === null) {
  3372. node.removeAttribute(attributeName);
  3373. } else {
  3374. var _type = propertyInfo.type;
  3375. var attributeValue = void 0;
  3376. if (_type === BOOLEAN || _type === OVERLOADED_BOOLEAN && value === true) {
  3377. attributeValue = '';
  3378. } else {
  3379. // `setAttribute` with objects becomes only `[object]` in IE8/9,
  3380. // ('' + value) makes it output the correct toString()-value.
  3381. attributeValue = '' + value;
  3382. if (propertyInfo.sanitizeURL) {
  3383. sanitizeURL(attributeValue);
  3384. }
  3385. }
  3386. if (attributeNamespace) {
  3387. node.setAttributeNS(attributeNamespace, attributeName, attributeValue);
  3388. } else {
  3389. node.setAttribute(attributeName, attributeValue);
  3390. }
  3391. }
  3392. }
  3393. // Flow does not allow string concatenation of most non-string types. To work
  3394. // around this limitation, we use an opaque type that can only be obtained by
  3395. // passing the value through getToStringValue first.
  3396. function toString(value) {
  3397. return '' + value;
  3398. }
  3399. function getToStringValue(value) {
  3400. switch (typeof value) {
  3401. case 'boolean':
  3402. case 'number':
  3403. case 'object':
  3404. case 'string':
  3405. case 'undefined':
  3406. return value;
  3407. default:
  3408. // function, symbol are assigned as empty strings
  3409. return '';
  3410. }
  3411. }
  3412. var ReactDebugCurrentFrame$2 = null;
  3413. var ReactControlledValuePropTypes = {
  3414. checkPropTypes: null
  3415. };
  3416. {
  3417. ReactDebugCurrentFrame$2 = ReactSharedInternals.ReactDebugCurrentFrame;
  3418. var hasReadOnlyValue = {
  3419. button: true,
  3420. checkbox: true,
  3421. image: true,
  3422. hidden: true,
  3423. radio: true,
  3424. reset: true,
  3425. submit: true
  3426. };
  3427. var propTypes = {
  3428. value: function (props, propName, componentName) {
  3429. if (hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled || props[propName] == null || enableFlareAPI && props.listeners) {
  3430. return null;
  3431. }
  3432. 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`.');
  3433. },
  3434. checked: function (props, propName, componentName) {
  3435. if (props.onChange || props.readOnly || props.disabled || props[propName] == null || enableFlareAPI && props.listeners) {
  3436. return null;
  3437. }
  3438. 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`.');
  3439. }
  3440. };
  3441. /**
  3442. * Provide a linked `value` attribute for controlled forms. You should not use
  3443. * this outside of the ReactDOM controlled form components.
  3444. */
  3445. ReactControlledValuePropTypes.checkPropTypes = function (tagName, props) {
  3446. checkPropTypes(propTypes, props, 'prop', tagName, ReactDebugCurrentFrame$2.getStackAddendum);
  3447. };
  3448. }
  3449. // TODO: direct imports like some-package/src/* are bad. Fix me.
  3450. var didWarnValueDefaultValue = false;
  3451. var didWarnCheckedDefaultChecked = false;
  3452. var didWarnControlledToUncontrolled = false;
  3453. var didWarnUncontrolledToControlled = false;
  3454. function isControlled(props) {
  3455. var usesChecked = props.type === 'checkbox' || props.type === 'radio';
  3456. return usesChecked ? props.checked != null : props.value != null;
  3457. }
  3458. /**
  3459. * Implements an <input> host component that allows setting these optional
  3460. * props: `checked`, `value`, `defaultChecked`, and `defaultValue`.
  3461. *
  3462. * If `checked` or `value` are not supplied (or null/undefined), user actions
  3463. * that affect the checked state or value will trigger updates to the element.
  3464. *
  3465. * If they are supplied (and not null/undefined), the rendered element will not
  3466. * trigger updates to the element. Instead, the props must change in order for
  3467. * the rendered element to be updated.
  3468. *
  3469. * The rendered element will be initialized as unchecked (or `defaultChecked`)
  3470. * with an empty value (or `defaultValue`).
  3471. *
  3472. * See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html
  3473. */
  3474. function getHostProps(element, props) {
  3475. var node = element;
  3476. var checked = props.checked;
  3477. var hostProps = _assign({}, props, {
  3478. defaultChecked: undefined,
  3479. defaultValue: undefined,
  3480. value: undefined,
  3481. checked: checked != null ? checked : node._wrapperState.initialChecked
  3482. });
  3483. return hostProps;
  3484. }
  3485. function initWrapperState(element, props) {
  3486. {
  3487. ReactControlledValuePropTypes.checkPropTypes('input', props);
  3488. if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) {
  3489. 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);
  3490. didWarnCheckedDefaultChecked = true;
  3491. }
  3492. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) {
  3493. 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);
  3494. didWarnValueDefaultValue = true;
  3495. }
  3496. }
  3497. var node = element;
  3498. var defaultValue = props.defaultValue == null ? '' : props.defaultValue;
  3499. node._wrapperState = {
  3500. initialChecked: props.checked != null ? props.checked : props.defaultChecked,
  3501. initialValue: getToStringValue(props.value != null ? props.value : defaultValue),
  3502. controlled: isControlled(props)
  3503. };
  3504. }
  3505. function updateChecked(element, props) {
  3506. var node = element;
  3507. var checked = props.checked;
  3508. if (checked != null) {
  3509. setValueForProperty(node, 'checked', checked, false);
  3510. }
  3511. }
  3512. function updateWrapper(element, props) {
  3513. var node = element;
  3514. {
  3515. var _controlled = isControlled(props);
  3516. if (!node._wrapperState.controlled && _controlled && !didWarnUncontrolledToControlled) {
  3517. 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);
  3518. didWarnUncontrolledToControlled = true;
  3519. }
  3520. if (node._wrapperState.controlled && !_controlled && !didWarnControlledToUncontrolled) {
  3521. 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);
  3522. didWarnControlledToUncontrolled = true;
  3523. }
  3524. }
  3525. updateChecked(element, props);
  3526. var value = getToStringValue(props.value);
  3527. var type = props.type;
  3528. if (value != null) {
  3529. if (type === 'number') {
  3530. if (value === 0 && node.value === '' ||
  3531. // We explicitly want to coerce to number here if possible.
  3532. // eslint-disable-next-line
  3533. node.value != value) {
  3534. node.value = toString(value);
  3535. }
  3536. } else if (node.value !== toString(value)) {
  3537. node.value = toString(value);
  3538. }
  3539. } else if (type === 'submit' || type === 'reset') {
  3540. // Submit/reset inputs need the attribute removed completely to avoid
  3541. // blank-text buttons.
  3542. node.removeAttribute('value');
  3543. return;
  3544. }
  3545. if (disableInputAttributeSyncing) {
  3546. // When not syncing the value attribute, React only assigns a new value
  3547. // whenever the defaultValue React prop has changed. When not present,
  3548. // React does nothing
  3549. if (props.hasOwnProperty('defaultValue')) {
  3550. setDefaultValue(node, props.type, getToStringValue(props.defaultValue));
  3551. }
  3552. } else {
  3553. // When syncing the value attribute, the value comes from a cascade of
  3554. // properties:
  3555. // 1. The value React property
  3556. // 2. The defaultValue React property
  3557. // 3. Otherwise there should be no change
  3558. if (props.hasOwnProperty('value')) {
  3559. setDefaultValue(node, props.type, value);
  3560. } else if (props.hasOwnProperty('defaultValue')) {
  3561. setDefaultValue(node, props.type, getToStringValue(props.defaultValue));
  3562. }
  3563. }
  3564. if (disableInputAttributeSyncing) {
  3565. // When not syncing the checked attribute, the attribute is directly
  3566. // controllable from the defaultValue React property. It needs to be
  3567. // updated as new props come in.
  3568. if (props.defaultChecked == null) {
  3569. node.removeAttribute('checked');
  3570. } else {
  3571. node.defaultChecked = !!props.defaultChecked;
  3572. }
  3573. } else {
  3574. // When syncing the checked attribute, it only changes when it needs
  3575. // to be removed, such as transitioning from a checkbox into a text input
  3576. if (props.checked == null && props.defaultChecked != null) {
  3577. node.defaultChecked = !!props.defaultChecked;
  3578. }
  3579. }
  3580. }
  3581. function postMountWrapper(element, props, isHydrating) {
  3582. var node = element;
  3583. // Do not assign value if it is already set. This prevents user text input
  3584. // from being lost during SSR hydration.
  3585. if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) {
  3586. var type = props.type;
  3587. var isButton = type === 'submit' || type === 'reset';
  3588. // Avoid setting value attribute on submit/reset inputs as it overrides the
  3589. // default value provided by the browser. See: #12872
  3590. if (isButton && (props.value === undefined || props.value === null)) {
  3591. return;
  3592. }
  3593. var _initialValue = toString(node._wrapperState.initialValue);
  3594. // Do not assign value if it is already set. This prevents user text input
  3595. // from being lost during SSR hydration.
  3596. if (!isHydrating) {
  3597. if (disableInputAttributeSyncing) {
  3598. var value = getToStringValue(props.value);
  3599. // When not syncing the value attribute, the value property points
  3600. // directly to the React prop. Only assign it if it exists.
  3601. if (value != null) {
  3602. // Always assign on buttons so that it is possible to assign an
  3603. // empty string to clear button text.
  3604. //
  3605. // Otherwise, do not re-assign the value property if is empty. This
  3606. // potentially avoids a DOM write and prevents Firefox (~60.0.1) from
  3607. // prematurely marking required inputs as invalid. Equality is compared
  3608. // to the current value in case the browser provided value is not an
  3609. // empty string.
  3610. if (isButton || value !== node.value) {
  3611. node.value = toString(value);
  3612. }
  3613. }
  3614. } else {
  3615. // When syncing the value attribute, the value property should use
  3616. // the wrapperState._initialValue property. This uses:
  3617. //
  3618. // 1. The value React property when present
  3619. // 2. The defaultValue React property when present
  3620. // 3. An empty string
  3621. if (_initialValue !== node.value) {
  3622. node.value = _initialValue;
  3623. }
  3624. }
  3625. }
  3626. if (disableInputAttributeSyncing) {
  3627. // When not syncing the value attribute, assign the value attribute
  3628. // directly from the defaultValue React property (when present)
  3629. var defaultValue = getToStringValue(props.defaultValue);
  3630. if (defaultValue != null) {
  3631. node.defaultValue = toString(defaultValue);
  3632. }
  3633. } else {
  3634. // Otherwise, the value attribute is synchronized to the property,
  3635. // so we assign defaultValue to the same thing as the value property
  3636. // assignment step above.
  3637. node.defaultValue = _initialValue;
  3638. }
  3639. }
  3640. // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug
  3641. // this is needed to work around a chrome bug where setting defaultChecked
  3642. // will sometimes influence the value of checked (even after detachment).
  3643. // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416
  3644. // We need to temporarily unset name to avoid disrupting radio button groups.
  3645. var name = node.name;
  3646. if (name !== '') {
  3647. node.name = '';
  3648. }
  3649. if (disableInputAttributeSyncing) {
  3650. // When not syncing the checked attribute, the checked property
  3651. // never gets assigned. It must be manually set. We don't want
  3652. // to do this when hydrating so that existing user input isn't
  3653. // modified
  3654. if (!isHydrating) {
  3655. updateChecked(element, props);
  3656. }
  3657. // Only assign the checked attribute if it is defined. This saves
  3658. // a DOM write when controlling the checked attribute isn't needed
  3659. // (text inputs, submit/reset)
  3660. if (props.hasOwnProperty('defaultChecked')) {
  3661. node.defaultChecked = !node.defaultChecked;
  3662. node.defaultChecked = !!props.defaultChecked;
  3663. }
  3664. } else {
  3665. // When syncing the checked attribute, both the checked property and
  3666. // attribute are assigned at the same time using defaultChecked. This uses:
  3667. //
  3668. // 1. The checked React property when present
  3669. // 2. The defaultChecked React property when present
  3670. // 3. Otherwise, false
  3671. node.defaultChecked = !node.defaultChecked;
  3672. node.defaultChecked = !!node._wrapperState.initialChecked;
  3673. }
  3674. if (name !== '') {
  3675. node.name = name;
  3676. }
  3677. }
  3678. function restoreControlledState(element, props) {
  3679. var node = element;
  3680. updateWrapper(node, props);
  3681. updateNamedCousins(node, props);
  3682. }
  3683. function updateNamedCousins(rootNode, props) {
  3684. var name = props.name;
  3685. if (props.type === 'radio' && name != null) {
  3686. var queryRoot = rootNode;
  3687. while (queryRoot.parentNode) {
  3688. queryRoot = queryRoot.parentNode;
  3689. }
  3690. // If `rootNode.form` was non-null, then we could try `form.elements`,
  3691. // but that sometimes behaves strangely in IE8. We could also try using
  3692. // `form.getElementsByName`, but that will only return direct children
  3693. // and won't include inputs that use the HTML5 `form=` attribute. Since
  3694. // the input might not even be in a form. It might not even be in the
  3695. // document. Let's just use the local `querySelectorAll` to ensure we don't
  3696. // miss anything.
  3697. var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]');
  3698. for (var i = 0; i < group.length; i++) {
  3699. var otherNode = group[i];
  3700. if (otherNode === rootNode || otherNode.form !== rootNode.form) {
  3701. continue;
  3702. }
  3703. // This will throw if radio buttons rendered by different copies of React
  3704. // and the same name are rendered into the same form (same as #1939).
  3705. // That's probably okay; we don't support it just as we don't support
  3706. // mixing React radio buttons with non-React ones.
  3707. var otherProps = getFiberCurrentPropsFromNode$1(otherNode);
  3708. (function () {
  3709. if (!otherProps) {
  3710. {
  3711. throw ReactError(Error('ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported.'));
  3712. }
  3713. }
  3714. })();
  3715. // We need update the tracked value on the named cousin since the value
  3716. // was changed but the input saw no event or value set
  3717. updateValueIfChanged(otherNode);
  3718. // If this is a controlled radio button group, forcing the input that
  3719. // was previously checked to update will cause it to be come re-checked
  3720. // as appropriate.
  3721. updateWrapper(otherNode, otherProps);
  3722. }
  3723. }
  3724. }
  3725. // In Chrome, assigning defaultValue to certain input types triggers input validation.
  3726. // For number inputs, the display value loses trailing decimal points. For email inputs,
  3727. // Chrome raises "The specified value <x> is not a valid email address".
  3728. //
  3729. // Here we check to see if the defaultValue has actually changed, avoiding these problems
  3730. // when the user is inputting text
  3731. //
  3732. // https://github.com/facebook/react/issues/7253
  3733. function setDefaultValue(node, type, value) {
  3734. if (
  3735. // Focused number inputs synchronize on blur. See ChangeEventPlugin.js
  3736. type !== 'number' || node.ownerDocument.activeElement !== node) {
  3737. if (value == null) {
  3738. node.defaultValue = toString(node._wrapperState.initialValue);
  3739. } else if (node.defaultValue !== toString(value)) {
  3740. node.defaultValue = toString(value);
  3741. }
  3742. }
  3743. }
  3744. var eventTypes$1 = {
  3745. change: {
  3746. phasedRegistrationNames: {
  3747. bubbled: 'onChange',
  3748. captured: 'onChangeCapture'
  3749. },
  3750. dependencies: [TOP_BLUR, TOP_CHANGE, TOP_CLICK, TOP_FOCUS, TOP_INPUT, TOP_KEY_DOWN, TOP_KEY_UP, TOP_SELECTION_CHANGE]
  3751. }
  3752. };
  3753. function createAndAccumulateChangeEvent(inst, nativeEvent, target) {
  3754. var event = SyntheticEvent.getPooled(eventTypes$1.change, inst, nativeEvent, target);
  3755. event.type = 'change';
  3756. // Flag this event loop as needing state restore.
  3757. enqueueStateRestore(target);
  3758. accumulateTwoPhaseDispatches(event);
  3759. return event;
  3760. }
  3761. /**
  3762. * For IE shims
  3763. */
  3764. var activeElement = null;
  3765. var activeElementInst = null;
  3766. /**
  3767. * SECTION: handle `change` event
  3768. */
  3769. function shouldUseChangeEvent(elem) {
  3770. var nodeName = elem.nodeName && elem.nodeName.toLowerCase();
  3771. return nodeName === 'select' || nodeName === 'input' && elem.type === 'file';
  3772. }
  3773. function manualDispatchChangeEvent(nativeEvent) {
  3774. var event = createAndAccumulateChangeEvent(activeElementInst, nativeEvent, getEventTarget(nativeEvent));
  3775. // If change and propertychange bubbled, we'd just bind to it like all the
  3776. // other events and have it go through ReactBrowserEventEmitter. Since it
  3777. // doesn't, we manually listen for the events and so we have to enqueue and
  3778. // process the abstract event manually.
  3779. //
  3780. // Batching is necessary here in order to ensure that all event handlers run
  3781. // before the next rerender (including event handlers attached to ancestor
  3782. // elements instead of directly on the input). Without this, controlled
  3783. // components don't work properly in conjunction with event bubbling because
  3784. // the component is rerendered and the value reverted before all the event
  3785. // handlers can run. See https://github.com/facebook/react/issues/708.
  3786. batchedUpdates(runEventInBatch, event);
  3787. }
  3788. function runEventInBatch(event) {
  3789. runEventsInBatch(event);
  3790. }
  3791. function getInstIfValueChanged(targetInst) {
  3792. var targetNode = getNodeFromInstance$1(targetInst);
  3793. if (updateValueIfChanged(targetNode)) {
  3794. return targetInst;
  3795. }
  3796. }
  3797. function getTargetInstForChangeEvent(topLevelType, targetInst) {
  3798. if (topLevelType === TOP_CHANGE) {
  3799. return targetInst;
  3800. }
  3801. }
  3802. /**
  3803. * SECTION: handle `input` event
  3804. */
  3805. var isInputEventSupported = false;
  3806. if (canUseDOM) {
  3807. // IE9 claims to support the input event but fails to trigger it when
  3808. // deleting text, so we ignore its input events.
  3809. isInputEventSupported = isEventSupported('input') && (!document.documentMode || document.documentMode > 9);
  3810. }
  3811. /**
  3812. * (For IE <=9) Starts tracking propertychange events on the passed-in element
  3813. * and override the value property so that we can distinguish user events from
  3814. * value changes in JS.
  3815. */
  3816. function startWatchingForValueChange(target, targetInst) {
  3817. activeElement = target;
  3818. activeElementInst = targetInst;
  3819. activeElement.attachEvent('onpropertychange', handlePropertyChange);
  3820. }
  3821. /**
  3822. * (For IE <=9) Removes the event listeners from the currently-tracked element,
  3823. * if any exists.
  3824. */
  3825. function stopWatchingForValueChange() {
  3826. if (!activeElement) {
  3827. return;
  3828. }
  3829. activeElement.detachEvent('onpropertychange', handlePropertyChange);
  3830. activeElement = null;
  3831. activeElementInst = null;
  3832. }
  3833. /**
  3834. * (For IE <=9) Handles a propertychange event, sending a `change` event if
  3835. * the value of the active element has changed.
  3836. */
  3837. function handlePropertyChange(nativeEvent) {
  3838. if (nativeEvent.propertyName !== 'value') {
  3839. return;
  3840. }
  3841. if (getInstIfValueChanged(activeElementInst)) {
  3842. manualDispatchChangeEvent(nativeEvent);
  3843. }
  3844. }
  3845. function handleEventsForInputEventPolyfill(topLevelType, target, targetInst) {
  3846. if (topLevelType === TOP_FOCUS) {
  3847. // In IE9, propertychange fires for most input events but is buggy and
  3848. // doesn't fire when text is deleted, but conveniently, selectionchange
  3849. // appears to fire in all of the remaining cases so we catch those and
  3850. // forward the event if the value has changed
  3851. // In either case, we don't want to call the event handler if the value
  3852. // is changed from JS so we redefine a setter for `.value` that updates
  3853. // our activeElementValue variable, allowing us to ignore those changes
  3854. //
  3855. // stopWatching() should be a noop here but we call it just in case we
  3856. // missed a blur event somehow.
  3857. stopWatchingForValueChange();
  3858. startWatchingForValueChange(target, targetInst);
  3859. } else if (topLevelType === TOP_BLUR) {
  3860. stopWatchingForValueChange();
  3861. }
  3862. }
  3863. // For IE8 and IE9.
  3864. function getTargetInstForInputEventPolyfill(topLevelType, targetInst) {
  3865. if (topLevelType === TOP_SELECTION_CHANGE || topLevelType === TOP_KEY_UP || topLevelType === TOP_KEY_DOWN) {
  3866. // On the selectionchange event, the target is just document which isn't
  3867. // helpful for us so just check activeElement instead.
  3868. //
  3869. // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire
  3870. // propertychange on the first input event after setting `value` from a
  3871. // script and fires only keydown, keypress, keyup. Catching keyup usually
  3872. // gets it and catching keydown lets us fire an event for the first
  3873. // keystroke if user does a key repeat (it'll be a little delayed: right
  3874. // before the second keystroke). Other input methods (e.g., paste) seem to
  3875. // fire selectionchange normally.
  3876. return getInstIfValueChanged(activeElementInst);
  3877. }
  3878. }
  3879. /**
  3880. * SECTION: handle `click` event
  3881. */
  3882. function shouldUseClickEvent(elem) {
  3883. // Use the `click` event to detect changes to checkbox and radio inputs.
  3884. // This approach works across all browsers, whereas `change` does not fire
  3885. // until `blur` in IE8.
  3886. var nodeName = elem.nodeName;
  3887. return nodeName && nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio');
  3888. }
  3889. function getTargetInstForClickEvent(topLevelType, targetInst) {
  3890. if (topLevelType === TOP_CLICK) {
  3891. return getInstIfValueChanged(targetInst);
  3892. }
  3893. }
  3894. function getTargetInstForInputOrChangeEvent(topLevelType, targetInst) {
  3895. if (topLevelType === TOP_INPUT || topLevelType === TOP_CHANGE) {
  3896. return getInstIfValueChanged(targetInst);
  3897. }
  3898. }
  3899. function handleControlledInputBlur(node) {
  3900. var state = node._wrapperState;
  3901. if (!state || !state.controlled || node.type !== 'number') {
  3902. return;
  3903. }
  3904. if (!disableInputAttributeSyncing) {
  3905. // If controlled, assign the value attribute to the current value on blur
  3906. setDefaultValue(node, 'number', node.value);
  3907. }
  3908. }
  3909. /**
  3910. * This plugin creates an `onChange` event that normalizes change events
  3911. * across form elements. This event fires at a time when it's possible to
  3912. * change the element's value without seeing a flicker.
  3913. *
  3914. * Supported elements are:
  3915. * - input (see `isTextInputElement`)
  3916. * - textarea
  3917. * - select
  3918. */
  3919. var ChangeEventPlugin = {
  3920. eventTypes: eventTypes$1,
  3921. _isInputEventSupported: isInputEventSupported,
  3922. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  3923. var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window;
  3924. var getTargetInstFunc = void 0,
  3925. handleEventFunc = void 0;
  3926. if (shouldUseChangeEvent(targetNode)) {
  3927. getTargetInstFunc = getTargetInstForChangeEvent;
  3928. } else if (isTextInputElement(targetNode)) {
  3929. if (isInputEventSupported) {
  3930. getTargetInstFunc = getTargetInstForInputOrChangeEvent;
  3931. } else {
  3932. getTargetInstFunc = getTargetInstForInputEventPolyfill;
  3933. handleEventFunc = handleEventsForInputEventPolyfill;
  3934. }
  3935. } else if (shouldUseClickEvent(targetNode)) {
  3936. getTargetInstFunc = getTargetInstForClickEvent;
  3937. }
  3938. if (getTargetInstFunc) {
  3939. var inst = getTargetInstFunc(topLevelType, targetInst);
  3940. if (inst) {
  3941. var event = createAndAccumulateChangeEvent(inst, nativeEvent, nativeEventTarget);
  3942. return event;
  3943. }
  3944. }
  3945. if (handleEventFunc) {
  3946. handleEventFunc(topLevelType, targetNode, targetInst);
  3947. }
  3948. // When blurring, set the value attribute for number inputs
  3949. if (topLevelType === TOP_BLUR) {
  3950. handleControlledInputBlur(targetNode);
  3951. }
  3952. }
  3953. };
  3954. /**
  3955. * Module that is injectable into `EventPluginHub`, that specifies a
  3956. * deterministic ordering of `EventPlugin`s. A convenient way to reason about
  3957. * plugins, without having to package every one of them. This is better than
  3958. * having plugins be ordered in the same order that they are injected because
  3959. * that ordering would be influenced by the packaging order.
  3960. * `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
  3961. * preventing default on events is convenient in `SimpleEventPlugin` handlers.
  3962. */
  3963. var DOMEventPluginOrder = ['ResponderEventPlugin', 'SimpleEventPlugin', 'EnterLeaveEventPlugin', 'ChangeEventPlugin', 'SelectEventPlugin', 'BeforeInputEventPlugin'];
  3964. var SyntheticUIEvent = SyntheticEvent.extend({
  3965. view: null,
  3966. detail: null
  3967. });
  3968. var modifierKeyToProp = {
  3969. Alt: 'altKey',
  3970. Control: 'ctrlKey',
  3971. Meta: 'metaKey',
  3972. Shift: 'shiftKey'
  3973. };
  3974. // Older browsers (Safari <= 10, iOS Safari <= 10.2) do not support
  3975. // getModifierState. If getModifierState is not supported, we map it to a set of
  3976. // modifier keys exposed by the event. In this case, Lock-keys are not supported.
  3977. /**
  3978. * Translation from modifier key to the associated property in the event.
  3979. * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
  3980. */
  3981. function modifierStateGetter(keyArg) {
  3982. var syntheticEvent = this;
  3983. var nativeEvent = syntheticEvent.nativeEvent;
  3984. if (nativeEvent.getModifierState) {
  3985. return nativeEvent.getModifierState(keyArg);
  3986. }
  3987. var keyProp = modifierKeyToProp[keyArg];
  3988. return keyProp ? !!nativeEvent[keyProp] : false;
  3989. }
  3990. function getEventModifierState(nativeEvent) {
  3991. return modifierStateGetter;
  3992. }
  3993. var previousScreenX = 0;
  3994. var previousScreenY = 0;
  3995. // Use flags to signal movementX/Y has already been set
  3996. var isMovementXSet = false;
  3997. var isMovementYSet = false;
  3998. /**
  3999. * @interface MouseEvent
  4000. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  4001. */
  4002. var SyntheticMouseEvent = SyntheticUIEvent.extend({
  4003. screenX: null,
  4004. screenY: null,
  4005. clientX: null,
  4006. clientY: null,
  4007. pageX: null,
  4008. pageY: null,
  4009. ctrlKey: null,
  4010. shiftKey: null,
  4011. altKey: null,
  4012. metaKey: null,
  4013. getModifierState: getEventModifierState,
  4014. button: null,
  4015. buttons: null,
  4016. relatedTarget: function (event) {
  4017. return event.relatedTarget || (event.fromElement === event.srcElement ? event.toElement : event.fromElement);
  4018. },
  4019. movementX: function (event) {
  4020. if ('movementX' in event) {
  4021. return event.movementX;
  4022. }
  4023. var screenX = previousScreenX;
  4024. previousScreenX = event.screenX;
  4025. if (!isMovementXSet) {
  4026. isMovementXSet = true;
  4027. return 0;
  4028. }
  4029. return event.type === 'mousemove' ? event.screenX - screenX : 0;
  4030. },
  4031. movementY: function (event) {
  4032. if ('movementY' in event) {
  4033. return event.movementY;
  4034. }
  4035. var screenY = previousScreenY;
  4036. previousScreenY = event.screenY;
  4037. if (!isMovementYSet) {
  4038. isMovementYSet = true;
  4039. return 0;
  4040. }
  4041. return event.type === 'mousemove' ? event.screenY - screenY : 0;
  4042. }
  4043. });
  4044. /**
  4045. * @interface PointerEvent
  4046. * @see http://www.w3.org/TR/pointerevents/
  4047. */
  4048. var SyntheticPointerEvent = SyntheticMouseEvent.extend({
  4049. pointerId: null,
  4050. width: null,
  4051. height: null,
  4052. pressure: null,
  4053. tangentialPressure: null,
  4054. tiltX: null,
  4055. tiltY: null,
  4056. twist: null,
  4057. pointerType: null,
  4058. isPrimary: null
  4059. });
  4060. var eventTypes$2 = {
  4061. mouseEnter: {
  4062. registrationName: 'onMouseEnter',
  4063. dependencies: [TOP_MOUSE_OUT, TOP_MOUSE_OVER]
  4064. },
  4065. mouseLeave: {
  4066. registrationName: 'onMouseLeave',
  4067. dependencies: [TOP_MOUSE_OUT, TOP_MOUSE_OVER]
  4068. },
  4069. pointerEnter: {
  4070. registrationName: 'onPointerEnter',
  4071. dependencies: [TOP_POINTER_OUT, TOP_POINTER_OVER]
  4072. },
  4073. pointerLeave: {
  4074. registrationName: 'onPointerLeave',
  4075. dependencies: [TOP_POINTER_OUT, TOP_POINTER_OVER]
  4076. }
  4077. };
  4078. var EnterLeaveEventPlugin = {
  4079. eventTypes: eventTypes$2,
  4080. /**
  4081. * For almost every interaction we care about, there will be both a top-level
  4082. * `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that
  4083. * we do not extract duplicate events. However, moving the mouse into the
  4084. * browser from outside will not fire a `mouseout` event. In this case, we use
  4085. * the `mouseover` top-level event.
  4086. */
  4087. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  4088. var isOverEvent = topLevelType === TOP_MOUSE_OVER || topLevelType === TOP_POINTER_OVER;
  4089. var isOutEvent = topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_POINTER_OUT;
  4090. if (isOverEvent && (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
  4091. return null;
  4092. }
  4093. if (!isOutEvent && !isOverEvent) {
  4094. // Must not be a mouse or pointer in or out - ignoring.
  4095. return null;
  4096. }
  4097. var win = void 0;
  4098. if (nativeEventTarget.window === nativeEventTarget) {
  4099. // `nativeEventTarget` is probably a window object.
  4100. win = nativeEventTarget;
  4101. } else {
  4102. // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
  4103. var doc = nativeEventTarget.ownerDocument;
  4104. if (doc) {
  4105. win = doc.defaultView || doc.parentWindow;
  4106. } else {
  4107. win = window;
  4108. }
  4109. }
  4110. var from = void 0;
  4111. var to = void 0;
  4112. if (isOutEvent) {
  4113. from = targetInst;
  4114. var related = nativeEvent.relatedTarget || nativeEvent.toElement;
  4115. to = related ? getClosestInstanceFromNode(related) : null;
  4116. } else {
  4117. // Moving to a node from outside the window.
  4118. from = null;
  4119. to = targetInst;
  4120. }
  4121. if (from === to) {
  4122. // Nothing pertains to our managed components.
  4123. return null;
  4124. }
  4125. var eventInterface = void 0,
  4126. leaveEventType = void 0,
  4127. enterEventType = void 0,
  4128. eventTypePrefix = void 0;
  4129. if (topLevelType === TOP_MOUSE_OUT || topLevelType === TOP_MOUSE_OVER) {
  4130. eventInterface = SyntheticMouseEvent;
  4131. leaveEventType = eventTypes$2.mouseLeave;
  4132. enterEventType = eventTypes$2.mouseEnter;
  4133. eventTypePrefix = 'mouse';
  4134. } else if (topLevelType === TOP_POINTER_OUT || topLevelType === TOP_POINTER_OVER) {
  4135. eventInterface = SyntheticPointerEvent;
  4136. leaveEventType = eventTypes$2.pointerLeave;
  4137. enterEventType = eventTypes$2.pointerEnter;
  4138. eventTypePrefix = 'pointer';
  4139. }
  4140. var fromNode = from == null ? win : getNodeFromInstance$1(from);
  4141. var toNode = to == null ? win : getNodeFromInstance$1(to);
  4142. var leave = eventInterface.getPooled(leaveEventType, from, nativeEvent, nativeEventTarget);
  4143. leave.type = eventTypePrefix + 'leave';
  4144. leave.target = fromNode;
  4145. leave.relatedTarget = toNode;
  4146. var enter = eventInterface.getPooled(enterEventType, to, nativeEvent, nativeEventTarget);
  4147. enter.type = eventTypePrefix + 'enter';
  4148. enter.target = toNode;
  4149. enter.relatedTarget = fromNode;
  4150. accumulateEnterLeaveDispatches(leave, enter, from, to);
  4151. return [leave, enter];
  4152. }
  4153. };
  4154. /**
  4155. * inlined Object.is polyfill to avoid requiring consumers ship their own
  4156. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  4157. */
  4158. function is(x, y) {
  4159. return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
  4160. ;
  4161. }
  4162. var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  4163. /**
  4164. * Performs equality by iterating through keys on an object and returning false
  4165. * when any key has values which are not strictly equal between the arguments.
  4166. * Returns true when the values of all keys are strictly equal.
  4167. */
  4168. function shallowEqual(objA, objB) {
  4169. if (is(objA, objB)) {
  4170. return true;
  4171. }
  4172. if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
  4173. return false;
  4174. }
  4175. var keysA = Object.keys(objA);
  4176. var keysB = Object.keys(objB);
  4177. if (keysA.length !== keysB.length) {
  4178. return false;
  4179. }
  4180. // Test for A's keys different from B.
  4181. for (var i = 0; i < keysA.length; i++) {
  4182. if (!hasOwnProperty$1.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
  4183. return false;
  4184. }
  4185. }
  4186. return true;
  4187. }
  4188. var PLUGIN_EVENT_SYSTEM = 1;
  4189. var RESPONDER_EVENT_SYSTEM = 1 << 1;
  4190. var IS_PASSIVE = 1 << 2;
  4191. var IS_ACTIVE = 1 << 3;
  4192. var PASSIVE_NOT_SUPPORTED = 1 << 4;
  4193. function createResponderListener(responder, props) {
  4194. var eventResponderListener = {
  4195. responder: responder,
  4196. props: props
  4197. };
  4198. {
  4199. Object.freeze(eventResponderListener);
  4200. }
  4201. return eventResponderListener;
  4202. }
  4203. function isFiberSuspenseAndTimedOut(fiber) {
  4204. return fiber.tag === SuspenseComponent && fiber.memoizedState !== null;
  4205. }
  4206. function getSuspenseFallbackChild(fiber) {
  4207. return fiber.child.sibling.child;
  4208. }
  4209. function createResponderInstance(responder, responderProps, responderState, target, fiber) {
  4210. return {
  4211. fiber: fiber,
  4212. props: responderProps,
  4213. responder: responder,
  4214. rootEventTypes: null,
  4215. state: responderState,
  4216. target: target
  4217. };
  4218. }
  4219. var DiscreteEvent = 0;
  4220. var UserBlockingEvent = 1;
  4221. var ContinuousEvent = 2;
  4222. // Intentionally not named imports because Rollup would use dynamic dispatch for
  4223. // CommonJS interop named imports.
  4224. var UserBlockingPriority$1 = Scheduler.unstable_UserBlockingPriority;
  4225. var runWithPriority$1 = Scheduler.unstable_runWithPriority;
  4226. var listenToResponderEventTypesImpl = void 0;
  4227. function setListenToResponderEventTypes(_listenToResponderEventTypesImpl) {
  4228. listenToResponderEventTypesImpl = _listenToResponderEventTypesImpl;
  4229. }
  4230. var activeTimeouts = new Map();
  4231. var rootEventTypesToEventResponderInstances = new Map();
  4232. var ownershipChangeListeners = new Set();
  4233. var globalOwner = null;
  4234. var currentTimeStamp = 0;
  4235. var currentTimers = new Map();
  4236. var currentInstance = null;
  4237. var currentEventQueue = null;
  4238. var currentEventQueuePriority = ContinuousEvent;
  4239. var currentTimerIDCounter = 0;
  4240. var currentDocument = null;
  4241. var eventResponderContext = {
  4242. dispatchEvent: function (eventValue, eventListener, eventPriority) {
  4243. validateResponderContext();
  4244. validateEventValue(eventValue);
  4245. if (eventPriority < currentEventQueuePriority) {
  4246. currentEventQueuePriority = eventPriority;
  4247. }
  4248. currentEventQueue.push(createEventQueueItem(eventValue, eventListener));
  4249. },
  4250. isTargetWithinResponder: function (target) {
  4251. validateResponderContext();
  4252. if (target != null) {
  4253. var fiber = getClosestInstanceFromNode(target);
  4254. var responderFiber = currentInstance.fiber;
  4255. while (fiber !== null) {
  4256. if (fiber === responderFiber || fiber.alternate === responderFiber) {
  4257. return true;
  4258. }
  4259. fiber = fiber.return;
  4260. }
  4261. }
  4262. return false;
  4263. },
  4264. isTargetWithinResponderScope: function (target) {
  4265. validateResponderContext();
  4266. var componentInstance = currentInstance;
  4267. var responder = componentInstance.responder;
  4268. if (target != null) {
  4269. var fiber = getClosestInstanceFromNode(target);
  4270. var responderFiber = currentInstance.fiber;
  4271. while (fiber !== null) {
  4272. if (fiber === responderFiber || fiber.alternate === responderFiber) {
  4273. return true;
  4274. }
  4275. if (doesFiberHaveResponder(fiber, responder)) {
  4276. return false;
  4277. }
  4278. fiber = fiber.return;
  4279. }
  4280. }
  4281. return false;
  4282. },
  4283. isTargetWithinNode: function (childTarget, parentTarget) {
  4284. validateResponderContext();
  4285. var childFiber = getClosestInstanceFromNode(childTarget);
  4286. var parentFiber = getClosestInstanceFromNode(parentTarget);
  4287. var parentAlternateFiber = parentFiber.alternate;
  4288. var node = childFiber;
  4289. while (node !== null) {
  4290. if (node === parentFiber || node === parentAlternateFiber) {
  4291. return true;
  4292. }
  4293. node = node.return;
  4294. }
  4295. return false;
  4296. },
  4297. addRootEventTypes: function (rootEventTypes) {
  4298. validateResponderContext();
  4299. var activeDocument = getActiveDocument();
  4300. listenToResponderEventTypesImpl(rootEventTypes, activeDocument);
  4301. for (var i = 0; i < rootEventTypes.length; i++) {
  4302. var rootEventType = rootEventTypes[i];
  4303. var eventResponderInstance = currentInstance;
  4304. registerRootEventType(rootEventType, eventResponderInstance);
  4305. }
  4306. },
  4307. removeRootEventTypes: function (rootEventTypes) {
  4308. validateResponderContext();
  4309. for (var i = 0; i < rootEventTypes.length; i++) {
  4310. var rootEventType = rootEventTypes[i];
  4311. var rootEventResponders = rootEventTypesToEventResponderInstances.get(rootEventType);
  4312. var rootEventTypesSet = currentInstance.rootEventTypes;
  4313. if (rootEventTypesSet !== null) {
  4314. rootEventTypesSet.delete(rootEventType);
  4315. }
  4316. if (rootEventResponders !== undefined) {
  4317. rootEventResponders.delete(currentInstance);
  4318. }
  4319. }
  4320. },
  4321. hasOwnership: function () {
  4322. validateResponderContext();
  4323. return globalOwner === currentInstance;
  4324. },
  4325. requestGlobalOwnership: function () {
  4326. validateResponderContext();
  4327. if (globalOwner !== null) {
  4328. return false;
  4329. }
  4330. globalOwner = currentInstance;
  4331. triggerOwnershipListeners();
  4332. return true;
  4333. },
  4334. releaseOwnership: function () {
  4335. validateResponderContext();
  4336. return releaseOwnershipForEventResponderInstance(currentInstance);
  4337. },
  4338. setTimeout: function (func, delay) {
  4339. validateResponderContext();
  4340. if (currentTimers === null) {
  4341. currentTimers = new Map();
  4342. }
  4343. var timeout = currentTimers.get(delay);
  4344. var timerId = currentTimerIDCounter++;
  4345. if (timeout === undefined) {
  4346. var _timers = new Map();
  4347. var _id = setTimeout(function () {
  4348. processTimers(_timers, delay);
  4349. }, delay);
  4350. timeout = {
  4351. id: _id,
  4352. timers: _timers
  4353. };
  4354. currentTimers.set(delay, timeout);
  4355. }
  4356. timeout.timers.set(timerId, {
  4357. instance: currentInstance,
  4358. func: func,
  4359. id: timerId,
  4360. timeStamp: currentTimeStamp
  4361. });
  4362. activeTimeouts.set(timerId, timeout);
  4363. return timerId;
  4364. },
  4365. clearTimeout: function (timerId) {
  4366. validateResponderContext();
  4367. var timeout = activeTimeouts.get(timerId);
  4368. if (timeout !== undefined) {
  4369. var _timers2 = timeout.timers;
  4370. _timers2.delete(timerId);
  4371. if (_timers2.size === 0) {
  4372. clearTimeout(timeout.id);
  4373. }
  4374. }
  4375. },
  4376. getFocusableElementsInScope: function (deep) {
  4377. validateResponderContext();
  4378. var focusableElements = [];
  4379. var eventResponderInstance = currentInstance;
  4380. var currentResponder = eventResponderInstance.responder;
  4381. var focusScopeFiber = eventResponderInstance.fiber;
  4382. if (deep) {
  4383. var deepNode = focusScopeFiber.return;
  4384. while (deepNode !== null) {
  4385. if (doesFiberHaveResponder(deepNode, currentResponder)) {
  4386. focusScopeFiber = deepNode;
  4387. }
  4388. deepNode = deepNode.return;
  4389. }
  4390. }
  4391. var child = focusScopeFiber.child;
  4392. if (child !== null) {
  4393. collectFocusableElements(child, focusableElements);
  4394. }
  4395. return focusableElements;
  4396. },
  4397. getActiveDocument: getActiveDocument,
  4398. objectAssign: _assign,
  4399. getTimeStamp: function () {
  4400. validateResponderContext();
  4401. return currentTimeStamp;
  4402. },
  4403. isTargetWithinHostComponent: function (target, elementType) {
  4404. validateResponderContext();
  4405. var fiber = getClosestInstanceFromNode(target);
  4406. while (fiber !== null) {
  4407. if (fiber.tag === HostComponent && fiber.type === elementType) {
  4408. return true;
  4409. }
  4410. fiber = fiber.return;
  4411. }
  4412. return false;
  4413. },
  4414. enqueueStateRestore: enqueueStateRestore
  4415. };
  4416. function validateEventValue(eventValue) {
  4417. if (typeof eventValue === 'object' && eventValue !== null) {
  4418. var target = eventValue.target,
  4419. type = eventValue.type,
  4420. _timeStamp = eventValue.timeStamp;
  4421. if (target == null || type == null || _timeStamp == null) {
  4422. throw new Error('context.dispatchEvent: "target", "timeStamp", and "type" fields on event object are required.');
  4423. }
  4424. var showWarning = function (name) {
  4425. {
  4426. warning$1(false, '%s is not available on event objects created from event responder modules (React Flare). ' + 'Try wrapping in a conditional, i.e. `if (event.type !== "press") { event.%s }`', name, name);
  4427. }
  4428. };
  4429. eventValue.preventDefault = function () {
  4430. {
  4431. showWarning('preventDefault()');
  4432. }
  4433. };
  4434. eventValue.stopPropagation = function () {
  4435. {
  4436. showWarning('stopPropagation()');
  4437. }
  4438. };
  4439. eventValue.isDefaultPrevented = function () {
  4440. {
  4441. showWarning('isDefaultPrevented()');
  4442. }
  4443. };
  4444. eventValue.isPropagationStopped = function () {
  4445. {
  4446. showWarning('isPropagationStopped()');
  4447. }
  4448. };
  4449. // $FlowFixMe: we don't need value, Flow thinks we do
  4450. Object.defineProperty(eventValue, 'nativeEvent', {
  4451. get: function () {
  4452. {
  4453. showWarning('nativeEvent');
  4454. }
  4455. }
  4456. });
  4457. }
  4458. }
  4459. function collectFocusableElements(node, focusableElements) {
  4460. if (isFiberSuspenseAndTimedOut(node)) {
  4461. var fallbackChild = getSuspenseFallbackChild(node);
  4462. if (fallbackChild !== null) {
  4463. collectFocusableElements(fallbackChild, focusableElements);
  4464. }
  4465. } else {
  4466. if (isFiberHostComponentFocusable(node)) {
  4467. focusableElements.push(node.stateNode);
  4468. } else {
  4469. var child = node.child;
  4470. if (child !== null) {
  4471. collectFocusableElements(child, focusableElements);
  4472. }
  4473. }
  4474. }
  4475. var sibling = node.sibling;
  4476. if (sibling !== null) {
  4477. collectFocusableElements(sibling, focusableElements);
  4478. }
  4479. }
  4480. function createEventQueueItem(value, listener) {
  4481. return {
  4482. value: value,
  4483. listener: listener
  4484. };
  4485. }
  4486. function doesFiberHaveResponder(fiber, responder) {
  4487. if (fiber.tag === HostComponent) {
  4488. var dependencies = fiber.dependencies;
  4489. if (dependencies !== null) {
  4490. var respondersMap = dependencies.responders;
  4491. if (respondersMap !== null && respondersMap.has(responder)) {
  4492. return true;
  4493. }
  4494. }
  4495. }
  4496. return false;
  4497. }
  4498. function getActiveDocument() {
  4499. return currentDocument;
  4500. }
  4501. function releaseOwnershipForEventResponderInstance(eventResponderInstance) {
  4502. if (globalOwner === eventResponderInstance) {
  4503. globalOwner = null;
  4504. triggerOwnershipListeners();
  4505. return true;
  4506. }
  4507. return false;
  4508. }
  4509. function isFiberHostComponentFocusable(fiber) {
  4510. if (fiber.tag !== HostComponent) {
  4511. return false;
  4512. }
  4513. var type = fiber.type,
  4514. memoizedProps = fiber.memoizedProps;
  4515. if (memoizedProps.tabIndex === -1 || memoizedProps.disabled) {
  4516. return false;
  4517. }
  4518. if (memoizedProps.tabIndex === 0 || memoizedProps.contentEditable === true) {
  4519. return true;
  4520. }
  4521. if (type === 'a' || type === 'area') {
  4522. return !!memoizedProps.href && memoizedProps.rel !== 'ignore';
  4523. }
  4524. if (type === 'input') {
  4525. return memoizedProps.type !== 'hidden' && memoizedProps.type !== 'file';
  4526. }
  4527. return type === 'button' || type === 'textarea' || type === 'object' || type === 'select' || type === 'iframe' || type === 'embed';
  4528. }
  4529. function processTimers(timers, delay) {
  4530. var timersArr = Array.from(timers.values());
  4531. currentEventQueuePriority = ContinuousEvent;
  4532. try {
  4533. for (var i = 0; i < timersArr.length; i++) {
  4534. var _timersArr$i = timersArr[i],
  4535. _instance = _timersArr$i.instance,
  4536. _func = _timersArr$i.func,
  4537. _id2 = _timersArr$i.id,
  4538. _timeStamp2 = _timersArr$i.timeStamp;
  4539. currentInstance = _instance;
  4540. currentEventQueue = [];
  4541. currentTimeStamp = _timeStamp2 + delay;
  4542. try {
  4543. _func();
  4544. } finally {
  4545. activeTimeouts.delete(_id2);
  4546. }
  4547. }
  4548. processEventQueue();
  4549. } finally {
  4550. currentTimers = null;
  4551. currentInstance = null;
  4552. currentEventQueue = null;
  4553. currentTimeStamp = 0;
  4554. }
  4555. }
  4556. function createDOMResponderEvent(topLevelType, nativeEvent, nativeEventTarget, passive, passiveSupported) {
  4557. var _ref = nativeEvent,
  4558. pointerType = _ref.pointerType;
  4559. var eventPointerType = '';
  4560. var pointerId = null;
  4561. if (pointerType !== undefined) {
  4562. eventPointerType = pointerType;
  4563. pointerId = nativeEvent.pointerId;
  4564. } else if (nativeEvent.key !== undefined) {
  4565. eventPointerType = 'keyboard';
  4566. } else if (nativeEvent.button !== undefined) {
  4567. eventPointerType = 'mouse';
  4568. } else if (nativeEvent.changedTouches !== undefined) {
  4569. eventPointerType = 'touch';
  4570. }
  4571. return {
  4572. nativeEvent: nativeEvent,
  4573. passive: passive,
  4574. passiveSupported: passiveSupported,
  4575. pointerId: pointerId,
  4576. pointerType: eventPointerType,
  4577. responderTarget: null,
  4578. target: nativeEventTarget,
  4579. type: topLevelType
  4580. };
  4581. }
  4582. function processEvents(eventQueue) {
  4583. for (var i = 0, length = eventQueue.length; i < length; i++) {
  4584. var _eventQueue$i = eventQueue[i],
  4585. _value = _eventQueue$i.value,
  4586. _listener = _eventQueue$i.listener;
  4587. var type = typeof _value === 'object' && _value !== null ? _value.type : '';
  4588. invokeGuardedCallbackAndCatchFirstError(type, _listener, undefined, _value);
  4589. }
  4590. }
  4591. function processEventQueue() {
  4592. var eventQueue = currentEventQueue;
  4593. if (eventQueue.length === 0) {
  4594. return;
  4595. }
  4596. switch (currentEventQueuePriority) {
  4597. case DiscreteEvent:
  4598. {
  4599. flushDiscreteUpdatesIfNeeded(currentTimeStamp);
  4600. discreteUpdates(function () {
  4601. batchedEventUpdates(processEvents, eventQueue);
  4602. });
  4603. break;
  4604. }
  4605. case UserBlockingEvent:
  4606. {
  4607. if (enableUserBlockingEvents) {
  4608. runWithPriority$1(UserBlockingPriority$1, batchedEventUpdates.bind(null, processEvents, eventQueue));
  4609. } else {
  4610. batchedEventUpdates(processEvents, eventQueue);
  4611. }
  4612. break;
  4613. }
  4614. case ContinuousEvent:
  4615. {
  4616. batchedEventUpdates(processEvents, eventQueue);
  4617. break;
  4618. }
  4619. }
  4620. }
  4621. function responderEventTypesContainType(eventTypes, type) {
  4622. for (var i = 0, len = eventTypes.length; i < len; i++) {
  4623. if (eventTypes[i] === type) {
  4624. return true;
  4625. }
  4626. }
  4627. return false;
  4628. }
  4629. function validateResponderTargetEventTypes(eventType, responder) {
  4630. var targetEventTypes = responder.targetEventTypes;
  4631. // Validate the target event type exists on the responder
  4632. if (targetEventTypes !== null) {
  4633. return responderEventTypesContainType(targetEventTypes, eventType);
  4634. }
  4635. return false;
  4636. }
  4637. function validateOwnership(responderInstance) {
  4638. return globalOwner === null || globalOwner === responderInstance;
  4639. }
  4640. function traverseAndHandleEventResponderInstances(topLevelType, targetFiber, nativeEvent, nativeEventTarget, eventSystemFlags) {
  4641. var isPassiveEvent = (eventSystemFlags & IS_PASSIVE) !== 0;
  4642. var isPassiveSupported = (eventSystemFlags & PASSIVE_NOT_SUPPORTED) === 0;
  4643. var isPassive = isPassiveEvent || !isPassiveSupported;
  4644. var eventType = isPassive ? topLevelType : topLevelType + '_active';
  4645. // Trigger event responders in this order:
  4646. // - Bubble target responder phase
  4647. // - Root responder phase
  4648. var visitedResponders = new Set();
  4649. var responderEvent = createDOMResponderEvent(topLevelType, nativeEvent, nativeEventTarget, isPassiveEvent, isPassiveSupported);
  4650. var node = targetFiber;
  4651. while (node !== null) {
  4652. var _node = node,
  4653. dependencies = _node.dependencies,
  4654. tag = _node.tag;
  4655. if (tag === HostComponent && dependencies !== null) {
  4656. var respondersMap = dependencies.responders;
  4657. if (respondersMap !== null) {
  4658. var responderInstances = Array.from(respondersMap.values());
  4659. for (var i = 0, length = responderInstances.length; i < length; i++) {
  4660. var responderInstance = responderInstances[i];
  4661. if (validateOwnership(responderInstance)) {
  4662. var props = responderInstance.props,
  4663. responder = responderInstance.responder,
  4664. state = responderInstance.state,
  4665. target = responderInstance.target;
  4666. if (!visitedResponders.has(responder) && validateResponderTargetEventTypes(eventType, responder)) {
  4667. visitedResponders.add(responder);
  4668. var onEvent = responder.onEvent;
  4669. if (onEvent !== null) {
  4670. currentInstance = responderInstance;
  4671. responderEvent.responderTarget = target;
  4672. onEvent(responderEvent, eventResponderContext, props, state);
  4673. }
  4674. }
  4675. }
  4676. }
  4677. }
  4678. }
  4679. node = node.return;
  4680. }
  4681. // Root phase
  4682. var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get(eventType);
  4683. if (rootEventResponderInstances !== undefined) {
  4684. var _responderInstances = Array.from(rootEventResponderInstances);
  4685. for (var _i = 0; _i < _responderInstances.length; _i++) {
  4686. var _responderInstance = _responderInstances[_i];
  4687. if (!validateOwnership(_responderInstance)) {
  4688. continue;
  4689. }
  4690. var _props = _responderInstance.props,
  4691. _responder = _responderInstance.responder,
  4692. _state = _responderInstance.state,
  4693. _target = _responderInstance.target;
  4694. var onRootEvent = _responder.onRootEvent;
  4695. if (onRootEvent !== null) {
  4696. currentInstance = _responderInstance;
  4697. responderEvent.responderTarget = _target;
  4698. onRootEvent(responderEvent, eventResponderContext, _props, _state);
  4699. }
  4700. }
  4701. }
  4702. }
  4703. function triggerOwnershipListeners() {
  4704. var listeningInstances = Array.from(ownershipChangeListeners);
  4705. var previousInstance = currentInstance;
  4706. var previousEventQueuePriority = currentEventQueuePriority;
  4707. var previousEventQueue = currentEventQueue;
  4708. try {
  4709. for (var i = 0; i < listeningInstances.length; i++) {
  4710. var _instance2 = listeningInstances[i];
  4711. var props = _instance2.props,
  4712. responder = _instance2.responder,
  4713. state = _instance2.state;
  4714. currentInstance = _instance2;
  4715. currentEventQueuePriority = ContinuousEvent;
  4716. currentEventQueue = [];
  4717. var onOwnershipChange = responder.onOwnershipChange;
  4718. if (onOwnershipChange !== null) {
  4719. onOwnershipChange(eventResponderContext, props, state);
  4720. }
  4721. }
  4722. processEventQueue();
  4723. } finally {
  4724. currentInstance = previousInstance;
  4725. currentEventQueue = previousEventQueue;
  4726. currentEventQueuePriority = previousEventQueuePriority;
  4727. }
  4728. }
  4729. function mountEventResponder(responder, responderInstance, props, state) {
  4730. if (responder.onOwnershipChange !== null) {
  4731. ownershipChangeListeners.add(responderInstance);
  4732. }
  4733. var onMount = responder.onMount;
  4734. if (onMount !== null) {
  4735. currentEventQueuePriority = ContinuousEvent;
  4736. currentInstance = responderInstance;
  4737. currentEventQueue = [];
  4738. try {
  4739. onMount(eventResponderContext, props, state);
  4740. processEventQueue();
  4741. } finally {
  4742. currentEventQueue = null;
  4743. currentInstance = null;
  4744. currentTimers = null;
  4745. }
  4746. }
  4747. }
  4748. function unmountEventResponder(responderInstance) {
  4749. var responder = responderInstance.responder;
  4750. var onUnmount = responder.onUnmount;
  4751. if (onUnmount !== null) {
  4752. var props = responderInstance.props,
  4753. state = responderInstance.state;
  4754. currentEventQueue = [];
  4755. currentEventQueuePriority = ContinuousEvent;
  4756. currentInstance = responderInstance;
  4757. try {
  4758. onUnmount(eventResponderContext, props, state);
  4759. processEventQueue();
  4760. } finally {
  4761. currentEventQueue = null;
  4762. currentInstance = null;
  4763. currentTimers = null;
  4764. }
  4765. }
  4766. releaseOwnershipForEventResponderInstance(responderInstance);
  4767. if (responder.onOwnershipChange !== null) {
  4768. ownershipChangeListeners.delete(responderInstance);
  4769. }
  4770. var rootEventTypesSet = responderInstance.rootEventTypes;
  4771. if (rootEventTypesSet !== null) {
  4772. var rootEventTypes = Array.from(rootEventTypesSet);
  4773. for (var i = 0; i < rootEventTypes.length; i++) {
  4774. var topLevelEventType = rootEventTypes[i];
  4775. var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get(topLevelEventType);
  4776. if (rootEventResponderInstances !== undefined) {
  4777. rootEventResponderInstances.delete(responderInstance);
  4778. }
  4779. }
  4780. }
  4781. }
  4782. function validateResponderContext() {
  4783. (function () {
  4784. if (!(currentInstance !== null)) {
  4785. {
  4786. throw ReactError(Error('An event responder context was used outside of an event cycle. Use context.setTimeout() to use asynchronous responder context outside of event cycle .'));
  4787. }
  4788. }
  4789. })();
  4790. }
  4791. function dispatchEventForResponderEventSystem(topLevelType, targetFiber, nativeEvent, nativeEventTarget, eventSystemFlags) {
  4792. if (enableFlareAPI) {
  4793. var previousEventQueue = currentEventQueue;
  4794. var previousInstance = currentInstance;
  4795. var previousTimers = currentTimers;
  4796. var previousTimeStamp = currentTimeStamp;
  4797. var previousDocument = currentDocument;
  4798. var previousEventQueuePriority = currentEventQueuePriority;
  4799. currentTimers = null;
  4800. currentEventQueue = [];
  4801. currentEventQueuePriority = ContinuousEvent;
  4802. // nodeType 9 is DOCUMENT_NODE
  4803. currentDocument = nativeEventTarget.nodeType === 9 ? nativeEventTarget : nativeEventTarget.ownerDocument;
  4804. // We might want to control timeStamp another way here
  4805. currentTimeStamp = nativeEvent.timeStamp;
  4806. try {
  4807. traverseAndHandleEventResponderInstances(topLevelType, targetFiber, nativeEvent, nativeEventTarget, eventSystemFlags);
  4808. processEventQueue();
  4809. } finally {
  4810. currentTimers = previousTimers;
  4811. currentInstance = previousInstance;
  4812. currentEventQueue = previousEventQueue;
  4813. currentTimeStamp = previousTimeStamp;
  4814. currentDocument = previousDocument;
  4815. currentEventQueuePriority = previousEventQueuePriority;
  4816. }
  4817. }
  4818. }
  4819. function addRootEventTypesForResponderInstance(responderInstance, rootEventTypes) {
  4820. for (var i = 0; i < rootEventTypes.length; i++) {
  4821. var rootEventType = rootEventTypes[i];
  4822. registerRootEventType(rootEventType, responderInstance);
  4823. }
  4824. }
  4825. function registerRootEventType(rootEventType, eventResponderInstance) {
  4826. var rootEventResponderInstances = rootEventTypesToEventResponderInstances.get(rootEventType);
  4827. if (rootEventResponderInstances === undefined) {
  4828. rootEventResponderInstances = new Set();
  4829. rootEventTypesToEventResponderInstances.set(rootEventType, rootEventResponderInstances);
  4830. }
  4831. var rootEventTypesSet = eventResponderInstance.rootEventTypes;
  4832. if (rootEventTypesSet === null) {
  4833. rootEventTypesSet = eventResponderInstance.rootEventTypes = new Set();
  4834. }
  4835. (function () {
  4836. if (!!rootEventTypesSet.has(rootEventType)) {
  4837. {
  4838. throw ReactError(Error('addRootEventTypes() found a duplicate root event type of "' + rootEventType + '". This might be because the event type exists in the event responder "rootEventTypes" array or because of a previous addRootEventTypes() using this root event type.'));
  4839. }
  4840. }
  4841. })();
  4842. rootEventTypesSet.add(rootEventType);
  4843. rootEventResponderInstances.add(eventResponderInstance);
  4844. }
  4845. /**
  4846. * `ReactInstanceMap` maintains a mapping from a public facing stateful
  4847. * instance (key) and the internal representation (value). This allows public
  4848. * methods to accept the user facing instance as an argument and map them back
  4849. * to internal methods.
  4850. *
  4851. * Note that this module is currently shared and assumed to be stateless.
  4852. * If this becomes an actual Map, that will break.
  4853. */
  4854. /**
  4855. * This API should be called `delete` but we'd have to make sure to always
  4856. * transform these to strings for IE support. When this transform is fully
  4857. * supported we can rename it.
  4858. */
  4859. function get(key) {
  4860. return key._reactInternalFiber;
  4861. }
  4862. function has(key) {
  4863. return key._reactInternalFiber !== undefined;
  4864. }
  4865. function set(key, value) {
  4866. key._reactInternalFiber = value;
  4867. }
  4868. // Don't change these two values. They're used by React Dev Tools.
  4869. var NoEffect = /* */0;
  4870. var PerformedWork = /* */1;
  4871. // You can change the rest (and add more).
  4872. var Placement = /* */2;
  4873. var Update = /* */4;
  4874. var PlacementAndUpdate = /* */6;
  4875. var Deletion = /* */8;
  4876. var ContentReset = /* */16;
  4877. var Callback = /* */32;
  4878. var DidCapture = /* */64;
  4879. var Ref = /* */128;
  4880. var Snapshot = /* */256;
  4881. var Passive = /* */512;
  4882. // Passive & Update & Callback & Ref & Snapshot
  4883. var LifecycleEffectMask = /* */932;
  4884. // Union of all host effects
  4885. var HostEffectMask = /* */1023;
  4886. var Incomplete = /* */1024;
  4887. var ShouldCapture = /* */2048;
  4888. var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
  4889. var MOUNTING = 1;
  4890. var MOUNTED = 2;
  4891. var UNMOUNTED = 3;
  4892. function isFiberMountedImpl(fiber) {
  4893. var node = fiber;
  4894. if (!fiber.alternate) {
  4895. // If there is no alternate, this might be a new tree that isn't inserted
  4896. // yet. If it is, then it will have a pending insertion effect on it.
  4897. if ((node.effectTag & Placement) !== NoEffect) {
  4898. return MOUNTING;
  4899. }
  4900. while (node.return) {
  4901. node = node.return;
  4902. if ((node.effectTag & Placement) !== NoEffect) {
  4903. return MOUNTING;
  4904. }
  4905. }
  4906. } else {
  4907. while (node.return) {
  4908. node = node.return;
  4909. }
  4910. }
  4911. if (node.tag === HostRoot) {
  4912. // TODO: Check if this was a nested HostRoot when used with
  4913. // renderContainerIntoSubtree.
  4914. return MOUNTED;
  4915. }
  4916. // If we didn't hit the root, that means that we're in an disconnected tree
  4917. // that has been unmounted.
  4918. return UNMOUNTED;
  4919. }
  4920. function isFiberMounted(fiber) {
  4921. return isFiberMountedImpl(fiber) === MOUNTED;
  4922. }
  4923. function isMounted(component) {
  4924. {
  4925. var owner = ReactCurrentOwner$1.current;
  4926. if (owner !== null && owner.tag === ClassComponent) {
  4927. var ownerFiber = owner;
  4928. var instance = ownerFiber.stateNode;
  4929. !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;
  4930. instance._warnedAboutRefsInRender = true;
  4931. }
  4932. }
  4933. var fiber = get(component);
  4934. if (!fiber) {
  4935. return false;
  4936. }
  4937. return isFiberMountedImpl(fiber) === MOUNTED;
  4938. }
  4939. function assertIsMounted(fiber) {
  4940. (function () {
  4941. if (!(isFiberMountedImpl(fiber) === MOUNTED)) {
  4942. {
  4943. throw ReactError(Error('Unable to find node on an unmounted component.'));
  4944. }
  4945. }
  4946. })();
  4947. }
  4948. function findCurrentFiberUsingSlowPath(fiber) {
  4949. var alternate = fiber.alternate;
  4950. if (!alternate) {
  4951. // If there is no alternate, then we only need to check if it is mounted.
  4952. var state = isFiberMountedImpl(fiber);
  4953. (function () {
  4954. if (!(state !== UNMOUNTED)) {
  4955. {
  4956. throw ReactError(Error('Unable to find node on an unmounted component.'));
  4957. }
  4958. }
  4959. })();
  4960. if (state === MOUNTING) {
  4961. return null;
  4962. }
  4963. return fiber;
  4964. }
  4965. // If we have two possible branches, we'll walk backwards up to the root
  4966. // to see what path the root points to. On the way we may hit one of the
  4967. // special cases and we'll deal with them.
  4968. var a = fiber;
  4969. var b = alternate;
  4970. while (true) {
  4971. var parentA = a.return;
  4972. if (parentA === null) {
  4973. // We're at the root.
  4974. break;
  4975. }
  4976. var parentB = parentA.alternate;
  4977. if (parentB === null) {
  4978. // There is no alternate. This is an unusual case. Currently, it only
  4979. // happens when a Suspense component is hidden. An extra fragment fiber
  4980. // is inserted in between the Suspense fiber and its children. Skip
  4981. // over this extra fragment fiber and proceed to the next parent.
  4982. var nextParent = parentA.return;
  4983. if (nextParent !== null) {
  4984. a = b = nextParent;
  4985. continue;
  4986. }
  4987. // If there's no parent, we're at the root.
  4988. break;
  4989. }
  4990. // If both copies of the parent fiber point to the same child, we can
  4991. // assume that the child is current. This happens when we bailout on low
  4992. // priority: the bailed out fiber's child reuses the current child.
  4993. if (parentA.child === parentB.child) {
  4994. var child = parentA.child;
  4995. while (child) {
  4996. if (child === a) {
  4997. // We've determined that A is the current branch.
  4998. assertIsMounted(parentA);
  4999. return fiber;
  5000. }
  5001. if (child === b) {
  5002. // We've determined that B is the current branch.
  5003. assertIsMounted(parentA);
  5004. return alternate;
  5005. }
  5006. child = child.sibling;
  5007. }
  5008. // We should never have an alternate for any mounting node. So the only
  5009. // way this could possibly happen is if this was unmounted, if at all.
  5010. (function () {
  5011. {
  5012. {
  5013. throw ReactError(Error('Unable to find node on an unmounted component.'));
  5014. }
  5015. }
  5016. })();
  5017. }
  5018. if (a.return !== b.return) {
  5019. // The return pointer of A and the return pointer of B point to different
  5020. // fibers. We assume that return pointers never criss-cross, so A must
  5021. // belong to the child set of A.return, and B must belong to the child
  5022. // set of B.return.
  5023. a = parentA;
  5024. b = parentB;
  5025. } else {
  5026. // The return pointers point to the same fiber. We'll have to use the
  5027. // default, slow path: scan the child sets of each parent alternate to see
  5028. // which child belongs to which set.
  5029. //
  5030. // Search parent A's child set
  5031. var didFindChild = false;
  5032. var _child = parentA.child;
  5033. while (_child) {
  5034. if (_child === a) {
  5035. didFindChild = true;
  5036. a = parentA;
  5037. b = parentB;
  5038. break;
  5039. }
  5040. if (_child === b) {
  5041. didFindChild = true;
  5042. b = parentA;
  5043. a = parentB;
  5044. break;
  5045. }
  5046. _child = _child.sibling;
  5047. }
  5048. if (!didFindChild) {
  5049. // Search parent B's child set
  5050. _child = parentB.child;
  5051. while (_child) {
  5052. if (_child === a) {
  5053. didFindChild = true;
  5054. a = parentB;
  5055. b = parentA;
  5056. break;
  5057. }
  5058. if (_child === b) {
  5059. didFindChild = true;
  5060. b = parentB;
  5061. a = parentA;
  5062. break;
  5063. }
  5064. _child = _child.sibling;
  5065. }
  5066. (function () {
  5067. if (!didFindChild) {
  5068. {
  5069. throw ReactError(Error('Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.'));
  5070. }
  5071. }
  5072. })();
  5073. }
  5074. }
  5075. (function () {
  5076. if (!(a.alternate === b)) {
  5077. {
  5078. throw ReactError(Error('Return fibers should always be each others\' alternates. This error is likely caused by a bug in React. Please file an issue.'));
  5079. }
  5080. }
  5081. })();
  5082. }
  5083. // If the root is not a host container, we're in a disconnected tree. I.e.
  5084. // unmounted.
  5085. (function () {
  5086. if (!(a.tag === HostRoot)) {
  5087. {
  5088. throw ReactError(Error('Unable to find node on an unmounted component.'));
  5089. }
  5090. }
  5091. })();
  5092. if (a.stateNode.current === a) {
  5093. // We've determined that A is the current branch.
  5094. return fiber;
  5095. }
  5096. // Otherwise B has to be current branch.
  5097. return alternate;
  5098. }
  5099. function findCurrentHostFiber(parent) {
  5100. var currentParent = findCurrentFiberUsingSlowPath(parent);
  5101. if (!currentParent) {
  5102. return null;
  5103. }
  5104. // Next we'll drill down this component to find the first HostComponent/Text.
  5105. var node = currentParent;
  5106. while (true) {
  5107. if (node.tag === HostComponent || node.tag === HostText) {
  5108. return node;
  5109. } else if (node.child) {
  5110. node.child.return = node;
  5111. node = node.child;
  5112. continue;
  5113. }
  5114. if (node === currentParent) {
  5115. return null;
  5116. }
  5117. while (!node.sibling) {
  5118. if (!node.return || node.return === currentParent) {
  5119. return null;
  5120. }
  5121. node = node.return;
  5122. }
  5123. node.sibling.return = node.return;
  5124. node = node.sibling;
  5125. }
  5126. // Flow needs the return null here, but ESLint complains about it.
  5127. // eslint-disable-next-line no-unreachable
  5128. return null;
  5129. }
  5130. function findCurrentHostFiberWithNoPortals(parent) {
  5131. var currentParent = findCurrentFiberUsingSlowPath(parent);
  5132. if (!currentParent) {
  5133. return null;
  5134. }
  5135. // Next we'll drill down this component to find the first HostComponent/Text.
  5136. var node = currentParent;
  5137. while (true) {
  5138. if (node.tag === HostComponent || node.tag === HostText || node.tag === FundamentalComponent) {
  5139. return node;
  5140. } else if (node.child && node.tag !== HostPortal) {
  5141. node.child.return = node;
  5142. node = node.child;
  5143. continue;
  5144. }
  5145. if (node === currentParent) {
  5146. return null;
  5147. }
  5148. while (!node.sibling) {
  5149. if (!node.return || node.return === currentParent) {
  5150. return null;
  5151. }
  5152. node = node.return;
  5153. }
  5154. node.sibling.return = node.return;
  5155. node = node.sibling;
  5156. }
  5157. // Flow needs the return null here, but ESLint complains about it.
  5158. // eslint-disable-next-line no-unreachable
  5159. return null;
  5160. }
  5161. function addEventBubbleListener(element, eventType, listener) {
  5162. element.addEventListener(eventType, listener, false);
  5163. }
  5164. function addEventCaptureListener(element, eventType, listener) {
  5165. element.addEventListener(eventType, listener, true);
  5166. }
  5167. function addEventCaptureListenerWithPassiveFlag(element, eventType, listener, passive) {
  5168. element.addEventListener(eventType, listener, {
  5169. capture: true,
  5170. passive: passive
  5171. });
  5172. }
  5173. /**
  5174. * @interface Event
  5175. * @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface
  5176. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent
  5177. */
  5178. var SyntheticAnimationEvent = SyntheticEvent.extend({
  5179. animationName: null,
  5180. elapsedTime: null,
  5181. pseudoElement: null
  5182. });
  5183. /**
  5184. * @interface Event
  5185. * @see http://www.w3.org/TR/clipboard-apis/
  5186. */
  5187. var SyntheticClipboardEvent = SyntheticEvent.extend({
  5188. clipboardData: function (event) {
  5189. return 'clipboardData' in event ? event.clipboardData : window.clipboardData;
  5190. }
  5191. });
  5192. /**
  5193. * @interface FocusEvent
  5194. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  5195. */
  5196. var SyntheticFocusEvent = SyntheticUIEvent.extend({
  5197. relatedTarget: null
  5198. });
  5199. /**
  5200. * `charCode` represents the actual "character code" and is safe to use with
  5201. * `String.fromCharCode`. As such, only keys that correspond to printable
  5202. * characters produce a valid `charCode`, the only exception to this is Enter.
  5203. * The Tab-key is considered non-printable and does not have a `charCode`,
  5204. * presumably because it does not produce a tab-character in browsers.
  5205. *
  5206. * @param {object} nativeEvent Native browser event.
  5207. * @return {number} Normalized `charCode` property.
  5208. */
  5209. function getEventCharCode(nativeEvent) {
  5210. var charCode = void 0;
  5211. var keyCode = nativeEvent.keyCode;
  5212. if ('charCode' in nativeEvent) {
  5213. charCode = nativeEvent.charCode;
  5214. // FF does not set `charCode` for the Enter-key, check against `keyCode`.
  5215. if (charCode === 0 && keyCode === 13) {
  5216. charCode = 13;
  5217. }
  5218. } else {
  5219. // IE8 does not implement `charCode`, but `keyCode` has the correct value.
  5220. charCode = keyCode;
  5221. }
  5222. // IE and Edge (on Windows) and Chrome / Safari (on Windows and Linux)
  5223. // report Enter as charCode 10 when ctrl is pressed.
  5224. if (charCode === 10) {
  5225. charCode = 13;
  5226. }
  5227. // Some non-printable keys are reported in `charCode`/`keyCode`, discard them.
  5228. // Must not discard the (non-)printable Enter-key.
  5229. if (charCode >= 32 || charCode === 13) {
  5230. return charCode;
  5231. }
  5232. return 0;
  5233. }
  5234. /**
  5235. * Normalization of deprecated HTML5 `key` values
  5236. * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
  5237. */
  5238. var normalizeKey = {
  5239. Esc: 'Escape',
  5240. Spacebar: ' ',
  5241. Left: 'ArrowLeft',
  5242. Up: 'ArrowUp',
  5243. Right: 'ArrowRight',
  5244. Down: 'ArrowDown',
  5245. Del: 'Delete',
  5246. Win: 'OS',
  5247. Menu: 'ContextMenu',
  5248. Apps: 'ContextMenu',
  5249. Scroll: 'ScrollLock',
  5250. MozPrintableKey: 'Unidentified'
  5251. };
  5252. /**
  5253. * Translation from legacy `keyCode` to HTML5 `key`
  5254. * Only special keys supported, all others depend on keyboard layout or browser
  5255. * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
  5256. */
  5257. var translateToKey = {
  5258. '8': 'Backspace',
  5259. '9': 'Tab',
  5260. '12': 'Clear',
  5261. '13': 'Enter',
  5262. '16': 'Shift',
  5263. '17': 'Control',
  5264. '18': 'Alt',
  5265. '19': 'Pause',
  5266. '20': 'CapsLock',
  5267. '27': 'Escape',
  5268. '32': ' ',
  5269. '33': 'PageUp',
  5270. '34': 'PageDown',
  5271. '35': 'End',
  5272. '36': 'Home',
  5273. '37': 'ArrowLeft',
  5274. '38': 'ArrowUp',
  5275. '39': 'ArrowRight',
  5276. '40': 'ArrowDown',
  5277. '45': 'Insert',
  5278. '46': 'Delete',
  5279. '112': 'F1',
  5280. '113': 'F2',
  5281. '114': 'F3',
  5282. '115': 'F4',
  5283. '116': 'F5',
  5284. '117': 'F6',
  5285. '118': 'F7',
  5286. '119': 'F8',
  5287. '120': 'F9',
  5288. '121': 'F10',
  5289. '122': 'F11',
  5290. '123': 'F12',
  5291. '144': 'NumLock',
  5292. '145': 'ScrollLock',
  5293. '224': 'Meta'
  5294. };
  5295. /**
  5296. * @param {object} nativeEvent Native browser event.
  5297. * @return {string} Normalized `key` property.
  5298. */
  5299. function getEventKey(nativeEvent) {
  5300. if (nativeEvent.key) {
  5301. // Normalize inconsistent values reported by browsers due to
  5302. // implementations of a working draft specification.
  5303. // FireFox implements `key` but returns `MozPrintableKey` for all
  5304. // printable characters (normalized to `Unidentified`), ignore it.
  5305. var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
  5306. if (key !== 'Unidentified') {
  5307. return key;
  5308. }
  5309. }
  5310. // Browser does not implement `key`, polyfill as much of it as we can.
  5311. if (nativeEvent.type === 'keypress') {
  5312. var charCode = getEventCharCode(nativeEvent);
  5313. // The enter-key is technically both printable and non-printable and can
  5314. // thus be captured by `keypress`, no other non-printable key should.
  5315. return charCode === 13 ? 'Enter' : String.fromCharCode(charCode);
  5316. }
  5317. if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {
  5318. // While user keyboard layout determines the actual meaning of each
  5319. // `keyCode` value, almost all function keys have a universal value.
  5320. return translateToKey[nativeEvent.keyCode] || 'Unidentified';
  5321. }
  5322. return '';
  5323. }
  5324. /**
  5325. * @interface KeyboardEvent
  5326. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  5327. */
  5328. var SyntheticKeyboardEvent = SyntheticUIEvent.extend({
  5329. key: getEventKey,
  5330. location: null,
  5331. ctrlKey: null,
  5332. shiftKey: null,
  5333. altKey: null,
  5334. metaKey: null,
  5335. repeat: null,
  5336. locale: null,
  5337. getModifierState: getEventModifierState,
  5338. // Legacy Interface
  5339. charCode: function (event) {
  5340. // `charCode` is the result of a KeyPress event and represents the value of
  5341. // the actual printable character.
  5342. // KeyPress is deprecated, but its replacement is not yet final and not
  5343. // implemented in any major browser. Only KeyPress has charCode.
  5344. if (event.type === 'keypress') {
  5345. return getEventCharCode(event);
  5346. }
  5347. return 0;
  5348. },
  5349. keyCode: function (event) {
  5350. // `keyCode` is the result of a KeyDown/Up event and represents the value of
  5351. // physical keyboard key.
  5352. // The actual meaning of the value depends on the users' keyboard layout
  5353. // which cannot be detected. Assuming that it is a US keyboard layout
  5354. // provides a surprisingly accurate mapping for US and European users.
  5355. // Due to this, it is left to the user to implement at this time.
  5356. if (event.type === 'keydown' || event.type === 'keyup') {
  5357. return event.keyCode;
  5358. }
  5359. return 0;
  5360. },
  5361. which: function (event) {
  5362. // `which` is an alias for either `keyCode` or `charCode` depending on the
  5363. // type of the event.
  5364. if (event.type === 'keypress') {
  5365. return getEventCharCode(event);
  5366. }
  5367. if (event.type === 'keydown' || event.type === 'keyup') {
  5368. return event.keyCode;
  5369. }
  5370. return 0;
  5371. }
  5372. });
  5373. /**
  5374. * @interface DragEvent
  5375. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  5376. */
  5377. var SyntheticDragEvent = SyntheticMouseEvent.extend({
  5378. dataTransfer: null
  5379. });
  5380. /**
  5381. * @interface TouchEvent
  5382. * @see http://www.w3.org/TR/touch-events/
  5383. */
  5384. var SyntheticTouchEvent = SyntheticUIEvent.extend({
  5385. touches: null,
  5386. targetTouches: null,
  5387. changedTouches: null,
  5388. altKey: null,
  5389. metaKey: null,
  5390. ctrlKey: null,
  5391. shiftKey: null,
  5392. getModifierState: getEventModifierState
  5393. });
  5394. /**
  5395. * @interface Event
  5396. * @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events-
  5397. * @see https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent
  5398. */
  5399. var SyntheticTransitionEvent = SyntheticEvent.extend({
  5400. propertyName: null,
  5401. elapsedTime: null,
  5402. pseudoElement: null
  5403. });
  5404. /**
  5405. * @interface WheelEvent
  5406. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  5407. */
  5408. var SyntheticWheelEvent = SyntheticMouseEvent.extend({
  5409. deltaX: function (event) {
  5410. return 'deltaX' in event ? event.deltaX : // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
  5411. 'wheelDeltaX' in event ? -event.wheelDeltaX : 0;
  5412. },
  5413. deltaY: function (event) {
  5414. return 'deltaY' in event ? event.deltaY : // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
  5415. 'wheelDeltaY' in event ? -event.wheelDeltaY : // Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
  5416. 'wheelDelta' in event ? -event.wheelDelta : 0;
  5417. },
  5418. deltaZ: null,
  5419. // Browsers without "deltaMode" is reporting in raw wheel delta where one
  5420. // notch on the scroll is always +/- 120, roughly equivalent to pixels.
  5421. // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or
  5422. // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size.
  5423. deltaMode: null
  5424. });
  5425. /**
  5426. * Turns
  5427. * ['abort', ...]
  5428. * into
  5429. * eventTypes = {
  5430. * 'abort': {
  5431. * phasedRegistrationNames: {
  5432. * bubbled: 'onAbort',
  5433. * captured: 'onAbortCapture',
  5434. * },
  5435. * dependencies: [TOP_ABORT],
  5436. * },
  5437. * ...
  5438. * };
  5439. * topLevelEventsToDispatchConfig = new Map([
  5440. * [TOP_ABORT, { sameConfig }],
  5441. * ]);
  5442. */
  5443. var eventTuples = [
  5444. // Discrete events
  5445. [TOP_BLUR, 'blur', DiscreteEvent], [TOP_CANCEL, 'cancel', DiscreteEvent], [TOP_CLICK, 'click', DiscreteEvent], [TOP_CLOSE, 'close', DiscreteEvent], [TOP_CONTEXT_MENU, 'contextMenu', DiscreteEvent], [TOP_COPY, 'copy', DiscreteEvent], [TOP_CUT, 'cut', DiscreteEvent], [TOP_AUX_CLICK, 'auxClick', DiscreteEvent], [TOP_DOUBLE_CLICK, 'doubleClick', DiscreteEvent], [TOP_DRAG_END, 'dragEnd', DiscreteEvent], [TOP_DRAG_START, 'dragStart', DiscreteEvent], [TOP_DROP, 'drop', DiscreteEvent], [TOP_FOCUS, 'focus', DiscreteEvent], [TOP_INPUT, 'input', DiscreteEvent], [TOP_INVALID, 'invalid', DiscreteEvent], [TOP_KEY_DOWN, 'keyDown', DiscreteEvent], [TOP_KEY_PRESS, 'keyPress', DiscreteEvent], [TOP_KEY_UP, 'keyUp', DiscreteEvent], [TOP_MOUSE_DOWN, 'mouseDown', DiscreteEvent], [TOP_MOUSE_UP, 'mouseUp', DiscreteEvent], [TOP_PASTE, 'paste', DiscreteEvent], [TOP_PAUSE, 'pause', DiscreteEvent], [TOP_PLAY, 'play', DiscreteEvent], [TOP_POINTER_CANCEL, 'pointerCancel', DiscreteEvent], [TOP_POINTER_DOWN, 'pointerDown', DiscreteEvent], [TOP_POINTER_UP, 'pointerUp', DiscreteEvent], [TOP_RATE_CHANGE, 'rateChange', DiscreteEvent], [TOP_RESET, 'reset', DiscreteEvent], [TOP_SEEKED, 'seeked', DiscreteEvent], [TOP_SUBMIT, 'submit', DiscreteEvent], [TOP_TOUCH_CANCEL, 'touchCancel', DiscreteEvent], [TOP_TOUCH_END, 'touchEnd', DiscreteEvent], [TOP_TOUCH_START, 'touchStart', DiscreteEvent], [TOP_VOLUME_CHANGE, 'volumeChange', DiscreteEvent],
  5446. // User-blocking events
  5447. [TOP_DRAG, 'drag', UserBlockingEvent], [TOP_DRAG_ENTER, 'dragEnter', UserBlockingEvent], [TOP_DRAG_EXIT, 'dragExit', UserBlockingEvent], [TOP_DRAG_LEAVE, 'dragLeave', UserBlockingEvent], [TOP_DRAG_OVER, 'dragOver', UserBlockingEvent], [TOP_MOUSE_MOVE, 'mouseMove', UserBlockingEvent], [TOP_MOUSE_OUT, 'mouseOut', UserBlockingEvent], [TOP_MOUSE_OVER, 'mouseOver', UserBlockingEvent], [TOP_POINTER_MOVE, 'pointerMove', UserBlockingEvent], [TOP_POINTER_OUT, 'pointerOut', UserBlockingEvent], [TOP_POINTER_OVER, 'pointerOver', UserBlockingEvent], [TOP_SCROLL, 'scroll', UserBlockingEvent], [TOP_TOGGLE, 'toggle', UserBlockingEvent], [TOP_TOUCH_MOVE, 'touchMove', UserBlockingEvent], [TOP_WHEEL, 'wheel', UserBlockingEvent],
  5448. // Continuous events
  5449. [TOP_ABORT, 'abort', ContinuousEvent], [TOP_ANIMATION_END, 'animationEnd', ContinuousEvent], [TOP_ANIMATION_ITERATION, 'animationIteration', ContinuousEvent], [TOP_ANIMATION_START, 'animationStart', ContinuousEvent], [TOP_CAN_PLAY, 'canPlay', ContinuousEvent], [TOP_CAN_PLAY_THROUGH, 'canPlayThrough', ContinuousEvent], [TOP_DURATION_CHANGE, 'durationChange', ContinuousEvent], [TOP_EMPTIED, 'emptied', ContinuousEvent], [TOP_ENCRYPTED, 'encrypted', ContinuousEvent], [TOP_ENDED, 'ended', ContinuousEvent], [TOP_ERROR, 'error', ContinuousEvent], [TOP_GOT_POINTER_CAPTURE, 'gotPointerCapture', ContinuousEvent], [TOP_LOAD, 'load', ContinuousEvent], [TOP_LOADED_DATA, 'loadedData', ContinuousEvent], [TOP_LOADED_METADATA, 'loadedMetadata', ContinuousEvent], [TOP_LOAD_START, 'loadStart', ContinuousEvent], [TOP_LOST_POINTER_CAPTURE, 'lostPointerCapture', ContinuousEvent], [TOP_PLAYING, 'playing', ContinuousEvent], [TOP_PROGRESS, 'progress', ContinuousEvent], [TOP_SEEKING, 'seeking', ContinuousEvent], [TOP_STALLED, 'stalled', ContinuousEvent], [TOP_SUSPEND, 'suspend', ContinuousEvent], [TOP_TIME_UPDATE, 'timeUpdate', ContinuousEvent], [TOP_TRANSITION_END, 'transitionEnd', ContinuousEvent], [TOP_WAITING, 'waiting', ContinuousEvent]];
  5450. var eventTypes$4 = {};
  5451. var topLevelEventsToDispatchConfig = {};
  5452. for (var i = 0; i < eventTuples.length; i++) {
  5453. var eventTuple = eventTuples[i];
  5454. var topEvent = eventTuple[0];
  5455. var event = eventTuple[1];
  5456. var eventPriority = eventTuple[2];
  5457. var capitalizedEvent = event[0].toUpperCase() + event.slice(1);
  5458. var onEvent = 'on' + capitalizedEvent;
  5459. var config = {
  5460. phasedRegistrationNames: {
  5461. bubbled: onEvent,
  5462. captured: onEvent + 'Capture'
  5463. },
  5464. dependencies: [topEvent],
  5465. eventPriority: eventPriority
  5466. };
  5467. eventTypes$4[event] = config;
  5468. topLevelEventsToDispatchConfig[topEvent] = config;
  5469. }
  5470. // Only used in DEV for exhaustiveness validation.
  5471. 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];
  5472. var SimpleEventPlugin = {
  5473. eventTypes: eventTypes$4,
  5474. getEventPriority: function (topLevelType) {
  5475. var config = topLevelEventsToDispatchConfig[topLevelType];
  5476. return config !== undefined ? config.eventPriority : ContinuousEvent;
  5477. },
  5478. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  5479. var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType];
  5480. if (!dispatchConfig) {
  5481. return null;
  5482. }
  5483. var EventConstructor = void 0;
  5484. switch (topLevelType) {
  5485. case TOP_KEY_PRESS:
  5486. // Firefox creates a keypress event for function keys too. This removes
  5487. // the unwanted keypress events. Enter is however both printable and
  5488. // non-printable. One would expect Tab to be as well (but it isn't).
  5489. if (getEventCharCode(nativeEvent) === 0) {
  5490. return null;
  5491. }
  5492. /* falls through */
  5493. case TOP_KEY_DOWN:
  5494. case TOP_KEY_UP:
  5495. EventConstructor = SyntheticKeyboardEvent;
  5496. break;
  5497. case TOP_BLUR:
  5498. case TOP_FOCUS:
  5499. EventConstructor = SyntheticFocusEvent;
  5500. break;
  5501. case TOP_CLICK:
  5502. // Firefox creates a click event on right mouse clicks. This removes the
  5503. // unwanted click events.
  5504. if (nativeEvent.button === 2) {
  5505. return null;
  5506. }
  5507. /* falls through */
  5508. case TOP_AUX_CLICK:
  5509. case TOP_DOUBLE_CLICK:
  5510. case TOP_MOUSE_DOWN:
  5511. case TOP_MOUSE_MOVE:
  5512. case TOP_MOUSE_UP:
  5513. // TODO: Disabled elements should not respond to mouse events
  5514. /* falls through */
  5515. case TOP_MOUSE_OUT:
  5516. case TOP_MOUSE_OVER:
  5517. case TOP_CONTEXT_MENU:
  5518. EventConstructor = SyntheticMouseEvent;
  5519. break;
  5520. case TOP_DRAG:
  5521. case TOP_DRAG_END:
  5522. case TOP_DRAG_ENTER:
  5523. case TOP_DRAG_EXIT:
  5524. case TOP_DRAG_LEAVE:
  5525. case TOP_DRAG_OVER:
  5526. case TOP_DRAG_START:
  5527. case TOP_DROP:
  5528. EventConstructor = SyntheticDragEvent;
  5529. break;
  5530. case TOP_TOUCH_CANCEL:
  5531. case TOP_TOUCH_END:
  5532. case TOP_TOUCH_MOVE:
  5533. case TOP_TOUCH_START:
  5534. EventConstructor = SyntheticTouchEvent;
  5535. break;
  5536. case TOP_ANIMATION_END:
  5537. case TOP_ANIMATION_ITERATION:
  5538. case TOP_ANIMATION_START:
  5539. EventConstructor = SyntheticAnimationEvent;
  5540. break;
  5541. case TOP_TRANSITION_END:
  5542. EventConstructor = SyntheticTransitionEvent;
  5543. break;
  5544. case TOP_SCROLL:
  5545. EventConstructor = SyntheticUIEvent;
  5546. break;
  5547. case TOP_WHEEL:
  5548. EventConstructor = SyntheticWheelEvent;
  5549. break;
  5550. case TOP_COPY:
  5551. case TOP_CUT:
  5552. case TOP_PASTE:
  5553. EventConstructor = SyntheticClipboardEvent;
  5554. break;
  5555. case TOP_GOT_POINTER_CAPTURE:
  5556. case TOP_LOST_POINTER_CAPTURE:
  5557. case TOP_POINTER_CANCEL:
  5558. case TOP_POINTER_DOWN:
  5559. case TOP_POINTER_MOVE:
  5560. case TOP_POINTER_OUT:
  5561. case TOP_POINTER_OVER:
  5562. case TOP_POINTER_UP:
  5563. EventConstructor = SyntheticPointerEvent;
  5564. break;
  5565. default:
  5566. {
  5567. if (knownHTMLTopLevelTypes.indexOf(topLevelType) === -1) {
  5568. warningWithoutStack$1(false, 'SimpleEventPlugin: Unhandled event type, `%s`. This warning ' + 'is likely caused by a bug in React. Please file an issue.', topLevelType);
  5569. }
  5570. }
  5571. // HTML Events
  5572. // @see http://www.w3.org/TR/html5/index.html#events-0
  5573. EventConstructor = SyntheticEvent;
  5574. break;
  5575. }
  5576. var event = EventConstructor.getPooled(dispatchConfig, targetInst, nativeEvent, nativeEventTarget);
  5577. accumulateTwoPhaseDispatches(event);
  5578. return event;
  5579. }
  5580. };
  5581. var passiveBrowserEventsSupported = false;
  5582. // Check if browser support events with passive listeners
  5583. // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
  5584. if (enableFlareAPI && canUseDOM) {
  5585. try {
  5586. var options = {};
  5587. // $FlowFixMe: Ignore Flow complaining about needing a value
  5588. Object.defineProperty(options, 'passive', {
  5589. get: function () {
  5590. passiveBrowserEventsSupported = true;
  5591. }
  5592. });
  5593. window.addEventListener('test', options, options);
  5594. window.removeEventListener('test', options, options);
  5595. } catch (e) {
  5596. passiveBrowserEventsSupported = false;
  5597. }
  5598. }
  5599. // Intentionally not named imports because Rollup would use dynamic dispatch for
  5600. // CommonJS interop named imports.
  5601. var UserBlockingPriority = Scheduler.unstable_UserBlockingPriority;
  5602. var runWithPriority = Scheduler.unstable_runWithPriority;
  5603. var getEventPriority = SimpleEventPlugin.getEventPriority;
  5604. var CALLBACK_BOOKKEEPING_POOL_SIZE = 10;
  5605. var callbackBookkeepingPool = [];
  5606. /**
  5607. * Find the deepest React component completely containing the root of the
  5608. * passed-in instance (for use when entire React trees are nested within each
  5609. * other). If React trees are not nested, returns null.
  5610. */
  5611. function findRootContainerNode(inst) {
  5612. // TODO: It may be a good idea to cache this to prevent unnecessary DOM
  5613. // traversal, but caching is difficult to do correctly without using a
  5614. // mutation observer to listen for all DOM changes.
  5615. while (inst.return) {
  5616. inst = inst.return;
  5617. }
  5618. if (inst.tag !== HostRoot) {
  5619. // This can happen if we're in a detached tree.
  5620. return null;
  5621. }
  5622. return inst.stateNode.containerInfo;
  5623. }
  5624. // Used to store ancestor hierarchy in top level callback
  5625. function getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst) {
  5626. if (callbackBookkeepingPool.length) {
  5627. var instance = callbackBookkeepingPool.pop();
  5628. instance.topLevelType = topLevelType;
  5629. instance.nativeEvent = nativeEvent;
  5630. instance.targetInst = targetInst;
  5631. return instance;
  5632. }
  5633. return {
  5634. topLevelType: topLevelType,
  5635. nativeEvent: nativeEvent,
  5636. targetInst: targetInst,
  5637. ancestors: []
  5638. };
  5639. }
  5640. function releaseTopLevelCallbackBookKeeping(instance) {
  5641. instance.topLevelType = null;
  5642. instance.nativeEvent = null;
  5643. instance.targetInst = null;
  5644. instance.ancestors.length = 0;
  5645. if (callbackBookkeepingPool.length < CALLBACK_BOOKKEEPING_POOL_SIZE) {
  5646. callbackBookkeepingPool.push(instance);
  5647. }
  5648. }
  5649. function handleTopLevel(bookKeeping) {
  5650. var targetInst = bookKeeping.targetInst;
  5651. // Loop through the hierarchy, in case there's any nested components.
  5652. // It's important that we build the array of ancestors before calling any
  5653. // event handlers, because event handlers can modify the DOM, leading to
  5654. // inconsistencies with ReactMount's node cache. See #1105.
  5655. var ancestor = targetInst;
  5656. do {
  5657. if (!ancestor) {
  5658. var _ancestors = bookKeeping.ancestors;
  5659. _ancestors.push(ancestor);
  5660. break;
  5661. }
  5662. var root = findRootContainerNode(ancestor);
  5663. if (!root) {
  5664. break;
  5665. }
  5666. bookKeeping.ancestors.push(ancestor);
  5667. ancestor = getClosestInstanceFromNode(root);
  5668. } while (ancestor);
  5669. for (var i = 0; i < bookKeeping.ancestors.length; i++) {
  5670. targetInst = bookKeeping.ancestors[i];
  5671. var eventTarget = getEventTarget(bookKeeping.nativeEvent);
  5672. var _topLevelType = bookKeeping.topLevelType;
  5673. var _nativeEvent = bookKeeping.nativeEvent;
  5674. runExtractedPluginEventsInBatch(_topLevelType, targetInst, _nativeEvent, eventTarget);
  5675. }
  5676. }
  5677. // TODO: can we stop exporting these?
  5678. var _enabled = true;
  5679. function setEnabled(enabled) {
  5680. _enabled = !!enabled;
  5681. }
  5682. function isEnabled() {
  5683. return _enabled;
  5684. }
  5685. function trapBubbledEvent(topLevelType, element) {
  5686. trapEventForPluginEventSystem(element, topLevelType, false);
  5687. }
  5688. function trapCapturedEvent(topLevelType, element) {
  5689. trapEventForPluginEventSystem(element, topLevelType, true);
  5690. }
  5691. function trapEventForResponderEventSystem(element, topLevelType, passive) {
  5692. if (enableFlareAPI) {
  5693. var rawEventName = getRawEventName(topLevelType);
  5694. var eventFlags = RESPONDER_EVENT_SYSTEM;
  5695. // If passive option is not supported, then the event will be
  5696. // active and not passive, but we flag it as using not being
  5697. // supported too. This way the responder event plugins know,
  5698. // and can provide polyfills if needed.
  5699. if (passive) {
  5700. if (passiveBrowserEventsSupported) {
  5701. eventFlags |= IS_PASSIVE;
  5702. } else {
  5703. eventFlags |= IS_ACTIVE;
  5704. eventFlags |= PASSIVE_NOT_SUPPORTED;
  5705. passive = false;
  5706. }
  5707. } else {
  5708. eventFlags |= IS_ACTIVE;
  5709. }
  5710. // Check if interactive and wrap in discreteUpdates
  5711. var listener = dispatchEvent.bind(null, topLevelType, eventFlags);
  5712. if (passiveBrowserEventsSupported) {
  5713. addEventCaptureListenerWithPassiveFlag(element, rawEventName, listener, passive);
  5714. } else {
  5715. addEventCaptureListener(element, rawEventName, listener);
  5716. }
  5717. }
  5718. }
  5719. function trapEventForPluginEventSystem(element, topLevelType, capture) {
  5720. var listener = void 0;
  5721. switch (getEventPriority(topLevelType)) {
  5722. case DiscreteEvent:
  5723. listener = dispatchDiscreteEvent.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM);
  5724. break;
  5725. case UserBlockingEvent:
  5726. listener = dispatchUserBlockingUpdate.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM);
  5727. break;
  5728. case ContinuousEvent:
  5729. default:
  5730. listener = dispatchEvent.bind(null, topLevelType, PLUGIN_EVENT_SYSTEM);
  5731. break;
  5732. }
  5733. var rawEventName = getRawEventName(topLevelType);
  5734. if (capture) {
  5735. addEventCaptureListener(element, rawEventName, listener);
  5736. } else {
  5737. addEventBubbleListener(element, rawEventName, listener);
  5738. }
  5739. }
  5740. function dispatchDiscreteEvent(topLevelType, eventSystemFlags, nativeEvent) {
  5741. flushDiscreteUpdatesIfNeeded(nativeEvent.timeStamp);
  5742. discreteUpdates(dispatchEvent, topLevelType, eventSystemFlags, nativeEvent);
  5743. }
  5744. function dispatchUserBlockingUpdate(topLevelType, eventSystemFlags, nativeEvent) {
  5745. if (enableUserBlockingEvents) {
  5746. runWithPriority(UserBlockingPriority, dispatchEvent.bind(null, topLevelType, eventSystemFlags, nativeEvent));
  5747. } else {
  5748. dispatchEvent(topLevelType, eventSystemFlags, nativeEvent);
  5749. }
  5750. }
  5751. function dispatchEventForPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, targetInst) {
  5752. var bookKeeping = getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst);
  5753. try {
  5754. // Event queue being processed in the same cycle allows
  5755. // `preventDefault`.
  5756. batchedEventUpdates(handleTopLevel, bookKeeping);
  5757. } finally {
  5758. releaseTopLevelCallbackBookKeeping(bookKeeping);
  5759. }
  5760. }
  5761. function dispatchEvent(topLevelType, eventSystemFlags, nativeEvent) {
  5762. if (!_enabled) {
  5763. return;
  5764. }
  5765. var nativeEventTarget = getEventTarget(nativeEvent);
  5766. var targetInst = getClosestInstanceFromNode(nativeEventTarget);
  5767. if (targetInst !== null && typeof targetInst.tag === 'number' && !isFiberMounted(targetInst)) {
  5768. // If we get an event (ex: img onload) before committing that
  5769. // component's mount, ignore it for now (that is, treat it as if it was an
  5770. // event on a non-React tree). We might also consider queueing events and
  5771. // dispatching them after the mount.
  5772. targetInst = null;
  5773. }
  5774. if (enableFlareAPI) {
  5775. if (eventSystemFlags === PLUGIN_EVENT_SYSTEM) {
  5776. dispatchEventForPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, targetInst);
  5777. } else {
  5778. // React Flare event system
  5779. dispatchEventForResponderEventSystem(topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags);
  5780. }
  5781. } else {
  5782. dispatchEventForPluginEventSystem(topLevelType, eventSystemFlags, nativeEvent, targetInst);
  5783. }
  5784. }
  5785. /**
  5786. * Summary of `ReactBrowserEventEmitter` event handling:
  5787. *
  5788. * - Top-level delegation is used to trap most native browser events. This
  5789. * may only occur in the main thread and is the responsibility of
  5790. * ReactDOMEventListener, which is injected and can therefore support
  5791. * pluggable event sources. This is the only work that occurs in the main
  5792. * thread.
  5793. *
  5794. * - We normalize and de-duplicate events to account for browser quirks. This
  5795. * may be done in the worker thread.
  5796. *
  5797. * - Forward these native events (with the associated top-level type used to
  5798. * trap it) to `EventPluginHub`, which in turn will ask plugins if they want
  5799. * to extract any synthetic events.
  5800. *
  5801. * - The `EventPluginHub` will then process each event by annotating them with
  5802. * "dispatches", a sequence of listeners and IDs that care about that event.
  5803. *
  5804. * - The `EventPluginHub` then dispatches the events.
  5805. *
  5806. * Overview of React and the event system:
  5807. *
  5808. * +------------+ .
  5809. * | DOM | .
  5810. * +------------+ .
  5811. * | .
  5812. * v .
  5813. * +------------+ .
  5814. * | ReactEvent | .
  5815. * | Listener | .
  5816. * +------------+ . +-----------+
  5817. * | . +--------+|SimpleEvent|
  5818. * | . | |Plugin |
  5819. * +-----|------+ . v +-----------+
  5820. * | | | . +--------------+ +------------+
  5821. * | +-----------.--->|EventPluginHub| | Event |
  5822. * | | . | | +-----------+ | Propagators|
  5823. * | ReactEvent | . | | |TapEvent | |------------|
  5824. * | Emitter | . | |<---+|Plugin | |other plugin|
  5825. * | | . | | +-----------+ | utilities |
  5826. * | +-----------.--->| | +------------+
  5827. * | | | . +--------------+
  5828. * +-----|------+ . ^ +-----------+
  5829. * | . | |Enter/Leave|
  5830. * + . +-------+|Plugin |
  5831. * +-------------+ . +-----------+
  5832. * | application | .
  5833. * |-------------| .
  5834. * | | .
  5835. * | | .
  5836. * +-------------+ .
  5837. * .
  5838. * React Core . General Purpose Event Plugin System
  5839. */
  5840. var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
  5841. var elementListeningSets = new PossiblyWeakMap();
  5842. function getListeningSetForElement(element) {
  5843. var listeningSet = elementListeningSets.get(element);
  5844. if (listeningSet === undefined) {
  5845. listeningSet = new Set();
  5846. elementListeningSets.set(element, listeningSet);
  5847. }
  5848. return listeningSet;
  5849. }
  5850. /**
  5851. * We listen for bubbled touch events on the document object.
  5852. *
  5853. * Firefox v8.01 (and possibly others) exhibited strange behavior when
  5854. * mounting `onmousemove` events at some node that was not the document
  5855. * element. The symptoms were that if your mouse is not moving over something
  5856. * contained within that mount point (for example on the background) the
  5857. * top-level listeners for `onmousemove` won't be called. However, if you
  5858. * register the `mousemove` on the document object, then it will of course
  5859. * catch all `mousemove`s. This along with iOS quirks, justifies restricting
  5860. * top-level listeners to the document object only, at least for these
  5861. * movement types of events and possibly all events.
  5862. *
  5863. * @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
  5864. *
  5865. * Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but
  5866. * they bubble to document.
  5867. *
  5868. * @param {string} registrationName Name of listener (e.g. `onClick`).
  5869. * @param {object} mountAt Container where to mount the listener
  5870. */
  5871. function listenTo(registrationName, mountAt) {
  5872. var listeningSet = getListeningSetForElement(mountAt);
  5873. var dependencies = registrationNameDependencies[registrationName];
  5874. for (var i = 0; i < dependencies.length; i++) {
  5875. var dependency = dependencies[i];
  5876. if (!listeningSet.has(dependency)) {
  5877. switch (dependency) {
  5878. case TOP_SCROLL:
  5879. trapCapturedEvent(TOP_SCROLL, mountAt);
  5880. break;
  5881. case TOP_FOCUS:
  5882. case TOP_BLUR:
  5883. trapCapturedEvent(TOP_FOCUS, mountAt);
  5884. trapCapturedEvent(TOP_BLUR, mountAt);
  5885. // We set the flag for a single dependency later in this function,
  5886. // but this ensures we mark both as attached rather than just one.
  5887. listeningSet.add(TOP_BLUR);
  5888. listeningSet.add(TOP_FOCUS);
  5889. break;
  5890. case TOP_CANCEL:
  5891. case TOP_CLOSE:
  5892. if (isEventSupported(getRawEventName(dependency))) {
  5893. trapCapturedEvent(dependency, mountAt);
  5894. }
  5895. break;
  5896. case TOP_INVALID:
  5897. case TOP_SUBMIT:
  5898. case TOP_RESET:
  5899. // We listen to them on the target DOM elements.
  5900. // Some of them bubble so we don't want them to fire twice.
  5901. break;
  5902. default:
  5903. // By default, listen on the top level to all non-media events.
  5904. // Media events don't bubble so adding the listener wouldn't do anything.
  5905. var isMediaEvent = mediaEventTypes.indexOf(dependency) !== -1;
  5906. if (!isMediaEvent) {
  5907. trapBubbledEvent(dependency, mountAt);
  5908. }
  5909. break;
  5910. }
  5911. listeningSet.add(dependency);
  5912. }
  5913. }
  5914. }
  5915. function isListeningToAllDependencies(registrationName, mountAt) {
  5916. var listeningSet = getListeningSetForElement(mountAt);
  5917. var dependencies = registrationNameDependencies[registrationName];
  5918. for (var i = 0; i < dependencies.length; i++) {
  5919. var dependency = dependencies[i];
  5920. if (!listeningSet.has(dependency)) {
  5921. return false;
  5922. }
  5923. }
  5924. return true;
  5925. }
  5926. function getActiveElement(doc) {
  5927. doc = doc || (typeof document !== 'undefined' ? document : undefined);
  5928. if (typeof doc === 'undefined') {
  5929. return null;
  5930. }
  5931. try {
  5932. return doc.activeElement || doc.body;
  5933. } catch (e) {
  5934. return doc.body;
  5935. }
  5936. }
  5937. /**
  5938. * Given any node return the first leaf node without children.
  5939. *
  5940. * @param {DOMElement|DOMTextNode} node
  5941. * @return {DOMElement|DOMTextNode}
  5942. */
  5943. function getLeafNode(node) {
  5944. while (node && node.firstChild) {
  5945. node = node.firstChild;
  5946. }
  5947. return node;
  5948. }
  5949. /**
  5950. * Get the next sibling within a container. This will walk up the
  5951. * DOM if a node's siblings have been exhausted.
  5952. *
  5953. * @param {DOMElement|DOMTextNode} node
  5954. * @return {?DOMElement|DOMTextNode}
  5955. */
  5956. function getSiblingNode(node) {
  5957. while (node) {
  5958. if (node.nextSibling) {
  5959. return node.nextSibling;
  5960. }
  5961. node = node.parentNode;
  5962. }
  5963. }
  5964. /**
  5965. * Get object describing the nodes which contain characters at offset.
  5966. *
  5967. * @param {DOMElement|DOMTextNode} root
  5968. * @param {number} offset
  5969. * @return {?object}
  5970. */
  5971. function getNodeForCharacterOffset(root, offset) {
  5972. var node = getLeafNode(root);
  5973. var nodeStart = 0;
  5974. var nodeEnd = 0;
  5975. while (node) {
  5976. if (node.nodeType === TEXT_NODE) {
  5977. nodeEnd = nodeStart + node.textContent.length;
  5978. if (nodeStart <= offset && nodeEnd >= offset) {
  5979. return {
  5980. node: node,
  5981. offset: offset - nodeStart
  5982. };
  5983. }
  5984. nodeStart = nodeEnd;
  5985. }
  5986. node = getLeafNode(getSiblingNode(node));
  5987. }
  5988. }
  5989. /**
  5990. * @param {DOMElement} outerNode
  5991. * @return {?object}
  5992. */
  5993. function getOffsets(outerNode) {
  5994. var ownerDocument = outerNode.ownerDocument;
  5995. var win = ownerDocument && ownerDocument.defaultView || window;
  5996. var selection = win.getSelection && win.getSelection();
  5997. if (!selection || selection.rangeCount === 0) {
  5998. return null;
  5999. }
  6000. var anchorNode = selection.anchorNode,
  6001. anchorOffset = selection.anchorOffset,
  6002. focusNode = selection.focusNode,
  6003. focusOffset = selection.focusOffset;
  6004. // In Firefox, anchorNode and focusNode can be "anonymous divs", e.g. the
  6005. // up/down buttons on an <input type="number">. Anonymous divs do not seem to
  6006. // expose properties, triggering a "Permission denied error" if any of its
  6007. // properties are accessed. The only seemingly possible way to avoid erroring
  6008. // is to access a property that typically works for non-anonymous divs and
  6009. // catch any error that may otherwise arise. See
  6010. // https://bugzilla.mozilla.org/show_bug.cgi?id=208427
  6011. try {
  6012. /* eslint-disable no-unused-expressions */
  6013. anchorNode.nodeType;
  6014. focusNode.nodeType;
  6015. /* eslint-enable no-unused-expressions */
  6016. } catch (e) {
  6017. return null;
  6018. }
  6019. return getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset);
  6020. }
  6021. /**
  6022. * Returns {start, end} where `start` is the character/codepoint index of
  6023. * (anchorNode, anchorOffset) within the textContent of `outerNode`, and
  6024. * `end` is the index of (focusNode, focusOffset).
  6025. *
  6026. * Returns null if you pass in garbage input but we should probably just crash.
  6027. *
  6028. * Exported only for testing.
  6029. */
  6030. function getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset) {
  6031. var length = 0;
  6032. var start = -1;
  6033. var end = -1;
  6034. var indexWithinAnchor = 0;
  6035. var indexWithinFocus = 0;
  6036. var node = outerNode;
  6037. var parentNode = null;
  6038. outer: while (true) {
  6039. var next = null;
  6040. while (true) {
  6041. if (node === anchorNode && (anchorOffset === 0 || node.nodeType === TEXT_NODE)) {
  6042. start = length + anchorOffset;
  6043. }
  6044. if (node === focusNode && (focusOffset === 0 || node.nodeType === TEXT_NODE)) {
  6045. end = length + focusOffset;
  6046. }
  6047. if (node.nodeType === TEXT_NODE) {
  6048. length += node.nodeValue.length;
  6049. }
  6050. if ((next = node.firstChild) === null) {
  6051. break;
  6052. }
  6053. // Moving from `node` to its first child `next`.
  6054. parentNode = node;
  6055. node = next;
  6056. }
  6057. while (true) {
  6058. if (node === outerNode) {
  6059. // If `outerNode` has children, this is always the second time visiting
  6060. // it. If it has no children, this is still the first loop, and the only
  6061. // valid selection is anchorNode and focusNode both equal to this node
  6062. // and both offsets 0, in which case we will have handled above.
  6063. break outer;
  6064. }
  6065. if (parentNode === anchorNode && ++indexWithinAnchor === anchorOffset) {
  6066. start = length;
  6067. }
  6068. if (parentNode === focusNode && ++indexWithinFocus === focusOffset) {
  6069. end = length;
  6070. }
  6071. if ((next = node.nextSibling) !== null) {
  6072. break;
  6073. }
  6074. node = parentNode;
  6075. parentNode = node.parentNode;
  6076. }
  6077. // Moving from `node` to its next sibling `next`.
  6078. node = next;
  6079. }
  6080. if (start === -1 || end === -1) {
  6081. // This should never happen. (Would happen if the anchor/focus nodes aren't
  6082. // actually inside the passed-in node.)
  6083. return null;
  6084. }
  6085. return {
  6086. start: start,
  6087. end: end
  6088. };
  6089. }
  6090. /**
  6091. * In modern non-IE browsers, we can support both forward and backward
  6092. * selections.
  6093. *
  6094. * Note: IE10+ supports the Selection object, but it does not support
  6095. * the `extend` method, which means that even in modern IE, it's not possible
  6096. * to programmatically create a backward selection. Thus, for all IE
  6097. * versions, we use the old IE API to create our selections.
  6098. *
  6099. * @param {DOMElement|DOMTextNode} node
  6100. * @param {object} offsets
  6101. */
  6102. function setOffsets(node, offsets) {
  6103. var doc = node.ownerDocument || document;
  6104. var win = doc && doc.defaultView || window;
  6105. // Edge fails with "Object expected" in some scenarios.
  6106. // (For instance: TinyMCE editor used in a list component that supports pasting to add more,
  6107. // fails when pasting 100+ items)
  6108. if (!win.getSelection) {
  6109. return;
  6110. }
  6111. var selection = win.getSelection();
  6112. var length = node.textContent.length;
  6113. var start = Math.min(offsets.start, length);
  6114. var end = offsets.end === undefined ? start : Math.min(offsets.end, length);
  6115. // IE 11 uses modern selection, but doesn't support the extend method.
  6116. // Flip backward selections, so we can set with a single range.
  6117. if (!selection.extend && start > end) {
  6118. var temp = end;
  6119. end = start;
  6120. start = temp;
  6121. }
  6122. var startMarker = getNodeForCharacterOffset(node, start);
  6123. var endMarker = getNodeForCharacterOffset(node, end);
  6124. if (startMarker && endMarker) {
  6125. if (selection.rangeCount === 1 && selection.anchorNode === startMarker.node && selection.anchorOffset === startMarker.offset && selection.focusNode === endMarker.node && selection.focusOffset === endMarker.offset) {
  6126. return;
  6127. }
  6128. var range = doc.createRange();
  6129. range.setStart(startMarker.node, startMarker.offset);
  6130. selection.removeAllRanges();
  6131. if (start > end) {
  6132. selection.addRange(range);
  6133. selection.extend(endMarker.node, endMarker.offset);
  6134. } else {
  6135. range.setEnd(endMarker.node, endMarker.offset);
  6136. selection.addRange(range);
  6137. }
  6138. }
  6139. }
  6140. function isTextNode(node) {
  6141. return node && node.nodeType === TEXT_NODE;
  6142. }
  6143. function containsNode(outerNode, innerNode) {
  6144. if (!outerNode || !innerNode) {
  6145. return false;
  6146. } else if (outerNode === innerNode) {
  6147. return true;
  6148. } else if (isTextNode(outerNode)) {
  6149. return false;
  6150. } else if (isTextNode(innerNode)) {
  6151. return containsNode(outerNode, innerNode.parentNode);
  6152. } else if ('contains' in outerNode) {
  6153. return outerNode.contains(innerNode);
  6154. } else if (outerNode.compareDocumentPosition) {
  6155. return !!(outerNode.compareDocumentPosition(innerNode) & 16);
  6156. } else {
  6157. return false;
  6158. }
  6159. }
  6160. function isInDocument(node) {
  6161. return node && node.ownerDocument && containsNode(node.ownerDocument.documentElement, node);
  6162. }
  6163. function isSameOriginFrame(iframe) {
  6164. try {
  6165. // Accessing the contentDocument of a HTMLIframeElement can cause the browser
  6166. // to throw, e.g. if it has a cross-origin src attribute.
  6167. // Safari will show an error in the console when the access results in "Blocked a frame with origin". e.g:
  6168. // iframe.contentDocument.defaultView;
  6169. // A safety way is to access one of the cross origin properties: Window or Location
  6170. // Which might result in "SecurityError" DOM Exception and it is compatible to Safari.
  6171. // https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl
  6172. return typeof iframe.contentWindow.location.href === 'string';
  6173. } catch (err) {
  6174. return false;
  6175. }
  6176. }
  6177. function getActiveElementDeep() {
  6178. var win = window;
  6179. var element = getActiveElement();
  6180. while (element instanceof win.HTMLIFrameElement) {
  6181. if (isSameOriginFrame(element)) {
  6182. win = element.contentWindow;
  6183. } else {
  6184. return element;
  6185. }
  6186. element = getActiveElement(win.document);
  6187. }
  6188. return element;
  6189. }
  6190. /**
  6191. * @ReactInputSelection: React input selection module. Based on Selection.js,
  6192. * but modified to be suitable for react and has a couple of bug fixes (doesn't
  6193. * assume buttons have range selections allowed).
  6194. * Input selection module for React.
  6195. */
  6196. /**
  6197. * @hasSelectionCapabilities: we get the element types that support selection
  6198. * from https://html.spec.whatwg.org/#do-not-apply, looking at `selectionStart`
  6199. * and `selectionEnd` rows.
  6200. */
  6201. function hasSelectionCapabilities(elem) {
  6202. var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
  6203. return nodeName && (nodeName === 'input' && (elem.type === 'text' || elem.type === 'search' || elem.type === 'tel' || elem.type === 'url' || elem.type === 'password') || nodeName === 'textarea' || elem.contentEditable === 'true');
  6204. }
  6205. function getSelectionInformation() {
  6206. var focusedElem = getActiveElementDeep();
  6207. return {
  6208. focusedElem: focusedElem,
  6209. selectionRange: hasSelectionCapabilities(focusedElem) ? getSelection$1(focusedElem) : null
  6210. };
  6211. }
  6212. /**
  6213. * @restoreSelection: If any selection information was potentially lost,
  6214. * restore it. This is useful when performing operations that could remove dom
  6215. * nodes and place them back in, resulting in focus being lost.
  6216. */
  6217. function restoreSelection(priorSelectionInformation) {
  6218. var curFocusedElem = getActiveElementDeep();
  6219. var priorFocusedElem = priorSelectionInformation.focusedElem;
  6220. var priorSelectionRange = priorSelectionInformation.selectionRange;
  6221. if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) {
  6222. if (priorSelectionRange !== null && hasSelectionCapabilities(priorFocusedElem)) {
  6223. setSelection(priorFocusedElem, priorSelectionRange);
  6224. }
  6225. // Focusing a node can change the scroll position, which is undesirable
  6226. var ancestors = [];
  6227. var ancestor = priorFocusedElem;
  6228. while (ancestor = ancestor.parentNode) {
  6229. if (ancestor.nodeType === ELEMENT_NODE) {
  6230. ancestors.push({
  6231. element: ancestor,
  6232. left: ancestor.scrollLeft,
  6233. top: ancestor.scrollTop
  6234. });
  6235. }
  6236. }
  6237. if (typeof priorFocusedElem.focus === 'function') {
  6238. priorFocusedElem.focus();
  6239. }
  6240. for (var i = 0; i < ancestors.length; i++) {
  6241. var info = ancestors[i];
  6242. info.element.scrollLeft = info.left;
  6243. info.element.scrollTop = info.top;
  6244. }
  6245. }
  6246. }
  6247. /**
  6248. * @getSelection: Gets the selection bounds of a focused textarea, input or
  6249. * contentEditable node.
  6250. * -@input: Look up selection bounds of this input
  6251. * -@return {start: selectionStart, end: selectionEnd}
  6252. */
  6253. function getSelection$1(input) {
  6254. var selection = void 0;
  6255. if ('selectionStart' in input) {
  6256. // Modern browser with input or textarea.
  6257. selection = {
  6258. start: input.selectionStart,
  6259. end: input.selectionEnd
  6260. };
  6261. } else {
  6262. // Content editable or old IE textarea.
  6263. selection = getOffsets(input);
  6264. }
  6265. return selection || { start: 0, end: 0 };
  6266. }
  6267. /**
  6268. * @setSelection: Sets the selection bounds of a textarea or input and focuses
  6269. * the input.
  6270. * -@input Set selection bounds of this input or textarea
  6271. * -@offsets Object of same form that is returned from get*
  6272. */
  6273. function setSelection(input, offsets) {
  6274. var start = offsets.start,
  6275. end = offsets.end;
  6276. if (end === undefined) {
  6277. end = start;
  6278. }
  6279. if ('selectionStart' in input) {
  6280. input.selectionStart = start;
  6281. input.selectionEnd = Math.min(end, input.value.length);
  6282. } else {
  6283. setOffsets(input, offsets);
  6284. }
  6285. }
  6286. var skipSelectionChangeEvent = canUseDOM && 'documentMode' in document && document.documentMode <= 11;
  6287. var eventTypes$3 = {
  6288. select: {
  6289. phasedRegistrationNames: {
  6290. bubbled: 'onSelect',
  6291. captured: 'onSelectCapture'
  6292. },
  6293. 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]
  6294. }
  6295. };
  6296. var activeElement$1 = null;
  6297. var activeElementInst$1 = null;
  6298. var lastSelection = null;
  6299. var mouseDown = false;
  6300. /**
  6301. * Get an object which is a unique representation of the current selection.
  6302. *
  6303. * The return value will not be consistent across nodes or browsers, but
  6304. * two identical selections on the same node will return identical objects.
  6305. *
  6306. * @param {DOMElement} node
  6307. * @return {object}
  6308. */
  6309. function getSelection(node) {
  6310. if ('selectionStart' in node && hasSelectionCapabilities(node)) {
  6311. return {
  6312. start: node.selectionStart,
  6313. end: node.selectionEnd
  6314. };
  6315. } else {
  6316. var win = node.ownerDocument && node.ownerDocument.defaultView || window;
  6317. var selection = win.getSelection();
  6318. return {
  6319. anchorNode: selection.anchorNode,
  6320. anchorOffset: selection.anchorOffset,
  6321. focusNode: selection.focusNode,
  6322. focusOffset: selection.focusOffset
  6323. };
  6324. }
  6325. }
  6326. /**
  6327. * Get document associated with the event target.
  6328. *
  6329. * @param {object} nativeEventTarget
  6330. * @return {Document}
  6331. */
  6332. function getEventTargetDocument(eventTarget) {
  6333. return eventTarget.window === eventTarget ? eventTarget.document : eventTarget.nodeType === DOCUMENT_NODE ? eventTarget : eventTarget.ownerDocument;
  6334. }
  6335. /**
  6336. * Poll selection to see whether it's changed.
  6337. *
  6338. * @param {object} nativeEvent
  6339. * @param {object} nativeEventTarget
  6340. * @return {?SyntheticEvent}
  6341. */
  6342. function constructSelectEvent(nativeEvent, nativeEventTarget) {
  6343. // Ensure we have the right element, and that the user is not dragging a
  6344. // selection (this matches native `select` event behavior). In HTML5, select
  6345. // fires only on input and textarea thus if there's no focused element we
  6346. // won't dispatch.
  6347. var doc = getEventTargetDocument(nativeEventTarget);
  6348. if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement(doc)) {
  6349. return null;
  6350. }
  6351. // Only fire when selection has actually changed.
  6352. var currentSelection = getSelection(activeElement$1);
  6353. if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
  6354. lastSelection = currentSelection;
  6355. var syntheticEvent = SyntheticEvent.getPooled(eventTypes$3.select, activeElementInst$1, nativeEvent, nativeEventTarget);
  6356. syntheticEvent.type = 'select';
  6357. syntheticEvent.target = activeElement$1;
  6358. accumulateTwoPhaseDispatches(syntheticEvent);
  6359. return syntheticEvent;
  6360. }
  6361. return null;
  6362. }
  6363. /**
  6364. * This plugin creates an `onSelect` event that normalizes select events
  6365. * across form elements.
  6366. *
  6367. * Supported elements are:
  6368. * - input (see `isTextInputElement`)
  6369. * - textarea
  6370. * - contentEditable
  6371. *
  6372. * This differs from native browser implementations in the following ways:
  6373. * - Fires on contentEditable fields as well as inputs.
  6374. * - Fires for collapsed selection.
  6375. * - Fires after user input.
  6376. */
  6377. var SelectEventPlugin = {
  6378. eventTypes: eventTypes$3,
  6379. extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
  6380. var doc = getEventTargetDocument(nativeEventTarget);
  6381. // Track whether all listeners exists for this plugin. If none exist, we do
  6382. // not extract events. See #3639.
  6383. if (!doc || !isListeningToAllDependencies('onSelect', doc)) {
  6384. return null;
  6385. }
  6386. var targetNode = targetInst ? getNodeFromInstance$1(targetInst) : window;
  6387. switch (topLevelType) {
  6388. // Track the input node that has focus.
  6389. case TOP_FOCUS:
  6390. if (isTextInputElement(targetNode) || targetNode.contentEditable === 'true') {
  6391. activeElement$1 = targetNode;
  6392. activeElementInst$1 = targetInst;
  6393. lastSelection = null;
  6394. }
  6395. break;
  6396. case TOP_BLUR:
  6397. activeElement$1 = null;
  6398. activeElementInst$1 = null;
  6399. lastSelection = null;
  6400. break;
  6401. // Don't fire the event while the user is dragging. This matches the
  6402. // semantics of the native select event.
  6403. case TOP_MOUSE_DOWN:
  6404. mouseDown = true;
  6405. break;
  6406. case TOP_CONTEXT_MENU:
  6407. case TOP_MOUSE_UP:
  6408. case TOP_DRAG_END:
  6409. mouseDown = false;
  6410. return constructSelectEvent(nativeEvent, nativeEventTarget);
  6411. // Chrome and IE fire non-standard event when selection is changed (and
  6412. // sometimes when it hasn't). IE's event fires out of order with respect
  6413. // to key and input events on deletion, so we discard it.
  6414. //
  6415. // Firefox doesn't support selectionchange, so check selection status
  6416. // after each key entry. The selection changes after keydown and before
  6417. // keyup, but we check on keydown as well in the case of holding down a
  6418. // key, when multiple keydown events are fired but only one keyup is.
  6419. // This is also our approach for IE handling, for the reason above.
  6420. case TOP_SELECTION_CHANGE:
  6421. if (skipSelectionChangeEvent) {
  6422. break;
  6423. }
  6424. // falls through
  6425. case TOP_KEY_DOWN:
  6426. case TOP_KEY_UP:
  6427. return constructSelectEvent(nativeEvent, nativeEventTarget);
  6428. }
  6429. return null;
  6430. }
  6431. };
  6432. /**
  6433. * Inject modules for resolving DOM hierarchy and plugin ordering.
  6434. */
  6435. injection.injectEventPluginOrder(DOMEventPluginOrder);
  6436. setComponentTree(getFiberCurrentPropsFromNode$1, getInstanceFromNode$1, getNodeFromInstance$1);
  6437. /**
  6438. * Some important event plugins included by default (without having to require
  6439. * them).
  6440. */
  6441. injection.injectEventPluginsByName({
  6442. SimpleEventPlugin: SimpleEventPlugin,
  6443. EnterLeaveEventPlugin: EnterLeaveEventPlugin,
  6444. ChangeEventPlugin: ChangeEventPlugin,
  6445. SelectEventPlugin: SelectEventPlugin,
  6446. BeforeInputEventPlugin: BeforeInputEventPlugin
  6447. });
  6448. function endsWith(subject, search) {
  6449. var length = subject.length;
  6450. return subject.substring(length - search.length, length) === search;
  6451. }
  6452. var didWarnSelectedSetOnOption = false;
  6453. var didWarnInvalidChild = false;
  6454. function flattenChildren(children) {
  6455. var content = '';
  6456. // Flatten children. We'll warn if they are invalid
  6457. // during validateProps() which runs for hydration too.
  6458. // Note that this would throw on non-element objects.
  6459. // Elements are stringified (which is normally irrelevant
  6460. // but matters for <fbt>).
  6461. React.Children.forEach(children, function (child) {
  6462. if (child == null) {
  6463. return;
  6464. }
  6465. content += child;
  6466. // Note: we don't warn about invalid children here.
  6467. // Instead, this is done separately below so that
  6468. // it happens during the hydration codepath too.
  6469. });
  6470. return content;
  6471. }
  6472. /**
  6473. * Implements an <option> host component that warns when `selected` is set.
  6474. */
  6475. function validateProps(element, props) {
  6476. {
  6477. // This mirrors the codepath above, but runs for hydration too.
  6478. // Warn about invalid children here so that client and hydration are consistent.
  6479. // TODO: this seems like it could cause a DEV-only throw for hydration
  6480. // if children contains a non-element object. We should try to avoid that.
  6481. if (typeof props.children === 'object' && props.children !== null) {
  6482. React.Children.forEach(props.children, function (child) {
  6483. if (child == null) {
  6484. return;
  6485. }
  6486. if (typeof child === 'string' || typeof child === 'number') {
  6487. return;
  6488. }
  6489. if (typeof child.type !== 'string') {
  6490. return;
  6491. }
  6492. if (!didWarnInvalidChild) {
  6493. didWarnInvalidChild = true;
  6494. warning$1(false, 'Only strings and numbers are supported as <option> children.');
  6495. }
  6496. });
  6497. }
  6498. // TODO: Remove support for `selected` in <option>.
  6499. if (props.selected != null && !didWarnSelectedSetOnOption) {
  6500. warning$1(false, 'Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.');
  6501. didWarnSelectedSetOnOption = true;
  6502. }
  6503. }
  6504. }
  6505. function postMountWrapper$1(element, props) {
  6506. // value="" should make a value attribute (#6219)
  6507. if (props.value != null) {
  6508. element.setAttribute('value', toString(getToStringValue(props.value)));
  6509. }
  6510. }
  6511. function getHostProps$1(element, props) {
  6512. var hostProps = _assign({ children: undefined }, props);
  6513. var content = flattenChildren(props.children);
  6514. if (content) {
  6515. hostProps.children = content;
  6516. }
  6517. return hostProps;
  6518. }
  6519. // TODO: direct imports like some-package/src/* are bad. Fix me.
  6520. var didWarnValueDefaultValue$1 = void 0;
  6521. {
  6522. didWarnValueDefaultValue$1 = false;
  6523. }
  6524. function getDeclarationErrorAddendum() {
  6525. var ownerName = getCurrentFiberOwnerNameInDevOrNull();
  6526. if (ownerName) {
  6527. return '\n\nCheck the render method of `' + ownerName + '`.';
  6528. }
  6529. return '';
  6530. }
  6531. var valuePropNames = ['value', 'defaultValue'];
  6532. /**
  6533. * Validation function for `value` and `defaultValue`.
  6534. */
  6535. function checkSelectPropTypes(props) {
  6536. ReactControlledValuePropTypes.checkPropTypes('select', props);
  6537. for (var i = 0; i < valuePropNames.length; i++) {
  6538. var propName = valuePropNames[i];
  6539. if (props[propName] == null) {
  6540. continue;
  6541. }
  6542. var isArray = Array.isArray(props[propName]);
  6543. if (props.multiple && !isArray) {
  6544. warning$1(false, 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum());
  6545. } else if (!props.multiple && isArray) {
  6546. warning$1(false, 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum());
  6547. }
  6548. }
  6549. }
  6550. function updateOptions(node, multiple, propValue, setDefaultSelected) {
  6551. var options = node.options;
  6552. if (multiple) {
  6553. var selectedValues = propValue;
  6554. var selectedValue = {};
  6555. for (var i = 0; i < selectedValues.length; i++) {
  6556. // Prefix to avoid chaos with special keys.
  6557. selectedValue['$' + selectedValues[i]] = true;
  6558. }
  6559. for (var _i = 0; _i < options.length; _i++) {
  6560. var selected = selectedValue.hasOwnProperty('$' + options[_i].value);
  6561. if (options[_i].selected !== selected) {
  6562. options[_i].selected = selected;
  6563. }
  6564. if (selected && setDefaultSelected) {
  6565. options[_i].defaultSelected = true;
  6566. }
  6567. }
  6568. } else {
  6569. // Do not set `select.value` as exact behavior isn't consistent across all
  6570. // browsers for all cases.
  6571. var _selectedValue = toString(getToStringValue(propValue));
  6572. var defaultSelected = null;
  6573. for (var _i2 = 0; _i2 < options.length; _i2++) {
  6574. if (options[_i2].value === _selectedValue) {
  6575. options[_i2].selected = true;
  6576. if (setDefaultSelected) {
  6577. options[_i2].defaultSelected = true;
  6578. }
  6579. return;
  6580. }
  6581. if (defaultSelected === null && !options[_i2].disabled) {
  6582. defaultSelected = options[_i2];
  6583. }
  6584. }
  6585. if (defaultSelected !== null) {
  6586. defaultSelected.selected = true;
  6587. }
  6588. }
  6589. }
  6590. /**
  6591. * Implements a <select> host component that allows optionally setting the
  6592. * props `value` and `defaultValue`. If `multiple` is false, the prop must be a
  6593. * stringable. If `multiple` is true, the prop must be an array of stringables.
  6594. *
  6595. * If `value` is not supplied (or null/undefined), user actions that change the
  6596. * selected option will trigger updates to the rendered options.
  6597. *
  6598. * If it is supplied (and not null/undefined), the rendered options will not
  6599. * update in response to user actions. Instead, the `value` prop must change in
  6600. * order for the rendered options to update.
  6601. *
  6602. * If `defaultValue` is provided, any options with the supplied values will be
  6603. * selected.
  6604. */
  6605. function getHostProps$2(element, props) {
  6606. return _assign({}, props, {
  6607. value: undefined
  6608. });
  6609. }
  6610. function initWrapperState$1(element, props) {
  6611. var node = element;
  6612. {
  6613. checkSelectPropTypes(props);
  6614. }
  6615. node._wrapperState = {
  6616. wasMultiple: !!props.multiple
  6617. };
  6618. {
  6619. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue$1) {
  6620. 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');
  6621. didWarnValueDefaultValue$1 = true;
  6622. }
  6623. }
  6624. }
  6625. function postMountWrapper$2(element, props) {
  6626. var node = element;
  6627. node.multiple = !!props.multiple;
  6628. var value = props.value;
  6629. if (value != null) {
  6630. updateOptions(node, !!props.multiple, value, false);
  6631. } else if (props.defaultValue != null) {
  6632. updateOptions(node, !!props.multiple, props.defaultValue, true);
  6633. }
  6634. }
  6635. function postUpdateWrapper(element, props) {
  6636. var node = element;
  6637. var wasMultiple = node._wrapperState.wasMultiple;
  6638. node._wrapperState.wasMultiple = !!props.multiple;
  6639. var value = props.value;
  6640. if (value != null) {
  6641. updateOptions(node, !!props.multiple, value, false);
  6642. } else if (wasMultiple !== !!props.multiple) {
  6643. // For simplicity, reapply `defaultValue` if `multiple` is toggled.
  6644. if (props.defaultValue != null) {
  6645. updateOptions(node, !!props.multiple, props.defaultValue, true);
  6646. } else {
  6647. // Revert the select back to its default unselected state.
  6648. updateOptions(node, !!props.multiple, props.multiple ? [] : '', false);
  6649. }
  6650. }
  6651. }
  6652. function restoreControlledState$2(element, props) {
  6653. var node = element;
  6654. var value = props.value;
  6655. if (value != null) {
  6656. updateOptions(node, !!props.multiple, value, false);
  6657. }
  6658. }
  6659. var didWarnValDefaultVal = false;
  6660. /**
  6661. * Implements a <textarea> host component that allows setting `value`, and
  6662. * `defaultValue`. This differs from the traditional DOM API because value is
  6663. * usually set as PCDATA children.
  6664. *
  6665. * If `value` is not supplied (or null/undefined), user actions that affect the
  6666. * value will trigger updates to the element.
  6667. *
  6668. * If `value` is supplied (and not null/undefined), the rendered element will
  6669. * not trigger updates to the element. Instead, the `value` prop must change in
  6670. * order for the rendered element to be updated.
  6671. *
  6672. * The rendered element will be initialized with an empty value, the prop
  6673. * `defaultValue` if specified, or the children content (deprecated).
  6674. */
  6675. function getHostProps$3(element, props) {
  6676. var node = element;
  6677. (function () {
  6678. if (!(props.dangerouslySetInnerHTML == null)) {
  6679. {
  6680. throw ReactError(Error('`dangerouslySetInnerHTML` does not make sense on <textarea>.'));
  6681. }
  6682. }
  6683. })();
  6684. // Always set children to the same thing. In IE9, the selection range will
  6685. // get reset if `textContent` is mutated. We could add a check in setTextContent
  6686. // to only set the value if/when the value differs from the node value (which would
  6687. // completely solve this IE9 bug), but Sebastian+Sophie seemed to like this
  6688. // solution. The value can be a boolean or object so that's why it's forced
  6689. // to be a string.
  6690. var hostProps = _assign({}, props, {
  6691. value: undefined,
  6692. defaultValue: undefined,
  6693. children: toString(node._wrapperState.initialValue)
  6694. });
  6695. return hostProps;
  6696. }
  6697. function initWrapperState$2(element, props) {
  6698. var node = element;
  6699. {
  6700. ReactControlledValuePropTypes.checkPropTypes('textarea', props);
  6701. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) {
  6702. 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');
  6703. didWarnValDefaultVal = true;
  6704. }
  6705. }
  6706. var initialValue = props.value;
  6707. // Only bother fetching default value if we're going to use it
  6708. if (initialValue == null) {
  6709. var defaultValue = props.defaultValue;
  6710. // TODO (yungsters): Remove support for children content in <textarea>.
  6711. var children = props.children;
  6712. if (children != null) {
  6713. {
  6714. warning$1(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.');
  6715. }
  6716. (function () {
  6717. if (!(defaultValue == null)) {
  6718. {
  6719. throw ReactError(Error('If you supply `defaultValue` on a <textarea>, do not pass children.'));
  6720. }
  6721. }
  6722. })();
  6723. if (Array.isArray(children)) {
  6724. (function () {
  6725. if (!(children.length <= 1)) {
  6726. {
  6727. throw ReactError(Error('<textarea> can only have at most one child.'));
  6728. }
  6729. }
  6730. })();
  6731. children = children[0];
  6732. }
  6733. defaultValue = children;
  6734. }
  6735. if (defaultValue == null) {
  6736. defaultValue = '';
  6737. }
  6738. initialValue = defaultValue;
  6739. }
  6740. node._wrapperState = {
  6741. initialValue: getToStringValue(initialValue)
  6742. };
  6743. }
  6744. function updateWrapper$1(element, props) {
  6745. var node = element;
  6746. var value = getToStringValue(props.value);
  6747. var defaultValue = getToStringValue(props.defaultValue);
  6748. if (value != null) {
  6749. // Cast `value` to a string to ensure the value is set correctly. While
  6750. // browsers typically do this as necessary, jsdom doesn't.
  6751. var newValue = toString(value);
  6752. // To avoid side effects (such as losing text selection), only set value if changed
  6753. if (newValue !== node.value) {
  6754. node.value = newValue;
  6755. }
  6756. if (props.defaultValue == null && node.defaultValue !== newValue) {
  6757. node.defaultValue = newValue;
  6758. }
  6759. }
  6760. if (defaultValue != null) {
  6761. node.defaultValue = toString(defaultValue);
  6762. }
  6763. }
  6764. function postMountWrapper$3(element, props) {
  6765. var node = element;
  6766. // This is in postMount because we need access to the DOM node, which is not
  6767. // available until after the component has mounted.
  6768. var textContent = node.textContent;
  6769. // Only set node.value if textContent is equal to the expected
  6770. // initial value. In IE10/IE11 there is a bug where the placeholder attribute
  6771. // will populate textContent as well.
  6772. // https://developer.microsoft.com/microsoft-edge/platform/issues/101525/
  6773. if (textContent === node._wrapperState.initialValue) {
  6774. node.value = textContent;
  6775. }
  6776. }
  6777. function restoreControlledState$3(element, props) {
  6778. // DOM component is still mounted; update
  6779. updateWrapper$1(element, props);
  6780. }
  6781. var HTML_NAMESPACE$1 = 'http://www.w3.org/1999/xhtml';
  6782. var MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
  6783. var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
  6784. var Namespaces = {
  6785. html: HTML_NAMESPACE$1,
  6786. mathml: MATH_NAMESPACE,
  6787. svg: SVG_NAMESPACE
  6788. };
  6789. // Assumes there is no parent namespace.
  6790. function getIntrinsicNamespace(type) {
  6791. switch (type) {
  6792. case 'svg':
  6793. return SVG_NAMESPACE;
  6794. case 'math':
  6795. return MATH_NAMESPACE;
  6796. default:
  6797. return HTML_NAMESPACE$1;
  6798. }
  6799. }
  6800. function getChildNamespace(parentNamespace, type) {
  6801. if (parentNamespace == null || parentNamespace === HTML_NAMESPACE$1) {
  6802. // No (or default) parent namespace: potential entry point.
  6803. return getIntrinsicNamespace(type);
  6804. }
  6805. if (parentNamespace === SVG_NAMESPACE && type === 'foreignObject') {
  6806. // We're leaving SVG.
  6807. return HTML_NAMESPACE$1;
  6808. }
  6809. // By default, pass namespace below.
  6810. return parentNamespace;
  6811. }
  6812. /* globals MSApp */
  6813. /**
  6814. * Create a function which has 'unsafe' privileges (required by windows8 apps)
  6815. */
  6816. var createMicrosoftUnsafeLocalFunction = function (func) {
  6817. if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
  6818. return function (arg0, arg1, arg2, arg3) {
  6819. MSApp.execUnsafeLocalFunction(function () {
  6820. return func(arg0, arg1, arg2, arg3);
  6821. });
  6822. };
  6823. } else {
  6824. return func;
  6825. }
  6826. };
  6827. // SVG temp container for IE lacking innerHTML
  6828. var reusableSVGContainer = void 0;
  6829. /**
  6830. * Set the innerHTML property of a node
  6831. *
  6832. * @param {DOMElement} node
  6833. * @param {string} html
  6834. * @internal
  6835. */
  6836. var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) {
  6837. // IE does not have innerHTML for SVG nodes, so instead we inject the
  6838. // new markup in a temp node and then move the child nodes across into
  6839. // the target node
  6840. if (node.namespaceURI === Namespaces.svg && !('innerHTML' in node)) {
  6841. reusableSVGContainer = reusableSVGContainer || document.createElement('div');
  6842. reusableSVGContainer.innerHTML = '<svg>' + html + '</svg>';
  6843. var svgNode = reusableSVGContainer.firstChild;
  6844. while (node.firstChild) {
  6845. node.removeChild(node.firstChild);
  6846. }
  6847. while (svgNode.firstChild) {
  6848. node.appendChild(svgNode.firstChild);
  6849. }
  6850. } else {
  6851. node.innerHTML = html;
  6852. }
  6853. });
  6854. /**
  6855. * Set the textContent property of a node. For text updates, it's faster
  6856. * to set the `nodeValue` of the Text node directly instead of using
  6857. * `.textContent` which will remove the existing node and create a new one.
  6858. *
  6859. * @param {DOMElement} node
  6860. * @param {string} text
  6861. * @internal
  6862. */
  6863. var setTextContent = function (node, text) {
  6864. if (text) {
  6865. var firstChild = node.firstChild;
  6866. if (firstChild && firstChild === node.lastChild && firstChild.nodeType === TEXT_NODE) {
  6867. firstChild.nodeValue = text;
  6868. return;
  6869. }
  6870. }
  6871. node.textContent = text;
  6872. };
  6873. // List derived from Gecko source code:
  6874. // https://github.com/mozilla/gecko-dev/blob/4e638efc71/layout/style/test/property_database.js
  6875. var shorthandToLonghand = {
  6876. animation: ['animationDelay', 'animationDirection', 'animationDuration', 'animationFillMode', 'animationIterationCount', 'animationName', 'animationPlayState', 'animationTimingFunction'],
  6877. background: ['backgroundAttachment', 'backgroundClip', 'backgroundColor', 'backgroundImage', 'backgroundOrigin', 'backgroundPositionX', 'backgroundPositionY', 'backgroundRepeat', 'backgroundSize'],
  6878. backgroundPosition: ['backgroundPositionX', 'backgroundPositionY'],
  6879. border: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth', 'borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth', 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth', 'borderRightColor', 'borderRightStyle', 'borderRightWidth', 'borderTopColor', 'borderTopStyle', 'borderTopWidth'],
  6880. borderBlockEnd: ['borderBlockEndColor', 'borderBlockEndStyle', 'borderBlockEndWidth'],
  6881. borderBlockStart: ['borderBlockStartColor', 'borderBlockStartStyle', 'borderBlockStartWidth'],
  6882. borderBottom: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth'],
  6883. borderColor: ['borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor'],
  6884. borderImage: ['borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth'],
  6885. borderInlineEnd: ['borderInlineEndColor', 'borderInlineEndStyle', 'borderInlineEndWidth'],
  6886. borderInlineStart: ['borderInlineStartColor', 'borderInlineStartStyle', 'borderInlineStartWidth'],
  6887. borderLeft: ['borderLeftColor', 'borderLeftStyle', 'borderLeftWidth'],
  6888. borderRadius: ['borderBottomLeftRadius', 'borderBottomRightRadius', 'borderTopLeftRadius', 'borderTopRightRadius'],
  6889. borderRight: ['borderRightColor', 'borderRightStyle', 'borderRightWidth'],
  6890. borderStyle: ['borderBottomStyle', 'borderLeftStyle', 'borderRightStyle', 'borderTopStyle'],
  6891. borderTop: ['borderTopColor', 'borderTopStyle', 'borderTopWidth'],
  6892. borderWidth: ['borderBottomWidth', 'borderLeftWidth', 'borderRightWidth', 'borderTopWidth'],
  6893. columnRule: ['columnRuleColor', 'columnRuleStyle', 'columnRuleWidth'],
  6894. columns: ['columnCount', 'columnWidth'],
  6895. flex: ['flexBasis', 'flexGrow', 'flexShrink'],
  6896. flexFlow: ['flexDirection', 'flexWrap'],
  6897. font: ['fontFamily', 'fontFeatureSettings', 'fontKerning', 'fontLanguageOverride', 'fontSize', 'fontSizeAdjust', 'fontStretch', 'fontStyle', 'fontVariant', 'fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition', 'fontWeight', 'lineHeight'],
  6898. fontVariant: ['fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition'],
  6899. gap: ['columnGap', 'rowGap'],
  6900. grid: ['gridAutoColumns', 'gridAutoFlow', 'gridAutoRows', 'gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'],
  6901. gridArea: ['gridColumnEnd', 'gridColumnStart', 'gridRowEnd', 'gridRowStart'],
  6902. gridColumn: ['gridColumnEnd', 'gridColumnStart'],
  6903. gridColumnGap: ['columnGap'],
  6904. gridGap: ['columnGap', 'rowGap'],
  6905. gridRow: ['gridRowEnd', 'gridRowStart'],
  6906. gridRowGap: ['rowGap'],
  6907. gridTemplate: ['gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'],
  6908. listStyle: ['listStyleImage', 'listStylePosition', 'listStyleType'],
  6909. margin: ['marginBottom', 'marginLeft', 'marginRight', 'marginTop'],
  6910. marker: ['markerEnd', 'markerMid', 'markerStart'],
  6911. mask: ['maskClip', 'maskComposite', 'maskImage', 'maskMode', 'maskOrigin', 'maskPositionX', 'maskPositionY', 'maskRepeat', 'maskSize'],
  6912. maskPosition: ['maskPositionX', 'maskPositionY'],
  6913. outline: ['outlineColor', 'outlineStyle', 'outlineWidth'],
  6914. overflow: ['overflowX', 'overflowY'],
  6915. padding: ['paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop'],
  6916. placeContent: ['alignContent', 'justifyContent'],
  6917. placeItems: ['alignItems', 'justifyItems'],
  6918. placeSelf: ['alignSelf', 'justifySelf'],
  6919. textDecoration: ['textDecorationColor', 'textDecorationLine', 'textDecorationStyle'],
  6920. textEmphasis: ['textEmphasisColor', 'textEmphasisStyle'],
  6921. transition: ['transitionDelay', 'transitionDuration', 'transitionProperty', 'transitionTimingFunction'],
  6922. wordWrap: ['overflowWrap']
  6923. };
  6924. /**
  6925. * CSS properties which accept numbers but are not in units of "px".
  6926. */
  6927. var isUnitlessNumber = {
  6928. animationIterationCount: true,
  6929. borderImageOutset: true,
  6930. borderImageSlice: true,
  6931. borderImageWidth: true,
  6932. boxFlex: true,
  6933. boxFlexGroup: true,
  6934. boxOrdinalGroup: true,
  6935. columnCount: true,
  6936. columns: true,
  6937. flex: true,
  6938. flexGrow: true,
  6939. flexPositive: true,
  6940. flexShrink: true,
  6941. flexNegative: true,
  6942. flexOrder: true,
  6943. gridArea: true,
  6944. gridRow: true,
  6945. gridRowEnd: true,
  6946. gridRowSpan: true,
  6947. gridRowStart: true,
  6948. gridColumn: true,
  6949. gridColumnEnd: true,
  6950. gridColumnSpan: true,
  6951. gridColumnStart: true,
  6952. fontWeight: true,
  6953. lineClamp: true,
  6954. lineHeight: true,
  6955. opacity: true,
  6956. order: true,
  6957. orphans: true,
  6958. tabSize: true,
  6959. widows: true,
  6960. zIndex: true,
  6961. zoom: true,
  6962. // SVG-related properties
  6963. fillOpacity: true,
  6964. floodOpacity: true,
  6965. stopOpacity: true,
  6966. strokeDasharray: true,
  6967. strokeDashoffset: true,
  6968. strokeMiterlimit: true,
  6969. strokeOpacity: true,
  6970. strokeWidth: true
  6971. };
  6972. /**
  6973. * @param {string} prefix vendor-specific prefix, eg: Webkit
  6974. * @param {string} key style name, eg: transitionDuration
  6975. * @return {string} style name prefixed with `prefix`, properly camelCased, eg:
  6976. * WebkitTransitionDuration
  6977. */
  6978. function prefixKey(prefix, key) {
  6979. return prefix + key.charAt(0).toUpperCase() + key.substring(1);
  6980. }
  6981. /**
  6982. * Support style names that may come passed in prefixed by adding permutations
  6983. * of vendor prefixes.
  6984. */
  6985. var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
  6986. // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
  6987. // infinite loop, because it iterates over the newly added props too.
  6988. Object.keys(isUnitlessNumber).forEach(function (prop) {
  6989. prefixes.forEach(function (prefix) {
  6990. isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
  6991. });
  6992. });
  6993. /**
  6994. * Convert a value into the proper css writable value. The style name `name`
  6995. * should be logical (no hyphens), as specified
  6996. * in `CSSProperty.isUnitlessNumber`.
  6997. *
  6998. * @param {string} name CSS property name such as `topMargin`.
  6999. * @param {*} value CSS property value such as `10px`.
  7000. * @return {string} Normalized style value with dimensions applied.
  7001. */
  7002. function dangerousStyleValue(name, value, isCustomProperty) {
  7003. // Note that we've removed escapeTextForBrowser() calls here since the
  7004. // whole string will be escaped when the attribute is injected into
  7005. // the markup. If you provide unsafe user data here they can inject
  7006. // arbitrary CSS which may be problematic (I couldn't repro this):
  7007. // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
  7008. // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
  7009. // This is not an XSS hole but instead a potential CSS injection issue
  7010. // which has lead to a greater discussion about how we're going to
  7011. // trust URLs moving forward. See #2115901
  7012. var isEmpty = value == null || typeof value === 'boolean' || value === '';
  7013. if (isEmpty) {
  7014. return '';
  7015. }
  7016. if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) {
  7017. return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers
  7018. }
  7019. return ('' + value).trim();
  7020. }
  7021. var uppercasePattern = /([A-Z])/g;
  7022. var msPattern = /^ms-/;
  7023. /**
  7024. * Hyphenates a camelcased CSS property name, for example:
  7025. *
  7026. * > hyphenateStyleName('backgroundColor')
  7027. * < "background-color"
  7028. * > hyphenateStyleName('MozTransition')
  7029. * < "-moz-transition"
  7030. * > hyphenateStyleName('msTransition')
  7031. * < "-ms-transition"
  7032. *
  7033. * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
  7034. * is converted to `-ms-`.
  7035. */
  7036. function hyphenateStyleName(name) {
  7037. return name.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern, '-ms-');
  7038. }
  7039. var warnValidStyle = function () {};
  7040. {
  7041. // 'msTransform' is correct, but the other prefixes should be capitalized
  7042. var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
  7043. var msPattern$1 = /^-ms-/;
  7044. var hyphenPattern = /-(.)/g;
  7045. // style values shouldn't contain a semicolon
  7046. var badStyleValueWithSemicolonPattern = /;\s*$/;
  7047. var warnedStyleNames = {};
  7048. var warnedStyleValues = {};
  7049. var warnedForNaNValue = false;
  7050. var warnedForInfinityValue = false;
  7051. var camelize = function (string) {
  7052. return string.replace(hyphenPattern, function (_, character) {
  7053. return character.toUpperCase();
  7054. });
  7055. };
  7056. var warnHyphenatedStyleName = function (name) {
  7057. if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
  7058. return;
  7059. }
  7060. warnedStyleNames[name] = true;
  7061. warning$1(false, 'Unsupported style property %s. Did you mean %s?', name,
  7062. // As Andi Smith suggests
  7063. // (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
  7064. // is converted to lowercase `ms`.
  7065. camelize(name.replace(msPattern$1, 'ms-')));
  7066. };
  7067. var warnBadVendoredStyleName = function (name) {
  7068. if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
  7069. return;
  7070. }
  7071. warnedStyleNames[name] = true;
  7072. warning$1(false, 'Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1));
  7073. };
  7074. var warnStyleValueWithSemicolon = function (name, value) {
  7075. if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
  7076. return;
  7077. }
  7078. warnedStyleValues[value] = true;
  7079. warning$1(false, "Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, ''));
  7080. };
  7081. var warnStyleValueIsNaN = function (name, value) {
  7082. if (warnedForNaNValue) {
  7083. return;
  7084. }
  7085. warnedForNaNValue = true;
  7086. warning$1(false, '`NaN` is an invalid value for the `%s` css style property.', name);
  7087. };
  7088. var warnStyleValueIsInfinity = function (name, value) {
  7089. if (warnedForInfinityValue) {
  7090. return;
  7091. }
  7092. warnedForInfinityValue = true;
  7093. warning$1(false, '`Infinity` is an invalid value for the `%s` css style property.', name);
  7094. };
  7095. warnValidStyle = function (name, value) {
  7096. if (name.indexOf('-') > -1) {
  7097. warnHyphenatedStyleName(name);
  7098. } else if (badVendoredStyleNamePattern.test(name)) {
  7099. warnBadVendoredStyleName(name);
  7100. } else if (badStyleValueWithSemicolonPattern.test(value)) {
  7101. warnStyleValueWithSemicolon(name, value);
  7102. }
  7103. if (typeof value === 'number') {
  7104. if (isNaN(value)) {
  7105. warnStyleValueIsNaN(name, value);
  7106. } else if (!isFinite(value)) {
  7107. warnStyleValueIsInfinity(name, value);
  7108. }
  7109. }
  7110. };
  7111. }
  7112. var warnValidStyle$1 = warnValidStyle;
  7113. /**
  7114. * Operations for dealing with CSS properties.
  7115. */
  7116. /**
  7117. * This creates a string that is expected to be equivalent to the style
  7118. * attribute generated by server-side rendering. It by-passes warnings and
  7119. * security checks so it's not safe to use this value for anything other than
  7120. * comparison. It is only used in DEV for SSR validation.
  7121. */
  7122. function createDangerousStringForStyles(styles) {
  7123. {
  7124. var serialized = '';
  7125. var delimiter = '';
  7126. for (var styleName in styles) {
  7127. if (!styles.hasOwnProperty(styleName)) {
  7128. continue;
  7129. }
  7130. var styleValue = styles[styleName];
  7131. if (styleValue != null) {
  7132. var isCustomProperty = styleName.indexOf('--') === 0;
  7133. serialized += delimiter + (isCustomProperty ? styleName : hyphenateStyleName(styleName)) + ':';
  7134. serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty);
  7135. delimiter = ';';
  7136. }
  7137. }
  7138. return serialized || null;
  7139. }
  7140. }
  7141. /**
  7142. * Sets the value for multiple styles on a node. If a value is specified as
  7143. * '' (empty string), the corresponding style property will be unset.
  7144. *
  7145. * @param {DOMElement} node
  7146. * @param {object} styles
  7147. */
  7148. function setValueForStyles(node, styles) {
  7149. var style = node.style;
  7150. for (var styleName in styles) {
  7151. if (!styles.hasOwnProperty(styleName)) {
  7152. continue;
  7153. }
  7154. var isCustomProperty = styleName.indexOf('--') === 0;
  7155. {
  7156. if (!isCustomProperty) {
  7157. warnValidStyle$1(styleName, styles[styleName]);
  7158. }
  7159. }
  7160. var styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty);
  7161. if (styleName === 'float') {
  7162. styleName = 'cssFloat';
  7163. }
  7164. if (isCustomProperty) {
  7165. style.setProperty(styleName, styleValue);
  7166. } else {
  7167. style[styleName] = styleValue;
  7168. }
  7169. }
  7170. }
  7171. function isValueEmpty(value) {
  7172. return value == null || typeof value === 'boolean' || value === '';
  7173. }
  7174. /**
  7175. * Given {color: 'red', overflow: 'hidden'} returns {
  7176. * color: 'color',
  7177. * overflowX: 'overflow',
  7178. * overflowY: 'overflow',
  7179. * }. This can be read as "the overflowY property was set by the overflow
  7180. * shorthand". That is, the values are the property that each was derived from.
  7181. */
  7182. function expandShorthandMap(styles) {
  7183. var expanded = {};
  7184. for (var key in styles) {
  7185. var longhands = shorthandToLonghand[key] || [key];
  7186. for (var i = 0; i < longhands.length; i++) {
  7187. expanded[longhands[i]] = key;
  7188. }
  7189. }
  7190. return expanded;
  7191. }
  7192. /**
  7193. * When mixing shorthand and longhand property names, we warn during updates if
  7194. * we expect an incorrect result to occur. In particular, we warn for:
  7195. *
  7196. * Updating a shorthand property (longhand gets overwritten):
  7197. * {font: 'foo', fontVariant: 'bar'} -> {font: 'baz', fontVariant: 'bar'}
  7198. * becomes .style.font = 'baz'
  7199. * Removing a shorthand property (longhand gets lost too):
  7200. * {font: 'foo', fontVariant: 'bar'} -> {fontVariant: 'bar'}
  7201. * becomes .style.font = ''
  7202. * Removing a longhand property (should revert to shorthand; doesn't):
  7203. * {font: 'foo', fontVariant: 'bar'} -> {font: 'foo'}
  7204. * becomes .style.fontVariant = ''
  7205. */
  7206. function validateShorthandPropertyCollisionInDev(styleUpdates, nextStyles) {
  7207. if (!warnAboutShorthandPropertyCollision) {
  7208. return;
  7209. }
  7210. if (!nextStyles) {
  7211. return;
  7212. }
  7213. var expandedUpdates = expandShorthandMap(styleUpdates);
  7214. var expandedStyles = expandShorthandMap(nextStyles);
  7215. var warnedAbout = {};
  7216. for (var key in expandedUpdates) {
  7217. var originalKey = expandedUpdates[key];
  7218. var correctOriginalKey = expandedStyles[key];
  7219. if (correctOriginalKey && originalKey !== correctOriginalKey) {
  7220. var warningKey = originalKey + ',' + correctOriginalKey;
  7221. if (warnedAbout[warningKey]) {
  7222. continue;
  7223. }
  7224. warnedAbout[warningKey] = true;
  7225. warning$1(false, '%s a style property during rerender (%s) when a ' + 'conflicting property is set (%s) can lead to styling bugs. To ' + "avoid this, don't mix shorthand and non-shorthand properties " + 'for the same value; instead, replace the shorthand with ' + 'separate values.', isValueEmpty(styleUpdates[originalKey]) ? 'Removing' : 'Updating', originalKey, correctOriginalKey);
  7226. }
  7227. }
  7228. }
  7229. // For HTML, certain tags should omit their close tag. We keep a whitelist for
  7230. // those special-case tags.
  7231. var omittedCloseTags = {
  7232. area: true,
  7233. base: true,
  7234. br: true,
  7235. col: true,
  7236. embed: true,
  7237. hr: true,
  7238. img: true,
  7239. input: true,
  7240. keygen: true,
  7241. link: true,
  7242. meta: true,
  7243. param: true,
  7244. source: true,
  7245. track: true,
  7246. wbr: true
  7247. // NOTE: menuitem's close tag should be omitted, but that causes problems.
  7248. };
  7249. // For HTML, certain tags cannot have children. This has the same purpose as
  7250. // `omittedCloseTags` except that `menuitem` should still have its closing tag.
  7251. var voidElementTags = _assign({
  7252. menuitem: true
  7253. }, omittedCloseTags);
  7254. // TODO: We can remove this if we add invariantWithStack()
  7255. // or add stack by default to invariants where possible.
  7256. var HTML$1 = '__html';
  7257. var ReactDebugCurrentFrame$3 = null;
  7258. {
  7259. ReactDebugCurrentFrame$3 = ReactSharedInternals.ReactDebugCurrentFrame;
  7260. }
  7261. function assertValidProps(tag, props) {
  7262. if (!props) {
  7263. return;
  7264. }
  7265. // Note the use of `==` which checks for null or undefined.
  7266. if (voidElementTags[tag]) {
  7267. (function () {
  7268. if (!(props.children == null && props.dangerouslySetInnerHTML == null)) {
  7269. {
  7270. throw ReactError(Error(tag + ' is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`.' + (ReactDebugCurrentFrame$3.getStackAddendum())));
  7271. }
  7272. }
  7273. })();
  7274. }
  7275. if (props.dangerouslySetInnerHTML != null) {
  7276. (function () {
  7277. if (!(props.children == null)) {
  7278. {
  7279. throw ReactError(Error('Can only set one of `children` or `props.dangerouslySetInnerHTML`.'));
  7280. }
  7281. }
  7282. })();
  7283. (function () {
  7284. if (!(typeof props.dangerouslySetInnerHTML === 'object' && HTML$1 in props.dangerouslySetInnerHTML)) {
  7285. {
  7286. throw ReactError(Error('`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://fb.me/react-invariant-dangerously-set-inner-html for more information.'));
  7287. }
  7288. }
  7289. })();
  7290. }
  7291. {
  7292. !(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;
  7293. }
  7294. (function () {
  7295. if (!(props.style == null || typeof props.style === 'object')) {
  7296. {
  7297. throw ReactError(Error('The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + \'em\'}} when using JSX.' + (ReactDebugCurrentFrame$3.getStackAddendum())));
  7298. }
  7299. }
  7300. })();
  7301. }
  7302. function isCustomComponent(tagName, props) {
  7303. if (tagName.indexOf('-') === -1) {
  7304. return typeof props.is === 'string';
  7305. }
  7306. switch (tagName) {
  7307. // These are reserved SVG and MathML elements.
  7308. // We don't mind this whitelist too much because we expect it to never grow.
  7309. // The alternative is to track the namespace in a few places which is convoluted.
  7310. // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
  7311. case 'annotation-xml':
  7312. case 'color-profile':
  7313. case 'font-face':
  7314. case 'font-face-src':
  7315. case 'font-face-uri':
  7316. case 'font-face-format':
  7317. case 'font-face-name':
  7318. case 'missing-glyph':
  7319. return false;
  7320. default:
  7321. return true;
  7322. }
  7323. }
  7324. // When adding attributes to the HTML or SVG whitelist, be sure to
  7325. // also add them to this module to ensure casing and incorrect name
  7326. // warnings.
  7327. var possibleStandardNames = {
  7328. // HTML
  7329. accept: 'accept',
  7330. acceptcharset: 'acceptCharset',
  7331. 'accept-charset': 'acceptCharset',
  7332. accesskey: 'accessKey',
  7333. action: 'action',
  7334. allowfullscreen: 'allowFullScreen',
  7335. alt: 'alt',
  7336. as: 'as',
  7337. async: 'async',
  7338. autocapitalize: 'autoCapitalize',
  7339. autocomplete: 'autoComplete',
  7340. autocorrect: 'autoCorrect',
  7341. autofocus: 'autoFocus',
  7342. autoplay: 'autoPlay',
  7343. autosave: 'autoSave',
  7344. capture: 'capture',
  7345. cellpadding: 'cellPadding',
  7346. cellspacing: 'cellSpacing',
  7347. challenge: 'challenge',
  7348. charset: 'charSet',
  7349. checked: 'checked',
  7350. children: 'children',
  7351. cite: 'cite',
  7352. class: 'className',
  7353. classid: 'classID',
  7354. classname: 'className',
  7355. cols: 'cols',
  7356. colspan: 'colSpan',
  7357. content: 'content',
  7358. contenteditable: 'contentEditable',
  7359. contextmenu: 'contextMenu',
  7360. controls: 'controls',
  7361. controlslist: 'controlsList',
  7362. coords: 'coords',
  7363. crossorigin: 'crossOrigin',
  7364. dangerouslysetinnerhtml: 'dangerouslySetInnerHTML',
  7365. data: 'data',
  7366. datetime: 'dateTime',
  7367. default: 'default',
  7368. defaultchecked: 'defaultChecked',
  7369. defaultvalue: 'defaultValue',
  7370. defer: 'defer',
  7371. dir: 'dir',
  7372. disabled: 'disabled',
  7373. disablepictureinpicture: 'disablePictureInPicture',
  7374. download: 'download',
  7375. draggable: 'draggable',
  7376. enctype: 'encType',
  7377. for: 'htmlFor',
  7378. form: 'form',
  7379. formmethod: 'formMethod',
  7380. formaction: 'formAction',
  7381. formenctype: 'formEncType',
  7382. formnovalidate: 'formNoValidate',
  7383. formtarget: 'formTarget',
  7384. frameborder: 'frameBorder',
  7385. headers: 'headers',
  7386. height: 'height',
  7387. hidden: 'hidden',
  7388. high: 'high',
  7389. href: 'href',
  7390. hreflang: 'hrefLang',
  7391. htmlfor: 'htmlFor',
  7392. httpequiv: 'httpEquiv',
  7393. 'http-equiv': 'httpEquiv',
  7394. icon: 'icon',
  7395. id: 'id',
  7396. innerhtml: 'innerHTML',
  7397. inputmode: 'inputMode',
  7398. integrity: 'integrity',
  7399. is: 'is',
  7400. itemid: 'itemID',
  7401. itemprop: 'itemProp',
  7402. itemref: 'itemRef',
  7403. itemscope: 'itemScope',
  7404. itemtype: 'itemType',
  7405. keyparams: 'keyParams',
  7406. keytype: 'keyType',
  7407. kind: 'kind',
  7408. label: 'label',
  7409. lang: 'lang',
  7410. list: 'list',
  7411. loop: 'loop',
  7412. low: 'low',
  7413. manifest: 'manifest',
  7414. marginwidth: 'marginWidth',
  7415. marginheight: 'marginHeight',
  7416. max: 'max',
  7417. maxlength: 'maxLength',
  7418. media: 'media',
  7419. mediagroup: 'mediaGroup',
  7420. method: 'method',
  7421. min: 'min',
  7422. minlength: 'minLength',
  7423. multiple: 'multiple',
  7424. muted: 'muted',
  7425. name: 'name',
  7426. nomodule: 'noModule',
  7427. nonce: 'nonce',
  7428. novalidate: 'noValidate',
  7429. open: 'open',
  7430. optimum: 'optimum',
  7431. pattern: 'pattern',
  7432. placeholder: 'placeholder',
  7433. playsinline: 'playsInline',
  7434. poster: 'poster',
  7435. preload: 'preload',
  7436. profile: 'profile',
  7437. radiogroup: 'radioGroup',
  7438. readonly: 'readOnly',
  7439. referrerpolicy: 'referrerPolicy',
  7440. rel: 'rel',
  7441. required: 'required',
  7442. reversed: 'reversed',
  7443. role: 'role',
  7444. rows: 'rows',
  7445. rowspan: 'rowSpan',
  7446. sandbox: 'sandbox',
  7447. scope: 'scope',
  7448. scoped: 'scoped',
  7449. scrolling: 'scrolling',
  7450. seamless: 'seamless',
  7451. selected: 'selected',
  7452. shape: 'shape',
  7453. size: 'size',
  7454. sizes: 'sizes',
  7455. span: 'span',
  7456. spellcheck: 'spellCheck',
  7457. src: 'src',
  7458. srcdoc: 'srcDoc',
  7459. srclang: 'srcLang',
  7460. srcset: 'srcSet',
  7461. start: 'start',
  7462. step: 'step',
  7463. style: 'style',
  7464. summary: 'summary',
  7465. tabindex: 'tabIndex',
  7466. target: 'target',
  7467. title: 'title',
  7468. type: 'type',
  7469. usemap: 'useMap',
  7470. value: 'value',
  7471. width: 'width',
  7472. wmode: 'wmode',
  7473. wrap: 'wrap',
  7474. // SVG
  7475. about: 'about',
  7476. accentheight: 'accentHeight',
  7477. 'accent-height': 'accentHeight',
  7478. accumulate: 'accumulate',
  7479. additive: 'additive',
  7480. alignmentbaseline: 'alignmentBaseline',
  7481. 'alignment-baseline': 'alignmentBaseline',
  7482. allowreorder: 'allowReorder',
  7483. alphabetic: 'alphabetic',
  7484. amplitude: 'amplitude',
  7485. arabicform: 'arabicForm',
  7486. 'arabic-form': 'arabicForm',
  7487. ascent: 'ascent',
  7488. attributename: 'attributeName',
  7489. attributetype: 'attributeType',
  7490. autoreverse: 'autoReverse',
  7491. azimuth: 'azimuth',
  7492. basefrequency: 'baseFrequency',
  7493. baselineshift: 'baselineShift',
  7494. 'baseline-shift': 'baselineShift',
  7495. baseprofile: 'baseProfile',
  7496. bbox: 'bbox',
  7497. begin: 'begin',
  7498. bias: 'bias',
  7499. by: 'by',
  7500. calcmode: 'calcMode',
  7501. capheight: 'capHeight',
  7502. 'cap-height': 'capHeight',
  7503. clip: 'clip',
  7504. clippath: 'clipPath',
  7505. 'clip-path': 'clipPath',
  7506. clippathunits: 'clipPathUnits',
  7507. cliprule: 'clipRule',
  7508. 'clip-rule': 'clipRule',
  7509. color: 'color',
  7510. colorinterpolation: 'colorInterpolation',
  7511. 'color-interpolation': 'colorInterpolation',
  7512. colorinterpolationfilters: 'colorInterpolationFilters',
  7513. 'color-interpolation-filters': 'colorInterpolationFilters',
  7514. colorprofile: 'colorProfile',
  7515. 'color-profile': 'colorProfile',
  7516. colorrendering: 'colorRendering',
  7517. 'color-rendering': 'colorRendering',
  7518. contentscripttype: 'contentScriptType',
  7519. contentstyletype: 'contentStyleType',
  7520. cursor: 'cursor',
  7521. cx: 'cx',
  7522. cy: 'cy',
  7523. d: 'd',
  7524. datatype: 'datatype',
  7525. decelerate: 'decelerate',
  7526. descent: 'descent',
  7527. diffuseconstant: 'diffuseConstant',
  7528. direction: 'direction',
  7529. display: 'display',
  7530. divisor: 'divisor',
  7531. dominantbaseline: 'dominantBaseline',
  7532. 'dominant-baseline': 'dominantBaseline',
  7533. dur: 'dur',
  7534. dx: 'dx',
  7535. dy: 'dy',
  7536. edgemode: 'edgeMode',
  7537. elevation: 'elevation',
  7538. enablebackground: 'enableBackground',
  7539. 'enable-background': 'enableBackground',
  7540. end: 'end',
  7541. exponent: 'exponent',
  7542. externalresourcesrequired: 'externalResourcesRequired',
  7543. fill: 'fill',
  7544. fillopacity: 'fillOpacity',
  7545. 'fill-opacity': 'fillOpacity',
  7546. fillrule: 'fillRule',
  7547. 'fill-rule': 'fillRule',
  7548. filter: 'filter',
  7549. filterres: 'filterRes',
  7550. filterunits: 'filterUnits',
  7551. floodopacity: 'floodOpacity',
  7552. 'flood-opacity': 'floodOpacity',
  7553. floodcolor: 'floodColor',
  7554. 'flood-color': 'floodColor',
  7555. focusable: 'focusable',
  7556. fontfamily: 'fontFamily',
  7557. 'font-family': 'fontFamily',
  7558. fontsize: 'fontSize',
  7559. 'font-size': 'fontSize',
  7560. fontsizeadjust: 'fontSizeAdjust',
  7561. 'font-size-adjust': 'fontSizeAdjust',
  7562. fontstretch: 'fontStretch',
  7563. 'font-stretch': 'fontStretch',
  7564. fontstyle: 'fontStyle',
  7565. 'font-style': 'fontStyle',
  7566. fontvariant: 'fontVariant',
  7567. 'font-variant': 'fontVariant',
  7568. fontweight: 'fontWeight',
  7569. 'font-weight': 'fontWeight',
  7570. format: 'format',
  7571. from: 'from',
  7572. fx: 'fx',
  7573. fy: 'fy',
  7574. g1: 'g1',
  7575. g2: 'g2',
  7576. glyphname: 'glyphName',
  7577. 'glyph-name': 'glyphName',
  7578. glyphorientationhorizontal: 'glyphOrientationHorizontal',
  7579. 'glyph-orientation-horizontal': 'glyphOrientationHorizontal',
  7580. glyphorientationvertical: 'glyphOrientationVertical',
  7581. 'glyph-orientation-vertical': 'glyphOrientationVertical',
  7582. glyphref: 'glyphRef',
  7583. gradienttransform: 'gradientTransform',
  7584. gradientunits: 'gradientUnits',
  7585. hanging: 'hanging',
  7586. horizadvx: 'horizAdvX',
  7587. 'horiz-adv-x': 'horizAdvX',
  7588. horizoriginx: 'horizOriginX',
  7589. 'horiz-origin-x': 'horizOriginX',
  7590. ideographic: 'ideographic',
  7591. imagerendering: 'imageRendering',
  7592. 'image-rendering': 'imageRendering',
  7593. in2: 'in2',
  7594. in: 'in',
  7595. inlist: 'inlist',
  7596. intercept: 'intercept',
  7597. k1: 'k1',
  7598. k2: 'k2',
  7599. k3: 'k3',
  7600. k4: 'k4',
  7601. k: 'k',
  7602. kernelmatrix: 'kernelMatrix',
  7603. kernelunitlength: 'kernelUnitLength',
  7604. kerning: 'kerning',
  7605. keypoints: 'keyPoints',
  7606. keysplines: 'keySplines',
  7607. keytimes: 'keyTimes',
  7608. lengthadjust: 'lengthAdjust',
  7609. letterspacing: 'letterSpacing',
  7610. 'letter-spacing': 'letterSpacing',
  7611. lightingcolor: 'lightingColor',
  7612. 'lighting-color': 'lightingColor',
  7613. limitingconeangle: 'limitingConeAngle',
  7614. local: 'local',
  7615. markerend: 'markerEnd',
  7616. 'marker-end': 'markerEnd',
  7617. markerheight: 'markerHeight',
  7618. markermid: 'markerMid',
  7619. 'marker-mid': 'markerMid',
  7620. markerstart: 'markerStart',
  7621. 'marker-start': 'markerStart',
  7622. markerunits: 'markerUnits',
  7623. markerwidth: 'markerWidth',
  7624. mask: 'mask',
  7625. maskcontentunits: 'maskContentUnits',
  7626. maskunits: 'maskUnits',
  7627. mathematical: 'mathematical',
  7628. mode: 'mode',
  7629. numoctaves: 'numOctaves',
  7630. offset: 'offset',
  7631. opacity: 'opacity',
  7632. operator: 'operator',
  7633. order: 'order',
  7634. orient: 'orient',
  7635. orientation: 'orientation',
  7636. origin: 'origin',
  7637. overflow: 'overflow',
  7638. overlineposition: 'overlinePosition',
  7639. 'overline-position': 'overlinePosition',
  7640. overlinethickness: 'overlineThickness',
  7641. 'overline-thickness': 'overlineThickness',
  7642. paintorder: 'paintOrder',
  7643. 'paint-order': 'paintOrder',
  7644. panose1: 'panose1',
  7645. 'panose-1': 'panose1',
  7646. pathlength: 'pathLength',
  7647. patterncontentunits: 'patternContentUnits',
  7648. patterntransform: 'patternTransform',
  7649. patternunits: 'patternUnits',
  7650. pointerevents: 'pointerEvents',
  7651. 'pointer-events': 'pointerEvents',
  7652. points: 'points',
  7653. pointsatx: 'pointsAtX',
  7654. pointsaty: 'pointsAtY',
  7655. pointsatz: 'pointsAtZ',
  7656. prefix: 'prefix',
  7657. preservealpha: 'preserveAlpha',
  7658. preserveaspectratio: 'preserveAspectRatio',
  7659. primitiveunits: 'primitiveUnits',
  7660. property: 'property',
  7661. r: 'r',
  7662. radius: 'radius',
  7663. refx: 'refX',
  7664. refy: 'refY',
  7665. renderingintent: 'renderingIntent',
  7666. 'rendering-intent': 'renderingIntent',
  7667. repeatcount: 'repeatCount',
  7668. repeatdur: 'repeatDur',
  7669. requiredextensions: 'requiredExtensions',
  7670. requiredfeatures: 'requiredFeatures',
  7671. resource: 'resource',
  7672. restart: 'restart',
  7673. result: 'result',
  7674. results: 'results',
  7675. rotate: 'rotate',
  7676. rx: 'rx',
  7677. ry: 'ry',
  7678. scale: 'scale',
  7679. security: 'security',
  7680. seed: 'seed',
  7681. shaperendering: 'shapeRendering',
  7682. 'shape-rendering': 'shapeRendering',
  7683. slope: 'slope',
  7684. spacing: 'spacing',
  7685. specularconstant: 'specularConstant',
  7686. specularexponent: 'specularExponent',
  7687. speed: 'speed',
  7688. spreadmethod: 'spreadMethod',
  7689. startoffset: 'startOffset',
  7690. stddeviation: 'stdDeviation',
  7691. stemh: 'stemh',
  7692. stemv: 'stemv',
  7693. stitchtiles: 'stitchTiles',
  7694. stopcolor: 'stopColor',
  7695. 'stop-color': 'stopColor',
  7696. stopopacity: 'stopOpacity',
  7697. 'stop-opacity': 'stopOpacity',
  7698. strikethroughposition: 'strikethroughPosition',
  7699. 'strikethrough-position': 'strikethroughPosition',
  7700. strikethroughthickness: 'strikethroughThickness',
  7701. 'strikethrough-thickness': 'strikethroughThickness',
  7702. string: 'string',
  7703. stroke: 'stroke',
  7704. strokedasharray: 'strokeDasharray',
  7705. 'stroke-dasharray': 'strokeDasharray',
  7706. strokedashoffset: 'strokeDashoffset',
  7707. 'stroke-dashoffset': 'strokeDashoffset',
  7708. strokelinecap: 'strokeLinecap',
  7709. 'stroke-linecap': 'strokeLinecap',
  7710. strokelinejoin: 'strokeLinejoin',
  7711. 'stroke-linejoin': 'strokeLinejoin',
  7712. strokemiterlimit: 'strokeMiterlimit',
  7713. 'stroke-miterlimit': 'strokeMiterlimit',
  7714. strokewidth: 'strokeWidth',
  7715. 'stroke-width': 'strokeWidth',
  7716. strokeopacity: 'strokeOpacity',
  7717. 'stroke-opacity': 'strokeOpacity',
  7718. suppresscontenteditablewarning: 'suppressContentEditableWarning',
  7719. suppresshydrationwarning: 'suppressHydrationWarning',
  7720. surfacescale: 'surfaceScale',
  7721. systemlanguage: 'systemLanguage',
  7722. tablevalues: 'tableValues',
  7723. targetx: 'targetX',
  7724. targety: 'targetY',
  7725. textanchor: 'textAnchor',
  7726. 'text-anchor': 'textAnchor',
  7727. textdecoration: 'textDecoration',
  7728. 'text-decoration': 'textDecoration',
  7729. textlength: 'textLength',
  7730. textrendering: 'textRendering',
  7731. 'text-rendering': 'textRendering',
  7732. to: 'to',
  7733. transform: 'transform',
  7734. typeof: 'typeof',
  7735. u1: 'u1',
  7736. u2: 'u2',
  7737. underlineposition: 'underlinePosition',
  7738. 'underline-position': 'underlinePosition',
  7739. underlinethickness: 'underlineThickness',
  7740. 'underline-thickness': 'underlineThickness',
  7741. unicode: 'unicode',
  7742. unicodebidi: 'unicodeBidi',
  7743. 'unicode-bidi': 'unicodeBidi',
  7744. unicoderange: 'unicodeRange',
  7745. 'unicode-range': 'unicodeRange',
  7746. unitsperem: 'unitsPerEm',
  7747. 'units-per-em': 'unitsPerEm',
  7748. unselectable: 'unselectable',
  7749. valphabetic: 'vAlphabetic',
  7750. 'v-alphabetic': 'vAlphabetic',
  7751. values: 'values',
  7752. vectoreffect: 'vectorEffect',
  7753. 'vector-effect': 'vectorEffect',
  7754. version: 'version',
  7755. vertadvy: 'vertAdvY',
  7756. 'vert-adv-y': 'vertAdvY',
  7757. vertoriginx: 'vertOriginX',
  7758. 'vert-origin-x': 'vertOriginX',
  7759. vertoriginy: 'vertOriginY',
  7760. 'vert-origin-y': 'vertOriginY',
  7761. vhanging: 'vHanging',
  7762. 'v-hanging': 'vHanging',
  7763. videographic: 'vIdeographic',
  7764. 'v-ideographic': 'vIdeographic',
  7765. viewbox: 'viewBox',
  7766. viewtarget: 'viewTarget',
  7767. visibility: 'visibility',
  7768. vmathematical: 'vMathematical',
  7769. 'v-mathematical': 'vMathematical',
  7770. vocab: 'vocab',
  7771. widths: 'widths',
  7772. wordspacing: 'wordSpacing',
  7773. 'word-spacing': 'wordSpacing',
  7774. writingmode: 'writingMode',
  7775. 'writing-mode': 'writingMode',
  7776. x1: 'x1',
  7777. x2: 'x2',
  7778. x: 'x',
  7779. xchannelselector: 'xChannelSelector',
  7780. xheight: 'xHeight',
  7781. 'x-height': 'xHeight',
  7782. xlinkactuate: 'xlinkActuate',
  7783. 'xlink:actuate': 'xlinkActuate',
  7784. xlinkarcrole: 'xlinkArcrole',
  7785. 'xlink:arcrole': 'xlinkArcrole',
  7786. xlinkhref: 'xlinkHref',
  7787. 'xlink:href': 'xlinkHref',
  7788. xlinkrole: 'xlinkRole',
  7789. 'xlink:role': 'xlinkRole',
  7790. xlinkshow: 'xlinkShow',
  7791. 'xlink:show': 'xlinkShow',
  7792. xlinktitle: 'xlinkTitle',
  7793. 'xlink:title': 'xlinkTitle',
  7794. xlinktype: 'xlinkType',
  7795. 'xlink:type': 'xlinkType',
  7796. xmlbase: 'xmlBase',
  7797. 'xml:base': 'xmlBase',
  7798. xmllang: 'xmlLang',
  7799. 'xml:lang': 'xmlLang',
  7800. xmlns: 'xmlns',
  7801. 'xml:space': 'xmlSpace',
  7802. xmlnsxlink: 'xmlnsXlink',
  7803. 'xmlns:xlink': 'xmlnsXlink',
  7804. xmlspace: 'xmlSpace',
  7805. y1: 'y1',
  7806. y2: 'y2',
  7807. y: 'y',
  7808. ychannelselector: 'yChannelSelector',
  7809. z: 'z',
  7810. zoomandpan: 'zoomAndPan'
  7811. };
  7812. var ariaProperties = {
  7813. 'aria-current': 0, // state
  7814. 'aria-details': 0,
  7815. 'aria-disabled': 0, // state
  7816. 'aria-hidden': 0, // state
  7817. 'aria-invalid': 0, // state
  7818. 'aria-keyshortcuts': 0,
  7819. 'aria-label': 0,
  7820. 'aria-roledescription': 0,
  7821. // Widget Attributes
  7822. 'aria-autocomplete': 0,
  7823. 'aria-checked': 0,
  7824. 'aria-expanded': 0,
  7825. 'aria-haspopup': 0,
  7826. 'aria-level': 0,
  7827. 'aria-modal': 0,
  7828. 'aria-multiline': 0,
  7829. 'aria-multiselectable': 0,
  7830. 'aria-orientation': 0,
  7831. 'aria-placeholder': 0,
  7832. 'aria-pressed': 0,
  7833. 'aria-readonly': 0,
  7834. 'aria-required': 0,
  7835. 'aria-selected': 0,
  7836. 'aria-sort': 0,
  7837. 'aria-valuemax': 0,
  7838. 'aria-valuemin': 0,
  7839. 'aria-valuenow': 0,
  7840. 'aria-valuetext': 0,
  7841. // Live Region Attributes
  7842. 'aria-atomic': 0,
  7843. 'aria-busy': 0,
  7844. 'aria-live': 0,
  7845. 'aria-relevant': 0,
  7846. // Drag-and-Drop Attributes
  7847. 'aria-dropeffect': 0,
  7848. 'aria-grabbed': 0,
  7849. // Relationship Attributes
  7850. 'aria-activedescendant': 0,
  7851. 'aria-colcount': 0,
  7852. 'aria-colindex': 0,
  7853. 'aria-colspan': 0,
  7854. 'aria-controls': 0,
  7855. 'aria-describedby': 0,
  7856. 'aria-errormessage': 0,
  7857. 'aria-flowto': 0,
  7858. 'aria-labelledby': 0,
  7859. 'aria-owns': 0,
  7860. 'aria-posinset': 0,
  7861. 'aria-rowcount': 0,
  7862. 'aria-rowindex': 0,
  7863. 'aria-rowspan': 0,
  7864. 'aria-setsize': 0
  7865. };
  7866. var warnedProperties = {};
  7867. var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
  7868. var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
  7869. var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
  7870. function validateProperty(tagName, name) {
  7871. if (hasOwnProperty$2.call(warnedProperties, name) && warnedProperties[name]) {
  7872. return true;
  7873. }
  7874. if (rARIACamel.test(name)) {
  7875. var ariaName = 'aria-' + name.slice(4).toLowerCase();
  7876. var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null;
  7877. // If this is an aria-* attribute, but is not listed in the known DOM
  7878. // DOM properties, then it is an invalid aria-* attribute.
  7879. if (correctName == null) {
  7880. warning$1(false, 'Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.', name);
  7881. warnedProperties[name] = true;
  7882. return true;
  7883. }
  7884. // aria-* attributes should be lowercase; suggest the lowercase version.
  7885. if (name !== correctName) {
  7886. warning$1(false, 'Invalid ARIA attribute `%s`. Did you mean `%s`?', name, correctName);
  7887. warnedProperties[name] = true;
  7888. return true;
  7889. }
  7890. }
  7891. if (rARIA.test(name)) {
  7892. var lowerCasedName = name.toLowerCase();
  7893. var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null;
  7894. // If this is an aria-* attribute, but is not listed in the known DOM
  7895. // DOM properties, then it is an invalid aria-* attribute.
  7896. if (standardName == null) {
  7897. warnedProperties[name] = true;
  7898. return false;
  7899. }
  7900. // aria-* attributes should be lowercase; suggest the lowercase version.
  7901. if (name !== standardName) {
  7902. warning$1(false, 'Unknown ARIA attribute `%s`. Did you mean `%s`?', name, standardName);
  7903. warnedProperties[name] = true;
  7904. return true;
  7905. }
  7906. }
  7907. return true;
  7908. }
  7909. function warnInvalidARIAProps(type, props) {
  7910. var invalidProps = [];
  7911. for (var key in props) {
  7912. var isValid = validateProperty(type, key);
  7913. if (!isValid) {
  7914. invalidProps.push(key);
  7915. }
  7916. }
  7917. var unknownPropString = invalidProps.map(function (prop) {
  7918. return '`' + prop + '`';
  7919. }).join(', ');
  7920. if (invalidProps.length === 1) {
  7921. warning$1(false, 'Invalid aria prop %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop', unknownPropString, type);
  7922. } else if (invalidProps.length > 1) {
  7923. warning$1(false, 'Invalid aria props %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop', unknownPropString, type);
  7924. }
  7925. }
  7926. function validateProperties(type, props) {
  7927. if (isCustomComponent(type, props)) {
  7928. return;
  7929. }
  7930. warnInvalidARIAProps(type, props);
  7931. }
  7932. var didWarnValueNull = false;
  7933. function validateProperties$1(type, props) {
  7934. if (type !== 'input' && type !== 'textarea' && type !== 'select') {
  7935. return;
  7936. }
  7937. if (props != null && props.value === null && !didWarnValueNull) {
  7938. didWarnValueNull = true;
  7939. if (type === 'select' && props.multiple) {
  7940. 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);
  7941. } else {
  7942. 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);
  7943. }
  7944. }
  7945. }
  7946. var validateProperty$1 = function () {};
  7947. {
  7948. var warnedProperties$1 = {};
  7949. var _hasOwnProperty = Object.prototype.hasOwnProperty;
  7950. var EVENT_NAME_REGEX = /^on./;
  7951. var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/;
  7952. var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
  7953. var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
  7954. validateProperty$1 = function (tagName, name, value, canUseEventSystem) {
  7955. if (_hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) {
  7956. return true;
  7957. }
  7958. var lowerCasedName = name.toLowerCase();
  7959. if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') {
  7960. 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.');
  7961. warnedProperties$1[name] = true;
  7962. return true;
  7963. }
  7964. // We can't rely on the event system being injected on the server.
  7965. if (canUseEventSystem) {
  7966. if (registrationNameModules.hasOwnProperty(name)) {
  7967. return true;
  7968. }
  7969. var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null;
  7970. if (registrationName != null) {
  7971. warning$1(false, 'Invalid event handler property `%s`. Did you mean `%s`?', name, registrationName);
  7972. warnedProperties$1[name] = true;
  7973. return true;
  7974. }
  7975. if (EVENT_NAME_REGEX.test(name)) {
  7976. warning$1(false, 'Unknown event handler property `%s`. It will be ignored.', name);
  7977. warnedProperties$1[name] = true;
  7978. return true;
  7979. }
  7980. } else if (EVENT_NAME_REGEX.test(name)) {
  7981. // If no event plugins have been injected, we are in a server environment.
  7982. // So we can't tell if the event name is correct for sure, but we can filter
  7983. // out known bad ones like `onclick`. We can't suggest a specific replacement though.
  7984. if (INVALID_EVENT_NAME_REGEX.test(name)) {
  7985. warning$1(false, 'Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.', name);
  7986. }
  7987. warnedProperties$1[name] = true;
  7988. return true;
  7989. }
  7990. // Let the ARIA attribute hook validate ARIA attributes
  7991. if (rARIA$1.test(name) || rARIACamel$1.test(name)) {
  7992. return true;
  7993. }
  7994. if (lowerCasedName === 'innerhtml') {
  7995. warning$1(false, 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.');
  7996. warnedProperties$1[name] = true;
  7997. return true;
  7998. }
  7999. if (lowerCasedName === 'aria') {
  8000. warning$1(false, 'The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.');
  8001. warnedProperties$1[name] = true;
  8002. return true;
  8003. }
  8004. if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') {
  8005. warning$1(false, 'Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.', typeof value);
  8006. warnedProperties$1[name] = true;
  8007. return true;
  8008. }
  8009. if (typeof value === 'number' && isNaN(value)) {
  8010. warning$1(false, 'Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.', name);
  8011. warnedProperties$1[name] = true;
  8012. return true;
  8013. }
  8014. var propertyInfo = getPropertyInfo(name);
  8015. var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED;
  8016. // Known attributes should match the casing specified in the property config.
  8017. if (possibleStandardNames.hasOwnProperty(lowerCasedName)) {
  8018. var standardName = possibleStandardNames[lowerCasedName];
  8019. if (standardName !== name) {
  8020. warning$1(false, 'Invalid DOM property `%s`. Did you mean `%s`?', name, standardName);
  8021. warnedProperties$1[name] = true;
  8022. return true;
  8023. }
  8024. } else if (!isReserved && name !== lowerCasedName) {
  8025. // Unknown attributes should have lowercase casing since that's how they
  8026. // will be cased anyway with server rendering.
  8027. 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);
  8028. warnedProperties$1[name] = true;
  8029. return true;
  8030. }
  8031. if (typeof value === 'boolean' && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
  8032. if (value) {
  8033. 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);
  8034. } else {
  8035. 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);
  8036. }
  8037. warnedProperties$1[name] = true;
  8038. return true;
  8039. }
  8040. // Now that we've validated casing, do not validate
  8041. // data types for reserved props
  8042. if (isReserved) {
  8043. return true;
  8044. }
  8045. // Warn when a known attribute is a bad type
  8046. if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
  8047. warnedProperties$1[name] = true;
  8048. return false;
  8049. }
  8050. // Warn when passing the strings 'false' or 'true' into a boolean prop
  8051. if ((value === 'false' || value === 'true') && propertyInfo !== null && propertyInfo.type === BOOLEAN) {
  8052. 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);
  8053. warnedProperties$1[name] = true;
  8054. return true;
  8055. }
  8056. return true;
  8057. };
  8058. }
  8059. var warnUnknownProperties = function (type, props, canUseEventSystem) {
  8060. var unknownProps = [];
  8061. for (var key in props) {
  8062. var isValid = validateProperty$1(type, key, props[key], canUseEventSystem);
  8063. if (!isValid) {
  8064. unknownProps.push(key);
  8065. }
  8066. }
  8067. var unknownPropString = unknownProps.map(function (prop) {
  8068. return '`' + prop + '`';
  8069. }).join(', ');
  8070. if (unknownProps.length === 1) {
  8071. 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);
  8072. } else if (unknownProps.length > 1) {
  8073. 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);
  8074. }
  8075. };
  8076. function validateProperties$2(type, props, canUseEventSystem) {
  8077. if (isCustomComponent(type, props)) {
  8078. return;
  8079. }
  8080. warnUnknownProperties(type, props, canUseEventSystem);
  8081. }
  8082. // TODO: direct imports like some-package/src/* are bad. Fix me.
  8083. var didWarnInvalidHydration = false;
  8084. var didWarnShadyDOM = false;
  8085. var DANGEROUSLY_SET_INNER_HTML = 'dangerouslySetInnerHTML';
  8086. var SUPPRESS_CONTENT_EDITABLE_WARNING = 'suppressContentEditableWarning';
  8087. var SUPPRESS_HYDRATION_WARNING$1 = 'suppressHydrationWarning';
  8088. var AUTOFOCUS = 'autoFocus';
  8089. var CHILDREN = 'children';
  8090. var STYLE$1 = 'style';
  8091. var HTML = '__html';
  8092. var LISTENERS = 'listeners';
  8093. var HTML_NAMESPACE = Namespaces.html;
  8094. var warnedUnknownTags = void 0;
  8095. var suppressHydrationWarning = void 0;
  8096. var validatePropertiesInDevelopment = void 0;
  8097. var warnForTextDifference = void 0;
  8098. var warnForPropDifference = void 0;
  8099. var warnForExtraAttributes = void 0;
  8100. var warnForInvalidEventListener = void 0;
  8101. var canDiffStyleForHydrationWarning = void 0;
  8102. var normalizeMarkupForTextOrAttribute = void 0;
  8103. var normalizeHTML = void 0;
  8104. {
  8105. warnedUnknownTags = {
  8106. // Chrome is the only major browser not shipping <time>. But as of July
  8107. // 2017 it intends to ship it due to widespread usage. We intentionally
  8108. // *don't* warn for <time> even if it's unrecognized by Chrome because
  8109. // it soon will be, and many apps have been using it anyway.
  8110. time: true,
  8111. // There are working polyfills for <dialog>. Let people use it.
  8112. dialog: true,
  8113. // Electron ships a custom <webview> tag to display external web content in
  8114. // an isolated frame and process.
  8115. // This tag is not present in non Electron environments such as JSDom which
  8116. // is often used for testing purposes.
  8117. // @see https://electronjs.org/docs/api/webview-tag
  8118. webview: true
  8119. };
  8120. validatePropertiesInDevelopment = function (type, props) {
  8121. validateProperties(type, props);
  8122. validateProperties$1(type, props);
  8123. validateProperties$2(type, props, /* canUseEventSystem */true);
  8124. };
  8125. // IE 11 parses & normalizes the style attribute as opposed to other
  8126. // browsers. It adds spaces and sorts the properties in some
  8127. // non-alphabetical order. Handling that would require sorting CSS
  8128. // properties in the client & server versions or applying
  8129. // `expectedStyle` to a temporary DOM node to read its `style` attribute
  8130. // normalized. Since it only affects IE, we're skipping style warnings
  8131. // in that browser completely in favor of doing all that work.
  8132. // See https://github.com/facebook/react/issues/11807
  8133. canDiffStyleForHydrationWarning = canUseDOM && !document.documentMode;
  8134. // HTML parsing normalizes CR and CRLF to LF.
  8135. // It also can turn \u0000 into \uFFFD inside attributes.
  8136. // https://www.w3.org/TR/html5/single-page.html#preprocessing-the-input-stream
  8137. // If we have a mismatch, it might be caused by that.
  8138. // We will still patch up in this case but not fire the warning.
  8139. var NORMALIZE_NEWLINES_REGEX = /\r\n?/g;
  8140. var NORMALIZE_NULL_AND_REPLACEMENT_REGEX = /\u0000|\uFFFD/g;
  8141. normalizeMarkupForTextOrAttribute = function (markup) {
  8142. var markupString = typeof markup === 'string' ? markup : '' + markup;
  8143. return markupString.replace(NORMALIZE_NEWLINES_REGEX, '\n').replace(NORMALIZE_NULL_AND_REPLACEMENT_REGEX, '');
  8144. };
  8145. warnForTextDifference = function (serverText, clientText) {
  8146. if (didWarnInvalidHydration) {
  8147. return;
  8148. }
  8149. var normalizedClientText = normalizeMarkupForTextOrAttribute(clientText);
  8150. var normalizedServerText = normalizeMarkupForTextOrAttribute(serverText);
  8151. if (normalizedServerText === normalizedClientText) {
  8152. return;
  8153. }
  8154. didWarnInvalidHydration = true;
  8155. warningWithoutStack$1(false, 'Text content did not match. Server: "%s" Client: "%s"', normalizedServerText, normalizedClientText);
  8156. };
  8157. warnForPropDifference = function (propName, serverValue, clientValue) {
  8158. if (didWarnInvalidHydration) {
  8159. return;
  8160. }
  8161. var normalizedClientValue = normalizeMarkupForTextOrAttribute(clientValue);
  8162. var normalizedServerValue = normalizeMarkupForTextOrAttribute(serverValue);
  8163. if (normalizedServerValue === normalizedClientValue) {
  8164. return;
  8165. }
  8166. didWarnInvalidHydration = true;
  8167. warningWithoutStack$1(false, 'Prop `%s` did not match. Server: %s Client: %s', propName, JSON.stringify(normalizedServerValue), JSON.stringify(normalizedClientValue));
  8168. };
  8169. warnForExtraAttributes = function (attributeNames) {
  8170. if (didWarnInvalidHydration) {
  8171. return;
  8172. }
  8173. didWarnInvalidHydration = true;
  8174. var names = [];
  8175. attributeNames.forEach(function (name) {
  8176. names.push(name);
  8177. });
  8178. warningWithoutStack$1(false, 'Extra attributes from the server: %s', names);
  8179. };
  8180. warnForInvalidEventListener = function (registrationName, listener) {
  8181. if (listener === false) {
  8182. 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);
  8183. } else {
  8184. warning$1(false, 'Expected `%s` listener to be a function, instead got a value of `%s` type.', registrationName, typeof listener);
  8185. }
  8186. };
  8187. // Parse the HTML and read it back to normalize the HTML string so that it
  8188. // can be used for comparison.
  8189. normalizeHTML = function (parent, html) {
  8190. // We could have created a separate document here to avoid
  8191. // re-initializing custom elements if they exist. But this breaks
  8192. // how <noscript> is being handled. So we use the same document.
  8193. // See the discussion in https://github.com/facebook/react/pull/11157.
  8194. var testElement = parent.namespaceURI === HTML_NAMESPACE ? parent.ownerDocument.createElement(parent.tagName) : parent.ownerDocument.createElementNS(parent.namespaceURI, parent.tagName);
  8195. testElement.innerHTML = html;
  8196. return testElement.innerHTML;
  8197. };
  8198. }
  8199. function ensureListeningTo(rootContainerElement, registrationName) {
  8200. var isDocumentOrFragment = rootContainerElement.nodeType === DOCUMENT_NODE || rootContainerElement.nodeType === DOCUMENT_FRAGMENT_NODE;
  8201. var doc = isDocumentOrFragment ? rootContainerElement : rootContainerElement.ownerDocument;
  8202. listenTo(registrationName, doc);
  8203. }
  8204. function getOwnerDocumentFromRootContainer(rootContainerElement) {
  8205. return rootContainerElement.nodeType === DOCUMENT_NODE ? rootContainerElement : rootContainerElement.ownerDocument;
  8206. }
  8207. function noop() {}
  8208. function trapClickOnNonInteractiveElement(node) {
  8209. // Mobile Safari does not fire properly bubble click events on
  8210. // non-interactive elements, which means delegated click listeners do not
  8211. // fire. The workaround for this bug involves attaching an empty click
  8212. // listener on the target node.
  8213. // http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
  8214. // Just set it using the onclick property so that we don't have to manage any
  8215. // bookkeeping for it. Not sure if we need to clear it when the listener is
  8216. // removed.
  8217. // TODO: Only do this for the relevant Safaris maybe?
  8218. node.onclick = noop;
  8219. }
  8220. function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) {
  8221. for (var propKey in nextProps) {
  8222. if (!nextProps.hasOwnProperty(propKey)) {
  8223. continue;
  8224. }
  8225. var nextProp = nextProps[propKey];
  8226. if (propKey === STYLE$1) {
  8227. {
  8228. if (nextProp) {
  8229. // Freeze the next style object so that we can assume it won't be
  8230. // mutated. We have already warned for this in the past.
  8231. Object.freeze(nextProp);
  8232. }
  8233. }
  8234. // Relies on `updateStylesByID` not mutating `styleUpdates`.
  8235. setValueForStyles(domElement, nextProp);
  8236. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  8237. var nextHtml = nextProp ? nextProp[HTML] : undefined;
  8238. if (nextHtml != null) {
  8239. setInnerHTML(domElement, nextHtml);
  8240. }
  8241. } else if (propKey === CHILDREN) {
  8242. if (typeof nextProp === 'string') {
  8243. // Avoid setting initial textContent when the text is empty. In IE11 setting
  8244. // textContent on a <textarea> will cause the placeholder to not
  8245. // show within the <textarea> until it has been focused and blurred again.
  8246. // https://github.com/facebook/react/issues/6731#issuecomment-254874553
  8247. var canSetTextContent = tag !== 'textarea' || nextProp !== '';
  8248. if (canSetTextContent) {
  8249. setTextContent(domElement, nextProp);
  8250. }
  8251. } else if (typeof nextProp === 'number') {
  8252. setTextContent(domElement, '' + nextProp);
  8253. }
  8254. } else if (enableFlareAPI && propKey === LISTENERS || propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {
  8255. // Noop
  8256. } else if (propKey === AUTOFOCUS) {
  8257. // We polyfill it separately on the client during commit.
  8258. // We could have excluded it in the property list instead of
  8259. // adding a special case here, but then it wouldn't be emitted
  8260. // on server rendering (but we *do* want to emit it in SSR).
  8261. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  8262. if (nextProp != null) {
  8263. if ( true && typeof nextProp !== 'function') {
  8264. warnForInvalidEventListener(propKey, nextProp);
  8265. }
  8266. ensureListeningTo(rootContainerElement, propKey);
  8267. }
  8268. } else if (nextProp != null) {
  8269. setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag);
  8270. }
  8271. }
  8272. }
  8273. function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) {
  8274. // TODO: Handle wasCustomComponentTag
  8275. for (var i = 0; i < updatePayload.length; i += 2) {
  8276. var propKey = updatePayload[i];
  8277. var propValue = updatePayload[i + 1];
  8278. if (propKey === STYLE$1) {
  8279. setValueForStyles(domElement, propValue);
  8280. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  8281. setInnerHTML(domElement, propValue);
  8282. } else if (propKey === CHILDREN) {
  8283. setTextContent(domElement, propValue);
  8284. } else {
  8285. setValueForProperty(domElement, propKey, propValue, isCustomComponentTag);
  8286. }
  8287. }
  8288. }
  8289. function createElement(type, props, rootContainerElement, parentNamespace) {
  8290. var isCustomComponentTag = void 0;
  8291. // We create tags in the namespace of their parent container, except HTML
  8292. // tags get no namespace.
  8293. var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement);
  8294. var domElement = void 0;
  8295. var namespaceURI = parentNamespace;
  8296. if (namespaceURI === HTML_NAMESPACE) {
  8297. namespaceURI = getIntrinsicNamespace(type);
  8298. }
  8299. if (namespaceURI === HTML_NAMESPACE) {
  8300. {
  8301. isCustomComponentTag = isCustomComponent(type, props);
  8302. // Should this check be gated by parent namespace? Not sure we want to
  8303. // allow <SVG> or <mATH>.
  8304. !(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;
  8305. }
  8306. if (type === 'script') {
  8307. // Create the script via .innerHTML so its "parser-inserted" flag is
  8308. // set to true and it does not execute
  8309. var div = ownerDocument.createElement('div');
  8310. div.innerHTML = '<script><' + '/script>'; // eslint-disable-line
  8311. // This is guaranteed to yield a script element.
  8312. var firstChild = div.firstChild;
  8313. domElement = div.removeChild(firstChild);
  8314. } else if (typeof props.is === 'string') {
  8315. // $FlowIssue `createElement` should be updated for Web Components
  8316. domElement = ownerDocument.createElement(type, { is: props.is });
  8317. } else {
  8318. // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug.
  8319. // See discussion in https://github.com/facebook/react/pull/6896
  8320. // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
  8321. domElement = ownerDocument.createElement(type);
  8322. // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple` and `size`
  8323. // attributes on `select`s needs to be added before `option`s are inserted.
  8324. // This prevents:
  8325. // - a bug where the `select` does not scroll to the correct option because singular
  8326. // `select` elements automatically pick the first item #13222
  8327. // - a bug where the `select` set the first item as selected despite the `size` attribute #14239
  8328. // See https://github.com/facebook/react/issues/13222
  8329. // and https://github.com/facebook/react/issues/14239
  8330. if (type === 'select') {
  8331. var node = domElement;
  8332. if (props.multiple) {
  8333. node.multiple = true;
  8334. } else if (props.size) {
  8335. // Setting a size greater than 1 causes a select to behave like `multiple=true`, where
  8336. // it is possible that no option is selected.
  8337. //
  8338. // This is only necessary when a select in "single selection mode".
  8339. node.size = props.size;
  8340. }
  8341. }
  8342. }
  8343. } else {
  8344. domElement = ownerDocument.createElementNS(namespaceURI, type);
  8345. }
  8346. {
  8347. if (namespaceURI === HTML_NAMESPACE) {
  8348. if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) {
  8349. warnedUnknownTags[type] = true;
  8350. 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);
  8351. }
  8352. }
  8353. }
  8354. return domElement;
  8355. }
  8356. function createTextNode(text, rootContainerElement) {
  8357. return getOwnerDocumentFromRootContainer(rootContainerElement).createTextNode(text);
  8358. }
  8359. function setInitialProperties(domElement, tag, rawProps, rootContainerElement) {
  8360. var isCustomComponentTag = isCustomComponent(tag, rawProps);
  8361. {
  8362. validatePropertiesInDevelopment(tag, rawProps);
  8363. if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) {
  8364. warning$1(false, '%s is using shady DOM. Using shady DOM with React can ' + 'cause things to break subtly.', getCurrentFiberOwnerNameInDevOrNull() || 'A component');
  8365. didWarnShadyDOM = true;
  8366. }
  8367. }
  8368. // TODO: Make sure that we check isMounted before firing any of these events.
  8369. var props = void 0;
  8370. switch (tag) {
  8371. case 'iframe':
  8372. case 'object':
  8373. case 'embed':
  8374. trapBubbledEvent(TOP_LOAD, domElement);
  8375. props = rawProps;
  8376. break;
  8377. case 'video':
  8378. case 'audio':
  8379. // Create listener for each media event
  8380. for (var i = 0; i < mediaEventTypes.length; i++) {
  8381. trapBubbledEvent(mediaEventTypes[i], domElement);
  8382. }
  8383. props = rawProps;
  8384. break;
  8385. case 'source':
  8386. trapBubbledEvent(TOP_ERROR, domElement);
  8387. props = rawProps;
  8388. break;
  8389. case 'img':
  8390. case 'image':
  8391. case 'link':
  8392. trapBubbledEvent(TOP_ERROR, domElement);
  8393. trapBubbledEvent(TOP_LOAD, domElement);
  8394. props = rawProps;
  8395. break;
  8396. case 'form':
  8397. trapBubbledEvent(TOP_RESET, domElement);
  8398. trapBubbledEvent(TOP_SUBMIT, domElement);
  8399. props = rawProps;
  8400. break;
  8401. case 'details':
  8402. trapBubbledEvent(TOP_TOGGLE, domElement);
  8403. props = rawProps;
  8404. break;
  8405. case 'input':
  8406. initWrapperState(domElement, rawProps);
  8407. props = getHostProps(domElement, rawProps);
  8408. trapBubbledEvent(TOP_INVALID, domElement);
  8409. // For controlled components we always need to ensure we're listening
  8410. // to onChange. Even if there is no listener.
  8411. ensureListeningTo(rootContainerElement, 'onChange');
  8412. break;
  8413. case 'option':
  8414. validateProps(domElement, rawProps);
  8415. props = getHostProps$1(domElement, rawProps);
  8416. break;
  8417. case 'select':
  8418. initWrapperState$1(domElement, rawProps);
  8419. props = getHostProps$2(domElement, rawProps);
  8420. trapBubbledEvent(TOP_INVALID, domElement);
  8421. // For controlled components we always need to ensure we're listening
  8422. // to onChange. Even if there is no listener.
  8423. ensureListeningTo(rootContainerElement, 'onChange');
  8424. break;
  8425. case 'textarea':
  8426. initWrapperState$2(domElement, rawProps);
  8427. props = getHostProps$3(domElement, rawProps);
  8428. trapBubbledEvent(TOP_INVALID, domElement);
  8429. // For controlled components we always need to ensure we're listening
  8430. // to onChange. Even if there is no listener.
  8431. ensureListeningTo(rootContainerElement, 'onChange');
  8432. break;
  8433. default:
  8434. props = rawProps;
  8435. }
  8436. assertValidProps(tag, props);
  8437. setInitialDOMProperties(tag, domElement, rootContainerElement, props, isCustomComponentTag);
  8438. switch (tag) {
  8439. case 'input':
  8440. // TODO: Make sure we check if this is still unmounted or do any clean
  8441. // up necessary since we never stop tracking anymore.
  8442. track(domElement);
  8443. postMountWrapper(domElement, rawProps, false);
  8444. break;
  8445. case 'textarea':
  8446. // TODO: Make sure we check if this is still unmounted or do any clean
  8447. // up necessary since we never stop tracking anymore.
  8448. track(domElement);
  8449. postMountWrapper$3(domElement, rawProps);
  8450. break;
  8451. case 'option':
  8452. postMountWrapper$1(domElement, rawProps);
  8453. break;
  8454. case 'select':
  8455. postMountWrapper$2(domElement, rawProps);
  8456. break;
  8457. default:
  8458. if (typeof props.onClick === 'function') {
  8459. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  8460. trapClickOnNonInteractiveElement(domElement);
  8461. }
  8462. break;
  8463. }
  8464. }
  8465. // Calculate the diff between the two objects.
  8466. function diffProperties(domElement, tag, lastRawProps, nextRawProps, rootContainerElement) {
  8467. {
  8468. validatePropertiesInDevelopment(tag, nextRawProps);
  8469. }
  8470. var updatePayload = null;
  8471. var lastProps = void 0;
  8472. var nextProps = void 0;
  8473. switch (tag) {
  8474. case 'input':
  8475. lastProps = getHostProps(domElement, lastRawProps);
  8476. nextProps = getHostProps(domElement, nextRawProps);
  8477. updatePayload = [];
  8478. break;
  8479. case 'option':
  8480. lastProps = getHostProps$1(domElement, lastRawProps);
  8481. nextProps = getHostProps$1(domElement, nextRawProps);
  8482. updatePayload = [];
  8483. break;
  8484. case 'select':
  8485. lastProps = getHostProps$2(domElement, lastRawProps);
  8486. nextProps = getHostProps$2(domElement, nextRawProps);
  8487. updatePayload = [];
  8488. break;
  8489. case 'textarea':
  8490. lastProps = getHostProps$3(domElement, lastRawProps);
  8491. nextProps = getHostProps$3(domElement, nextRawProps);
  8492. updatePayload = [];
  8493. break;
  8494. default:
  8495. lastProps = lastRawProps;
  8496. nextProps = nextRawProps;
  8497. if (typeof lastProps.onClick !== 'function' && typeof nextProps.onClick === 'function') {
  8498. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  8499. trapClickOnNonInteractiveElement(domElement);
  8500. }
  8501. break;
  8502. }
  8503. assertValidProps(tag, nextProps);
  8504. var propKey = void 0;
  8505. var styleName = void 0;
  8506. var styleUpdates = null;
  8507. for (propKey in lastProps) {
  8508. if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) {
  8509. continue;
  8510. }
  8511. if (propKey === STYLE$1) {
  8512. var lastStyle = lastProps[propKey];
  8513. for (styleName in lastStyle) {
  8514. if (lastStyle.hasOwnProperty(styleName)) {
  8515. if (!styleUpdates) {
  8516. styleUpdates = {};
  8517. }
  8518. styleUpdates[styleName] = '';
  8519. }
  8520. }
  8521. } else if (propKey === DANGEROUSLY_SET_INNER_HTML || propKey === CHILDREN) {
  8522. // Noop. This is handled by the clear text mechanism.
  8523. } else if (enableFlareAPI && propKey === LISTENERS || propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {
  8524. // Noop
  8525. } else if (propKey === AUTOFOCUS) {
  8526. // Noop. It doesn't work on updates anyway.
  8527. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  8528. // This is a special case. If any listener updates we need to ensure
  8529. // that the "current" fiber pointer gets updated so we need a commit
  8530. // to update this element.
  8531. if (!updatePayload) {
  8532. updatePayload = [];
  8533. }
  8534. } else {
  8535. // For all other deleted properties we add it to the queue. We use
  8536. // the whitelist in the commit phase instead.
  8537. (updatePayload = updatePayload || []).push(propKey, null);
  8538. }
  8539. }
  8540. for (propKey in nextProps) {
  8541. var nextProp = nextProps[propKey];
  8542. var lastProp = lastProps != null ? lastProps[propKey] : undefined;
  8543. if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) {
  8544. continue;
  8545. }
  8546. if (propKey === STYLE$1) {
  8547. {
  8548. if (nextProp) {
  8549. // Freeze the next style object so that we can assume it won't be
  8550. // mutated. We have already warned for this in the past.
  8551. Object.freeze(nextProp);
  8552. }
  8553. }
  8554. if (lastProp) {
  8555. // Unset styles on `lastProp` but not on `nextProp`.
  8556. for (styleName in lastProp) {
  8557. if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) {
  8558. if (!styleUpdates) {
  8559. styleUpdates = {};
  8560. }
  8561. styleUpdates[styleName] = '';
  8562. }
  8563. }
  8564. // Update styles that changed since `lastProp`.
  8565. for (styleName in nextProp) {
  8566. if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) {
  8567. if (!styleUpdates) {
  8568. styleUpdates = {};
  8569. }
  8570. styleUpdates[styleName] = nextProp[styleName];
  8571. }
  8572. }
  8573. } else {
  8574. // Relies on `updateStylesByID` not mutating `styleUpdates`.
  8575. if (!styleUpdates) {
  8576. if (!updatePayload) {
  8577. updatePayload = [];
  8578. }
  8579. updatePayload.push(propKey, styleUpdates);
  8580. }
  8581. styleUpdates = nextProp;
  8582. }
  8583. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  8584. var nextHtml = nextProp ? nextProp[HTML] : undefined;
  8585. var lastHtml = lastProp ? lastProp[HTML] : undefined;
  8586. if (nextHtml != null) {
  8587. if (lastHtml !== nextHtml) {
  8588. (updatePayload = updatePayload || []).push(propKey, '' + nextHtml);
  8589. }
  8590. } else {
  8591. // TODO: It might be too late to clear this if we have children
  8592. // inserted already.
  8593. }
  8594. } else if (propKey === CHILDREN) {
  8595. if (lastProp !== nextProp && (typeof nextProp === 'string' || typeof nextProp === 'number')) {
  8596. (updatePayload = updatePayload || []).push(propKey, '' + nextProp);
  8597. }
  8598. } else if (enableFlareAPI && propKey === LISTENERS || propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1) {
  8599. // Noop
  8600. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  8601. if (nextProp != null) {
  8602. // We eagerly listen to this even though we haven't committed yet.
  8603. if ( true && typeof nextProp !== 'function') {
  8604. warnForInvalidEventListener(propKey, nextProp);
  8605. }
  8606. ensureListeningTo(rootContainerElement, propKey);
  8607. }
  8608. if (!updatePayload && lastProp !== nextProp) {
  8609. // This is a special case. If any listener updates we need to ensure
  8610. // that the "current" props pointer gets updated so we need a commit
  8611. // to update this element.
  8612. updatePayload = [];
  8613. }
  8614. } else {
  8615. // For any other property we always add it to the queue and then we
  8616. // filter it out using the whitelist during the commit.
  8617. (updatePayload = updatePayload || []).push(propKey, nextProp);
  8618. }
  8619. }
  8620. if (styleUpdates) {
  8621. {
  8622. validateShorthandPropertyCollisionInDev(styleUpdates, nextProps[STYLE$1]);
  8623. }
  8624. (updatePayload = updatePayload || []).push(STYLE$1, styleUpdates);
  8625. }
  8626. return updatePayload;
  8627. }
  8628. // Apply the diff.
  8629. function updateProperties(domElement, updatePayload, tag, lastRawProps, nextRawProps) {
  8630. // Update checked *before* name.
  8631. // In the middle of an update, it is possible to have multiple checked.
  8632. // When a checked radio tries to change name, browser makes another radio's checked false.
  8633. if (tag === 'input' && nextRawProps.type === 'radio' && nextRawProps.name != null) {
  8634. updateChecked(domElement, nextRawProps);
  8635. }
  8636. var wasCustomComponentTag = isCustomComponent(tag, lastRawProps);
  8637. var isCustomComponentTag = isCustomComponent(tag, nextRawProps);
  8638. // Apply the diff.
  8639. updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag);
  8640. // TODO: Ensure that an update gets scheduled if any of the special props
  8641. // changed.
  8642. switch (tag) {
  8643. case 'input':
  8644. // Update the wrapper around inputs *after* updating props. This has to
  8645. // happen after `updateDOMProperties`. Otherwise HTML5 input validations
  8646. // raise warnings and prevent the new value from being assigned.
  8647. updateWrapper(domElement, nextRawProps);
  8648. break;
  8649. case 'textarea':
  8650. updateWrapper$1(domElement, nextRawProps);
  8651. break;
  8652. case 'select':
  8653. // <select> value update needs to occur after <option> children
  8654. // reconciliation
  8655. postUpdateWrapper(domElement, nextRawProps);
  8656. break;
  8657. }
  8658. }
  8659. function getPossibleStandardName(propName) {
  8660. {
  8661. var lowerCasedName = propName.toLowerCase();
  8662. if (!possibleStandardNames.hasOwnProperty(lowerCasedName)) {
  8663. return null;
  8664. }
  8665. return possibleStandardNames[lowerCasedName] || null;
  8666. }
  8667. return null;
  8668. }
  8669. function diffHydratedProperties(domElement, tag, rawProps, parentNamespace, rootContainerElement) {
  8670. var isCustomComponentTag = void 0;
  8671. var extraAttributeNames = void 0;
  8672. {
  8673. suppressHydrationWarning = rawProps[SUPPRESS_HYDRATION_WARNING$1] === true;
  8674. isCustomComponentTag = isCustomComponent(tag, rawProps);
  8675. validatePropertiesInDevelopment(tag, rawProps);
  8676. if (isCustomComponentTag && !didWarnShadyDOM && domElement.shadyRoot) {
  8677. warning$1(false, '%s is using shady DOM. Using shady DOM with React can ' + 'cause things to break subtly.', getCurrentFiberOwnerNameInDevOrNull() || 'A component');
  8678. didWarnShadyDOM = true;
  8679. }
  8680. }
  8681. // TODO: Make sure that we check isMounted before firing any of these events.
  8682. switch (tag) {
  8683. case 'iframe':
  8684. case 'object':
  8685. case 'embed':
  8686. trapBubbledEvent(TOP_LOAD, domElement);
  8687. break;
  8688. case 'video':
  8689. case 'audio':
  8690. // Create listener for each media event
  8691. for (var i = 0; i < mediaEventTypes.length; i++) {
  8692. trapBubbledEvent(mediaEventTypes[i], domElement);
  8693. }
  8694. break;
  8695. case 'source':
  8696. trapBubbledEvent(TOP_ERROR, domElement);
  8697. break;
  8698. case 'img':
  8699. case 'image':
  8700. case 'link':
  8701. trapBubbledEvent(TOP_ERROR, domElement);
  8702. trapBubbledEvent(TOP_LOAD, domElement);
  8703. break;
  8704. case 'form':
  8705. trapBubbledEvent(TOP_RESET, domElement);
  8706. trapBubbledEvent(TOP_SUBMIT, domElement);
  8707. break;
  8708. case 'details':
  8709. trapBubbledEvent(TOP_TOGGLE, domElement);
  8710. break;
  8711. case 'input':
  8712. initWrapperState(domElement, rawProps);
  8713. trapBubbledEvent(TOP_INVALID, domElement);
  8714. // For controlled components we always need to ensure we're listening
  8715. // to onChange. Even if there is no listener.
  8716. ensureListeningTo(rootContainerElement, 'onChange');
  8717. break;
  8718. case 'option':
  8719. validateProps(domElement, rawProps);
  8720. break;
  8721. case 'select':
  8722. initWrapperState$1(domElement, rawProps);
  8723. trapBubbledEvent(TOP_INVALID, domElement);
  8724. // For controlled components we always need to ensure we're listening
  8725. // to onChange. Even if there is no listener.
  8726. ensureListeningTo(rootContainerElement, 'onChange');
  8727. break;
  8728. case 'textarea':
  8729. initWrapperState$2(domElement, rawProps);
  8730. trapBubbledEvent(TOP_INVALID, domElement);
  8731. // For controlled components we always need to ensure we're listening
  8732. // to onChange. Even if there is no listener.
  8733. ensureListeningTo(rootContainerElement, 'onChange');
  8734. break;
  8735. }
  8736. assertValidProps(tag, rawProps);
  8737. {
  8738. extraAttributeNames = new Set();
  8739. var attributes = domElement.attributes;
  8740. for (var _i = 0; _i < attributes.length; _i++) {
  8741. var name = attributes[_i].name.toLowerCase();
  8742. switch (name) {
  8743. // Built-in SSR attribute is whitelisted
  8744. case 'data-reactroot':
  8745. break;
  8746. // Controlled attributes are not validated
  8747. // TODO: Only ignore them on controlled tags.
  8748. case 'value':
  8749. break;
  8750. case 'checked':
  8751. break;
  8752. case 'selected':
  8753. break;
  8754. default:
  8755. // Intentionally use the original name.
  8756. // See discussion in https://github.com/facebook/react/pull/10676.
  8757. extraAttributeNames.add(attributes[_i].name);
  8758. }
  8759. }
  8760. }
  8761. var updatePayload = null;
  8762. for (var propKey in rawProps) {
  8763. if (!rawProps.hasOwnProperty(propKey)) {
  8764. continue;
  8765. }
  8766. var nextProp = rawProps[propKey];
  8767. if (propKey === CHILDREN) {
  8768. // For text content children we compare against textContent. This
  8769. // might match additional HTML that is hidden when we read it using
  8770. // textContent. E.g. "foo" will match "f<span>oo</span>" but that still
  8771. // satisfies our requirement. Our requirement is not to produce perfect
  8772. // HTML and attributes. Ideally we should preserve structure but it's
  8773. // ok not to if the visible content is still enough to indicate what
  8774. // even listeners these nodes might be wired up to.
  8775. // TODO: Warn if there is more than a single textNode as a child.
  8776. // TODO: Should we use domElement.firstChild.nodeValue to compare?
  8777. if (typeof nextProp === 'string') {
  8778. if (domElement.textContent !== nextProp) {
  8779. if ( true && !suppressHydrationWarning) {
  8780. warnForTextDifference(domElement.textContent, nextProp);
  8781. }
  8782. updatePayload = [CHILDREN, nextProp];
  8783. }
  8784. } else if (typeof nextProp === 'number') {
  8785. if (domElement.textContent !== '' + nextProp) {
  8786. if ( true && !suppressHydrationWarning) {
  8787. warnForTextDifference(domElement.textContent, nextProp);
  8788. }
  8789. updatePayload = [CHILDREN, '' + nextProp];
  8790. }
  8791. }
  8792. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  8793. if (nextProp != null) {
  8794. if ( true && typeof nextProp !== 'function') {
  8795. warnForInvalidEventListener(propKey, nextProp);
  8796. }
  8797. ensureListeningTo(rootContainerElement, propKey);
  8798. }
  8799. } else if ( true &&
  8800. // Convince Flow we've calculated it (it's DEV-only in this method.)
  8801. typeof isCustomComponentTag === 'boolean') {
  8802. // Validate that the properties correspond to their expected values.
  8803. var serverValue = void 0;
  8804. var propertyInfo = getPropertyInfo(propKey);
  8805. if (suppressHydrationWarning) {
  8806. // Don't bother comparing. We're ignoring all these warnings.
  8807. } else if (enableFlareAPI && propKey === LISTENERS || propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING$1 ||
  8808. // Controlled attributes are not validated
  8809. // TODO: Only ignore them on controlled tags.
  8810. propKey === 'value' || propKey === 'checked' || propKey === 'selected') {
  8811. // Noop
  8812. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  8813. var serverHTML = domElement.innerHTML;
  8814. var nextHtml = nextProp ? nextProp[HTML] : undefined;
  8815. var expectedHTML = normalizeHTML(domElement, nextHtml != null ? nextHtml : '');
  8816. if (expectedHTML !== serverHTML) {
  8817. warnForPropDifference(propKey, serverHTML, expectedHTML);
  8818. }
  8819. } else if (propKey === STYLE$1) {
  8820. // $FlowFixMe - Should be inferred as not undefined.
  8821. extraAttributeNames.delete(propKey);
  8822. if (canDiffStyleForHydrationWarning) {
  8823. var expectedStyle = createDangerousStringForStyles(nextProp);
  8824. serverValue = domElement.getAttribute('style');
  8825. if (expectedStyle !== serverValue) {
  8826. warnForPropDifference(propKey, serverValue, expectedStyle);
  8827. }
  8828. }
  8829. } else if (isCustomComponentTag) {
  8830. // $FlowFixMe - Should be inferred as not undefined.
  8831. extraAttributeNames.delete(propKey.toLowerCase());
  8832. serverValue = getValueForAttribute(domElement, propKey, nextProp);
  8833. if (nextProp !== serverValue) {
  8834. warnForPropDifference(propKey, serverValue, nextProp);
  8835. }
  8836. } else if (!shouldIgnoreAttribute(propKey, propertyInfo, isCustomComponentTag) && !shouldRemoveAttribute(propKey, nextProp, propertyInfo, isCustomComponentTag)) {
  8837. var isMismatchDueToBadCasing = false;
  8838. if (propertyInfo !== null) {
  8839. // $FlowFixMe - Should be inferred as not undefined.
  8840. extraAttributeNames.delete(propertyInfo.attributeName);
  8841. serverValue = getValueForProperty(domElement, propKey, nextProp, propertyInfo);
  8842. } else {
  8843. var ownNamespace = parentNamespace;
  8844. if (ownNamespace === HTML_NAMESPACE) {
  8845. ownNamespace = getIntrinsicNamespace(tag);
  8846. }
  8847. if (ownNamespace === HTML_NAMESPACE) {
  8848. // $FlowFixMe - Should be inferred as not undefined.
  8849. extraAttributeNames.delete(propKey.toLowerCase());
  8850. } else {
  8851. var standardName = getPossibleStandardName(propKey);
  8852. if (standardName !== null && standardName !== propKey) {
  8853. // If an SVG prop is supplied with bad casing, it will
  8854. // be successfully parsed from HTML, but will produce a mismatch
  8855. // (and would be incorrectly rendered on the client).
  8856. // However, we already warn about bad casing elsewhere.
  8857. // So we'll skip the misleading extra mismatch warning in this case.
  8858. isMismatchDueToBadCasing = true;
  8859. // $FlowFixMe - Should be inferred as not undefined.
  8860. extraAttributeNames.delete(standardName);
  8861. }
  8862. // $FlowFixMe - Should be inferred as not undefined.
  8863. extraAttributeNames.delete(propKey);
  8864. }
  8865. serverValue = getValueForAttribute(domElement, propKey, nextProp);
  8866. }
  8867. if (nextProp !== serverValue && !isMismatchDueToBadCasing) {
  8868. warnForPropDifference(propKey, serverValue, nextProp);
  8869. }
  8870. }
  8871. }
  8872. }
  8873. {
  8874. // $FlowFixMe - Should be inferred as not undefined.
  8875. if (extraAttributeNames.size > 0 && !suppressHydrationWarning) {
  8876. // $FlowFixMe - Should be inferred as not undefined.
  8877. warnForExtraAttributes(extraAttributeNames);
  8878. }
  8879. }
  8880. switch (tag) {
  8881. case 'input':
  8882. // TODO: Make sure we check if this is still unmounted or do any clean
  8883. // up necessary since we never stop tracking anymore.
  8884. track(domElement);
  8885. postMountWrapper(domElement, rawProps, true);
  8886. break;
  8887. case 'textarea':
  8888. // TODO: Make sure we check if this is still unmounted or do any clean
  8889. // up necessary since we never stop tracking anymore.
  8890. track(domElement);
  8891. postMountWrapper$3(domElement, rawProps);
  8892. break;
  8893. case 'select':
  8894. case 'option':
  8895. // For input and textarea we current always set the value property at
  8896. // post mount to force it to diverge from attributes. However, for
  8897. // option and select we don't quite do the same thing and select
  8898. // is not resilient to the DOM state changing so we don't do that here.
  8899. // TODO: Consider not doing this for input and textarea.
  8900. break;
  8901. default:
  8902. if (typeof rawProps.onClick === 'function') {
  8903. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  8904. trapClickOnNonInteractiveElement(domElement);
  8905. }
  8906. break;
  8907. }
  8908. return updatePayload;
  8909. }
  8910. function diffHydratedText(textNode, text) {
  8911. var isDifferent = textNode.nodeValue !== text;
  8912. return isDifferent;
  8913. }
  8914. function warnForUnmatchedText(textNode, text) {
  8915. {
  8916. warnForTextDifference(textNode.nodeValue, text);
  8917. }
  8918. }
  8919. function warnForDeletedHydratableElement(parentNode, child) {
  8920. {
  8921. if (didWarnInvalidHydration) {
  8922. return;
  8923. }
  8924. didWarnInvalidHydration = true;
  8925. warningWithoutStack$1(false, 'Did not expect server HTML to contain a <%s> in <%s>.', child.nodeName.toLowerCase(), parentNode.nodeName.toLowerCase());
  8926. }
  8927. }
  8928. function warnForDeletedHydratableText(parentNode, child) {
  8929. {
  8930. if (didWarnInvalidHydration) {
  8931. return;
  8932. }
  8933. didWarnInvalidHydration = true;
  8934. warningWithoutStack$1(false, 'Did not expect server HTML to contain the text node "%s" in <%s>.', child.nodeValue, parentNode.nodeName.toLowerCase());
  8935. }
  8936. }
  8937. function warnForInsertedHydratedElement(parentNode, tag, props) {
  8938. {
  8939. if (didWarnInvalidHydration) {
  8940. return;
  8941. }
  8942. didWarnInvalidHydration = true;
  8943. warningWithoutStack$1(false, 'Expected server HTML to contain a matching <%s> in <%s>.', tag, parentNode.nodeName.toLowerCase());
  8944. }
  8945. }
  8946. function warnForInsertedHydratedText(parentNode, text) {
  8947. {
  8948. if (text === '') {
  8949. // We expect to insert empty text nodes since they're not represented in
  8950. // the HTML.
  8951. // TODO: Remove this special case if we can just avoid inserting empty
  8952. // text nodes.
  8953. return;
  8954. }
  8955. if (didWarnInvalidHydration) {
  8956. return;
  8957. }
  8958. didWarnInvalidHydration = true;
  8959. warningWithoutStack$1(false, 'Expected server HTML to contain a matching text node for "%s" in <%s>.', text, parentNode.nodeName.toLowerCase());
  8960. }
  8961. }
  8962. function restoreControlledState$1(domElement, tag, props) {
  8963. switch (tag) {
  8964. case 'input':
  8965. restoreControlledState(domElement, props);
  8966. return;
  8967. case 'textarea':
  8968. restoreControlledState$3(domElement, props);
  8969. return;
  8970. case 'select':
  8971. restoreControlledState$2(domElement, props);
  8972. return;
  8973. }
  8974. }
  8975. function listenToEventResponderEventTypes(eventTypes, element) {
  8976. if (enableFlareAPI) {
  8977. // Get the listening Set for this element. We use this to track
  8978. // what events we're listening to.
  8979. var listeningSet = getListeningSetForElement(element);
  8980. // Go through each target event type of the event responder
  8981. for (var i = 0, length = eventTypes.length; i < length; ++i) {
  8982. var eventType = eventTypes[i];
  8983. var isPassive = !endsWith(eventType, '_active');
  8984. var eventKey = isPassive ? eventType + '_passive' : eventType;
  8985. var targetEventType = isPassive ? eventType : eventType.substring(0, eventType.length - 7);
  8986. if (!listeningSet.has(eventKey)) {
  8987. trapEventForResponderEventSystem(element, targetEventType, isPassive);
  8988. listeningSet.add(eventKey);
  8989. }
  8990. }
  8991. }
  8992. }
  8993. // We can remove this once the event API is stable and out of a flag
  8994. if (enableFlareAPI) {
  8995. setListenToResponderEventTypes(listenToEventResponderEventTypes);
  8996. }
  8997. // TODO: direct imports like some-package/src/* are bad. Fix me.
  8998. var validateDOMNesting = function () {};
  8999. var updatedAncestorInfo = function () {};
  9000. {
  9001. // This validation code was written based on the HTML5 parsing spec:
  9002. // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope
  9003. //
  9004. // Note: this does not catch all invalid nesting, nor does it try to (as it's
  9005. // not clear what practical benefit doing so provides); instead, we warn only
  9006. // for cases where the parser will give a parse tree differing from what React
  9007. // intended. For example, <b><div></div></b> is invalid but we don't warn
  9008. // because it still parses correctly; we do warn for other cases like nested
  9009. // <p> tags where the beginning of the second element implicitly closes the
  9010. // first, causing a confusing mess.
  9011. // https://html.spec.whatwg.org/multipage/syntax.html#special
  9012. 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'];
  9013. // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope
  9014. var inScopeTags = ['applet', 'caption', 'html', 'table', 'td', 'th', 'marquee', 'object', 'template',
  9015. // https://html.spec.whatwg.org/multipage/syntax.html#html-integration-point
  9016. // TODO: Distinguish by namespace here -- for <title>, including it here
  9017. // errs on the side of fewer warnings
  9018. 'foreignObject', 'desc', 'title'];
  9019. // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-button-scope
  9020. var buttonScopeTags = inScopeTags.concat(['button']);
  9021. // https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags
  9022. var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt'];
  9023. var emptyAncestorInfo = {
  9024. current: null,
  9025. formTag: null,
  9026. aTagInScope: null,
  9027. buttonTagInScope: null,
  9028. nobrTagInScope: null,
  9029. pTagInButtonScope: null,
  9030. listItemTagAutoclosing: null,
  9031. dlItemTagAutoclosing: null
  9032. };
  9033. updatedAncestorInfo = function (oldInfo, tag) {
  9034. var ancestorInfo = _assign({}, oldInfo || emptyAncestorInfo);
  9035. var info = { tag: tag };
  9036. if (inScopeTags.indexOf(tag) !== -1) {
  9037. ancestorInfo.aTagInScope = null;
  9038. ancestorInfo.buttonTagInScope = null;
  9039. ancestorInfo.nobrTagInScope = null;
  9040. }
  9041. if (buttonScopeTags.indexOf(tag) !== -1) {
  9042. ancestorInfo.pTagInButtonScope = null;
  9043. }
  9044. // See rules for 'li', 'dd', 'dt' start tags in
  9045. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
  9046. if (specialTags.indexOf(tag) !== -1 && tag !== 'address' && tag !== 'div' && tag !== 'p') {
  9047. ancestorInfo.listItemTagAutoclosing = null;
  9048. ancestorInfo.dlItemTagAutoclosing = null;
  9049. }
  9050. ancestorInfo.current = info;
  9051. if (tag === 'form') {
  9052. ancestorInfo.formTag = info;
  9053. }
  9054. if (tag === 'a') {
  9055. ancestorInfo.aTagInScope = info;
  9056. }
  9057. if (tag === 'button') {
  9058. ancestorInfo.buttonTagInScope = info;
  9059. }
  9060. if (tag === 'nobr') {
  9061. ancestorInfo.nobrTagInScope = info;
  9062. }
  9063. if (tag === 'p') {
  9064. ancestorInfo.pTagInButtonScope = info;
  9065. }
  9066. if (tag === 'li') {
  9067. ancestorInfo.listItemTagAutoclosing = info;
  9068. }
  9069. if (tag === 'dd' || tag === 'dt') {
  9070. ancestorInfo.dlItemTagAutoclosing = info;
  9071. }
  9072. return ancestorInfo;
  9073. };
  9074. /**
  9075. * Returns whether
  9076. */
  9077. var isTagValidWithParent = function (tag, parentTag) {
  9078. // First, let's check if we're in an unusual parsing mode...
  9079. switch (parentTag) {
  9080. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect
  9081. case 'select':
  9082. return tag === 'option' || tag === 'optgroup' || tag === '#text';
  9083. case 'optgroup':
  9084. return tag === 'option' || tag === '#text';
  9085. // Strictly speaking, seeing an <option> doesn't mean we're in a <select>
  9086. // but
  9087. case 'option':
  9088. return tag === '#text';
  9089. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd
  9090. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption
  9091. // No special behavior since these rules fall back to "in body" mode for
  9092. // all except special table nodes which cause bad parsing behavior anyway.
  9093. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr
  9094. case 'tr':
  9095. return tag === 'th' || tag === 'td' || tag === 'style' || tag === 'script' || tag === 'template';
  9096. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody
  9097. case 'tbody':
  9098. case 'thead':
  9099. case 'tfoot':
  9100. return tag === 'tr' || tag === 'style' || tag === 'script' || tag === 'template';
  9101. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup
  9102. case 'colgroup':
  9103. return tag === 'col' || tag === 'template';
  9104. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable
  9105. case 'table':
  9106. return tag === 'caption' || tag === 'colgroup' || tag === 'tbody' || tag === 'tfoot' || tag === 'thead' || tag === 'style' || tag === 'script' || tag === 'template';
  9107. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead
  9108. case 'head':
  9109. return tag === 'base' || tag === 'basefont' || tag === 'bgsound' || tag === 'link' || tag === 'meta' || tag === 'title' || tag === 'noscript' || tag === 'noframes' || tag === 'style' || tag === 'script' || tag === 'template';
  9110. // https://html.spec.whatwg.org/multipage/semantics.html#the-html-element
  9111. case 'html':
  9112. return tag === 'head' || tag === 'body' || tag === 'frameset';
  9113. case 'frameset':
  9114. return tag === 'frame';
  9115. case '#document':
  9116. return tag === 'html';
  9117. }
  9118. // Probably in the "in body" parsing mode, so we outlaw only tag combos
  9119. // where the parsing rules cause implicit opens or closes to be added.
  9120. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
  9121. switch (tag) {
  9122. case 'h1':
  9123. case 'h2':
  9124. case 'h3':
  9125. case 'h4':
  9126. case 'h5':
  9127. case 'h6':
  9128. return parentTag !== 'h1' && parentTag !== 'h2' && parentTag !== 'h3' && parentTag !== 'h4' && parentTag !== 'h5' && parentTag !== 'h6';
  9129. case 'rp':
  9130. case 'rt':
  9131. return impliedEndTags.indexOf(parentTag) === -1;
  9132. case 'body':
  9133. case 'caption':
  9134. case 'col':
  9135. case 'colgroup':
  9136. case 'frameset':
  9137. case 'frame':
  9138. case 'head':
  9139. case 'html':
  9140. case 'tbody':
  9141. case 'td':
  9142. case 'tfoot':
  9143. case 'th':
  9144. case 'thead':
  9145. case 'tr':
  9146. // These tags are only valid with a few parents that have special child
  9147. // parsing rules -- if we're down here, then none of those matched and
  9148. // so we allow it only if we don't know what the parent is, as all other
  9149. // cases are invalid.
  9150. return parentTag == null;
  9151. }
  9152. return true;
  9153. };
  9154. /**
  9155. * Returns whether
  9156. */
  9157. var findInvalidAncestorForTag = function (tag, ancestorInfo) {
  9158. switch (tag) {
  9159. case 'address':
  9160. case 'article':
  9161. case 'aside':
  9162. case 'blockquote':
  9163. case 'center':
  9164. case 'details':
  9165. case 'dialog':
  9166. case 'dir':
  9167. case 'div':
  9168. case 'dl':
  9169. case 'fieldset':
  9170. case 'figcaption':
  9171. case 'figure':
  9172. case 'footer':
  9173. case 'header':
  9174. case 'hgroup':
  9175. case 'main':
  9176. case 'menu':
  9177. case 'nav':
  9178. case 'ol':
  9179. case 'p':
  9180. case 'section':
  9181. case 'summary':
  9182. case 'ul':
  9183. case 'pre':
  9184. case 'listing':
  9185. case 'table':
  9186. case 'hr':
  9187. case 'xmp':
  9188. case 'h1':
  9189. case 'h2':
  9190. case 'h3':
  9191. case 'h4':
  9192. case 'h5':
  9193. case 'h6':
  9194. return ancestorInfo.pTagInButtonScope;
  9195. case 'form':
  9196. return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope;
  9197. case 'li':
  9198. return ancestorInfo.listItemTagAutoclosing;
  9199. case 'dd':
  9200. case 'dt':
  9201. return ancestorInfo.dlItemTagAutoclosing;
  9202. case 'button':
  9203. return ancestorInfo.buttonTagInScope;
  9204. case 'a':
  9205. // Spec says something about storing a list of markers, but it sounds
  9206. // equivalent to this check.
  9207. return ancestorInfo.aTagInScope;
  9208. case 'nobr':
  9209. return ancestorInfo.nobrTagInScope;
  9210. }
  9211. return null;
  9212. };
  9213. var didWarn$1 = {};
  9214. validateDOMNesting = function (childTag, childText, ancestorInfo) {
  9215. ancestorInfo = ancestorInfo || emptyAncestorInfo;
  9216. var parentInfo = ancestorInfo.current;
  9217. var parentTag = parentInfo && parentInfo.tag;
  9218. if (childText != null) {
  9219. !(childTag == null) ? warningWithoutStack$1(false, 'validateDOMNesting: when childText is passed, childTag should be null') : void 0;
  9220. childTag = '#text';
  9221. }
  9222. var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo;
  9223. var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo);
  9224. var invalidParentOrAncestor = invalidParent || invalidAncestor;
  9225. if (!invalidParentOrAncestor) {
  9226. return;
  9227. }
  9228. var ancestorTag = invalidParentOrAncestor.tag;
  9229. var addendum = getCurrentFiberStackInDev();
  9230. var warnKey = !!invalidParent + '|' + childTag + '|' + ancestorTag + '|' + addendum;
  9231. if (didWarn$1[warnKey]) {
  9232. return;
  9233. }
  9234. didWarn$1[warnKey] = true;
  9235. var tagDisplayName = childTag;
  9236. var whitespaceInfo = '';
  9237. if (childTag === '#text') {
  9238. if (/\S/.test(childText)) {
  9239. tagDisplayName = 'Text nodes';
  9240. } else {
  9241. tagDisplayName = 'Whitespace text nodes';
  9242. whitespaceInfo = " Make sure you don't have any extra whitespace between tags on " + 'each line of your source code.';
  9243. }
  9244. } else {
  9245. tagDisplayName = '<' + childTag + '>';
  9246. }
  9247. if (invalidParent) {
  9248. var info = '';
  9249. if (ancestorTag === 'table' && childTag === 'tr') {
  9250. info += ' Add a <tbody> to your code to match the DOM tree generated by ' + 'the browser.';
  9251. }
  9252. warningWithoutStack$1(false, 'validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s%s', tagDisplayName, ancestorTag, whitespaceInfo, info, addendum);
  9253. } else {
  9254. warningWithoutStack$1(false, 'validateDOMNesting(...): %s cannot appear as a descendant of ' + '<%s>.%s', tagDisplayName, ancestorTag, addendum);
  9255. }
  9256. };
  9257. }
  9258. // Renderers that don't support persistence
  9259. // can re-export everything from this module.
  9260. function shim() {
  9261. (function () {
  9262. {
  9263. {
  9264. throw ReactError(Error('The current renderer does not support persistence. This error is likely caused by a bug in React. Please file an issue.'));
  9265. }
  9266. }
  9267. })();
  9268. }
  9269. // Persistence (when unsupported)
  9270. var supportsPersistence = false;
  9271. var cloneInstance = shim;
  9272. var cloneFundamentalInstance = shim;
  9273. var createContainerChildSet = shim;
  9274. var appendChildToContainerChildSet = shim;
  9275. var finalizeContainerChildren = shim;
  9276. var replaceContainerChildren = shim;
  9277. var cloneHiddenInstance = shim;
  9278. var cloneHiddenTextInstance = shim;
  9279. var SUPPRESS_HYDRATION_WARNING = void 0;
  9280. {
  9281. SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning';
  9282. }
  9283. var SUSPENSE_START_DATA = '$';
  9284. var SUSPENSE_END_DATA = '/$';
  9285. var SUSPENSE_PENDING_START_DATA = '$?';
  9286. var SUSPENSE_FALLBACK_START_DATA = '$!';
  9287. var STYLE = 'style';
  9288. var eventsEnabled = null;
  9289. var selectionInformation = null;
  9290. function shouldAutoFocusHostComponent(type, props) {
  9291. switch (type) {
  9292. case 'button':
  9293. case 'input':
  9294. case 'select':
  9295. case 'textarea':
  9296. return !!props.autoFocus;
  9297. }
  9298. return false;
  9299. }
  9300. function getRootHostContext(rootContainerInstance) {
  9301. var type = void 0;
  9302. var namespace = void 0;
  9303. var nodeType = rootContainerInstance.nodeType;
  9304. switch (nodeType) {
  9305. case DOCUMENT_NODE:
  9306. case DOCUMENT_FRAGMENT_NODE:
  9307. {
  9308. type = nodeType === DOCUMENT_NODE ? '#document' : '#fragment';
  9309. var root = rootContainerInstance.documentElement;
  9310. namespace = root ? root.namespaceURI : getChildNamespace(null, '');
  9311. break;
  9312. }
  9313. default:
  9314. {
  9315. var container = nodeType === COMMENT_NODE ? rootContainerInstance.parentNode : rootContainerInstance;
  9316. var ownNamespace = container.namespaceURI || null;
  9317. type = container.tagName;
  9318. namespace = getChildNamespace(ownNamespace, type);
  9319. break;
  9320. }
  9321. }
  9322. {
  9323. var validatedTag = type.toLowerCase();
  9324. var _ancestorInfo = updatedAncestorInfo(null, validatedTag);
  9325. return { namespace: namespace, ancestorInfo: _ancestorInfo };
  9326. }
  9327. return namespace;
  9328. }
  9329. function getChildHostContext(parentHostContext, type, rootContainerInstance) {
  9330. {
  9331. var parentHostContextDev = parentHostContext;
  9332. var _namespace = getChildNamespace(parentHostContextDev.namespace, type);
  9333. var _ancestorInfo2 = updatedAncestorInfo(parentHostContextDev.ancestorInfo, type);
  9334. return { namespace: _namespace, ancestorInfo: _ancestorInfo2 };
  9335. }
  9336. var parentNamespace = parentHostContext;
  9337. return getChildNamespace(parentNamespace, type);
  9338. }
  9339. function getPublicInstance(instance) {
  9340. return instance;
  9341. }
  9342. function prepareForCommit(containerInfo) {
  9343. eventsEnabled = isEnabled();
  9344. selectionInformation = getSelectionInformation();
  9345. setEnabled(false);
  9346. }
  9347. function resetAfterCommit(containerInfo) {
  9348. restoreSelection(selectionInformation);
  9349. selectionInformation = null;
  9350. setEnabled(eventsEnabled);
  9351. eventsEnabled = null;
  9352. }
  9353. function createInstance(type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
  9354. var parentNamespace = void 0;
  9355. {
  9356. // TODO: take namespace into account when validating.
  9357. var hostContextDev = hostContext;
  9358. validateDOMNesting(type, null, hostContextDev.ancestorInfo);
  9359. if (typeof props.children === 'string' || typeof props.children === 'number') {
  9360. var string = '' + props.children;
  9361. var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type);
  9362. validateDOMNesting(null, string, ownAncestorInfo);
  9363. }
  9364. parentNamespace = hostContextDev.namespace;
  9365. }
  9366. var domElement = createElement(type, props, rootContainerInstance, parentNamespace);
  9367. precacheFiberNode(internalInstanceHandle, domElement);
  9368. updateFiberProps(domElement, props);
  9369. return domElement;
  9370. }
  9371. function appendInitialChild(parentInstance, child) {
  9372. parentInstance.appendChild(child);
  9373. }
  9374. function finalizeInitialChildren(domElement, type, props, rootContainerInstance, hostContext) {
  9375. setInitialProperties(domElement, type, props, rootContainerInstance);
  9376. return shouldAutoFocusHostComponent(type, props);
  9377. }
  9378. function prepareUpdate(domElement, type, oldProps, newProps, rootContainerInstance, hostContext) {
  9379. {
  9380. var hostContextDev = hostContext;
  9381. if (typeof newProps.children !== typeof oldProps.children && (typeof newProps.children === 'string' || typeof newProps.children === 'number')) {
  9382. var string = '' + newProps.children;
  9383. var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type);
  9384. validateDOMNesting(null, string, ownAncestorInfo);
  9385. }
  9386. }
  9387. return diffProperties(domElement, type, oldProps, newProps, rootContainerInstance);
  9388. }
  9389. function shouldSetTextContent(type, props) {
  9390. 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;
  9391. }
  9392. function shouldDeprioritizeSubtree(type, props) {
  9393. return !!props.hidden;
  9394. }
  9395. function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) {
  9396. {
  9397. var hostContextDev = hostContext;
  9398. validateDOMNesting(null, text, hostContextDev.ancestorInfo);
  9399. }
  9400. var textNode = createTextNode(text, rootContainerInstance);
  9401. precacheFiberNode(internalInstanceHandle, textNode);
  9402. return textNode;
  9403. }
  9404. var isPrimaryRenderer = true;
  9405. var warnsIfNotActing = true;
  9406. // This initialization code may run even on server environments
  9407. // if a component just imports ReactDOM (e.g. for findDOMNode).
  9408. // Some environments might not have setTimeout or clearTimeout.
  9409. var scheduleTimeout = typeof setTimeout === 'function' ? setTimeout : undefined;
  9410. var cancelTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined;
  9411. var noTimeout = -1;
  9412. // -------------------
  9413. // Mutation
  9414. // -------------------
  9415. var supportsMutation = true;
  9416. function commitMount(domElement, type, newProps, internalInstanceHandle) {
  9417. // Despite the naming that might imply otherwise, this method only
  9418. // fires if there is an `Update` effect scheduled during mounting.
  9419. // This happens if `finalizeInitialChildren` returns `true` (which it
  9420. // does to implement the `autoFocus` attribute on the client). But
  9421. // there are also other cases when this might happen (such as patching
  9422. // up text content during hydration mismatch). So we'll check this again.
  9423. if (shouldAutoFocusHostComponent(type, newProps)) {
  9424. domElement.focus();
  9425. }
  9426. }
  9427. function commitUpdate(domElement, updatePayload, type, oldProps, newProps, internalInstanceHandle) {
  9428. // Update the props handle so that we know which props are the ones with
  9429. // with current event handlers.
  9430. updateFiberProps(domElement, newProps);
  9431. // Apply the diff to the DOM node.
  9432. updateProperties(domElement, updatePayload, type, oldProps, newProps);
  9433. }
  9434. function resetTextContent(domElement) {
  9435. setTextContent(domElement, '');
  9436. }
  9437. function commitTextUpdate(textInstance, oldText, newText) {
  9438. textInstance.nodeValue = newText;
  9439. }
  9440. function appendChild(parentInstance, child) {
  9441. parentInstance.appendChild(child);
  9442. }
  9443. function appendChildToContainer(container, child) {
  9444. var parentNode = void 0;
  9445. if (container.nodeType === COMMENT_NODE) {
  9446. parentNode = container.parentNode;
  9447. parentNode.insertBefore(child, container);
  9448. } else {
  9449. parentNode = container;
  9450. parentNode.appendChild(child);
  9451. }
  9452. // This container might be used for a portal.
  9453. // If something inside a portal is clicked, that click should bubble
  9454. // through the React tree. However, on Mobile Safari the click would
  9455. // never bubble through the *DOM* tree unless an ancestor with onclick
  9456. // event exists. So we wouldn't see it and dispatch it.
  9457. // This is why we ensure that non React root containers have inline onclick
  9458. // defined.
  9459. // https://github.com/facebook/react/issues/11918
  9460. var reactRootContainer = container._reactRootContainer;
  9461. if ((reactRootContainer === null || reactRootContainer === undefined) && parentNode.onclick === null) {
  9462. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  9463. trapClickOnNonInteractiveElement(parentNode);
  9464. }
  9465. }
  9466. function insertBefore(parentInstance, child, beforeChild) {
  9467. parentInstance.insertBefore(child, beforeChild);
  9468. }
  9469. function insertInContainerBefore(container, child, beforeChild) {
  9470. if (container.nodeType === COMMENT_NODE) {
  9471. container.parentNode.insertBefore(child, beforeChild);
  9472. } else {
  9473. container.insertBefore(child, beforeChild);
  9474. }
  9475. }
  9476. function removeChild(parentInstance, child) {
  9477. parentInstance.removeChild(child);
  9478. }
  9479. function removeChildFromContainer(container, child) {
  9480. if (container.nodeType === COMMENT_NODE) {
  9481. container.parentNode.removeChild(child);
  9482. } else {
  9483. container.removeChild(child);
  9484. }
  9485. }
  9486. function clearSuspenseBoundary(parentInstance, suspenseInstance) {
  9487. var node = suspenseInstance;
  9488. // Delete all nodes within this suspense boundary.
  9489. // There might be nested nodes so we need to keep track of how
  9490. // deep we are and only break out when we're back on top.
  9491. var depth = 0;
  9492. do {
  9493. var nextNode = node.nextSibling;
  9494. parentInstance.removeChild(node);
  9495. if (nextNode && nextNode.nodeType === COMMENT_NODE) {
  9496. var data = nextNode.data;
  9497. if (data === SUSPENSE_END_DATA) {
  9498. if (depth === 0) {
  9499. parentInstance.removeChild(nextNode);
  9500. return;
  9501. } else {
  9502. depth--;
  9503. }
  9504. } else if (data === SUSPENSE_START_DATA || data === SUSPENSE_PENDING_START_DATA || data === SUSPENSE_FALLBACK_START_DATA) {
  9505. depth++;
  9506. }
  9507. }
  9508. node = nextNode;
  9509. } while (node);
  9510. // TODO: Warn, we didn't find the end comment boundary.
  9511. }
  9512. function clearSuspenseBoundaryFromContainer(container, suspenseInstance) {
  9513. if (container.nodeType === COMMENT_NODE) {
  9514. clearSuspenseBoundary(container.parentNode, suspenseInstance);
  9515. } else if (container.nodeType === ELEMENT_NODE) {
  9516. clearSuspenseBoundary(container, suspenseInstance);
  9517. } else {
  9518. // Document nodes should never contain suspense boundaries.
  9519. }
  9520. }
  9521. function hideInstance(instance) {
  9522. // TODO: Does this work for all element types? What about MathML? Should we
  9523. // pass host context to this method?
  9524. instance = instance;
  9525. var style = instance.style;
  9526. if (typeof style.setProperty === 'function') {
  9527. style.setProperty('display', 'none', 'important');
  9528. } else {
  9529. style.display = 'none';
  9530. }
  9531. }
  9532. function hideTextInstance(textInstance) {
  9533. textInstance.nodeValue = '';
  9534. }
  9535. function unhideInstance(instance, props) {
  9536. instance = instance;
  9537. var styleProp = props[STYLE];
  9538. var display = styleProp !== undefined && styleProp !== null && styleProp.hasOwnProperty('display') ? styleProp.display : null;
  9539. instance.style.display = dangerousStyleValue('display', display);
  9540. }
  9541. function unhideTextInstance(textInstance, text) {
  9542. textInstance.nodeValue = text;
  9543. }
  9544. // -------------------
  9545. // Hydration
  9546. // -------------------
  9547. var supportsHydration = true;
  9548. function canHydrateInstance(instance, type, props) {
  9549. if (instance.nodeType !== ELEMENT_NODE || type.toLowerCase() !== instance.nodeName.toLowerCase()) {
  9550. return null;
  9551. }
  9552. // This has now been refined to an element node.
  9553. return instance;
  9554. }
  9555. function canHydrateTextInstance(instance, text) {
  9556. if (text === '' || instance.nodeType !== TEXT_NODE) {
  9557. // Empty strings are not parsed by HTML so there won't be a correct match here.
  9558. return null;
  9559. }
  9560. // This has now been refined to a text node.
  9561. return instance;
  9562. }
  9563. function canHydrateSuspenseInstance(instance) {
  9564. if (instance.nodeType !== COMMENT_NODE) {
  9565. // Empty strings are not parsed by HTML so there won't be a correct match here.
  9566. return null;
  9567. }
  9568. // This has now been refined to a suspense node.
  9569. return instance;
  9570. }
  9571. function isSuspenseInstancePending(instance) {
  9572. return instance.data === SUSPENSE_PENDING_START_DATA;
  9573. }
  9574. function isSuspenseInstanceFallback(instance) {
  9575. return instance.data === SUSPENSE_FALLBACK_START_DATA;
  9576. }
  9577. function registerSuspenseInstanceRetry(instance, callback) {
  9578. instance._reactRetry = callback;
  9579. }
  9580. function getNextHydratable(node) {
  9581. // Skip non-hydratable nodes.
  9582. for (; node != null; node = node.nextSibling) {
  9583. var nodeType = node.nodeType;
  9584. if (nodeType === ELEMENT_NODE || nodeType === TEXT_NODE) {
  9585. break;
  9586. }
  9587. if (enableSuspenseServerRenderer) {
  9588. if (nodeType === COMMENT_NODE) {
  9589. break;
  9590. }
  9591. var nodeData = node.data;
  9592. if (nodeData === SUSPENSE_START_DATA || nodeData === SUSPENSE_FALLBACK_START_DATA || nodeData === SUSPENSE_PENDING_START_DATA) {
  9593. break;
  9594. }
  9595. }
  9596. }
  9597. return node;
  9598. }
  9599. function getNextHydratableSibling(instance) {
  9600. return getNextHydratable(instance.nextSibling);
  9601. }
  9602. function getFirstHydratableChild(parentInstance) {
  9603. return getNextHydratable(parentInstance.firstChild);
  9604. }
  9605. function hydrateInstance(instance, type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
  9606. precacheFiberNode(internalInstanceHandle, instance);
  9607. // TODO: Possibly defer this until the commit phase where all the events
  9608. // get attached.
  9609. updateFiberProps(instance, props);
  9610. var parentNamespace = void 0;
  9611. {
  9612. var hostContextDev = hostContext;
  9613. parentNamespace = hostContextDev.namespace;
  9614. }
  9615. return diffHydratedProperties(instance, type, props, parentNamespace, rootContainerInstance);
  9616. }
  9617. function hydrateTextInstance(textInstance, text, internalInstanceHandle) {
  9618. precacheFiberNode(internalInstanceHandle, textInstance);
  9619. return diffHydratedText(textInstance, text);
  9620. }
  9621. function getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance) {
  9622. var node = suspenseInstance.nextSibling;
  9623. // Skip past all nodes within this suspense boundary.
  9624. // There might be nested nodes so we need to keep track of how
  9625. // deep we are and only break out when we're back on top.
  9626. var depth = 0;
  9627. while (node) {
  9628. if (node.nodeType === COMMENT_NODE) {
  9629. var data = node.data;
  9630. if (data === SUSPENSE_END_DATA) {
  9631. if (depth === 0) {
  9632. return getNextHydratableSibling(node);
  9633. } else {
  9634. depth--;
  9635. }
  9636. } else if (data === SUSPENSE_START_DATA) {
  9637. depth++;
  9638. }
  9639. }
  9640. node = node.nextSibling;
  9641. }
  9642. // TODO: Warn, we didn't find the end comment boundary.
  9643. return null;
  9644. }
  9645. function didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, text) {
  9646. {
  9647. warnForUnmatchedText(textInstance, text);
  9648. }
  9649. }
  9650. function didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, text) {
  9651. if ( true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  9652. warnForUnmatchedText(textInstance, text);
  9653. }
  9654. }
  9655. function didNotHydrateContainerInstance(parentContainer, instance) {
  9656. {
  9657. if (instance.nodeType === ELEMENT_NODE) {
  9658. warnForDeletedHydratableElement(parentContainer, instance);
  9659. } else if (instance.nodeType === COMMENT_NODE) {
  9660. // TODO: warnForDeletedHydratableSuspenseBoundary
  9661. } else {
  9662. warnForDeletedHydratableText(parentContainer, instance);
  9663. }
  9664. }
  9665. }
  9666. function didNotHydrateInstance(parentType, parentProps, parentInstance, instance) {
  9667. if ( true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  9668. if (instance.nodeType === ELEMENT_NODE) {
  9669. warnForDeletedHydratableElement(parentInstance, instance);
  9670. } else if (instance.nodeType === COMMENT_NODE) {
  9671. // TODO: warnForDeletedHydratableSuspenseBoundary
  9672. } else {
  9673. warnForDeletedHydratableText(parentInstance, instance);
  9674. }
  9675. }
  9676. }
  9677. function didNotFindHydratableContainerInstance(parentContainer, type, props) {
  9678. {
  9679. warnForInsertedHydratedElement(parentContainer, type, props);
  9680. }
  9681. }
  9682. function didNotFindHydratableContainerTextInstance(parentContainer, text) {
  9683. {
  9684. warnForInsertedHydratedText(parentContainer, text);
  9685. }
  9686. }
  9687. function didNotFindHydratableInstance(parentType, parentProps, parentInstance, type, props) {
  9688. if ( true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  9689. warnForInsertedHydratedElement(parentInstance, type, props);
  9690. }
  9691. }
  9692. function didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, text) {
  9693. if ( true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  9694. warnForInsertedHydratedText(parentInstance, text);
  9695. }
  9696. }
  9697. function didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance) {
  9698. if ( true && parentProps[SUPPRESS_HYDRATION_WARNING] !== true) {
  9699. // TODO: warnForInsertedHydratedSuspense(parentInstance);
  9700. }
  9701. }
  9702. function mountResponderInstance(responder, responderInstance, responderProps, responderState, instance, rootContainerInstance) {
  9703. // Listen to events
  9704. var doc = rootContainerInstance.ownerDocument;
  9705. var documentBody = doc.body || doc;
  9706. var _ref = responder,
  9707. rootEventTypes = _ref.rootEventTypes,
  9708. targetEventTypes = _ref.targetEventTypes;
  9709. if (targetEventTypes !== null) {
  9710. listenToEventResponderEventTypes(targetEventTypes, documentBody);
  9711. }
  9712. if (rootEventTypes !== null) {
  9713. addRootEventTypesForResponderInstance(responderInstance, rootEventTypes);
  9714. listenToEventResponderEventTypes(rootEventTypes, documentBody);
  9715. }
  9716. mountEventResponder(responder, responderInstance, responderProps, responderState);
  9717. return responderInstance;
  9718. }
  9719. function unmountResponderInstance(responderInstance) {
  9720. if (enableFlareAPI) {
  9721. // TODO stop listening to targetEventTypes
  9722. unmountEventResponder(responderInstance);
  9723. }
  9724. }
  9725. function getFundamentalComponentInstance(fundamentalInstance) {
  9726. if (enableFundamentalAPI) {
  9727. var currentFiber = fundamentalInstance.currentFiber,
  9728. impl = fundamentalInstance.impl,
  9729. _props = fundamentalInstance.props,
  9730. state = fundamentalInstance.state;
  9731. var instance = impl.getInstance(null, _props, state);
  9732. precacheFiberNode(currentFiber, instance);
  9733. return instance;
  9734. }
  9735. // Because of the flag above, this gets around the Flow error;
  9736. return null;
  9737. }
  9738. function mountFundamentalComponent(fundamentalInstance) {
  9739. if (enableFundamentalAPI) {
  9740. var impl = fundamentalInstance.impl,
  9741. instance = fundamentalInstance.instance,
  9742. _props2 = fundamentalInstance.props,
  9743. state = fundamentalInstance.state;
  9744. var onMount = impl.onMount;
  9745. if (onMount !== undefined) {
  9746. onMount(null, instance, _props2, state);
  9747. }
  9748. }
  9749. }
  9750. function shouldUpdateFundamentalComponent(fundamentalInstance) {
  9751. if (enableFundamentalAPI) {
  9752. var impl = fundamentalInstance.impl,
  9753. prevProps = fundamentalInstance.prevProps,
  9754. _props3 = fundamentalInstance.props,
  9755. state = fundamentalInstance.state;
  9756. var shouldUpdate = impl.shouldUpdate;
  9757. if (shouldUpdate !== undefined) {
  9758. return shouldUpdate(null, prevProps, _props3, state);
  9759. }
  9760. }
  9761. return true;
  9762. }
  9763. function updateFundamentalComponent(fundamentalInstance) {
  9764. if (enableFundamentalAPI) {
  9765. var impl = fundamentalInstance.impl,
  9766. instance = fundamentalInstance.instance,
  9767. prevProps = fundamentalInstance.prevProps,
  9768. _props4 = fundamentalInstance.props,
  9769. state = fundamentalInstance.state;
  9770. var onUpdate = impl.onUpdate;
  9771. if (onUpdate !== undefined) {
  9772. onUpdate(null, instance, prevProps, _props4, state);
  9773. }
  9774. }
  9775. }
  9776. function unmountFundamentalComponent(fundamentalInstance) {
  9777. if (enableFundamentalAPI) {
  9778. var impl = fundamentalInstance.impl,
  9779. instance = fundamentalInstance.instance,
  9780. _props5 = fundamentalInstance.props,
  9781. state = fundamentalInstance.state;
  9782. var onUnmount = impl.onUnmount;
  9783. if (onUnmount !== undefined) {
  9784. onUnmount(null, instance, _props5, state);
  9785. }
  9786. }
  9787. }
  9788. // Prefix measurements so that it's possible to filter them.
  9789. // Longer prefixes are hard to read in DevTools.
  9790. var reactEmoji = '\u269B';
  9791. var warningEmoji = '\u26D4';
  9792. var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';
  9793. // Keep track of current fiber so that we know the path to unwind on pause.
  9794. // TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them?
  9795. var currentFiber = null;
  9796. // If we're in the middle of user code, which fiber and method is it?
  9797. // Reusing `currentFiber` would be confusing for this because user code fiber
  9798. // can change during commit phase too, but we don't need to unwind it (since
  9799. // lifecycles in the commit phase don't resemble a tree).
  9800. var currentPhase = null;
  9801. var currentPhaseFiber = null;
  9802. // Did lifecycle hook schedule an update? This is often a performance problem,
  9803. // so we will keep track of it, and include it in the report.
  9804. // Track commits caused by cascading updates.
  9805. var isCommitting = false;
  9806. var hasScheduledUpdateInCurrentCommit = false;
  9807. var hasScheduledUpdateInCurrentPhase = false;
  9808. var commitCountInCurrentWorkLoop = 0;
  9809. var effectCountInCurrentCommit = 0;
  9810. var isWaitingForCallback = false;
  9811. // During commits, we only show a measurement once per method name
  9812. // to avoid stretch the commit phase with measurement overhead.
  9813. var labelsInCurrentCommit = new Set();
  9814. var formatMarkName = function (markName) {
  9815. return reactEmoji + ' ' + markName;
  9816. };
  9817. var formatLabel = function (label, warning) {
  9818. var prefix = warning ? warningEmoji + ' ' : reactEmoji + ' ';
  9819. var suffix = warning ? ' Warning: ' + warning : '';
  9820. return '' + prefix + label + suffix;
  9821. };
  9822. var beginMark = function (markName) {
  9823. performance.mark(formatMarkName(markName));
  9824. };
  9825. var clearMark = function (markName) {
  9826. performance.clearMarks(formatMarkName(markName));
  9827. };
  9828. var endMark = function (label, markName, warning) {
  9829. var formattedMarkName = formatMarkName(markName);
  9830. var formattedLabel = formatLabel(label, warning);
  9831. try {
  9832. performance.measure(formattedLabel, formattedMarkName);
  9833. } catch (err) {}
  9834. // If previous mark was missing for some reason, this will throw.
  9835. // This could only happen if React crashed in an unexpected place earlier.
  9836. // Don't pile on with more errors.
  9837. // Clear marks immediately to avoid growing buffer.
  9838. performance.clearMarks(formattedMarkName);
  9839. performance.clearMeasures(formattedLabel);
  9840. };
  9841. var getFiberMarkName = function (label, debugID) {
  9842. return label + ' (#' + debugID + ')';
  9843. };
  9844. var getFiberLabel = function (componentName, isMounted, phase) {
  9845. if (phase === null) {
  9846. // These are composite component total time measurements.
  9847. return componentName + ' [' + (isMounted ? 'update' : 'mount') + ']';
  9848. } else {
  9849. // Composite component methods.
  9850. return componentName + '.' + phase;
  9851. }
  9852. };
  9853. var beginFiberMark = function (fiber, phase) {
  9854. var componentName = getComponentName(fiber.type) || 'Unknown';
  9855. var debugID = fiber._debugID;
  9856. var isMounted = fiber.alternate !== null;
  9857. var label = getFiberLabel(componentName, isMounted, phase);
  9858. if (isCommitting && labelsInCurrentCommit.has(label)) {
  9859. // During the commit phase, we don't show duplicate labels because
  9860. // there is a fixed overhead for every measurement, and we don't
  9861. // want to stretch the commit phase beyond necessary.
  9862. return false;
  9863. }
  9864. labelsInCurrentCommit.add(label);
  9865. var markName = getFiberMarkName(label, debugID);
  9866. beginMark(markName);
  9867. return true;
  9868. };
  9869. var clearFiberMark = function (fiber, phase) {
  9870. var componentName = getComponentName(fiber.type) || 'Unknown';
  9871. var debugID = fiber._debugID;
  9872. var isMounted = fiber.alternate !== null;
  9873. var label = getFiberLabel(componentName, isMounted, phase);
  9874. var markName = getFiberMarkName(label, debugID);
  9875. clearMark(markName);
  9876. };
  9877. var endFiberMark = function (fiber, phase, warning) {
  9878. var componentName = getComponentName(fiber.type) || 'Unknown';
  9879. var debugID = fiber._debugID;
  9880. var isMounted = fiber.alternate !== null;
  9881. var label = getFiberLabel(componentName, isMounted, phase);
  9882. var markName = getFiberMarkName(label, debugID);
  9883. endMark(label, markName, warning);
  9884. };
  9885. var shouldIgnoreFiber = function (fiber) {
  9886. // Host components should be skipped in the timeline.
  9887. // We could check typeof fiber.type, but does this work with RN?
  9888. switch (fiber.tag) {
  9889. case HostRoot:
  9890. case HostComponent:
  9891. case HostText:
  9892. case HostPortal:
  9893. case Fragment:
  9894. case ContextProvider:
  9895. case ContextConsumer:
  9896. case Mode:
  9897. return true;
  9898. default:
  9899. return false;
  9900. }
  9901. };
  9902. var clearPendingPhaseMeasurement = function () {
  9903. if (currentPhase !== null && currentPhaseFiber !== null) {
  9904. clearFiberMark(currentPhaseFiber, currentPhase);
  9905. }
  9906. currentPhaseFiber = null;
  9907. currentPhase = null;
  9908. hasScheduledUpdateInCurrentPhase = false;
  9909. };
  9910. var pauseTimers = function () {
  9911. // Stops all currently active measurements so that they can be resumed
  9912. // if we continue in a later deferred loop from the same unit of work.
  9913. var fiber = currentFiber;
  9914. while (fiber) {
  9915. if (fiber._debugIsCurrentlyTiming) {
  9916. endFiberMark(fiber, null, null);
  9917. }
  9918. fiber = fiber.return;
  9919. }
  9920. };
  9921. var resumeTimersRecursively = function (fiber) {
  9922. if (fiber.return !== null) {
  9923. resumeTimersRecursively(fiber.return);
  9924. }
  9925. if (fiber._debugIsCurrentlyTiming) {
  9926. beginFiberMark(fiber, null);
  9927. }
  9928. };
  9929. var resumeTimers = function () {
  9930. // Resumes all measurements that were active during the last deferred loop.
  9931. if (currentFiber !== null) {
  9932. resumeTimersRecursively(currentFiber);
  9933. }
  9934. };
  9935. function recordEffect() {
  9936. if (enableUserTimingAPI) {
  9937. effectCountInCurrentCommit++;
  9938. }
  9939. }
  9940. function recordScheduleUpdate() {
  9941. if (enableUserTimingAPI) {
  9942. if (isCommitting) {
  9943. hasScheduledUpdateInCurrentCommit = true;
  9944. }
  9945. if (currentPhase !== null && currentPhase !== 'componentWillMount' && currentPhase !== 'componentWillReceiveProps') {
  9946. hasScheduledUpdateInCurrentPhase = true;
  9947. }
  9948. }
  9949. }
  9950. function startRequestCallbackTimer() {
  9951. if (enableUserTimingAPI) {
  9952. if (supportsUserTiming && !isWaitingForCallback) {
  9953. isWaitingForCallback = true;
  9954. beginMark('(Waiting for async callback...)');
  9955. }
  9956. }
  9957. }
  9958. function stopRequestCallbackTimer(didExpire) {
  9959. if (enableUserTimingAPI) {
  9960. if (supportsUserTiming) {
  9961. isWaitingForCallback = false;
  9962. var warning = didExpire ? 'Update expired; will flush synchronously' : null;
  9963. endMark('(Waiting for async callback...)', '(Waiting for async callback...)', warning);
  9964. }
  9965. }
  9966. }
  9967. function startWorkTimer(fiber) {
  9968. if (enableUserTimingAPI) {
  9969. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  9970. return;
  9971. }
  9972. // If we pause, this is the fiber to unwind from.
  9973. currentFiber = fiber;
  9974. if (!beginFiberMark(fiber, null)) {
  9975. return;
  9976. }
  9977. fiber._debugIsCurrentlyTiming = true;
  9978. }
  9979. }
  9980. function cancelWorkTimer(fiber) {
  9981. if (enableUserTimingAPI) {
  9982. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  9983. return;
  9984. }
  9985. // Remember we shouldn't complete measurement for this fiber.
  9986. // Otherwise flamechart will be deep even for small updates.
  9987. fiber._debugIsCurrentlyTiming = false;
  9988. clearFiberMark(fiber, null);
  9989. }
  9990. }
  9991. function stopWorkTimer(fiber) {
  9992. if (enableUserTimingAPI) {
  9993. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  9994. return;
  9995. }
  9996. // If we pause, its parent is the fiber to unwind from.
  9997. currentFiber = fiber.return;
  9998. if (!fiber._debugIsCurrentlyTiming) {
  9999. return;
  10000. }
  10001. fiber._debugIsCurrentlyTiming = false;
  10002. endFiberMark(fiber, null, null);
  10003. }
  10004. }
  10005. function stopFailedWorkTimer(fiber) {
  10006. if (enableUserTimingAPI) {
  10007. if (!supportsUserTiming || shouldIgnoreFiber(fiber)) {
  10008. return;
  10009. }
  10010. // If we pause, its parent is the fiber to unwind from.
  10011. currentFiber = fiber.return;
  10012. if (!fiber._debugIsCurrentlyTiming) {
  10013. return;
  10014. }
  10015. fiber._debugIsCurrentlyTiming = false;
  10016. var warning = fiber.tag === SuspenseComponent || fiber.tag === DehydratedSuspenseComponent ? 'Rendering was suspended' : 'An error was thrown inside this error boundary';
  10017. endFiberMark(fiber, null, warning);
  10018. }
  10019. }
  10020. function startPhaseTimer(fiber, phase) {
  10021. if (enableUserTimingAPI) {
  10022. if (!supportsUserTiming) {
  10023. return;
  10024. }
  10025. clearPendingPhaseMeasurement();
  10026. if (!beginFiberMark(fiber, phase)) {
  10027. return;
  10028. }
  10029. currentPhaseFiber = fiber;
  10030. currentPhase = phase;
  10031. }
  10032. }
  10033. function stopPhaseTimer() {
  10034. if (enableUserTimingAPI) {
  10035. if (!supportsUserTiming) {
  10036. return;
  10037. }
  10038. if (currentPhase !== null && currentPhaseFiber !== null) {
  10039. var warning = hasScheduledUpdateInCurrentPhase ? 'Scheduled a cascading update' : null;
  10040. endFiberMark(currentPhaseFiber, currentPhase, warning);
  10041. }
  10042. currentPhase = null;
  10043. currentPhaseFiber = null;
  10044. }
  10045. }
  10046. function startWorkLoopTimer(nextUnitOfWork) {
  10047. if (enableUserTimingAPI) {
  10048. currentFiber = nextUnitOfWork;
  10049. if (!supportsUserTiming) {
  10050. return;
  10051. }
  10052. commitCountInCurrentWorkLoop = 0;
  10053. // This is top level call.
  10054. // Any other measurements are performed within.
  10055. beginMark('(React Tree Reconciliation)');
  10056. // Resume any measurements that were in progress during the last loop.
  10057. resumeTimers();
  10058. }
  10059. }
  10060. function stopWorkLoopTimer(interruptedBy, didCompleteRoot) {
  10061. if (enableUserTimingAPI) {
  10062. if (!supportsUserTiming) {
  10063. return;
  10064. }
  10065. var warning = null;
  10066. if (interruptedBy !== null) {
  10067. if (interruptedBy.tag === HostRoot) {
  10068. warning = 'A top-level update interrupted the previous render';
  10069. } else {
  10070. var componentName = getComponentName(interruptedBy.type) || 'Unknown';
  10071. warning = 'An update to ' + componentName + ' interrupted the previous render';
  10072. }
  10073. } else if (commitCountInCurrentWorkLoop > 1) {
  10074. warning = 'There were cascading updates';
  10075. }
  10076. commitCountInCurrentWorkLoop = 0;
  10077. var label = didCompleteRoot ? '(React Tree Reconciliation: Completed Root)' : '(React Tree Reconciliation: Yielded)';
  10078. // Pause any measurements until the next loop.
  10079. pauseTimers();
  10080. endMark(label, '(React Tree Reconciliation)', warning);
  10081. }
  10082. }
  10083. function startCommitTimer() {
  10084. if (enableUserTimingAPI) {
  10085. if (!supportsUserTiming) {
  10086. return;
  10087. }
  10088. isCommitting = true;
  10089. hasScheduledUpdateInCurrentCommit = false;
  10090. labelsInCurrentCommit.clear();
  10091. beginMark('(Committing Changes)');
  10092. }
  10093. }
  10094. function stopCommitTimer() {
  10095. if (enableUserTimingAPI) {
  10096. if (!supportsUserTiming) {
  10097. return;
  10098. }
  10099. var warning = null;
  10100. if (hasScheduledUpdateInCurrentCommit) {
  10101. warning = 'Lifecycle hook scheduled a cascading update';
  10102. } else if (commitCountInCurrentWorkLoop > 0) {
  10103. warning = 'Caused by a cascading update in earlier commit';
  10104. }
  10105. hasScheduledUpdateInCurrentCommit = false;
  10106. commitCountInCurrentWorkLoop++;
  10107. isCommitting = false;
  10108. labelsInCurrentCommit.clear();
  10109. endMark('(Committing Changes)', '(Committing Changes)', warning);
  10110. }
  10111. }
  10112. function startCommitSnapshotEffectsTimer() {
  10113. if (enableUserTimingAPI) {
  10114. if (!supportsUserTiming) {
  10115. return;
  10116. }
  10117. effectCountInCurrentCommit = 0;
  10118. beginMark('(Committing Snapshot Effects)');
  10119. }
  10120. }
  10121. function stopCommitSnapshotEffectsTimer() {
  10122. if (enableUserTimingAPI) {
  10123. if (!supportsUserTiming) {
  10124. return;
  10125. }
  10126. var count = effectCountInCurrentCommit;
  10127. effectCountInCurrentCommit = 0;
  10128. endMark('(Committing Snapshot Effects: ' + count + ' Total)', '(Committing Snapshot Effects)', null);
  10129. }
  10130. }
  10131. function startCommitHostEffectsTimer() {
  10132. if (enableUserTimingAPI) {
  10133. if (!supportsUserTiming) {
  10134. return;
  10135. }
  10136. effectCountInCurrentCommit = 0;
  10137. beginMark('(Committing Host Effects)');
  10138. }
  10139. }
  10140. function stopCommitHostEffectsTimer() {
  10141. if (enableUserTimingAPI) {
  10142. if (!supportsUserTiming) {
  10143. return;
  10144. }
  10145. var count = effectCountInCurrentCommit;
  10146. effectCountInCurrentCommit = 0;
  10147. endMark('(Committing Host Effects: ' + count + ' Total)', '(Committing Host Effects)', null);
  10148. }
  10149. }
  10150. function startCommitLifeCyclesTimer() {
  10151. if (enableUserTimingAPI) {
  10152. if (!supportsUserTiming) {
  10153. return;
  10154. }
  10155. effectCountInCurrentCommit = 0;
  10156. beginMark('(Calling Lifecycle Methods)');
  10157. }
  10158. }
  10159. function stopCommitLifeCyclesTimer() {
  10160. if (enableUserTimingAPI) {
  10161. if (!supportsUserTiming) {
  10162. return;
  10163. }
  10164. var count = effectCountInCurrentCommit;
  10165. effectCountInCurrentCommit = 0;
  10166. endMark('(Calling Lifecycle Methods: ' + count + ' Total)', '(Calling Lifecycle Methods)', null);
  10167. }
  10168. }
  10169. var valueStack = [];
  10170. var fiberStack = void 0;
  10171. {
  10172. fiberStack = [];
  10173. }
  10174. var index = -1;
  10175. function createCursor(defaultValue) {
  10176. return {
  10177. current: defaultValue
  10178. };
  10179. }
  10180. function pop(cursor, fiber) {
  10181. if (index < 0) {
  10182. {
  10183. warningWithoutStack$1(false, 'Unexpected pop.');
  10184. }
  10185. return;
  10186. }
  10187. {
  10188. if (fiber !== fiberStack[index]) {
  10189. warningWithoutStack$1(false, 'Unexpected Fiber popped.');
  10190. }
  10191. }
  10192. cursor.current = valueStack[index];
  10193. valueStack[index] = null;
  10194. {
  10195. fiberStack[index] = null;
  10196. }
  10197. index--;
  10198. }
  10199. function push(cursor, value, fiber) {
  10200. index++;
  10201. valueStack[index] = cursor.current;
  10202. {
  10203. fiberStack[index] = fiber;
  10204. }
  10205. cursor.current = value;
  10206. }
  10207. var warnedAboutMissingGetChildContext = void 0;
  10208. {
  10209. warnedAboutMissingGetChildContext = {};
  10210. }
  10211. var emptyContextObject = {};
  10212. {
  10213. Object.freeze(emptyContextObject);
  10214. }
  10215. // A cursor to the current merged context object on the stack.
  10216. var contextStackCursor = createCursor(emptyContextObject);
  10217. // A cursor to a boolean indicating whether the context has changed.
  10218. var didPerformWorkStackCursor = createCursor(false);
  10219. // Keep track of the previous context object that was on the stack.
  10220. // We use this to get access to the parent context after we have already
  10221. // pushed the next context provider, and now need to merge their contexts.
  10222. var previousContext = emptyContextObject;
  10223. function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) {
  10224. if (disableLegacyContext) {
  10225. return emptyContextObject;
  10226. } else {
  10227. if (didPushOwnContextIfProvider && isContextProvider(Component)) {
  10228. // If the fiber is a context provider itself, when we read its context
  10229. // we may have already pushed its own child context on the stack. A context
  10230. // provider should not "see" its own child context. Therefore we read the
  10231. // previous (parent) context instead for a context provider.
  10232. return previousContext;
  10233. }
  10234. return contextStackCursor.current;
  10235. }
  10236. }
  10237. function cacheContext(workInProgress, unmaskedContext, maskedContext) {
  10238. if (disableLegacyContext) {
  10239. return;
  10240. } else {
  10241. var instance = workInProgress.stateNode;
  10242. instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
  10243. instance.__reactInternalMemoizedMaskedChildContext = maskedContext;
  10244. }
  10245. }
  10246. function getMaskedContext(workInProgress, unmaskedContext) {
  10247. if (disableLegacyContext) {
  10248. return emptyContextObject;
  10249. } else {
  10250. var type = workInProgress.type;
  10251. var contextTypes = type.contextTypes;
  10252. if (!contextTypes) {
  10253. return emptyContextObject;
  10254. }
  10255. // Avoid recreating masked context unless unmasked context has changed.
  10256. // Failing to do this will result in unnecessary calls to componentWillReceiveProps.
  10257. // This may trigger infinite loops if componentWillReceiveProps calls setState.
  10258. var instance = workInProgress.stateNode;
  10259. if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
  10260. return instance.__reactInternalMemoizedMaskedChildContext;
  10261. }
  10262. var context = {};
  10263. for (var key in contextTypes) {
  10264. context[key] = unmaskedContext[key];
  10265. }
  10266. {
  10267. var name = getComponentName(type) || 'Unknown';
  10268. checkPropTypes(contextTypes, context, 'context', name, getCurrentFiberStackInDev);
  10269. }
  10270. // Cache unmasked context so we can avoid recreating masked context unless necessary.
  10271. // Context is created before the class component is instantiated so check for instance.
  10272. if (instance) {
  10273. cacheContext(workInProgress, unmaskedContext, context);
  10274. }
  10275. return context;
  10276. }
  10277. }
  10278. function hasContextChanged() {
  10279. if (disableLegacyContext) {
  10280. return false;
  10281. } else {
  10282. return didPerformWorkStackCursor.current;
  10283. }
  10284. }
  10285. function isContextProvider(type) {
  10286. if (disableLegacyContext) {
  10287. return false;
  10288. } else {
  10289. var childContextTypes = type.childContextTypes;
  10290. return childContextTypes !== null && childContextTypes !== undefined;
  10291. }
  10292. }
  10293. function popContext(fiber) {
  10294. if (disableLegacyContext) {
  10295. return;
  10296. } else {
  10297. pop(didPerformWorkStackCursor, fiber);
  10298. pop(contextStackCursor, fiber);
  10299. }
  10300. }
  10301. function popTopLevelContextObject(fiber) {
  10302. if (disableLegacyContext) {
  10303. return;
  10304. } else {
  10305. pop(didPerformWorkStackCursor, fiber);
  10306. pop(contextStackCursor, fiber);
  10307. }
  10308. }
  10309. function pushTopLevelContextObject(fiber, context, didChange) {
  10310. if (disableLegacyContext) {
  10311. return;
  10312. } else {
  10313. (function () {
  10314. if (!(contextStackCursor.current === emptyContextObject)) {
  10315. {
  10316. throw ReactError(Error('Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue.'));
  10317. }
  10318. }
  10319. })();
  10320. push(contextStackCursor, context, fiber);
  10321. push(didPerformWorkStackCursor, didChange, fiber);
  10322. }
  10323. }
  10324. function processChildContext(fiber, type, parentContext) {
  10325. if (disableLegacyContext) {
  10326. return parentContext;
  10327. } else {
  10328. var instance = fiber.stateNode;
  10329. var childContextTypes = type.childContextTypes;
  10330. // TODO (bvaughn) Replace this behavior with an invariant() in the future.
  10331. // It has only been added in Fiber to match the (unintentional) behavior in Stack.
  10332. if (typeof instance.getChildContext !== 'function') {
  10333. {
  10334. var componentName = getComponentName(type) || 'Unknown';
  10335. if (!warnedAboutMissingGetChildContext[componentName]) {
  10336. warnedAboutMissingGetChildContext[componentName] = true;
  10337. 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);
  10338. }
  10339. }
  10340. return parentContext;
  10341. }
  10342. var childContext = void 0;
  10343. {
  10344. setCurrentPhase('getChildContext');
  10345. }
  10346. startPhaseTimer(fiber, 'getChildContext');
  10347. childContext = instance.getChildContext();
  10348. stopPhaseTimer();
  10349. {
  10350. setCurrentPhase(null);
  10351. }
  10352. for (var contextKey in childContext) {
  10353. (function () {
  10354. if (!(contextKey in childContextTypes)) {
  10355. {
  10356. throw ReactError(Error((getComponentName(type) || 'Unknown') + '.getChildContext(): key "' + contextKey + '" is not defined in childContextTypes.'));
  10357. }
  10358. }
  10359. })();
  10360. }
  10361. {
  10362. var name = getComponentName(type) || 'Unknown';
  10363. checkPropTypes(childContextTypes, childContext, 'child context', name,
  10364. // In practice, there is one case in which we won't get a stack. It's when
  10365. // somebody calls unstable_renderSubtreeIntoContainer() and we process
  10366. // context from the parent component instance. The stack will be missing
  10367. // because it's outside of the reconciliation, and so the pointer has not
  10368. // been set. This is rare and doesn't matter. We'll also remove that API.
  10369. getCurrentFiberStackInDev);
  10370. }
  10371. return _assign({}, parentContext, childContext);
  10372. }
  10373. }
  10374. function pushContextProvider(workInProgress) {
  10375. if (disableLegacyContext) {
  10376. return false;
  10377. } else {
  10378. var instance = workInProgress.stateNode;
  10379. // We push the context as early as possible to ensure stack integrity.
  10380. // If the instance does not exist yet, we will push null at first,
  10381. // and replace it on the stack later when invalidating the context.
  10382. var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject;
  10383. // Remember the parent context so we can merge with it later.
  10384. // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates.
  10385. previousContext = contextStackCursor.current;
  10386. push(contextStackCursor, memoizedMergedChildContext, workInProgress);
  10387. push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress);
  10388. return true;
  10389. }
  10390. }
  10391. function invalidateContextProvider(workInProgress, type, didChange) {
  10392. if (disableLegacyContext) {
  10393. return;
  10394. } else {
  10395. var instance = workInProgress.stateNode;
  10396. (function () {
  10397. if (!instance) {
  10398. {
  10399. throw ReactError(Error('Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue.'));
  10400. }
  10401. }
  10402. })();
  10403. if (didChange) {
  10404. // Merge parent and own context.
  10405. // Skip this if we're not updating due to sCU.
  10406. // This avoids unnecessarily recomputing memoized values.
  10407. var mergedContext = processChildContext(workInProgress, type, previousContext);
  10408. instance.__reactInternalMemoizedMergedChildContext = mergedContext;
  10409. // Replace the old (or empty) context with the new one.
  10410. // It is important to unwind the context in the reverse order.
  10411. pop(didPerformWorkStackCursor, workInProgress);
  10412. pop(contextStackCursor, workInProgress);
  10413. // Now push the new context and mark that it has changed.
  10414. push(contextStackCursor, mergedContext, workInProgress);
  10415. push(didPerformWorkStackCursor, didChange, workInProgress);
  10416. } else {
  10417. pop(didPerformWorkStackCursor, workInProgress);
  10418. push(didPerformWorkStackCursor, didChange, workInProgress);
  10419. }
  10420. }
  10421. }
  10422. function findCurrentUnmaskedContext(fiber) {
  10423. if (disableLegacyContext) {
  10424. return emptyContextObject;
  10425. } else {
  10426. // Currently this is only used with renderSubtreeIntoContainer; not sure if it
  10427. // makes sense elsewhere
  10428. (function () {
  10429. if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) {
  10430. {
  10431. throw ReactError(Error('Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue.'));
  10432. }
  10433. }
  10434. })();
  10435. var node = fiber;
  10436. do {
  10437. switch (node.tag) {
  10438. case HostRoot:
  10439. return node.stateNode.context;
  10440. case ClassComponent:
  10441. {
  10442. var Component = node.type;
  10443. if (isContextProvider(Component)) {
  10444. return node.stateNode.__reactInternalMemoizedMergedChildContext;
  10445. }
  10446. break;
  10447. }
  10448. }
  10449. node = node.return;
  10450. } while (node !== null);
  10451. (function () {
  10452. {
  10453. {
  10454. throw ReactError(Error('Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue.'));
  10455. }
  10456. }
  10457. })();
  10458. }
  10459. }
  10460. var LegacyRoot = 0;
  10461. var BatchedRoot = 1;
  10462. var ConcurrentRoot = 2;
  10463. // Intentionally not named imports because Rollup would use dynamic dispatch for
  10464. // CommonJS interop named imports.
  10465. var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority;
  10466. var Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback;
  10467. var Scheduler_cancelCallback = Scheduler.unstable_cancelCallback;
  10468. var Scheduler_shouldYield = Scheduler.unstable_shouldYield;
  10469. var Scheduler_requestPaint = Scheduler.unstable_requestPaint;
  10470. var Scheduler_now = Scheduler.unstable_now;
  10471. var Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel;
  10472. var Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority;
  10473. var Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority;
  10474. var Scheduler_NormalPriority = Scheduler.unstable_NormalPriority;
  10475. var Scheduler_LowPriority = Scheduler.unstable_LowPriority;
  10476. var Scheduler_IdlePriority = Scheduler.unstable_IdlePriority;
  10477. if (enableSchedulerTracing) {
  10478. // Provide explicit error message when production+profiling bundle of e.g.
  10479. // react-dom is used with production (non-profiling) bundle of
  10480. // scheduler/tracing
  10481. (function () {
  10482. if (!(tracing.__interactionsRef != null && tracing.__interactionsRef.current != null)) {
  10483. {
  10484. throw ReactError(Error('It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling'));
  10485. }
  10486. }
  10487. })();
  10488. }
  10489. var fakeCallbackNode = {};
  10490. // Except for NoPriority, these correspond to Scheduler priorities. We use
  10491. // ascending numbers so we can compare them like numbers. They start at 90 to
  10492. // avoid clashing with Scheduler's priorities.
  10493. var ImmediatePriority = 99;
  10494. var UserBlockingPriority$2 = 98;
  10495. var NormalPriority = 97;
  10496. var LowPriority = 96;
  10497. var IdlePriority = 95;
  10498. // NoPriority is the absence of priority. Also React-only.
  10499. var NoPriority = 90;
  10500. var shouldYield = Scheduler_shouldYield;
  10501. var requestPaint =
  10502. // Fall back gracefully if we're running an older version of Scheduler.
  10503. Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function () {};
  10504. var syncQueue = null;
  10505. var immediateQueueCallbackNode = null;
  10506. var isFlushingSyncQueue = false;
  10507. var initialTimeMs = Scheduler_now();
  10508. // If the initial timestamp is reasonably small, use Scheduler's `now` directly.
  10509. // This will be the case for modern browsers that support `performance.now`. In
  10510. // older browsers, Scheduler falls back to `Date.now`, which returns a Unix
  10511. // timestamp. In that case, subtract the module initialization time to simulate
  10512. // the behavior of performance.now and keep our times small enough to fit
  10513. // within 32 bits.
  10514. // TODO: Consider lifting this into Scheduler.
  10515. var now = initialTimeMs < 10000 ? Scheduler_now : function () {
  10516. return Scheduler_now() - initialTimeMs;
  10517. };
  10518. function getCurrentPriorityLevel() {
  10519. switch (Scheduler_getCurrentPriorityLevel()) {
  10520. case Scheduler_ImmediatePriority:
  10521. return ImmediatePriority;
  10522. case Scheduler_UserBlockingPriority:
  10523. return UserBlockingPriority$2;
  10524. case Scheduler_NormalPriority:
  10525. return NormalPriority;
  10526. case Scheduler_LowPriority:
  10527. return LowPriority;
  10528. case Scheduler_IdlePriority:
  10529. return IdlePriority;
  10530. default:
  10531. (function () {
  10532. {
  10533. {
  10534. throw ReactError(Error('Unknown priority level.'));
  10535. }
  10536. }
  10537. })();
  10538. }
  10539. }
  10540. function reactPriorityToSchedulerPriority(reactPriorityLevel) {
  10541. switch (reactPriorityLevel) {
  10542. case ImmediatePriority:
  10543. return Scheduler_ImmediatePriority;
  10544. case UserBlockingPriority$2:
  10545. return Scheduler_UserBlockingPriority;
  10546. case NormalPriority:
  10547. return Scheduler_NormalPriority;
  10548. case LowPriority:
  10549. return Scheduler_LowPriority;
  10550. case IdlePriority:
  10551. return Scheduler_IdlePriority;
  10552. default:
  10553. (function () {
  10554. {
  10555. {
  10556. throw ReactError(Error('Unknown priority level.'));
  10557. }
  10558. }
  10559. })();
  10560. }
  10561. }
  10562. function runWithPriority$2(reactPriorityLevel, fn) {
  10563. var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
  10564. return Scheduler_runWithPriority(priorityLevel, fn);
  10565. }
  10566. function scheduleCallback(reactPriorityLevel, callback, options) {
  10567. var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
  10568. return Scheduler_scheduleCallback(priorityLevel, callback, options);
  10569. }
  10570. function scheduleSyncCallback(callback) {
  10571. // Push this callback into an internal queue. We'll flush these either in
  10572. // the next tick, or earlier if something calls `flushSyncCallbackQueue`.
  10573. if (syncQueue === null) {
  10574. syncQueue = [callback];
  10575. // Flush the queue in the next tick, at the earliest.
  10576. immediateQueueCallbackNode = Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueueImpl);
  10577. } else {
  10578. // Push onto existing queue. Don't need to schedule a callback because
  10579. // we already scheduled one when we created the queue.
  10580. syncQueue.push(callback);
  10581. }
  10582. return fakeCallbackNode;
  10583. }
  10584. function cancelCallback(callbackNode) {
  10585. if (callbackNode !== fakeCallbackNode) {
  10586. Scheduler_cancelCallback(callbackNode);
  10587. }
  10588. }
  10589. function flushSyncCallbackQueue() {
  10590. if (immediateQueueCallbackNode !== null) {
  10591. Scheduler_cancelCallback(immediateQueueCallbackNode);
  10592. }
  10593. flushSyncCallbackQueueImpl();
  10594. }
  10595. function flushSyncCallbackQueueImpl() {
  10596. if (!isFlushingSyncQueue && syncQueue !== null) {
  10597. // Prevent re-entrancy.
  10598. isFlushingSyncQueue = true;
  10599. var i = 0;
  10600. try {
  10601. var _isSync = true;
  10602. var queue = syncQueue;
  10603. runWithPriority$2(ImmediatePriority, function () {
  10604. for (; i < queue.length; i++) {
  10605. var callback = queue[i];
  10606. do {
  10607. callback = callback(_isSync);
  10608. } while (callback !== null);
  10609. }
  10610. });
  10611. syncQueue = null;
  10612. } catch (error) {
  10613. // If something throws, leave the remaining callbacks on the queue.
  10614. if (syncQueue !== null) {
  10615. syncQueue = syncQueue.slice(i + 1);
  10616. }
  10617. // Resume flushing in the next tick
  10618. Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueue);
  10619. throw error;
  10620. } finally {
  10621. isFlushingSyncQueue = false;
  10622. }
  10623. }
  10624. }
  10625. var NoMode = 0;
  10626. var StrictMode = 1;
  10627. // TODO: Remove BatchedMode and ConcurrentMode by reading from the root
  10628. // tag instead
  10629. var BatchedMode = 2;
  10630. var ConcurrentMode = 4;
  10631. var ProfileMode = 8;
  10632. // Max 31 bit integer. The max integer size in V8 for 32-bit systems.
  10633. // Math.pow(2, 30) - 1
  10634. // 0b111111111111111111111111111111
  10635. var MAX_SIGNED_31_BIT_INT = 1073741823;
  10636. var NoWork = 0;
  10637. var Never = 1;
  10638. var Sync = MAX_SIGNED_31_BIT_INT;
  10639. var Batched = Sync - 1;
  10640. var UNIT_SIZE = 10;
  10641. var MAGIC_NUMBER_OFFSET = Batched - 1;
  10642. // 1 unit of expiration time represents 10ms.
  10643. function msToExpirationTime(ms) {
  10644. // Always add an offset so that we don't clash with the magic number for NoWork.
  10645. return MAGIC_NUMBER_OFFSET - (ms / UNIT_SIZE | 0);
  10646. }
  10647. function expirationTimeToMs(expirationTime) {
  10648. return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE;
  10649. }
  10650. function ceiling(num, precision) {
  10651. return ((num / precision | 0) + 1) * precision;
  10652. }
  10653. function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) {
  10654. return MAGIC_NUMBER_OFFSET - ceiling(MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE);
  10655. }
  10656. // TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update
  10657. // the names to reflect.
  10658. var LOW_PRIORITY_EXPIRATION = 5000;
  10659. var LOW_PRIORITY_BATCH_SIZE = 250;
  10660. function computeAsyncExpiration(currentTime) {
  10661. return computeExpirationBucket(currentTime, LOW_PRIORITY_EXPIRATION, LOW_PRIORITY_BATCH_SIZE);
  10662. }
  10663. function computeSuspenseExpiration(currentTime, timeoutMs) {
  10664. // TODO: Should we warn if timeoutMs is lower than the normal pri expiration time?
  10665. return computeExpirationBucket(currentTime, timeoutMs, LOW_PRIORITY_BATCH_SIZE);
  10666. }
  10667. // We intentionally set a higher expiration time for interactive updates in
  10668. // dev than in production.
  10669. //
  10670. // If the main thread is being blocked so long that you hit the expiration,
  10671. // it's a problem that could be solved with better scheduling.
  10672. //
  10673. // People will be more likely to notice this and fix it with the long
  10674. // expiration time in development.
  10675. //
  10676. // In production we opt for better UX at the risk of masking scheduling
  10677. // problems, by expiring fast.
  10678. var HIGH_PRIORITY_EXPIRATION = 500;
  10679. var HIGH_PRIORITY_BATCH_SIZE = 100;
  10680. function computeInteractiveExpiration(currentTime) {
  10681. return computeExpirationBucket(currentTime, HIGH_PRIORITY_EXPIRATION, HIGH_PRIORITY_BATCH_SIZE);
  10682. }
  10683. function inferPriorityFromExpirationTime(currentTime, expirationTime) {
  10684. if (expirationTime === Sync) {
  10685. return ImmediatePriority;
  10686. }
  10687. if (expirationTime === Never) {
  10688. return IdlePriority;
  10689. }
  10690. var msUntil = expirationTimeToMs(expirationTime) - expirationTimeToMs(currentTime);
  10691. if (msUntil <= 0) {
  10692. return ImmediatePriority;
  10693. }
  10694. if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) {
  10695. return UserBlockingPriority$2;
  10696. }
  10697. if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) {
  10698. return NormalPriority;
  10699. }
  10700. // TODO: Handle LowPriority
  10701. // Assume anything lower has idle priority
  10702. return IdlePriority;
  10703. }
  10704. /**
  10705. * Forked from fbjs/warning:
  10706. * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
  10707. *
  10708. * Only change is we use console.warn instead of console.error,
  10709. * and do nothing when 'console' is not supported.
  10710. * This really simplifies the code.
  10711. * ---
  10712. * Similar to invariant but only logs a warning if the condition is not met.
  10713. * This can be used to log issues in development environments in critical
  10714. * paths. Removing the logging code for production environments will keep the
  10715. * same logic and follow the same code paths.
  10716. */
  10717. var lowPriorityWarning = function () {};
  10718. {
  10719. var printWarning = function (format) {
  10720. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  10721. args[_key - 1] = arguments[_key];
  10722. }
  10723. var argIndex = 0;
  10724. var message = 'Warning: ' + format.replace(/%s/g, function () {
  10725. return args[argIndex++];
  10726. });
  10727. if (typeof console !== 'undefined') {
  10728. console.warn(message);
  10729. }
  10730. try {
  10731. // --- Welcome to debugging React ---
  10732. // This error was thrown as a convenience so that you can use this stack
  10733. // to find the callsite that caused this warning to fire.
  10734. throw new Error(message);
  10735. } catch (x) {}
  10736. };
  10737. lowPriorityWarning = function (condition, format) {
  10738. if (format === undefined) {
  10739. throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
  10740. }
  10741. if (!condition) {
  10742. for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  10743. args[_key2 - 2] = arguments[_key2];
  10744. }
  10745. printWarning.apply(undefined, [format].concat(args));
  10746. }
  10747. };
  10748. }
  10749. var lowPriorityWarning$1 = lowPriorityWarning;
  10750. var ReactStrictModeWarnings = {
  10751. recordUnsafeLifecycleWarnings: function (fiber, instance) {},
  10752. flushPendingUnsafeLifecycleWarnings: function () {},
  10753. recordLegacyContextWarning: function (fiber, instance) {},
  10754. flushLegacyContextWarning: function () {},
  10755. discardPendingWarnings: function () {}
  10756. };
  10757. {
  10758. var findStrictRoot = function (fiber) {
  10759. var maybeStrictRoot = null;
  10760. var node = fiber;
  10761. while (node !== null) {
  10762. if (node.mode & StrictMode) {
  10763. maybeStrictRoot = node;
  10764. }
  10765. node = node.return;
  10766. }
  10767. return maybeStrictRoot;
  10768. };
  10769. var setToSortedString = function (set) {
  10770. var array = [];
  10771. set.forEach(function (value) {
  10772. array.push(value);
  10773. });
  10774. return array.sort().join(', ');
  10775. };
  10776. var pendingComponentWillMountWarnings = [];
  10777. var pendingUNSAFE_ComponentWillMountWarnings = [];
  10778. var pendingComponentWillReceivePropsWarnings = [];
  10779. var pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
  10780. var pendingComponentWillUpdateWarnings = [];
  10781. var pendingUNSAFE_ComponentWillUpdateWarnings = [];
  10782. // Tracks components we have already warned about.
  10783. var didWarnAboutUnsafeLifecycles = new Set();
  10784. ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) {
  10785. // Dedup strategy: Warn once per component.
  10786. if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
  10787. return;
  10788. }
  10789. if (typeof instance.componentWillMount === 'function' &&
  10790. // Don't warn about react-lifecycles-compat polyfilled components.
  10791. instance.componentWillMount.__suppressDeprecationWarning !== true) {
  10792. pendingComponentWillMountWarnings.push(fiber);
  10793. }
  10794. if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillMount === 'function') {
  10795. pendingUNSAFE_ComponentWillMountWarnings.push(fiber);
  10796. }
  10797. if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
  10798. pendingComponentWillReceivePropsWarnings.push(fiber);
  10799. }
  10800. if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  10801. pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber);
  10802. }
  10803. if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
  10804. pendingComponentWillUpdateWarnings.push(fiber);
  10805. }
  10806. if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillUpdate === 'function') {
  10807. pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber);
  10808. }
  10809. };
  10810. ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () {
  10811. // We do an initial pass to gather component names
  10812. var componentWillMountUniqueNames = new Set();
  10813. if (pendingComponentWillMountWarnings.length > 0) {
  10814. pendingComponentWillMountWarnings.forEach(function (fiber) {
  10815. componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component');
  10816. didWarnAboutUnsafeLifecycles.add(fiber.type);
  10817. });
  10818. pendingComponentWillMountWarnings = [];
  10819. }
  10820. var UNSAFE_componentWillMountUniqueNames = new Set();
  10821. if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) {
  10822. pendingUNSAFE_ComponentWillMountWarnings.forEach(function (fiber) {
  10823. UNSAFE_componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component');
  10824. didWarnAboutUnsafeLifecycles.add(fiber.type);
  10825. });
  10826. pendingUNSAFE_ComponentWillMountWarnings = [];
  10827. }
  10828. var componentWillReceivePropsUniqueNames = new Set();
  10829. if (pendingComponentWillReceivePropsWarnings.length > 0) {
  10830. pendingComponentWillReceivePropsWarnings.forEach(function (fiber) {
  10831. componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component');
  10832. didWarnAboutUnsafeLifecycles.add(fiber.type);
  10833. });
  10834. pendingComponentWillReceivePropsWarnings = [];
  10835. }
  10836. var UNSAFE_componentWillReceivePropsUniqueNames = new Set();
  10837. if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) {
  10838. pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function (fiber) {
  10839. UNSAFE_componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component');
  10840. didWarnAboutUnsafeLifecycles.add(fiber.type);
  10841. });
  10842. pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
  10843. }
  10844. var componentWillUpdateUniqueNames = new Set();
  10845. if (pendingComponentWillUpdateWarnings.length > 0) {
  10846. pendingComponentWillUpdateWarnings.forEach(function (fiber) {
  10847. componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component');
  10848. didWarnAboutUnsafeLifecycles.add(fiber.type);
  10849. });
  10850. pendingComponentWillUpdateWarnings = [];
  10851. }
  10852. var UNSAFE_componentWillUpdateUniqueNames = new Set();
  10853. if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) {
  10854. pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function (fiber) {
  10855. UNSAFE_componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component');
  10856. didWarnAboutUnsafeLifecycles.add(fiber.type);
  10857. });
  10858. pendingUNSAFE_ComponentWillUpdateWarnings = [];
  10859. }
  10860. // Finally, we flush all the warnings
  10861. // UNSAFE_ ones before the deprecated ones, since they'll be 'louder'
  10862. if (UNSAFE_componentWillMountUniqueNames.size > 0) {
  10863. var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames);
  10864. warningWithoutStack$1(false, 'Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. ' + 'See https://fb.me/react-async-component-lifecycle-hooks for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '\nPlease update the following components: %s', sortedNames);
  10865. }
  10866. if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) {
  10867. var _sortedNames = setToSortedString(UNSAFE_componentWillReceivePropsUniqueNames);
  10868. warningWithoutStack$1(false, 'Using UNSAFE_componentWillReceiveProps in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://fb.me/react-async-component-lifecycle-hooks for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, " + 'refactor your code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n' + '\nPlease update the following components: %s', _sortedNames);
  10869. }
  10870. if (UNSAFE_componentWillUpdateUniqueNames.size > 0) {
  10871. var _sortedNames2 = setToSortedString(UNSAFE_componentWillUpdateUniqueNames);
  10872. warningWithoutStack$1(false, 'Using UNSAFE_componentWillUpdate in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://fb.me/react-async-component-lifecycle-hooks for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '\nPlease update the following components: %s', _sortedNames2);
  10873. }
  10874. if (componentWillMountUniqueNames.size > 0) {
  10875. var _sortedNames3 = setToSortedString(componentWillMountUniqueNames);
  10876. lowPriorityWarning$1(false, 'componentWillMount has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-async-component-lifecycle-hooks for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '* Rename componentWillMount to UNSAFE_componentWillMount to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames3);
  10877. }
  10878. if (componentWillReceivePropsUniqueNames.size > 0) {
  10879. var _sortedNames4 = setToSortedString(componentWillReceivePropsUniqueNames);
  10880. lowPriorityWarning$1(false, 'componentWillReceiveProps has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-async-component-lifecycle-hooks for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, refactor your " + 'code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n' + '* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames4);
  10881. }
  10882. if (componentWillUpdateUniqueNames.size > 0) {
  10883. var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames);
  10884. lowPriorityWarning$1(false, 'componentWillUpdate has been renamed, and is not recommended for use. ' + 'See https://fb.me/react-async-component-lifecycle-hooks for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress ' + 'this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. ' + 'To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n' + '\nPlease update the following components: %s', _sortedNames5);
  10885. }
  10886. };
  10887. var pendingLegacyContextWarning = new Map();
  10888. // Tracks components we have already warned about.
  10889. var didWarnAboutLegacyContext = new Set();
  10890. ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) {
  10891. var strictRoot = findStrictRoot(fiber);
  10892. if (strictRoot === null) {
  10893. 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.');
  10894. return;
  10895. }
  10896. // Dedup strategy: Warn once per component.
  10897. if (didWarnAboutLegacyContext.has(fiber.type)) {
  10898. return;
  10899. }
  10900. var warningsForRoot = pendingLegacyContextWarning.get(strictRoot);
  10901. if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') {
  10902. if (warningsForRoot === undefined) {
  10903. warningsForRoot = [];
  10904. pendingLegacyContextWarning.set(strictRoot, warningsForRoot);
  10905. }
  10906. warningsForRoot.push(fiber);
  10907. }
  10908. };
  10909. ReactStrictModeWarnings.flushLegacyContextWarning = function () {
  10910. pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) {
  10911. var uniqueNames = new Set();
  10912. fiberArray.forEach(function (fiber) {
  10913. uniqueNames.add(getComponentName(fiber.type) || 'Component');
  10914. didWarnAboutLegacyContext.add(fiber.type);
  10915. });
  10916. var sortedNames = setToSortedString(uniqueNames);
  10917. var strictRootComponentStack = getStackByFiberInDevAndProd(strictRoot);
  10918. warningWithoutStack$1(false, 'Legacy context API has been detected within a strict-mode tree: %s' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here:' + '\nhttps://fb.me/react-legacy-context', strictRootComponentStack, sortedNames);
  10919. });
  10920. };
  10921. ReactStrictModeWarnings.discardPendingWarnings = function () {
  10922. pendingComponentWillMountWarnings = [];
  10923. pendingUNSAFE_ComponentWillMountWarnings = [];
  10924. pendingComponentWillReceivePropsWarnings = [];
  10925. pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
  10926. pendingComponentWillUpdateWarnings = [];
  10927. pendingUNSAFE_ComponentWillUpdateWarnings = [];
  10928. pendingLegacyContextWarning = new Map();
  10929. };
  10930. }
  10931. // Resolves type to a family.
  10932. // Used by React Refresh runtime through DevTools Global Hook.
  10933. var resolveFamily = null;
  10934. // $FlowFixMe Flow gets confused by a WeakSet feature check below.
  10935. var failedBoundaries = null;
  10936. var setRefreshHandler = function (handler) {
  10937. {
  10938. resolveFamily = handler;
  10939. }
  10940. };
  10941. function resolveFunctionForHotReloading(type) {
  10942. {
  10943. if (resolveFamily === null) {
  10944. // Hot reloading is disabled.
  10945. return type;
  10946. }
  10947. var family = resolveFamily(type);
  10948. if (family === undefined) {
  10949. return type;
  10950. }
  10951. // Use the latest known implementation.
  10952. return family.current;
  10953. }
  10954. }
  10955. function resolveClassForHotReloading(type) {
  10956. // No implementation differences.
  10957. return resolveFunctionForHotReloading(type);
  10958. }
  10959. function resolveForwardRefForHotReloading(type) {
  10960. {
  10961. if (resolveFamily === null) {
  10962. // Hot reloading is disabled.
  10963. return type;
  10964. }
  10965. var family = resolveFamily(type);
  10966. if (family === undefined) {
  10967. // Check if we're dealing with a real forwardRef. Don't want to crash early.
  10968. if (type !== null && type !== undefined && typeof type.render === 'function') {
  10969. // ForwardRef is special because its resolved .type is an object,
  10970. // but it's possible that we only have its inner render function in the map.
  10971. // If that inner render function is different, we'll build a new forwardRef type.
  10972. var currentRender = resolveFunctionForHotReloading(type.render);
  10973. if (type.render !== currentRender) {
  10974. var syntheticType = {
  10975. $$typeof: REACT_FORWARD_REF_TYPE,
  10976. render: currentRender
  10977. };
  10978. if (type.displayName !== undefined) {
  10979. syntheticType.displayName = type.displayName;
  10980. }
  10981. return syntheticType;
  10982. }
  10983. }
  10984. return type;
  10985. }
  10986. // Use the latest known implementation.
  10987. return family.current;
  10988. }
  10989. }
  10990. function isCompatibleFamilyForHotReloading(fiber, element) {
  10991. {
  10992. if (resolveFamily === null) {
  10993. // Hot reloading is disabled.
  10994. return false;
  10995. }
  10996. var prevType = fiber.elementType;
  10997. var nextType = element.type;
  10998. // If we got here, we know types aren't === equal.
  10999. var needsCompareFamilies = false;
  11000. var $$typeofNextType = typeof nextType === 'object' && nextType !== null ? nextType.$$typeof : null;
  11001. switch (fiber.tag) {
  11002. case ClassComponent:
  11003. {
  11004. if (typeof nextType === 'function') {
  11005. needsCompareFamilies = true;
  11006. }
  11007. break;
  11008. }
  11009. case FunctionComponent:
  11010. {
  11011. if (typeof nextType === 'function') {
  11012. needsCompareFamilies = true;
  11013. } else if ($$typeofNextType === REACT_LAZY_TYPE) {
  11014. // We don't know the inner type yet.
  11015. // We're going to assume that the lazy inner type is stable,
  11016. // and so it is sufficient to avoid reconciling it away.
  11017. // We're not going to unwrap or actually use the new lazy type.
  11018. needsCompareFamilies = true;
  11019. }
  11020. break;
  11021. }
  11022. case ForwardRef:
  11023. {
  11024. if ($$typeofNextType === REACT_FORWARD_REF_TYPE) {
  11025. needsCompareFamilies = true;
  11026. } else if ($$typeofNextType === REACT_LAZY_TYPE) {
  11027. needsCompareFamilies = true;
  11028. }
  11029. break;
  11030. }
  11031. case MemoComponent:
  11032. case SimpleMemoComponent:
  11033. {
  11034. if ($$typeofNextType === REACT_MEMO_TYPE) {
  11035. // TODO: if it was but can no longer be simple,
  11036. // we shouldn't set this.
  11037. needsCompareFamilies = true;
  11038. } else if ($$typeofNextType === REACT_LAZY_TYPE) {
  11039. needsCompareFamilies = true;
  11040. }
  11041. break;
  11042. }
  11043. default:
  11044. return false;
  11045. }
  11046. // Check if both types have a family and it's the same one.
  11047. if (needsCompareFamilies) {
  11048. // Note: memo() and forwardRef() we'll compare outer rather than inner type.
  11049. // This means both of them need to be registered to preserve state.
  11050. // If we unwrapped and compared the inner types for wrappers instead,
  11051. // then we would risk falsely saying two separate memo(Foo)
  11052. // calls are equivalent because they wrap the same Foo function.
  11053. var prevFamily = resolveFamily(prevType);
  11054. if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) {
  11055. return true;
  11056. }
  11057. }
  11058. return false;
  11059. }
  11060. }
  11061. function markFailedErrorBoundaryForHotReloading(fiber) {
  11062. {
  11063. if (resolveFamily === null) {
  11064. // Hot reloading is disabled.
  11065. return;
  11066. }
  11067. if (typeof WeakSet !== 'function') {
  11068. return;
  11069. }
  11070. if (failedBoundaries === null) {
  11071. failedBoundaries = new WeakSet();
  11072. }
  11073. failedBoundaries.add(fiber);
  11074. }
  11075. }
  11076. var scheduleRefresh = function (root, update) {
  11077. {
  11078. if (resolveFamily === null) {
  11079. // Hot reloading is disabled.
  11080. return;
  11081. }
  11082. var _staleFamilies = update.staleFamilies,
  11083. _updatedFamilies = update.updatedFamilies;
  11084. flushPassiveEffects();
  11085. flushSync(function () {
  11086. scheduleFibersWithFamiliesRecursively(root.current, _updatedFamilies, _staleFamilies);
  11087. });
  11088. }
  11089. };
  11090. var scheduleRoot = function (root, element) {
  11091. {
  11092. if (root.context !== emptyContextObject) {
  11093. // Super edge case: root has a legacy _renderSubtree context
  11094. // but we don't know the parentComponent so we can't pass it.
  11095. // Just ignore. We'll delete this with _renderSubtree code path later.
  11096. return;
  11097. }
  11098. flushPassiveEffects();
  11099. updateContainerAtExpirationTime(element, root, null, Sync, null);
  11100. }
  11101. };
  11102. function scheduleFibersWithFamiliesRecursively(fiber, updatedFamilies, staleFamilies) {
  11103. {
  11104. var alternate = fiber.alternate,
  11105. child = fiber.child,
  11106. sibling = fiber.sibling,
  11107. tag = fiber.tag,
  11108. type = fiber.type;
  11109. var candidateType = null;
  11110. switch (tag) {
  11111. case FunctionComponent:
  11112. case SimpleMemoComponent:
  11113. case ClassComponent:
  11114. candidateType = type;
  11115. break;
  11116. case ForwardRef:
  11117. candidateType = type.render;
  11118. break;
  11119. default:
  11120. break;
  11121. }
  11122. if (resolveFamily === null) {
  11123. throw new Error('Expected resolveFamily to be set during hot reload.');
  11124. }
  11125. var needsRender = false;
  11126. var needsRemount = false;
  11127. if (candidateType !== null) {
  11128. var family = resolveFamily(candidateType);
  11129. if (family !== undefined) {
  11130. if (staleFamilies.has(family)) {
  11131. needsRemount = true;
  11132. } else if (updatedFamilies.has(family)) {
  11133. needsRender = true;
  11134. }
  11135. }
  11136. }
  11137. if (failedBoundaries !== null) {
  11138. if (failedBoundaries.has(fiber) || alternate !== null && failedBoundaries.has(alternate)) {
  11139. needsRemount = true;
  11140. }
  11141. }
  11142. if (needsRemount) {
  11143. fiber._debugNeedsRemount = true;
  11144. }
  11145. if (needsRemount || needsRender) {
  11146. scheduleWork(fiber, Sync);
  11147. }
  11148. if (child !== null && !needsRemount) {
  11149. scheduleFibersWithFamiliesRecursively(child, updatedFamilies, staleFamilies);
  11150. }
  11151. if (sibling !== null) {
  11152. scheduleFibersWithFamiliesRecursively(sibling, updatedFamilies, staleFamilies);
  11153. }
  11154. }
  11155. }
  11156. var findHostInstancesForRefresh = function (root, families) {
  11157. {
  11158. var hostInstances = new Set();
  11159. var types = new Set(families.map(function (family) {
  11160. return family.current;
  11161. }));
  11162. findHostInstancesForMatchingFibersRecursively(root.current, types, hostInstances);
  11163. return hostInstances;
  11164. }
  11165. };
  11166. function findHostInstancesForMatchingFibersRecursively(fiber, types, hostInstances) {
  11167. {
  11168. var child = fiber.child,
  11169. sibling = fiber.sibling,
  11170. tag = fiber.tag,
  11171. type = fiber.type;
  11172. var candidateType = null;
  11173. switch (tag) {
  11174. case FunctionComponent:
  11175. case SimpleMemoComponent:
  11176. case ClassComponent:
  11177. candidateType = type;
  11178. break;
  11179. case ForwardRef:
  11180. candidateType = type.render;
  11181. break;
  11182. default:
  11183. break;
  11184. }
  11185. var didMatch = false;
  11186. if (candidateType !== null) {
  11187. if (types.has(candidateType)) {
  11188. didMatch = true;
  11189. }
  11190. }
  11191. if (didMatch) {
  11192. // We have a match. This only drills down to the closest host components.
  11193. // There's no need to search deeper because for the purpose of giving
  11194. // visual feedback, "flashing" outermost parent rectangles is sufficient.
  11195. findHostInstancesForFiberShallowly(fiber, hostInstances);
  11196. } else {
  11197. // If there's no match, maybe there will be one further down in the child tree.
  11198. if (child !== null) {
  11199. findHostInstancesForMatchingFibersRecursively(child, types, hostInstances);
  11200. }
  11201. }
  11202. if (sibling !== null) {
  11203. findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances);
  11204. }
  11205. }
  11206. }
  11207. function findHostInstancesForFiberShallowly(fiber, hostInstances) {
  11208. {
  11209. var foundHostInstances = findChildHostInstancesForFiberShallowly(fiber, hostInstances);
  11210. if (foundHostInstances) {
  11211. return;
  11212. }
  11213. // If we didn't find any host children, fallback to closest host parent.
  11214. var node = fiber;
  11215. while (true) {
  11216. switch (node.tag) {
  11217. case HostComponent:
  11218. hostInstances.add(node.stateNode);
  11219. return;
  11220. case HostPortal:
  11221. hostInstances.add(node.stateNode.containerInfo);
  11222. return;
  11223. case HostRoot:
  11224. hostInstances.add(node.stateNode.containerInfo);
  11225. return;
  11226. }
  11227. if (node.return === null) {
  11228. throw new Error('Expected to reach root first.');
  11229. }
  11230. node = node.return;
  11231. }
  11232. }
  11233. }
  11234. function findChildHostInstancesForFiberShallowly(fiber, hostInstances) {
  11235. {
  11236. var node = fiber;
  11237. var foundHostInstances = false;
  11238. while (true) {
  11239. if (node.tag === HostComponent) {
  11240. // We got a match.
  11241. foundHostInstances = true;
  11242. hostInstances.add(node.stateNode);
  11243. // There may still be more, so keep searching.
  11244. } else if (node.child !== null) {
  11245. node.child.return = node;
  11246. node = node.child;
  11247. continue;
  11248. }
  11249. if (node === fiber) {
  11250. return foundHostInstances;
  11251. }
  11252. while (node.sibling === null) {
  11253. if (node.return === null || node.return === fiber) {
  11254. return foundHostInstances;
  11255. }
  11256. node = node.return;
  11257. }
  11258. node.sibling.return = node.return;
  11259. node = node.sibling;
  11260. }
  11261. }
  11262. return false;
  11263. }
  11264. function resolveDefaultProps(Component, baseProps) {
  11265. if (Component && Component.defaultProps) {
  11266. // Resolve default props. Taken from ReactElement
  11267. var props = _assign({}, baseProps);
  11268. var defaultProps = Component.defaultProps;
  11269. for (var propName in defaultProps) {
  11270. if (props[propName] === undefined) {
  11271. props[propName] = defaultProps[propName];
  11272. }
  11273. }
  11274. return props;
  11275. }
  11276. return baseProps;
  11277. }
  11278. function readLazyComponentType(lazyComponent) {
  11279. var status = lazyComponent._status;
  11280. var result = lazyComponent._result;
  11281. switch (status) {
  11282. case Resolved:
  11283. {
  11284. var Component = result;
  11285. return Component;
  11286. }
  11287. case Rejected:
  11288. {
  11289. var error = result;
  11290. throw error;
  11291. }
  11292. case Pending:
  11293. {
  11294. var thenable = result;
  11295. throw thenable;
  11296. }
  11297. default:
  11298. {
  11299. lazyComponent._status = Pending;
  11300. var ctor = lazyComponent._ctor;
  11301. var _thenable = ctor();
  11302. _thenable.then(function (moduleObject) {
  11303. if (lazyComponent._status === Pending) {
  11304. var defaultExport = moduleObject.default;
  11305. {
  11306. if (defaultExport === undefined) {
  11307. 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);
  11308. }
  11309. }
  11310. lazyComponent._status = Resolved;
  11311. lazyComponent._result = defaultExport;
  11312. }
  11313. }, function (error) {
  11314. if (lazyComponent._status === Pending) {
  11315. lazyComponent._status = Rejected;
  11316. lazyComponent._result = error;
  11317. }
  11318. });
  11319. // Handle synchronous thenables.
  11320. switch (lazyComponent._status) {
  11321. case Resolved:
  11322. return lazyComponent._result;
  11323. case Rejected:
  11324. throw lazyComponent._result;
  11325. }
  11326. lazyComponent._result = _thenable;
  11327. throw _thenable;
  11328. }
  11329. }
  11330. }
  11331. var valueCursor = createCursor(null);
  11332. var rendererSigil = void 0;
  11333. {
  11334. // Use this to detect multiple renderers using the same context
  11335. rendererSigil = {};
  11336. }
  11337. var currentlyRenderingFiber = null;
  11338. var lastContextDependency = null;
  11339. var lastContextWithAllBitsObserved = null;
  11340. var isDisallowedContextReadInDEV = false;
  11341. function resetContextDependencies() {
  11342. // This is called right before React yields execution, to ensure `readContext`
  11343. // cannot be called outside the render phase.
  11344. currentlyRenderingFiber = null;
  11345. lastContextDependency = null;
  11346. lastContextWithAllBitsObserved = null;
  11347. {
  11348. isDisallowedContextReadInDEV = false;
  11349. }
  11350. }
  11351. function enterDisallowedContextReadInDEV() {
  11352. {
  11353. isDisallowedContextReadInDEV = true;
  11354. }
  11355. }
  11356. function exitDisallowedContextReadInDEV() {
  11357. {
  11358. isDisallowedContextReadInDEV = false;
  11359. }
  11360. }
  11361. function pushProvider(providerFiber, nextValue) {
  11362. var context = providerFiber.type._context;
  11363. if (isPrimaryRenderer) {
  11364. push(valueCursor, context._currentValue, providerFiber);
  11365. context._currentValue = nextValue;
  11366. {
  11367. !(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;
  11368. context._currentRenderer = rendererSigil;
  11369. }
  11370. } else {
  11371. push(valueCursor, context._currentValue2, providerFiber);
  11372. context._currentValue2 = nextValue;
  11373. {
  11374. !(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;
  11375. context._currentRenderer2 = rendererSigil;
  11376. }
  11377. }
  11378. }
  11379. function popProvider(providerFiber) {
  11380. var currentValue = valueCursor.current;
  11381. pop(valueCursor, providerFiber);
  11382. var context = providerFiber.type._context;
  11383. if (isPrimaryRenderer) {
  11384. context._currentValue = currentValue;
  11385. } else {
  11386. context._currentValue2 = currentValue;
  11387. }
  11388. }
  11389. function calculateChangedBits(context, newValue, oldValue) {
  11390. if (is(oldValue, newValue)) {
  11391. // No change
  11392. return 0;
  11393. } else {
  11394. var changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
  11395. {
  11396. !((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits) ? warning$1(false, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits) : void 0;
  11397. }
  11398. return changedBits | 0;
  11399. }
  11400. }
  11401. function scheduleWorkOnParentPath(parent, renderExpirationTime) {
  11402. // Update the child expiration time of all the ancestors, including
  11403. // the alternates.
  11404. var node = parent;
  11405. while (node !== null) {
  11406. var alternate = node.alternate;
  11407. if (node.childExpirationTime < renderExpirationTime) {
  11408. node.childExpirationTime = renderExpirationTime;
  11409. if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
  11410. alternate.childExpirationTime = renderExpirationTime;
  11411. }
  11412. } else if (alternate !== null && alternate.childExpirationTime < renderExpirationTime) {
  11413. alternate.childExpirationTime = renderExpirationTime;
  11414. } else {
  11415. // Neither alternate was updated, which means the rest of the
  11416. // ancestor path already has sufficient priority.
  11417. break;
  11418. }
  11419. node = node.return;
  11420. }
  11421. }
  11422. function propagateContextChange(workInProgress, context, changedBits, renderExpirationTime) {
  11423. var fiber = workInProgress.child;
  11424. if (fiber !== null) {
  11425. // Set the return pointer of the child to the work-in-progress fiber.
  11426. fiber.return = workInProgress;
  11427. }
  11428. while (fiber !== null) {
  11429. var nextFiber = void 0;
  11430. // Visit this fiber.
  11431. var list = fiber.dependencies;
  11432. if (list !== null) {
  11433. nextFiber = fiber.child;
  11434. var dependency = list.firstContext;
  11435. while (dependency !== null) {
  11436. // Check if the context matches.
  11437. if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) {
  11438. // Match! Schedule an update on this fiber.
  11439. if (fiber.tag === ClassComponent) {
  11440. // Schedule a force update on the work-in-progress.
  11441. var update = createUpdate(renderExpirationTime, null);
  11442. update.tag = ForceUpdate;
  11443. // TODO: Because we don't have a work-in-progress, this will add the
  11444. // update to the current fiber, too, which means it will persist even if
  11445. // this render is thrown away. Since it's a race condition, not sure it's
  11446. // worth fixing.
  11447. enqueueUpdate(fiber, update);
  11448. }
  11449. if (fiber.expirationTime < renderExpirationTime) {
  11450. fiber.expirationTime = renderExpirationTime;
  11451. }
  11452. var alternate = fiber.alternate;
  11453. if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
  11454. alternate.expirationTime = renderExpirationTime;
  11455. }
  11456. scheduleWorkOnParentPath(fiber.return, renderExpirationTime);
  11457. // Mark the expiration time on the list, too.
  11458. if (list.expirationTime < renderExpirationTime) {
  11459. list.expirationTime = renderExpirationTime;
  11460. }
  11461. // Since we already found a match, we can stop traversing the
  11462. // dependency list.
  11463. break;
  11464. }
  11465. dependency = dependency.next;
  11466. }
  11467. } else if (fiber.tag === ContextProvider) {
  11468. // Don't scan deeper if this is a matching provider
  11469. nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
  11470. } else if (enableSuspenseServerRenderer && fiber.tag === DehydratedSuspenseComponent) {
  11471. // If a dehydrated suspense component is in this subtree, we don't know
  11472. // if it will have any context consumers in it. The best we can do is
  11473. // mark it as having updates on its children.
  11474. if (fiber.expirationTime < renderExpirationTime) {
  11475. fiber.expirationTime = renderExpirationTime;
  11476. }
  11477. var _alternate = fiber.alternate;
  11478. if (_alternate !== null && _alternate.expirationTime < renderExpirationTime) {
  11479. _alternate.expirationTime = renderExpirationTime;
  11480. }
  11481. // This is intentionally passing this fiber as the parent
  11482. // because we want to schedule this fiber as having work
  11483. // on its children. We'll use the childExpirationTime on
  11484. // this fiber to indicate that a context has changed.
  11485. scheduleWorkOnParentPath(fiber, renderExpirationTime);
  11486. nextFiber = fiber.sibling;
  11487. } else {
  11488. // Traverse down.
  11489. nextFiber = fiber.child;
  11490. }
  11491. if (nextFiber !== null) {
  11492. // Set the return pointer of the child to the work-in-progress fiber.
  11493. nextFiber.return = fiber;
  11494. } else {
  11495. // No child. Traverse to next sibling.
  11496. nextFiber = fiber;
  11497. while (nextFiber !== null) {
  11498. if (nextFiber === workInProgress) {
  11499. // We're back to the root of this subtree. Exit.
  11500. nextFiber = null;
  11501. break;
  11502. }
  11503. var sibling = nextFiber.sibling;
  11504. if (sibling !== null) {
  11505. // Set the return pointer of the sibling to the work-in-progress fiber.
  11506. sibling.return = nextFiber.return;
  11507. nextFiber = sibling;
  11508. break;
  11509. }
  11510. // No more siblings. Traverse up.
  11511. nextFiber = nextFiber.return;
  11512. }
  11513. }
  11514. fiber = nextFiber;
  11515. }
  11516. }
  11517. function prepareToReadContext(workInProgress, renderExpirationTime) {
  11518. currentlyRenderingFiber = workInProgress;
  11519. lastContextDependency = null;
  11520. lastContextWithAllBitsObserved = null;
  11521. var dependencies = workInProgress.dependencies;
  11522. if (dependencies !== null) {
  11523. var firstContext = dependencies.firstContext;
  11524. if (firstContext !== null) {
  11525. if (dependencies.expirationTime >= renderExpirationTime) {
  11526. // Context list has a pending update. Mark that this fiber performed work.
  11527. markWorkInProgressReceivedUpdate();
  11528. }
  11529. // Reset the work-in-progress list
  11530. dependencies.firstContext = null;
  11531. }
  11532. }
  11533. }
  11534. function readContext(context, observedBits) {
  11535. {
  11536. // This warning would fire if you read context inside a Hook like useMemo.
  11537. // Unlike the class check below, it's not enforced in production for perf.
  11538. !!isDisallowedContextReadInDEV ? warning$1(false, 'Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().') : void 0;
  11539. }
  11540. if (lastContextWithAllBitsObserved === context) {
  11541. // Nothing to do. We already observe everything in this context.
  11542. } else if (observedBits === false || observedBits === 0) {
  11543. // Do not observe any updates.
  11544. } else {
  11545. var resolvedObservedBits = void 0; // Avoid deopting on observable arguments or heterogeneous types.
  11546. if (typeof observedBits !== 'number' || observedBits === MAX_SIGNED_31_BIT_INT) {
  11547. // Observe all updates.
  11548. lastContextWithAllBitsObserved = context;
  11549. resolvedObservedBits = MAX_SIGNED_31_BIT_INT;
  11550. } else {
  11551. resolvedObservedBits = observedBits;
  11552. }
  11553. var contextItem = {
  11554. context: context,
  11555. observedBits: resolvedObservedBits,
  11556. next: null
  11557. };
  11558. if (lastContextDependency === null) {
  11559. (function () {
  11560. if (!(currentlyRenderingFiber !== null)) {
  11561. {
  11562. throw ReactError(Error('Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().'));
  11563. }
  11564. }
  11565. })();
  11566. // This is the first dependency for this component. Create a new list.
  11567. lastContextDependency = contextItem;
  11568. currentlyRenderingFiber.dependencies = {
  11569. expirationTime: NoWork,
  11570. firstContext: contextItem,
  11571. responders: null
  11572. };
  11573. } else {
  11574. // Append a new context item.
  11575. lastContextDependency = lastContextDependency.next = contextItem;
  11576. }
  11577. }
  11578. return isPrimaryRenderer ? context._currentValue : context._currentValue2;
  11579. }
  11580. // UpdateQueue is a linked list of prioritized updates.
  11581. //
  11582. // Like fibers, update queues come in pairs: a current queue, which represents
  11583. // the visible state of the screen, and a work-in-progress queue, which can be
  11584. // mutated and processed asynchronously before it is committed — a form of
  11585. // double buffering. If a work-in-progress render is discarded before finishing,
  11586. // we create a new work-in-progress by cloning the current queue.
  11587. //
  11588. // Both queues share a persistent, singly-linked list structure. To schedule an
  11589. // update, we append it to the end of both queues. Each queue maintains a
  11590. // pointer to first update in the persistent list that hasn't been processed.
  11591. // The work-in-progress pointer always has a position equal to or greater than
  11592. // the current queue, since we always work on that one. The current queue's
  11593. // pointer is only updated during the commit phase, when we swap in the
  11594. // work-in-progress.
  11595. //
  11596. // For example:
  11597. //
  11598. // Current pointer: A - B - C - D - E - F
  11599. // Work-in-progress pointer: D - E - F
  11600. // ^
  11601. // The work-in-progress queue has
  11602. // processed more updates than current.
  11603. //
  11604. // The reason we append to both queues is because otherwise we might drop
  11605. // updates without ever processing them. For example, if we only add updates to
  11606. // the work-in-progress queue, some updates could be lost whenever a work-in
  11607. // -progress render restarts by cloning from current. Similarly, if we only add
  11608. // updates to the current queue, the updates will be lost whenever an already
  11609. // in-progress queue commits and swaps with the current queue. However, by
  11610. // adding to both queues, we guarantee that the update will be part of the next
  11611. // work-in-progress. (And because the work-in-progress queue becomes the
  11612. // current queue once it commits, there's no danger of applying the same
  11613. // update twice.)
  11614. //
  11615. // Prioritization
  11616. // --------------
  11617. //
  11618. // Updates are not sorted by priority, but by insertion; new updates are always
  11619. // appended to the end of the list.
  11620. //
  11621. // The priority is still important, though. When processing the update queue
  11622. // during the render phase, only the updates with sufficient priority are
  11623. // included in the result. If we skip an update because it has insufficient
  11624. // priority, it remains in the queue to be processed later, during a lower
  11625. // priority render. Crucially, all updates subsequent to a skipped update also
  11626. // remain in the queue *regardless of their priority*. That means high priority
  11627. // updates are sometimes processed twice, at two separate priorities. We also
  11628. // keep track of a base state, that represents the state before the first
  11629. // update in the queue is applied.
  11630. //
  11631. // For example:
  11632. //
  11633. // Given a base state of '', and the following queue of updates
  11634. //
  11635. // A1 - B2 - C1 - D2
  11636. //
  11637. // where the number indicates the priority, and the update is applied to the
  11638. // previous state by appending a letter, React will process these updates as
  11639. // two separate renders, one per distinct priority level:
  11640. //
  11641. // First render, at priority 1:
  11642. // Base state: ''
  11643. // Updates: [A1, C1]
  11644. // Result state: 'AC'
  11645. //
  11646. // Second render, at priority 2:
  11647. // Base state: 'A' <- The base state does not include C1,
  11648. // because B2 was skipped.
  11649. // Updates: [B2, C1, D2] <- C1 was rebased on top of B2
  11650. // Result state: 'ABCD'
  11651. //
  11652. // Because we process updates in insertion order, and rebase high priority
  11653. // updates when preceding updates are skipped, the final result is deterministic
  11654. // regardless of priority. Intermediate state may vary according to system
  11655. // resources, but the final state is always the same.
  11656. var UpdateState = 0;
  11657. var ReplaceState = 1;
  11658. var ForceUpdate = 2;
  11659. var CaptureUpdate = 3;
  11660. // Global state that is reset at the beginning of calling `processUpdateQueue`.
  11661. // It should only be read right after calling `processUpdateQueue`, via
  11662. // `checkHasForceUpdateAfterProcessing`.
  11663. var hasForceUpdate = false;
  11664. var didWarnUpdateInsideUpdate = void 0;
  11665. var currentlyProcessingQueue = void 0;
  11666. {
  11667. didWarnUpdateInsideUpdate = false;
  11668. currentlyProcessingQueue = null;
  11669. }
  11670. function createUpdateQueue(baseState) {
  11671. var queue = {
  11672. baseState: baseState,
  11673. firstUpdate: null,
  11674. lastUpdate: null,
  11675. firstCapturedUpdate: null,
  11676. lastCapturedUpdate: null,
  11677. firstEffect: null,
  11678. lastEffect: null,
  11679. firstCapturedEffect: null,
  11680. lastCapturedEffect: null
  11681. };
  11682. return queue;
  11683. }
  11684. function cloneUpdateQueue(currentQueue) {
  11685. var queue = {
  11686. baseState: currentQueue.baseState,
  11687. firstUpdate: currentQueue.firstUpdate,
  11688. lastUpdate: currentQueue.lastUpdate,
  11689. // TODO: With resuming, if we bail out and resuse the child tree, we should
  11690. // keep these effects.
  11691. firstCapturedUpdate: null,
  11692. lastCapturedUpdate: null,
  11693. firstEffect: null,
  11694. lastEffect: null,
  11695. firstCapturedEffect: null,
  11696. lastCapturedEffect: null
  11697. };
  11698. return queue;
  11699. }
  11700. function createUpdate(expirationTime, suspenseConfig) {
  11701. var update = {
  11702. expirationTime: expirationTime,
  11703. suspenseConfig: suspenseConfig,
  11704. tag: UpdateState,
  11705. payload: null,
  11706. callback: null,
  11707. next: null,
  11708. nextEffect: null
  11709. };
  11710. {
  11711. update.priority = getCurrentPriorityLevel();
  11712. }
  11713. return update;
  11714. }
  11715. function appendUpdateToQueue(queue, update) {
  11716. // Append the update to the end of the list.
  11717. if (queue.lastUpdate === null) {
  11718. // Queue is empty
  11719. queue.firstUpdate = queue.lastUpdate = update;
  11720. } else {
  11721. queue.lastUpdate.next = update;
  11722. queue.lastUpdate = update;
  11723. }
  11724. }
  11725. function enqueueUpdate(fiber, update) {
  11726. // Update queues are created lazily.
  11727. var alternate = fiber.alternate;
  11728. var queue1 = void 0;
  11729. var queue2 = void 0;
  11730. if (alternate === null) {
  11731. // There's only one fiber.
  11732. queue1 = fiber.updateQueue;
  11733. queue2 = null;
  11734. if (queue1 === null) {
  11735. queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState);
  11736. }
  11737. } else {
  11738. // There are two owners.
  11739. queue1 = fiber.updateQueue;
  11740. queue2 = alternate.updateQueue;
  11741. if (queue1 === null) {
  11742. if (queue2 === null) {
  11743. // Neither fiber has an update queue. Create new ones.
  11744. queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState);
  11745. queue2 = alternate.updateQueue = createUpdateQueue(alternate.memoizedState);
  11746. } else {
  11747. // Only one fiber has an update queue. Clone to create a new one.
  11748. queue1 = fiber.updateQueue = cloneUpdateQueue(queue2);
  11749. }
  11750. } else {
  11751. if (queue2 === null) {
  11752. // Only one fiber has an update queue. Clone to create a new one.
  11753. queue2 = alternate.updateQueue = cloneUpdateQueue(queue1);
  11754. } else {
  11755. // Both owners have an update queue.
  11756. }
  11757. }
  11758. }
  11759. if (queue2 === null || queue1 === queue2) {
  11760. // There's only a single queue.
  11761. appendUpdateToQueue(queue1, update);
  11762. } else {
  11763. // There are two queues. We need to append the update to both queues,
  11764. // while accounting for the persistent structure of the list — we don't
  11765. // want the same update to be added multiple times.
  11766. if (queue1.lastUpdate === null || queue2.lastUpdate === null) {
  11767. // One of the queues is not empty. We must add the update to both queues.
  11768. appendUpdateToQueue(queue1, update);
  11769. appendUpdateToQueue(queue2, update);
  11770. } else {
  11771. // Both queues are non-empty. The last update is the same in both lists,
  11772. // because of structural sharing. So, only append to one of the lists.
  11773. appendUpdateToQueue(queue1, update);
  11774. // But we still need to update the `lastUpdate` pointer of queue2.
  11775. queue2.lastUpdate = update;
  11776. }
  11777. }
  11778. {
  11779. if (fiber.tag === ClassComponent && (currentlyProcessingQueue === queue1 || queue2 !== null && currentlyProcessingQueue === queue2) && !didWarnUpdateInsideUpdate) {
  11780. 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.');
  11781. didWarnUpdateInsideUpdate = true;
  11782. }
  11783. }
  11784. }
  11785. function enqueueCapturedUpdate(workInProgress, update) {
  11786. // Captured updates go into a separate list, and only on the work-in-
  11787. // progress queue.
  11788. var workInProgressQueue = workInProgress.updateQueue;
  11789. if (workInProgressQueue === null) {
  11790. workInProgressQueue = workInProgress.updateQueue = createUpdateQueue(workInProgress.memoizedState);
  11791. } else {
  11792. // TODO: I put this here rather than createWorkInProgress so that we don't
  11793. // clone the queue unnecessarily. There's probably a better way to
  11794. // structure this.
  11795. workInProgressQueue = ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue);
  11796. }
  11797. // Append the update to the end of the list.
  11798. if (workInProgressQueue.lastCapturedUpdate === null) {
  11799. // This is the first render phase update
  11800. workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update;
  11801. } else {
  11802. workInProgressQueue.lastCapturedUpdate.next = update;
  11803. workInProgressQueue.lastCapturedUpdate = update;
  11804. }
  11805. }
  11806. function ensureWorkInProgressQueueIsAClone(workInProgress, queue) {
  11807. var current = workInProgress.alternate;
  11808. if (current !== null) {
  11809. // If the work-in-progress queue is equal to the current queue,
  11810. // we need to clone it first.
  11811. if (queue === current.updateQueue) {
  11812. queue = workInProgress.updateQueue = cloneUpdateQueue(queue);
  11813. }
  11814. }
  11815. return queue;
  11816. }
  11817. function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) {
  11818. switch (update.tag) {
  11819. case ReplaceState:
  11820. {
  11821. var _payload = update.payload;
  11822. if (typeof _payload === 'function') {
  11823. // Updater function
  11824. {
  11825. enterDisallowedContextReadInDEV();
  11826. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  11827. _payload.call(instance, prevState, nextProps);
  11828. }
  11829. }
  11830. var nextState = _payload.call(instance, prevState, nextProps);
  11831. {
  11832. exitDisallowedContextReadInDEV();
  11833. }
  11834. return nextState;
  11835. }
  11836. // State object
  11837. return _payload;
  11838. }
  11839. case CaptureUpdate:
  11840. {
  11841. workInProgress.effectTag = workInProgress.effectTag & ~ShouldCapture | DidCapture;
  11842. }
  11843. // Intentional fallthrough
  11844. case UpdateState:
  11845. {
  11846. var _payload2 = update.payload;
  11847. var partialState = void 0;
  11848. if (typeof _payload2 === 'function') {
  11849. // Updater function
  11850. {
  11851. enterDisallowedContextReadInDEV();
  11852. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  11853. _payload2.call(instance, prevState, nextProps);
  11854. }
  11855. }
  11856. partialState = _payload2.call(instance, prevState, nextProps);
  11857. {
  11858. exitDisallowedContextReadInDEV();
  11859. }
  11860. } else {
  11861. // Partial state object
  11862. partialState = _payload2;
  11863. }
  11864. if (partialState === null || partialState === undefined) {
  11865. // Null and undefined are treated as no-ops.
  11866. return prevState;
  11867. }
  11868. // Merge the partial state and the previous state.
  11869. return _assign({}, prevState, partialState);
  11870. }
  11871. case ForceUpdate:
  11872. {
  11873. hasForceUpdate = true;
  11874. return prevState;
  11875. }
  11876. }
  11877. return prevState;
  11878. }
  11879. function processUpdateQueue(workInProgress, queue, props, instance, renderExpirationTime) {
  11880. hasForceUpdate = false;
  11881. queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue);
  11882. {
  11883. currentlyProcessingQueue = queue;
  11884. }
  11885. // These values may change as we process the queue.
  11886. var newBaseState = queue.baseState;
  11887. var newFirstUpdate = null;
  11888. var newExpirationTime = NoWork;
  11889. // Iterate through the list of updates to compute the result.
  11890. var update = queue.firstUpdate;
  11891. var resultState = newBaseState;
  11892. while (update !== null) {
  11893. var updateExpirationTime = update.expirationTime;
  11894. if (updateExpirationTime < renderExpirationTime) {
  11895. // This update does not have sufficient priority. Skip it.
  11896. if (newFirstUpdate === null) {
  11897. // This is the first skipped update. It will be the first update in
  11898. // the new list.
  11899. newFirstUpdate = update;
  11900. // Since this is the first update that was skipped, the current result
  11901. // is the new base state.
  11902. newBaseState = resultState;
  11903. }
  11904. // Since this update will remain in the list, update the remaining
  11905. // expiration time.
  11906. if (newExpirationTime < updateExpirationTime) {
  11907. newExpirationTime = updateExpirationTime;
  11908. }
  11909. } else {
  11910. // This update does have sufficient priority.
  11911. // Mark the event time of this update as relevant to this render pass.
  11912. // TODO: This should ideally use the true event time of this update rather than
  11913. // its priority which is a derived and not reverseable value.
  11914. // TODO: We should skip this update if it was already committed but currently
  11915. // we have no way of detecting the difference between a committed and suspended
  11916. // update here.
  11917. markRenderEventTimeAndConfig(updateExpirationTime, update.suspenseConfig);
  11918. // Process it and compute a new result.
  11919. resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance);
  11920. var _callback = update.callback;
  11921. if (_callback !== null) {
  11922. workInProgress.effectTag |= Callback;
  11923. // Set this to null, in case it was mutated during an aborted render.
  11924. update.nextEffect = null;
  11925. if (queue.lastEffect === null) {
  11926. queue.firstEffect = queue.lastEffect = update;
  11927. } else {
  11928. queue.lastEffect.nextEffect = update;
  11929. queue.lastEffect = update;
  11930. }
  11931. }
  11932. }
  11933. // Continue to the next update.
  11934. update = update.next;
  11935. }
  11936. // Separately, iterate though the list of captured updates.
  11937. var newFirstCapturedUpdate = null;
  11938. update = queue.firstCapturedUpdate;
  11939. while (update !== null) {
  11940. var _updateExpirationTime = update.expirationTime;
  11941. if (_updateExpirationTime < renderExpirationTime) {
  11942. // This update does not have sufficient priority. Skip it.
  11943. if (newFirstCapturedUpdate === null) {
  11944. // This is the first skipped captured update. It will be the first
  11945. // update in the new list.
  11946. newFirstCapturedUpdate = update;
  11947. // If this is the first update that was skipped, the current result is
  11948. // the new base state.
  11949. if (newFirstUpdate === null) {
  11950. newBaseState = resultState;
  11951. }
  11952. }
  11953. // Since this update will remain in the list, update the remaining
  11954. // expiration time.
  11955. if (newExpirationTime < _updateExpirationTime) {
  11956. newExpirationTime = _updateExpirationTime;
  11957. }
  11958. } else {
  11959. // This update does have sufficient priority. Process it and compute
  11960. // a new result.
  11961. resultState = getStateFromUpdate(workInProgress, queue, update, resultState, props, instance);
  11962. var _callback2 = update.callback;
  11963. if (_callback2 !== null) {
  11964. workInProgress.effectTag |= Callback;
  11965. // Set this to null, in case it was mutated during an aborted render.
  11966. update.nextEffect = null;
  11967. if (queue.lastCapturedEffect === null) {
  11968. queue.firstCapturedEffect = queue.lastCapturedEffect = update;
  11969. } else {
  11970. queue.lastCapturedEffect.nextEffect = update;
  11971. queue.lastCapturedEffect = update;
  11972. }
  11973. }
  11974. }
  11975. update = update.next;
  11976. }
  11977. if (newFirstUpdate === null) {
  11978. queue.lastUpdate = null;
  11979. }
  11980. if (newFirstCapturedUpdate === null) {
  11981. queue.lastCapturedUpdate = null;
  11982. } else {
  11983. workInProgress.effectTag |= Callback;
  11984. }
  11985. if (newFirstUpdate === null && newFirstCapturedUpdate === null) {
  11986. // We processed every update, without skipping. That means the new base
  11987. // state is the same as the result state.
  11988. newBaseState = resultState;
  11989. }
  11990. queue.baseState = newBaseState;
  11991. queue.firstUpdate = newFirstUpdate;
  11992. queue.firstCapturedUpdate = newFirstCapturedUpdate;
  11993. // Set the remaining expiration time to be whatever is remaining in the queue.
  11994. // This should be fine because the only two other things that contribute to
  11995. // expiration time are props and context. We're already in the middle of the
  11996. // begin phase by the time we start processing the queue, so we've already
  11997. // dealt with the props. Context in components that specify
  11998. // shouldComponentUpdate is tricky; but we'll have to account for
  11999. // that regardless.
  12000. workInProgress.expirationTime = newExpirationTime;
  12001. workInProgress.memoizedState = resultState;
  12002. {
  12003. currentlyProcessingQueue = null;
  12004. }
  12005. }
  12006. function callCallback(callback, context) {
  12007. (function () {
  12008. if (!(typeof callback === 'function')) {
  12009. {
  12010. throw ReactError(Error('Invalid argument passed as callback. Expected a function. Instead received: ' + callback));
  12011. }
  12012. }
  12013. })();
  12014. callback.call(context);
  12015. }
  12016. function resetHasForceUpdateBeforeProcessing() {
  12017. hasForceUpdate = false;
  12018. }
  12019. function checkHasForceUpdateAfterProcessing() {
  12020. return hasForceUpdate;
  12021. }
  12022. function commitUpdateQueue(finishedWork, finishedQueue, instance, renderExpirationTime) {
  12023. // If the finished render included captured updates, and there are still
  12024. // lower priority updates left over, we need to keep the captured updates
  12025. // in the queue so that they are rebased and not dropped once we process the
  12026. // queue again at the lower priority.
  12027. if (finishedQueue.firstCapturedUpdate !== null) {
  12028. // Join the captured update list to the end of the normal list.
  12029. if (finishedQueue.lastUpdate !== null) {
  12030. finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate;
  12031. finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate;
  12032. }
  12033. // Clear the list of captured updates.
  12034. finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null;
  12035. }
  12036. // Commit the effects
  12037. commitUpdateEffects(finishedQueue.firstEffect, instance);
  12038. finishedQueue.firstEffect = finishedQueue.lastEffect = null;
  12039. commitUpdateEffects(finishedQueue.firstCapturedEffect, instance);
  12040. finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null;
  12041. }
  12042. function commitUpdateEffects(effect, instance) {
  12043. while (effect !== null) {
  12044. var _callback3 = effect.callback;
  12045. if (_callback3 !== null) {
  12046. effect.callback = null;
  12047. callCallback(_callback3, instance);
  12048. }
  12049. effect = effect.nextEffect;
  12050. }
  12051. }
  12052. var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
  12053. function requestCurrentSuspenseConfig() {
  12054. return ReactCurrentBatchConfig.suspense;
  12055. }
  12056. var fakeInternalInstance = {};
  12057. var isArray$1 = Array.isArray;
  12058. // React.Component uses a shared frozen object by default.
  12059. // We'll use it to determine whether we need to initialize legacy refs.
  12060. var emptyRefsObject = new React.Component().refs;
  12061. var didWarnAboutStateAssignmentForComponent = void 0;
  12062. var didWarnAboutUninitializedState = void 0;
  12063. var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = void 0;
  12064. var didWarnAboutLegacyLifecyclesAndDerivedState = void 0;
  12065. var didWarnAboutUndefinedDerivedState = void 0;
  12066. var warnOnUndefinedDerivedState = void 0;
  12067. var warnOnInvalidCallback$1 = void 0;
  12068. var didWarnAboutDirectlyAssigningPropsToState = void 0;
  12069. var didWarnAboutContextTypeAndContextTypes = void 0;
  12070. var didWarnAboutInvalidateContextType = void 0;
  12071. {
  12072. didWarnAboutStateAssignmentForComponent = new Set();
  12073. didWarnAboutUninitializedState = new Set();
  12074. didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set();
  12075. didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
  12076. didWarnAboutDirectlyAssigningPropsToState = new Set();
  12077. didWarnAboutUndefinedDerivedState = new Set();
  12078. didWarnAboutContextTypeAndContextTypes = new Set();
  12079. didWarnAboutInvalidateContextType = new Set();
  12080. var didWarnOnInvalidCallback = new Set();
  12081. warnOnInvalidCallback$1 = function (callback, callerName) {
  12082. if (callback === null || typeof callback === 'function') {
  12083. return;
  12084. }
  12085. var key = callerName + '_' + callback;
  12086. if (!didWarnOnInvalidCallback.has(key)) {
  12087. didWarnOnInvalidCallback.add(key);
  12088. warningWithoutStack$1(false, '%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
  12089. }
  12090. };
  12091. warnOnUndefinedDerivedState = function (type, partialState) {
  12092. if (partialState === undefined) {
  12093. var componentName = getComponentName(type) || 'Component';
  12094. if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
  12095. didWarnAboutUndefinedDerivedState.add(componentName);
  12096. warningWithoutStack$1(false, '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
  12097. }
  12098. }
  12099. };
  12100. // This is so gross but it's at least non-critical and can be removed if
  12101. // it causes problems. This is meant to give a nicer error message for
  12102. // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component,
  12103. // ...)) which otherwise throws a "_processChildContext is not a function"
  12104. // exception.
  12105. Object.defineProperty(fakeInternalInstance, '_processChildContext', {
  12106. enumerable: false,
  12107. value: function () {
  12108. (function () {
  12109. {
  12110. {
  12111. throw ReactError(Error('_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn\'t supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal).'));
  12112. }
  12113. }
  12114. })();
  12115. }
  12116. });
  12117. Object.freeze(fakeInternalInstance);
  12118. }
  12119. function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) {
  12120. var prevState = workInProgress.memoizedState;
  12121. {
  12122. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  12123. // Invoke the function an extra time to help detect side-effects.
  12124. getDerivedStateFromProps(nextProps, prevState);
  12125. }
  12126. }
  12127. var partialState = getDerivedStateFromProps(nextProps, prevState);
  12128. {
  12129. warnOnUndefinedDerivedState(ctor, partialState);
  12130. }
  12131. // Merge the partial state and the previous state.
  12132. var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState);
  12133. workInProgress.memoizedState = memoizedState;
  12134. // Once the update queue is empty, persist the derived state onto the
  12135. // base state.
  12136. var updateQueue = workInProgress.updateQueue;
  12137. if (updateQueue !== null && workInProgress.expirationTime === NoWork) {
  12138. updateQueue.baseState = memoizedState;
  12139. }
  12140. }
  12141. var classComponentUpdater = {
  12142. isMounted: isMounted,
  12143. enqueueSetState: function (inst, payload, callback) {
  12144. var fiber = get(inst);
  12145. var currentTime = requestCurrentTime();
  12146. var suspenseConfig = requestCurrentSuspenseConfig();
  12147. var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
  12148. var update = createUpdate(expirationTime, suspenseConfig);
  12149. update.payload = payload;
  12150. if (callback !== undefined && callback !== null) {
  12151. {
  12152. warnOnInvalidCallback$1(callback, 'setState');
  12153. }
  12154. update.callback = callback;
  12155. }
  12156. if (revertPassiveEffectsChange) {
  12157. flushPassiveEffects();
  12158. }
  12159. enqueueUpdate(fiber, update);
  12160. scheduleWork(fiber, expirationTime);
  12161. },
  12162. enqueueReplaceState: function (inst, payload, callback) {
  12163. var fiber = get(inst);
  12164. var currentTime = requestCurrentTime();
  12165. var suspenseConfig = requestCurrentSuspenseConfig();
  12166. var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
  12167. var update = createUpdate(expirationTime, suspenseConfig);
  12168. update.tag = ReplaceState;
  12169. update.payload = payload;
  12170. if (callback !== undefined && callback !== null) {
  12171. {
  12172. warnOnInvalidCallback$1(callback, 'replaceState');
  12173. }
  12174. update.callback = callback;
  12175. }
  12176. if (revertPassiveEffectsChange) {
  12177. flushPassiveEffects();
  12178. }
  12179. enqueueUpdate(fiber, update);
  12180. scheduleWork(fiber, expirationTime);
  12181. },
  12182. enqueueForceUpdate: function (inst, callback) {
  12183. var fiber = get(inst);
  12184. var currentTime = requestCurrentTime();
  12185. var suspenseConfig = requestCurrentSuspenseConfig();
  12186. var expirationTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig);
  12187. var update = createUpdate(expirationTime, suspenseConfig);
  12188. update.tag = ForceUpdate;
  12189. if (callback !== undefined && callback !== null) {
  12190. {
  12191. warnOnInvalidCallback$1(callback, 'forceUpdate');
  12192. }
  12193. update.callback = callback;
  12194. }
  12195. if (revertPassiveEffectsChange) {
  12196. flushPassiveEffects();
  12197. }
  12198. enqueueUpdate(fiber, update);
  12199. scheduleWork(fiber, expirationTime);
  12200. }
  12201. };
  12202. function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) {
  12203. var instance = workInProgress.stateNode;
  12204. if (typeof instance.shouldComponentUpdate === 'function') {
  12205. startPhaseTimer(workInProgress, 'shouldComponentUpdate');
  12206. var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext);
  12207. stopPhaseTimer();
  12208. {
  12209. !(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;
  12210. }
  12211. return shouldUpdate;
  12212. }
  12213. if (ctor.prototype && ctor.prototype.isPureReactComponent) {
  12214. return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
  12215. }
  12216. return true;
  12217. }
  12218. function checkClassInstance(workInProgress, ctor, newProps) {
  12219. var instance = workInProgress.stateNode;
  12220. {
  12221. var name = getComponentName(ctor) || 'Component';
  12222. var renderPresent = instance.render;
  12223. if (!renderPresent) {
  12224. if (ctor.prototype && typeof ctor.prototype.render === 'function') {
  12225. warningWithoutStack$1(false, '%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
  12226. } else {
  12227. warningWithoutStack$1(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
  12228. }
  12229. }
  12230. var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state;
  12231. !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;
  12232. var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved;
  12233. !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;
  12234. var noInstancePropTypes = !instance.propTypes;
  12235. !noInstancePropTypes ? warningWithoutStack$1(false, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name) : void 0;
  12236. var noInstanceContextType = !instance.contextType;
  12237. !noInstanceContextType ? warningWithoutStack$1(false, 'contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name) : void 0;
  12238. if (disableLegacyContext) {
  12239. if (ctor.childContextTypes) {
  12240. warningWithoutStack$1(false, '%s uses the legacy childContextTypes API which is no longer supported. ' + 'Use React.createContext() instead.', name);
  12241. }
  12242. if (ctor.contextTypes) {
  12243. warningWithoutStack$1(false, '%s uses the legacy contextTypes API which is no longer supported. ' + 'Use React.createContext() with static contextType instead.', name);
  12244. }
  12245. } else {
  12246. var noInstanceContextTypes = !instance.contextTypes;
  12247. !noInstanceContextTypes ? warningWithoutStack$1(false, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name) : void 0;
  12248. if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
  12249. didWarnAboutContextTypeAndContextTypes.add(ctor);
  12250. warningWithoutStack$1(false, '%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
  12251. }
  12252. }
  12253. var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';
  12254. !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;
  12255. if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
  12256. 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');
  12257. }
  12258. var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';
  12259. !noComponentDidUnmount ? warningWithoutStack$1(false, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name) : void 0;
  12260. var noComponentDidReceiveProps = typeof instance.componentDidReceiveProps !== 'function';
  12261. !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;
  12262. var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';
  12263. !noComponentWillRecieveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name) : void 0;
  12264. var noUnsafeComponentWillRecieveProps = typeof instance.UNSAFE_componentWillRecieveProps !== 'function';
  12265. !noUnsafeComponentWillRecieveProps ? warningWithoutStack$1(false, '%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name) : void 0;
  12266. var hasMutatedProps = instance.props !== newProps;
  12267. !(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;
  12268. var noInstanceDefaultProps = !instance.defaultProps;
  12269. !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;
  12270. if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) {
  12271. didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor);
  12272. warningWithoutStack$1(false, '%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(ctor));
  12273. }
  12274. var noInstanceGetDerivedStateFromProps = typeof instance.getDerivedStateFromProps !== 'function';
  12275. !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;
  12276. var noInstanceGetDerivedStateFromCatch = typeof instance.getDerivedStateFromError !== 'function';
  12277. !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;
  12278. var noStaticGetSnapshotBeforeUpdate = typeof ctor.getSnapshotBeforeUpdate !== 'function';
  12279. !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;
  12280. var _state = instance.state;
  12281. if (_state && (typeof _state !== 'object' || isArray$1(_state))) {
  12282. warningWithoutStack$1(false, '%s.state: must be set to an object or null', name);
  12283. }
  12284. if (typeof instance.getChildContext === 'function') {
  12285. !(typeof ctor.childContextTypes === 'object') ? warningWithoutStack$1(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name) : void 0;
  12286. }
  12287. }
  12288. }
  12289. function adoptClassInstance(workInProgress, instance) {
  12290. instance.updater = classComponentUpdater;
  12291. workInProgress.stateNode = instance;
  12292. // The instance needs access to the fiber so that it can schedule updates
  12293. set(instance, workInProgress);
  12294. {
  12295. instance._reactInternalInstance = fakeInternalInstance;
  12296. }
  12297. }
  12298. function constructClassInstance(workInProgress, ctor, props, renderExpirationTime) {
  12299. var isLegacyContextConsumer = false;
  12300. var unmaskedContext = emptyContextObject;
  12301. var context = emptyContextObject;
  12302. var contextType = ctor.contextType;
  12303. {
  12304. if ('contextType' in ctor) {
  12305. var isValid =
  12306. // Allow null for conditional declaration
  12307. contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer>
  12308. if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
  12309. didWarnAboutInvalidateContextType.add(ctor);
  12310. var addendum = '';
  12311. if (contextType === undefined) {
  12312. addendum = ' However, it is set to undefined. ' + 'This can be caused by a typo or by mixing up named and default imports. ' + 'This can also happen due to a circular dependency, so ' + 'try moving the createContext() call to a separate file.';
  12313. } else if (typeof contextType !== 'object') {
  12314. addendum = ' However, it is set to a ' + typeof contextType + '.';
  12315. } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
  12316. addendum = ' Did you accidentally pass the Context.Provider instead?';
  12317. } else if (contextType._context !== undefined) {
  12318. // <Context.Consumer>
  12319. addendum = ' Did you accidentally pass the Context.Consumer instead?';
  12320. } else {
  12321. addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.';
  12322. }
  12323. warningWithoutStack$1(false, '%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum);
  12324. }
  12325. }
  12326. }
  12327. if (typeof contextType === 'object' && contextType !== null) {
  12328. context = readContext(contextType);
  12329. } else if (!disableLegacyContext) {
  12330. unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  12331. var contextTypes = ctor.contextTypes;
  12332. isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined;
  12333. context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject;
  12334. }
  12335. // Instantiate twice to help detect side-effects.
  12336. {
  12337. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  12338. new ctor(props, context); // eslint-disable-line no-new
  12339. }
  12340. }
  12341. var instance = new ctor(props, context);
  12342. var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null;
  12343. adoptClassInstance(workInProgress, instance);
  12344. {
  12345. if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) {
  12346. var componentName = getComponentName(ctor) || 'Component';
  12347. if (!didWarnAboutUninitializedState.has(componentName)) {
  12348. didWarnAboutUninitializedState.add(componentName);
  12349. 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);
  12350. }
  12351. }
  12352. // If new component APIs are defined, "unsafe" lifecycles won't be called.
  12353. // Warn about these lifecycles if they are present.
  12354. // Don't warn about react-lifecycles-compat polyfilled methods though.
  12355. if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') {
  12356. var foundWillMountName = null;
  12357. var foundWillReceivePropsName = null;
  12358. var foundWillUpdateName = null;
  12359. if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
  12360. foundWillMountName = 'componentWillMount';
  12361. } else if (typeof instance.UNSAFE_componentWillMount === 'function') {
  12362. foundWillMountName = 'UNSAFE_componentWillMount';
  12363. }
  12364. if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
  12365. foundWillReceivePropsName = 'componentWillReceiveProps';
  12366. } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  12367. foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
  12368. }
  12369. if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
  12370. foundWillUpdateName = 'componentWillUpdate';
  12371. } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
  12372. foundWillUpdateName = 'UNSAFE_componentWillUpdate';
  12373. }
  12374. if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
  12375. var _componentName = getComponentName(ctor) || 'Component';
  12376. var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()';
  12377. if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) {
  12378. didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName);
  12379. 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 : '');
  12380. }
  12381. }
  12382. }
  12383. }
  12384. // Cache unmasked context so we can avoid recreating masked context unless necessary.
  12385. // ReactFiberContext usually updates this cache but can't for newly-created instances.
  12386. if (isLegacyContextConsumer) {
  12387. cacheContext(workInProgress, unmaskedContext, context);
  12388. }
  12389. return instance;
  12390. }
  12391. function callComponentWillMount(workInProgress, instance) {
  12392. startPhaseTimer(workInProgress, 'componentWillMount');
  12393. var oldState = instance.state;
  12394. if (typeof instance.componentWillMount === 'function') {
  12395. instance.componentWillMount();
  12396. }
  12397. if (typeof instance.UNSAFE_componentWillMount === 'function') {
  12398. instance.UNSAFE_componentWillMount();
  12399. }
  12400. stopPhaseTimer();
  12401. if (oldState !== instance.state) {
  12402. {
  12403. 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');
  12404. }
  12405. classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
  12406. }
  12407. }
  12408. function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) {
  12409. var oldState = instance.state;
  12410. startPhaseTimer(workInProgress, 'componentWillReceiveProps');
  12411. if (typeof instance.componentWillReceiveProps === 'function') {
  12412. instance.componentWillReceiveProps(newProps, nextContext);
  12413. }
  12414. if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  12415. instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
  12416. }
  12417. stopPhaseTimer();
  12418. if (instance.state !== oldState) {
  12419. {
  12420. var componentName = getComponentName(workInProgress.type) || 'Component';
  12421. if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
  12422. didWarnAboutStateAssignmentForComponent.add(componentName);
  12423. warningWithoutStack$1(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName);
  12424. }
  12425. }
  12426. classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
  12427. }
  12428. }
  12429. // Invokes the mount life-cycles on a previously never rendered instance.
  12430. function mountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
  12431. {
  12432. checkClassInstance(workInProgress, ctor, newProps);
  12433. }
  12434. var instance = workInProgress.stateNode;
  12435. instance.props = newProps;
  12436. instance.state = workInProgress.memoizedState;
  12437. instance.refs = emptyRefsObject;
  12438. var contextType = ctor.contextType;
  12439. if (typeof contextType === 'object' && contextType !== null) {
  12440. instance.context = readContext(contextType);
  12441. } else if (disableLegacyContext) {
  12442. instance.context = emptyContextObject;
  12443. } else {
  12444. var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  12445. instance.context = getMaskedContext(workInProgress, unmaskedContext);
  12446. }
  12447. {
  12448. if (instance.state === newProps) {
  12449. var componentName = getComponentName(ctor) || 'Component';
  12450. if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) {
  12451. didWarnAboutDirectlyAssigningPropsToState.add(componentName);
  12452. 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);
  12453. }
  12454. }
  12455. if (workInProgress.mode & StrictMode) {
  12456. ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance);
  12457. }
  12458. if (warnAboutDeprecatedLifecycles) {
  12459. ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance);
  12460. }
  12461. }
  12462. var updateQueue = workInProgress.updateQueue;
  12463. if (updateQueue !== null) {
  12464. processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
  12465. instance.state = workInProgress.memoizedState;
  12466. }
  12467. var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
  12468. if (typeof getDerivedStateFromProps === 'function') {
  12469. applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
  12470. instance.state = workInProgress.memoizedState;
  12471. }
  12472. // In order to support react-lifecycles-compat polyfilled components,
  12473. // Unsafe lifecycles should not be invoked for components using the new APIs.
  12474. if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
  12475. callComponentWillMount(workInProgress, instance);
  12476. // If we had additional state updates during this life-cycle, let's
  12477. // process them now.
  12478. updateQueue = workInProgress.updateQueue;
  12479. if (updateQueue !== null) {
  12480. processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
  12481. instance.state = workInProgress.memoizedState;
  12482. }
  12483. }
  12484. if (typeof instance.componentDidMount === 'function') {
  12485. workInProgress.effectTag |= Update;
  12486. }
  12487. }
  12488. function resumeMountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) {
  12489. var instance = workInProgress.stateNode;
  12490. var oldProps = workInProgress.memoizedProps;
  12491. instance.props = oldProps;
  12492. var oldContext = instance.context;
  12493. var contextType = ctor.contextType;
  12494. var nextContext = emptyContextObject;
  12495. if (typeof contextType === 'object' && contextType !== null) {
  12496. nextContext = readContext(contextType);
  12497. } else if (!disableLegacyContext) {
  12498. var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  12499. nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext);
  12500. }
  12501. var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
  12502. var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
  12503. // Note: During these life-cycles, instance.props/instance.state are what
  12504. // ever the previously attempted to render - not the "current". However,
  12505. // during componentDidUpdate we pass the "current" props.
  12506. // In order to support react-lifecycles-compat polyfilled components,
  12507. // Unsafe lifecycles should not be invoked for components using the new APIs.
  12508. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
  12509. if (oldProps !== newProps || oldContext !== nextContext) {
  12510. callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
  12511. }
  12512. }
  12513. resetHasForceUpdateBeforeProcessing();
  12514. var oldState = workInProgress.memoizedState;
  12515. var newState = instance.state = oldState;
  12516. var updateQueue = workInProgress.updateQueue;
  12517. if (updateQueue !== null) {
  12518. processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
  12519. newState = workInProgress.memoizedState;
  12520. }
  12521. if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
  12522. // If an update was already in progress, we should schedule an Update
  12523. // effect even though we're bailing out, so that cWU/cDU are called.
  12524. if (typeof instance.componentDidMount === 'function') {
  12525. workInProgress.effectTag |= Update;
  12526. }
  12527. return false;
  12528. }
  12529. if (typeof getDerivedStateFromProps === 'function') {
  12530. applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
  12531. newState = workInProgress.memoizedState;
  12532. }
  12533. var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
  12534. if (shouldUpdate) {
  12535. // In order to support react-lifecycles-compat polyfilled components,
  12536. // Unsafe lifecycles should not be invoked for components using the new APIs.
  12537. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
  12538. startPhaseTimer(workInProgress, 'componentWillMount');
  12539. if (typeof instance.componentWillMount === 'function') {
  12540. instance.componentWillMount();
  12541. }
  12542. if (typeof instance.UNSAFE_componentWillMount === 'function') {
  12543. instance.UNSAFE_componentWillMount();
  12544. }
  12545. stopPhaseTimer();
  12546. }
  12547. if (typeof instance.componentDidMount === 'function') {
  12548. workInProgress.effectTag |= Update;
  12549. }
  12550. } else {
  12551. // If an update was already in progress, we should schedule an Update
  12552. // effect even though we're bailing out, so that cWU/cDU are called.
  12553. if (typeof instance.componentDidMount === 'function') {
  12554. workInProgress.effectTag |= Update;
  12555. }
  12556. // If shouldComponentUpdate returned false, we should still update the
  12557. // memoized state to indicate that this work can be reused.
  12558. workInProgress.memoizedProps = newProps;
  12559. workInProgress.memoizedState = newState;
  12560. }
  12561. // Update the existing instance's state, props, and context pointers even
  12562. // if shouldComponentUpdate returns false.
  12563. instance.props = newProps;
  12564. instance.state = newState;
  12565. instance.context = nextContext;
  12566. return shouldUpdate;
  12567. }
  12568. // Invokes the update life-cycles and returns false if it shouldn't rerender.
  12569. function updateClassInstance(current, workInProgress, ctor, newProps, renderExpirationTime) {
  12570. var instance = workInProgress.stateNode;
  12571. var oldProps = workInProgress.memoizedProps;
  12572. instance.props = workInProgress.type === workInProgress.elementType ? oldProps : resolveDefaultProps(workInProgress.type, oldProps);
  12573. var oldContext = instance.context;
  12574. var contextType = ctor.contextType;
  12575. var nextContext = emptyContextObject;
  12576. if (typeof contextType === 'object' && contextType !== null) {
  12577. nextContext = readContext(contextType);
  12578. } else if (!disableLegacyContext) {
  12579. var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  12580. nextContext = getMaskedContext(workInProgress, nextUnmaskedContext);
  12581. }
  12582. var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
  12583. var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
  12584. // Note: During these life-cycles, instance.props/instance.state are what
  12585. // ever the previously attempted to render - not the "current". However,
  12586. // during componentDidUpdate we pass the "current" props.
  12587. // In order to support react-lifecycles-compat polyfilled components,
  12588. // Unsafe lifecycles should not be invoked for components using the new APIs.
  12589. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
  12590. if (oldProps !== newProps || oldContext !== nextContext) {
  12591. callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
  12592. }
  12593. }
  12594. resetHasForceUpdateBeforeProcessing();
  12595. var oldState = workInProgress.memoizedState;
  12596. var newState = instance.state = oldState;
  12597. var updateQueue = workInProgress.updateQueue;
  12598. if (updateQueue !== null) {
  12599. processUpdateQueue(workInProgress, updateQueue, newProps, instance, renderExpirationTime);
  12600. newState = workInProgress.memoizedState;
  12601. }
  12602. if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
  12603. // If an update was already in progress, we should schedule an Update
  12604. // effect even though we're bailing out, so that cWU/cDU are called.
  12605. if (typeof instance.componentDidUpdate === 'function') {
  12606. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  12607. workInProgress.effectTag |= Update;
  12608. }
  12609. }
  12610. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  12611. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  12612. workInProgress.effectTag |= Snapshot;
  12613. }
  12614. }
  12615. return false;
  12616. }
  12617. if (typeof getDerivedStateFromProps === 'function') {
  12618. applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
  12619. newState = workInProgress.memoizedState;
  12620. }
  12621. var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
  12622. if (shouldUpdate) {
  12623. // In order to support react-lifecycles-compat polyfilled components,
  12624. // Unsafe lifecycles should not be invoked for components using the new APIs.
  12625. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) {
  12626. startPhaseTimer(workInProgress, 'componentWillUpdate');
  12627. if (typeof instance.componentWillUpdate === 'function') {
  12628. instance.componentWillUpdate(newProps, newState, nextContext);
  12629. }
  12630. if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
  12631. instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext);
  12632. }
  12633. stopPhaseTimer();
  12634. }
  12635. if (typeof instance.componentDidUpdate === 'function') {
  12636. workInProgress.effectTag |= Update;
  12637. }
  12638. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  12639. workInProgress.effectTag |= Snapshot;
  12640. }
  12641. } else {
  12642. // If an update was already in progress, we should schedule an Update
  12643. // effect even though we're bailing out, so that cWU/cDU are called.
  12644. if (typeof instance.componentDidUpdate === 'function') {
  12645. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  12646. workInProgress.effectTag |= Update;
  12647. }
  12648. }
  12649. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  12650. if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  12651. workInProgress.effectTag |= Snapshot;
  12652. }
  12653. }
  12654. // If shouldComponentUpdate returned false, we should still update the
  12655. // memoized props/state to indicate that this work can be reused.
  12656. workInProgress.memoizedProps = newProps;
  12657. workInProgress.memoizedState = newState;
  12658. }
  12659. // Update the existing instance's state, props, and context pointers even
  12660. // if shouldComponentUpdate returns false.
  12661. instance.props = newProps;
  12662. instance.state = newState;
  12663. instance.context = nextContext;
  12664. return shouldUpdate;
  12665. }
  12666. var didWarnAboutMaps = void 0;
  12667. var didWarnAboutGenerators = void 0;
  12668. var didWarnAboutStringRefInStrictMode = void 0;
  12669. var ownerHasKeyUseWarning = void 0;
  12670. var ownerHasFunctionTypeWarning = void 0;
  12671. var warnForMissingKey = function (child) {};
  12672. {
  12673. didWarnAboutMaps = false;
  12674. didWarnAboutGenerators = false;
  12675. didWarnAboutStringRefInStrictMode = {};
  12676. /**
  12677. * Warn if there's no key explicitly set on dynamic arrays of children or
  12678. * object keys are not valid. This allows us to keep track of children between
  12679. * updates.
  12680. */
  12681. ownerHasKeyUseWarning = {};
  12682. ownerHasFunctionTypeWarning = {};
  12683. warnForMissingKey = function (child) {
  12684. if (child === null || typeof child !== 'object') {
  12685. return;
  12686. }
  12687. if (!child._store || child._store.validated || child.key != null) {
  12688. return;
  12689. }
  12690. (function () {
  12691. if (!(typeof child._store === 'object')) {
  12692. {
  12693. throw ReactError(Error('React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue.'));
  12694. }
  12695. }
  12696. })();
  12697. child._store.validated = true;
  12698. var currentComponentErrorInfo = 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.' + getCurrentFiberStackInDev();
  12699. if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
  12700. return;
  12701. }
  12702. ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
  12703. warning$1(false, 'Each child in a list should have a unique ' + '"key" prop. See https://fb.me/react-warning-keys for ' + 'more information.');
  12704. };
  12705. }
  12706. var isArray = Array.isArray;
  12707. function coerceRef(returnFiber, current$$1, element) {
  12708. var mixedRef = element.ref;
  12709. if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') {
  12710. {
  12711. if (returnFiber.mode & StrictMode) {
  12712. var componentName = getComponentName(returnFiber.type) || 'Component';
  12713. if (!didWarnAboutStringRefInStrictMode[componentName]) {
  12714. 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));
  12715. didWarnAboutStringRefInStrictMode[componentName] = true;
  12716. }
  12717. }
  12718. }
  12719. if (element._owner) {
  12720. var owner = element._owner;
  12721. var inst = void 0;
  12722. if (owner) {
  12723. var ownerFiber = owner;
  12724. (function () {
  12725. if (!(ownerFiber.tag === ClassComponent)) {
  12726. {
  12727. throw ReactError(Error('Function components cannot have refs. Did you mean to use React.forwardRef()?'));
  12728. }
  12729. }
  12730. })();
  12731. inst = ownerFiber.stateNode;
  12732. }
  12733. (function () {
  12734. if (!inst) {
  12735. {
  12736. throw ReactError(Error('Missing owner for string ref ' + mixedRef + '. This error is likely caused by a bug in React. Please file an issue.'));
  12737. }
  12738. }
  12739. })();
  12740. var stringRef = '' + mixedRef;
  12741. // Check if previous string ref matches new string ref
  12742. if (current$$1 !== null && current$$1.ref !== null && typeof current$$1.ref === 'function' && current$$1.ref._stringRef === stringRef) {
  12743. return current$$1.ref;
  12744. }
  12745. var ref = function (value) {
  12746. var refs = inst.refs;
  12747. if (refs === emptyRefsObject) {
  12748. // This is a lazy pooled frozen object, so we need to initialize.
  12749. refs = inst.refs = {};
  12750. }
  12751. if (value === null) {
  12752. delete refs[stringRef];
  12753. } else {
  12754. refs[stringRef] = value;
  12755. }
  12756. };
  12757. ref._stringRef = stringRef;
  12758. return ref;
  12759. } else {
  12760. (function () {
  12761. if (!(typeof mixedRef === 'string')) {
  12762. {
  12763. throw ReactError(Error('Expected ref to be a function, a string, an object returned by React.createRef(), or null.'));
  12764. }
  12765. }
  12766. })();
  12767. (function () {
  12768. if (!element._owner) {
  12769. {
  12770. throw ReactError(Error('Element ref was specified as a string (' + mixedRef + ') but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component\'s render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information.'));
  12771. }
  12772. }
  12773. })();
  12774. }
  12775. }
  12776. return mixedRef;
  12777. }
  12778. function throwOnInvalidObjectType(returnFiber, newChild) {
  12779. if (returnFiber.type !== 'textarea') {
  12780. var addendum = '';
  12781. {
  12782. addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + getCurrentFiberStackInDev();
  12783. }
  12784. (function () {
  12785. {
  12786. {
  12787. throw ReactError(Error('Objects are not valid as a React child (found: ' + (Object.prototype.toString.call(newChild) === '[object Object]' ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' : newChild) + ').' + addendum));
  12788. }
  12789. }
  12790. })();
  12791. }
  12792. }
  12793. function warnOnFunctionType() {
  12794. 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();
  12795. if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) {
  12796. return;
  12797. }
  12798. ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true;
  12799. 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.');
  12800. }
  12801. // This wrapper function exists because I expect to clone the code in each path
  12802. // to be able to optimize each path individually by branching early. This needs
  12803. // a compiler or we can do it manually. Helpers that don't need this branching
  12804. // live outside of this function.
  12805. function ChildReconciler(shouldTrackSideEffects) {
  12806. function deleteChild(returnFiber, childToDelete) {
  12807. if (!shouldTrackSideEffects) {
  12808. // Noop.
  12809. return;
  12810. }
  12811. // Deletions are added in reversed order so we add it to the front.
  12812. // At this point, the return fiber's effect list is empty except for
  12813. // deletions, so we can just append the deletion to the list. The remaining
  12814. // effects aren't added until the complete phase. Once we implement
  12815. // resuming, this may not be true.
  12816. var last = returnFiber.lastEffect;
  12817. if (last !== null) {
  12818. last.nextEffect = childToDelete;
  12819. returnFiber.lastEffect = childToDelete;
  12820. } else {
  12821. returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
  12822. }
  12823. childToDelete.nextEffect = null;
  12824. childToDelete.effectTag = Deletion;
  12825. }
  12826. function deleteRemainingChildren(returnFiber, currentFirstChild) {
  12827. if (!shouldTrackSideEffects) {
  12828. // Noop.
  12829. return null;
  12830. }
  12831. // TODO: For the shouldClone case, this could be micro-optimized a bit by
  12832. // assuming that after the first child we've already added everything.
  12833. var childToDelete = currentFirstChild;
  12834. while (childToDelete !== null) {
  12835. deleteChild(returnFiber, childToDelete);
  12836. childToDelete = childToDelete.sibling;
  12837. }
  12838. return null;
  12839. }
  12840. function mapRemainingChildren(returnFiber, currentFirstChild) {
  12841. // Add the remaining children to a temporary map so that we can find them by
  12842. // keys quickly. Implicit (null) keys get added to this set with their index
  12843. var existingChildren = new Map();
  12844. var existingChild = currentFirstChild;
  12845. while (existingChild !== null) {
  12846. if (existingChild.key !== null) {
  12847. existingChildren.set(existingChild.key, existingChild);
  12848. } else {
  12849. existingChildren.set(existingChild.index, existingChild);
  12850. }
  12851. existingChild = existingChild.sibling;
  12852. }
  12853. return existingChildren;
  12854. }
  12855. function useFiber(fiber, pendingProps, expirationTime) {
  12856. // We currently set sibling to null and index to 0 here because it is easy
  12857. // to forget to do before returning it. E.g. for the single child case.
  12858. var clone = createWorkInProgress(fiber, pendingProps, expirationTime);
  12859. clone.index = 0;
  12860. clone.sibling = null;
  12861. return clone;
  12862. }
  12863. function placeChild(newFiber, lastPlacedIndex, newIndex) {
  12864. newFiber.index = newIndex;
  12865. if (!shouldTrackSideEffects) {
  12866. // Noop.
  12867. return lastPlacedIndex;
  12868. }
  12869. var current$$1 = newFiber.alternate;
  12870. if (current$$1 !== null) {
  12871. var oldIndex = current$$1.index;
  12872. if (oldIndex < lastPlacedIndex) {
  12873. // This is a move.
  12874. newFiber.effectTag = Placement;
  12875. return lastPlacedIndex;
  12876. } else {
  12877. // This item can stay in place.
  12878. return oldIndex;
  12879. }
  12880. } else {
  12881. // This is an insertion.
  12882. newFiber.effectTag = Placement;
  12883. return lastPlacedIndex;
  12884. }
  12885. }
  12886. function placeSingleChild(newFiber) {
  12887. // This is simpler for the single child case. We only need to do a
  12888. // placement for inserting new children.
  12889. if (shouldTrackSideEffects && newFiber.alternate === null) {
  12890. newFiber.effectTag = Placement;
  12891. }
  12892. return newFiber;
  12893. }
  12894. function updateTextNode(returnFiber, current$$1, textContent, expirationTime) {
  12895. if (current$$1 === null || current$$1.tag !== HostText) {
  12896. // Insert
  12897. var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
  12898. created.return = returnFiber;
  12899. return created;
  12900. } else {
  12901. // Update
  12902. var existing = useFiber(current$$1, textContent, expirationTime);
  12903. existing.return = returnFiber;
  12904. return existing;
  12905. }
  12906. }
  12907. function updateElement(returnFiber, current$$1, element, expirationTime) {
  12908. if (current$$1 !== null && (current$$1.elementType === element.type || (
  12909. // Keep this check inline so it only runs on the false path:
  12910. isCompatibleFamilyForHotReloading(current$$1, element)))) {
  12911. // Move based on index
  12912. var existing = useFiber(current$$1, element.props, expirationTime);
  12913. existing.ref = coerceRef(returnFiber, current$$1, element);
  12914. existing.return = returnFiber;
  12915. {
  12916. existing._debugSource = element._source;
  12917. existing._debugOwner = element._owner;
  12918. }
  12919. return existing;
  12920. } else {
  12921. // Insert
  12922. var created = createFiberFromElement(element, returnFiber.mode, expirationTime);
  12923. created.ref = coerceRef(returnFiber, current$$1, element);
  12924. created.return = returnFiber;
  12925. return created;
  12926. }
  12927. }
  12928. function updatePortal(returnFiber, current$$1, portal, expirationTime) {
  12929. if (current$$1 === null || current$$1.tag !== HostPortal || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation) {
  12930. // Insert
  12931. var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
  12932. created.return = returnFiber;
  12933. return created;
  12934. } else {
  12935. // Update
  12936. var existing = useFiber(current$$1, portal.children || [], expirationTime);
  12937. existing.return = returnFiber;
  12938. return existing;
  12939. }
  12940. }
  12941. function updateFragment(returnFiber, current$$1, fragment, expirationTime, key) {
  12942. if (current$$1 === null || current$$1.tag !== Fragment) {
  12943. // Insert
  12944. var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key);
  12945. created.return = returnFiber;
  12946. return created;
  12947. } else {
  12948. // Update
  12949. var existing = useFiber(current$$1, fragment, expirationTime);
  12950. existing.return = returnFiber;
  12951. return existing;
  12952. }
  12953. }
  12954. function createChild(returnFiber, newChild, expirationTime) {
  12955. if (typeof newChild === 'string' || typeof newChild === 'number') {
  12956. // Text nodes don't have keys. If the previous node is implicitly keyed
  12957. // we can continue to replace it without aborting even if it is not a text
  12958. // node.
  12959. var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime);
  12960. created.return = returnFiber;
  12961. return created;
  12962. }
  12963. if (typeof newChild === 'object' && newChild !== null) {
  12964. switch (newChild.$$typeof) {
  12965. case REACT_ELEMENT_TYPE:
  12966. {
  12967. var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime);
  12968. _created.ref = coerceRef(returnFiber, null, newChild);
  12969. _created.return = returnFiber;
  12970. return _created;
  12971. }
  12972. case REACT_PORTAL_TYPE:
  12973. {
  12974. var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime);
  12975. _created2.return = returnFiber;
  12976. return _created2;
  12977. }
  12978. }
  12979. if (isArray(newChild) || getIteratorFn(newChild)) {
  12980. var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null);
  12981. _created3.return = returnFiber;
  12982. return _created3;
  12983. }
  12984. throwOnInvalidObjectType(returnFiber, newChild);
  12985. }
  12986. {
  12987. if (typeof newChild === 'function') {
  12988. warnOnFunctionType();
  12989. }
  12990. }
  12991. return null;
  12992. }
  12993. function updateSlot(returnFiber, oldFiber, newChild, expirationTime) {
  12994. // Update the fiber if the keys match, otherwise return null.
  12995. var key = oldFiber !== null ? oldFiber.key : null;
  12996. if (typeof newChild === 'string' || typeof newChild === 'number') {
  12997. // Text nodes don't have keys. If the previous node is implicitly keyed
  12998. // we can continue to replace it without aborting even if it is not a text
  12999. // node.
  13000. if (key !== null) {
  13001. return null;
  13002. }
  13003. return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime);
  13004. }
  13005. if (typeof newChild === 'object' && newChild !== null) {
  13006. switch (newChild.$$typeof) {
  13007. case REACT_ELEMENT_TYPE:
  13008. {
  13009. if (newChild.key === key) {
  13010. if (newChild.type === REACT_FRAGMENT_TYPE) {
  13011. return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key);
  13012. }
  13013. return updateElement(returnFiber, oldFiber, newChild, expirationTime);
  13014. } else {
  13015. return null;
  13016. }
  13017. }
  13018. case REACT_PORTAL_TYPE:
  13019. {
  13020. if (newChild.key === key) {
  13021. return updatePortal(returnFiber, oldFiber, newChild, expirationTime);
  13022. } else {
  13023. return null;
  13024. }
  13025. }
  13026. }
  13027. if (isArray(newChild) || getIteratorFn(newChild)) {
  13028. if (key !== null) {
  13029. return null;
  13030. }
  13031. return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null);
  13032. }
  13033. throwOnInvalidObjectType(returnFiber, newChild);
  13034. }
  13035. {
  13036. if (typeof newChild === 'function') {
  13037. warnOnFunctionType();
  13038. }
  13039. }
  13040. return null;
  13041. }
  13042. function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) {
  13043. if (typeof newChild === 'string' || typeof newChild === 'number') {
  13044. // Text nodes don't have keys, so we neither have to check the old nor
  13045. // new node for the key. If both are text nodes, they match.
  13046. var matchedFiber = existingChildren.get(newIdx) || null;
  13047. return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime);
  13048. }
  13049. if (typeof newChild === 'object' && newChild !== null) {
  13050. switch (newChild.$$typeof) {
  13051. case REACT_ELEMENT_TYPE:
  13052. {
  13053. var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
  13054. if (newChild.type === REACT_FRAGMENT_TYPE) {
  13055. return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key);
  13056. }
  13057. return updateElement(returnFiber, _matchedFiber, newChild, expirationTime);
  13058. }
  13059. case REACT_PORTAL_TYPE:
  13060. {
  13061. var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
  13062. return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime);
  13063. }
  13064. }
  13065. if (isArray(newChild) || getIteratorFn(newChild)) {
  13066. var _matchedFiber3 = existingChildren.get(newIdx) || null;
  13067. return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null);
  13068. }
  13069. throwOnInvalidObjectType(returnFiber, newChild);
  13070. }
  13071. {
  13072. if (typeof newChild === 'function') {
  13073. warnOnFunctionType();
  13074. }
  13075. }
  13076. return null;
  13077. }
  13078. /**
  13079. * Warns if there is a duplicate or missing key
  13080. */
  13081. function warnOnInvalidKey(child, knownKeys) {
  13082. {
  13083. if (typeof child !== 'object' || child === null) {
  13084. return knownKeys;
  13085. }
  13086. switch (child.$$typeof) {
  13087. case REACT_ELEMENT_TYPE:
  13088. case REACT_PORTAL_TYPE:
  13089. warnForMissingKey(child);
  13090. var key = child.key;
  13091. if (typeof key !== 'string') {
  13092. break;
  13093. }
  13094. if (knownKeys === null) {
  13095. knownKeys = new Set();
  13096. knownKeys.add(key);
  13097. break;
  13098. }
  13099. if (!knownKeys.has(key)) {
  13100. knownKeys.add(key);
  13101. break;
  13102. }
  13103. 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);
  13104. break;
  13105. default:
  13106. break;
  13107. }
  13108. }
  13109. return knownKeys;
  13110. }
  13111. function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) {
  13112. // This algorithm can't optimize by searching from both ends since we
  13113. // don't have backpointers on fibers. I'm trying to see how far we can get
  13114. // with that model. If it ends up not being worth the tradeoffs, we can
  13115. // add it later.
  13116. // Even with a two ended optimization, we'd want to optimize for the case
  13117. // where there are few changes and brute force the comparison instead of
  13118. // going for the Map. It'd like to explore hitting that path first in
  13119. // forward-only mode and only go for the Map once we notice that we need
  13120. // lots of look ahead. This doesn't handle reversal as well as two ended
  13121. // search but that's unusual. Besides, for the two ended optimization to
  13122. // work on Iterables, we'd need to copy the whole set.
  13123. // In this first iteration, we'll just live with hitting the bad case
  13124. // (adding everything to a Map) in for every insert/move.
  13125. // If you change this code, also update reconcileChildrenIterator() which
  13126. // uses the same algorithm.
  13127. {
  13128. // First, validate keys.
  13129. var knownKeys = null;
  13130. for (var i = 0; i < newChildren.length; i++) {
  13131. var child = newChildren[i];
  13132. knownKeys = warnOnInvalidKey(child, knownKeys);
  13133. }
  13134. }
  13135. var resultingFirstChild = null;
  13136. var previousNewFiber = null;
  13137. var oldFiber = currentFirstChild;
  13138. var lastPlacedIndex = 0;
  13139. var newIdx = 0;
  13140. var nextOldFiber = null;
  13141. for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {
  13142. if (oldFiber.index > newIdx) {
  13143. nextOldFiber = oldFiber;
  13144. oldFiber = null;
  13145. } else {
  13146. nextOldFiber = oldFiber.sibling;
  13147. }
  13148. var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime);
  13149. if (newFiber === null) {
  13150. // TODO: This breaks on empty slots like null children. That's
  13151. // unfortunate because it triggers the slow path all the time. We need
  13152. // a better way to communicate whether this was a miss or null,
  13153. // boolean, undefined, etc.
  13154. if (oldFiber === null) {
  13155. oldFiber = nextOldFiber;
  13156. }
  13157. break;
  13158. }
  13159. if (shouldTrackSideEffects) {
  13160. if (oldFiber && newFiber.alternate === null) {
  13161. // We matched the slot, but we didn't reuse the existing fiber, so we
  13162. // need to delete the existing child.
  13163. deleteChild(returnFiber, oldFiber);
  13164. }
  13165. }
  13166. lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
  13167. if (previousNewFiber === null) {
  13168. // TODO: Move out of the loop. This only happens for the first run.
  13169. resultingFirstChild = newFiber;
  13170. } else {
  13171. // TODO: Defer siblings if we're not at the right index for this slot.
  13172. // I.e. if we had null values before, then we want to defer this
  13173. // for each null value. However, we also don't want to call updateSlot
  13174. // with the previous one.
  13175. previousNewFiber.sibling = newFiber;
  13176. }
  13177. previousNewFiber = newFiber;
  13178. oldFiber = nextOldFiber;
  13179. }
  13180. if (newIdx === newChildren.length) {
  13181. // We've reached the end of the new children. We can delete the rest.
  13182. deleteRemainingChildren(returnFiber, oldFiber);
  13183. return resultingFirstChild;
  13184. }
  13185. if (oldFiber === null) {
  13186. // If we don't have any more existing children we can choose a fast path
  13187. // since the rest will all be insertions.
  13188. for (; newIdx < newChildren.length; newIdx++) {
  13189. var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime);
  13190. if (_newFiber === null) {
  13191. continue;
  13192. }
  13193. lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);
  13194. if (previousNewFiber === null) {
  13195. // TODO: Move out of the loop. This only happens for the first run.
  13196. resultingFirstChild = _newFiber;
  13197. } else {
  13198. previousNewFiber.sibling = _newFiber;
  13199. }
  13200. previousNewFiber = _newFiber;
  13201. }
  13202. return resultingFirstChild;
  13203. }
  13204. // Add all children to a key map for quick lookups.
  13205. var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
  13206. // Keep scanning and use the map to restore deleted items as moves.
  13207. for (; newIdx < newChildren.length; newIdx++) {
  13208. var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime);
  13209. if (_newFiber2 !== null) {
  13210. if (shouldTrackSideEffects) {
  13211. if (_newFiber2.alternate !== null) {
  13212. // The new fiber is a work in progress, but if there exists a
  13213. // current, that means that we reused the fiber. We need to delete
  13214. // it from the child list so that we don't add it to the deletion
  13215. // list.
  13216. existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);
  13217. }
  13218. }
  13219. lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);
  13220. if (previousNewFiber === null) {
  13221. resultingFirstChild = _newFiber2;
  13222. } else {
  13223. previousNewFiber.sibling = _newFiber2;
  13224. }
  13225. previousNewFiber = _newFiber2;
  13226. }
  13227. }
  13228. if (shouldTrackSideEffects) {
  13229. // Any existing children that weren't consumed above were deleted. We need
  13230. // to add them to the deletion list.
  13231. existingChildren.forEach(function (child) {
  13232. return deleteChild(returnFiber, child);
  13233. });
  13234. }
  13235. return resultingFirstChild;
  13236. }
  13237. function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) {
  13238. // This is the same implementation as reconcileChildrenArray(),
  13239. // but using the iterator instead.
  13240. var iteratorFn = getIteratorFn(newChildrenIterable);
  13241. (function () {
  13242. if (!(typeof iteratorFn === 'function')) {
  13243. {
  13244. throw ReactError(Error('An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.'));
  13245. }
  13246. }
  13247. })();
  13248. {
  13249. // We don't support rendering Generators because it's a mutation.
  13250. // See https://github.com/facebook/react/issues/12995
  13251. if (typeof Symbol === 'function' &&
  13252. // $FlowFixMe Flow doesn't know about toStringTag
  13253. newChildrenIterable[Symbol.toStringTag] === 'Generator') {
  13254. !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;
  13255. didWarnAboutGenerators = true;
  13256. }
  13257. // Warn about using Maps as children
  13258. if (newChildrenIterable.entries === iteratorFn) {
  13259. !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;
  13260. didWarnAboutMaps = true;
  13261. }
  13262. // First, validate keys.
  13263. // We'll get a different iterator later for the main pass.
  13264. var _newChildren = iteratorFn.call(newChildrenIterable);
  13265. if (_newChildren) {
  13266. var knownKeys = null;
  13267. var _step = _newChildren.next();
  13268. for (; !_step.done; _step = _newChildren.next()) {
  13269. var child = _step.value;
  13270. knownKeys = warnOnInvalidKey(child, knownKeys);
  13271. }
  13272. }
  13273. }
  13274. var newChildren = iteratorFn.call(newChildrenIterable);
  13275. (function () {
  13276. if (!(newChildren != null)) {
  13277. {
  13278. throw ReactError(Error('An iterable object provided no iterator.'));
  13279. }
  13280. }
  13281. })();
  13282. var resultingFirstChild = null;
  13283. var previousNewFiber = null;
  13284. var oldFiber = currentFirstChild;
  13285. var lastPlacedIndex = 0;
  13286. var newIdx = 0;
  13287. var nextOldFiber = null;
  13288. var step = newChildren.next();
  13289. for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {
  13290. if (oldFiber.index > newIdx) {
  13291. nextOldFiber = oldFiber;
  13292. oldFiber = null;
  13293. } else {
  13294. nextOldFiber = oldFiber.sibling;
  13295. }
  13296. var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime);
  13297. if (newFiber === null) {
  13298. // TODO: This breaks on empty slots like null children. That's
  13299. // unfortunate because it triggers the slow path all the time. We need
  13300. // a better way to communicate whether this was a miss or null,
  13301. // boolean, undefined, etc.
  13302. if (oldFiber === null) {
  13303. oldFiber = nextOldFiber;
  13304. }
  13305. break;
  13306. }
  13307. if (shouldTrackSideEffects) {
  13308. if (oldFiber && newFiber.alternate === null) {
  13309. // We matched the slot, but we didn't reuse the existing fiber, so we
  13310. // need to delete the existing child.
  13311. deleteChild(returnFiber, oldFiber);
  13312. }
  13313. }
  13314. lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
  13315. if (previousNewFiber === null) {
  13316. // TODO: Move out of the loop. This only happens for the first run.
  13317. resultingFirstChild = newFiber;
  13318. } else {
  13319. // TODO: Defer siblings if we're not at the right index for this slot.
  13320. // I.e. if we had null values before, then we want to defer this
  13321. // for each null value. However, we also don't want to call updateSlot
  13322. // with the previous one.
  13323. previousNewFiber.sibling = newFiber;
  13324. }
  13325. previousNewFiber = newFiber;
  13326. oldFiber = nextOldFiber;
  13327. }
  13328. if (step.done) {
  13329. // We've reached the end of the new children. We can delete the rest.
  13330. deleteRemainingChildren(returnFiber, oldFiber);
  13331. return resultingFirstChild;
  13332. }
  13333. if (oldFiber === null) {
  13334. // If we don't have any more existing children we can choose a fast path
  13335. // since the rest will all be insertions.
  13336. for (; !step.done; newIdx++, step = newChildren.next()) {
  13337. var _newFiber3 = createChild(returnFiber, step.value, expirationTime);
  13338. if (_newFiber3 === null) {
  13339. continue;
  13340. }
  13341. lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);
  13342. if (previousNewFiber === null) {
  13343. // TODO: Move out of the loop. This only happens for the first run.
  13344. resultingFirstChild = _newFiber3;
  13345. } else {
  13346. previousNewFiber.sibling = _newFiber3;
  13347. }
  13348. previousNewFiber = _newFiber3;
  13349. }
  13350. return resultingFirstChild;
  13351. }
  13352. // Add all children to a key map for quick lookups.
  13353. var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
  13354. // Keep scanning and use the map to restore deleted items as moves.
  13355. for (; !step.done; newIdx++, step = newChildren.next()) {
  13356. var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime);
  13357. if (_newFiber4 !== null) {
  13358. if (shouldTrackSideEffects) {
  13359. if (_newFiber4.alternate !== null) {
  13360. // The new fiber is a work in progress, but if there exists a
  13361. // current, that means that we reused the fiber. We need to delete
  13362. // it from the child list so that we don't add it to the deletion
  13363. // list.
  13364. existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);
  13365. }
  13366. }
  13367. lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);
  13368. if (previousNewFiber === null) {
  13369. resultingFirstChild = _newFiber4;
  13370. } else {
  13371. previousNewFiber.sibling = _newFiber4;
  13372. }
  13373. previousNewFiber = _newFiber4;
  13374. }
  13375. }
  13376. if (shouldTrackSideEffects) {
  13377. // Any existing children that weren't consumed above were deleted. We need
  13378. // to add them to the deletion list.
  13379. existingChildren.forEach(function (child) {
  13380. return deleteChild(returnFiber, child);
  13381. });
  13382. }
  13383. return resultingFirstChild;
  13384. }
  13385. function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) {
  13386. // There's no need to check for keys on text nodes since we don't have a
  13387. // way to define them.
  13388. if (currentFirstChild !== null && currentFirstChild.tag === HostText) {
  13389. // We already have an existing node so let's just update it and delete
  13390. // the rest.
  13391. deleteRemainingChildren(returnFiber, currentFirstChild.sibling);
  13392. var existing = useFiber(currentFirstChild, textContent, expirationTime);
  13393. existing.return = returnFiber;
  13394. return existing;
  13395. }
  13396. // The existing first child is not a text node so we need to create one
  13397. // and delete the existing ones.
  13398. deleteRemainingChildren(returnFiber, currentFirstChild);
  13399. var created = createFiberFromText(textContent, returnFiber.mode, expirationTime);
  13400. created.return = returnFiber;
  13401. return created;
  13402. }
  13403. function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) {
  13404. var key = element.key;
  13405. var child = currentFirstChild;
  13406. while (child !== null) {
  13407. // TODO: If key === null and child.key === null, then this only applies to
  13408. // the first item in the list.
  13409. if (child.key === key) {
  13410. if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type || (
  13411. // Keep this check inline so it only runs on the false path:
  13412. isCompatibleFamilyForHotReloading(child, element))) {
  13413. deleteRemainingChildren(returnFiber, child.sibling);
  13414. var existing = useFiber(child, element.type === REACT_FRAGMENT_TYPE ? element.props.children : element.props, expirationTime);
  13415. existing.ref = coerceRef(returnFiber, child, element);
  13416. existing.return = returnFiber;
  13417. {
  13418. existing._debugSource = element._source;
  13419. existing._debugOwner = element._owner;
  13420. }
  13421. return existing;
  13422. } else {
  13423. deleteRemainingChildren(returnFiber, child);
  13424. break;
  13425. }
  13426. } else {
  13427. deleteChild(returnFiber, child);
  13428. }
  13429. child = child.sibling;
  13430. }
  13431. if (element.type === REACT_FRAGMENT_TYPE) {
  13432. var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key);
  13433. created.return = returnFiber;
  13434. return created;
  13435. } else {
  13436. var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime);
  13437. _created4.ref = coerceRef(returnFiber, currentFirstChild, element);
  13438. _created4.return = returnFiber;
  13439. return _created4;
  13440. }
  13441. }
  13442. function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) {
  13443. var key = portal.key;
  13444. var child = currentFirstChild;
  13445. while (child !== null) {
  13446. // TODO: If key === null and child.key === null, then this only applies to
  13447. // the first item in the list.
  13448. if (child.key === key) {
  13449. if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {
  13450. deleteRemainingChildren(returnFiber, child.sibling);
  13451. var existing = useFiber(child, portal.children || [], expirationTime);
  13452. existing.return = returnFiber;
  13453. return existing;
  13454. } else {
  13455. deleteRemainingChildren(returnFiber, child);
  13456. break;
  13457. }
  13458. } else {
  13459. deleteChild(returnFiber, child);
  13460. }
  13461. child = child.sibling;
  13462. }
  13463. var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime);
  13464. created.return = returnFiber;
  13465. return created;
  13466. }
  13467. // This API will tag the children with the side-effect of the reconciliation
  13468. // itself. They will be added to the side-effect list as we pass through the
  13469. // children and the parent.
  13470. function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) {
  13471. // This function is not recursive.
  13472. // If the top level item is an array, we treat it as a set of children,
  13473. // not as a fragment. Nested arrays on the other hand will be treated as
  13474. // fragment nodes. Recursion happens at the normal flow.
  13475. // Handle top level unkeyed fragments as if they were arrays.
  13476. // This leads to an ambiguity between <>{[...]}</> and <>...</>.
  13477. // We treat the ambiguous cases above the same.
  13478. var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;
  13479. if (isUnkeyedTopLevelFragment) {
  13480. newChild = newChild.props.children;
  13481. }
  13482. // Handle object types
  13483. var isObject = typeof newChild === 'object' && newChild !== null;
  13484. if (isObject) {
  13485. switch (newChild.$$typeof) {
  13486. case REACT_ELEMENT_TYPE:
  13487. return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime));
  13488. case REACT_PORTAL_TYPE:
  13489. return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime));
  13490. }
  13491. }
  13492. if (typeof newChild === 'string' || typeof newChild === 'number') {
  13493. return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime));
  13494. }
  13495. if (isArray(newChild)) {
  13496. return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime);
  13497. }
  13498. if (getIteratorFn(newChild)) {
  13499. return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime);
  13500. }
  13501. if (isObject) {
  13502. throwOnInvalidObjectType(returnFiber, newChild);
  13503. }
  13504. {
  13505. if (typeof newChild === 'function') {
  13506. warnOnFunctionType();
  13507. }
  13508. }
  13509. if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {
  13510. // If the new child is undefined, and the return fiber is a composite
  13511. // component, throw an error. If Fiber return types are disabled,
  13512. // we already threw above.
  13513. switch (returnFiber.tag) {
  13514. case ClassComponent:
  13515. {
  13516. {
  13517. var instance = returnFiber.stateNode;
  13518. if (instance.render._isMockFunction) {
  13519. // We allow auto-mocks to proceed as if they're returning null.
  13520. break;
  13521. }
  13522. }
  13523. }
  13524. // Intentionally fall through to the next case, which handles both
  13525. // functions and classes
  13526. // eslint-disable-next-lined no-fallthrough
  13527. case FunctionComponent:
  13528. {
  13529. var Component = returnFiber.type;
  13530. (function () {
  13531. {
  13532. {
  13533. throw ReactError(Error((Component.displayName || Component.name || 'Component') + '(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.'));
  13534. }
  13535. }
  13536. })();
  13537. }
  13538. }
  13539. }
  13540. // Remaining cases are all treated as empty.
  13541. return deleteRemainingChildren(returnFiber, currentFirstChild);
  13542. }
  13543. return reconcileChildFibers;
  13544. }
  13545. var reconcileChildFibers = ChildReconciler(true);
  13546. var mountChildFibers = ChildReconciler(false);
  13547. function cloneChildFibers(current$$1, workInProgress) {
  13548. (function () {
  13549. if (!(current$$1 === null || workInProgress.child === current$$1.child)) {
  13550. {
  13551. throw ReactError(Error('Resuming work not yet implemented.'));
  13552. }
  13553. }
  13554. })();
  13555. if (workInProgress.child === null) {
  13556. return;
  13557. }
  13558. var currentChild = workInProgress.child;
  13559. var newChild = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
  13560. workInProgress.child = newChild;
  13561. newChild.return = workInProgress;
  13562. while (currentChild.sibling !== null) {
  13563. currentChild = currentChild.sibling;
  13564. newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps, currentChild.expirationTime);
  13565. newChild.return = workInProgress;
  13566. }
  13567. newChild.sibling = null;
  13568. }
  13569. // Reset a workInProgress child set to prepare it for a second pass.
  13570. function resetChildFibers(workInProgress, renderExpirationTime) {
  13571. var child = workInProgress.child;
  13572. while (child !== null) {
  13573. resetWorkInProgress(child, renderExpirationTime);
  13574. child = child.sibling;
  13575. }
  13576. }
  13577. var NO_CONTEXT = {};
  13578. var contextStackCursor$1 = createCursor(NO_CONTEXT);
  13579. var contextFiberStackCursor = createCursor(NO_CONTEXT);
  13580. var rootInstanceStackCursor = createCursor(NO_CONTEXT);
  13581. function requiredContext(c) {
  13582. (function () {
  13583. if (!(c !== NO_CONTEXT)) {
  13584. {
  13585. throw ReactError(Error('Expected host context to exist. This error is likely caused by a bug in React. Please file an issue.'));
  13586. }
  13587. }
  13588. })();
  13589. return c;
  13590. }
  13591. function getRootHostContainer() {
  13592. var rootInstance = requiredContext(rootInstanceStackCursor.current);
  13593. return rootInstance;
  13594. }
  13595. function pushHostContainer(fiber, nextRootInstance) {
  13596. // Push current root instance onto the stack;
  13597. // This allows us to reset root when portals are popped.
  13598. push(rootInstanceStackCursor, nextRootInstance, fiber);
  13599. // Track the context and the Fiber that provided it.
  13600. // This enables us to pop only Fibers that provide unique contexts.
  13601. push(contextFiberStackCursor, fiber, fiber);
  13602. // Finally, we need to push the host context to the stack.
  13603. // However, we can't just call getRootHostContext() and push it because
  13604. // we'd have a different number of entries on the stack depending on
  13605. // whether getRootHostContext() throws somewhere in renderer code or not.
  13606. // So we push an empty value first. This lets us safely unwind on errors.
  13607. push(contextStackCursor$1, NO_CONTEXT, fiber);
  13608. var nextRootContext = getRootHostContext(nextRootInstance);
  13609. // Now that we know this function doesn't throw, replace it.
  13610. pop(contextStackCursor$1, fiber);
  13611. push(contextStackCursor$1, nextRootContext, fiber);
  13612. }
  13613. function popHostContainer(fiber) {
  13614. pop(contextStackCursor$1, fiber);
  13615. pop(contextFiberStackCursor, fiber);
  13616. pop(rootInstanceStackCursor, fiber);
  13617. }
  13618. function getHostContext() {
  13619. var context = requiredContext(contextStackCursor$1.current);
  13620. return context;
  13621. }
  13622. function pushHostContext(fiber) {
  13623. var rootInstance = requiredContext(rootInstanceStackCursor.current);
  13624. var context = requiredContext(contextStackCursor$1.current);
  13625. var nextContext = getChildHostContext(context, fiber.type, rootInstance);
  13626. // Don't push this Fiber's context unless it's unique.
  13627. if (context === nextContext) {
  13628. return;
  13629. }
  13630. // Track the context and the Fiber that provided it.
  13631. // This enables us to pop only Fibers that provide unique contexts.
  13632. push(contextFiberStackCursor, fiber, fiber);
  13633. push(contextStackCursor$1, nextContext, fiber);
  13634. }
  13635. function popHostContext(fiber) {
  13636. // Do not pop unless this Fiber provided the current context.
  13637. // pushHostContext() only pushes Fibers that provide unique contexts.
  13638. if (contextFiberStackCursor.current !== fiber) {
  13639. return;
  13640. }
  13641. pop(contextStackCursor$1, fiber);
  13642. pop(contextFiberStackCursor, fiber);
  13643. }
  13644. var DefaultSuspenseContext = 0;
  13645. // The Suspense Context is split into two parts. The lower bits is
  13646. // inherited deeply down the subtree. The upper bits only affect
  13647. // this immediate suspense boundary and gets reset each new
  13648. // boundary or suspense list.
  13649. var SubtreeSuspenseContextMask = 1;
  13650. // Subtree Flags:
  13651. // InvisibleParentSuspenseContext indicates that one of our parent Suspense
  13652. // boundaries is not currently showing visible main content.
  13653. // Either because it is already showing a fallback or is not mounted at all.
  13654. // We can use this to determine if it is desirable to trigger a fallback at
  13655. // the parent. If not, then we might need to trigger undesirable boundaries
  13656. // and/or suspend the commit to avoid hiding the parent content.
  13657. var InvisibleParentSuspenseContext = 1;
  13658. // Shallow Flags:
  13659. // ForceSuspenseFallback can be used by SuspenseList to force newly added
  13660. // items into their fallback state during one of the render passes.
  13661. var ForceSuspenseFallback = 2;
  13662. var suspenseStackCursor = createCursor(DefaultSuspenseContext);
  13663. function hasSuspenseContext(parentContext, flag) {
  13664. return (parentContext & flag) !== 0;
  13665. }
  13666. function setDefaultShallowSuspenseContext(parentContext) {
  13667. return parentContext & SubtreeSuspenseContextMask;
  13668. }
  13669. function setShallowSuspenseContext(parentContext, shallowContext) {
  13670. return parentContext & SubtreeSuspenseContextMask | shallowContext;
  13671. }
  13672. function addSubtreeSuspenseContext(parentContext, subtreeContext) {
  13673. return parentContext | subtreeContext;
  13674. }
  13675. function pushSuspenseContext(fiber, newContext) {
  13676. push(suspenseStackCursor, newContext, fiber);
  13677. }
  13678. function popSuspenseContext(fiber) {
  13679. pop(suspenseStackCursor, fiber);
  13680. }
  13681. // TODO: This is now an empty object. Should we switch this to a boolean?
  13682. // Alternatively we can make this use an effect tag similar to SuspenseList.
  13683. function shouldCaptureSuspense(workInProgress, hasInvisibleParent) {
  13684. // If it was the primary children that just suspended, capture and render the
  13685. var nextState = workInProgress.memoizedState;
  13686. if (nextState !== null) {
  13687. return false;
  13688. }
  13689. var props = workInProgress.memoizedProps;
  13690. // In order to capture, the Suspense component must have a fallback prop.
  13691. if (props.fallback === undefined) {
  13692. return false;
  13693. }
  13694. // Regular boundaries always capture.
  13695. if (props.unstable_avoidThisFallback !== true) {
  13696. return true;
  13697. }
  13698. // If it's a boundary we should avoid, then we prefer to bubble up to the
  13699. // parent boundary if it is currently invisible.
  13700. if (hasInvisibleParent) {
  13701. return false;
  13702. }
  13703. // If the parent is not able to handle it, we must handle it.
  13704. return true;
  13705. }
  13706. function findFirstSuspended(row) {
  13707. var node = row;
  13708. while (node !== null) {
  13709. if (node.tag === SuspenseComponent) {
  13710. var state = node.memoizedState;
  13711. if (state !== null) {
  13712. return node;
  13713. }
  13714. } else if (node.tag === SuspenseListComponent &&
  13715. // revealOrder undefined can't be trusted because it don't
  13716. // keep track of whether it suspended or not.
  13717. node.memoizedProps.revealOrder !== undefined) {
  13718. var didSuspend = (node.effectTag & DidCapture) !== NoEffect;
  13719. if (didSuspend) {
  13720. return node;
  13721. }
  13722. } else if (node.child !== null) {
  13723. node.child.return = node;
  13724. node = node.child;
  13725. continue;
  13726. }
  13727. if (node === row) {
  13728. return null;
  13729. }
  13730. while (node.sibling === null) {
  13731. if (node.return === null || node.return === row) {
  13732. return null;
  13733. }
  13734. node = node.return;
  13735. }
  13736. node.sibling.return = node.return;
  13737. node = node.sibling;
  13738. }
  13739. return null;
  13740. }
  13741. var NoEffect$1 = /* */0;
  13742. var UnmountSnapshot = /* */2;
  13743. var UnmountMutation = /* */4;
  13744. var MountMutation = /* */8;
  13745. var UnmountLayout = /* */16;
  13746. var MountLayout = /* */32;
  13747. var MountPassive = /* */64;
  13748. var UnmountPassive = /* */128;
  13749. var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;
  13750. var didWarnAboutMismatchedHooksForComponent = void 0;
  13751. {
  13752. didWarnAboutMismatchedHooksForComponent = new Set();
  13753. }
  13754. // These are set right before calling the component.
  13755. var renderExpirationTime$1 = NoWork;
  13756. // The work-in-progress fiber. I've named it differently to distinguish it from
  13757. // the work-in-progress hook.
  13758. var currentlyRenderingFiber$1 = null;
  13759. // Hooks are stored as a linked list on the fiber's memoizedState field. The
  13760. // current hook list is the list that belongs to the current fiber. The
  13761. // work-in-progress hook list is a new list that will be added to the
  13762. // work-in-progress fiber.
  13763. var currentHook = null;
  13764. var nextCurrentHook = null;
  13765. var firstWorkInProgressHook = null;
  13766. var workInProgressHook = null;
  13767. var nextWorkInProgressHook = null;
  13768. var remainingExpirationTime = NoWork;
  13769. var componentUpdateQueue = null;
  13770. var sideEffectTag = 0;
  13771. // Updates scheduled during render will trigger an immediate re-render at the
  13772. // end of the current pass. We can't store these updates on the normal queue,
  13773. // because if the work is aborted, they should be discarded. Because this is
  13774. // a relatively rare case, we also don't want to add an additional field to
  13775. // either the hook or queue object types. So we store them in a lazily create
  13776. // map of queue -> render-phase updates, which are discarded once the component
  13777. // completes without re-rendering.
  13778. // Whether an update was scheduled during the currently executing render pass.
  13779. var didScheduleRenderPhaseUpdate = false;
  13780. // Lazily created map of render-phase updates
  13781. var renderPhaseUpdates = null;
  13782. // Counter to prevent infinite loops.
  13783. var numberOfReRenders = 0;
  13784. var RE_RENDER_LIMIT = 25;
  13785. // In DEV, this is the name of the currently executing primitive hook
  13786. var currentHookNameInDev = null;
  13787. // In DEV, this list ensures that hooks are called in the same order between renders.
  13788. // The list stores the order of hooks used during the initial render (mount).
  13789. // Subsequent renders (updates) reference this list.
  13790. var hookTypesDev = null;
  13791. var hookTypesUpdateIndexDev = -1;
  13792. // In DEV, this tracks whether currently rendering component needs to ignore
  13793. // the dependencies for Hooks that need them (e.g. useEffect or useMemo).
  13794. // When true, such Hooks will always be "remounted". Only used during hot reload.
  13795. var ignorePreviousDependencies = false;
  13796. function mountHookTypesDev() {
  13797. {
  13798. var hookName = currentHookNameInDev;
  13799. if (hookTypesDev === null) {
  13800. hookTypesDev = [hookName];
  13801. } else {
  13802. hookTypesDev.push(hookName);
  13803. }
  13804. }
  13805. }
  13806. function updateHookTypesDev() {
  13807. {
  13808. var hookName = currentHookNameInDev;
  13809. if (hookTypesDev !== null) {
  13810. hookTypesUpdateIndexDev++;
  13811. if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
  13812. warnOnHookMismatchInDev(hookName);
  13813. }
  13814. }
  13815. }
  13816. }
  13817. function checkDepsAreArrayDev(deps) {
  13818. {
  13819. if (deps !== undefined && deps !== null && !Array.isArray(deps)) {
  13820. // Verify deps, but only on mount to avoid extra checks.
  13821. // It's unlikely their type would change as usually you define them inline.
  13822. warning$1(false, '%s received a final argument that is not an array (instead, received `%s`). When ' + 'specified, the final argument must be an array.', currentHookNameInDev, typeof deps);
  13823. }
  13824. }
  13825. }
  13826. function warnOnHookMismatchInDev(currentHookName) {
  13827. {
  13828. var componentName = getComponentName(currentlyRenderingFiber$1.type);
  13829. if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
  13830. didWarnAboutMismatchedHooksForComponent.add(componentName);
  13831. if (hookTypesDev !== null) {
  13832. var table = '';
  13833. var secondColumnStart = 30;
  13834. for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
  13835. var oldHookName = hookTypesDev[i];
  13836. var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
  13837. var row = i + 1 + '. ' + oldHookName;
  13838. // Extra space so second column lines up
  13839. // lol @ IE not supporting String#repeat
  13840. while (row.length < secondColumnStart) {
  13841. row += ' ';
  13842. }
  13843. row += newHookName + '\n';
  13844. table += row;
  13845. }
  13846. warning$1(false, 'React has detected a change in the order of Hooks called by %s. ' + 'This will lead to bugs and errors if not fixed. ' + 'For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' ------------------------------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table);
  13847. }
  13848. }
  13849. }
  13850. }
  13851. function throwInvalidHookError() {
  13852. (function () {
  13853. {
  13854. {
  13855. throw ReactError(Error('Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.'));
  13856. }
  13857. }
  13858. })();
  13859. }
  13860. function areHookInputsEqual(nextDeps, prevDeps) {
  13861. {
  13862. if (ignorePreviousDependencies) {
  13863. // Only true when this component is being hot reloaded.
  13864. return false;
  13865. }
  13866. }
  13867. if (prevDeps === null) {
  13868. {
  13869. warning$1(false, '%s received a final argument during this render, but not during ' + 'the previous render. Even though the final argument is optional, ' + 'its type cannot change between renders.', currentHookNameInDev);
  13870. }
  13871. return false;
  13872. }
  13873. {
  13874. // Don't bother comparing lengths in prod because these arrays should be
  13875. // passed inline.
  13876. if (nextDeps.length !== prevDeps.length) {
  13877. warning$1(false, 'The final argument passed to %s changed size between renders. The ' + 'order and size of this array must remain constant.\n\n' + 'Previous: %s\n' + 'Incoming: %s', currentHookNameInDev, '[' + prevDeps.join(', ') + ']', '[' + nextDeps.join(', ') + ']');
  13878. }
  13879. }
  13880. for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
  13881. if (is(nextDeps[i], prevDeps[i])) {
  13882. continue;
  13883. }
  13884. return false;
  13885. }
  13886. return true;
  13887. }
  13888. function renderWithHooks(current, workInProgress, Component, props, refOrContext, nextRenderExpirationTime) {
  13889. renderExpirationTime$1 = nextRenderExpirationTime;
  13890. currentlyRenderingFiber$1 = workInProgress;
  13891. nextCurrentHook = current !== null ? current.memoizedState : null;
  13892. {
  13893. hookTypesDev = current !== null ? current._debugHookTypes : null;
  13894. hookTypesUpdateIndexDev = -1;
  13895. // Used for hot reloading:
  13896. ignorePreviousDependencies = current !== null && current.type !== workInProgress.type;
  13897. }
  13898. // The following should have already been reset
  13899. // currentHook = null;
  13900. // workInProgressHook = null;
  13901. // remainingExpirationTime = NoWork;
  13902. // componentUpdateQueue = null;
  13903. // didScheduleRenderPhaseUpdate = false;
  13904. // renderPhaseUpdates = null;
  13905. // numberOfReRenders = 0;
  13906. // sideEffectTag = 0;
  13907. // TODO Warn if no hooks are used at all during mount, then some are used during update.
  13908. // Currently we will identify the update render as a mount because nextCurrentHook === null.
  13909. // This is tricky because it's valid for certain types of components (e.g. React.lazy)
  13910. // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used.
  13911. // Non-stateful hooks (e.g. context) don't get added to memoizedState,
  13912. // so nextCurrentHook would be null during updates and mounts.
  13913. {
  13914. if (nextCurrentHook !== null) {
  13915. ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
  13916. } else if (hookTypesDev !== null) {
  13917. // This dispatcher handles an edge case where a component is updating,
  13918. // but no stateful hooks have been used.
  13919. // We want to match the production code behavior (which will use HooksDispatcherOnMount),
  13920. // but with the extra DEV validation to ensure hooks ordering hasn't changed.
  13921. // This dispatcher does that.
  13922. ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
  13923. } else {
  13924. ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
  13925. }
  13926. }
  13927. var children = Component(props, refOrContext);
  13928. if (didScheduleRenderPhaseUpdate) {
  13929. do {
  13930. didScheduleRenderPhaseUpdate = false;
  13931. numberOfReRenders += 1;
  13932. // Start over from the beginning of the list
  13933. nextCurrentHook = current !== null ? current.memoizedState : null;
  13934. nextWorkInProgressHook = firstWorkInProgressHook;
  13935. currentHook = null;
  13936. workInProgressHook = null;
  13937. componentUpdateQueue = null;
  13938. {
  13939. // Also validate hook order for cascading updates.
  13940. hookTypesUpdateIndexDev = -1;
  13941. }
  13942. ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
  13943. children = Component(props, refOrContext);
  13944. } while (didScheduleRenderPhaseUpdate);
  13945. renderPhaseUpdates = null;
  13946. numberOfReRenders = 0;
  13947. }
  13948. // We can assume the previous dispatcher is always this one, since we set it
  13949. // at the beginning of the render phase and there's no re-entrancy.
  13950. ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
  13951. var renderedWork = currentlyRenderingFiber$1;
  13952. renderedWork.memoizedState = firstWorkInProgressHook;
  13953. renderedWork.expirationTime = remainingExpirationTime;
  13954. renderedWork.updateQueue = componentUpdateQueue;
  13955. renderedWork.effectTag |= sideEffectTag;
  13956. {
  13957. renderedWork._debugHookTypes = hookTypesDev;
  13958. }
  13959. // This check uses currentHook so that it works the same in DEV and prod bundles.
  13960. // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
  13961. var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
  13962. renderExpirationTime$1 = NoWork;
  13963. currentlyRenderingFiber$1 = null;
  13964. currentHook = null;
  13965. nextCurrentHook = null;
  13966. firstWorkInProgressHook = null;
  13967. workInProgressHook = null;
  13968. nextWorkInProgressHook = null;
  13969. {
  13970. currentHookNameInDev = null;
  13971. hookTypesDev = null;
  13972. hookTypesUpdateIndexDev = -1;
  13973. }
  13974. remainingExpirationTime = NoWork;
  13975. componentUpdateQueue = null;
  13976. sideEffectTag = 0;
  13977. // These were reset above
  13978. // didScheduleRenderPhaseUpdate = false;
  13979. // renderPhaseUpdates = null;
  13980. // numberOfReRenders = 0;
  13981. (function () {
  13982. if (!!didRenderTooFewHooks) {
  13983. {
  13984. throw ReactError(Error('Rendered fewer hooks than expected. This may be caused by an accidental early return statement.'));
  13985. }
  13986. }
  13987. })();
  13988. return children;
  13989. }
  13990. function bailoutHooks(current, workInProgress, expirationTime) {
  13991. workInProgress.updateQueue = current.updateQueue;
  13992. workInProgress.effectTag &= ~(Passive | Update);
  13993. if (current.expirationTime <= expirationTime) {
  13994. current.expirationTime = NoWork;
  13995. }
  13996. }
  13997. function resetHooks() {
  13998. // We can assume the previous dispatcher is always this one, since we set it
  13999. // at the beginning of the render phase and there's no re-entrancy.
  14000. ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
  14001. // This is used to reset the state of this module when a component throws.
  14002. // It's also called inside mountIndeterminateComponent if we determine the
  14003. // component is a module-style component.
  14004. renderExpirationTime$1 = NoWork;
  14005. currentlyRenderingFiber$1 = null;
  14006. currentHook = null;
  14007. nextCurrentHook = null;
  14008. firstWorkInProgressHook = null;
  14009. workInProgressHook = null;
  14010. nextWorkInProgressHook = null;
  14011. {
  14012. hookTypesDev = null;
  14013. hookTypesUpdateIndexDev = -1;
  14014. currentHookNameInDev = null;
  14015. }
  14016. remainingExpirationTime = NoWork;
  14017. componentUpdateQueue = null;
  14018. sideEffectTag = 0;
  14019. didScheduleRenderPhaseUpdate = false;
  14020. renderPhaseUpdates = null;
  14021. numberOfReRenders = 0;
  14022. }
  14023. function mountWorkInProgressHook() {
  14024. var hook = {
  14025. memoizedState: null,
  14026. baseState: null,
  14027. queue: null,
  14028. baseUpdate: null,
  14029. next: null
  14030. };
  14031. if (workInProgressHook === null) {
  14032. // This is the first hook in the list
  14033. firstWorkInProgressHook = workInProgressHook = hook;
  14034. } else {
  14035. // Append to the end of the list
  14036. workInProgressHook = workInProgressHook.next = hook;
  14037. }
  14038. return workInProgressHook;
  14039. }
  14040. function updateWorkInProgressHook() {
  14041. // This function is used both for updates and for re-renders triggered by a
  14042. // render phase update. It assumes there is either a current hook we can
  14043. // clone, or a work-in-progress hook from a previous render pass that we can
  14044. // use as a base. When we reach the end of the base list, we must switch to
  14045. // the dispatcher used for mounts.
  14046. if (nextWorkInProgressHook !== null) {
  14047. // There's already a work-in-progress. Reuse it.
  14048. workInProgressHook = nextWorkInProgressHook;
  14049. nextWorkInProgressHook = workInProgressHook.next;
  14050. currentHook = nextCurrentHook;
  14051. nextCurrentHook = currentHook !== null ? currentHook.next : null;
  14052. } else {
  14053. // Clone from the current hook.
  14054. (function () {
  14055. if (!(nextCurrentHook !== null)) {
  14056. {
  14057. throw ReactError(Error('Rendered more hooks than during the previous render.'));
  14058. }
  14059. }
  14060. })();
  14061. currentHook = nextCurrentHook;
  14062. var newHook = {
  14063. memoizedState: currentHook.memoizedState,
  14064. baseState: currentHook.baseState,
  14065. queue: currentHook.queue,
  14066. baseUpdate: currentHook.baseUpdate,
  14067. next: null
  14068. };
  14069. if (workInProgressHook === null) {
  14070. // This is the first hook in the list.
  14071. workInProgressHook = firstWorkInProgressHook = newHook;
  14072. } else {
  14073. // Append to the end of the list.
  14074. workInProgressHook = workInProgressHook.next = newHook;
  14075. }
  14076. nextCurrentHook = currentHook.next;
  14077. }
  14078. return workInProgressHook;
  14079. }
  14080. function createFunctionComponentUpdateQueue() {
  14081. return {
  14082. lastEffect: null
  14083. };
  14084. }
  14085. function basicStateReducer(state, action) {
  14086. return typeof action === 'function' ? action(state) : action;
  14087. }
  14088. function mountReducer(reducer, initialArg, init) {
  14089. var hook = mountWorkInProgressHook();
  14090. var initialState = void 0;
  14091. if (init !== undefined) {
  14092. initialState = init(initialArg);
  14093. } else {
  14094. initialState = initialArg;
  14095. }
  14096. hook.memoizedState = hook.baseState = initialState;
  14097. var queue = hook.queue = {
  14098. last: null,
  14099. dispatch: null,
  14100. lastRenderedReducer: reducer,
  14101. lastRenderedState: initialState
  14102. };
  14103. var dispatch = queue.dispatch = dispatchAction.bind(null,
  14104. // Flow doesn't know this is non-null, but we do.
  14105. currentlyRenderingFiber$1, queue);
  14106. return [hook.memoizedState, dispatch];
  14107. }
  14108. function updateReducer(reducer, initialArg, init) {
  14109. var hook = updateWorkInProgressHook();
  14110. var queue = hook.queue;
  14111. (function () {
  14112. if (!(queue !== null)) {
  14113. {
  14114. throw ReactError(Error('Should have a queue. This is likely a bug in React. Please file an issue.'));
  14115. }
  14116. }
  14117. })();
  14118. queue.lastRenderedReducer = reducer;
  14119. if (numberOfReRenders > 0) {
  14120. // This is a re-render. Apply the new render phase updates to the previous
  14121. var _dispatch = queue.dispatch;
  14122. if (renderPhaseUpdates !== null) {
  14123. // Render phase updates are stored in a map of queue -> linked list
  14124. var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
  14125. if (firstRenderPhaseUpdate !== undefined) {
  14126. renderPhaseUpdates.delete(queue);
  14127. var newState = hook.memoizedState;
  14128. var update = firstRenderPhaseUpdate;
  14129. do {
  14130. // Process this render phase update. We don't have to check the
  14131. // priority because it will always be the same as the current
  14132. // render's.
  14133. var _action = update.action;
  14134. newState = reducer(newState, _action);
  14135. update = update.next;
  14136. } while (update !== null);
  14137. // Mark that the fiber performed work, but only if the new state is
  14138. // different from the current state.
  14139. if (!is(newState, hook.memoizedState)) {
  14140. markWorkInProgressReceivedUpdate();
  14141. }
  14142. hook.memoizedState = newState;
  14143. // Don't persist the state accumulated from the render phase updates to
  14144. // the base state unless the queue is empty.
  14145. // TODO: Not sure if this is the desired semantics, but it's what we
  14146. // do for gDSFP. I can't remember why.
  14147. if (hook.baseUpdate === queue.last) {
  14148. hook.baseState = newState;
  14149. }
  14150. queue.lastRenderedState = newState;
  14151. return [newState, _dispatch];
  14152. }
  14153. }
  14154. return [hook.memoizedState, _dispatch];
  14155. }
  14156. // The last update in the entire queue
  14157. var last = queue.last;
  14158. // The last update that is part of the base state.
  14159. var baseUpdate = hook.baseUpdate;
  14160. var baseState = hook.baseState;
  14161. // Find the first unprocessed update.
  14162. var first = void 0;
  14163. if (baseUpdate !== null) {
  14164. if (last !== null) {
  14165. // For the first update, the queue is a circular linked list where
  14166. // `queue.last.next = queue.first`. Once the first update commits, and
  14167. // the `baseUpdate` is no longer empty, we can unravel the list.
  14168. last.next = null;
  14169. }
  14170. first = baseUpdate.next;
  14171. } else {
  14172. first = last !== null ? last.next : null;
  14173. }
  14174. if (first !== null) {
  14175. var _newState = baseState;
  14176. var newBaseState = null;
  14177. var newBaseUpdate = null;
  14178. var prevUpdate = baseUpdate;
  14179. var _update = first;
  14180. var didSkip = false;
  14181. do {
  14182. var updateExpirationTime = _update.expirationTime;
  14183. if (updateExpirationTime < renderExpirationTime$1) {
  14184. // Priority is insufficient. Skip this update. If this is the first
  14185. // skipped update, the previous update/state is the new base
  14186. // update/state.
  14187. if (!didSkip) {
  14188. didSkip = true;
  14189. newBaseUpdate = prevUpdate;
  14190. newBaseState = _newState;
  14191. }
  14192. // Update the remaining priority in the queue.
  14193. if (updateExpirationTime > remainingExpirationTime) {
  14194. remainingExpirationTime = updateExpirationTime;
  14195. }
  14196. } else {
  14197. // This update does have sufficient priority.
  14198. // Mark the event time of this update as relevant to this render pass.
  14199. // TODO: This should ideally use the true event time of this update rather than
  14200. // its priority which is a derived and not reverseable value.
  14201. // TODO: We should skip this update if it was already committed but currently
  14202. // we have no way of detecting the difference between a committed and suspended
  14203. // update here.
  14204. markRenderEventTimeAndConfig(updateExpirationTime, _update.suspenseConfig);
  14205. // Process this update.
  14206. if (_update.eagerReducer === reducer) {
  14207. // If this update was processed eagerly, and its reducer matches the
  14208. // current reducer, we can use the eagerly computed state.
  14209. _newState = _update.eagerState;
  14210. } else {
  14211. var _action2 = _update.action;
  14212. _newState = reducer(_newState, _action2);
  14213. }
  14214. }
  14215. prevUpdate = _update;
  14216. _update = _update.next;
  14217. } while (_update !== null && _update !== first);
  14218. if (!didSkip) {
  14219. newBaseUpdate = prevUpdate;
  14220. newBaseState = _newState;
  14221. }
  14222. // Mark that the fiber performed work, but only if the new state is
  14223. // different from the current state.
  14224. if (!is(_newState, hook.memoizedState)) {
  14225. markWorkInProgressReceivedUpdate();
  14226. }
  14227. hook.memoizedState = _newState;
  14228. hook.baseUpdate = newBaseUpdate;
  14229. hook.baseState = newBaseState;
  14230. queue.lastRenderedState = _newState;
  14231. }
  14232. var dispatch = queue.dispatch;
  14233. return [hook.memoizedState, dispatch];
  14234. }
  14235. function mountState(initialState) {
  14236. var hook = mountWorkInProgressHook();
  14237. if (typeof initialState === 'function') {
  14238. initialState = initialState();
  14239. }
  14240. hook.memoizedState = hook.baseState = initialState;
  14241. var queue = hook.queue = {
  14242. last: null,
  14243. dispatch: null,
  14244. lastRenderedReducer: basicStateReducer,
  14245. lastRenderedState: initialState
  14246. };
  14247. var dispatch = queue.dispatch = dispatchAction.bind(null,
  14248. // Flow doesn't know this is non-null, but we do.
  14249. currentlyRenderingFiber$1, queue);
  14250. return [hook.memoizedState, dispatch];
  14251. }
  14252. function updateState(initialState) {
  14253. return updateReducer(basicStateReducer, initialState);
  14254. }
  14255. function pushEffect(tag, create, destroy, deps) {
  14256. var effect = {
  14257. tag: tag,
  14258. create: create,
  14259. destroy: destroy,
  14260. deps: deps,
  14261. // Circular
  14262. next: null
  14263. };
  14264. if (componentUpdateQueue === null) {
  14265. componentUpdateQueue = createFunctionComponentUpdateQueue();
  14266. componentUpdateQueue.lastEffect = effect.next = effect;
  14267. } else {
  14268. var _lastEffect = componentUpdateQueue.lastEffect;
  14269. if (_lastEffect === null) {
  14270. componentUpdateQueue.lastEffect = effect.next = effect;
  14271. } else {
  14272. var firstEffect = _lastEffect.next;
  14273. _lastEffect.next = effect;
  14274. effect.next = firstEffect;
  14275. componentUpdateQueue.lastEffect = effect;
  14276. }
  14277. }
  14278. return effect;
  14279. }
  14280. function mountRef(initialValue) {
  14281. var hook = mountWorkInProgressHook();
  14282. var ref = { current: initialValue };
  14283. {
  14284. Object.seal(ref);
  14285. }
  14286. hook.memoizedState = ref;
  14287. return ref;
  14288. }
  14289. function updateRef(initialValue) {
  14290. var hook = updateWorkInProgressHook();
  14291. return hook.memoizedState;
  14292. }
  14293. function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
  14294. var hook = mountWorkInProgressHook();
  14295. var nextDeps = deps === undefined ? null : deps;
  14296. sideEffectTag |= fiberEffectTag;
  14297. hook.memoizedState = pushEffect(hookEffectTag, create, undefined, nextDeps);
  14298. }
  14299. function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) {
  14300. var hook = updateWorkInProgressHook();
  14301. var nextDeps = deps === undefined ? null : deps;
  14302. var destroy = undefined;
  14303. if (currentHook !== null) {
  14304. var prevEffect = currentHook.memoizedState;
  14305. destroy = prevEffect.destroy;
  14306. if (nextDeps !== null) {
  14307. var prevDeps = prevEffect.deps;
  14308. if (areHookInputsEqual(nextDeps, prevDeps)) {
  14309. pushEffect(NoEffect$1, create, destroy, nextDeps);
  14310. return;
  14311. }
  14312. }
  14313. }
  14314. sideEffectTag |= fiberEffectTag;
  14315. hook.memoizedState = pushEffect(hookEffectTag, create, destroy, nextDeps);
  14316. }
  14317. function mountEffect(create, deps) {
  14318. {
  14319. // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
  14320. if ('undefined' !== typeof jest) {
  14321. warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
  14322. }
  14323. }
  14324. return mountEffectImpl(Update | Passive, UnmountPassive | MountPassive, create, deps);
  14325. }
  14326. function updateEffect(create, deps) {
  14327. {
  14328. // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
  14329. if ('undefined' !== typeof jest) {
  14330. warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
  14331. }
  14332. }
  14333. return updateEffectImpl(Update | Passive, UnmountPassive | MountPassive, create, deps);
  14334. }
  14335. function mountLayoutEffect(create, deps) {
  14336. return mountEffectImpl(Update, UnmountMutation | MountLayout, create, deps);
  14337. }
  14338. function updateLayoutEffect(create, deps) {
  14339. return updateEffectImpl(Update, UnmountMutation | MountLayout, create, deps);
  14340. }
  14341. function imperativeHandleEffect(create, ref) {
  14342. if (typeof ref === 'function') {
  14343. var refCallback = ref;
  14344. var _inst = create();
  14345. refCallback(_inst);
  14346. return function () {
  14347. refCallback(null);
  14348. };
  14349. } else if (ref !== null && ref !== undefined) {
  14350. var refObject = ref;
  14351. {
  14352. !refObject.hasOwnProperty('current') ? warning$1(false, 'Expected useImperativeHandle() first argument to either be a ' + 'ref callback or React.createRef() object. Instead received: %s.', 'an object with keys {' + Object.keys(refObject).join(', ') + '}') : void 0;
  14353. }
  14354. var _inst2 = create();
  14355. refObject.current = _inst2;
  14356. return function () {
  14357. refObject.current = null;
  14358. };
  14359. }
  14360. }
  14361. function mountImperativeHandle(ref, create, deps) {
  14362. {
  14363. !(typeof create === 'function') ? warning$1(false, 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null') : void 0;
  14364. }
  14365. // TODO: If deps are provided, should we skip comparing the ref itself?
  14366. var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
  14367. return mountEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
  14368. }
  14369. function updateImperativeHandle(ref, create, deps) {
  14370. {
  14371. !(typeof create === 'function') ? warning$1(false, 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null') : void 0;
  14372. }
  14373. // TODO: If deps are provided, should we skip comparing the ref itself?
  14374. var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
  14375. return updateEffectImpl(Update, UnmountMutation | MountLayout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
  14376. }
  14377. function mountDebugValue(value, formatterFn) {
  14378. // This hook is normally a no-op.
  14379. // The react-debug-hooks package injects its own implementation
  14380. // so that e.g. DevTools can display custom hook values.
  14381. }
  14382. var updateDebugValue = mountDebugValue;
  14383. function mountCallback(callback, deps) {
  14384. var hook = mountWorkInProgressHook();
  14385. var nextDeps = deps === undefined ? null : deps;
  14386. hook.memoizedState = [callback, nextDeps];
  14387. return callback;
  14388. }
  14389. function updateCallback(callback, deps) {
  14390. var hook = updateWorkInProgressHook();
  14391. var nextDeps = deps === undefined ? null : deps;
  14392. var prevState = hook.memoizedState;
  14393. if (prevState !== null) {
  14394. if (nextDeps !== null) {
  14395. var prevDeps = prevState[1];
  14396. if (areHookInputsEqual(nextDeps, prevDeps)) {
  14397. return prevState[0];
  14398. }
  14399. }
  14400. }
  14401. hook.memoizedState = [callback, nextDeps];
  14402. return callback;
  14403. }
  14404. function mountMemo(nextCreate, deps) {
  14405. var hook = mountWorkInProgressHook();
  14406. var nextDeps = deps === undefined ? null : deps;
  14407. var nextValue = nextCreate();
  14408. hook.memoizedState = [nextValue, nextDeps];
  14409. return nextValue;
  14410. }
  14411. function updateMemo(nextCreate, deps) {
  14412. var hook = updateWorkInProgressHook();
  14413. var nextDeps = deps === undefined ? null : deps;
  14414. var prevState = hook.memoizedState;
  14415. if (prevState !== null) {
  14416. // Assume these are defined. If they're not, areHookInputsEqual will warn.
  14417. if (nextDeps !== null) {
  14418. var prevDeps = prevState[1];
  14419. if (areHookInputsEqual(nextDeps, prevDeps)) {
  14420. return prevState[0];
  14421. }
  14422. }
  14423. }
  14424. var nextValue = nextCreate();
  14425. hook.memoizedState = [nextValue, nextDeps];
  14426. return nextValue;
  14427. }
  14428. function dispatchAction(fiber, queue, action) {
  14429. (function () {
  14430. if (!(numberOfReRenders < RE_RENDER_LIMIT)) {
  14431. {
  14432. throw ReactError(Error('Too many re-renders. React limits the number of renders to prevent an infinite loop.'));
  14433. }
  14434. }
  14435. })();
  14436. {
  14437. !(arguments.length <= 3) ? warning$1(false, "State updates from the useState() and useReducer() Hooks don't support the " + 'second callback argument. To execute a side effect after ' + 'rendering, declare it in the component body with useEffect().') : void 0;
  14438. }
  14439. var alternate = fiber.alternate;
  14440. if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) {
  14441. // This is a render phase update. Stash it in a lazily-created map of
  14442. // queue -> linked list of updates. After this render pass, we'll restart
  14443. // and apply the stashed updates on top of the work-in-progress hook.
  14444. didScheduleRenderPhaseUpdate = true;
  14445. var update = {
  14446. expirationTime: renderExpirationTime$1,
  14447. suspenseConfig: null,
  14448. action: action,
  14449. eagerReducer: null,
  14450. eagerState: null,
  14451. next: null
  14452. };
  14453. {
  14454. update.priority = getCurrentPriorityLevel();
  14455. }
  14456. if (renderPhaseUpdates === null) {
  14457. renderPhaseUpdates = new Map();
  14458. }
  14459. var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
  14460. if (firstRenderPhaseUpdate === undefined) {
  14461. renderPhaseUpdates.set(queue, update);
  14462. } else {
  14463. // Append the update to the end of the list.
  14464. var lastRenderPhaseUpdate = firstRenderPhaseUpdate;
  14465. while (lastRenderPhaseUpdate.next !== null) {
  14466. lastRenderPhaseUpdate = lastRenderPhaseUpdate.next;
  14467. }
  14468. lastRenderPhaseUpdate.next = update;
  14469. }
  14470. } else {
  14471. if (revertPassiveEffectsChange) {
  14472. flushPassiveEffects();
  14473. }
  14474. var currentTime = requestCurrentTime();
  14475. var _suspenseConfig = requestCurrentSuspenseConfig();
  14476. var _expirationTime = computeExpirationForFiber(currentTime, fiber, _suspenseConfig);
  14477. var _update2 = {
  14478. expirationTime: _expirationTime,
  14479. suspenseConfig: _suspenseConfig,
  14480. action: action,
  14481. eagerReducer: null,
  14482. eagerState: null,
  14483. next: null
  14484. };
  14485. {
  14486. _update2.priority = getCurrentPriorityLevel();
  14487. }
  14488. // Append the update to the end of the list.
  14489. var _last = queue.last;
  14490. if (_last === null) {
  14491. // This is the first update. Create a circular list.
  14492. _update2.next = _update2;
  14493. } else {
  14494. var first = _last.next;
  14495. if (first !== null) {
  14496. // Still circular.
  14497. _update2.next = first;
  14498. }
  14499. _last.next = _update2;
  14500. }
  14501. queue.last = _update2;
  14502. if (fiber.expirationTime === NoWork && (alternate === null || alternate.expirationTime === NoWork)) {
  14503. // The queue is currently empty, which means we can eagerly compute the
  14504. // next state before entering the render phase. If the new state is the
  14505. // same as the current state, we may be able to bail out entirely.
  14506. var _lastRenderedReducer = queue.lastRenderedReducer;
  14507. if (_lastRenderedReducer !== null) {
  14508. var prevDispatcher = void 0;
  14509. {
  14510. prevDispatcher = ReactCurrentDispatcher$1.current;
  14511. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  14512. }
  14513. try {
  14514. var currentState = queue.lastRenderedState;
  14515. var _eagerState = _lastRenderedReducer(currentState, action);
  14516. // Stash the eagerly computed state, and the reducer used to compute
  14517. // it, on the update object. If the reducer hasn't changed by the
  14518. // time we enter the render phase, then the eager state can be used
  14519. // without calling the reducer again.
  14520. _update2.eagerReducer = _lastRenderedReducer;
  14521. _update2.eagerState = _eagerState;
  14522. if (is(_eagerState, currentState)) {
  14523. // Fast path. We can bail out without scheduling React to re-render.
  14524. // It's still possible that we'll need to rebase this update later,
  14525. // if the component re-renders for a different reason and by that
  14526. // time the reducer has changed.
  14527. return;
  14528. }
  14529. } catch (error) {
  14530. // Suppress the error. It will throw again in the render phase.
  14531. } finally {
  14532. {
  14533. ReactCurrentDispatcher$1.current = prevDispatcher;
  14534. }
  14535. }
  14536. }
  14537. }
  14538. {
  14539. // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
  14540. if ('undefined' !== typeof jest) {
  14541. warnIfNotScopedWithMatchingAct(fiber);
  14542. warnIfNotCurrentlyActingUpdatesInDev(fiber);
  14543. }
  14544. }
  14545. scheduleWork(fiber, _expirationTime);
  14546. }
  14547. }
  14548. var ContextOnlyDispatcher = {
  14549. readContext: readContext,
  14550. useCallback: throwInvalidHookError,
  14551. useContext: throwInvalidHookError,
  14552. useEffect: throwInvalidHookError,
  14553. useImperativeHandle: throwInvalidHookError,
  14554. useLayoutEffect: throwInvalidHookError,
  14555. useMemo: throwInvalidHookError,
  14556. useReducer: throwInvalidHookError,
  14557. useRef: throwInvalidHookError,
  14558. useState: throwInvalidHookError,
  14559. useDebugValue: throwInvalidHookError,
  14560. useResponder: throwInvalidHookError
  14561. };
  14562. var HooksDispatcherOnMountInDEV = null;
  14563. var HooksDispatcherOnMountWithHookTypesInDEV = null;
  14564. var HooksDispatcherOnUpdateInDEV = null;
  14565. var InvalidNestedHooksDispatcherOnMountInDEV = null;
  14566. var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
  14567. {
  14568. var warnInvalidContextAccess = function () {
  14569. warning$1(false, 'Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().');
  14570. };
  14571. var warnInvalidHookAccess = function () {
  14572. warning$1(false, 'Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. ' + 'You can only call Hooks at the top level of your React function. ' + 'For more information, see ' + 'https://fb.me/rules-of-hooks');
  14573. };
  14574. HooksDispatcherOnMountInDEV = {
  14575. readContext: function (context, observedBits) {
  14576. return readContext(context, observedBits);
  14577. },
  14578. useCallback: function (callback, deps) {
  14579. currentHookNameInDev = 'useCallback';
  14580. mountHookTypesDev();
  14581. checkDepsAreArrayDev(deps);
  14582. return mountCallback(callback, deps);
  14583. },
  14584. useContext: function (context, observedBits) {
  14585. currentHookNameInDev = 'useContext';
  14586. mountHookTypesDev();
  14587. return readContext(context, observedBits);
  14588. },
  14589. useEffect: function (create, deps) {
  14590. currentHookNameInDev = 'useEffect';
  14591. mountHookTypesDev();
  14592. checkDepsAreArrayDev(deps);
  14593. return mountEffect(create, deps);
  14594. },
  14595. useImperativeHandle: function (ref, create, deps) {
  14596. currentHookNameInDev = 'useImperativeHandle';
  14597. mountHookTypesDev();
  14598. checkDepsAreArrayDev(deps);
  14599. return mountImperativeHandle(ref, create, deps);
  14600. },
  14601. useLayoutEffect: function (create, deps) {
  14602. currentHookNameInDev = 'useLayoutEffect';
  14603. mountHookTypesDev();
  14604. checkDepsAreArrayDev(deps);
  14605. return mountLayoutEffect(create, deps);
  14606. },
  14607. useMemo: function (create, deps) {
  14608. currentHookNameInDev = 'useMemo';
  14609. mountHookTypesDev();
  14610. checkDepsAreArrayDev(deps);
  14611. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14612. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  14613. try {
  14614. return mountMemo(create, deps);
  14615. } finally {
  14616. ReactCurrentDispatcher$1.current = prevDispatcher;
  14617. }
  14618. },
  14619. useReducer: function (reducer, initialArg, init) {
  14620. currentHookNameInDev = 'useReducer';
  14621. mountHookTypesDev();
  14622. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14623. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  14624. try {
  14625. return mountReducer(reducer, initialArg, init);
  14626. } finally {
  14627. ReactCurrentDispatcher$1.current = prevDispatcher;
  14628. }
  14629. },
  14630. useRef: function (initialValue) {
  14631. currentHookNameInDev = 'useRef';
  14632. mountHookTypesDev();
  14633. return mountRef(initialValue);
  14634. },
  14635. useState: function (initialState) {
  14636. currentHookNameInDev = 'useState';
  14637. mountHookTypesDev();
  14638. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14639. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  14640. try {
  14641. return mountState(initialState);
  14642. } finally {
  14643. ReactCurrentDispatcher$1.current = prevDispatcher;
  14644. }
  14645. },
  14646. useDebugValue: function (value, formatterFn) {
  14647. currentHookNameInDev = 'useDebugValue';
  14648. mountHookTypesDev();
  14649. return mountDebugValue(value, formatterFn);
  14650. },
  14651. useResponder: function (responder, props) {
  14652. currentHookNameInDev = 'useResponder';
  14653. mountHookTypesDev();
  14654. return createResponderListener(responder, props);
  14655. }
  14656. };
  14657. HooksDispatcherOnMountWithHookTypesInDEV = {
  14658. readContext: function (context, observedBits) {
  14659. return readContext(context, observedBits);
  14660. },
  14661. useCallback: function (callback, deps) {
  14662. currentHookNameInDev = 'useCallback';
  14663. updateHookTypesDev();
  14664. return mountCallback(callback, deps);
  14665. },
  14666. useContext: function (context, observedBits) {
  14667. currentHookNameInDev = 'useContext';
  14668. updateHookTypesDev();
  14669. return readContext(context, observedBits);
  14670. },
  14671. useEffect: function (create, deps) {
  14672. currentHookNameInDev = 'useEffect';
  14673. updateHookTypesDev();
  14674. return mountEffect(create, deps);
  14675. },
  14676. useImperativeHandle: function (ref, create, deps) {
  14677. currentHookNameInDev = 'useImperativeHandle';
  14678. updateHookTypesDev();
  14679. return mountImperativeHandle(ref, create, deps);
  14680. },
  14681. useLayoutEffect: function (create, deps) {
  14682. currentHookNameInDev = 'useLayoutEffect';
  14683. updateHookTypesDev();
  14684. return mountLayoutEffect(create, deps);
  14685. },
  14686. useMemo: function (create, deps) {
  14687. currentHookNameInDev = 'useMemo';
  14688. updateHookTypesDev();
  14689. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14690. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  14691. try {
  14692. return mountMemo(create, deps);
  14693. } finally {
  14694. ReactCurrentDispatcher$1.current = prevDispatcher;
  14695. }
  14696. },
  14697. useReducer: function (reducer, initialArg, init) {
  14698. currentHookNameInDev = 'useReducer';
  14699. updateHookTypesDev();
  14700. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14701. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  14702. try {
  14703. return mountReducer(reducer, initialArg, init);
  14704. } finally {
  14705. ReactCurrentDispatcher$1.current = prevDispatcher;
  14706. }
  14707. },
  14708. useRef: function (initialValue) {
  14709. currentHookNameInDev = 'useRef';
  14710. updateHookTypesDev();
  14711. return mountRef(initialValue);
  14712. },
  14713. useState: function (initialState) {
  14714. currentHookNameInDev = 'useState';
  14715. updateHookTypesDev();
  14716. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14717. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  14718. try {
  14719. return mountState(initialState);
  14720. } finally {
  14721. ReactCurrentDispatcher$1.current = prevDispatcher;
  14722. }
  14723. },
  14724. useDebugValue: function (value, formatterFn) {
  14725. currentHookNameInDev = 'useDebugValue';
  14726. updateHookTypesDev();
  14727. return mountDebugValue(value, formatterFn);
  14728. },
  14729. useResponder: function (responder, props) {
  14730. currentHookNameInDev = 'useResponder';
  14731. updateHookTypesDev();
  14732. return createResponderListener(responder, props);
  14733. }
  14734. };
  14735. HooksDispatcherOnUpdateInDEV = {
  14736. readContext: function (context, observedBits) {
  14737. return readContext(context, observedBits);
  14738. },
  14739. useCallback: function (callback, deps) {
  14740. currentHookNameInDev = 'useCallback';
  14741. updateHookTypesDev();
  14742. return updateCallback(callback, deps);
  14743. },
  14744. useContext: function (context, observedBits) {
  14745. currentHookNameInDev = 'useContext';
  14746. updateHookTypesDev();
  14747. return readContext(context, observedBits);
  14748. },
  14749. useEffect: function (create, deps) {
  14750. currentHookNameInDev = 'useEffect';
  14751. updateHookTypesDev();
  14752. return updateEffect(create, deps);
  14753. },
  14754. useImperativeHandle: function (ref, create, deps) {
  14755. currentHookNameInDev = 'useImperativeHandle';
  14756. updateHookTypesDev();
  14757. return updateImperativeHandle(ref, create, deps);
  14758. },
  14759. useLayoutEffect: function (create, deps) {
  14760. currentHookNameInDev = 'useLayoutEffect';
  14761. updateHookTypesDev();
  14762. return updateLayoutEffect(create, deps);
  14763. },
  14764. useMemo: function (create, deps) {
  14765. currentHookNameInDev = 'useMemo';
  14766. updateHookTypesDev();
  14767. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14768. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  14769. try {
  14770. return updateMemo(create, deps);
  14771. } finally {
  14772. ReactCurrentDispatcher$1.current = prevDispatcher;
  14773. }
  14774. },
  14775. useReducer: function (reducer, initialArg, init) {
  14776. currentHookNameInDev = 'useReducer';
  14777. updateHookTypesDev();
  14778. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14779. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  14780. try {
  14781. return updateReducer(reducer, initialArg, init);
  14782. } finally {
  14783. ReactCurrentDispatcher$1.current = prevDispatcher;
  14784. }
  14785. },
  14786. useRef: function (initialValue) {
  14787. currentHookNameInDev = 'useRef';
  14788. updateHookTypesDev();
  14789. return updateRef(initialValue);
  14790. },
  14791. useState: function (initialState) {
  14792. currentHookNameInDev = 'useState';
  14793. updateHookTypesDev();
  14794. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14795. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  14796. try {
  14797. return updateState(initialState);
  14798. } finally {
  14799. ReactCurrentDispatcher$1.current = prevDispatcher;
  14800. }
  14801. },
  14802. useDebugValue: function (value, formatterFn) {
  14803. currentHookNameInDev = 'useDebugValue';
  14804. updateHookTypesDev();
  14805. return updateDebugValue(value, formatterFn);
  14806. },
  14807. useResponder: function (responder, props) {
  14808. currentHookNameInDev = 'useResponder';
  14809. updateHookTypesDev();
  14810. return createResponderListener(responder, props);
  14811. }
  14812. };
  14813. InvalidNestedHooksDispatcherOnMountInDEV = {
  14814. readContext: function (context, observedBits) {
  14815. warnInvalidContextAccess();
  14816. return readContext(context, observedBits);
  14817. },
  14818. useCallback: function (callback, deps) {
  14819. currentHookNameInDev = 'useCallback';
  14820. warnInvalidHookAccess();
  14821. mountHookTypesDev();
  14822. return mountCallback(callback, deps);
  14823. },
  14824. useContext: function (context, observedBits) {
  14825. currentHookNameInDev = 'useContext';
  14826. warnInvalidHookAccess();
  14827. mountHookTypesDev();
  14828. return readContext(context, observedBits);
  14829. },
  14830. useEffect: function (create, deps) {
  14831. currentHookNameInDev = 'useEffect';
  14832. warnInvalidHookAccess();
  14833. mountHookTypesDev();
  14834. return mountEffect(create, deps);
  14835. },
  14836. useImperativeHandle: function (ref, create, deps) {
  14837. currentHookNameInDev = 'useImperativeHandle';
  14838. warnInvalidHookAccess();
  14839. mountHookTypesDev();
  14840. return mountImperativeHandle(ref, create, deps);
  14841. },
  14842. useLayoutEffect: function (create, deps) {
  14843. currentHookNameInDev = 'useLayoutEffect';
  14844. warnInvalidHookAccess();
  14845. mountHookTypesDev();
  14846. return mountLayoutEffect(create, deps);
  14847. },
  14848. useMemo: function (create, deps) {
  14849. currentHookNameInDev = 'useMemo';
  14850. warnInvalidHookAccess();
  14851. mountHookTypesDev();
  14852. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14853. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  14854. try {
  14855. return mountMemo(create, deps);
  14856. } finally {
  14857. ReactCurrentDispatcher$1.current = prevDispatcher;
  14858. }
  14859. },
  14860. useReducer: function (reducer, initialArg, init) {
  14861. currentHookNameInDev = 'useReducer';
  14862. warnInvalidHookAccess();
  14863. mountHookTypesDev();
  14864. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14865. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  14866. try {
  14867. return mountReducer(reducer, initialArg, init);
  14868. } finally {
  14869. ReactCurrentDispatcher$1.current = prevDispatcher;
  14870. }
  14871. },
  14872. useRef: function (initialValue) {
  14873. currentHookNameInDev = 'useRef';
  14874. warnInvalidHookAccess();
  14875. mountHookTypesDev();
  14876. return mountRef(initialValue);
  14877. },
  14878. useState: function (initialState) {
  14879. currentHookNameInDev = 'useState';
  14880. warnInvalidHookAccess();
  14881. mountHookTypesDev();
  14882. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14883. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  14884. try {
  14885. return mountState(initialState);
  14886. } finally {
  14887. ReactCurrentDispatcher$1.current = prevDispatcher;
  14888. }
  14889. },
  14890. useDebugValue: function (value, formatterFn) {
  14891. currentHookNameInDev = 'useDebugValue';
  14892. warnInvalidHookAccess();
  14893. mountHookTypesDev();
  14894. return mountDebugValue(value, formatterFn);
  14895. },
  14896. useResponder: function (responder, props) {
  14897. currentHookNameInDev = 'useResponder';
  14898. warnInvalidHookAccess();
  14899. mountHookTypesDev();
  14900. return createResponderListener(responder, props);
  14901. }
  14902. };
  14903. InvalidNestedHooksDispatcherOnUpdateInDEV = {
  14904. readContext: function (context, observedBits) {
  14905. warnInvalidContextAccess();
  14906. return readContext(context, observedBits);
  14907. },
  14908. useCallback: function (callback, deps) {
  14909. currentHookNameInDev = 'useCallback';
  14910. warnInvalidHookAccess();
  14911. updateHookTypesDev();
  14912. return updateCallback(callback, deps);
  14913. },
  14914. useContext: function (context, observedBits) {
  14915. currentHookNameInDev = 'useContext';
  14916. warnInvalidHookAccess();
  14917. updateHookTypesDev();
  14918. return readContext(context, observedBits);
  14919. },
  14920. useEffect: function (create, deps) {
  14921. currentHookNameInDev = 'useEffect';
  14922. warnInvalidHookAccess();
  14923. updateHookTypesDev();
  14924. return updateEffect(create, deps);
  14925. },
  14926. useImperativeHandle: function (ref, create, deps) {
  14927. currentHookNameInDev = 'useImperativeHandle';
  14928. warnInvalidHookAccess();
  14929. updateHookTypesDev();
  14930. return updateImperativeHandle(ref, create, deps);
  14931. },
  14932. useLayoutEffect: function (create, deps) {
  14933. currentHookNameInDev = 'useLayoutEffect';
  14934. warnInvalidHookAccess();
  14935. updateHookTypesDev();
  14936. return updateLayoutEffect(create, deps);
  14937. },
  14938. useMemo: function (create, deps) {
  14939. currentHookNameInDev = 'useMemo';
  14940. warnInvalidHookAccess();
  14941. updateHookTypesDev();
  14942. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14943. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  14944. try {
  14945. return updateMemo(create, deps);
  14946. } finally {
  14947. ReactCurrentDispatcher$1.current = prevDispatcher;
  14948. }
  14949. },
  14950. useReducer: function (reducer, initialArg, init) {
  14951. currentHookNameInDev = 'useReducer';
  14952. warnInvalidHookAccess();
  14953. updateHookTypesDev();
  14954. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14955. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  14956. try {
  14957. return updateReducer(reducer, initialArg, init);
  14958. } finally {
  14959. ReactCurrentDispatcher$1.current = prevDispatcher;
  14960. }
  14961. },
  14962. useRef: function (initialValue) {
  14963. currentHookNameInDev = 'useRef';
  14964. warnInvalidHookAccess();
  14965. updateHookTypesDev();
  14966. return updateRef(initialValue);
  14967. },
  14968. useState: function (initialState) {
  14969. currentHookNameInDev = 'useState';
  14970. warnInvalidHookAccess();
  14971. updateHookTypesDev();
  14972. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14973. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  14974. try {
  14975. return updateState(initialState);
  14976. } finally {
  14977. ReactCurrentDispatcher$1.current = prevDispatcher;
  14978. }
  14979. },
  14980. useDebugValue: function (value, formatterFn) {
  14981. currentHookNameInDev = 'useDebugValue';
  14982. warnInvalidHookAccess();
  14983. updateHookTypesDev();
  14984. return updateDebugValue(value, formatterFn);
  14985. },
  14986. useResponder: function (responder, props) {
  14987. currentHookNameInDev = 'useResponder';
  14988. warnInvalidHookAccess();
  14989. updateHookTypesDev();
  14990. return createResponderListener(responder, props);
  14991. }
  14992. };
  14993. }
  14994. // Intentionally not named imports because Rollup would use dynamic dispatch for
  14995. // CommonJS interop named imports.
  14996. var now$1 = Scheduler.unstable_now;
  14997. var commitTime = 0;
  14998. var profilerStartTime = -1;
  14999. function getCommitTime() {
  15000. return commitTime;
  15001. }
  15002. function recordCommitTime() {
  15003. if (!enableProfilerTimer) {
  15004. return;
  15005. }
  15006. commitTime = now$1();
  15007. }
  15008. function startProfilerTimer(fiber) {
  15009. if (!enableProfilerTimer) {
  15010. return;
  15011. }
  15012. profilerStartTime = now$1();
  15013. if (fiber.actualStartTime < 0) {
  15014. fiber.actualStartTime = now$1();
  15015. }
  15016. }
  15017. function stopProfilerTimerIfRunning(fiber) {
  15018. if (!enableProfilerTimer) {
  15019. return;
  15020. }
  15021. profilerStartTime = -1;
  15022. }
  15023. function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
  15024. if (!enableProfilerTimer) {
  15025. return;
  15026. }
  15027. if (profilerStartTime >= 0) {
  15028. var elapsedTime = now$1() - profilerStartTime;
  15029. fiber.actualDuration += elapsedTime;
  15030. if (overrideBaseTime) {
  15031. fiber.selfBaseDuration = elapsedTime;
  15032. }
  15033. profilerStartTime = -1;
  15034. }
  15035. }
  15036. // The deepest Fiber on the stack involved in a hydration context.
  15037. // This may have been an insertion or a hydration.
  15038. var hydrationParentFiber = null;
  15039. var nextHydratableInstance = null;
  15040. var isHydrating = false;
  15041. function enterHydrationState(fiber) {
  15042. if (!supportsHydration) {
  15043. return false;
  15044. }
  15045. var parentInstance = fiber.stateNode.containerInfo;
  15046. nextHydratableInstance = getFirstHydratableChild(parentInstance);
  15047. hydrationParentFiber = fiber;
  15048. isHydrating = true;
  15049. return true;
  15050. }
  15051. function reenterHydrationStateFromDehydratedSuspenseInstance(fiber) {
  15052. if (!supportsHydration) {
  15053. return false;
  15054. }
  15055. var suspenseInstance = fiber.stateNode;
  15056. nextHydratableInstance = getNextHydratableSibling(suspenseInstance);
  15057. popToNextHostParent(fiber);
  15058. isHydrating = true;
  15059. return true;
  15060. }
  15061. function deleteHydratableInstance(returnFiber, instance) {
  15062. {
  15063. switch (returnFiber.tag) {
  15064. case HostRoot:
  15065. didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance);
  15066. break;
  15067. case HostComponent:
  15068. didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance);
  15069. break;
  15070. }
  15071. }
  15072. var childToDelete = createFiberFromHostInstanceForDeletion();
  15073. childToDelete.stateNode = instance;
  15074. childToDelete.return = returnFiber;
  15075. childToDelete.effectTag = Deletion;
  15076. // This might seem like it belongs on progressedFirstDeletion. However,
  15077. // these children are not part of the reconciliation list of children.
  15078. // Even if we abort and rereconcile the children, that will try to hydrate
  15079. // again and the nodes are still in the host tree so these will be
  15080. // recreated.
  15081. if (returnFiber.lastEffect !== null) {
  15082. returnFiber.lastEffect.nextEffect = childToDelete;
  15083. returnFiber.lastEffect = childToDelete;
  15084. } else {
  15085. returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
  15086. }
  15087. }
  15088. function insertNonHydratedInstance(returnFiber, fiber) {
  15089. fiber.effectTag |= Placement;
  15090. {
  15091. switch (returnFiber.tag) {
  15092. case HostRoot:
  15093. {
  15094. var parentContainer = returnFiber.stateNode.containerInfo;
  15095. switch (fiber.tag) {
  15096. case HostComponent:
  15097. var type = fiber.type;
  15098. var props = fiber.pendingProps;
  15099. didNotFindHydratableContainerInstance(parentContainer, type, props);
  15100. break;
  15101. case HostText:
  15102. var text = fiber.pendingProps;
  15103. didNotFindHydratableContainerTextInstance(parentContainer, text);
  15104. break;
  15105. case SuspenseComponent:
  15106. break;
  15107. }
  15108. break;
  15109. }
  15110. case HostComponent:
  15111. {
  15112. var parentType = returnFiber.type;
  15113. var parentProps = returnFiber.memoizedProps;
  15114. var parentInstance = returnFiber.stateNode;
  15115. switch (fiber.tag) {
  15116. case HostComponent:
  15117. var _type = fiber.type;
  15118. var _props = fiber.pendingProps;
  15119. didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type, _props);
  15120. break;
  15121. case HostText:
  15122. var _text = fiber.pendingProps;
  15123. didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text);
  15124. break;
  15125. case SuspenseComponent:
  15126. didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance);
  15127. break;
  15128. }
  15129. break;
  15130. }
  15131. default:
  15132. return;
  15133. }
  15134. }
  15135. }
  15136. function tryHydrate(fiber, nextInstance) {
  15137. switch (fiber.tag) {
  15138. case HostComponent:
  15139. {
  15140. var type = fiber.type;
  15141. var props = fiber.pendingProps;
  15142. var instance = canHydrateInstance(nextInstance, type, props);
  15143. if (instance !== null) {
  15144. fiber.stateNode = instance;
  15145. return true;
  15146. }
  15147. return false;
  15148. }
  15149. case HostText:
  15150. {
  15151. var text = fiber.pendingProps;
  15152. var textInstance = canHydrateTextInstance(nextInstance, text);
  15153. if (textInstance !== null) {
  15154. fiber.stateNode = textInstance;
  15155. return true;
  15156. }
  15157. return false;
  15158. }
  15159. case SuspenseComponent:
  15160. {
  15161. if (enableSuspenseServerRenderer) {
  15162. var suspenseInstance = canHydrateSuspenseInstance(nextInstance);
  15163. if (suspenseInstance !== null) {
  15164. // Downgrade the tag to a dehydrated component until we've hydrated it.
  15165. fiber.tag = DehydratedSuspenseComponent;
  15166. fiber.stateNode = suspenseInstance;
  15167. return true;
  15168. }
  15169. }
  15170. return false;
  15171. }
  15172. default:
  15173. return false;
  15174. }
  15175. }
  15176. function tryToClaimNextHydratableInstance(fiber) {
  15177. if (!isHydrating) {
  15178. return;
  15179. }
  15180. var nextInstance = nextHydratableInstance;
  15181. if (!nextInstance) {
  15182. // Nothing to hydrate. Make it an insertion.
  15183. insertNonHydratedInstance(hydrationParentFiber, fiber);
  15184. isHydrating = false;
  15185. hydrationParentFiber = fiber;
  15186. return;
  15187. }
  15188. var firstAttemptedInstance = nextInstance;
  15189. if (!tryHydrate(fiber, nextInstance)) {
  15190. // If we can't hydrate this instance let's try the next one.
  15191. // We use this as a heuristic. It's based on intuition and not data so it
  15192. // might be flawed or unnecessary.
  15193. nextInstance = getNextHydratableSibling(firstAttemptedInstance);
  15194. if (!nextInstance || !tryHydrate(fiber, nextInstance)) {
  15195. // Nothing to hydrate. Make it an insertion.
  15196. insertNonHydratedInstance(hydrationParentFiber, fiber);
  15197. isHydrating = false;
  15198. hydrationParentFiber = fiber;
  15199. return;
  15200. }
  15201. // We matched the next one, we'll now assume that the first one was
  15202. // superfluous and we'll delete it. Since we can't eagerly delete it
  15203. // we'll have to schedule a deletion. To do that, this node needs a dummy
  15204. // fiber associated with it.
  15205. deleteHydratableInstance(hydrationParentFiber, firstAttemptedInstance);
  15206. }
  15207. hydrationParentFiber = fiber;
  15208. nextHydratableInstance = getFirstHydratableChild(nextInstance);
  15209. }
  15210. function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) {
  15211. if (!supportsHydration) {
  15212. (function () {
  15213. {
  15214. {
  15215. throw ReactError(Error('Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.'));
  15216. }
  15217. }
  15218. })();
  15219. }
  15220. var instance = fiber.stateNode;
  15221. var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber);
  15222. // TODO: Type this specific to this type of component.
  15223. fiber.updateQueue = updatePayload;
  15224. // If the update payload indicates that there is a change or if there
  15225. // is a new ref we mark this as an update.
  15226. if (updatePayload !== null) {
  15227. return true;
  15228. }
  15229. return false;
  15230. }
  15231. function prepareToHydrateHostTextInstance(fiber) {
  15232. if (!supportsHydration) {
  15233. (function () {
  15234. {
  15235. {
  15236. throw ReactError(Error('Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.'));
  15237. }
  15238. }
  15239. })();
  15240. }
  15241. var textInstance = fiber.stateNode;
  15242. var textContent = fiber.memoizedProps;
  15243. var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber);
  15244. {
  15245. if (shouldUpdate) {
  15246. // We assume that prepareToHydrateHostTextInstance is called in a context where the
  15247. // hydration parent is the parent host component of this host text.
  15248. var returnFiber = hydrationParentFiber;
  15249. if (returnFiber !== null) {
  15250. switch (returnFiber.tag) {
  15251. case HostRoot:
  15252. {
  15253. var parentContainer = returnFiber.stateNode.containerInfo;
  15254. didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent);
  15255. break;
  15256. }
  15257. case HostComponent:
  15258. {
  15259. var parentType = returnFiber.type;
  15260. var parentProps = returnFiber.memoizedProps;
  15261. var parentInstance = returnFiber.stateNode;
  15262. didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent);
  15263. break;
  15264. }
  15265. }
  15266. }
  15267. }
  15268. }
  15269. return shouldUpdate;
  15270. }
  15271. function skipPastDehydratedSuspenseInstance(fiber) {
  15272. if (!supportsHydration) {
  15273. (function () {
  15274. {
  15275. {
  15276. throw ReactError(Error('Expected skipPastDehydratedSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue.'));
  15277. }
  15278. }
  15279. })();
  15280. }
  15281. var suspenseInstance = fiber.stateNode;
  15282. (function () {
  15283. if (!suspenseInstance) {
  15284. {
  15285. throw ReactError(Error('Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue.'));
  15286. }
  15287. }
  15288. })();
  15289. nextHydratableInstance = getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
  15290. }
  15291. function popToNextHostParent(fiber) {
  15292. var parent = fiber.return;
  15293. while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== DehydratedSuspenseComponent) {
  15294. parent = parent.return;
  15295. }
  15296. hydrationParentFiber = parent;
  15297. }
  15298. function popHydrationState(fiber) {
  15299. if (!supportsHydration) {
  15300. return false;
  15301. }
  15302. if (fiber !== hydrationParentFiber) {
  15303. // We're deeper than the current hydration context, inside an inserted
  15304. // tree.
  15305. return false;
  15306. }
  15307. if (!isHydrating) {
  15308. // If we're not currently hydrating but we're in a hydration context, then
  15309. // we were an insertion and now need to pop up reenter hydration of our
  15310. // siblings.
  15311. popToNextHostParent(fiber);
  15312. isHydrating = true;
  15313. return false;
  15314. }
  15315. var type = fiber.type;
  15316. // If we have any remaining hydratable nodes, we need to delete them now.
  15317. // We only do this deeper than head and body since they tend to have random
  15318. // other nodes in them. We also ignore components with pure text content in
  15319. // side of them.
  15320. // TODO: Better heuristic.
  15321. if (fiber.tag !== HostComponent || type !== 'head' && type !== 'body' && !shouldSetTextContent(type, fiber.memoizedProps)) {
  15322. var nextInstance = nextHydratableInstance;
  15323. while (nextInstance) {
  15324. deleteHydratableInstance(fiber, nextInstance);
  15325. nextInstance = getNextHydratableSibling(nextInstance);
  15326. }
  15327. }
  15328. popToNextHostParent(fiber);
  15329. nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null;
  15330. return true;
  15331. }
  15332. function resetHydrationState() {
  15333. if (!supportsHydration) {
  15334. return;
  15335. }
  15336. hydrationParentFiber = null;
  15337. nextHydratableInstance = null;
  15338. isHydrating = false;
  15339. }
  15340. var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner;
  15341. var didReceiveUpdate = false;
  15342. var didWarnAboutBadClass = void 0;
  15343. var didWarnAboutModulePatternComponent = void 0;
  15344. var didWarnAboutContextTypeOnFunctionComponent = void 0;
  15345. var didWarnAboutGetDerivedStateOnFunctionComponent = void 0;
  15346. var didWarnAboutFunctionRefs = void 0;
  15347. var didWarnAboutReassigningProps = void 0;
  15348. var didWarnAboutMaxDuration = void 0;
  15349. var didWarnAboutRevealOrder = void 0;
  15350. var didWarnAboutTailOptions = void 0;
  15351. var didWarnAboutDefaultPropsOnFunctionComponent = void 0;
  15352. {
  15353. didWarnAboutBadClass = {};
  15354. didWarnAboutModulePatternComponent = {};
  15355. didWarnAboutContextTypeOnFunctionComponent = {};
  15356. didWarnAboutGetDerivedStateOnFunctionComponent = {};
  15357. didWarnAboutFunctionRefs = {};
  15358. didWarnAboutReassigningProps = false;
  15359. didWarnAboutMaxDuration = false;
  15360. didWarnAboutRevealOrder = {};
  15361. didWarnAboutTailOptions = {};
  15362. didWarnAboutDefaultPropsOnFunctionComponent = {};
  15363. }
  15364. function reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime) {
  15365. if (current$$1 === null) {
  15366. // If this is a fresh new component that hasn't been rendered yet, we
  15367. // won't update its child set by applying minimal side-effects. Instead,
  15368. // we will add them all to the child before it gets rendered. That means
  15369. // we can optimize this reconciliation pass by not tracking side-effects.
  15370. workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  15371. } else {
  15372. // If the current child is the same as the work in progress, it means that
  15373. // we haven't yet started any work on these children. Therefore, we use
  15374. // the clone algorithm to create a copy of all the current children.
  15375. // If we had any progressed work already, that is invalid at this point so
  15376. // let's throw it out.
  15377. workInProgress.child = reconcileChildFibers(workInProgress, current$$1.child, nextChildren, renderExpirationTime);
  15378. }
  15379. }
  15380. function forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildren, renderExpirationTime) {
  15381. // This function is fork of reconcileChildren. It's used in cases where we
  15382. // want to reconcile without matching against the existing set. This has the
  15383. // effect of all current children being unmounted; even if the type and key
  15384. // are the same, the old child is unmounted and a new child is created.
  15385. //
  15386. // To do this, we're going to go through the reconcile algorithm twice. In
  15387. // the first pass, we schedule a deletion for all the current children by
  15388. // passing null.
  15389. workInProgress.child = reconcileChildFibers(workInProgress, current$$1.child, null, renderExpirationTime);
  15390. // In the second pass, we mount the new children. The trick here is that we
  15391. // pass null in place of where we usually pass the current child set. This has
  15392. // the effect of remounting all children regardless of whether their their
  15393. // identity matches.
  15394. workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  15395. }
  15396. function updateForwardRef(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
  15397. // TODO: current can be non-null here even if the component
  15398. // hasn't yet mounted. This happens after the first render suspends.
  15399. // We'll need to figure out if this is fine or can cause issues.
  15400. {
  15401. if (workInProgress.type !== workInProgress.elementType) {
  15402. // Lazy component props can't be validated in createElement
  15403. // because they're only guaranteed to be resolved here.
  15404. var innerPropTypes = Component.propTypes;
  15405. if (innerPropTypes) {
  15406. checkPropTypes(innerPropTypes, nextProps, // Resolved props
  15407. 'prop', getComponentName(Component), getCurrentFiberStackInDev);
  15408. }
  15409. }
  15410. }
  15411. var render = Component.render;
  15412. var ref = workInProgress.ref;
  15413. // The rest is a fork of updateFunctionComponent
  15414. var nextChildren = void 0;
  15415. prepareToReadContext(workInProgress, renderExpirationTime);
  15416. {
  15417. ReactCurrentOwner$3.current = workInProgress;
  15418. setCurrentPhase('render');
  15419. nextChildren = renderWithHooks(current$$1, workInProgress, render, nextProps, ref, renderExpirationTime);
  15420. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  15421. // Only double-render components with Hooks
  15422. if (workInProgress.memoizedState !== null) {
  15423. nextChildren = renderWithHooks(current$$1, workInProgress, render, nextProps, ref, renderExpirationTime);
  15424. }
  15425. }
  15426. setCurrentPhase(null);
  15427. }
  15428. if (current$$1 !== null && !didReceiveUpdate) {
  15429. bailoutHooks(current$$1, workInProgress, renderExpirationTime);
  15430. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  15431. }
  15432. // React DevTools reads this flag.
  15433. workInProgress.effectTag |= PerformedWork;
  15434. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  15435. return workInProgress.child;
  15436. }
  15437. function updateMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
  15438. if (current$$1 === null) {
  15439. var type = Component.type;
  15440. if (isSimpleFunctionComponent(type) && Component.compare === null &&
  15441. // SimpleMemoComponent codepath doesn't resolve outer props either.
  15442. Component.defaultProps === undefined) {
  15443. var resolvedType = type;
  15444. {
  15445. resolvedType = resolveFunctionForHotReloading(type);
  15446. }
  15447. // If this is a plain function component without default props,
  15448. // and with only the default shallow comparison, we upgrade it
  15449. // to a SimpleMemoComponent to allow fast path updates.
  15450. workInProgress.tag = SimpleMemoComponent;
  15451. workInProgress.type = resolvedType;
  15452. {
  15453. validateFunctionComponentInDev(workInProgress, type);
  15454. }
  15455. return updateSimpleMemoComponent(current$$1, workInProgress, resolvedType, nextProps, updateExpirationTime, renderExpirationTime);
  15456. }
  15457. {
  15458. var innerPropTypes = type.propTypes;
  15459. if (innerPropTypes) {
  15460. // Inner memo component props aren't currently validated in createElement.
  15461. // We could move it there, but we'd still need this for lazy code path.
  15462. checkPropTypes(innerPropTypes, nextProps, // Resolved props
  15463. 'prop', getComponentName(type), getCurrentFiberStackInDev);
  15464. }
  15465. }
  15466. var child = createFiberFromTypeAndProps(Component.type, null, nextProps, null, workInProgress.mode, renderExpirationTime);
  15467. child.ref = workInProgress.ref;
  15468. child.return = workInProgress;
  15469. workInProgress.child = child;
  15470. return child;
  15471. }
  15472. {
  15473. var _type = Component.type;
  15474. var _innerPropTypes = _type.propTypes;
  15475. if (_innerPropTypes) {
  15476. // Inner memo component props aren't currently validated in createElement.
  15477. // We could move it there, but we'd still need this for lazy code path.
  15478. checkPropTypes(_innerPropTypes, nextProps, // Resolved props
  15479. 'prop', getComponentName(_type), getCurrentFiberStackInDev);
  15480. }
  15481. }
  15482. var currentChild = current$$1.child; // This is always exactly one child
  15483. if (updateExpirationTime < renderExpirationTime) {
  15484. // This will be the props with resolved defaultProps,
  15485. // unlike current.memoizedProps which will be the unresolved ones.
  15486. var prevProps = currentChild.memoizedProps;
  15487. // Default to shallow comparison
  15488. var compare = Component.compare;
  15489. compare = compare !== null ? compare : shallowEqual;
  15490. if (compare(prevProps, nextProps) && current$$1.ref === workInProgress.ref) {
  15491. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  15492. }
  15493. }
  15494. // React DevTools reads this flag.
  15495. workInProgress.effectTag |= PerformedWork;
  15496. var newChild = createWorkInProgress(currentChild, nextProps, renderExpirationTime);
  15497. newChild.ref = workInProgress.ref;
  15498. newChild.return = workInProgress;
  15499. workInProgress.child = newChild;
  15500. return newChild;
  15501. }
  15502. function updateSimpleMemoComponent(current$$1, workInProgress, Component, nextProps, updateExpirationTime, renderExpirationTime) {
  15503. // TODO: current can be non-null here even if the component
  15504. // hasn't yet mounted. This happens when the inner render suspends.
  15505. // We'll need to figure out if this is fine or can cause issues.
  15506. {
  15507. if (workInProgress.type !== workInProgress.elementType) {
  15508. // Lazy component props can't be validated in createElement
  15509. // because they're only guaranteed to be resolved here.
  15510. var outerMemoType = workInProgress.elementType;
  15511. if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
  15512. // We warn when you define propTypes on lazy()
  15513. // so let's just skip over it to find memo() outer wrapper.
  15514. // Inner props for memo are validated later.
  15515. outerMemoType = refineResolvedLazyComponent(outerMemoType);
  15516. }
  15517. var outerPropTypes = outerMemoType && outerMemoType.propTypes;
  15518. if (outerPropTypes) {
  15519. checkPropTypes(outerPropTypes, nextProps, // Resolved (SimpleMemoComponent has no defaultProps)
  15520. 'prop', getComponentName(outerMemoType), getCurrentFiberStackInDev);
  15521. }
  15522. // Inner propTypes will be validated in the function component path.
  15523. }
  15524. }
  15525. if (current$$1 !== null) {
  15526. var prevProps = current$$1.memoizedProps;
  15527. if (shallowEqual(prevProps, nextProps) && current$$1.ref === workInProgress.ref && (
  15528. // Prevent bailout if the implementation changed due to hot reload:
  15529. workInProgress.type === current$$1.type)) {
  15530. didReceiveUpdate = false;
  15531. if (updateExpirationTime < renderExpirationTime) {
  15532. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  15533. }
  15534. }
  15535. }
  15536. return updateFunctionComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime);
  15537. }
  15538. function updateFragment(current$$1, workInProgress, renderExpirationTime) {
  15539. var nextChildren = workInProgress.pendingProps;
  15540. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  15541. return workInProgress.child;
  15542. }
  15543. function updateMode(current$$1, workInProgress, renderExpirationTime) {
  15544. var nextChildren = workInProgress.pendingProps.children;
  15545. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  15546. return workInProgress.child;
  15547. }
  15548. function updateProfiler(current$$1, workInProgress, renderExpirationTime) {
  15549. if (enableProfilerTimer) {
  15550. workInProgress.effectTag |= Update;
  15551. }
  15552. var nextProps = workInProgress.pendingProps;
  15553. var nextChildren = nextProps.children;
  15554. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  15555. return workInProgress.child;
  15556. }
  15557. function markRef(current$$1, workInProgress) {
  15558. var ref = workInProgress.ref;
  15559. if (current$$1 === null && ref !== null || current$$1 !== null && current$$1.ref !== ref) {
  15560. // Schedule a Ref effect
  15561. workInProgress.effectTag |= Ref;
  15562. }
  15563. }
  15564. function updateFunctionComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
  15565. {
  15566. if (workInProgress.type !== workInProgress.elementType) {
  15567. // Lazy component props can't be validated in createElement
  15568. // because they're only guaranteed to be resolved here.
  15569. var innerPropTypes = Component.propTypes;
  15570. if (innerPropTypes) {
  15571. checkPropTypes(innerPropTypes, nextProps, // Resolved props
  15572. 'prop', getComponentName(Component), getCurrentFiberStackInDev);
  15573. }
  15574. }
  15575. }
  15576. var context = void 0;
  15577. if (!disableLegacyContext) {
  15578. var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
  15579. context = getMaskedContext(workInProgress, unmaskedContext);
  15580. }
  15581. var nextChildren = void 0;
  15582. prepareToReadContext(workInProgress, renderExpirationTime);
  15583. {
  15584. ReactCurrentOwner$3.current = workInProgress;
  15585. setCurrentPhase('render');
  15586. nextChildren = renderWithHooks(current$$1, workInProgress, Component, nextProps, context, renderExpirationTime);
  15587. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  15588. // Only double-render components with Hooks
  15589. if (workInProgress.memoizedState !== null) {
  15590. nextChildren = renderWithHooks(current$$1, workInProgress, Component, nextProps, context, renderExpirationTime);
  15591. }
  15592. }
  15593. setCurrentPhase(null);
  15594. }
  15595. if (current$$1 !== null && !didReceiveUpdate) {
  15596. bailoutHooks(current$$1, workInProgress, renderExpirationTime);
  15597. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  15598. }
  15599. // React DevTools reads this flag.
  15600. workInProgress.effectTag |= PerformedWork;
  15601. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  15602. return workInProgress.child;
  15603. }
  15604. function updateClassComponent(current$$1, workInProgress, Component, nextProps, renderExpirationTime) {
  15605. {
  15606. if (workInProgress.type !== workInProgress.elementType) {
  15607. // Lazy component props can't be validated in createElement
  15608. // because they're only guaranteed to be resolved here.
  15609. var innerPropTypes = Component.propTypes;
  15610. if (innerPropTypes) {
  15611. checkPropTypes(innerPropTypes, nextProps, // Resolved props
  15612. 'prop', getComponentName(Component), getCurrentFiberStackInDev);
  15613. }
  15614. }
  15615. }
  15616. // Push context providers early to prevent context stack mismatches.
  15617. // During mounting we don't know the child context yet as the instance doesn't exist.
  15618. // We will invalidate the child context in finishClassComponent() right after rendering.
  15619. var hasContext = void 0;
  15620. if (isContextProvider(Component)) {
  15621. hasContext = true;
  15622. pushContextProvider(workInProgress);
  15623. } else {
  15624. hasContext = false;
  15625. }
  15626. prepareToReadContext(workInProgress, renderExpirationTime);
  15627. var instance = workInProgress.stateNode;
  15628. var shouldUpdate = void 0;
  15629. if (instance === null) {
  15630. if (current$$1 !== null) {
  15631. // An class component without an instance only mounts if it suspended
  15632. // inside a non- concurrent tree, in an inconsistent state. We want to
  15633. // tree it like a new mount, even though an empty version of it already
  15634. // committed. Disconnect the alternate pointers.
  15635. current$$1.alternate = null;
  15636. workInProgress.alternate = null;
  15637. // Since this is conceptually a new fiber, schedule a Placement effect
  15638. workInProgress.effectTag |= Placement;
  15639. }
  15640. // In the initial pass we might need to construct the instance.
  15641. constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  15642. mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  15643. shouldUpdate = true;
  15644. } else if (current$$1 === null) {
  15645. // In a resume, we'll already have an instance we can reuse.
  15646. shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  15647. } else {
  15648. shouldUpdate = updateClassInstance(current$$1, workInProgress, Component, nextProps, renderExpirationTime);
  15649. }
  15650. var nextUnitOfWork = finishClassComponent(current$$1, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime);
  15651. {
  15652. var inst = workInProgress.stateNode;
  15653. if (inst.props !== nextProps) {
  15654. !didWarnAboutReassigningProps ? warning$1(false, 'It looks like %s is reassigning its own `this.props` while rendering. ' + 'This is not supported and can lead to confusing bugs.', getComponentName(workInProgress.type) || 'a component') : void 0;
  15655. didWarnAboutReassigningProps = true;
  15656. }
  15657. }
  15658. return nextUnitOfWork;
  15659. }
  15660. function finishClassComponent(current$$1, workInProgress, Component, shouldUpdate, hasContext, renderExpirationTime) {
  15661. // Refs should update even if shouldComponentUpdate returns false
  15662. markRef(current$$1, workInProgress);
  15663. var didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect;
  15664. if (!shouldUpdate && !didCaptureError) {
  15665. // Context providers should defer to sCU for rendering
  15666. if (hasContext) {
  15667. invalidateContextProvider(workInProgress, Component, false);
  15668. }
  15669. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  15670. }
  15671. var instance = workInProgress.stateNode;
  15672. // Rerender
  15673. ReactCurrentOwner$3.current = workInProgress;
  15674. var nextChildren = void 0;
  15675. if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') {
  15676. // If we captured an error, but getDerivedStateFrom catch is not defined,
  15677. // unmount all the children. componentDidCatch will schedule an update to
  15678. // re-render a fallback. This is temporary until we migrate everyone to
  15679. // the new API.
  15680. // TODO: Warn in a future release.
  15681. nextChildren = null;
  15682. if (enableProfilerTimer) {
  15683. stopProfilerTimerIfRunning(workInProgress);
  15684. }
  15685. } else {
  15686. {
  15687. setCurrentPhase('render');
  15688. nextChildren = instance.render();
  15689. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  15690. instance.render();
  15691. }
  15692. setCurrentPhase(null);
  15693. }
  15694. }
  15695. // React DevTools reads this flag.
  15696. workInProgress.effectTag |= PerformedWork;
  15697. if (current$$1 !== null && didCaptureError) {
  15698. // If we're recovering from an error, reconcile without reusing any of
  15699. // the existing children. Conceptually, the normal children and the children
  15700. // that are shown on error are two different sets, so we shouldn't reuse
  15701. // normal children even if their identities match.
  15702. forceUnmountCurrentAndReconcile(current$$1, workInProgress, nextChildren, renderExpirationTime);
  15703. } else {
  15704. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  15705. }
  15706. // Memoize state using the values we just used to render.
  15707. // TODO: Restructure so we never read values from the instance.
  15708. workInProgress.memoizedState = instance.state;
  15709. // The context might have changed so we need to recalculate it.
  15710. if (hasContext) {
  15711. invalidateContextProvider(workInProgress, Component, true);
  15712. }
  15713. return workInProgress.child;
  15714. }
  15715. function pushHostRootContext(workInProgress) {
  15716. var root = workInProgress.stateNode;
  15717. if (root.pendingContext) {
  15718. pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context);
  15719. } else if (root.context) {
  15720. // Should always be set
  15721. pushTopLevelContextObject(workInProgress, root.context, false);
  15722. }
  15723. pushHostContainer(workInProgress, root.containerInfo);
  15724. }
  15725. function updateHostRoot(current$$1, workInProgress, renderExpirationTime) {
  15726. pushHostRootContext(workInProgress);
  15727. var updateQueue = workInProgress.updateQueue;
  15728. (function () {
  15729. if (!(updateQueue !== null)) {
  15730. {
  15731. throw ReactError(Error('If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue.'));
  15732. }
  15733. }
  15734. })();
  15735. var nextProps = workInProgress.pendingProps;
  15736. var prevState = workInProgress.memoizedState;
  15737. var prevChildren = prevState !== null ? prevState.element : null;
  15738. processUpdateQueue(workInProgress, updateQueue, nextProps, null, renderExpirationTime);
  15739. var nextState = workInProgress.memoizedState;
  15740. // Caution: React DevTools currently depends on this property
  15741. // being called "element".
  15742. var nextChildren = nextState.element;
  15743. if (nextChildren === prevChildren) {
  15744. // If the state is the same as before, that's a bailout because we had
  15745. // no work that expires at this time.
  15746. resetHydrationState();
  15747. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  15748. }
  15749. var root = workInProgress.stateNode;
  15750. if ((current$$1 === null || current$$1.child === null) && root.hydrate && enterHydrationState(workInProgress)) {
  15751. // If we don't have any current children this might be the first pass.
  15752. // We always try to hydrate. If this isn't a hydration pass there won't
  15753. // be any children to hydrate which is effectively the same thing as
  15754. // not hydrating.
  15755. // This is a bit of a hack. We track the host root as a placement to
  15756. // know that we're currently in a mounting state. That way isMounted
  15757. // works as expected. We must reset this before committing.
  15758. // TODO: Delete this when we delete isMounted and findDOMNode.
  15759. workInProgress.effectTag |= Placement;
  15760. // Ensure that children mount into this root without tracking
  15761. // side-effects. This ensures that we don't store Placement effects on
  15762. // nodes that will be hydrated.
  15763. workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  15764. } else {
  15765. // Otherwise reset hydration state in case we aborted and resumed another
  15766. // root.
  15767. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  15768. resetHydrationState();
  15769. }
  15770. return workInProgress.child;
  15771. }
  15772. function updateHostComponent(current$$1, workInProgress, renderExpirationTime) {
  15773. pushHostContext(workInProgress);
  15774. if (current$$1 === null) {
  15775. tryToClaimNextHydratableInstance(workInProgress);
  15776. }
  15777. var type = workInProgress.type;
  15778. var nextProps = workInProgress.pendingProps;
  15779. var prevProps = current$$1 !== null ? current$$1.memoizedProps : null;
  15780. var nextChildren = nextProps.children;
  15781. var isDirectTextChild = shouldSetTextContent(type, nextProps);
  15782. if (isDirectTextChild) {
  15783. // We special case a direct text child of a host node. This is a common
  15784. // case. We won't handle it as a reified child. We will instead handle
  15785. // this in the host environment that also have access to this prop. That
  15786. // avoids allocating another HostText fiber and traversing it.
  15787. nextChildren = null;
  15788. } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) {
  15789. // If we're switching from a direct text child to a normal child, or to
  15790. // empty, we need to schedule the text content to be reset.
  15791. workInProgress.effectTag |= ContentReset;
  15792. }
  15793. markRef(current$$1, workInProgress);
  15794. // Check the host config to see if the children are offscreen/hidden.
  15795. if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(type, nextProps)) {
  15796. if (enableSchedulerTracing) {
  15797. markSpawnedWork(Never);
  15798. }
  15799. // Schedule this fiber to re-render at offscreen priority. Then bailout.
  15800. workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
  15801. return null;
  15802. }
  15803. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  15804. return workInProgress.child;
  15805. }
  15806. function updateHostText(current$$1, workInProgress) {
  15807. if (current$$1 === null) {
  15808. tryToClaimNextHydratableInstance(workInProgress);
  15809. }
  15810. // Nothing to do here. This is terminal. We'll do the completion step
  15811. // immediately after.
  15812. return null;
  15813. }
  15814. function mountLazyComponent(_current, workInProgress, elementType, updateExpirationTime, renderExpirationTime) {
  15815. if (_current !== null) {
  15816. // An lazy component only mounts if it suspended inside a non-
  15817. // concurrent tree, in an inconsistent state. We want to treat it like
  15818. // a new mount, even though an empty version of it already committed.
  15819. // Disconnect the alternate pointers.
  15820. _current.alternate = null;
  15821. workInProgress.alternate = null;
  15822. // Since this is conceptually a new fiber, schedule a Placement effect
  15823. workInProgress.effectTag |= Placement;
  15824. }
  15825. var props = workInProgress.pendingProps;
  15826. // We can't start a User Timing measurement with correct label yet.
  15827. // Cancel and resume right after we know the tag.
  15828. cancelWorkTimer(workInProgress);
  15829. var Component = readLazyComponentType(elementType);
  15830. // Store the unwrapped component in the type.
  15831. workInProgress.type = Component;
  15832. var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component);
  15833. startWorkTimer(workInProgress);
  15834. var resolvedProps = resolveDefaultProps(Component, props);
  15835. var child = void 0;
  15836. switch (resolvedTag) {
  15837. case FunctionComponent:
  15838. {
  15839. {
  15840. validateFunctionComponentInDev(workInProgress, Component);
  15841. workInProgress.type = Component = resolveFunctionForHotReloading(Component);
  15842. }
  15843. child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
  15844. break;
  15845. }
  15846. case ClassComponent:
  15847. {
  15848. {
  15849. workInProgress.type = Component = resolveClassForHotReloading(Component);
  15850. }
  15851. child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderExpirationTime);
  15852. break;
  15853. }
  15854. case ForwardRef:
  15855. {
  15856. {
  15857. workInProgress.type = Component = resolveForwardRefForHotReloading(Component);
  15858. }
  15859. child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderExpirationTime);
  15860. break;
  15861. }
  15862. case MemoComponent:
  15863. {
  15864. {
  15865. if (workInProgress.type !== workInProgress.elementType) {
  15866. var outerPropTypes = Component.propTypes;
  15867. if (outerPropTypes) {
  15868. checkPropTypes(outerPropTypes, resolvedProps, // Resolved for outer only
  15869. 'prop', getComponentName(Component), getCurrentFiberStackInDev);
  15870. }
  15871. }
  15872. }
  15873. child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too
  15874. updateExpirationTime, renderExpirationTime);
  15875. break;
  15876. }
  15877. default:
  15878. {
  15879. var hint = '';
  15880. {
  15881. if (Component !== null && typeof Component === 'object' && Component.$$typeof === REACT_LAZY_TYPE) {
  15882. hint = ' Did you wrap a component in React.lazy() more than once?';
  15883. }
  15884. }
  15885. // This message intentionally doesn't mention ForwardRef or MemoComponent
  15886. // because the fact that it's a separate type of work is an
  15887. // implementation detail.
  15888. (function () {
  15889. {
  15890. {
  15891. throw ReactError(Error('Element type is invalid. Received a promise that resolves to: ' + Component + '. Lazy element type must resolve to a class or function.' + hint));
  15892. }
  15893. }
  15894. })();
  15895. }
  15896. }
  15897. return child;
  15898. }
  15899. function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderExpirationTime) {
  15900. if (_current !== null) {
  15901. // An incomplete component only mounts if it suspended inside a non-
  15902. // concurrent tree, in an inconsistent state. We want to treat it like
  15903. // a new mount, even though an empty version of it already committed.
  15904. // Disconnect the alternate pointers.
  15905. _current.alternate = null;
  15906. workInProgress.alternate = null;
  15907. // Since this is conceptually a new fiber, schedule a Placement effect
  15908. workInProgress.effectTag |= Placement;
  15909. }
  15910. // Promote the fiber to a class and try rendering again.
  15911. workInProgress.tag = ClassComponent;
  15912. // The rest of this function is a fork of `updateClassComponent`
  15913. // Push context providers early to prevent context stack mismatches.
  15914. // During mounting we don't know the child context yet as the instance doesn't exist.
  15915. // We will invalidate the child context in finishClassComponent() right after rendering.
  15916. var hasContext = void 0;
  15917. if (isContextProvider(Component)) {
  15918. hasContext = true;
  15919. pushContextProvider(workInProgress);
  15920. } else {
  15921. hasContext = false;
  15922. }
  15923. prepareToReadContext(workInProgress, renderExpirationTime);
  15924. constructClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  15925. mountClassInstance(workInProgress, Component, nextProps, renderExpirationTime);
  15926. return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
  15927. }
  15928. function mountIndeterminateComponent(_current, workInProgress, Component, renderExpirationTime) {
  15929. if (_current !== null) {
  15930. // An indeterminate component only mounts if it suspended inside a non-
  15931. // concurrent tree, in an inconsistent state. We want to treat it like
  15932. // a new mount, even though an empty version of it already committed.
  15933. // Disconnect the alternate pointers.
  15934. _current.alternate = null;
  15935. workInProgress.alternate = null;
  15936. // Since this is conceptually a new fiber, schedule a Placement effect
  15937. workInProgress.effectTag |= Placement;
  15938. }
  15939. var props = workInProgress.pendingProps;
  15940. var context = void 0;
  15941. if (!disableLegacyContext) {
  15942. var unmaskedContext = getUnmaskedContext(workInProgress, Component, false);
  15943. context = getMaskedContext(workInProgress, unmaskedContext);
  15944. }
  15945. prepareToReadContext(workInProgress, renderExpirationTime);
  15946. var value = void 0;
  15947. {
  15948. if (Component.prototype && typeof Component.prototype.render === 'function') {
  15949. var componentName = getComponentName(Component) || 'Unknown';
  15950. if (!didWarnAboutBadClass[componentName]) {
  15951. 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);
  15952. didWarnAboutBadClass[componentName] = true;
  15953. }
  15954. }
  15955. if (workInProgress.mode & StrictMode) {
  15956. ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
  15957. }
  15958. ReactCurrentOwner$3.current = workInProgress;
  15959. value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
  15960. }
  15961. // React DevTools reads this flag.
  15962. workInProgress.effectTag |= PerformedWork;
  15963. if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
  15964. {
  15965. var _componentName = getComponentName(Component) || 'Unknown';
  15966. if (!didWarnAboutModulePatternComponent[_componentName]) {
  15967. warningWithoutStack$1(false, 'The <%s /> component appears to be a function component that returns a class instance. ' + 'Change %s to a class that extends React.Component instead. ' + "If you can't use a class try assigning the prototype on the function as a workaround. " + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + 'cannot be called with `new` by React.', _componentName, _componentName, _componentName);
  15968. didWarnAboutModulePatternComponent[_componentName] = true;
  15969. }
  15970. }
  15971. // Proceed under the assumption that this is a class instance
  15972. workInProgress.tag = ClassComponent;
  15973. // Throw out any hooks that were used.
  15974. resetHooks();
  15975. // Push context providers early to prevent context stack mismatches.
  15976. // During mounting we don't know the child context yet as the instance doesn't exist.
  15977. // We will invalidate the child context in finishClassComponent() right after rendering.
  15978. var hasContext = false;
  15979. if (isContextProvider(Component)) {
  15980. hasContext = true;
  15981. pushContextProvider(workInProgress);
  15982. } else {
  15983. hasContext = false;
  15984. }
  15985. workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null;
  15986. var getDerivedStateFromProps = Component.getDerivedStateFromProps;
  15987. if (typeof getDerivedStateFromProps === 'function') {
  15988. applyDerivedStateFromProps(workInProgress, Component, getDerivedStateFromProps, props);
  15989. }
  15990. adoptClassInstance(workInProgress, value);
  15991. mountClassInstance(workInProgress, Component, props, renderExpirationTime);
  15992. return finishClassComponent(null, workInProgress, Component, true, hasContext, renderExpirationTime);
  15993. } else {
  15994. // Proceed under the assumption that this is a function component
  15995. workInProgress.tag = FunctionComponent;
  15996. {
  15997. if (disableLegacyContext && Component.contextTypes) {
  15998. warningWithoutStack$1(false, '%s uses the legacy contextTypes API which is no longer supported. ' + 'Use React.createContext() with React.useContext() instead.', getComponentName(Component) || 'Unknown');
  15999. }
  16000. if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
  16001. // Only double-render components with Hooks
  16002. if (workInProgress.memoizedState !== null) {
  16003. value = renderWithHooks(null, workInProgress, Component, props, context, renderExpirationTime);
  16004. }
  16005. }
  16006. }
  16007. reconcileChildren(null, workInProgress, value, renderExpirationTime);
  16008. {
  16009. validateFunctionComponentInDev(workInProgress, Component);
  16010. }
  16011. return workInProgress.child;
  16012. }
  16013. }
  16014. function validateFunctionComponentInDev(workInProgress, Component) {
  16015. if (Component) {
  16016. !!Component.childContextTypes ? warningWithoutStack$1(false, '%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component') : void 0;
  16017. }
  16018. if (workInProgress.ref !== null) {
  16019. var info = '';
  16020. var ownerName = getCurrentFiberOwnerNameInDevOrNull();
  16021. if (ownerName) {
  16022. info += '\n\nCheck the render method of `' + ownerName + '`.';
  16023. }
  16024. var warningKey = ownerName || workInProgress._debugID || '';
  16025. var debugSource = workInProgress._debugSource;
  16026. if (debugSource) {
  16027. warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
  16028. }
  16029. if (!didWarnAboutFunctionRefs[warningKey]) {
  16030. didWarnAboutFunctionRefs[warningKey] = true;
  16031. warning$1(false, 'Function components cannot be given refs. ' + 'Attempts to access this ref will fail. ' + 'Did you mean to use React.forwardRef()?%s', info);
  16032. }
  16033. }
  16034. if (warnAboutDefaultPropsOnFunctionComponents && Component.defaultProps !== undefined) {
  16035. var componentName = getComponentName(Component) || 'Unknown';
  16036. if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
  16037. warningWithoutStack$1(false, '%s: Support for defaultProps will be removed from function components ' + 'in a future major release. Use JavaScript default parameters instead.', componentName);
  16038. didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true;
  16039. }
  16040. }
  16041. if (typeof Component.getDerivedStateFromProps === 'function') {
  16042. var _componentName2 = getComponentName(Component) || 'Unknown';
  16043. if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) {
  16044. warningWithoutStack$1(false, '%s: Function components do not support getDerivedStateFromProps.', _componentName2);
  16045. didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true;
  16046. }
  16047. }
  16048. if (typeof Component.contextType === 'object' && Component.contextType !== null) {
  16049. var _componentName3 = getComponentName(Component) || 'Unknown';
  16050. if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) {
  16051. warningWithoutStack$1(false, '%s: Function components do not support contextType.', _componentName3);
  16052. didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true;
  16053. }
  16054. }
  16055. }
  16056. // TODO: This is now an empty object. Should we just make it a boolean?
  16057. var SUSPENDED_MARKER = {};
  16058. function shouldRemainOnFallback(suspenseContext, current$$1, workInProgress) {
  16059. // If the context is telling us that we should show a fallback, and we're not
  16060. // already showing content, then we should show the fallback instead.
  16061. return hasSuspenseContext(suspenseContext, ForceSuspenseFallback) && (current$$1 === null || current$$1.memoizedState !== null);
  16062. }
  16063. function updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime) {
  16064. var mode = workInProgress.mode;
  16065. var nextProps = workInProgress.pendingProps;
  16066. // This is used by DevTools to force a boundary to suspend.
  16067. {
  16068. if (shouldSuspend(workInProgress)) {
  16069. workInProgress.effectTag |= DidCapture;
  16070. }
  16071. }
  16072. var suspenseContext = suspenseStackCursor.current;
  16073. var nextState = null;
  16074. var nextDidTimeout = false;
  16075. if ((workInProgress.effectTag & DidCapture) !== NoEffect || shouldRemainOnFallback(suspenseContext, current$$1, workInProgress)) {
  16076. // Something in this boundary's subtree already suspended. Switch to
  16077. // rendering the fallback children.
  16078. nextState = SUSPENDED_MARKER;
  16079. nextDidTimeout = true;
  16080. workInProgress.effectTag &= ~DidCapture;
  16081. } else {
  16082. // Attempting the main content
  16083. if (current$$1 === null || current$$1.memoizedState !== null) {
  16084. // This is a new mount or this boundary is already showing a fallback state.
  16085. // Mark this subtree context as having at least one invisible parent that could
  16086. // handle the fallback state.
  16087. // Boundaries without fallbacks or should be avoided are not considered since
  16088. // they cannot handle preferred fallback states.
  16089. if (nextProps.fallback !== undefined && nextProps.unstable_avoidThisFallback !== true) {
  16090. suspenseContext = addSubtreeSuspenseContext(suspenseContext, InvisibleParentSuspenseContext);
  16091. }
  16092. }
  16093. }
  16094. suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
  16095. pushSuspenseContext(workInProgress, suspenseContext);
  16096. {
  16097. if ('maxDuration' in nextProps) {
  16098. if (!didWarnAboutMaxDuration) {
  16099. didWarnAboutMaxDuration = true;
  16100. warning$1(false, 'maxDuration has been removed from React. ' + 'Remove the maxDuration prop.');
  16101. }
  16102. }
  16103. }
  16104. // This next part is a bit confusing. If the children timeout, we switch to
  16105. // showing the fallback children in place of the "primary" children.
  16106. // However, we don't want to delete the primary children because then their
  16107. // state will be lost (both the React state and the host state, e.g.
  16108. // uncontrolled form inputs). Instead we keep them mounted and hide them.
  16109. // Both the fallback children AND the primary children are rendered at the
  16110. // same time. Once the primary children are un-suspended, we can delete
  16111. // the fallback children — don't need to preserve their state.
  16112. //
  16113. // The two sets of children are siblings in the host environment, but
  16114. // semantically, for purposes of reconciliation, they are two separate sets.
  16115. // So we store them using two fragment fibers.
  16116. //
  16117. // However, we want to avoid allocating extra fibers for every placeholder.
  16118. // They're only necessary when the children time out, because that's the
  16119. // only time when both sets are mounted.
  16120. //
  16121. // So, the extra fragment fibers are only used if the children time out.
  16122. // Otherwise, we render the primary children directly. This requires some
  16123. // custom reconciliation logic to preserve the state of the primary
  16124. // children. It's essentially a very basic form of re-parenting.
  16125. // `child` points to the child fiber. In the normal case, this is the first
  16126. // fiber of the primary children set. In the timed-out case, it's a
  16127. // a fragment fiber containing the primary children.
  16128. var child = void 0;
  16129. // `next` points to the next fiber React should render. In the normal case,
  16130. // it's the same as `child`: the first fiber of the primary children set.
  16131. // In the timed-out case, it's a fragment fiber containing the *fallback*
  16132. // children -- we skip over the primary children entirely.
  16133. var next = void 0;
  16134. if (current$$1 === null) {
  16135. if (enableSuspenseServerRenderer) {
  16136. // If we're currently hydrating, try to hydrate this boundary.
  16137. // But only if this has a fallback.
  16138. if (nextProps.fallback !== undefined) {
  16139. tryToClaimNextHydratableInstance(workInProgress);
  16140. // This could've changed the tag if this was a dehydrated suspense component.
  16141. if (workInProgress.tag === DehydratedSuspenseComponent) {
  16142. popSuspenseContext(workInProgress);
  16143. return updateDehydratedSuspenseComponent(null, workInProgress, renderExpirationTime);
  16144. }
  16145. }
  16146. }
  16147. // This is the initial mount. This branch is pretty simple because there's
  16148. // no previous state that needs to be preserved.
  16149. if (nextDidTimeout) {
  16150. // Mount separate fragments for primary and fallback children.
  16151. var nextFallbackChildren = nextProps.fallback;
  16152. var primaryChildFragment = createFiberFromFragment(null, mode, NoWork, null);
  16153. primaryChildFragment.return = workInProgress;
  16154. if ((workInProgress.mode & BatchedMode) === NoMode) {
  16155. // Outside of batched mode, we commit the effects from the
  16156. var progressedState = workInProgress.memoizedState;
  16157. var progressedPrimaryChild = progressedState !== null ? workInProgress.child.child : workInProgress.child;
  16158. primaryChildFragment.child = progressedPrimaryChild;
  16159. var progressedChild = progressedPrimaryChild;
  16160. while (progressedChild !== null) {
  16161. progressedChild.return = primaryChildFragment;
  16162. progressedChild = progressedChild.sibling;
  16163. }
  16164. }
  16165. var fallbackChildFragment = createFiberFromFragment(nextFallbackChildren, mode, renderExpirationTime, null);
  16166. fallbackChildFragment.return = workInProgress;
  16167. primaryChildFragment.sibling = fallbackChildFragment;
  16168. child = primaryChildFragment;
  16169. // Skip the primary children, and continue working on the
  16170. // fallback children.
  16171. next = fallbackChildFragment;
  16172. } else {
  16173. // Mount the primary children without an intermediate fragment fiber.
  16174. var nextPrimaryChildren = nextProps.children;
  16175. child = next = mountChildFibers(workInProgress, null, nextPrimaryChildren, renderExpirationTime);
  16176. }
  16177. } else {
  16178. // This is an update. This branch is more complicated because we need to
  16179. // ensure the state of the primary children is preserved.
  16180. var prevState = current$$1.memoizedState;
  16181. var prevDidTimeout = prevState !== null;
  16182. if (prevDidTimeout) {
  16183. // The current tree already timed out. That means each child set is
  16184. var currentPrimaryChildFragment = current$$1.child;
  16185. var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
  16186. if (nextDidTimeout) {
  16187. // Still timed out. Reuse the current primary children by cloning
  16188. // its fragment. We're going to skip over these entirely.
  16189. var _nextFallbackChildren = nextProps.fallback;
  16190. var _primaryChildFragment = createWorkInProgress(currentPrimaryChildFragment, currentPrimaryChildFragment.pendingProps, NoWork);
  16191. _primaryChildFragment.return = workInProgress;
  16192. if ((workInProgress.mode & BatchedMode) === NoMode) {
  16193. // Outside of batched mode, we commit the effects from the
  16194. var _progressedState = workInProgress.memoizedState;
  16195. var _progressedPrimaryChild = _progressedState !== null ? workInProgress.child.child : workInProgress.child;
  16196. if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) {
  16197. _primaryChildFragment.child = _progressedPrimaryChild;
  16198. var _progressedChild = _progressedPrimaryChild;
  16199. while (_progressedChild !== null) {
  16200. _progressedChild.return = _primaryChildFragment;
  16201. _progressedChild = _progressedChild.sibling;
  16202. }
  16203. }
  16204. }
  16205. // Because primaryChildFragment is a new fiber that we're inserting as the
  16206. // parent of a new tree, we need to set its treeBaseDuration.
  16207. if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
  16208. // treeBaseDuration is the sum of all the child tree base durations.
  16209. var treeBaseDuration = 0;
  16210. var hiddenChild = _primaryChildFragment.child;
  16211. while (hiddenChild !== null) {
  16212. treeBaseDuration += hiddenChild.treeBaseDuration;
  16213. hiddenChild = hiddenChild.sibling;
  16214. }
  16215. _primaryChildFragment.treeBaseDuration = treeBaseDuration;
  16216. }
  16217. // Clone the fallback child fragment, too. These we'll continue
  16218. // working on.
  16219. var _fallbackChildFragment = createWorkInProgress(currentFallbackChildFragment, _nextFallbackChildren, currentFallbackChildFragment.expirationTime);
  16220. _fallbackChildFragment.return = workInProgress;
  16221. _primaryChildFragment.sibling = _fallbackChildFragment;
  16222. child = _primaryChildFragment;
  16223. _primaryChildFragment.childExpirationTime = NoWork;
  16224. // Skip the primary children, and continue working on the
  16225. // fallback children.
  16226. next = _fallbackChildFragment;
  16227. } else {
  16228. // No longer suspended. Switch back to showing the primary children,
  16229. // and remove the intermediate fragment fiber.
  16230. var _nextPrimaryChildren = nextProps.children;
  16231. var currentPrimaryChild = currentPrimaryChildFragment.child;
  16232. var primaryChild = reconcileChildFibers(workInProgress, currentPrimaryChild, _nextPrimaryChildren, renderExpirationTime);
  16233. // If this render doesn't suspend, we need to delete the fallback
  16234. // children. Wait until the complete phase, after we've confirmed the
  16235. // fallback is no longer needed.
  16236. // TODO: Would it be better to store the fallback fragment on
  16237. // the stateNode?
  16238. // Continue rendering the children, like we normally do.
  16239. child = next = primaryChild;
  16240. }
  16241. } else {
  16242. // The current tree has not already timed out. That means the primary
  16243. // children are not wrapped in a fragment fiber.
  16244. var _currentPrimaryChild = current$$1.child;
  16245. if (nextDidTimeout) {
  16246. // Timed out. Wrap the children in a fragment fiber to keep them
  16247. // separate from the fallback children.
  16248. var _nextFallbackChildren2 = nextProps.fallback;
  16249. var _primaryChildFragment2 = createFiberFromFragment(
  16250. // It shouldn't matter what the pending props are because we aren't
  16251. // going to render this fragment.
  16252. null, mode, NoWork, null);
  16253. _primaryChildFragment2.return = workInProgress;
  16254. _primaryChildFragment2.child = _currentPrimaryChild;
  16255. if (_currentPrimaryChild !== null) {
  16256. _currentPrimaryChild.return = _primaryChildFragment2;
  16257. }
  16258. // Even though we're creating a new fiber, there are no new children,
  16259. // because we're reusing an already mounted tree. So we don't need to
  16260. // schedule a placement.
  16261. // primaryChildFragment.effectTag |= Placement;
  16262. if ((workInProgress.mode & BatchedMode) === NoMode) {
  16263. // Outside of batched mode, we commit the effects from the
  16264. var _progressedState2 = workInProgress.memoizedState;
  16265. var _progressedPrimaryChild2 = _progressedState2 !== null ? workInProgress.child.child : workInProgress.child;
  16266. _primaryChildFragment2.child = _progressedPrimaryChild2;
  16267. var _progressedChild2 = _progressedPrimaryChild2;
  16268. while (_progressedChild2 !== null) {
  16269. _progressedChild2.return = _primaryChildFragment2;
  16270. _progressedChild2 = _progressedChild2.sibling;
  16271. }
  16272. }
  16273. // Because primaryChildFragment is a new fiber that we're inserting as the
  16274. // parent of a new tree, we need to set its treeBaseDuration.
  16275. if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
  16276. // treeBaseDuration is the sum of all the child tree base durations.
  16277. var _treeBaseDuration = 0;
  16278. var _hiddenChild = _primaryChildFragment2.child;
  16279. while (_hiddenChild !== null) {
  16280. _treeBaseDuration += _hiddenChild.treeBaseDuration;
  16281. _hiddenChild = _hiddenChild.sibling;
  16282. }
  16283. _primaryChildFragment2.treeBaseDuration = _treeBaseDuration;
  16284. }
  16285. // Create a fragment from the fallback children, too.
  16286. var _fallbackChildFragment2 = createFiberFromFragment(_nextFallbackChildren2, mode, renderExpirationTime, null);
  16287. _fallbackChildFragment2.return = workInProgress;
  16288. _primaryChildFragment2.sibling = _fallbackChildFragment2;
  16289. _fallbackChildFragment2.effectTag |= Placement;
  16290. child = _primaryChildFragment2;
  16291. _primaryChildFragment2.childExpirationTime = NoWork;
  16292. // Skip the primary children, and continue working on the
  16293. // fallback children.
  16294. next = _fallbackChildFragment2;
  16295. } else {
  16296. // Still haven't timed out. Continue rendering the children, like we
  16297. // normally do.
  16298. var _nextPrimaryChildren2 = nextProps.children;
  16299. next = child = reconcileChildFibers(workInProgress, _currentPrimaryChild, _nextPrimaryChildren2, renderExpirationTime);
  16300. }
  16301. }
  16302. workInProgress.stateNode = current$$1.stateNode;
  16303. }
  16304. workInProgress.memoizedState = nextState;
  16305. workInProgress.child = child;
  16306. return next;
  16307. }
  16308. function retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime) {
  16309. // Detach from the current dehydrated boundary.
  16310. current$$1.alternate = null;
  16311. workInProgress.alternate = null;
  16312. // Insert a deletion in the effect list.
  16313. var returnFiber = workInProgress.return;
  16314. (function () {
  16315. if (!(returnFiber !== null)) {
  16316. {
  16317. throw ReactError(Error('Suspense boundaries are never on the root. This is probably a bug in React.'));
  16318. }
  16319. }
  16320. })();
  16321. var last = returnFiber.lastEffect;
  16322. if (last !== null) {
  16323. last.nextEffect = current$$1;
  16324. returnFiber.lastEffect = current$$1;
  16325. } else {
  16326. returnFiber.firstEffect = returnFiber.lastEffect = current$$1;
  16327. }
  16328. current$$1.nextEffect = null;
  16329. current$$1.effectTag = Deletion;
  16330. popSuspenseContext(workInProgress);
  16331. // Upgrade this work in progress to a real Suspense component.
  16332. workInProgress.tag = SuspenseComponent;
  16333. workInProgress.stateNode = null;
  16334. workInProgress.memoizedState = null;
  16335. // This is now an insertion.
  16336. workInProgress.effectTag |= Placement;
  16337. // Retry as a real Suspense component.
  16338. return updateSuspenseComponent(null, workInProgress, renderExpirationTime);
  16339. }
  16340. function updateDehydratedSuspenseComponent(current$$1, workInProgress, renderExpirationTime) {
  16341. pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
  16342. var suspenseInstance = workInProgress.stateNode;
  16343. if (current$$1 === null) {
  16344. // During the first pass, we'll bail out and not drill into the children.
  16345. // Instead, we'll leave the content in place and try to hydrate it later.
  16346. if (isSuspenseInstanceFallback(suspenseInstance)) {
  16347. // This is a client-only boundary. Since we won't get any content from the server
  16348. // for this, we need to schedule that at a higher priority based on when it would
  16349. // have timed out. In theory we could render it in this pass but it would have the
  16350. // wrong priority associated with it and will prevent hydration of parent path.
  16351. // Instead, we'll leave work left on it to render it in a separate commit.
  16352. // TODO This time should be the time at which the server rendered response that is
  16353. // a parent to this boundary was displayed. However, since we currently don't have
  16354. // a protocol to transfer that time, we'll just estimate it by using the current
  16355. // time. This will mean that Suspense timeouts are slightly shifted to later than
  16356. // they should be.
  16357. var serverDisplayTime = requestCurrentTime();
  16358. // Schedule a normal pri update to render this content.
  16359. workInProgress.expirationTime = computeAsyncExpiration(serverDisplayTime);
  16360. } else {
  16361. // We'll continue hydrating the rest at offscreen priority since we'll already
  16362. // be showing the right content coming from the server, it is no rush.
  16363. workInProgress.expirationTime = Never;
  16364. }
  16365. return null;
  16366. }
  16367. if ((workInProgress.effectTag & DidCapture) !== NoEffect) {
  16368. // Something suspended. Leave the existing children in place.
  16369. // TODO: In non-concurrent mode, should we commit the nodes we have hydrated so far?
  16370. workInProgress.child = null;
  16371. return null;
  16372. }
  16373. if (isSuspenseInstanceFallback(suspenseInstance)) {
  16374. // This boundary is in a permanent fallback state. In this case, we'll never
  16375. // get an update and we'll never be able to hydrate the final content. Let's just try the
  16376. // client side render instead.
  16377. return retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime);
  16378. }
  16379. // We use childExpirationTime to indicate that a child might depend on context, so if
  16380. // any context has changed, we need to treat is as if the input might have changed.
  16381. var hasContextChanged$$1 = current$$1.childExpirationTime >= renderExpirationTime;
  16382. if (didReceiveUpdate || hasContextChanged$$1) {
  16383. // This boundary has changed since the first render. This means that we are now unable to
  16384. // hydrate it. We might still be able to hydrate it using an earlier expiration time but
  16385. // during this render we can't. Instead, we're going to delete the whole subtree and
  16386. // instead inject a new real Suspense boundary to take its place, which may render content
  16387. // or fallback. The real Suspense boundary will suspend for a while so we have some time
  16388. // to ensure it can produce real content, but all state and pending events will be lost.
  16389. return retrySuspenseComponentWithoutHydrating(current$$1, workInProgress, renderExpirationTime);
  16390. } else if (isSuspenseInstancePending(suspenseInstance)) {
  16391. // This component is still pending more data from the server, so we can't hydrate its
  16392. // content. We treat it as if this component suspended itself. It might seem as if
  16393. // we could just try to render it client-side instead. However, this will perform a
  16394. // lot of unnecessary work and is unlikely to complete since it often will suspend
  16395. // on missing data anyway. Additionally, the server might be able to render more
  16396. // than we can on the client yet. In that case we'd end up with more fallback states
  16397. // on the client than if we just leave it alone. If the server times out or errors
  16398. // these should update this boundary to the permanent Fallback state instead.
  16399. // Mark it as having captured (i.e. suspended).
  16400. workInProgress.effectTag |= DidCapture;
  16401. // Leave the children in place. I.e. empty.
  16402. workInProgress.child = null;
  16403. // Register a callback to retry this boundary once the server has sent the result.
  16404. registerSuspenseInstanceRetry(suspenseInstance, retryTimedOutBoundary.bind(null, current$$1));
  16405. return null;
  16406. } else {
  16407. // This is the first attempt.
  16408. reenterHydrationStateFromDehydratedSuspenseInstance(workInProgress);
  16409. var nextProps = workInProgress.pendingProps;
  16410. var nextChildren = nextProps.children;
  16411. workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  16412. return workInProgress.child;
  16413. }
  16414. }
  16415. function propagateSuspenseContextChange(workInProgress, firstChild, renderExpirationTime) {
  16416. // Mark any Suspense boundaries with fallbacks as having work to do.
  16417. // If they were previously forced into fallbacks, they may now be able
  16418. // to unblock.
  16419. var node = firstChild;
  16420. while (node !== null) {
  16421. if (node.tag === SuspenseComponent) {
  16422. var state = node.memoizedState;
  16423. if (state !== null) {
  16424. if (node.expirationTime < renderExpirationTime) {
  16425. node.expirationTime = renderExpirationTime;
  16426. }
  16427. var alternate = node.alternate;
  16428. if (alternate !== null && alternate.expirationTime < renderExpirationTime) {
  16429. alternate.expirationTime = renderExpirationTime;
  16430. }
  16431. scheduleWorkOnParentPath(node.return, renderExpirationTime);
  16432. }
  16433. } else if (node.child !== null) {
  16434. node.child.return = node;
  16435. node = node.child;
  16436. continue;
  16437. }
  16438. if (node === workInProgress) {
  16439. return;
  16440. }
  16441. while (node.sibling === null) {
  16442. if (node.return === null || node.return === workInProgress) {
  16443. return;
  16444. }
  16445. node = node.return;
  16446. }
  16447. node.sibling.return = node.return;
  16448. node = node.sibling;
  16449. }
  16450. }
  16451. function findLastContentRow(firstChild) {
  16452. // This is going to find the last row among these children that is already
  16453. // showing content on the screen, as opposed to being in fallback state or
  16454. // new. If a row has multiple Suspense boundaries, any of them being in the
  16455. // fallback state, counts as the whole row being in a fallback state.
  16456. // Note that the "rows" will be workInProgress, but any nested children
  16457. // will still be current since we haven't rendered them yet. The mounted
  16458. // order may not be the same as the new order. We use the new order.
  16459. var row = firstChild;
  16460. var lastContentRow = null;
  16461. while (row !== null) {
  16462. var currentRow = row.alternate;
  16463. // New rows can't be content rows.
  16464. if (currentRow !== null && findFirstSuspended(currentRow) === null) {
  16465. lastContentRow = row;
  16466. }
  16467. row = row.sibling;
  16468. }
  16469. return lastContentRow;
  16470. }
  16471. function validateRevealOrder(revealOrder) {
  16472. {
  16473. if (revealOrder !== undefined && revealOrder !== 'forwards' && revealOrder !== 'backwards' && revealOrder !== 'together' && !didWarnAboutRevealOrder[revealOrder]) {
  16474. didWarnAboutRevealOrder[revealOrder] = true;
  16475. if (typeof revealOrder === 'string') {
  16476. switch (revealOrder.toLowerCase()) {
  16477. case 'together':
  16478. case 'forwards':
  16479. case 'backwards':
  16480. {
  16481. warning$1(false, '"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase());
  16482. break;
  16483. }
  16484. case 'forward':
  16485. case 'backward':
  16486. {
  16487. warning$1(false, '"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'React uses the -s suffix in the spelling. Use "%ss" instead.', revealOrder, revealOrder.toLowerCase());
  16488. break;
  16489. }
  16490. default:
  16491. warning$1(false, '"%s" is not a supported revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
  16492. break;
  16493. }
  16494. } else {
  16495. warning$1(false, '%s is not a supported value for revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
  16496. }
  16497. }
  16498. }
  16499. }
  16500. function validateTailOptions(tailMode, revealOrder) {
  16501. {
  16502. if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) {
  16503. if (tailMode !== 'collapsed' && tailMode !== 'hidden') {
  16504. didWarnAboutTailOptions[tailMode] = true;
  16505. warning$1(false, '"%s" is not a supported value for tail on <SuspenseList />. ' + 'Did you mean "collapsed" or "hidden"?', tailMode);
  16506. } else if (revealOrder !== 'forwards' && revealOrder !== 'backwards') {
  16507. didWarnAboutTailOptions[tailMode] = true;
  16508. warning$1(false, '<SuspenseList tail="%s" /> is only valid if revealOrder is ' + '"forwards" or "backwards". ' + 'Did you mean to specify revealOrder="forwards"?', tailMode);
  16509. }
  16510. }
  16511. }
  16512. }
  16513. function validateSuspenseListNestedChild(childSlot, index) {
  16514. {
  16515. var isArray = Array.isArray(childSlot);
  16516. var isIterable = !isArray && typeof getIteratorFn(childSlot) === 'function';
  16517. if (isArray || isIterable) {
  16518. var type = isArray ? 'array' : 'iterable';
  16519. warning$1(false, 'A nested %s was passed to row #%s in <SuspenseList />. Wrap it in ' + 'an additional SuspenseList to configure its revealOrder: ' + '<SuspenseList revealOrder=...> ... ' + '<SuspenseList revealOrder=...>{%s}</SuspenseList> ... ' + '</SuspenseList>', type, index, type);
  16520. return false;
  16521. }
  16522. }
  16523. return true;
  16524. }
  16525. function validateSuspenseListChildren(children, revealOrder) {
  16526. {
  16527. if ((revealOrder === 'forwards' || revealOrder === 'backwards') && children !== undefined && children !== null && children !== false) {
  16528. if (Array.isArray(children)) {
  16529. for (var i = 0; i < children.length; i++) {
  16530. if (!validateSuspenseListNestedChild(children[i], i)) {
  16531. return;
  16532. }
  16533. }
  16534. } else {
  16535. var iteratorFn = getIteratorFn(children);
  16536. if (typeof iteratorFn === 'function') {
  16537. var childrenIterator = iteratorFn.call(children);
  16538. if (childrenIterator) {
  16539. var step = childrenIterator.next();
  16540. var _i = 0;
  16541. for (; !step.done; step = childrenIterator.next()) {
  16542. if (!validateSuspenseListNestedChild(step.value, _i)) {
  16543. return;
  16544. }
  16545. _i++;
  16546. }
  16547. }
  16548. } else {
  16549. warning$1(false, 'A single row was passed to a <SuspenseList revealOrder="%s" />. ' + 'This is not useful since it needs multiple rows. ' + 'Did you mean to pass multiple children or an array?', revealOrder);
  16550. }
  16551. }
  16552. }
  16553. }
  16554. }
  16555. function initSuspenseListRenderState(workInProgress, isBackwards, tail, lastContentRow, tailMode) {
  16556. var renderState = workInProgress.memoizedState;
  16557. if (renderState === null) {
  16558. workInProgress.memoizedState = {
  16559. isBackwards: isBackwards,
  16560. rendering: null,
  16561. last: lastContentRow,
  16562. tail: tail,
  16563. tailExpiration: 0,
  16564. tailMode: tailMode
  16565. };
  16566. } else {
  16567. // We can reuse the existing object from previous renders.
  16568. renderState.isBackwards = isBackwards;
  16569. renderState.rendering = null;
  16570. renderState.last = lastContentRow;
  16571. renderState.tail = tail;
  16572. renderState.tailExpiration = 0;
  16573. renderState.tailMode = tailMode;
  16574. }
  16575. }
  16576. // This can end up rendering this component multiple passes.
  16577. // The first pass splits the children fibers into two sets. A head and tail.
  16578. // We first render the head. If anything is in fallback state, we do another
  16579. // pass through beginWork to rerender all children (including the tail) with
  16580. // the force suspend context. If the first render didn't have anything in
  16581. // in fallback state. Then we render each row in the tail one-by-one.
  16582. // That happens in the completeWork phase without going back to beginWork.
  16583. function updateSuspenseListComponent(current$$1, workInProgress, renderExpirationTime) {
  16584. var nextProps = workInProgress.pendingProps;
  16585. var revealOrder = nextProps.revealOrder;
  16586. var tailMode = nextProps.tail;
  16587. var newChildren = nextProps.children;
  16588. validateRevealOrder(revealOrder);
  16589. validateTailOptions(tailMode, revealOrder);
  16590. validateSuspenseListChildren(newChildren, revealOrder);
  16591. reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
  16592. var suspenseContext = suspenseStackCursor.current;
  16593. var shouldForceFallback = hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
  16594. if (shouldForceFallback) {
  16595. suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
  16596. workInProgress.effectTag |= DidCapture;
  16597. } else {
  16598. var didSuspendBefore = current$$1 !== null && (current$$1.effectTag & DidCapture) !== NoEffect;
  16599. if (didSuspendBefore) {
  16600. // If we previously forced a fallback, we need to schedule work
  16601. // on any nested boundaries to let them know to try to render
  16602. // again. This is the same as context updating.
  16603. propagateSuspenseContextChange(workInProgress, workInProgress.child, renderExpirationTime);
  16604. }
  16605. suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
  16606. }
  16607. pushSuspenseContext(workInProgress, suspenseContext);
  16608. if ((workInProgress.mode & BatchedMode) === NoMode) {
  16609. // Outside of batched mode, SuspenseList doesn't work so we just
  16610. // use make it a noop by treating it as the default revealOrder.
  16611. workInProgress.memoizedState = null;
  16612. } else {
  16613. switch (revealOrder) {
  16614. case 'forwards':
  16615. {
  16616. var lastContentRow = findLastContentRow(workInProgress.child);
  16617. var tail = void 0;
  16618. if (lastContentRow === null) {
  16619. // The whole list is part of the tail.
  16620. // TODO: We could fast path by just rendering the tail now.
  16621. tail = workInProgress.child;
  16622. workInProgress.child = null;
  16623. } else {
  16624. // Disconnect the tail rows after the content row.
  16625. // We're going to render them separately later.
  16626. tail = lastContentRow.sibling;
  16627. lastContentRow.sibling = null;
  16628. }
  16629. initSuspenseListRenderState(workInProgress, false, // isBackwards
  16630. tail, lastContentRow, tailMode);
  16631. break;
  16632. }
  16633. case 'backwards':
  16634. {
  16635. // We're going to find the first row that has existing content.
  16636. // At the same time we're going to reverse the list of everything
  16637. // we pass in the meantime. That's going to be our tail in reverse
  16638. // order.
  16639. var _tail = null;
  16640. var row = workInProgress.child;
  16641. workInProgress.child = null;
  16642. while (row !== null) {
  16643. var currentRow = row.alternate;
  16644. // New rows can't be content rows.
  16645. if (currentRow !== null && findFirstSuspended(currentRow) === null) {
  16646. // This is the beginning of the main content.
  16647. workInProgress.child = row;
  16648. break;
  16649. }
  16650. var nextRow = row.sibling;
  16651. row.sibling = _tail;
  16652. _tail = row;
  16653. row = nextRow;
  16654. }
  16655. // TODO: If workInProgress.child is null, we can continue on the tail immediately.
  16656. initSuspenseListRenderState(workInProgress, true, // isBackwards
  16657. _tail, null, // last
  16658. tailMode);
  16659. break;
  16660. }
  16661. case 'together':
  16662. {
  16663. initSuspenseListRenderState(workInProgress, false, // isBackwards
  16664. null, // tail
  16665. null, // last
  16666. undefined);
  16667. break;
  16668. }
  16669. default:
  16670. {
  16671. // The default reveal order is the same as not having
  16672. // a boundary.
  16673. workInProgress.memoizedState = null;
  16674. }
  16675. }
  16676. }
  16677. return workInProgress.child;
  16678. }
  16679. function updatePortalComponent(current$$1, workInProgress, renderExpirationTime) {
  16680. pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
  16681. var nextChildren = workInProgress.pendingProps;
  16682. if (current$$1 === null) {
  16683. // Portals are special because we don't append the children during mount
  16684. // but at commit. Therefore we need to track insertions which the normal
  16685. // flow doesn't do during mount. This doesn't happen at the root because
  16686. // the root always starts with a "current" with a null child.
  16687. // TODO: Consider unifying this with how the root works.
  16688. workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
  16689. } else {
  16690. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  16691. }
  16692. return workInProgress.child;
  16693. }
  16694. function updateContextProvider(current$$1, workInProgress, renderExpirationTime) {
  16695. var providerType = workInProgress.type;
  16696. var context = providerType._context;
  16697. var newProps = workInProgress.pendingProps;
  16698. var oldProps = workInProgress.memoizedProps;
  16699. var newValue = newProps.value;
  16700. {
  16701. var providerPropTypes = workInProgress.type.propTypes;
  16702. if (providerPropTypes) {
  16703. checkPropTypes(providerPropTypes, newProps, 'prop', 'Context.Provider', getCurrentFiberStackInDev);
  16704. }
  16705. }
  16706. pushProvider(workInProgress, newValue);
  16707. if (oldProps !== null) {
  16708. var oldValue = oldProps.value;
  16709. var changedBits = calculateChangedBits(context, newValue, oldValue);
  16710. if (changedBits === 0) {
  16711. // No change. Bailout early if children are the same.
  16712. if (oldProps.children === newProps.children && !hasContextChanged()) {
  16713. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  16714. }
  16715. } else {
  16716. // The context value changed. Search for matching consumers and schedule
  16717. // them to update.
  16718. propagateContextChange(workInProgress, context, changedBits, renderExpirationTime);
  16719. }
  16720. }
  16721. var newChildren = newProps.children;
  16722. reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
  16723. return workInProgress.child;
  16724. }
  16725. var hasWarnedAboutUsingContextAsConsumer = false;
  16726. function updateContextConsumer(current$$1, workInProgress, renderExpirationTime) {
  16727. var context = workInProgress.type;
  16728. // The logic below for Context differs depending on PROD or DEV mode. In
  16729. // DEV mode, we create a separate object for Context.Consumer that acts
  16730. // like a proxy to Context. This proxy object adds unnecessary code in PROD
  16731. // so we use the old behaviour (Context.Consumer references Context) to
  16732. // reduce size and overhead. The separate object references context via
  16733. // a property called "_context", which also gives us the ability to check
  16734. // in DEV mode if this property exists or not and warn if it does not.
  16735. {
  16736. if (context._context === undefined) {
  16737. // This may be because it's a Context (rather than a Consumer).
  16738. // Or it may be because it's older React where they're the same thing.
  16739. // We only want to warn if we're sure it's a new React.
  16740. if (context !== context.Consumer) {
  16741. if (!hasWarnedAboutUsingContextAsConsumer) {
  16742. hasWarnedAboutUsingContextAsConsumer = true;
  16743. 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?');
  16744. }
  16745. }
  16746. } else {
  16747. context = context._context;
  16748. }
  16749. }
  16750. var newProps = workInProgress.pendingProps;
  16751. var render = newProps.children;
  16752. {
  16753. !(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;
  16754. }
  16755. prepareToReadContext(workInProgress, renderExpirationTime);
  16756. var newValue = readContext(context, newProps.unstable_observedBits);
  16757. var newChildren = void 0;
  16758. {
  16759. ReactCurrentOwner$3.current = workInProgress;
  16760. setCurrentPhase('render');
  16761. newChildren = render(newValue);
  16762. setCurrentPhase(null);
  16763. }
  16764. // React DevTools reads this flag.
  16765. workInProgress.effectTag |= PerformedWork;
  16766. reconcileChildren(current$$1, workInProgress, newChildren, renderExpirationTime);
  16767. return workInProgress.child;
  16768. }
  16769. function updateFundamentalComponent$1(current$$1, workInProgress, renderExpirationTime) {
  16770. var fundamentalImpl = workInProgress.type.impl;
  16771. if (fundamentalImpl.reconcileChildren === false) {
  16772. return null;
  16773. }
  16774. var nextProps = workInProgress.pendingProps;
  16775. var nextChildren = nextProps.children;
  16776. reconcileChildren(current$$1, workInProgress, nextChildren, renderExpirationTime);
  16777. return workInProgress.child;
  16778. }
  16779. function markWorkInProgressReceivedUpdate() {
  16780. didReceiveUpdate = true;
  16781. }
  16782. function bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime) {
  16783. cancelWorkTimer(workInProgress);
  16784. if (current$$1 !== null) {
  16785. // Reuse previous dependencies
  16786. workInProgress.dependencies = current$$1.dependencies;
  16787. }
  16788. if (enableProfilerTimer) {
  16789. // Don't update "base" render times for bailouts.
  16790. stopProfilerTimerIfRunning(workInProgress);
  16791. }
  16792. // Check if the children have any pending work.
  16793. var childExpirationTime = workInProgress.childExpirationTime;
  16794. if (childExpirationTime < renderExpirationTime) {
  16795. // The children don't have any work either. We can skip them.
  16796. // TODO: Once we add back resuming, we should check if the children are
  16797. // a work-in-progress set. If so, we need to transfer their effects.
  16798. return null;
  16799. } else {
  16800. // This fiber doesn't have work, but its subtree does. Clone the child
  16801. // fibers and continue.
  16802. cloneChildFibers(current$$1, workInProgress);
  16803. return workInProgress.child;
  16804. }
  16805. }
  16806. function remountFiber(current$$1, oldWorkInProgress, newWorkInProgress) {
  16807. {
  16808. var returnFiber = oldWorkInProgress.return;
  16809. if (returnFiber === null) {
  16810. throw new Error('Cannot swap the root fiber.');
  16811. }
  16812. // Disconnect from the old current.
  16813. // It will get deleted.
  16814. current$$1.alternate = null;
  16815. oldWorkInProgress.alternate = null;
  16816. // Connect to the new tree.
  16817. newWorkInProgress.index = oldWorkInProgress.index;
  16818. newWorkInProgress.sibling = oldWorkInProgress.sibling;
  16819. newWorkInProgress.return = oldWorkInProgress.return;
  16820. newWorkInProgress.ref = oldWorkInProgress.ref;
  16821. // Replace the child/sibling pointers above it.
  16822. if (oldWorkInProgress === returnFiber.child) {
  16823. returnFiber.child = newWorkInProgress;
  16824. } else {
  16825. var prevSibling = returnFiber.child;
  16826. if (prevSibling === null) {
  16827. throw new Error('Expected parent to have a child.');
  16828. }
  16829. while (prevSibling.sibling !== oldWorkInProgress) {
  16830. prevSibling = prevSibling.sibling;
  16831. if (prevSibling === null) {
  16832. throw new Error('Expected to find the previous sibling.');
  16833. }
  16834. }
  16835. prevSibling.sibling = newWorkInProgress;
  16836. }
  16837. // Delete the old fiber and place the new one.
  16838. // Since the old fiber is disconnected, we have to schedule it manually.
  16839. var last = returnFiber.lastEffect;
  16840. if (last !== null) {
  16841. last.nextEffect = current$$1;
  16842. returnFiber.lastEffect = current$$1;
  16843. } else {
  16844. returnFiber.firstEffect = returnFiber.lastEffect = current$$1;
  16845. }
  16846. current$$1.nextEffect = null;
  16847. current$$1.effectTag = Deletion;
  16848. newWorkInProgress.effectTag |= Placement;
  16849. // Restart work from the new fiber.
  16850. return newWorkInProgress;
  16851. }
  16852. }
  16853. function beginWork$1(current$$1, workInProgress, renderExpirationTime) {
  16854. var updateExpirationTime = workInProgress.expirationTime;
  16855. {
  16856. if (workInProgress._debugNeedsRemount && current$$1 !== null) {
  16857. // This will restart the begin phase with a new fiber.
  16858. return remountFiber(current$$1, workInProgress, createFiberFromTypeAndProps(workInProgress.type, workInProgress.key, workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, workInProgress.expirationTime));
  16859. }
  16860. }
  16861. if (current$$1 !== null) {
  16862. var oldProps = current$$1.memoizedProps;
  16863. var newProps = workInProgress.pendingProps;
  16864. if (oldProps !== newProps || hasContextChanged() || (
  16865. // Force a re-render if the implementation changed due to hot reload:
  16866. workInProgress.type !== current$$1.type)) {
  16867. // If props or context changed, mark the fiber as having performed work.
  16868. // This may be unset if the props are determined to be equal later (memo).
  16869. didReceiveUpdate = true;
  16870. } else if (updateExpirationTime < renderExpirationTime) {
  16871. didReceiveUpdate = false;
  16872. // This fiber does not have any pending work. Bailout without entering
  16873. // the begin phase. There's still some bookkeeping we that needs to be done
  16874. // in this optimized path, mostly pushing stuff onto the stack.
  16875. switch (workInProgress.tag) {
  16876. case HostRoot:
  16877. pushHostRootContext(workInProgress);
  16878. resetHydrationState();
  16879. break;
  16880. case HostComponent:
  16881. pushHostContext(workInProgress);
  16882. if (workInProgress.mode & ConcurrentMode && renderExpirationTime !== Never && shouldDeprioritizeSubtree(workInProgress.type, newProps)) {
  16883. if (enableSchedulerTracing) {
  16884. markSpawnedWork(Never);
  16885. }
  16886. // Schedule this fiber to re-render at offscreen priority. Then bailout.
  16887. workInProgress.expirationTime = workInProgress.childExpirationTime = Never;
  16888. return null;
  16889. }
  16890. break;
  16891. case ClassComponent:
  16892. {
  16893. var Component = workInProgress.type;
  16894. if (isContextProvider(Component)) {
  16895. pushContextProvider(workInProgress);
  16896. }
  16897. break;
  16898. }
  16899. case HostPortal:
  16900. pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
  16901. break;
  16902. case ContextProvider:
  16903. {
  16904. var newValue = workInProgress.memoizedProps.value;
  16905. pushProvider(workInProgress, newValue);
  16906. break;
  16907. }
  16908. case Profiler:
  16909. if (enableProfilerTimer) {
  16910. workInProgress.effectTag |= Update;
  16911. }
  16912. break;
  16913. case SuspenseComponent:
  16914. {
  16915. var state = workInProgress.memoizedState;
  16916. var didTimeout = state !== null;
  16917. if (didTimeout) {
  16918. // If this boundary is currently timed out, we need to decide
  16919. // whether to retry the primary children, or to skip over it and
  16920. // go straight to the fallback. Check the priority of the primary
  16921. var primaryChildFragment = workInProgress.child;
  16922. var primaryChildExpirationTime = primaryChildFragment.childExpirationTime;
  16923. if (primaryChildExpirationTime !== NoWork && primaryChildExpirationTime >= renderExpirationTime) {
  16924. // The primary children have pending work. Use the normal path
  16925. // to attempt to render the primary children again.
  16926. return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
  16927. } else {
  16928. pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
  16929. // The primary children do not have pending work with sufficient
  16930. // priority. Bailout.
  16931. var child = bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  16932. if (child !== null) {
  16933. // The fallback children have pending work. Skip over the
  16934. // primary children and work on the fallback.
  16935. return child.sibling;
  16936. } else {
  16937. return null;
  16938. }
  16939. }
  16940. } else {
  16941. pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
  16942. }
  16943. break;
  16944. }
  16945. case DehydratedSuspenseComponent:
  16946. {
  16947. if (enableSuspenseServerRenderer) {
  16948. pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
  16949. // We know that this component will suspend again because if it has
  16950. // been unsuspended it has committed as a regular Suspense component.
  16951. // If it needs to be retried, it should have work scheduled on it.
  16952. workInProgress.effectTag |= DidCapture;
  16953. }
  16954. break;
  16955. }
  16956. case SuspenseListComponent:
  16957. {
  16958. var didSuspendBefore = (current$$1.effectTag & DidCapture) !== NoEffect;
  16959. var hasChildWork = workInProgress.childExpirationTime >= renderExpirationTime;
  16960. if (didSuspendBefore) {
  16961. if (hasChildWork) {
  16962. // If something was in fallback state last time, and we have all the
  16963. // same children then we're still in progressive loading state.
  16964. // Something might get unblocked by state updates or retries in the
  16965. // tree which will affect the tail. So we need to use the normal
  16966. // path to compute the correct tail.
  16967. return updateSuspenseListComponent(current$$1, workInProgress, renderExpirationTime);
  16968. }
  16969. // If none of the children had any work, that means that none of
  16970. // them got retried so they'll still be blocked in the same way
  16971. // as before. We can fast bail out.
  16972. workInProgress.effectTag |= DidCapture;
  16973. }
  16974. // If nothing suspended before and we're rendering the same children,
  16975. // then the tail doesn't matter. Anything new that suspends will work
  16976. // in the "together" mode, so we can continue from the state we had.
  16977. var renderState = workInProgress.memoizedState;
  16978. if (renderState !== null) {
  16979. // Reset to the "together" mode in case we've started a different
  16980. // update in the past but didn't complete it.
  16981. renderState.rendering = null;
  16982. renderState.tail = null;
  16983. }
  16984. pushSuspenseContext(workInProgress, suspenseStackCursor.current);
  16985. if (hasChildWork) {
  16986. break;
  16987. } else {
  16988. // If none of the children had any work, that means that none of
  16989. // them got retried so they'll still be blocked in the same way
  16990. // as before. We can fast bail out.
  16991. return null;
  16992. }
  16993. }
  16994. }
  16995. return bailoutOnAlreadyFinishedWork(current$$1, workInProgress, renderExpirationTime);
  16996. }
  16997. } else {
  16998. didReceiveUpdate = false;
  16999. }
  17000. // Before entering the begin phase, clear the expiration time.
  17001. workInProgress.expirationTime = NoWork;
  17002. switch (workInProgress.tag) {
  17003. case IndeterminateComponent:
  17004. {
  17005. return mountIndeterminateComponent(current$$1, workInProgress, workInProgress.type, renderExpirationTime);
  17006. }
  17007. case LazyComponent:
  17008. {
  17009. var elementType = workInProgress.elementType;
  17010. return mountLazyComponent(current$$1, workInProgress, elementType, updateExpirationTime, renderExpirationTime);
  17011. }
  17012. case FunctionComponent:
  17013. {
  17014. var _Component = workInProgress.type;
  17015. var unresolvedProps = workInProgress.pendingProps;
  17016. var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps);
  17017. return updateFunctionComponent(current$$1, workInProgress, _Component, resolvedProps, renderExpirationTime);
  17018. }
  17019. case ClassComponent:
  17020. {
  17021. var _Component2 = workInProgress.type;
  17022. var _unresolvedProps = workInProgress.pendingProps;
  17023. var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps);
  17024. return updateClassComponent(current$$1, workInProgress, _Component2, _resolvedProps, renderExpirationTime);
  17025. }
  17026. case HostRoot:
  17027. return updateHostRoot(current$$1, workInProgress, renderExpirationTime);
  17028. case HostComponent:
  17029. return updateHostComponent(current$$1, workInProgress, renderExpirationTime);
  17030. case HostText:
  17031. return updateHostText(current$$1, workInProgress);
  17032. case SuspenseComponent:
  17033. return updateSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
  17034. case HostPortal:
  17035. return updatePortalComponent(current$$1, workInProgress, renderExpirationTime);
  17036. case ForwardRef:
  17037. {
  17038. var type = workInProgress.type;
  17039. var _unresolvedProps2 = workInProgress.pendingProps;
  17040. var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
  17041. return updateForwardRef(current$$1, workInProgress, type, _resolvedProps2, renderExpirationTime);
  17042. }
  17043. case Fragment:
  17044. return updateFragment(current$$1, workInProgress, renderExpirationTime);
  17045. case Mode:
  17046. return updateMode(current$$1, workInProgress, renderExpirationTime);
  17047. case Profiler:
  17048. return updateProfiler(current$$1, workInProgress, renderExpirationTime);
  17049. case ContextProvider:
  17050. return updateContextProvider(current$$1, workInProgress, renderExpirationTime);
  17051. case ContextConsumer:
  17052. return updateContextConsumer(current$$1, workInProgress, renderExpirationTime);
  17053. case MemoComponent:
  17054. {
  17055. var _type2 = workInProgress.type;
  17056. var _unresolvedProps3 = workInProgress.pendingProps;
  17057. // Resolve outer props first, then resolve inner props.
  17058. var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);
  17059. {
  17060. if (workInProgress.type !== workInProgress.elementType) {
  17061. var outerPropTypes = _type2.propTypes;
  17062. if (outerPropTypes) {
  17063. checkPropTypes(outerPropTypes, _resolvedProps3, // Resolved for outer only
  17064. 'prop', getComponentName(_type2), getCurrentFiberStackInDev);
  17065. }
  17066. }
  17067. }
  17068. _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);
  17069. return updateMemoComponent(current$$1, workInProgress, _type2, _resolvedProps3, updateExpirationTime, renderExpirationTime);
  17070. }
  17071. case SimpleMemoComponent:
  17072. {
  17073. return updateSimpleMemoComponent(current$$1, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime);
  17074. }
  17075. case IncompleteClassComponent:
  17076. {
  17077. var _Component3 = workInProgress.type;
  17078. var _unresolvedProps4 = workInProgress.pendingProps;
  17079. var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
  17080. return mountIncompleteClassComponent(current$$1, workInProgress, _Component3, _resolvedProps4, renderExpirationTime);
  17081. }
  17082. case DehydratedSuspenseComponent:
  17083. {
  17084. if (enableSuspenseServerRenderer) {
  17085. return updateDehydratedSuspenseComponent(current$$1, workInProgress, renderExpirationTime);
  17086. }
  17087. break;
  17088. }
  17089. case SuspenseListComponent:
  17090. {
  17091. return updateSuspenseListComponent(current$$1, workInProgress, renderExpirationTime);
  17092. }
  17093. case FundamentalComponent:
  17094. {
  17095. if (enableFundamentalAPI) {
  17096. return updateFundamentalComponent$1(current$$1, workInProgress, renderExpirationTime);
  17097. }
  17098. break;
  17099. }
  17100. }
  17101. (function () {
  17102. {
  17103. {
  17104. throw ReactError(Error('Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.'));
  17105. }
  17106. }
  17107. })();
  17108. }
  17109. function createFundamentalStateInstance(currentFiber, props, impl, state) {
  17110. return {
  17111. currentFiber: currentFiber,
  17112. impl: impl,
  17113. instance: null,
  17114. prevProps: null,
  17115. props: props,
  17116. state: state
  17117. };
  17118. }
  17119. var emptyObject = {};
  17120. var isArray$2 = Array.isArray;
  17121. function markUpdate(workInProgress) {
  17122. // Tag the fiber with an update effect. This turns a Placement into
  17123. // a PlacementAndUpdate.
  17124. workInProgress.effectTag |= Update;
  17125. }
  17126. function markRef$1(workInProgress) {
  17127. workInProgress.effectTag |= Ref;
  17128. }
  17129. var appendAllChildren = void 0;
  17130. var updateHostContainer = void 0;
  17131. var updateHostComponent$1 = void 0;
  17132. var updateHostText$1 = void 0;
  17133. if (supportsMutation) {
  17134. // Mutation mode
  17135. appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
  17136. // We only have the top Fiber that was created but we need recurse down its
  17137. // children to find all the terminal nodes.
  17138. var node = workInProgress.child;
  17139. while (node !== null) {
  17140. if (node.tag === HostComponent || node.tag === HostText) {
  17141. appendInitialChild(parent, node.stateNode);
  17142. } else if (node.tag === FundamentalComponent) {
  17143. appendInitialChild(parent, node.stateNode.instance);
  17144. } else if (node.tag === HostPortal) {
  17145. // If we have a portal child, then we don't want to traverse
  17146. // down its children. Instead, we'll get insertions from each child in
  17147. // the portal directly.
  17148. } else if (node.child !== null) {
  17149. node.child.return = node;
  17150. node = node.child;
  17151. continue;
  17152. }
  17153. if (node === workInProgress) {
  17154. return;
  17155. }
  17156. while (node.sibling === null) {
  17157. if (node.return === null || node.return === workInProgress) {
  17158. return;
  17159. }
  17160. node = node.return;
  17161. }
  17162. node.sibling.return = node.return;
  17163. node = node.sibling;
  17164. }
  17165. };
  17166. updateHostContainer = function (workInProgress) {
  17167. // Noop
  17168. };
  17169. updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
  17170. // If we have an alternate, that means this is an update and we need to
  17171. // schedule a side-effect to do the updates.
  17172. var oldProps = current.memoizedProps;
  17173. if (oldProps === newProps) {
  17174. // In mutation mode, this is sufficient for a bailout because
  17175. // we won't touch this node even if children changed.
  17176. return;
  17177. }
  17178. // If we get updated because one of our children updated, we don't
  17179. // have newProps so we'll have to reuse them.
  17180. // TODO: Split the update API as separate for the props vs. children.
  17181. // Even better would be if children weren't special cased at all tho.
  17182. var instance = workInProgress.stateNode;
  17183. var currentHostContext = getHostContext();
  17184. // TODO: Experiencing an error where oldProps is null. Suggests a host
  17185. // component is hitting the resume path. Figure out why. Possibly
  17186. // related to `hidden`.
  17187. var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext);
  17188. // TODO: Type this specific to this type of component.
  17189. workInProgress.updateQueue = updatePayload;
  17190. // If the update payload indicates that there is a change or if there
  17191. // is a new ref we mark this as an update. All the work is done in commitWork.
  17192. if (updatePayload) {
  17193. markUpdate(workInProgress);
  17194. }
  17195. };
  17196. updateHostText$1 = function (current, workInProgress, oldText, newText) {
  17197. // If the text differs, mark it as an update. All the work in done in commitWork.
  17198. if (oldText !== newText) {
  17199. markUpdate(workInProgress);
  17200. }
  17201. };
  17202. } else if (supportsPersistence) {
  17203. // Persistent host tree mode
  17204. appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
  17205. // We only have the top Fiber that was created but we need recurse down its
  17206. // children to find all the terminal nodes.
  17207. var node = workInProgress.child;
  17208. while (node !== null) {
  17209. // eslint-disable-next-line no-labels
  17210. branches: if (node.tag === HostComponent) {
  17211. var instance = node.stateNode;
  17212. if (needsVisibilityToggle && isHidden) {
  17213. // This child is inside a timed out tree. Hide it.
  17214. var props = node.memoizedProps;
  17215. var type = node.type;
  17216. instance = cloneHiddenInstance(instance, type, props, node);
  17217. }
  17218. appendInitialChild(parent, instance);
  17219. } else if (node.tag === HostText) {
  17220. var _instance = node.stateNode;
  17221. if (needsVisibilityToggle && isHidden) {
  17222. // This child is inside a timed out tree. Hide it.
  17223. var text = node.memoizedProps;
  17224. _instance = cloneHiddenTextInstance(_instance, text, node);
  17225. }
  17226. appendInitialChild(parent, _instance);
  17227. } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
  17228. var _instance2 = node.stateNode.instance;
  17229. if (needsVisibilityToggle && isHidden) {
  17230. // This child is inside a timed out tree. Hide it.
  17231. var _props = node.memoizedProps;
  17232. var _type = node.type;
  17233. _instance2 = cloneHiddenInstance(_instance2, _type, _props, node);
  17234. }
  17235. appendInitialChild(parent, _instance2);
  17236. } else if (node.tag === HostPortal) {
  17237. // If we have a portal child, then we don't want to traverse
  17238. // down its children. Instead, we'll get insertions from each child in
  17239. // the portal directly.
  17240. } else if (node.tag === SuspenseComponent) {
  17241. if ((node.effectTag & Update) !== NoEffect) {
  17242. // Need to toggle the visibility of the primary children.
  17243. var newIsHidden = node.memoizedState !== null;
  17244. if (newIsHidden) {
  17245. var primaryChildParent = node.child;
  17246. if (primaryChildParent !== null) {
  17247. if (primaryChildParent.child !== null) {
  17248. primaryChildParent.child.return = primaryChildParent;
  17249. appendAllChildren(parent, primaryChildParent, true, newIsHidden);
  17250. }
  17251. var fallbackChildParent = primaryChildParent.sibling;
  17252. if (fallbackChildParent !== null) {
  17253. fallbackChildParent.return = node;
  17254. node = fallbackChildParent;
  17255. continue;
  17256. }
  17257. }
  17258. }
  17259. }
  17260. if (node.child !== null) {
  17261. // Continue traversing like normal
  17262. node.child.return = node;
  17263. node = node.child;
  17264. continue;
  17265. }
  17266. } else if (node.child !== null) {
  17267. node.child.return = node;
  17268. node = node.child;
  17269. continue;
  17270. }
  17271. // $FlowFixMe This is correct but Flow is confused by the labeled break.
  17272. node = node;
  17273. if (node === workInProgress) {
  17274. return;
  17275. }
  17276. while (node.sibling === null) {
  17277. if (node.return === null || node.return === workInProgress) {
  17278. return;
  17279. }
  17280. node = node.return;
  17281. }
  17282. node.sibling.return = node.return;
  17283. node = node.sibling;
  17284. }
  17285. };
  17286. // An unfortunate fork of appendAllChildren because we have two different parent types.
  17287. var appendAllChildrenToContainer = function (containerChildSet, workInProgress, needsVisibilityToggle, isHidden) {
  17288. // We only have the top Fiber that was created but we need recurse down its
  17289. // children to find all the terminal nodes.
  17290. var node = workInProgress.child;
  17291. while (node !== null) {
  17292. // eslint-disable-next-line no-labels
  17293. branches: if (node.tag === HostComponent) {
  17294. var instance = node.stateNode;
  17295. if (needsVisibilityToggle && isHidden) {
  17296. // This child is inside a timed out tree. Hide it.
  17297. var props = node.memoizedProps;
  17298. var type = node.type;
  17299. instance = cloneHiddenInstance(instance, type, props, node);
  17300. }
  17301. appendChildToContainerChildSet(containerChildSet, instance);
  17302. } else if (node.tag === HostText) {
  17303. var _instance3 = node.stateNode;
  17304. if (needsVisibilityToggle && isHidden) {
  17305. // This child is inside a timed out tree. Hide it.
  17306. var text = node.memoizedProps;
  17307. _instance3 = cloneHiddenTextInstance(_instance3, text, node);
  17308. }
  17309. appendChildToContainerChildSet(containerChildSet, _instance3);
  17310. } else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
  17311. var _instance4 = node.stateNode.instance;
  17312. if (needsVisibilityToggle && isHidden) {
  17313. // This child is inside a timed out tree. Hide it.
  17314. var _props2 = node.memoizedProps;
  17315. var _type2 = node.type;
  17316. _instance4 = cloneHiddenInstance(_instance4, _type2, _props2, node);
  17317. }
  17318. appendChildToContainerChildSet(containerChildSet, _instance4);
  17319. } else if (node.tag === HostPortal) {
  17320. // If we have a portal child, then we don't want to traverse
  17321. // down its children. Instead, we'll get insertions from each child in
  17322. // the portal directly.
  17323. } else if (node.tag === SuspenseComponent) {
  17324. if ((node.effectTag & Update) !== NoEffect) {
  17325. // Need to toggle the visibility of the primary children.
  17326. var newIsHidden = node.memoizedState !== null;
  17327. if (newIsHidden) {
  17328. var primaryChildParent = node.child;
  17329. if (primaryChildParent !== null) {
  17330. if (primaryChildParent.child !== null) {
  17331. primaryChildParent.child.return = primaryChildParent;
  17332. appendAllChildrenToContainer(containerChildSet, primaryChildParent, true, newIsHidden);
  17333. }
  17334. var fallbackChildParent = primaryChildParent.sibling;
  17335. if (fallbackChildParent !== null) {
  17336. fallbackChildParent.return = node;
  17337. node = fallbackChildParent;
  17338. continue;
  17339. }
  17340. }
  17341. }
  17342. }
  17343. if (node.child !== null) {
  17344. // Continue traversing like normal
  17345. node.child.return = node;
  17346. node = node.child;
  17347. continue;
  17348. }
  17349. } else if (node.child !== null) {
  17350. node.child.return = node;
  17351. node = node.child;
  17352. continue;
  17353. }
  17354. // $FlowFixMe This is correct but Flow is confused by the labeled break.
  17355. node = node;
  17356. if (node === workInProgress) {
  17357. return;
  17358. }
  17359. while (node.sibling === null) {
  17360. if (node.return === null || node.return === workInProgress) {
  17361. return;
  17362. }
  17363. node = node.return;
  17364. }
  17365. node.sibling.return = node.return;
  17366. node = node.sibling;
  17367. }
  17368. };
  17369. updateHostContainer = function (workInProgress) {
  17370. var portalOrRoot = workInProgress.stateNode;
  17371. var childrenUnchanged = workInProgress.firstEffect === null;
  17372. if (childrenUnchanged) {
  17373. // No changes, just reuse the existing instance.
  17374. } else {
  17375. var container = portalOrRoot.containerInfo;
  17376. var newChildSet = createContainerChildSet(container);
  17377. // If children might have changed, we have to add them all to the set.
  17378. appendAllChildrenToContainer(newChildSet, workInProgress, false, false);
  17379. portalOrRoot.pendingChildren = newChildSet;
  17380. // Schedule an update on the container to swap out the container.
  17381. markUpdate(workInProgress);
  17382. finalizeContainerChildren(container, newChildSet);
  17383. }
  17384. };
  17385. updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
  17386. var currentInstance = current.stateNode;
  17387. var oldProps = current.memoizedProps;
  17388. // If there are no effects associated with this node, then none of our children had any updates.
  17389. // This guarantees that we can reuse all of them.
  17390. var childrenUnchanged = workInProgress.firstEffect === null;
  17391. if (childrenUnchanged && oldProps === newProps) {
  17392. // No changes, just reuse the existing instance.
  17393. // Note that this might release a previous clone.
  17394. workInProgress.stateNode = currentInstance;
  17395. return;
  17396. }
  17397. var recyclableInstance = workInProgress.stateNode;
  17398. var currentHostContext = getHostContext();
  17399. var updatePayload = null;
  17400. if (oldProps !== newProps) {
  17401. updatePayload = prepareUpdate(recyclableInstance, type, oldProps, newProps, rootContainerInstance, currentHostContext);
  17402. }
  17403. if (childrenUnchanged && updatePayload === null) {
  17404. // No changes, just reuse the existing instance.
  17405. // Note that this might release a previous clone.
  17406. workInProgress.stateNode = currentInstance;
  17407. return;
  17408. }
  17409. var newInstance = cloneInstance(currentInstance, updatePayload, type, oldProps, newProps, workInProgress, childrenUnchanged, recyclableInstance);
  17410. if (finalizeInitialChildren(newInstance, type, newProps, rootContainerInstance, currentHostContext)) {
  17411. markUpdate(workInProgress);
  17412. }
  17413. workInProgress.stateNode = newInstance;
  17414. if (childrenUnchanged) {
  17415. // If there are no other effects in this tree, we need to flag this node as having one.
  17416. // Even though we're not going to use it for anything.
  17417. // Otherwise parents won't know that there are new children to propagate upwards.
  17418. markUpdate(workInProgress);
  17419. } else {
  17420. // If children might have changed, we have to add them all to the set.
  17421. appendAllChildren(newInstance, workInProgress, false, false);
  17422. }
  17423. };
  17424. updateHostText$1 = function (current, workInProgress, oldText, newText) {
  17425. if (oldText !== newText) {
  17426. // If the text content differs, we'll create a new text instance for it.
  17427. var rootContainerInstance = getRootHostContainer();
  17428. var currentHostContext = getHostContext();
  17429. workInProgress.stateNode = createTextInstance(newText, rootContainerInstance, currentHostContext, workInProgress);
  17430. // We'll have to mark it as having an effect, even though we won't use the effect for anything.
  17431. // This lets the parents know that at least one of their children has changed.
  17432. markUpdate(workInProgress);
  17433. }
  17434. };
  17435. } else {
  17436. // No host operations
  17437. updateHostContainer = function (workInProgress) {
  17438. // Noop
  17439. };
  17440. updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
  17441. // Noop
  17442. };
  17443. updateHostText$1 = function (current, workInProgress, oldText, newText) {
  17444. // Noop
  17445. };
  17446. }
  17447. function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
  17448. switch (renderState.tailMode) {
  17449. case 'hidden':
  17450. {
  17451. // Any insertions at the end of the tail list after this point
  17452. // should be invisible. If there are already mounted boundaries
  17453. // anything before them are not considered for collapsing.
  17454. // Therefore we need to go through the whole tail to find if
  17455. // there are any.
  17456. var tailNode = renderState.tail;
  17457. var lastTailNode = null;
  17458. while (tailNode !== null) {
  17459. if (tailNode.alternate !== null) {
  17460. lastTailNode = tailNode;
  17461. }
  17462. tailNode = tailNode.sibling;
  17463. }
  17464. // Next we're simply going to delete all insertions after the
  17465. // last rendered item.
  17466. if (lastTailNode === null) {
  17467. // All remaining items in the tail are insertions.
  17468. renderState.tail = null;
  17469. } else {
  17470. // Detach the insertion after the last node that was already
  17471. // inserted.
  17472. lastTailNode.sibling = null;
  17473. }
  17474. break;
  17475. }
  17476. case 'collapsed':
  17477. {
  17478. // Any insertions at the end of the tail list after this point
  17479. // should be invisible. If there are already mounted boundaries
  17480. // anything before them are not considered for collapsing.
  17481. // Therefore we need to go through the whole tail to find if
  17482. // there are any.
  17483. var _tailNode = renderState.tail;
  17484. var _lastTailNode = null;
  17485. while (_tailNode !== null) {
  17486. if (_tailNode.alternate !== null) {
  17487. _lastTailNode = _tailNode;
  17488. }
  17489. _tailNode = _tailNode.sibling;
  17490. }
  17491. // Next we're simply going to delete all insertions after the
  17492. // last rendered item.
  17493. if (_lastTailNode === null) {
  17494. // All remaining items in the tail are insertions.
  17495. if (!hasRenderedATailFallback && renderState.tail !== null) {
  17496. // We suspended during the head. We want to show at least one
  17497. // row at the tail. So we'll keep on and cut off the rest.
  17498. renderState.tail.sibling = null;
  17499. } else {
  17500. renderState.tail = null;
  17501. }
  17502. } else {
  17503. // Detach the insertion after the last node that was already
  17504. // inserted.
  17505. _lastTailNode.sibling = null;
  17506. }
  17507. break;
  17508. }
  17509. }
  17510. }
  17511. function completeWork(current, workInProgress, renderExpirationTime) {
  17512. var newProps = workInProgress.pendingProps;
  17513. switch (workInProgress.tag) {
  17514. case IndeterminateComponent:
  17515. break;
  17516. case LazyComponent:
  17517. break;
  17518. case SimpleMemoComponent:
  17519. case FunctionComponent:
  17520. break;
  17521. case ClassComponent:
  17522. {
  17523. var Component = workInProgress.type;
  17524. if (isContextProvider(Component)) {
  17525. popContext(workInProgress);
  17526. }
  17527. break;
  17528. }
  17529. case HostRoot:
  17530. {
  17531. popHostContainer(workInProgress);
  17532. popTopLevelContextObject(workInProgress);
  17533. var fiberRoot = workInProgress.stateNode;
  17534. if (fiberRoot.pendingContext) {
  17535. fiberRoot.context = fiberRoot.pendingContext;
  17536. fiberRoot.pendingContext = null;
  17537. }
  17538. if (current === null || current.child === null) {
  17539. // If we hydrated, pop so that we can delete any remaining children
  17540. // that weren't hydrated.
  17541. popHydrationState(workInProgress);
  17542. // This resets the hacky state to fix isMounted before committing.
  17543. // TODO: Delete this when we delete isMounted and findDOMNode.
  17544. workInProgress.effectTag &= ~Placement;
  17545. }
  17546. updateHostContainer(workInProgress);
  17547. break;
  17548. }
  17549. case HostComponent:
  17550. {
  17551. popHostContext(workInProgress);
  17552. var rootContainerInstance = getRootHostContainer();
  17553. var type = workInProgress.type;
  17554. if (current !== null && workInProgress.stateNode != null) {
  17555. updateHostComponent$1(current, workInProgress, type, newProps, rootContainerInstance);
  17556. if (enableFlareAPI) {
  17557. var prevListeners = current.memoizedProps.listeners;
  17558. var nextListeners = newProps.listeners;
  17559. var instance = workInProgress.stateNode;
  17560. if (prevListeners !== nextListeners) {
  17561. updateEventListeners(nextListeners, instance, rootContainerInstance, workInProgress);
  17562. }
  17563. }
  17564. if (current.ref !== workInProgress.ref) {
  17565. markRef$1(workInProgress);
  17566. }
  17567. } else {
  17568. if (!newProps) {
  17569. (function () {
  17570. if (!(workInProgress.stateNode !== null)) {
  17571. {
  17572. throw ReactError(Error('We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.'));
  17573. }
  17574. }
  17575. })();
  17576. // This can happen when we abort work.
  17577. break;
  17578. }
  17579. var currentHostContext = getHostContext();
  17580. // TODO: Move createInstance to beginWork and keep it on a context
  17581. // "stack" as the parent. Then append children as we go in beginWork
  17582. // or completeWork depending on we want to add then top->down or
  17583. // bottom->up. Top->down is faster in IE11.
  17584. var wasHydrated = popHydrationState(workInProgress);
  17585. if (wasHydrated) {
  17586. // TODO: Move this and createInstance step into the beginPhase
  17587. // to consolidate.
  17588. if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, currentHostContext)) {
  17589. // If changes to the hydrated node needs to be applied at the
  17590. // commit-phase we mark this as such.
  17591. markUpdate(workInProgress);
  17592. }
  17593. } else {
  17594. var _instance5 = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress);
  17595. appendAllChildren(_instance5, workInProgress, false, false);
  17596. if (enableFlareAPI) {
  17597. var listeners = newProps.listeners;
  17598. if (listeners != null) {
  17599. updateEventListeners(listeners, _instance5, rootContainerInstance, workInProgress);
  17600. }
  17601. }
  17602. // Certain renderers require commit-time effects for initial mount.
  17603. // (eg DOM renderer supports auto-focus for certain elements).
  17604. // Make sure such renderers get scheduled for later work.
  17605. if (finalizeInitialChildren(_instance5, type, newProps, rootContainerInstance, currentHostContext)) {
  17606. markUpdate(workInProgress);
  17607. }
  17608. workInProgress.stateNode = _instance5;
  17609. }
  17610. if (workInProgress.ref !== null) {
  17611. // If there is a ref on a host node we need to schedule a callback
  17612. markRef$1(workInProgress);
  17613. }
  17614. }
  17615. break;
  17616. }
  17617. case HostText:
  17618. {
  17619. var newText = newProps;
  17620. if (current && workInProgress.stateNode != null) {
  17621. var oldText = current.memoizedProps;
  17622. // If we have an alternate, that means this is an update and we need
  17623. // to schedule a side-effect to do the updates.
  17624. updateHostText$1(current, workInProgress, oldText, newText);
  17625. } else {
  17626. if (typeof newText !== 'string') {
  17627. (function () {
  17628. if (!(workInProgress.stateNode !== null)) {
  17629. {
  17630. throw ReactError(Error('We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.'));
  17631. }
  17632. }
  17633. })();
  17634. // This can happen when we abort work.
  17635. }
  17636. var _rootContainerInstance = getRootHostContainer();
  17637. var _currentHostContext = getHostContext();
  17638. var _wasHydrated = popHydrationState(workInProgress);
  17639. if (_wasHydrated) {
  17640. if (prepareToHydrateHostTextInstance(workInProgress)) {
  17641. markUpdate(workInProgress);
  17642. }
  17643. } else {
  17644. workInProgress.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext, workInProgress);
  17645. }
  17646. }
  17647. break;
  17648. }
  17649. case ForwardRef:
  17650. break;
  17651. case SuspenseComponent:
  17652. {
  17653. popSuspenseContext(workInProgress);
  17654. var nextState = workInProgress.memoizedState;
  17655. if ((workInProgress.effectTag & DidCapture) !== NoEffect) {
  17656. // Something suspended. Re-render with the fallback children.
  17657. workInProgress.expirationTime = renderExpirationTime;
  17658. // Do not reset the effect list.
  17659. return workInProgress;
  17660. }
  17661. var nextDidTimeout = nextState !== null;
  17662. var prevDidTimeout = false;
  17663. if (current === null) {
  17664. // In cases where we didn't find a suitable hydration boundary we never
  17665. // downgraded this to a DehydratedSuspenseComponent, but we still need to
  17666. // pop the hydration state since we might be inside the insertion tree.
  17667. popHydrationState(workInProgress);
  17668. } else {
  17669. var prevState = current.memoizedState;
  17670. prevDidTimeout = prevState !== null;
  17671. if (!nextDidTimeout && prevState !== null) {
  17672. // We just switched from the fallback to the normal children.
  17673. // Delete the fallback.
  17674. // TODO: Would it be better to store the fallback fragment on
  17675. var currentFallbackChild = current.child.sibling;
  17676. if (currentFallbackChild !== null) {
  17677. // Deletions go at the beginning of the return fiber's effect list
  17678. var first = workInProgress.firstEffect;
  17679. if (first !== null) {
  17680. workInProgress.firstEffect = currentFallbackChild;
  17681. currentFallbackChild.nextEffect = first;
  17682. } else {
  17683. workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild;
  17684. currentFallbackChild.nextEffect = null;
  17685. }
  17686. currentFallbackChild.effectTag = Deletion;
  17687. }
  17688. }
  17689. }
  17690. if (nextDidTimeout && !prevDidTimeout) {
  17691. // If this subtreee is running in batched mode we can suspend,
  17692. // otherwise we won't suspend.
  17693. // TODO: This will still suspend a synchronous tree if anything
  17694. // in the concurrent tree already suspended during this render.
  17695. // This is a known bug.
  17696. if ((workInProgress.mode & BatchedMode) !== NoMode) {
  17697. // TODO: Move this back to throwException because this is too late
  17698. // if this is a large tree which is common for initial loads. We
  17699. // don't know if we should restart a render or not until we get
  17700. // this marker, and this is too late.
  17701. // If this render already had a ping or lower pri updates,
  17702. // and this is the first time we know we're going to suspend we
  17703. // should be able to immediately restart from within throwException.
  17704. var hasInvisibleChildContext = current === null && workInProgress.memoizedProps.unstable_avoidThisFallback !== true;
  17705. if (hasInvisibleChildContext || hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext)) {
  17706. // If this was in an invisible tree or a new render, then showing
  17707. // this boundary is ok.
  17708. renderDidSuspend();
  17709. } else {
  17710. // Otherwise, we're going to have to hide content so we should
  17711. // suspend for longer if possible.
  17712. renderDidSuspendDelayIfPossible();
  17713. }
  17714. }
  17715. }
  17716. if (supportsPersistence) {
  17717. // TODO: Only schedule updates if not prevDidTimeout.
  17718. if (nextDidTimeout) {
  17719. // If this boundary just timed out, schedule an effect to attach a
  17720. // retry listener to the proimse. This flag is also used to hide the
  17721. // primary children.
  17722. workInProgress.effectTag |= Update;
  17723. }
  17724. }
  17725. if (supportsMutation) {
  17726. // TODO: Only schedule updates if these values are non equal, i.e. it changed.
  17727. if (nextDidTimeout || prevDidTimeout) {
  17728. // If this boundary just timed out, schedule an effect to attach a
  17729. // retry listener to the proimse. This flag is also used to hide the
  17730. // primary children. In mutation mode, we also need the flag to
  17731. // *unhide* children that were previously hidden, so check if the
  17732. // is currently timed out, too.
  17733. workInProgress.effectTag |= Update;
  17734. }
  17735. }
  17736. if (enableSuspenseCallback && workInProgress.updateQueue !== null && workInProgress.memoizedProps.suspenseCallback != null) {
  17737. // Always notify the callback
  17738. workInProgress.effectTag |= Update;
  17739. }
  17740. break;
  17741. }
  17742. case Fragment:
  17743. break;
  17744. case Mode:
  17745. break;
  17746. case Profiler:
  17747. break;
  17748. case HostPortal:
  17749. popHostContainer(workInProgress);
  17750. updateHostContainer(workInProgress);
  17751. break;
  17752. case ContextProvider:
  17753. // Pop provider fiber
  17754. popProvider(workInProgress);
  17755. break;
  17756. case ContextConsumer:
  17757. break;
  17758. case MemoComponent:
  17759. break;
  17760. case IncompleteClassComponent:
  17761. {
  17762. // Same as class component case. I put it down here so that the tags are
  17763. // sequential to ensure this switch is compiled to a jump table.
  17764. var _Component = workInProgress.type;
  17765. if (isContextProvider(_Component)) {
  17766. popContext(workInProgress);
  17767. }
  17768. break;
  17769. }
  17770. case DehydratedSuspenseComponent:
  17771. {
  17772. if (enableSuspenseServerRenderer) {
  17773. popSuspenseContext(workInProgress);
  17774. if (current === null) {
  17775. var _wasHydrated2 = popHydrationState(workInProgress);
  17776. (function () {
  17777. if (!_wasHydrated2) {
  17778. {
  17779. throw ReactError(Error('A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.'));
  17780. }
  17781. }
  17782. })();
  17783. if (enableSchedulerTracing) {
  17784. markSpawnedWork(Never);
  17785. }
  17786. skipPastDehydratedSuspenseInstance(workInProgress);
  17787. } else if ((workInProgress.effectTag & DidCapture) === NoEffect) {
  17788. // This boundary did not suspend so it's now hydrated.
  17789. // To handle any future suspense cases, we're going to now upgrade it
  17790. // to a Suspense component. We detach it from the existing current fiber.
  17791. current.alternate = null;
  17792. workInProgress.alternate = null;
  17793. workInProgress.tag = SuspenseComponent;
  17794. workInProgress.memoizedState = null;
  17795. workInProgress.stateNode = null;
  17796. }
  17797. }
  17798. break;
  17799. }
  17800. case SuspenseListComponent:
  17801. {
  17802. popSuspenseContext(workInProgress);
  17803. var renderState = workInProgress.memoizedState;
  17804. if (renderState === null) {
  17805. // We're running in the default, "independent" mode. We don't do anything
  17806. // in this mode.
  17807. break;
  17808. }
  17809. var didSuspendAlready = (workInProgress.effectTag & DidCapture) !== NoEffect;
  17810. var renderedTail = renderState.rendering;
  17811. if (renderedTail === null) {
  17812. // We just rendered the head.
  17813. if (!didSuspendAlready) {
  17814. // This is the first pass. We need to figure out if anything is still
  17815. // suspended in the rendered set.
  17816. // If new content unsuspended, but there's still some content that
  17817. // didn't. Then we need to do a second pass that forces everything
  17818. // to keep showing their fallbacks.
  17819. // We might be suspended if something in this render pass suspended, or
  17820. // something in the previous committed pass suspended. Otherwise,
  17821. // there's no chance so we can skip the expensive call to
  17822. // findFirstSuspended.
  17823. var cannotBeSuspended = renderHasNotSuspendedYet() && (current === null || (current.effectTag & DidCapture) === NoEffect);
  17824. if (!cannotBeSuspended) {
  17825. var row = workInProgress.child;
  17826. while (row !== null) {
  17827. var suspended = findFirstSuspended(row);
  17828. if (suspended !== null) {
  17829. didSuspendAlready = true;
  17830. workInProgress.effectTag |= DidCapture;
  17831. cutOffTailIfNeeded(renderState, false);
  17832. // If this is a newly suspended tree, it might not get committed as
  17833. // part of the second pass. In that case nothing will subscribe to
  17834. // its thennables. Instead, we'll transfer its thennables to the
  17835. // SuspenseList so that it can retry if they resolve.
  17836. // There might be multiple of these in the list but since we're
  17837. // going to wait for all of them anyway, it doesn't really matter
  17838. // which ones gets to ping. In theory we could get clever and keep
  17839. // track of how many dependencies remain but it gets tricky because
  17840. // in the meantime, we can add/remove/change items and dependencies.
  17841. // We might bail out of the loop before finding any but that
  17842. // doesn't matter since that means that the other boundaries that
  17843. // we did find already has their listeners attached.
  17844. var newThennables = suspended.updateQueue;
  17845. if (newThennables !== null) {
  17846. workInProgress.updateQueue = newThennables;
  17847. workInProgress.effectTag |= Update;
  17848. }
  17849. // Rerender the whole list, but this time, we'll force fallbacks
  17850. // to stay in place.
  17851. // Reset the effect list before doing the second pass since that's now invalid.
  17852. workInProgress.firstEffect = workInProgress.lastEffect = null;
  17853. // Reset the child fibers to their original state.
  17854. resetChildFibers(workInProgress, renderExpirationTime);
  17855. // Set up the Suspense Context to force suspense and immediately
  17856. // rerender the children.
  17857. pushSuspenseContext(workInProgress, setShallowSuspenseContext(suspenseStackCursor.current, ForceSuspenseFallback));
  17858. return workInProgress.child;
  17859. }
  17860. row = row.sibling;
  17861. }
  17862. }
  17863. } else {
  17864. cutOffTailIfNeeded(renderState, false);
  17865. }
  17866. // Next we're going to render the tail.
  17867. } else {
  17868. // Append the rendered row to the child list.
  17869. if (!didSuspendAlready) {
  17870. var _suspended = findFirstSuspended(renderedTail);
  17871. if (_suspended !== null) {
  17872. workInProgress.effectTag |= DidCapture;
  17873. didSuspendAlready = true;
  17874. cutOffTailIfNeeded(renderState, true);
  17875. // This might have been modified.
  17876. if (renderState.tail === null && renderState.tailMode === 'hidden') {
  17877. // We need to delete the row we just rendered.
  17878. // Ensure we transfer the update queue to the parent.
  17879. var _newThennables = _suspended.updateQueue;
  17880. if (_newThennables !== null) {
  17881. workInProgress.updateQueue = _newThennables;
  17882. workInProgress.effectTag |= Update;
  17883. }
  17884. // Reset the effect list to what it w as before we rendered this
  17885. // child. The nested children have already appended themselves.
  17886. var lastEffect = workInProgress.lastEffect = renderState.lastEffect;
  17887. // Remove any effects that were appended after this point.
  17888. if (lastEffect !== null) {
  17889. lastEffect.nextEffect = null;
  17890. }
  17891. // We're done.
  17892. return null;
  17893. }
  17894. } else if (now() > renderState.tailExpiration && renderExpirationTime > Never) {
  17895. // We have now passed our CPU deadline and we'll just give up further
  17896. // attempts to render the main content and only render fallbacks.
  17897. // The assumption is that this is usually faster.
  17898. workInProgress.effectTag |= DidCapture;
  17899. didSuspendAlready = true;
  17900. cutOffTailIfNeeded(renderState, false);
  17901. // Since nothing actually suspended, there will nothing to ping this
  17902. // to get it started back up to attempt the next item. If we can show
  17903. // them, then they really have the same priority as this render.
  17904. // So we'll pick it back up the very next render pass once we've had
  17905. // an opportunity to yield for paint.
  17906. var nextPriority = renderExpirationTime - 1;
  17907. workInProgress.expirationTime = workInProgress.childExpirationTime = nextPriority;
  17908. if (enableSchedulerTracing) {
  17909. markSpawnedWork(nextPriority);
  17910. }
  17911. }
  17912. }
  17913. if (renderState.isBackwards) {
  17914. // The effect list of the backwards tail will have been added
  17915. // to the end. This breaks the guarantee that life-cycles fire in
  17916. // sibling order but that isn't a strong guarantee promised by React.
  17917. // Especially since these might also just pop in during future commits.
  17918. // Append to the beginning of the list.
  17919. renderedTail.sibling = workInProgress.child;
  17920. workInProgress.child = renderedTail;
  17921. } else {
  17922. var previousSibling = renderState.last;
  17923. if (previousSibling !== null) {
  17924. previousSibling.sibling = renderedTail;
  17925. } else {
  17926. workInProgress.child = renderedTail;
  17927. }
  17928. renderState.last = renderedTail;
  17929. }
  17930. }
  17931. if (renderState.tail !== null) {
  17932. // We still have tail rows to render.
  17933. if (renderState.tailExpiration === 0) {
  17934. // Heuristic for how long we're willing to spend rendering rows
  17935. // until we just give up and show what we have so far.
  17936. var TAIL_EXPIRATION_TIMEOUT_MS = 500;
  17937. renderState.tailExpiration = now() + TAIL_EXPIRATION_TIMEOUT_MS;
  17938. }
  17939. // Pop a row.
  17940. var next = renderState.tail;
  17941. renderState.rendering = next;
  17942. renderState.tail = next.sibling;
  17943. renderState.lastEffect = workInProgress.lastEffect;
  17944. next.sibling = null;
  17945. // Restore the context.
  17946. // TODO: We can probably just avoid popping it instead and only
  17947. // setting it the first time we go from not suspended to suspended.
  17948. var suspenseContext = suspenseStackCursor.current;
  17949. if (didSuspendAlready) {
  17950. suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
  17951. } else {
  17952. suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
  17953. }
  17954. pushSuspenseContext(workInProgress, suspenseContext);
  17955. // Do a pass over the next row.
  17956. return next;
  17957. }
  17958. break;
  17959. }
  17960. case FundamentalComponent:
  17961. {
  17962. if (enableFundamentalAPI) {
  17963. var fundamentalImpl = workInProgress.type.impl;
  17964. var fundamentalInstance = workInProgress.stateNode;
  17965. if (fundamentalInstance === null) {
  17966. var getInitialState = fundamentalImpl.getInitialState;
  17967. var fundamentalState = void 0;
  17968. if (getInitialState !== undefined) {
  17969. fundamentalState = getInitialState(newProps);
  17970. }
  17971. fundamentalInstance = workInProgress.stateNode = createFundamentalStateInstance(workInProgress, newProps, fundamentalImpl, fundamentalState || {});
  17972. var _instance6 = getFundamentalComponentInstance(fundamentalInstance);
  17973. fundamentalInstance.instance = _instance6;
  17974. if (fundamentalImpl.reconcileChildren === false) {
  17975. return null;
  17976. }
  17977. appendAllChildren(_instance6, workInProgress, false, false);
  17978. mountFundamentalComponent(fundamentalInstance);
  17979. } else {
  17980. // We fire update in commit phase
  17981. var prevProps = fundamentalInstance.props;
  17982. fundamentalInstance.prevProps = prevProps;
  17983. fundamentalInstance.props = newProps;
  17984. fundamentalInstance.currentFiber = workInProgress;
  17985. if (supportsPersistence) {
  17986. var _instance7 = cloneFundamentalInstance(fundamentalInstance);
  17987. fundamentalInstance.instance = _instance7;
  17988. appendAllChildren(_instance7, workInProgress, false, false);
  17989. }
  17990. var shouldUpdate = shouldUpdateFundamentalComponent(fundamentalInstance);
  17991. if (shouldUpdate) {
  17992. markUpdate(workInProgress);
  17993. }
  17994. }
  17995. }
  17996. break;
  17997. }
  17998. default:
  17999. (function () {
  18000. {
  18001. {
  18002. throw ReactError(Error('Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue.'));
  18003. }
  18004. }
  18005. })();
  18006. }
  18007. return null;
  18008. }
  18009. function mountEventResponder$1(responder, responderProps, instance, rootContainerInstance, fiber, respondersMap) {
  18010. var responderState = emptyObject;
  18011. var getInitialState = responder.getInitialState;
  18012. if (getInitialState !== null) {
  18013. responderState = getInitialState(responderProps);
  18014. }
  18015. var responderInstance = createResponderInstance(responder, responderProps, responderState, instance, fiber);
  18016. mountResponderInstance(responder, responderInstance, responderProps, responderState, instance, rootContainerInstance);
  18017. respondersMap.set(responder, responderInstance);
  18018. }
  18019. function updateEventListener(listener, fiber, visistedResponders, respondersMap, instance, rootContainerInstance) {
  18020. var responder = void 0;
  18021. var props = void 0;
  18022. if (listener) {
  18023. responder = listener.responder;
  18024. props = listener.props;
  18025. }
  18026. (function () {
  18027. if (!(responder && responder.$$typeof === REACT_RESPONDER_TYPE)) {
  18028. {
  18029. throw ReactError(Error('An invalid value was used as an event listener. Expect one or many event listeners created via React.unstable_useResponer().'));
  18030. }
  18031. }
  18032. })();
  18033. var listenerProps = props;
  18034. if (visistedResponders.has(responder)) {
  18035. // show warning
  18036. {
  18037. warning$1(false, 'Duplicate event responder "%s" found in event listeners. ' + 'Event listeners passed to elements cannot use the same event responder more than once.', responder.displayName);
  18038. }
  18039. return;
  18040. }
  18041. visistedResponders.add(responder);
  18042. var responderInstance = respondersMap.get(responder);
  18043. if (responderInstance === undefined) {
  18044. // Mount
  18045. mountEventResponder$1(responder, listenerProps, instance, rootContainerInstance, fiber, respondersMap);
  18046. } else {
  18047. // Update
  18048. responderInstance.props = listenerProps;
  18049. responderInstance.fiber = fiber;
  18050. }
  18051. }
  18052. function updateEventListeners(listeners, instance, rootContainerInstance, fiber) {
  18053. var visistedResponders = new Set();
  18054. var dependencies = fiber.dependencies;
  18055. if (listeners != null) {
  18056. if (dependencies === null) {
  18057. dependencies = fiber.dependencies = {
  18058. expirationTime: NoWork,
  18059. firstContext: null,
  18060. responders: new Map()
  18061. };
  18062. }
  18063. var respondersMap = dependencies.responders;
  18064. if (respondersMap === null) {
  18065. respondersMap = new Map();
  18066. }
  18067. if (isArray$2(listeners)) {
  18068. for (var i = 0, length = listeners.length; i < length; i++) {
  18069. var listener = listeners[i];
  18070. updateEventListener(listener, fiber, visistedResponders, respondersMap, instance, rootContainerInstance);
  18071. }
  18072. } else {
  18073. updateEventListener(listeners, fiber, visistedResponders, respondersMap, instance, rootContainerInstance);
  18074. }
  18075. }
  18076. if (dependencies !== null) {
  18077. var _respondersMap = dependencies.responders;
  18078. if (_respondersMap !== null) {
  18079. // Unmount
  18080. var mountedResponders = Array.from(_respondersMap.keys());
  18081. for (var _i = 0, _length = mountedResponders.length; _i < _length; _i++) {
  18082. var mountedResponder = mountedResponders[_i];
  18083. if (!visistedResponders.has(mountedResponder)) {
  18084. var responderInstance = _respondersMap.get(mountedResponder);
  18085. unmountResponderInstance(responderInstance);
  18086. _respondersMap.delete(mountedResponder);
  18087. }
  18088. }
  18089. }
  18090. }
  18091. }
  18092. function unwindWork(workInProgress, renderExpirationTime) {
  18093. switch (workInProgress.tag) {
  18094. case ClassComponent:
  18095. {
  18096. var Component = workInProgress.type;
  18097. if (isContextProvider(Component)) {
  18098. popContext(workInProgress);
  18099. }
  18100. var effectTag = workInProgress.effectTag;
  18101. if (effectTag & ShouldCapture) {
  18102. workInProgress.effectTag = effectTag & ~ShouldCapture | DidCapture;
  18103. return workInProgress;
  18104. }
  18105. return null;
  18106. }
  18107. case HostRoot:
  18108. {
  18109. popHostContainer(workInProgress);
  18110. popTopLevelContextObject(workInProgress);
  18111. var _effectTag = workInProgress.effectTag;
  18112. (function () {
  18113. if (!((_effectTag & DidCapture) === NoEffect)) {
  18114. {
  18115. throw ReactError(Error('The root failed to unmount after an error. This is likely a bug in React. Please file an issue.'));
  18116. }
  18117. }
  18118. })();
  18119. workInProgress.effectTag = _effectTag & ~ShouldCapture | DidCapture;
  18120. return workInProgress;
  18121. }
  18122. case HostComponent:
  18123. {
  18124. // TODO: popHydrationState
  18125. popHostContext(workInProgress);
  18126. return null;
  18127. }
  18128. case SuspenseComponent:
  18129. {
  18130. popSuspenseContext(workInProgress);
  18131. var _effectTag2 = workInProgress.effectTag;
  18132. if (_effectTag2 & ShouldCapture) {
  18133. workInProgress.effectTag = _effectTag2 & ~ShouldCapture | DidCapture;
  18134. // Captured a suspense effect. Re-render the boundary.
  18135. return workInProgress;
  18136. }
  18137. return null;
  18138. }
  18139. case DehydratedSuspenseComponent:
  18140. {
  18141. if (enableSuspenseServerRenderer) {
  18142. // TODO: popHydrationState
  18143. popSuspenseContext(workInProgress);
  18144. var _effectTag3 = workInProgress.effectTag;
  18145. if (_effectTag3 & ShouldCapture) {
  18146. workInProgress.effectTag = _effectTag3 & ~ShouldCapture | DidCapture;
  18147. // Captured a suspense effect. Re-render the boundary.
  18148. return workInProgress;
  18149. }
  18150. }
  18151. return null;
  18152. }
  18153. case SuspenseListComponent:
  18154. {
  18155. popSuspenseContext(workInProgress);
  18156. // SuspenseList doesn't actually catch anything. It should've been
  18157. // caught by a nested boundary. If not, it should bubble through.
  18158. return null;
  18159. }
  18160. case HostPortal:
  18161. popHostContainer(workInProgress);
  18162. return null;
  18163. case ContextProvider:
  18164. popProvider(workInProgress);
  18165. return null;
  18166. default:
  18167. return null;
  18168. }
  18169. }
  18170. function unwindInterruptedWork(interruptedWork) {
  18171. switch (interruptedWork.tag) {
  18172. case ClassComponent:
  18173. {
  18174. var childContextTypes = interruptedWork.type.childContextTypes;
  18175. if (childContextTypes !== null && childContextTypes !== undefined) {
  18176. popContext(interruptedWork);
  18177. }
  18178. break;
  18179. }
  18180. case HostRoot:
  18181. {
  18182. popHostContainer(interruptedWork);
  18183. popTopLevelContextObject(interruptedWork);
  18184. break;
  18185. }
  18186. case HostComponent:
  18187. {
  18188. popHostContext(interruptedWork);
  18189. break;
  18190. }
  18191. case HostPortal:
  18192. popHostContainer(interruptedWork);
  18193. break;
  18194. case SuspenseComponent:
  18195. popSuspenseContext(interruptedWork);
  18196. break;
  18197. case DehydratedSuspenseComponent:
  18198. if (enableSuspenseServerRenderer) {
  18199. // TODO: popHydrationState
  18200. popSuspenseContext(interruptedWork);
  18201. }
  18202. break;
  18203. case SuspenseListComponent:
  18204. popSuspenseContext(interruptedWork);
  18205. break;
  18206. case ContextProvider:
  18207. popProvider(interruptedWork);
  18208. break;
  18209. default:
  18210. break;
  18211. }
  18212. }
  18213. function createCapturedValue(value, source) {
  18214. // If the value is an error, call this function immediately after it is thrown
  18215. // so the stack is accurate.
  18216. return {
  18217. value: value,
  18218. source: source,
  18219. stack: getStackByFiberInDevAndProd(source)
  18220. };
  18221. }
  18222. // This module is forked in different environments.
  18223. // By default, return `true` to log errors to the console.
  18224. // Forks can return `false` if this isn't desirable.
  18225. function showErrorDialog(capturedError) {
  18226. return true;
  18227. }
  18228. function logCapturedError(capturedError) {
  18229. var logError = showErrorDialog(capturedError);
  18230. // Allow injected showErrorDialog() to prevent default console.error logging.
  18231. // This enables renderers like ReactNative to better manage redbox behavior.
  18232. if (logError === false) {
  18233. return;
  18234. }
  18235. var error = capturedError.error;
  18236. {
  18237. var componentName = capturedError.componentName,
  18238. componentStack = capturedError.componentStack,
  18239. errorBoundaryName = capturedError.errorBoundaryName,
  18240. errorBoundaryFound = capturedError.errorBoundaryFound,
  18241. willRetry = capturedError.willRetry;
  18242. // Browsers support silencing uncaught errors by calling
  18243. // `preventDefault()` in window `error` handler.
  18244. // We record this information as an expando on the error.
  18245. if (error != null && error._suppressLogging) {
  18246. if (errorBoundaryFound && willRetry) {
  18247. // The error is recoverable and was silenced.
  18248. // Ignore it and don't print the stack addendum.
  18249. // This is handy for testing error boundaries without noise.
  18250. return;
  18251. }
  18252. // The error is fatal. Since the silencing might have
  18253. // been accidental, we'll surface it anyway.
  18254. // However, the browser would have silenced the original error
  18255. // so we'll print it first, and then print the stack addendum.
  18256. console.error(error);
  18257. // For a more detailed description of this block, see:
  18258. // https://github.com/facebook/react/pull/13384
  18259. }
  18260. var componentNameMessage = componentName ? 'The above error occurred in the <' + componentName + '> component:' : 'The above error occurred in one of your React components:';
  18261. var errorBoundaryMessage = void 0;
  18262. // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow.
  18263. if (errorBoundaryFound && errorBoundaryName) {
  18264. if (willRetry) {
  18265. errorBoundaryMessage = 'React will try to recreate this component tree from scratch ' + ('using the error boundary you provided, ' + errorBoundaryName + '.');
  18266. } else {
  18267. errorBoundaryMessage = 'This error was initially handled by the error boundary ' + errorBoundaryName + '.\n' + 'Recreating the tree from scratch failed so React will unmount the tree.';
  18268. }
  18269. } else {
  18270. 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.';
  18271. }
  18272. var combinedMessage = '' + componentNameMessage + componentStack + '\n\n' + ('' + errorBoundaryMessage);
  18273. // In development, we provide our own message with just the component stack.
  18274. // We don't include the original error message and JS stack because the browser
  18275. // has already printed it. Even if the application swallows the error, it is still
  18276. // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils.
  18277. console.error(combinedMessage);
  18278. }
  18279. }
  18280. var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
  18281. {
  18282. didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
  18283. }
  18284. var PossiblyWeakSet$1 = typeof WeakSet === 'function' ? WeakSet : Set;
  18285. function logError(boundary, errorInfo) {
  18286. var source = errorInfo.source;
  18287. var stack = errorInfo.stack;
  18288. if (stack === null && source !== null) {
  18289. stack = getStackByFiberInDevAndProd(source);
  18290. }
  18291. var capturedError = {
  18292. componentName: source !== null ? getComponentName(source.type) : null,
  18293. componentStack: stack !== null ? stack : '',
  18294. error: errorInfo.value,
  18295. errorBoundary: null,
  18296. errorBoundaryName: null,
  18297. errorBoundaryFound: false,
  18298. willRetry: false
  18299. };
  18300. if (boundary !== null && boundary.tag === ClassComponent) {
  18301. capturedError.errorBoundary = boundary.stateNode;
  18302. capturedError.errorBoundaryName = getComponentName(boundary.type);
  18303. capturedError.errorBoundaryFound = true;
  18304. capturedError.willRetry = true;
  18305. }
  18306. try {
  18307. logCapturedError(capturedError);
  18308. } catch (e) {
  18309. // This method must not throw, or React internal state will get messed up.
  18310. // If console.error is overridden, or logCapturedError() shows a dialog that throws,
  18311. // we want to report this error outside of the normal stack as a last resort.
  18312. // https://github.com/facebook/react/issues/13188
  18313. setTimeout(function () {
  18314. throw e;
  18315. });
  18316. }
  18317. }
  18318. var callComponentWillUnmountWithTimer = function (current$$1, instance) {
  18319. startPhaseTimer(current$$1, 'componentWillUnmount');
  18320. instance.props = current$$1.memoizedProps;
  18321. instance.state = current$$1.memoizedState;
  18322. instance.componentWillUnmount();
  18323. stopPhaseTimer();
  18324. };
  18325. // Capture errors so they don't interrupt unmounting.
  18326. function safelyCallComponentWillUnmount(current$$1, instance) {
  18327. {
  18328. invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current$$1, instance);
  18329. if (hasCaughtError()) {
  18330. var unmountError = clearCaughtError();
  18331. captureCommitPhaseError(current$$1, unmountError);
  18332. }
  18333. }
  18334. }
  18335. function safelyDetachRef(current$$1) {
  18336. var ref = current$$1.ref;
  18337. if (ref !== null) {
  18338. if (typeof ref === 'function') {
  18339. {
  18340. invokeGuardedCallback(null, ref, null, null);
  18341. if (hasCaughtError()) {
  18342. var refError = clearCaughtError();
  18343. captureCommitPhaseError(current$$1, refError);
  18344. }
  18345. }
  18346. } else {
  18347. ref.current = null;
  18348. }
  18349. }
  18350. }
  18351. function safelyCallDestroy(current$$1, destroy) {
  18352. {
  18353. invokeGuardedCallback(null, destroy, null);
  18354. if (hasCaughtError()) {
  18355. var error = clearCaughtError();
  18356. captureCommitPhaseError(current$$1, error);
  18357. }
  18358. }
  18359. }
  18360. function commitBeforeMutationLifeCycles(current$$1, finishedWork) {
  18361. switch (finishedWork.tag) {
  18362. case FunctionComponent:
  18363. case ForwardRef:
  18364. case SimpleMemoComponent:
  18365. {
  18366. commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork);
  18367. return;
  18368. }
  18369. case ClassComponent:
  18370. {
  18371. if (finishedWork.effectTag & Snapshot) {
  18372. if (current$$1 !== null) {
  18373. var prevProps = current$$1.memoizedProps;
  18374. var prevState = current$$1.memoizedState;
  18375. startPhaseTimer(finishedWork, 'getSnapshotBeforeUpdate');
  18376. var instance = finishedWork.stateNode;
  18377. // We could update instance props and state here,
  18378. // but instead we rely on them being set during last render.
  18379. // TODO: revisit this when we implement resuming.
  18380. {
  18381. if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
  18382. !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
  18383. !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
  18384. }
  18385. }
  18386. var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState);
  18387. {
  18388. var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate;
  18389. if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
  18390. didWarnSet.add(finishedWork.type);
  18391. warningWithoutStack$1(false, '%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork.type));
  18392. }
  18393. }
  18394. instance.__reactInternalSnapshotBeforeUpdate = snapshot;
  18395. stopPhaseTimer();
  18396. }
  18397. }
  18398. return;
  18399. }
  18400. case HostRoot:
  18401. case HostComponent:
  18402. case HostText:
  18403. case HostPortal:
  18404. case IncompleteClassComponent:
  18405. // Nothing to do for these component types
  18406. return;
  18407. default:
  18408. {
  18409. (function () {
  18410. {
  18411. {
  18412. throw ReactError(Error('This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.'));
  18413. }
  18414. }
  18415. })();
  18416. }
  18417. }
  18418. }
  18419. function commitHookEffectList(unmountTag, mountTag, finishedWork) {
  18420. var updateQueue = finishedWork.updateQueue;
  18421. var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
  18422. if (lastEffect !== null) {
  18423. var firstEffect = lastEffect.next;
  18424. var effect = firstEffect;
  18425. do {
  18426. if ((effect.tag & unmountTag) !== NoEffect$1) {
  18427. // Unmount
  18428. var destroy = effect.destroy;
  18429. effect.destroy = undefined;
  18430. if (destroy !== undefined) {
  18431. destroy();
  18432. }
  18433. }
  18434. if ((effect.tag & mountTag) !== NoEffect$1) {
  18435. // Mount
  18436. var create = effect.create;
  18437. effect.destroy = create();
  18438. {
  18439. var _destroy = effect.destroy;
  18440. if (_destroy !== undefined && typeof _destroy !== 'function') {
  18441. var addendum = void 0;
  18442. if (_destroy === null) {
  18443. addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).';
  18444. } else if (typeof _destroy.then === 'function') {
  18445. addendum = '\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. ' + 'Instead, write the async function inside your effect ' + 'and call it immediately:\n\n' + 'useEffect(() => {\n' + ' async function fetchData() {\n' + ' // You can await here\n' + ' const response = await MyAPI.getData(someId);\n' + ' // ...\n' + ' }\n' + ' fetchData();\n' + '}, [someId]); // Or [] if effect doesn\'t need props or state\n\n' + 'Learn more about data fetching with Hooks: https://fb.me/react-hooks-data-fetching';
  18446. } else {
  18447. addendum = ' You returned: ' + _destroy;
  18448. }
  18449. warningWithoutStack$1(false, 'An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
  18450. }
  18451. }
  18452. }
  18453. effect = effect.next;
  18454. } while (effect !== firstEffect);
  18455. }
  18456. }
  18457. function commitPassiveHookEffects(finishedWork) {
  18458. if ((finishedWork.effectTag & Passive) !== NoEffect) {
  18459. switch (finishedWork.tag) {
  18460. case FunctionComponent:
  18461. case ForwardRef:
  18462. case SimpleMemoComponent:
  18463. {
  18464. commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork);
  18465. commitHookEffectList(NoEffect$1, MountPassive, finishedWork);
  18466. break;
  18467. }
  18468. default:
  18469. break;
  18470. }
  18471. }
  18472. }
  18473. function commitLifeCycles(finishedRoot, current$$1, finishedWork, committedExpirationTime) {
  18474. switch (finishedWork.tag) {
  18475. case FunctionComponent:
  18476. case ForwardRef:
  18477. case SimpleMemoComponent:
  18478. {
  18479. commitHookEffectList(UnmountLayout, MountLayout, finishedWork);
  18480. break;
  18481. }
  18482. case ClassComponent:
  18483. {
  18484. var instance = finishedWork.stateNode;
  18485. if (finishedWork.effectTag & Update) {
  18486. if (current$$1 === null) {
  18487. startPhaseTimer(finishedWork, 'componentDidMount');
  18488. // We could update instance props and state here,
  18489. // but instead we rely on them being set during last render.
  18490. // TODO: revisit this when we implement resuming.
  18491. {
  18492. if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
  18493. !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
  18494. !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'componentDidMount. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
  18495. }
  18496. }
  18497. instance.componentDidMount();
  18498. stopPhaseTimer();
  18499. } else {
  18500. var prevProps = finishedWork.elementType === finishedWork.type ? current$$1.memoizedProps : resolveDefaultProps(finishedWork.type, current$$1.memoizedProps);
  18501. var prevState = current$$1.memoizedState;
  18502. startPhaseTimer(finishedWork, 'componentDidUpdate');
  18503. // We could update instance props and state here,
  18504. // but instead we rely on them being set during last render.
  18505. // TODO: revisit this when we implement resuming.
  18506. {
  18507. if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
  18508. !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
  18509. !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'componentDidUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
  18510. }
  18511. }
  18512. instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate);
  18513. stopPhaseTimer();
  18514. }
  18515. }
  18516. var updateQueue = finishedWork.updateQueue;
  18517. if (updateQueue !== null) {
  18518. {
  18519. if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
  18520. !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
  18521. !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'processing the update queue. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0;
  18522. }
  18523. }
  18524. // We could update instance props and state here,
  18525. // but instead we rely on them being set during last render.
  18526. // TODO: revisit this when we implement resuming.
  18527. commitUpdateQueue(finishedWork, updateQueue, instance, committedExpirationTime);
  18528. }
  18529. return;
  18530. }
  18531. case HostRoot:
  18532. {
  18533. var _updateQueue = finishedWork.updateQueue;
  18534. if (_updateQueue !== null) {
  18535. var _instance = null;
  18536. if (finishedWork.child !== null) {
  18537. switch (finishedWork.child.tag) {
  18538. case HostComponent:
  18539. _instance = getPublicInstance(finishedWork.child.stateNode);
  18540. break;
  18541. case ClassComponent:
  18542. _instance = finishedWork.child.stateNode;
  18543. break;
  18544. }
  18545. }
  18546. commitUpdateQueue(finishedWork, _updateQueue, _instance, committedExpirationTime);
  18547. }
  18548. return;
  18549. }
  18550. case HostComponent:
  18551. {
  18552. var _instance2 = finishedWork.stateNode;
  18553. // Renderers may schedule work to be done after host components are mounted
  18554. // (eg DOM renderer may schedule auto-focus for inputs and form controls).
  18555. // These effects should only be committed when components are first mounted,
  18556. // aka when there is no current/alternate.
  18557. if (current$$1 === null && finishedWork.effectTag & Update) {
  18558. var type = finishedWork.type;
  18559. var props = finishedWork.memoizedProps;
  18560. commitMount(_instance2, type, props, finishedWork);
  18561. }
  18562. return;
  18563. }
  18564. case HostText:
  18565. {
  18566. // We have no life-cycles associated with text.
  18567. return;
  18568. }
  18569. case HostPortal:
  18570. {
  18571. // We have no life-cycles associated with portals.
  18572. return;
  18573. }
  18574. case Profiler:
  18575. {
  18576. if (enableProfilerTimer) {
  18577. var onRender = finishedWork.memoizedProps.onRender;
  18578. if (typeof onRender === 'function') {
  18579. if (enableSchedulerTracing) {
  18580. onRender(finishedWork.memoizedProps.id, current$$1 === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime(), finishedRoot.memoizedInteractions);
  18581. } else {
  18582. onRender(finishedWork.memoizedProps.id, current$$1 === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, getCommitTime());
  18583. }
  18584. }
  18585. }
  18586. return;
  18587. }
  18588. case SuspenseComponent:
  18589. case SuspenseListComponent:
  18590. case IncompleteClassComponent:
  18591. case FundamentalComponent:
  18592. return;
  18593. default:
  18594. {
  18595. (function () {
  18596. {
  18597. {
  18598. throw ReactError(Error('This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.'));
  18599. }
  18600. }
  18601. })();
  18602. }
  18603. }
  18604. }
  18605. function hideOrUnhideAllChildren(finishedWork, isHidden) {
  18606. if (supportsMutation) {
  18607. // We only have the top Fiber that was inserted but we need to recurse down its
  18608. var node = finishedWork;
  18609. while (true) {
  18610. if (node.tag === HostComponent) {
  18611. var instance = node.stateNode;
  18612. if (isHidden) {
  18613. hideInstance(instance);
  18614. } else {
  18615. unhideInstance(node.stateNode, node.memoizedProps);
  18616. }
  18617. } else if (node.tag === HostText) {
  18618. var _instance3 = node.stateNode;
  18619. if (isHidden) {
  18620. hideTextInstance(_instance3);
  18621. } else {
  18622. unhideTextInstance(_instance3, node.memoizedProps);
  18623. }
  18624. } else if (node.tag === SuspenseComponent && node.memoizedState !== null) {
  18625. // Found a nested Suspense component that timed out. Skip over the
  18626. var fallbackChildFragment = node.child.sibling;
  18627. fallbackChildFragment.return = node;
  18628. node = fallbackChildFragment;
  18629. continue;
  18630. } else if (node.child !== null) {
  18631. node.child.return = node;
  18632. node = node.child;
  18633. continue;
  18634. }
  18635. if (node === finishedWork) {
  18636. return;
  18637. }
  18638. while (node.sibling === null) {
  18639. if (node.return === null || node.return === finishedWork) {
  18640. return;
  18641. }
  18642. node = node.return;
  18643. }
  18644. node.sibling.return = node.return;
  18645. node = node.sibling;
  18646. }
  18647. }
  18648. }
  18649. function commitAttachRef(finishedWork) {
  18650. var ref = finishedWork.ref;
  18651. if (ref !== null) {
  18652. var instance = finishedWork.stateNode;
  18653. var instanceToUse = void 0;
  18654. switch (finishedWork.tag) {
  18655. case HostComponent:
  18656. instanceToUse = getPublicInstance(instance);
  18657. break;
  18658. default:
  18659. instanceToUse = instance;
  18660. }
  18661. if (typeof ref === 'function') {
  18662. ref(instanceToUse);
  18663. } else {
  18664. {
  18665. if (!ref.hasOwnProperty('current')) {
  18666. warningWithoutStack$1(false, 'Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().%s', getComponentName(finishedWork.type), getStackByFiberInDevAndProd(finishedWork));
  18667. }
  18668. }
  18669. ref.current = instanceToUse;
  18670. }
  18671. }
  18672. }
  18673. function commitDetachRef(current$$1) {
  18674. var currentRef = current$$1.ref;
  18675. if (currentRef !== null) {
  18676. if (typeof currentRef === 'function') {
  18677. currentRef(null);
  18678. } else {
  18679. currentRef.current = null;
  18680. }
  18681. }
  18682. }
  18683. // User-originating errors (lifecycles and refs) should not interrupt
  18684. // deletion, so don't let them throw. Host-originating errors should
  18685. // interrupt deletion, so it's okay
  18686. function commitUnmount(current$$1, renderPriorityLevel) {
  18687. onCommitUnmount(current$$1);
  18688. switch (current$$1.tag) {
  18689. case FunctionComponent:
  18690. case ForwardRef:
  18691. case MemoComponent:
  18692. case SimpleMemoComponent:
  18693. {
  18694. var updateQueue = current$$1.updateQueue;
  18695. if (updateQueue !== null) {
  18696. var lastEffect = updateQueue.lastEffect;
  18697. if (lastEffect !== null) {
  18698. var firstEffect = lastEffect.next;
  18699. // When the owner fiber is deleted, the destroy function of a passive
  18700. // effect hook is called during the synchronous commit phase. This is
  18701. // a concession to implementation complexity. Calling it in the
  18702. // passive effect phase (like they usually are, when dependencies
  18703. // change during an update) would require either traversing the
  18704. // children of the deleted fiber again, or including unmount effects
  18705. // as part of the fiber effect list.
  18706. //
  18707. // Because this is during the sync commit phase, we need to change
  18708. // the priority.
  18709. //
  18710. // TODO: Reconsider this implementation trade off.
  18711. var priorityLevel = renderPriorityLevel > NormalPriority ? NormalPriority : renderPriorityLevel;
  18712. runWithPriority$2(priorityLevel, function () {
  18713. var effect = firstEffect;
  18714. do {
  18715. var destroy = effect.destroy;
  18716. if (destroy !== undefined) {
  18717. safelyCallDestroy(current$$1, destroy);
  18718. }
  18719. effect = effect.next;
  18720. } while (effect !== firstEffect);
  18721. });
  18722. }
  18723. }
  18724. break;
  18725. }
  18726. case ClassComponent:
  18727. {
  18728. safelyDetachRef(current$$1);
  18729. var instance = current$$1.stateNode;
  18730. if (typeof instance.componentWillUnmount === 'function') {
  18731. safelyCallComponentWillUnmount(current$$1, instance);
  18732. }
  18733. return;
  18734. }
  18735. case HostComponent:
  18736. {
  18737. if (enableFlareAPI) {
  18738. var dependencies = current$$1.dependencies;
  18739. if (dependencies !== null) {
  18740. var respondersMap = dependencies.responders;
  18741. if (respondersMap !== null) {
  18742. var responderInstances = Array.from(respondersMap.values());
  18743. for (var i = 0, length = responderInstances.length; i < length; i++) {
  18744. var responderInstance = responderInstances[i];
  18745. unmountResponderInstance(responderInstance);
  18746. }
  18747. dependencies.responders = null;
  18748. }
  18749. }
  18750. }
  18751. safelyDetachRef(current$$1);
  18752. return;
  18753. }
  18754. case HostPortal:
  18755. {
  18756. // TODO: this is recursive.
  18757. // We are also not using this parent because
  18758. // the portal will get pushed immediately.
  18759. if (supportsMutation) {
  18760. unmountHostComponents(current$$1, renderPriorityLevel);
  18761. } else if (supportsPersistence) {
  18762. emptyPortalContainer(current$$1);
  18763. }
  18764. return;
  18765. }
  18766. case FundamentalComponent:
  18767. {
  18768. if (enableFundamentalAPI) {
  18769. var fundamentalInstance = current$$1.stateNode;
  18770. if (fundamentalInstance !== null) {
  18771. unmountFundamentalComponent(fundamentalInstance);
  18772. current$$1.stateNode = null;
  18773. }
  18774. }
  18775. }
  18776. }
  18777. }
  18778. function commitNestedUnmounts(root, renderPriorityLevel) {
  18779. // While we're inside a removed host node we don't want to call
  18780. // removeChild on the inner nodes because they're removed by the top
  18781. // call anyway. We also want to call componentWillUnmount on all
  18782. // composites before this host node is removed from the tree. Therefore
  18783. var node = root;
  18784. while (true) {
  18785. commitUnmount(node, renderPriorityLevel);
  18786. // Visit children because they may contain more composite or host nodes.
  18787. // Skip portals because commitUnmount() currently visits them recursively.
  18788. if (node.child !== null && (
  18789. // If we use mutation we drill down into portals using commitUnmount above.
  18790. // If we don't use mutation we drill down into portals here instead.
  18791. !supportsMutation || node.tag !== HostPortal)) {
  18792. node.child.return = node;
  18793. node = node.child;
  18794. continue;
  18795. }
  18796. if (node === root) {
  18797. return;
  18798. }
  18799. while (node.sibling === null) {
  18800. if (node.return === null || node.return === root) {
  18801. return;
  18802. }
  18803. node = node.return;
  18804. }
  18805. node.sibling.return = node.return;
  18806. node = node.sibling;
  18807. }
  18808. }
  18809. function detachFiber(current$$1) {
  18810. // Cut off the return pointers to disconnect it from the tree. Ideally, we
  18811. // should clear the child pointer of the parent alternate to let this
  18812. // get GC:ed but we don't know which for sure which parent is the current
  18813. // one so we'll settle for GC:ing the subtree of this child. This child
  18814. // itself will be GC:ed when the parent updates the next time.
  18815. current$$1.return = null;
  18816. current$$1.child = null;
  18817. current$$1.memoizedState = null;
  18818. current$$1.updateQueue = null;
  18819. current$$1.dependencies = null;
  18820. var alternate = current$$1.alternate;
  18821. if (alternate !== null) {
  18822. alternate.return = null;
  18823. alternate.child = null;
  18824. alternate.memoizedState = null;
  18825. alternate.updateQueue = null;
  18826. alternate.dependencies = null;
  18827. }
  18828. }
  18829. function emptyPortalContainer(current$$1) {
  18830. if (!supportsPersistence) {
  18831. return;
  18832. }
  18833. var portal = current$$1.stateNode;
  18834. var containerInfo = portal.containerInfo;
  18835. var emptyChildSet = createContainerChildSet(containerInfo);
  18836. replaceContainerChildren(containerInfo, emptyChildSet);
  18837. }
  18838. function commitContainer(finishedWork) {
  18839. if (!supportsPersistence) {
  18840. return;
  18841. }
  18842. switch (finishedWork.tag) {
  18843. case ClassComponent:
  18844. case HostComponent:
  18845. case HostText:
  18846. case FundamentalComponent:
  18847. {
  18848. return;
  18849. }
  18850. case HostRoot:
  18851. case HostPortal:
  18852. {
  18853. var portalOrRoot = finishedWork.stateNode;
  18854. var containerInfo = portalOrRoot.containerInfo,
  18855. _pendingChildren = portalOrRoot.pendingChildren;
  18856. replaceContainerChildren(containerInfo, _pendingChildren);
  18857. return;
  18858. }
  18859. default:
  18860. {
  18861. (function () {
  18862. {
  18863. {
  18864. throw ReactError(Error('This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.'));
  18865. }
  18866. }
  18867. })();
  18868. }
  18869. }
  18870. }
  18871. function getHostParentFiber(fiber) {
  18872. var parent = fiber.return;
  18873. while (parent !== null) {
  18874. if (isHostParent(parent)) {
  18875. return parent;
  18876. }
  18877. parent = parent.return;
  18878. }
  18879. (function () {
  18880. {
  18881. {
  18882. throw ReactError(Error('Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.'));
  18883. }
  18884. }
  18885. })();
  18886. }
  18887. function isHostParent(fiber) {
  18888. return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal;
  18889. }
  18890. function getHostSibling(fiber) {
  18891. // We're going to search forward into the tree until we find a sibling host
  18892. // node. Unfortunately, if multiple insertions are done in a row we have to
  18893. // search past them. This leads to exponential search for the next sibling.
  18894. var node = fiber;
  18895. siblings: while (true) {
  18896. // If we didn't find anything, let's try the next sibling.
  18897. while (node.sibling === null) {
  18898. if (node.return === null || isHostParent(node.return)) {
  18899. // If we pop out of the root or hit the parent the fiber we are the
  18900. // last sibling.
  18901. return null;
  18902. }
  18903. node = node.return;
  18904. }
  18905. node.sibling.return = node.return;
  18906. node = node.sibling;
  18907. while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedSuspenseComponent) {
  18908. // If it is not host node and, we might have a host node inside it.
  18909. // Try to search down until we find one.
  18910. if (node.effectTag & Placement) {
  18911. // If we don't have a child, try the siblings instead.
  18912. continue siblings;
  18913. }
  18914. // If we don't have a child, try the siblings instead.
  18915. // We also skip portals because they are not part of this host tree.
  18916. if (node.child === null || node.tag === HostPortal) {
  18917. continue siblings;
  18918. } else {
  18919. node.child.return = node;
  18920. node = node.child;
  18921. }
  18922. }
  18923. // Check if this host node is stable or about to be placed.
  18924. if (!(node.effectTag & Placement)) {
  18925. // Found it!
  18926. return node.stateNode;
  18927. }
  18928. }
  18929. }
  18930. function commitPlacement(finishedWork) {
  18931. if (!supportsMutation) {
  18932. return;
  18933. }
  18934. // Recursively insert all host nodes into the parent.
  18935. var parentFiber = getHostParentFiber(finishedWork);
  18936. // Note: these two variables *must* always be updated together.
  18937. var parent = void 0;
  18938. var isContainer = void 0;
  18939. var parentStateNode = parentFiber.stateNode;
  18940. switch (parentFiber.tag) {
  18941. case HostComponent:
  18942. parent = parentStateNode;
  18943. isContainer = false;
  18944. break;
  18945. case HostRoot:
  18946. parent = parentStateNode.containerInfo;
  18947. isContainer = true;
  18948. break;
  18949. case HostPortal:
  18950. parent = parentStateNode.containerInfo;
  18951. isContainer = true;
  18952. break;
  18953. case FundamentalComponent:
  18954. if (enableFundamentalAPI) {
  18955. parent = parentStateNode.instance;
  18956. isContainer = false;
  18957. }
  18958. // eslint-disable-next-line-no-fallthrough
  18959. default:
  18960. (function () {
  18961. {
  18962. {
  18963. throw ReactError(Error('Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.'));
  18964. }
  18965. }
  18966. })();
  18967. }
  18968. if (parentFiber.effectTag & ContentReset) {
  18969. // Reset the text content of the parent before doing any insertions
  18970. resetTextContent(parent);
  18971. // Clear ContentReset from the effect tag
  18972. parentFiber.effectTag &= ~ContentReset;
  18973. }
  18974. var before = getHostSibling(finishedWork);
  18975. // We only have the top Fiber that was inserted but we need to recurse down its
  18976. // children to find all the terminal nodes.
  18977. var node = finishedWork;
  18978. while (true) {
  18979. var isHost = node.tag === HostComponent || node.tag === HostText;
  18980. if (isHost || node.tag === FundamentalComponent) {
  18981. var stateNode = isHost ? node.stateNode : node.stateNode.instance;
  18982. if (before) {
  18983. if (isContainer) {
  18984. insertInContainerBefore(parent, stateNode, before);
  18985. } else {
  18986. insertBefore(parent, stateNode, before);
  18987. }
  18988. } else {
  18989. if (isContainer) {
  18990. appendChildToContainer(parent, stateNode);
  18991. } else {
  18992. appendChild(parent, stateNode);
  18993. }
  18994. }
  18995. } else if (node.tag === HostPortal) {
  18996. // If the insertion itself is a portal, then we don't want to traverse
  18997. // down its children. Instead, we'll get insertions from each child in
  18998. // the portal directly.
  18999. } else if (node.child !== null) {
  19000. node.child.return = node;
  19001. node = node.child;
  19002. continue;
  19003. }
  19004. if (node === finishedWork) {
  19005. return;
  19006. }
  19007. while (node.sibling === null) {
  19008. if (node.return === null || node.return === finishedWork) {
  19009. return;
  19010. }
  19011. node = node.return;
  19012. }
  19013. node.sibling.return = node.return;
  19014. node = node.sibling;
  19015. }
  19016. }
  19017. function unmountHostComponents(current$$1, renderPriorityLevel) {
  19018. // We only have the top Fiber that was deleted but we need to recurse down its
  19019. var node = current$$1;
  19020. // Each iteration, currentParent is populated with node's host parent if not
  19021. // currentParentIsValid.
  19022. var currentParentIsValid = false;
  19023. // Note: these two variables *must* always be updated together.
  19024. var currentParent = void 0;
  19025. var currentParentIsContainer = void 0;
  19026. while (true) {
  19027. if (!currentParentIsValid) {
  19028. var parent = node.return;
  19029. findParent: while (true) {
  19030. (function () {
  19031. if (!(parent !== null)) {
  19032. {
  19033. throw ReactError(Error('Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.'));
  19034. }
  19035. }
  19036. })();
  19037. var parentStateNode = parent.stateNode;
  19038. switch (parent.tag) {
  19039. case HostComponent:
  19040. currentParent = parentStateNode;
  19041. currentParentIsContainer = false;
  19042. break findParent;
  19043. case HostRoot:
  19044. currentParent = parentStateNode.containerInfo;
  19045. currentParentIsContainer = true;
  19046. break findParent;
  19047. case HostPortal:
  19048. currentParent = parentStateNode.containerInfo;
  19049. currentParentIsContainer = true;
  19050. break findParent;
  19051. case FundamentalComponent:
  19052. if (enableFundamentalAPI) {
  19053. currentParent = parentStateNode.instance;
  19054. currentParentIsContainer = false;
  19055. }
  19056. }
  19057. parent = parent.return;
  19058. }
  19059. currentParentIsValid = true;
  19060. }
  19061. if (node.tag === HostComponent || node.tag === HostText) {
  19062. commitNestedUnmounts(node, renderPriorityLevel);
  19063. // After all the children have unmounted, it is now safe to remove the
  19064. // node from the tree.
  19065. if (currentParentIsContainer) {
  19066. removeChildFromContainer(currentParent, node.stateNode);
  19067. } else {
  19068. removeChild(currentParent, node.stateNode);
  19069. }
  19070. // Don't visit children because we already visited them.
  19071. } else if (node.tag === FundamentalComponent) {
  19072. var fundamentalNode = node.stateNode.instance;
  19073. commitNestedUnmounts(node, renderPriorityLevel);
  19074. // After all the children have unmounted, it is now safe to remove the
  19075. // node from the tree.
  19076. if (currentParentIsContainer) {
  19077. removeChildFromContainer(currentParent, fundamentalNode);
  19078. } else {
  19079. removeChild(currentParent, fundamentalNode);
  19080. }
  19081. } else if (enableSuspenseServerRenderer && node.tag === DehydratedSuspenseComponent) {
  19082. // Delete the dehydrated suspense boundary and all of its content.
  19083. if (currentParentIsContainer) {
  19084. clearSuspenseBoundaryFromContainer(currentParent, node.stateNode);
  19085. } else {
  19086. clearSuspenseBoundary(currentParent, node.stateNode);
  19087. }
  19088. } else if (node.tag === HostPortal) {
  19089. if (node.child !== null) {
  19090. // When we go into a portal, it becomes the parent to remove from.
  19091. // We will reassign it back when we pop the portal on the way up.
  19092. currentParent = node.stateNode.containerInfo;
  19093. currentParentIsContainer = true;
  19094. // Visit children because portals might contain host components.
  19095. node.child.return = node;
  19096. node = node.child;
  19097. continue;
  19098. }
  19099. } else {
  19100. commitUnmount(node, renderPriorityLevel);
  19101. // Visit children because we may find more host components below.
  19102. if (node.child !== null) {
  19103. node.child.return = node;
  19104. node = node.child;
  19105. continue;
  19106. }
  19107. }
  19108. if (node === current$$1) {
  19109. return;
  19110. }
  19111. while (node.sibling === null) {
  19112. if (node.return === null || node.return === current$$1) {
  19113. return;
  19114. }
  19115. node = node.return;
  19116. if (node.tag === HostPortal) {
  19117. // When we go out of the portal, we need to restore the parent.
  19118. // Since we don't keep a stack of them, we will search for it.
  19119. currentParentIsValid = false;
  19120. }
  19121. }
  19122. node.sibling.return = node.return;
  19123. node = node.sibling;
  19124. }
  19125. }
  19126. function commitDeletion(current$$1, renderPriorityLevel) {
  19127. if (supportsMutation) {
  19128. // Recursively delete all host nodes from the parent.
  19129. // Detach refs and call componentWillUnmount() on the whole subtree.
  19130. unmountHostComponents(current$$1, renderPriorityLevel);
  19131. } else {
  19132. // Detach refs and call componentWillUnmount() on the whole subtree.
  19133. commitNestedUnmounts(current$$1, renderPriorityLevel);
  19134. }
  19135. detachFiber(current$$1);
  19136. }
  19137. function commitWork(current$$1, finishedWork) {
  19138. if (!supportsMutation) {
  19139. switch (finishedWork.tag) {
  19140. case FunctionComponent:
  19141. case ForwardRef:
  19142. case MemoComponent:
  19143. case SimpleMemoComponent:
  19144. {
  19145. // Note: We currently never use MountMutation, but useLayout uses
  19146. // UnmountMutation.
  19147. commitHookEffectList(UnmountMutation, MountMutation, finishedWork);
  19148. return;
  19149. }
  19150. case Profiler:
  19151. {
  19152. return;
  19153. }
  19154. case SuspenseComponent:
  19155. {
  19156. commitSuspenseComponent(finishedWork);
  19157. attachSuspenseRetryListeners(finishedWork);
  19158. return;
  19159. }
  19160. case SuspenseListComponent:
  19161. {
  19162. attachSuspenseRetryListeners(finishedWork);
  19163. return;
  19164. }
  19165. }
  19166. commitContainer(finishedWork);
  19167. return;
  19168. }
  19169. switch (finishedWork.tag) {
  19170. case FunctionComponent:
  19171. case ForwardRef:
  19172. case MemoComponent:
  19173. case SimpleMemoComponent:
  19174. {
  19175. // Note: We currently never use MountMutation, but useLayout uses
  19176. // UnmountMutation.
  19177. commitHookEffectList(UnmountMutation, MountMutation, finishedWork);
  19178. return;
  19179. }
  19180. case ClassComponent:
  19181. {
  19182. return;
  19183. }
  19184. case HostComponent:
  19185. {
  19186. var instance = finishedWork.stateNode;
  19187. if (instance != null) {
  19188. // Commit the work prepared earlier.
  19189. var newProps = finishedWork.memoizedProps;
  19190. // For hydration we reuse the update path but we treat the oldProps
  19191. // as the newProps. The updatePayload will contain the real change in
  19192. // this case.
  19193. var oldProps = current$$1 !== null ? current$$1.memoizedProps : newProps;
  19194. var type = finishedWork.type;
  19195. // TODO: Type the updateQueue to be specific to host components.
  19196. var updatePayload = finishedWork.updateQueue;
  19197. finishedWork.updateQueue = null;
  19198. if (updatePayload !== null) {
  19199. commitUpdate(instance, updatePayload, type, oldProps, newProps, finishedWork);
  19200. }
  19201. }
  19202. return;
  19203. }
  19204. case HostText:
  19205. {
  19206. (function () {
  19207. if (!(finishedWork.stateNode !== null)) {
  19208. {
  19209. throw ReactError(Error('This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue.'));
  19210. }
  19211. }
  19212. })();
  19213. var textInstance = finishedWork.stateNode;
  19214. var newText = finishedWork.memoizedProps;
  19215. // For hydration we reuse the update path but we treat the oldProps
  19216. // as the newProps. The updatePayload will contain the real change in
  19217. // this case.
  19218. var oldText = current$$1 !== null ? current$$1.memoizedProps : newText;
  19219. commitTextUpdate(textInstance, oldText, newText);
  19220. return;
  19221. }
  19222. case HostRoot:
  19223. {
  19224. return;
  19225. }
  19226. case Profiler:
  19227. {
  19228. return;
  19229. }
  19230. case SuspenseComponent:
  19231. {
  19232. commitSuspenseComponent(finishedWork);
  19233. attachSuspenseRetryListeners(finishedWork);
  19234. return;
  19235. }
  19236. case SuspenseListComponent:
  19237. {
  19238. attachSuspenseRetryListeners(finishedWork);
  19239. return;
  19240. }
  19241. case IncompleteClassComponent:
  19242. {
  19243. return;
  19244. }
  19245. case FundamentalComponent:
  19246. {
  19247. if (enableFundamentalAPI) {
  19248. var fundamentalInstance = finishedWork.stateNode;
  19249. updateFundamentalComponent(fundamentalInstance);
  19250. }
  19251. return;
  19252. }
  19253. default:
  19254. {
  19255. (function () {
  19256. {
  19257. {
  19258. throw ReactError(Error('This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.'));
  19259. }
  19260. }
  19261. })();
  19262. }
  19263. }
  19264. }
  19265. function commitSuspenseComponent(finishedWork) {
  19266. var newState = finishedWork.memoizedState;
  19267. var newDidTimeout = void 0;
  19268. var primaryChildParent = finishedWork;
  19269. if (newState === null) {
  19270. newDidTimeout = false;
  19271. } else {
  19272. newDidTimeout = true;
  19273. primaryChildParent = finishedWork.child;
  19274. markCommitTimeOfFallback();
  19275. }
  19276. if (supportsMutation && primaryChildParent !== null) {
  19277. hideOrUnhideAllChildren(primaryChildParent, newDidTimeout);
  19278. }
  19279. if (enableSuspenseCallback && newState !== null) {
  19280. var suspenseCallback = finishedWork.memoizedProps.suspenseCallback;
  19281. if (typeof suspenseCallback === 'function') {
  19282. var thenables = finishedWork.updateQueue;
  19283. if (thenables !== null) {
  19284. suspenseCallback(new Set(thenables));
  19285. }
  19286. } else {
  19287. if (suspenseCallback !== undefined) {
  19288. warning$1(false, 'Unexpected type for suspenseCallback.');
  19289. }
  19290. }
  19291. }
  19292. }
  19293. function attachSuspenseRetryListeners(finishedWork) {
  19294. // If this boundary just timed out, then it will have a set of thenables.
  19295. // For each thenable, attach a listener so that when it resolves, React
  19296. var thenables = finishedWork.updateQueue;
  19297. if (thenables !== null) {
  19298. finishedWork.updateQueue = null;
  19299. var retryCache = finishedWork.stateNode;
  19300. if (retryCache === null) {
  19301. retryCache = finishedWork.stateNode = new PossiblyWeakSet$1();
  19302. }
  19303. thenables.forEach(function (thenable) {
  19304. // Memoize using the boundary fiber to prevent redundant listeners.
  19305. var retry = resolveRetryThenable.bind(null, finishedWork, thenable);
  19306. if (!retryCache.has(thenable)) {
  19307. if (enableSchedulerTracing) {
  19308. retry = tracing.unstable_wrap(retry);
  19309. }
  19310. retryCache.add(thenable);
  19311. thenable.then(retry, retry);
  19312. }
  19313. });
  19314. }
  19315. }
  19316. function commitResetTextContent(current$$1) {
  19317. if (!supportsMutation) {
  19318. return;
  19319. }
  19320. resetTextContent(current$$1.stateNode);
  19321. }
  19322. var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
  19323. var PossiblyWeakMap$1 = typeof WeakMap === 'function' ? WeakMap : Map;
  19324. function createRootErrorUpdate(fiber, errorInfo, expirationTime) {
  19325. var update = createUpdate(expirationTime, null);
  19326. // Unmount the root by rendering null.
  19327. update.tag = CaptureUpdate;
  19328. // Caution: React DevTools currently depends on this property
  19329. // being called "element".
  19330. update.payload = { element: null };
  19331. var error = errorInfo.value;
  19332. update.callback = function () {
  19333. onUncaughtError(error);
  19334. logError(fiber, errorInfo);
  19335. };
  19336. return update;
  19337. }
  19338. function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
  19339. var update = createUpdate(expirationTime, null);
  19340. update.tag = CaptureUpdate;
  19341. var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
  19342. if (typeof getDerivedStateFromError === 'function') {
  19343. var error = errorInfo.value;
  19344. update.payload = function () {
  19345. logError(fiber, errorInfo);
  19346. return getDerivedStateFromError(error);
  19347. };
  19348. }
  19349. var inst = fiber.stateNode;
  19350. if (inst !== null && typeof inst.componentDidCatch === 'function') {
  19351. update.callback = function callback() {
  19352. {
  19353. markFailedErrorBoundaryForHotReloading(fiber);
  19354. }
  19355. if (typeof getDerivedStateFromError !== 'function') {
  19356. // To preserve the preexisting retry behavior of error boundaries,
  19357. // we keep track of which ones already failed during this batch.
  19358. // This gets reset before we yield back to the browser.
  19359. // TODO: Warn in strict mode if getDerivedStateFromError is
  19360. // not defined.
  19361. markLegacyErrorBoundaryAsFailed(this);
  19362. // Only log here if componentDidCatch is the only error boundary method defined
  19363. logError(fiber, errorInfo);
  19364. }
  19365. var error = errorInfo.value;
  19366. var stack = errorInfo.stack;
  19367. this.componentDidCatch(error, {
  19368. componentStack: stack !== null ? stack : ''
  19369. });
  19370. {
  19371. if (typeof getDerivedStateFromError !== 'function') {
  19372. // If componentDidCatch is the only error boundary method defined,
  19373. // then it needs to call setState to recover from errors.
  19374. // If no state update is scheduled then the boundary will swallow the error.
  19375. !(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;
  19376. }
  19377. }
  19378. };
  19379. } else {
  19380. update.callback = function () {
  19381. markFailedErrorBoundaryForHotReloading(fiber);
  19382. };
  19383. }
  19384. return update;
  19385. }
  19386. function attachPingListener(root, renderExpirationTime, thenable) {
  19387. // Attach a listener to the promise to "ping" the root and retry. But
  19388. // only if one does not already exist for the current render expiration
  19389. // time (which acts like a "thread ID" here).
  19390. var pingCache = root.pingCache;
  19391. var threadIDs = void 0;
  19392. if (pingCache === null) {
  19393. pingCache = root.pingCache = new PossiblyWeakMap$1();
  19394. threadIDs = new Set();
  19395. pingCache.set(thenable, threadIDs);
  19396. } else {
  19397. threadIDs = pingCache.get(thenable);
  19398. if (threadIDs === undefined) {
  19399. threadIDs = new Set();
  19400. pingCache.set(thenable, threadIDs);
  19401. }
  19402. }
  19403. if (!threadIDs.has(renderExpirationTime)) {
  19404. // Memoize using the thread ID to prevent redundant listeners.
  19405. threadIDs.add(renderExpirationTime);
  19406. var ping = pingSuspendedRoot.bind(null, root, thenable, renderExpirationTime);
  19407. if (enableSchedulerTracing) {
  19408. ping = tracing.unstable_wrap(ping);
  19409. }
  19410. thenable.then(ping, ping);
  19411. }
  19412. }
  19413. function throwException(root, returnFiber, sourceFiber, value, renderExpirationTime) {
  19414. // The source fiber did not complete.
  19415. sourceFiber.effectTag |= Incomplete;
  19416. // Its effect list is no longer valid.
  19417. sourceFiber.firstEffect = sourceFiber.lastEffect = null;
  19418. if (value !== null && typeof value === 'object' && typeof value.then === 'function') {
  19419. // This is a thenable.
  19420. var thenable = value;
  19421. checkForWrongSuspensePriorityInDEV(sourceFiber);
  19422. var hasInvisibleParentBoundary = hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext);
  19423. // Schedule the nearest Suspense to re-render the timed out view.
  19424. var _workInProgress = returnFiber;
  19425. do {
  19426. if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)) {
  19427. // Found the nearest boundary.
  19428. // Stash the promise on the boundary fiber. If the boundary times out, we'll
  19429. var thenables = _workInProgress.updateQueue;
  19430. if (thenables === null) {
  19431. var updateQueue = new Set();
  19432. updateQueue.add(thenable);
  19433. _workInProgress.updateQueue = updateQueue;
  19434. } else {
  19435. thenables.add(thenable);
  19436. }
  19437. // If the boundary is outside of batched mode, we should *not*
  19438. // suspend the commit. Pretend as if the suspended component rendered
  19439. // null and keep rendering. In the commit phase, we'll schedule a
  19440. // subsequent synchronous update to re-render the Suspense.
  19441. //
  19442. // Note: It doesn't matter whether the component that suspended was
  19443. // inside a batched mode tree. If the Suspense is outside of it, we
  19444. // should *not* suspend the commit.
  19445. if ((_workInProgress.mode & BatchedMode) === NoMode) {
  19446. _workInProgress.effectTag |= DidCapture;
  19447. // We're going to commit this fiber even though it didn't complete.
  19448. // But we shouldn't call any lifecycle methods or callbacks. Remove
  19449. // all lifecycle effect tags.
  19450. sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete);
  19451. if (sourceFiber.tag === ClassComponent) {
  19452. var currentSourceFiber = sourceFiber.alternate;
  19453. if (currentSourceFiber === null) {
  19454. // This is a new mount. Change the tag so it's not mistaken for a
  19455. // completed class component. For example, we should not call
  19456. // componentWillUnmount if it is deleted.
  19457. sourceFiber.tag = IncompleteClassComponent;
  19458. } else {
  19459. // When we try rendering again, we should not reuse the current fiber,
  19460. // since it's known to be in an inconsistent state. Use a force update to
  19461. // prevent a bail out.
  19462. var update = createUpdate(Sync, null);
  19463. update.tag = ForceUpdate;
  19464. enqueueUpdate(sourceFiber, update);
  19465. }
  19466. }
  19467. // The source fiber did not complete. Mark it with Sync priority to
  19468. // indicate that it still has pending work.
  19469. sourceFiber.expirationTime = Sync;
  19470. // Exit without suspending.
  19471. return;
  19472. }
  19473. // Confirmed that the boundary is in a concurrent mode tree. Continue
  19474. // with the normal suspend path.
  19475. //
  19476. // After this we'll use a set of heuristics to determine whether this
  19477. // render pass will run to completion or restart or "suspend" the commit.
  19478. // The actual logic for this is spread out in different places.
  19479. //
  19480. // This first principle is that if we're going to suspend when we complete
  19481. // a root, then we should also restart if we get an update or ping that
  19482. // might unsuspend it, and vice versa. The only reason to suspend is
  19483. // because you think you might want to restart before committing. However,
  19484. // it doesn't make sense to restart only while in the period we're suspended.
  19485. //
  19486. // Restarting too aggressively is also not good because it starves out any
  19487. // intermediate loading state. So we use heuristics to determine when.
  19488. // Suspense Heuristics
  19489. //
  19490. // If nothing threw a Promise or all the same fallbacks are already showing,
  19491. // then don't suspend/restart.
  19492. //
  19493. // If this is an initial render of a new tree of Suspense boundaries and
  19494. // those trigger a fallback, then don't suspend/restart. We want to ensure
  19495. // that we can show the initial loading state as quickly as possible.
  19496. //
  19497. // If we hit a "Delayed" case, such as when we'd switch from content back into
  19498. // a fallback, then we should always suspend/restart. SuspenseConfig applies to
  19499. // this case. If none is defined, JND is used instead.
  19500. //
  19501. // If we're already showing a fallback and it gets "retried", allowing us to show
  19502. // another level, but there's still an inner boundary that would show a fallback,
  19503. // then we suspend/restart for 500ms since the last time we showed a fallback
  19504. // anywhere in the tree. This effectively throttles progressive loading into a
  19505. // consistent train of commits. This also gives us an opportunity to restart to
  19506. // get to the completed state slightly earlier.
  19507. //
  19508. // If there's ambiguity due to batching it's resolved in preference of:
  19509. // 1) "delayed", 2) "initial render", 3) "retry".
  19510. //
  19511. // We want to ensure that a "busy" state doesn't get force committed. We want to
  19512. // ensure that new initial loading states can commit as soon as possible.
  19513. attachPingListener(root, renderExpirationTime, thenable);
  19514. _workInProgress.effectTag |= ShouldCapture;
  19515. _workInProgress.expirationTime = renderExpirationTime;
  19516. return;
  19517. } else if (enableSuspenseServerRenderer && _workInProgress.tag === DehydratedSuspenseComponent) {
  19518. attachPingListener(root, renderExpirationTime, thenable);
  19519. // Since we already have a current fiber, we can eagerly add a retry listener.
  19520. var retryCache = _workInProgress.memoizedState;
  19521. if (retryCache === null) {
  19522. retryCache = _workInProgress.memoizedState = new PossiblyWeakSet();
  19523. var current$$1 = _workInProgress.alternate;
  19524. (function () {
  19525. if (!current$$1) {
  19526. {
  19527. throw ReactError(Error('A dehydrated suspense boundary must commit before trying to render. This is probably a bug in React.'));
  19528. }
  19529. }
  19530. })();
  19531. current$$1.memoizedState = retryCache;
  19532. }
  19533. // Memoize using the boundary fiber to prevent redundant listeners.
  19534. if (!retryCache.has(thenable)) {
  19535. retryCache.add(thenable);
  19536. var retry = resolveRetryThenable.bind(null, _workInProgress, thenable);
  19537. if (enableSchedulerTracing) {
  19538. retry = tracing.unstable_wrap(retry);
  19539. }
  19540. thenable.then(retry, retry);
  19541. }
  19542. _workInProgress.effectTag |= ShouldCapture;
  19543. _workInProgress.expirationTime = renderExpirationTime;
  19544. return;
  19545. }
  19546. // This boundary already captured during this render. Continue to the next
  19547. // boundary.
  19548. _workInProgress = _workInProgress.return;
  19549. } while (_workInProgress !== null);
  19550. // No boundary was found. Fallthrough to error mode.
  19551. // TODO: Use invariant so the message is stripped in prod?
  19552. 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));
  19553. }
  19554. // We didn't find a boundary that could handle this type of exception. Start
  19555. // over and traverse parent path again, this time treating the exception
  19556. // as an error.
  19557. renderDidError();
  19558. value = createCapturedValue(value, sourceFiber);
  19559. var workInProgress = returnFiber;
  19560. do {
  19561. switch (workInProgress.tag) {
  19562. case HostRoot:
  19563. {
  19564. var _errorInfo = value;
  19565. workInProgress.effectTag |= ShouldCapture;
  19566. workInProgress.expirationTime = renderExpirationTime;
  19567. var _update = createRootErrorUpdate(workInProgress, _errorInfo, renderExpirationTime);
  19568. enqueueCapturedUpdate(workInProgress, _update);
  19569. return;
  19570. }
  19571. case ClassComponent:
  19572. // Capture and retry
  19573. var errorInfo = value;
  19574. var ctor = workInProgress.type;
  19575. var instance = workInProgress.stateNode;
  19576. if ((workInProgress.effectTag & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) {
  19577. workInProgress.effectTag |= ShouldCapture;
  19578. workInProgress.expirationTime = renderExpirationTime;
  19579. // Schedule the error boundary to re-render using updated state
  19580. var _update2 = createClassErrorUpdate(workInProgress, errorInfo, renderExpirationTime);
  19581. enqueueCapturedUpdate(workInProgress, _update2);
  19582. return;
  19583. }
  19584. break;
  19585. default:
  19586. break;
  19587. }
  19588. workInProgress = workInProgress.return;
  19589. } while (workInProgress !== null);
  19590. }
  19591. // The scheduler is imported here *only* to detect whether it's been mocked
  19592. // DEV stuff
  19593. var ceil = Math.ceil;
  19594. var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
  19595. var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner;
  19596. var IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing;
  19597. var NoContext = /* */0;
  19598. var BatchedContext = /* */1;
  19599. var EventContext = /* */2;
  19600. var DiscreteEventContext = /* */4;
  19601. var LegacyUnbatchedContext = /* */8;
  19602. var RenderContext = /* */16;
  19603. var CommitContext = /* */32;
  19604. var RootIncomplete = 0;
  19605. var RootErrored = 1;
  19606. var RootSuspended = 2;
  19607. var RootSuspendedWithDelay = 3;
  19608. var RootCompleted = 4;
  19609. // Describes where we are in the React execution stack
  19610. var executionContext = NoContext;
  19611. // The root we're working on
  19612. var workInProgressRoot = null;
  19613. // The fiber we're working on
  19614. var workInProgress = null;
  19615. // The expiration time we're rendering
  19616. var renderExpirationTime = NoWork;
  19617. // Whether to root completed, errored, suspended, etc.
  19618. var workInProgressRootExitStatus = RootIncomplete;
  19619. // Most recent event time among processed updates during this render.
  19620. // This is conceptually a time stamp but expressed in terms of an ExpirationTime
  19621. // because we deal mostly with expiration times in the hot path, so this avoids
  19622. // the conversion happening in the hot path.
  19623. var workInProgressRootLatestProcessedExpirationTime = Sync;
  19624. var workInProgressRootLatestSuspenseTimeout = Sync;
  19625. var workInProgressRootCanSuspendUsingConfig = null;
  19626. // If we're pinged while rendering we don't always restart immediately.
  19627. // This flag determines if it might be worthwhile to restart if an opportunity
  19628. // happens latere.
  19629. var workInProgressRootHasPendingPing = false;
  19630. // The most recent time we committed a fallback. This lets us ensure a train
  19631. // model where we don't commit new loading states in too quick succession.
  19632. var globalMostRecentFallbackTime = 0;
  19633. var FALLBACK_THROTTLE_MS = 500;
  19634. var nextEffect = null;
  19635. var hasUncaughtError = false;
  19636. var firstUncaughtError = null;
  19637. var legacyErrorBoundariesThatAlreadyFailed = null;
  19638. var rootDoesHavePassiveEffects = false;
  19639. var rootWithPendingPassiveEffects = null;
  19640. var pendingPassiveEffectsRenderPriority = NoPriority;
  19641. var pendingPassiveEffectsExpirationTime = NoWork;
  19642. var rootsWithPendingDiscreteUpdates = null;
  19643. // Use these to prevent an infinite loop of nested updates
  19644. var NESTED_UPDATE_LIMIT = 50;
  19645. var nestedUpdateCount = 0;
  19646. var rootWithNestedUpdates = null;
  19647. var NESTED_PASSIVE_UPDATE_LIMIT = 50;
  19648. var nestedPassiveUpdateCount = 0;
  19649. var interruptedBy = null;
  19650. // Marks the need to reschedule pending interactions at these expiration times
  19651. // during the commit phase. This enables them to be traced across components
  19652. // that spawn new work during render. E.g. hidden boundaries, suspended SSR
  19653. // hydration or SuspenseList.
  19654. var spawnedWorkDuringRender = null;
  19655. // Expiration times are computed by adding to the current time (the start
  19656. // time). However, if two updates are scheduled within the same event, we
  19657. // should treat their start times as simultaneous, even if the actual clock
  19658. // time has advanced between the first and second call.
  19659. // In other words, because expiration times determine how updates are batched,
  19660. // we want all updates of like priority that occur within the same event to
  19661. // receive the same expiration time. Otherwise we get tearing.
  19662. var currentEventTime = NoWork;
  19663. function requestCurrentTime() {
  19664. if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
  19665. // We're inside React, so it's fine to read the actual time.
  19666. return msToExpirationTime(now());
  19667. }
  19668. // We're not inside React, so we may be in the middle of a browser event.
  19669. if (currentEventTime !== NoWork) {
  19670. // Use the same start time for all updates until we enter React again.
  19671. return currentEventTime;
  19672. }
  19673. // This is the first update since React yielded. Compute a new start time.
  19674. currentEventTime = msToExpirationTime(now());
  19675. return currentEventTime;
  19676. }
  19677. function computeExpirationForFiber(currentTime, fiber, suspenseConfig) {
  19678. var mode = fiber.mode;
  19679. if ((mode & BatchedMode) === NoMode) {
  19680. return Sync;
  19681. }
  19682. var priorityLevel = getCurrentPriorityLevel();
  19683. if ((mode & ConcurrentMode) === NoMode) {
  19684. return priorityLevel === ImmediatePriority ? Sync : Batched;
  19685. }
  19686. if ((executionContext & RenderContext) !== NoContext) {
  19687. // Use whatever time we're already rendering
  19688. return renderExpirationTime;
  19689. }
  19690. var expirationTime = void 0;
  19691. if (suspenseConfig !== null) {
  19692. // Compute an expiration time based on the Suspense timeout.
  19693. expirationTime = computeSuspenseExpiration(currentTime, suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION);
  19694. } else {
  19695. // Compute an expiration time based on the Scheduler priority.
  19696. switch (priorityLevel) {
  19697. case ImmediatePriority:
  19698. expirationTime = Sync;
  19699. break;
  19700. case UserBlockingPriority$2:
  19701. // TODO: Rename this to computeUserBlockingExpiration
  19702. expirationTime = computeInteractiveExpiration(currentTime);
  19703. break;
  19704. case NormalPriority:
  19705. case LowPriority:
  19706. // TODO: Handle LowPriority
  19707. // TODO: Rename this to... something better.
  19708. expirationTime = computeAsyncExpiration(currentTime);
  19709. break;
  19710. case IdlePriority:
  19711. expirationTime = Never;
  19712. break;
  19713. default:
  19714. (function () {
  19715. {
  19716. {
  19717. throw ReactError(Error('Expected a valid priority level'));
  19718. }
  19719. }
  19720. })();
  19721. }
  19722. }
  19723. // If we're in the middle of rendering a tree, do not update at the same
  19724. // expiration time that is already rendering.
  19725. // TODO: We shouldn't have to do this if the update is on a different root.
  19726. // Refactor computeExpirationForFiber + scheduleUpdate so we have access to
  19727. // the root when we check for this condition.
  19728. if (workInProgressRoot !== null && expirationTime === renderExpirationTime) {
  19729. // This is a trick to move this update into a separate batch
  19730. expirationTime -= 1;
  19731. }
  19732. return expirationTime;
  19733. }
  19734. var lastUniqueAsyncExpiration = NoWork;
  19735. function computeUniqueAsyncExpiration() {
  19736. var currentTime = requestCurrentTime();
  19737. var result = computeAsyncExpiration(currentTime);
  19738. if (result <= lastUniqueAsyncExpiration) {
  19739. // Since we assume the current time monotonically increases, we only hit
  19740. // this branch when computeUniqueAsyncExpiration is fired multiple times
  19741. // within a 200ms window (or whatever the async bucket size is).
  19742. result -= 1;
  19743. }
  19744. lastUniqueAsyncExpiration = result;
  19745. return result;
  19746. }
  19747. function scheduleUpdateOnFiber(fiber, expirationTime) {
  19748. checkForNestedUpdates();
  19749. warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber);
  19750. var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime);
  19751. if (root === null) {
  19752. warnAboutUpdateOnUnmountedFiberInDEV(fiber);
  19753. return;
  19754. }
  19755. root.pingTime = NoWork;
  19756. checkForInterruption(fiber, expirationTime);
  19757. recordScheduleUpdate();
  19758. // TODO: computeExpirationForFiber also reads the priority. Pass the
  19759. // priority as an argument to that function and this one.
  19760. var priorityLevel = getCurrentPriorityLevel();
  19761. if (expirationTime === Sync) {
  19762. if (
  19763. // Check if we're inside unbatchedUpdates
  19764. (executionContext & LegacyUnbatchedContext) !== NoContext &&
  19765. // Check if we're not already rendering
  19766. (executionContext & (RenderContext | CommitContext)) === NoContext) {
  19767. // Register pending interactions on the root to avoid losing traced interaction data.
  19768. schedulePendingInteractions(root, expirationTime);
  19769. // This is a legacy edge case. The initial mount of a ReactDOM.render-ed
  19770. // root inside of batchedUpdates should be synchronous, but layout updates
  19771. // should be deferred until the end of the batch.
  19772. var callback = renderRoot(root, Sync, true);
  19773. while (callback !== null) {
  19774. callback = callback(true);
  19775. }
  19776. } else {
  19777. scheduleCallbackForRoot(root, ImmediatePriority, Sync);
  19778. if (executionContext === NoContext) {
  19779. // Flush the synchronous work now, wnless we're already working or inside
  19780. // a batch. This is intentionally inside scheduleUpdateOnFiber instead of
  19781. // scheduleCallbackForFiber to preserve the ability to schedule a callback
  19782. // without immediately flushing it. We only do this for user-initiated
  19783. // updates, to preserve historical behavior of sync mode.
  19784. flushSyncCallbackQueue();
  19785. }
  19786. }
  19787. } else {
  19788. scheduleCallbackForRoot(root, priorityLevel, expirationTime);
  19789. }
  19790. if ((executionContext & DiscreteEventContext) !== NoContext && (
  19791. // Only updates at user-blocking priority or greater are considered
  19792. // discrete, even inside a discrete event.
  19793. priorityLevel === UserBlockingPriority$2 || priorityLevel === ImmediatePriority)) {
  19794. // This is the result of a discrete event. Track the lowest priority
  19795. // discrete update per root so we can flush them early, if needed.
  19796. if (rootsWithPendingDiscreteUpdates === null) {
  19797. rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]);
  19798. } else {
  19799. var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root);
  19800. if (lastDiscreteTime === undefined || lastDiscreteTime > expirationTime) {
  19801. rootsWithPendingDiscreteUpdates.set(root, expirationTime);
  19802. }
  19803. }
  19804. }
  19805. }
  19806. var scheduleWork = scheduleUpdateOnFiber;
  19807. // This is split into a separate function so we can mark a fiber with pending
  19808. // work without treating it as a typical update that originates from an event;
  19809. // e.g. retrying a Suspense boundary isn't an update, but it does schedule work
  19810. // on a fiber.
  19811. function markUpdateTimeFromFiberToRoot(fiber, expirationTime) {
  19812. // Update the source fiber's expiration time
  19813. if (fiber.expirationTime < expirationTime) {
  19814. fiber.expirationTime = expirationTime;
  19815. }
  19816. var alternate = fiber.alternate;
  19817. if (alternate !== null && alternate.expirationTime < expirationTime) {
  19818. alternate.expirationTime = expirationTime;
  19819. }
  19820. // Walk the parent path to the root and update the child expiration time.
  19821. var node = fiber.return;
  19822. var root = null;
  19823. if (node === null && fiber.tag === HostRoot) {
  19824. root = fiber.stateNode;
  19825. } else {
  19826. while (node !== null) {
  19827. alternate = node.alternate;
  19828. if (node.childExpirationTime < expirationTime) {
  19829. node.childExpirationTime = expirationTime;
  19830. if (alternate !== null && alternate.childExpirationTime < expirationTime) {
  19831. alternate.childExpirationTime = expirationTime;
  19832. }
  19833. } else if (alternate !== null && alternate.childExpirationTime < expirationTime) {
  19834. alternate.childExpirationTime = expirationTime;
  19835. }
  19836. if (node.return === null && node.tag === HostRoot) {
  19837. root = node.stateNode;
  19838. break;
  19839. }
  19840. node = node.return;
  19841. }
  19842. }
  19843. if (root !== null) {
  19844. // Update the first and last pending expiration times in this root
  19845. var firstPendingTime = root.firstPendingTime;
  19846. if (expirationTime > firstPendingTime) {
  19847. root.firstPendingTime = expirationTime;
  19848. }
  19849. var lastPendingTime = root.lastPendingTime;
  19850. if (lastPendingTime === NoWork || expirationTime < lastPendingTime) {
  19851. root.lastPendingTime = expirationTime;
  19852. }
  19853. }
  19854. return root;
  19855. }
  19856. // Use this function, along with runRootCallback, to ensure that only a single
  19857. // callback per root is scheduled. It's still possible to call renderRoot
  19858. // directly, but scheduling via this function helps avoid excessive callbacks.
  19859. // It works by storing the callback node and expiration time on the root. When a
  19860. // new callback comes in, it compares the expiration time to determine if it
  19861. // should cancel the previous one. It also relies on commitRoot scheduling a
  19862. // callback to render the next level, because that means we don't need a
  19863. // separate callback per expiration time.
  19864. function scheduleCallbackForRoot(root, priorityLevel, expirationTime) {
  19865. var existingCallbackExpirationTime = root.callbackExpirationTime;
  19866. if (existingCallbackExpirationTime < expirationTime) {
  19867. // New callback has higher priority than the existing one.
  19868. var existingCallbackNode = root.callbackNode;
  19869. if (existingCallbackNode !== null) {
  19870. cancelCallback(existingCallbackNode);
  19871. }
  19872. root.callbackExpirationTime = expirationTime;
  19873. if (expirationTime === Sync) {
  19874. // Sync React callbacks are scheduled on a special internal queue
  19875. root.callbackNode = scheduleSyncCallback(runRootCallback.bind(null, root, renderRoot.bind(null, root, expirationTime)));
  19876. } else {
  19877. var options = null;
  19878. if (!disableSchedulerTimeoutBasedOnReactExpirationTime && expirationTime !== Never) {
  19879. var timeout = expirationTimeToMs(expirationTime) - now();
  19880. options = { timeout: timeout };
  19881. }
  19882. root.callbackNode = scheduleCallback(priorityLevel, runRootCallback.bind(null, root, renderRoot.bind(null, root, expirationTime)), options);
  19883. if (enableUserTimingAPI && expirationTime !== Sync && (executionContext & (RenderContext | CommitContext)) === NoContext) {
  19884. // Scheduled an async callback, and we're not already working. Add an
  19885. // entry to the flamegraph that shows we're waiting for a callback
  19886. // to fire.
  19887. startRequestCallbackTimer();
  19888. }
  19889. }
  19890. }
  19891. // Associate the current interactions with this new root+priority.
  19892. schedulePendingInteractions(root, expirationTime);
  19893. }
  19894. function runRootCallback(root, callback, isSync) {
  19895. var prevCallbackNode = root.callbackNode;
  19896. var continuation = null;
  19897. try {
  19898. continuation = callback(isSync);
  19899. if (continuation !== null) {
  19900. return runRootCallback.bind(null, root, continuation);
  19901. } else {
  19902. return null;
  19903. }
  19904. } finally {
  19905. // If the callback exits without returning a continuation, remove the
  19906. // corresponding callback node from the root. Unless the callback node
  19907. // has changed, which implies that it was already cancelled by a high
  19908. // priority update.
  19909. if (continuation === null && prevCallbackNode === root.callbackNode) {
  19910. root.callbackNode = null;
  19911. root.callbackExpirationTime = NoWork;
  19912. }
  19913. }
  19914. }
  19915. function flushRoot(root, expirationTime) {
  19916. if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
  19917. (function () {
  19918. {
  19919. {
  19920. throw ReactError(Error('work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method.'));
  19921. }
  19922. }
  19923. })();
  19924. }
  19925. scheduleSyncCallback(renderRoot.bind(null, root, expirationTime));
  19926. flushSyncCallbackQueue();
  19927. }
  19928. function flushDiscreteUpdates() {
  19929. // TODO: Should be able to flush inside batchedUpdates, but not inside `act`.
  19930. // However, `act` uses `batchedUpdates`, so there's no way to distinguish
  19931. // those two cases. Need to fix this before exposing flushDiscreteUpdates
  19932. // as a public API.
  19933. if ((executionContext & (BatchedContext | RenderContext | CommitContext)) !== NoContext) {
  19934. if ( true && (executionContext & RenderContext) !== NoContext) {
  19935. warning$1(false, 'unstable_flushDiscreteUpdates: Cannot flush updates when React is ' + 'already rendering.');
  19936. }
  19937. // We're already rendering, so we can't synchronously flush pending work.
  19938. // This is probably a nested event dispatch triggered by a lifecycle/effect,
  19939. // like `el.focus()`. Exit.
  19940. return;
  19941. }
  19942. flushPendingDiscreteUpdates();
  19943. if (!revertPassiveEffectsChange) {
  19944. // If the discrete updates scheduled passive effects, flush them now so that
  19945. // they fire before the next serial event.
  19946. flushPassiveEffects();
  19947. }
  19948. }
  19949. function resolveLocksOnRoot(root, expirationTime) {
  19950. var firstBatch = root.firstBatch;
  19951. if (firstBatch !== null && firstBatch._defer && firstBatch._expirationTime >= expirationTime) {
  19952. scheduleCallback(NormalPriority, function () {
  19953. firstBatch._onComplete();
  19954. return null;
  19955. });
  19956. return true;
  19957. } else {
  19958. return false;
  19959. }
  19960. }
  19961. function flushPendingDiscreteUpdates() {
  19962. if (rootsWithPendingDiscreteUpdates !== null) {
  19963. // For each root with pending discrete updates, schedule a callback to
  19964. // immediately flush them.
  19965. var roots = rootsWithPendingDiscreteUpdates;
  19966. rootsWithPendingDiscreteUpdates = null;
  19967. roots.forEach(function (expirationTime, root) {
  19968. scheduleSyncCallback(renderRoot.bind(null, root, expirationTime));
  19969. });
  19970. // Now flush the immediate queue.
  19971. flushSyncCallbackQueue();
  19972. }
  19973. }
  19974. function batchedUpdates$1(fn, a) {
  19975. var prevExecutionContext = executionContext;
  19976. executionContext |= BatchedContext;
  19977. try {
  19978. return fn(a);
  19979. } finally {
  19980. executionContext = prevExecutionContext;
  19981. if (executionContext === NoContext) {
  19982. // Flush the immediate callbacks that were scheduled during this batch
  19983. flushSyncCallbackQueue();
  19984. }
  19985. }
  19986. }
  19987. function batchedEventUpdates$1(fn, a) {
  19988. var prevExecutionContext = executionContext;
  19989. executionContext |= EventContext;
  19990. try {
  19991. return fn(a);
  19992. } finally {
  19993. executionContext = prevExecutionContext;
  19994. if (executionContext === NoContext) {
  19995. // Flush the immediate callbacks that were scheduled during this batch
  19996. flushSyncCallbackQueue();
  19997. }
  19998. }
  19999. }
  20000. function discreteUpdates$1(fn, a, b, c) {
  20001. var prevExecutionContext = executionContext;
  20002. executionContext |= DiscreteEventContext;
  20003. try {
  20004. // Should this
  20005. return runWithPriority$2(UserBlockingPriority$2, fn.bind(null, a, b, c));
  20006. } finally {
  20007. executionContext = prevExecutionContext;
  20008. if (executionContext === NoContext) {
  20009. // Flush the immediate callbacks that were scheduled during this batch
  20010. flushSyncCallbackQueue();
  20011. }
  20012. }
  20013. }
  20014. function unbatchedUpdates(fn, a) {
  20015. var prevExecutionContext = executionContext;
  20016. executionContext &= ~BatchedContext;
  20017. executionContext |= LegacyUnbatchedContext;
  20018. try {
  20019. return fn(a);
  20020. } finally {
  20021. executionContext = prevExecutionContext;
  20022. if (executionContext === NoContext) {
  20023. // Flush the immediate callbacks that were scheduled during this batch
  20024. flushSyncCallbackQueue();
  20025. }
  20026. }
  20027. }
  20028. function flushSync(fn, a) {
  20029. if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
  20030. (function () {
  20031. {
  20032. {
  20033. throw ReactError(Error('flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering.'));
  20034. }
  20035. }
  20036. })();
  20037. }
  20038. var prevExecutionContext = executionContext;
  20039. executionContext |= BatchedContext;
  20040. try {
  20041. return runWithPriority$2(ImmediatePriority, fn.bind(null, a));
  20042. } finally {
  20043. executionContext = prevExecutionContext;
  20044. // Flush the immediate callbacks that were scheduled during this batch.
  20045. // Note that this will happen even if batchedUpdates is higher up
  20046. // the stack.
  20047. flushSyncCallbackQueue();
  20048. }
  20049. }
  20050. function flushControlled(fn) {
  20051. var prevExecutionContext = executionContext;
  20052. executionContext |= BatchedContext;
  20053. try {
  20054. runWithPriority$2(ImmediatePriority, fn);
  20055. } finally {
  20056. executionContext = prevExecutionContext;
  20057. if (executionContext === NoContext) {
  20058. // Flush the immediate callbacks that were scheduled during this batch
  20059. flushSyncCallbackQueue();
  20060. }
  20061. }
  20062. }
  20063. function prepareFreshStack(root, expirationTime) {
  20064. root.finishedWork = null;
  20065. root.finishedExpirationTime = NoWork;
  20066. var timeoutHandle = root.timeoutHandle;
  20067. if (timeoutHandle !== noTimeout) {
  20068. // The root previous suspended and scheduled a timeout to commit a fallback
  20069. // state. Now that we have additional work, cancel the timeout.
  20070. root.timeoutHandle = noTimeout;
  20071. // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
  20072. cancelTimeout(timeoutHandle);
  20073. }
  20074. if (workInProgress !== null) {
  20075. var interruptedWork = workInProgress.return;
  20076. while (interruptedWork !== null) {
  20077. unwindInterruptedWork(interruptedWork);
  20078. interruptedWork = interruptedWork.return;
  20079. }
  20080. }
  20081. workInProgressRoot = root;
  20082. workInProgress = createWorkInProgress(root.current, null, expirationTime);
  20083. renderExpirationTime = expirationTime;
  20084. workInProgressRootExitStatus = RootIncomplete;
  20085. workInProgressRootLatestProcessedExpirationTime = Sync;
  20086. workInProgressRootLatestSuspenseTimeout = Sync;
  20087. workInProgressRootCanSuspendUsingConfig = null;
  20088. workInProgressRootHasPendingPing = false;
  20089. if (enableSchedulerTracing) {
  20090. spawnedWorkDuringRender = null;
  20091. }
  20092. {
  20093. ReactStrictModeWarnings.discardPendingWarnings();
  20094. componentsThatTriggeredHighPriSuspend = null;
  20095. }
  20096. }
  20097. function renderRoot(root, expirationTime, isSync) {
  20098. (function () {
  20099. if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
  20100. {
  20101. throw ReactError(Error('Should not already be working.'));
  20102. }
  20103. }
  20104. })();
  20105. if (enableUserTimingAPI && expirationTime !== Sync) {
  20106. var didExpire = isSync;
  20107. stopRequestCallbackTimer(didExpire);
  20108. }
  20109. if (root.firstPendingTime < expirationTime) {
  20110. // If there's no work left at this expiration time, exit immediately. This
  20111. // happens when multiple callbacks are scheduled for a single root, but an
  20112. // earlier callback flushes the work of a later one.
  20113. return null;
  20114. }
  20115. if (isSync && root.finishedExpirationTime === expirationTime) {
  20116. // There's already a pending commit at this expiration time.
  20117. // TODO: This is poorly factored. This case only exists for the
  20118. // batch.commit() API.
  20119. return commitRoot.bind(null, root);
  20120. }
  20121. flushPassiveEffects();
  20122. // If the root or expiration time have changed, throw out the existing stack
  20123. // and prepare a fresh one. Otherwise we'll continue where we left off.
  20124. if (root !== workInProgressRoot || expirationTime !== renderExpirationTime) {
  20125. prepareFreshStack(root, expirationTime);
  20126. startWorkOnPendingInteractions(root, expirationTime);
  20127. } else if (workInProgressRootExitStatus === RootSuspendedWithDelay) {
  20128. // We could've received an update at a lower priority while we yielded.
  20129. // We're suspended in a delayed state. Once we complete this render we're
  20130. // just going to try to recover at the last pending time anyway so we might
  20131. // as well start doing that eagerly.
  20132. // Ideally we should be able to do this even for retries but we don't yet
  20133. // know if we're going to process an update which wants to commit earlier,
  20134. // and this path happens very early so it would happen too often. Instead,
  20135. // for that case, we'll wait until we complete.
  20136. if (workInProgressRootHasPendingPing) {
  20137. // We have a ping at this expiration. Let's restart to see if we get unblocked.
  20138. prepareFreshStack(root, expirationTime);
  20139. } else {
  20140. var lastPendingTime = root.lastPendingTime;
  20141. if (lastPendingTime < expirationTime) {
  20142. // There's lower priority work. It might be unsuspended. Try rendering
  20143. // at that level immediately, while preserving the position in the queue.
  20144. return renderRoot.bind(null, root, lastPendingTime);
  20145. }
  20146. }
  20147. }
  20148. // If we have a work-in-progress fiber, it means there's still work to do
  20149. // in this root.
  20150. if (workInProgress !== null) {
  20151. var prevExecutionContext = executionContext;
  20152. executionContext |= RenderContext;
  20153. var prevDispatcher = ReactCurrentDispatcher.current;
  20154. if (prevDispatcher === null) {
  20155. // The React isomorphic package does not include a default dispatcher.
  20156. // Instead the first renderer will lazily attach one, in order to give
  20157. // nicer error messages.
  20158. prevDispatcher = ContextOnlyDispatcher;
  20159. }
  20160. ReactCurrentDispatcher.current = ContextOnlyDispatcher;
  20161. var prevInteractions = null;
  20162. if (enableSchedulerTracing) {
  20163. prevInteractions = tracing.__interactionsRef.current;
  20164. tracing.__interactionsRef.current = root.memoizedInteractions;
  20165. }
  20166. startWorkLoopTimer(workInProgress);
  20167. // TODO: Fork renderRoot into renderRootSync and renderRootAsync
  20168. if (isSync) {
  20169. if (expirationTime !== Sync) {
  20170. // An async update expired. There may be other expired updates on
  20171. // this root. We should render all the expired work in a
  20172. // single batch.
  20173. var currentTime = requestCurrentTime();
  20174. if (currentTime < expirationTime) {
  20175. // Restart at the current time.
  20176. executionContext = prevExecutionContext;
  20177. resetContextDependencies();
  20178. ReactCurrentDispatcher.current = prevDispatcher;
  20179. if (enableSchedulerTracing) {
  20180. tracing.__interactionsRef.current = prevInteractions;
  20181. }
  20182. return renderRoot.bind(null, root, currentTime);
  20183. }
  20184. }
  20185. } else {
  20186. // Since we know we're in a React event, we can clear the current
  20187. // event time. The next update will compute a new event time.
  20188. currentEventTime = NoWork;
  20189. }
  20190. do {
  20191. try {
  20192. if (isSync) {
  20193. workLoopSync();
  20194. } else {
  20195. workLoop();
  20196. }
  20197. break;
  20198. } catch (thrownValue) {
  20199. // Reset module-level state that was set during the render phase.
  20200. resetContextDependencies();
  20201. resetHooks();
  20202. var sourceFiber = workInProgress;
  20203. if (sourceFiber === null || sourceFiber.return === null) {
  20204. // Expected to be working on a non-root fiber. This is a fatal error
  20205. // because there's no ancestor that can handle it; the root is
  20206. // supposed to capture all errors that weren't caught by an error
  20207. // boundary.
  20208. prepareFreshStack(root, expirationTime);
  20209. executionContext = prevExecutionContext;
  20210. throw thrownValue;
  20211. }
  20212. if (enableProfilerTimer && sourceFiber.mode & ProfileMode) {
  20213. // Record the time spent rendering before an error was thrown. This
  20214. // avoids inaccurate Profiler durations in the case of a
  20215. // suspended render.
  20216. stopProfilerTimerIfRunningAndRecordDelta(sourceFiber, true);
  20217. }
  20218. var returnFiber = sourceFiber.return;
  20219. throwException(root, returnFiber, sourceFiber, thrownValue, renderExpirationTime);
  20220. workInProgress = completeUnitOfWork(sourceFiber);
  20221. }
  20222. } while (true);
  20223. executionContext = prevExecutionContext;
  20224. resetContextDependencies();
  20225. ReactCurrentDispatcher.current = prevDispatcher;
  20226. if (enableSchedulerTracing) {
  20227. tracing.__interactionsRef.current = prevInteractions;
  20228. }
  20229. if (workInProgress !== null) {
  20230. // There's still work left over. Return a continuation.
  20231. stopInterruptedWorkLoopTimer();
  20232. if (expirationTime !== Sync) {
  20233. startRequestCallbackTimer();
  20234. }
  20235. return renderRoot.bind(null, root, expirationTime);
  20236. }
  20237. }
  20238. // We now have a consistent tree. The next step is either to commit it, or, if
  20239. // something suspended, wait to commit it after a timeout.
  20240. stopFinishedWorkLoopTimer();
  20241. root.finishedWork = root.current.alternate;
  20242. root.finishedExpirationTime = expirationTime;
  20243. var isLocked = resolveLocksOnRoot(root, expirationTime);
  20244. if (isLocked) {
  20245. // This root has a lock that prevents it from committing. Exit. If we begin
  20246. // work on the root again, without any intervening updates, it will finish
  20247. // without doing additional work.
  20248. return null;
  20249. }
  20250. // Set this to null to indicate there's no in-progress render.
  20251. workInProgressRoot = null;
  20252. switch (workInProgressRootExitStatus) {
  20253. case RootIncomplete:
  20254. {
  20255. (function () {
  20256. {
  20257. {
  20258. throw ReactError(Error('Should have a work-in-progress.'));
  20259. }
  20260. }
  20261. })();
  20262. }
  20263. // Flow knows about invariant, so it complains if I add a break statement,
  20264. // but eslint doesn't know about invariant, so it complains if I do.
  20265. // eslint-disable-next-line no-fallthrough
  20266. case RootErrored:
  20267. {
  20268. // An error was thrown. First check if there is lower priority work
  20269. // scheduled on this root.
  20270. var _lastPendingTime = root.lastPendingTime;
  20271. if (_lastPendingTime < expirationTime) {
  20272. // There's lower priority work. Before raising the error, try rendering
  20273. // at the lower priority to see if it fixes it. Use a continuation to
  20274. // maintain the existing priority and position in the queue.
  20275. return renderRoot.bind(null, root, _lastPendingTime);
  20276. }
  20277. if (!isSync) {
  20278. // If we're rendering asynchronously, it's possible the error was
  20279. // caused by tearing due to a mutation during an event. Try rendering
  20280. // one more time without yiedling to events.
  20281. prepareFreshStack(root, expirationTime);
  20282. scheduleSyncCallback(renderRoot.bind(null, root, expirationTime));
  20283. return null;
  20284. }
  20285. // If we're already rendering synchronously, commit the root in its
  20286. // errored state.
  20287. return commitRoot.bind(null, root);
  20288. }
  20289. case RootSuspended:
  20290. {
  20291. flushSuspensePriorityWarningInDEV();
  20292. // We have an acceptable loading state. We need to figure out if we should
  20293. // immediately commit it or wait a bit.
  20294. // If we have processed new updates during this render, we may now have a
  20295. // new loading state ready. We want to ensure that we commit that as soon as
  20296. // possible.
  20297. var hasNotProcessedNewUpdates = workInProgressRootLatestProcessedExpirationTime === Sync;
  20298. if (hasNotProcessedNewUpdates && !isSync &&
  20299. // do not delay if we're inside an act() scope
  20300. !( true && flushSuspenseFallbacksInTests && IsThisRendererActing.current)) {
  20301. // If we have not processed any new updates during this pass, then this is
  20302. // either a retry of an existing fallback state or a hidden tree.
  20303. // Hidden trees shouldn't be batched with other work and after that's
  20304. // fixed it can only be a retry.
  20305. // We're going to throttle committing retries so that we don't show too
  20306. // many loading states too quickly.
  20307. var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now();
  20308. // Don't bother with a very short suspense time.
  20309. if (msUntilTimeout > 10) {
  20310. if (workInProgressRootHasPendingPing) {
  20311. // This render was pinged but we didn't get to restart earlier so try
  20312. // restarting now instead.
  20313. prepareFreshStack(root, expirationTime);
  20314. return renderRoot.bind(null, root, expirationTime);
  20315. }
  20316. var _lastPendingTime2 = root.lastPendingTime;
  20317. if (_lastPendingTime2 < expirationTime) {
  20318. // There's lower priority work. It might be unsuspended. Try rendering
  20319. // at that level.
  20320. return renderRoot.bind(null, root, _lastPendingTime2);
  20321. }
  20322. // The render is suspended, it hasn't timed out, and there's no lower
  20323. // priority work to do. Instead of committing the fallback
  20324. // immediately, wait for more data to arrive.
  20325. root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), msUntilTimeout);
  20326. return null;
  20327. }
  20328. }
  20329. // The work expired. Commit immediately.
  20330. return commitRoot.bind(null, root);
  20331. }
  20332. case RootSuspendedWithDelay:
  20333. {
  20334. flushSuspensePriorityWarningInDEV();
  20335. if (!isSync &&
  20336. // do not delay if we're inside an act() scope
  20337. !( true && flushSuspenseFallbacksInTests && IsThisRendererActing.current)) {
  20338. // We're suspended in a state that should be avoided. We'll try to avoid committing
  20339. // it for as long as the timeouts let us.
  20340. if (workInProgressRootHasPendingPing) {
  20341. // This render was pinged but we didn't get to restart earlier so try
  20342. // restarting now instead.
  20343. prepareFreshStack(root, expirationTime);
  20344. return renderRoot.bind(null, root, expirationTime);
  20345. }
  20346. var _lastPendingTime3 = root.lastPendingTime;
  20347. if (_lastPendingTime3 < expirationTime) {
  20348. // There's lower priority work. It might be unsuspended. Try rendering
  20349. // at that level immediately.
  20350. return renderRoot.bind(null, root, _lastPendingTime3);
  20351. }
  20352. var _msUntilTimeout = void 0;
  20353. if (workInProgressRootLatestSuspenseTimeout !== Sync) {
  20354. // We have processed a suspense config whose expiration time we can use as
  20355. // the timeout.
  20356. _msUntilTimeout = expirationTimeToMs(workInProgressRootLatestSuspenseTimeout) - now();
  20357. } else if (workInProgressRootLatestProcessedExpirationTime === Sync) {
  20358. // This should never normally happen because only new updates cause
  20359. // delayed states, so we should have processed something. However,
  20360. // this could also happen in an offscreen tree.
  20361. _msUntilTimeout = 0;
  20362. } else {
  20363. // If we don't have a suspense config, we're going to use a heuristic to
  20364. var eventTimeMs = inferTimeFromExpirationTime(workInProgressRootLatestProcessedExpirationTime);
  20365. var currentTimeMs = now();
  20366. var timeUntilExpirationMs = expirationTimeToMs(expirationTime) - currentTimeMs;
  20367. var timeElapsed = currentTimeMs - eventTimeMs;
  20368. if (timeElapsed < 0) {
  20369. // We get this wrong some time since we estimate the time.
  20370. timeElapsed = 0;
  20371. }
  20372. _msUntilTimeout = jnd(timeElapsed) - timeElapsed;
  20373. // Clamp the timeout to the expiration time.
  20374. // TODO: Once the event time is exact instead of inferred from expiration time
  20375. // we don't need this.
  20376. if (timeUntilExpirationMs < _msUntilTimeout) {
  20377. _msUntilTimeout = timeUntilExpirationMs;
  20378. }
  20379. }
  20380. // Don't bother with a very short suspense time.
  20381. if (_msUntilTimeout > 10) {
  20382. // The render is suspended, it hasn't timed out, and there's no lower
  20383. // priority work to do. Instead of committing the fallback
  20384. // immediately, wait for more data to arrive.
  20385. root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout);
  20386. return null;
  20387. }
  20388. }
  20389. // The work expired. Commit immediately.
  20390. return commitRoot.bind(null, root);
  20391. }
  20392. case RootCompleted:
  20393. {
  20394. // The work completed. Ready to commit.
  20395. if (!isSync &&
  20396. // do not delay if we're inside an act() scope
  20397. !( true && flushSuspenseFallbacksInTests && IsThisRendererActing.current) && workInProgressRootLatestProcessedExpirationTime !== Sync && workInProgressRootCanSuspendUsingConfig !== null) {
  20398. // If we have exceeded the minimum loading delay, which probably
  20399. // means we have shown a spinner already, we might have to suspend
  20400. // a bit longer to ensure that the spinner is shown for enough time.
  20401. var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay(workInProgressRootLatestProcessedExpirationTime, expirationTime, workInProgressRootCanSuspendUsingConfig);
  20402. if (_msUntilTimeout2 > 10) {
  20403. root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout2);
  20404. return null;
  20405. }
  20406. }
  20407. return commitRoot.bind(null, root);
  20408. }
  20409. default:
  20410. {
  20411. (function () {
  20412. {
  20413. {
  20414. throw ReactError(Error('Unknown root exit status.'));
  20415. }
  20416. }
  20417. })();
  20418. }
  20419. }
  20420. }
  20421. function markCommitTimeOfFallback() {
  20422. globalMostRecentFallbackTime = now();
  20423. }
  20424. function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) {
  20425. if (expirationTime < workInProgressRootLatestProcessedExpirationTime && expirationTime > Never) {
  20426. workInProgressRootLatestProcessedExpirationTime = expirationTime;
  20427. }
  20428. if (suspenseConfig !== null) {
  20429. if (expirationTime < workInProgressRootLatestSuspenseTimeout && expirationTime > Never) {
  20430. workInProgressRootLatestSuspenseTimeout = expirationTime;
  20431. // Most of the time we only have one config and getting wrong is not bad.
  20432. workInProgressRootCanSuspendUsingConfig = suspenseConfig;
  20433. }
  20434. }
  20435. }
  20436. function renderDidSuspend() {
  20437. if (workInProgressRootExitStatus === RootIncomplete) {
  20438. workInProgressRootExitStatus = RootSuspended;
  20439. }
  20440. }
  20441. function renderDidSuspendDelayIfPossible() {
  20442. if (workInProgressRootExitStatus === RootIncomplete || workInProgressRootExitStatus === RootSuspended) {
  20443. workInProgressRootExitStatus = RootSuspendedWithDelay;
  20444. }
  20445. }
  20446. function renderDidError() {
  20447. if (workInProgressRootExitStatus !== RootCompleted) {
  20448. workInProgressRootExitStatus = RootErrored;
  20449. }
  20450. }
  20451. // Called during render to determine if anything has suspended.
  20452. // Returns false if we're not sure.
  20453. function renderHasNotSuspendedYet() {
  20454. // If something errored or completed, we can't really be sure,
  20455. // so those are false.
  20456. return workInProgressRootExitStatus === RootIncomplete;
  20457. }
  20458. function inferTimeFromExpirationTime(expirationTime) {
  20459. // We don't know exactly when the update was scheduled, but we can infer an
  20460. // approximate start time from the expiration time.
  20461. var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
  20462. return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION;
  20463. }
  20464. function inferTimeFromExpirationTimeWithSuspenseConfig(expirationTime, suspenseConfig) {
  20465. // We don't know exactly when the update was scheduled, but we can infer an
  20466. // approximate start time from the expiration time by subtracting the timeout
  20467. // that was added to the event time.
  20468. var earliestExpirationTimeMs = expirationTimeToMs(expirationTime);
  20469. return earliestExpirationTimeMs - (suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION);
  20470. }
  20471. function workLoopSync() {
  20472. // Already timed out, so perform work without checking if we need to yield.
  20473. while (workInProgress !== null) {
  20474. workInProgress = performUnitOfWork(workInProgress);
  20475. }
  20476. }
  20477. function workLoop() {
  20478. // Perform work until Scheduler asks us to yield
  20479. while (workInProgress !== null && !shouldYield()) {
  20480. workInProgress = performUnitOfWork(workInProgress);
  20481. }
  20482. }
  20483. function performUnitOfWork(unitOfWork) {
  20484. // The current, flushed, state of this fiber is the alternate. Ideally
  20485. // nothing should rely on this, but relying on it here means that we don't
  20486. // need an additional field on the work in progress.
  20487. var current$$1 = unitOfWork.alternate;
  20488. startWorkTimer(unitOfWork);
  20489. setCurrentFiber(unitOfWork);
  20490. var next = void 0;
  20491. if (enableProfilerTimer && (unitOfWork.mode & ProfileMode) !== NoMode) {
  20492. startProfilerTimer(unitOfWork);
  20493. next = beginWork$$1(current$$1, unitOfWork, renderExpirationTime);
  20494. stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);
  20495. } else {
  20496. next = beginWork$$1(current$$1, unitOfWork, renderExpirationTime);
  20497. }
  20498. resetCurrentFiber();
  20499. unitOfWork.memoizedProps = unitOfWork.pendingProps;
  20500. if (next === null) {
  20501. // If this doesn't spawn new work, complete the current work.
  20502. next = completeUnitOfWork(unitOfWork);
  20503. }
  20504. ReactCurrentOwner$2.current = null;
  20505. return next;
  20506. }
  20507. function completeUnitOfWork(unitOfWork) {
  20508. // Attempt to complete the current unit of work, then move to the next
  20509. // sibling. If there are no more siblings, return to the parent fiber.
  20510. workInProgress = unitOfWork;
  20511. do {
  20512. // The current, flushed, state of this fiber is the alternate. Ideally
  20513. // nothing should rely on this, but relying on it here means that we don't
  20514. // need an additional field on the work in progress.
  20515. var current$$1 = workInProgress.alternate;
  20516. var returnFiber = workInProgress.return;
  20517. // Check if the work completed or if something threw.
  20518. if ((workInProgress.effectTag & Incomplete) === NoEffect) {
  20519. setCurrentFiber(workInProgress);
  20520. var next = void 0;
  20521. if (!enableProfilerTimer || (workInProgress.mode & ProfileMode) === NoMode) {
  20522. next = completeWork(current$$1, workInProgress, renderExpirationTime);
  20523. } else {
  20524. startProfilerTimer(workInProgress);
  20525. next = completeWork(current$$1, workInProgress, renderExpirationTime);
  20526. // Update render duration assuming we didn't error.
  20527. stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
  20528. }
  20529. stopWorkTimer(workInProgress);
  20530. resetCurrentFiber();
  20531. resetChildExpirationTime(workInProgress);
  20532. if (next !== null) {
  20533. // Completing this fiber spawned new work. Work on that next.
  20534. return next;
  20535. }
  20536. if (returnFiber !== null &&
  20537. // Do not append effects to parents if a sibling failed to complete
  20538. (returnFiber.effectTag & Incomplete) === NoEffect) {
  20539. // Append all the effects of the subtree and this fiber onto the effect
  20540. // list of the parent. The completion order of the children affects the
  20541. // side-effect order.
  20542. if (returnFiber.firstEffect === null) {
  20543. returnFiber.firstEffect = workInProgress.firstEffect;
  20544. }
  20545. if (workInProgress.lastEffect !== null) {
  20546. if (returnFiber.lastEffect !== null) {
  20547. returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
  20548. }
  20549. returnFiber.lastEffect = workInProgress.lastEffect;
  20550. }
  20551. // If this fiber had side-effects, we append it AFTER the children's
  20552. // side-effects. We can perform certain side-effects earlier if needed,
  20553. // by doing multiple passes over the effect list. We don't want to
  20554. // schedule our own side-effect on our own list because if end up
  20555. // reusing children we'll schedule this effect onto itself since we're
  20556. // at the end.
  20557. var effectTag = workInProgress.effectTag;
  20558. // Skip both NoWork and PerformedWork tags when creating the effect
  20559. // list. PerformedWork effect is read by React DevTools but shouldn't be
  20560. // committed.
  20561. if (effectTag > PerformedWork) {
  20562. if (returnFiber.lastEffect !== null) {
  20563. returnFiber.lastEffect.nextEffect = workInProgress;
  20564. } else {
  20565. returnFiber.firstEffect = workInProgress;
  20566. }
  20567. returnFiber.lastEffect = workInProgress;
  20568. }
  20569. }
  20570. } else {
  20571. // This fiber did not complete because something threw. Pop values off
  20572. // the stack without entering the complete phase. If this is a boundary,
  20573. // capture values if possible.
  20574. var _next = unwindWork(workInProgress, renderExpirationTime);
  20575. // Because this fiber did not complete, don't reset its expiration time.
  20576. if (enableProfilerTimer && (workInProgress.mode & ProfileMode) !== NoMode) {
  20577. // Record the render duration for the fiber that errored.
  20578. stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false);
  20579. // Include the time spent working on failed children before continuing.
  20580. var actualDuration = workInProgress.actualDuration;
  20581. var child = workInProgress.child;
  20582. while (child !== null) {
  20583. actualDuration += child.actualDuration;
  20584. child = child.sibling;
  20585. }
  20586. workInProgress.actualDuration = actualDuration;
  20587. }
  20588. if (_next !== null) {
  20589. // If completing this work spawned new work, do that next. We'll come
  20590. // back here again.
  20591. // Since we're restarting, remove anything that is not a host effect
  20592. // from the effect tag.
  20593. // TODO: The name stopFailedWorkTimer is misleading because Suspense
  20594. // also captures and restarts.
  20595. stopFailedWorkTimer(workInProgress);
  20596. _next.effectTag &= HostEffectMask;
  20597. return _next;
  20598. }
  20599. stopWorkTimer(workInProgress);
  20600. if (returnFiber !== null) {
  20601. // Mark the parent fiber as incomplete and clear its effect list.
  20602. returnFiber.firstEffect = returnFiber.lastEffect = null;
  20603. returnFiber.effectTag |= Incomplete;
  20604. }
  20605. }
  20606. var siblingFiber = workInProgress.sibling;
  20607. if (siblingFiber !== null) {
  20608. // If there is more work to do in this returnFiber, do that next.
  20609. return siblingFiber;
  20610. }
  20611. // Otherwise, return to the parent
  20612. workInProgress = returnFiber;
  20613. } while (workInProgress !== null);
  20614. // We've reached the root.
  20615. if (workInProgressRootExitStatus === RootIncomplete) {
  20616. workInProgressRootExitStatus = RootCompleted;
  20617. }
  20618. return null;
  20619. }
  20620. function resetChildExpirationTime(completedWork) {
  20621. if (renderExpirationTime !== Never && completedWork.childExpirationTime === Never) {
  20622. // The children of this component are hidden. Don't bubble their
  20623. // expiration times.
  20624. return;
  20625. }
  20626. var newChildExpirationTime = NoWork;
  20627. // Bubble up the earliest expiration time.
  20628. if (enableProfilerTimer && (completedWork.mode & ProfileMode) !== NoMode) {
  20629. // In profiling mode, resetChildExpirationTime is also used to reset
  20630. // profiler durations.
  20631. var actualDuration = completedWork.actualDuration;
  20632. var treeBaseDuration = completedWork.selfBaseDuration;
  20633. // When a fiber is cloned, its actualDuration is reset to 0. This value will
  20634. // only be updated if work is done on the fiber (i.e. it doesn't bailout).
  20635. // When work is done, it should bubble to the parent's actualDuration. If
  20636. // the fiber has not been cloned though, (meaning no work was done), then
  20637. // this value will reflect the amount of time spent working on a previous
  20638. // render. In that case it should not bubble. We determine whether it was
  20639. // cloned by comparing the child pointer.
  20640. var shouldBubbleActualDurations = completedWork.alternate === null || completedWork.child !== completedWork.alternate.child;
  20641. var child = completedWork.child;
  20642. while (child !== null) {
  20643. var childUpdateExpirationTime = child.expirationTime;
  20644. var childChildExpirationTime = child.childExpirationTime;
  20645. if (childUpdateExpirationTime > newChildExpirationTime) {
  20646. newChildExpirationTime = childUpdateExpirationTime;
  20647. }
  20648. if (childChildExpirationTime > newChildExpirationTime) {
  20649. newChildExpirationTime = childChildExpirationTime;
  20650. }
  20651. if (shouldBubbleActualDurations) {
  20652. actualDuration += child.actualDuration;
  20653. }
  20654. treeBaseDuration += child.treeBaseDuration;
  20655. child = child.sibling;
  20656. }
  20657. completedWork.actualDuration = actualDuration;
  20658. completedWork.treeBaseDuration = treeBaseDuration;
  20659. } else {
  20660. var _child = completedWork.child;
  20661. while (_child !== null) {
  20662. var _childUpdateExpirationTime = _child.expirationTime;
  20663. var _childChildExpirationTime = _child.childExpirationTime;
  20664. if (_childUpdateExpirationTime > newChildExpirationTime) {
  20665. newChildExpirationTime = _childUpdateExpirationTime;
  20666. }
  20667. if (_childChildExpirationTime > newChildExpirationTime) {
  20668. newChildExpirationTime = _childChildExpirationTime;
  20669. }
  20670. _child = _child.sibling;
  20671. }
  20672. }
  20673. completedWork.childExpirationTime = newChildExpirationTime;
  20674. }
  20675. function commitRoot(root) {
  20676. var renderPriorityLevel = getCurrentPriorityLevel();
  20677. runWithPriority$2(ImmediatePriority, commitRootImpl.bind(null, root, renderPriorityLevel));
  20678. // If there are passive effects, schedule a callback to flush them. This goes
  20679. // outside commitRootImpl so that it inherits the priority of the render.
  20680. if (rootWithPendingPassiveEffects !== null) {
  20681. scheduleCallback(NormalPriority, function () {
  20682. flushPassiveEffects();
  20683. return null;
  20684. });
  20685. }
  20686. return null;
  20687. }
  20688. function commitRootImpl(root, renderPriorityLevel) {
  20689. flushPassiveEffects();
  20690. flushRenderPhaseStrictModeWarningsInDEV();
  20691. (function () {
  20692. if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
  20693. {
  20694. throw ReactError(Error('Should not already be working.'));
  20695. }
  20696. }
  20697. })();
  20698. var finishedWork = root.finishedWork;
  20699. var expirationTime = root.finishedExpirationTime;
  20700. if (finishedWork === null) {
  20701. return null;
  20702. }
  20703. root.finishedWork = null;
  20704. root.finishedExpirationTime = NoWork;
  20705. (function () {
  20706. if (!(finishedWork !== root.current)) {
  20707. {
  20708. throw ReactError(Error('Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue.'));
  20709. }
  20710. }
  20711. })();
  20712. // commitRoot never returns a continuation; it always finishes synchronously.
  20713. // So we can clear these now to allow a new callback to be scheduled.
  20714. root.callbackNode = null;
  20715. root.callbackExpirationTime = NoWork;
  20716. startCommitTimer();
  20717. // Update the first and last pending times on this root. The new first
  20718. // pending time is whatever is left on the root fiber.
  20719. var updateExpirationTimeBeforeCommit = finishedWork.expirationTime;
  20720. var childExpirationTimeBeforeCommit = finishedWork.childExpirationTime;
  20721. var firstPendingTimeBeforeCommit = childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit ? childExpirationTimeBeforeCommit : updateExpirationTimeBeforeCommit;
  20722. root.firstPendingTime = firstPendingTimeBeforeCommit;
  20723. if (firstPendingTimeBeforeCommit < root.lastPendingTime) {
  20724. // This usually means we've finished all the work, but it can also happen
  20725. // when something gets downprioritized during render, like a hidden tree.
  20726. root.lastPendingTime = firstPendingTimeBeforeCommit;
  20727. }
  20728. if (root === workInProgressRoot) {
  20729. // We can reset these now that they are finished.
  20730. workInProgressRoot = null;
  20731. workInProgress = null;
  20732. renderExpirationTime = NoWork;
  20733. } else {}
  20734. // This indicates that the last root we worked on is not the same one that
  20735. // we're committing now. This most commonly happens when a suspended root
  20736. // times out.
  20737. // Get the list of effects.
  20738. var firstEffect = void 0;
  20739. if (finishedWork.effectTag > PerformedWork) {
  20740. // A fiber's effect list consists only of its children, not itself. So if
  20741. // the root has an effect, we need to add it to the end of the list. The
  20742. // resulting list is the set that would belong to the root's parent, if it
  20743. // had one; that is, all the effects in the tree including the root.
  20744. if (finishedWork.lastEffect !== null) {
  20745. finishedWork.lastEffect.nextEffect = finishedWork;
  20746. firstEffect = finishedWork.firstEffect;
  20747. } else {
  20748. firstEffect = finishedWork;
  20749. }
  20750. } else {
  20751. // There is no effect on the root.
  20752. firstEffect = finishedWork.firstEffect;
  20753. }
  20754. if (firstEffect !== null) {
  20755. var prevExecutionContext = executionContext;
  20756. executionContext |= CommitContext;
  20757. var prevInteractions = null;
  20758. if (enableSchedulerTracing) {
  20759. prevInteractions = tracing.__interactionsRef.current;
  20760. tracing.__interactionsRef.current = root.memoizedInteractions;
  20761. }
  20762. // Reset this to null before calling lifecycles
  20763. ReactCurrentOwner$2.current = null;
  20764. // The commit phase is broken into several sub-phases. We do a separate pass
  20765. // of the effect list for each phase: all mutation effects come before all
  20766. // layout effects, and so on.
  20767. // The first phase a "before mutation" phase. We use this phase to read the
  20768. // state of the host tree right before we mutate it. This is where
  20769. // getSnapshotBeforeUpdate is called.
  20770. startCommitSnapshotEffectsTimer();
  20771. prepareForCommit(root.containerInfo);
  20772. nextEffect = firstEffect;
  20773. do {
  20774. {
  20775. invokeGuardedCallback(null, commitBeforeMutationEffects, null);
  20776. if (hasCaughtError()) {
  20777. (function () {
  20778. if (!(nextEffect !== null)) {
  20779. {
  20780. throw ReactError(Error('Should be working on an effect.'));
  20781. }
  20782. }
  20783. })();
  20784. var error = clearCaughtError();
  20785. captureCommitPhaseError(nextEffect, error);
  20786. nextEffect = nextEffect.nextEffect;
  20787. }
  20788. }
  20789. } while (nextEffect !== null);
  20790. stopCommitSnapshotEffectsTimer();
  20791. if (enableProfilerTimer) {
  20792. // Mark the current commit time to be shared by all Profilers in this
  20793. // batch. This enables them to be grouped later.
  20794. recordCommitTime();
  20795. }
  20796. // The next phase is the mutation phase, where we mutate the host tree.
  20797. startCommitHostEffectsTimer();
  20798. nextEffect = firstEffect;
  20799. do {
  20800. {
  20801. invokeGuardedCallback(null, commitMutationEffects, null, renderPriorityLevel);
  20802. if (hasCaughtError()) {
  20803. (function () {
  20804. if (!(nextEffect !== null)) {
  20805. {
  20806. throw ReactError(Error('Should be working on an effect.'));
  20807. }
  20808. }
  20809. })();
  20810. var _error = clearCaughtError();
  20811. captureCommitPhaseError(nextEffect, _error);
  20812. nextEffect = nextEffect.nextEffect;
  20813. }
  20814. }
  20815. } while (nextEffect !== null);
  20816. stopCommitHostEffectsTimer();
  20817. resetAfterCommit(root.containerInfo);
  20818. // The work-in-progress tree is now the current tree. This must come after
  20819. // the mutation phase, so that the previous tree is still current during
  20820. // componentWillUnmount, but before the layout phase, so that the finished
  20821. // work is current during componentDidMount/Update.
  20822. root.current = finishedWork;
  20823. // The next phase is the layout phase, where we call effects that read
  20824. // the host tree after it's been mutated. The idiomatic use case for this is
  20825. // layout, but class component lifecycles also fire here for legacy reasons.
  20826. startCommitLifeCyclesTimer();
  20827. nextEffect = firstEffect;
  20828. do {
  20829. {
  20830. invokeGuardedCallback(null, commitLayoutEffects, null, root, expirationTime);
  20831. if (hasCaughtError()) {
  20832. (function () {
  20833. if (!(nextEffect !== null)) {
  20834. {
  20835. throw ReactError(Error('Should be working on an effect.'));
  20836. }
  20837. }
  20838. })();
  20839. var _error2 = clearCaughtError();
  20840. captureCommitPhaseError(nextEffect, _error2);
  20841. nextEffect = nextEffect.nextEffect;
  20842. }
  20843. }
  20844. } while (nextEffect !== null);
  20845. stopCommitLifeCyclesTimer();
  20846. nextEffect = null;
  20847. // Tell Scheduler to yield at the end of the frame, so the browser has an
  20848. // opportunity to paint.
  20849. requestPaint();
  20850. if (enableSchedulerTracing) {
  20851. tracing.__interactionsRef.current = prevInteractions;
  20852. }
  20853. executionContext = prevExecutionContext;
  20854. } else {
  20855. // No effects.
  20856. root.current = finishedWork;
  20857. // Measure these anyway so the flamegraph explicitly shows that there were
  20858. // no effects.
  20859. // TODO: Maybe there's a better way to report this.
  20860. startCommitSnapshotEffectsTimer();
  20861. stopCommitSnapshotEffectsTimer();
  20862. if (enableProfilerTimer) {
  20863. recordCommitTime();
  20864. }
  20865. startCommitHostEffectsTimer();
  20866. stopCommitHostEffectsTimer();
  20867. startCommitLifeCyclesTimer();
  20868. stopCommitLifeCyclesTimer();
  20869. }
  20870. stopCommitTimer();
  20871. var rootDidHavePassiveEffects = rootDoesHavePassiveEffects;
  20872. if (rootDoesHavePassiveEffects) {
  20873. // This commit has passive effects. Stash a reference to them. But don't
  20874. // schedule a callback until after flushing layout work.
  20875. rootDoesHavePassiveEffects = false;
  20876. rootWithPendingPassiveEffects = root;
  20877. pendingPassiveEffectsExpirationTime = expirationTime;
  20878. pendingPassiveEffectsRenderPriority = renderPriorityLevel;
  20879. } else {
  20880. // We are done with the effect chain at this point so let's clear the
  20881. // nextEffect pointers to assist with GC. If we have passive effects, we'll
  20882. // clear this in flushPassiveEffects.
  20883. nextEffect = firstEffect;
  20884. while (nextEffect !== null) {
  20885. var nextNextEffect = nextEffect.nextEffect;
  20886. nextEffect.nextEffect = null;
  20887. nextEffect = nextNextEffect;
  20888. }
  20889. }
  20890. // Check if there's remaining work on this root
  20891. var remainingExpirationTime = root.firstPendingTime;
  20892. if (remainingExpirationTime !== NoWork) {
  20893. var currentTime = requestCurrentTime();
  20894. var priorityLevel = inferPriorityFromExpirationTime(currentTime, remainingExpirationTime);
  20895. if (enableSchedulerTracing) {
  20896. if (spawnedWorkDuringRender !== null) {
  20897. var expirationTimes = spawnedWorkDuringRender;
  20898. spawnedWorkDuringRender = null;
  20899. for (var i = 0; i < expirationTimes.length; i++) {
  20900. scheduleInteractions(root, expirationTimes[i], root.memoizedInteractions);
  20901. }
  20902. }
  20903. }
  20904. scheduleCallbackForRoot(root, priorityLevel, remainingExpirationTime);
  20905. } else {
  20906. // If there's no remaining work, we can clear the set of already failed
  20907. // error boundaries.
  20908. legacyErrorBoundariesThatAlreadyFailed = null;
  20909. }
  20910. if (enableSchedulerTracing) {
  20911. if (!rootDidHavePassiveEffects) {
  20912. // If there are no passive effects, then we can complete the pending interactions.
  20913. // Otherwise, we'll wait until after the passive effects are flushed.
  20914. // Wait to do this until after remaining work has been scheduled,
  20915. // so that we don't prematurely signal complete for interactions when there's e.g. hidden work.
  20916. finishPendingInteractions(root, expirationTime);
  20917. }
  20918. }
  20919. onCommitRoot(finishedWork.stateNode, expirationTime);
  20920. if (remainingExpirationTime === Sync) {
  20921. // Count the number of times the root synchronously re-renders without
  20922. // finishing. If there are too many, it indicates an infinite update loop.
  20923. if (root === rootWithNestedUpdates) {
  20924. nestedUpdateCount++;
  20925. } else {
  20926. nestedUpdateCount = 0;
  20927. rootWithNestedUpdates = root;
  20928. }
  20929. } else {
  20930. nestedUpdateCount = 0;
  20931. }
  20932. if (hasUncaughtError) {
  20933. hasUncaughtError = false;
  20934. var _error3 = firstUncaughtError;
  20935. firstUncaughtError = null;
  20936. throw _error3;
  20937. }
  20938. if ((executionContext & LegacyUnbatchedContext) !== NoContext) {
  20939. // This is a legacy edge case. We just committed the initial mount of
  20940. // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired
  20941. // synchronously, but layout updates should be deferred until the end
  20942. // of the batch.
  20943. return null;
  20944. }
  20945. // If layout work was scheduled, flush it now.
  20946. flushSyncCallbackQueue();
  20947. return null;
  20948. }
  20949. function commitBeforeMutationEffects() {
  20950. while (nextEffect !== null) {
  20951. if ((nextEffect.effectTag & Snapshot) !== NoEffect) {
  20952. setCurrentFiber(nextEffect);
  20953. recordEffect();
  20954. var current$$1 = nextEffect.alternate;
  20955. commitBeforeMutationLifeCycles(current$$1, nextEffect);
  20956. resetCurrentFiber();
  20957. }
  20958. nextEffect = nextEffect.nextEffect;
  20959. }
  20960. }
  20961. function commitMutationEffects(renderPriorityLevel) {
  20962. // TODO: Should probably move the bulk of this function to commitWork.
  20963. while (nextEffect !== null) {
  20964. setCurrentFiber(nextEffect);
  20965. var effectTag = nextEffect.effectTag;
  20966. if (effectTag & ContentReset) {
  20967. commitResetTextContent(nextEffect);
  20968. }
  20969. if (effectTag & Ref) {
  20970. var current$$1 = nextEffect.alternate;
  20971. if (current$$1 !== null) {
  20972. commitDetachRef(current$$1);
  20973. }
  20974. }
  20975. // The following switch statement is only concerned about placement,
  20976. // updates, and deletions. To avoid needing to add a case for every possible
  20977. // bitmap value, we remove the secondary effects from the effect tag and
  20978. // switch on that value.
  20979. var primaryEffectTag = effectTag & (Placement | Update | Deletion);
  20980. switch (primaryEffectTag) {
  20981. case Placement:
  20982. {
  20983. commitPlacement(nextEffect);
  20984. // Clear the "placement" from effect tag so that we know that this is
  20985. // inserted, before any life-cycles like componentDidMount gets called.
  20986. // TODO: findDOMNode doesn't rely on this any more but isMounted does
  20987. // and isMounted is deprecated anyway so we should be able to kill this.
  20988. nextEffect.effectTag &= ~Placement;
  20989. break;
  20990. }
  20991. case PlacementAndUpdate:
  20992. {
  20993. // Placement
  20994. commitPlacement(nextEffect);
  20995. // Clear the "placement" from effect tag so that we know that this is
  20996. // inserted, before any life-cycles like componentDidMount gets called.
  20997. nextEffect.effectTag &= ~Placement;
  20998. // Update
  20999. var _current = nextEffect.alternate;
  21000. commitWork(_current, nextEffect);
  21001. break;
  21002. }
  21003. case Update:
  21004. {
  21005. var _current2 = nextEffect.alternate;
  21006. commitWork(_current2, nextEffect);
  21007. break;
  21008. }
  21009. case Deletion:
  21010. {
  21011. commitDeletion(nextEffect, renderPriorityLevel);
  21012. break;
  21013. }
  21014. }
  21015. // TODO: Only record a mutation effect if primaryEffectTag is non-zero.
  21016. recordEffect();
  21017. resetCurrentFiber();
  21018. nextEffect = nextEffect.nextEffect;
  21019. }
  21020. }
  21021. function commitLayoutEffects(root, committedExpirationTime) {
  21022. // TODO: Should probably move the bulk of this function to commitWork.
  21023. while (nextEffect !== null) {
  21024. setCurrentFiber(nextEffect);
  21025. var effectTag = nextEffect.effectTag;
  21026. if (effectTag & (Update | Callback)) {
  21027. recordEffect();
  21028. var current$$1 = nextEffect.alternate;
  21029. commitLifeCycles(root, current$$1, nextEffect, committedExpirationTime);
  21030. }
  21031. if (effectTag & Ref) {
  21032. recordEffect();
  21033. commitAttachRef(nextEffect);
  21034. }
  21035. if (effectTag & Passive) {
  21036. rootDoesHavePassiveEffects = true;
  21037. }
  21038. resetCurrentFiber();
  21039. nextEffect = nextEffect.nextEffect;
  21040. }
  21041. }
  21042. function flushPassiveEffects() {
  21043. if (rootWithPendingPassiveEffects === null) {
  21044. return false;
  21045. }
  21046. var root = rootWithPendingPassiveEffects;
  21047. var expirationTime = pendingPassiveEffectsExpirationTime;
  21048. var renderPriorityLevel = pendingPassiveEffectsRenderPriority;
  21049. rootWithPendingPassiveEffects = null;
  21050. pendingPassiveEffectsExpirationTime = NoWork;
  21051. pendingPassiveEffectsRenderPriority = NoPriority;
  21052. var priorityLevel = renderPriorityLevel > NormalPriority ? NormalPriority : renderPriorityLevel;
  21053. return runWithPriority$2(priorityLevel, flushPassiveEffectsImpl.bind(null, root, expirationTime));
  21054. }
  21055. function flushPassiveEffectsImpl(root, expirationTime) {
  21056. var prevInteractions = null;
  21057. if (enableSchedulerTracing) {
  21058. prevInteractions = tracing.__interactionsRef.current;
  21059. tracing.__interactionsRef.current = root.memoizedInteractions;
  21060. }
  21061. (function () {
  21062. if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
  21063. {
  21064. throw ReactError(Error('Cannot flush passive effects while already rendering.'));
  21065. }
  21066. }
  21067. })();
  21068. var prevExecutionContext = executionContext;
  21069. executionContext |= CommitContext;
  21070. // Note: This currently assumes there are no passive effects on the root
  21071. // fiber, because the root is not part of its own effect list. This could
  21072. // change in the future.
  21073. var effect = root.current.firstEffect;
  21074. while (effect !== null) {
  21075. {
  21076. setCurrentFiber(effect);
  21077. invokeGuardedCallback(null, commitPassiveHookEffects, null, effect);
  21078. if (hasCaughtError()) {
  21079. (function () {
  21080. if (!(effect !== null)) {
  21081. {
  21082. throw ReactError(Error('Should be working on an effect.'));
  21083. }
  21084. }
  21085. })();
  21086. var error = clearCaughtError();
  21087. captureCommitPhaseError(effect, error);
  21088. }
  21089. resetCurrentFiber();
  21090. }
  21091. var nextNextEffect = effect.nextEffect;
  21092. // Remove nextEffect pointer to assist GC
  21093. effect.nextEffect = null;
  21094. effect = nextNextEffect;
  21095. }
  21096. if (enableSchedulerTracing) {
  21097. tracing.__interactionsRef.current = prevInteractions;
  21098. finishPendingInteractions(root, expirationTime);
  21099. }
  21100. executionContext = prevExecutionContext;
  21101. flushSyncCallbackQueue();
  21102. // If additional passive effects were scheduled, increment a counter. If this
  21103. // exceeds the limit, we'll fire a warning.
  21104. nestedPassiveUpdateCount = rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1;
  21105. return true;
  21106. }
  21107. function isAlreadyFailedLegacyErrorBoundary(instance) {
  21108. return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance);
  21109. }
  21110. function markLegacyErrorBoundaryAsFailed(instance) {
  21111. if (legacyErrorBoundariesThatAlreadyFailed === null) {
  21112. legacyErrorBoundariesThatAlreadyFailed = new Set([instance]);
  21113. } else {
  21114. legacyErrorBoundariesThatAlreadyFailed.add(instance);
  21115. }
  21116. }
  21117. function prepareToThrowUncaughtError(error) {
  21118. if (!hasUncaughtError) {
  21119. hasUncaughtError = true;
  21120. firstUncaughtError = error;
  21121. }
  21122. }
  21123. var onUncaughtError = prepareToThrowUncaughtError;
  21124. function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) {
  21125. var errorInfo = createCapturedValue(error, sourceFiber);
  21126. var update = createRootErrorUpdate(rootFiber, errorInfo, Sync);
  21127. enqueueUpdate(rootFiber, update);
  21128. var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync);
  21129. if (root !== null) {
  21130. scheduleCallbackForRoot(root, ImmediatePriority, Sync);
  21131. }
  21132. }
  21133. function captureCommitPhaseError(sourceFiber, error) {
  21134. if (sourceFiber.tag === HostRoot) {
  21135. // Error was thrown at the root. There is no parent, so the root
  21136. // itself should capture it.
  21137. captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error);
  21138. return;
  21139. }
  21140. var fiber = sourceFiber.return;
  21141. while (fiber !== null) {
  21142. if (fiber.tag === HostRoot) {
  21143. captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error);
  21144. return;
  21145. } else if (fiber.tag === ClassComponent) {
  21146. var ctor = fiber.type;
  21147. var instance = fiber.stateNode;
  21148. if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) {
  21149. var errorInfo = createCapturedValue(error, sourceFiber);
  21150. var update = createClassErrorUpdate(fiber, errorInfo,
  21151. // TODO: This is always sync
  21152. Sync);
  21153. enqueueUpdate(fiber, update);
  21154. var root = markUpdateTimeFromFiberToRoot(fiber, Sync);
  21155. if (root !== null) {
  21156. scheduleCallbackForRoot(root, ImmediatePriority, Sync);
  21157. }
  21158. return;
  21159. }
  21160. }
  21161. fiber = fiber.return;
  21162. }
  21163. }
  21164. function pingSuspendedRoot(root, thenable, suspendedTime) {
  21165. var pingCache = root.pingCache;
  21166. if (pingCache !== null) {
  21167. // The thenable resolved, so we no longer need to memoize, because it will
  21168. // never be thrown again.
  21169. pingCache.delete(thenable);
  21170. }
  21171. if (workInProgressRoot === root && renderExpirationTime === suspendedTime) {
  21172. // Received a ping at the same priority level at which we're currently
  21173. // rendering. We might want to restart this render. This should mirror
  21174. // the logic of whether or not a root suspends once it completes.
  21175. // TODO: If we're rendering sync either due to Sync, Batched or expired,
  21176. // we should probably never restart.
  21177. // If we're suspended with delay, we'll always suspend so we can always
  21178. // restart. If we're suspended without any updates, it might be a retry.
  21179. // If it's early in the retry we can restart. We can't know for sure
  21180. // whether we'll eventually process an update during this render pass,
  21181. // but it's somewhat unlikely that we get to a ping before that, since
  21182. // getting to the root most update is usually very fast.
  21183. if (workInProgressRootExitStatus === RootSuspendedWithDelay || workInProgressRootExitStatus === RootSuspended && workInProgressRootLatestProcessedExpirationTime === Sync && now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) {
  21184. // Restart from the root. Don't need to schedule a ping because
  21185. // we're already working on this tree.
  21186. prepareFreshStack(root, renderExpirationTime);
  21187. } else {
  21188. // Even though we can't restart right now, we might get an
  21189. // opportunity later. So we mark this render as having a ping.
  21190. workInProgressRootHasPendingPing = true;
  21191. }
  21192. return;
  21193. }
  21194. var lastPendingTime = root.lastPendingTime;
  21195. if (lastPendingTime < suspendedTime) {
  21196. // The root is no longer suspended at this time.
  21197. return;
  21198. }
  21199. var pingTime = root.pingTime;
  21200. if (pingTime !== NoWork && pingTime < suspendedTime) {
  21201. // There's already a lower priority ping scheduled.
  21202. return;
  21203. }
  21204. // Mark the time at which this ping was scheduled.
  21205. root.pingTime = suspendedTime;
  21206. if (root.finishedExpirationTime === suspendedTime) {
  21207. // If there's a pending fallback waiting to commit, throw it away.
  21208. root.finishedExpirationTime = NoWork;
  21209. root.finishedWork = null;
  21210. }
  21211. var currentTime = requestCurrentTime();
  21212. var priorityLevel = inferPriorityFromExpirationTime(currentTime, suspendedTime);
  21213. scheduleCallbackForRoot(root, priorityLevel, suspendedTime);
  21214. }
  21215. function retryTimedOutBoundary(boundaryFiber) {
  21216. // The boundary fiber (a Suspense component or SuspenseList component)
  21217. // previously was rendered in its fallback state. One of the promises that
  21218. // suspended it has resolved, which means at least part of the tree was
  21219. // likely unblocked. Try rendering again, at a new expiration time.
  21220. var currentTime = requestCurrentTime();
  21221. var suspenseConfig = null; // Retries don't carry over the already committed update.
  21222. var retryTime = computeExpirationForFiber(currentTime, boundaryFiber, suspenseConfig);
  21223. // TODO: Special case idle priority?
  21224. var priorityLevel = inferPriorityFromExpirationTime(currentTime, retryTime);
  21225. var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime);
  21226. if (root !== null) {
  21227. scheduleCallbackForRoot(root, priorityLevel, retryTime);
  21228. }
  21229. }
  21230. function resolveRetryThenable(boundaryFiber, thenable) {
  21231. var retryCache = void 0;
  21232. if (enableSuspenseServerRenderer) {
  21233. switch (boundaryFiber.tag) {
  21234. case SuspenseComponent:
  21235. retryCache = boundaryFiber.stateNode;
  21236. break;
  21237. case DehydratedSuspenseComponent:
  21238. retryCache = boundaryFiber.memoizedState;
  21239. break;
  21240. default:
  21241. (function () {
  21242. {
  21243. {
  21244. throw ReactError(Error('Pinged unknown suspense boundary type. This is probably a bug in React.'));
  21245. }
  21246. }
  21247. })();
  21248. }
  21249. } else {
  21250. retryCache = boundaryFiber.stateNode;
  21251. }
  21252. if (retryCache !== null) {
  21253. // The thenable resolved, so we no longer need to memoize, because it will
  21254. // never be thrown again.
  21255. retryCache.delete(thenable);
  21256. }
  21257. retryTimedOutBoundary(boundaryFiber);
  21258. }
  21259. // Computes the next Just Noticeable Difference (JND) boundary.
  21260. // The theory is that a person can't tell the difference between small differences in time.
  21261. // Therefore, if we wait a bit longer than necessary that won't translate to a noticeable
  21262. // difference in the experience. However, waiting for longer might mean that we can avoid
  21263. // showing an intermediate loading state. The longer we have already waited, the harder it
  21264. // is to tell small differences in time. Therefore, the longer we've already waited,
  21265. // the longer we can wait additionally. At some point we have to give up though.
  21266. // We pick a train model where the next boundary commits at a consistent schedule.
  21267. // These particular numbers are vague estimates. We expect to adjust them based on research.
  21268. function jnd(timeElapsed) {
  21269. return timeElapsed < 120 ? 120 : timeElapsed < 480 ? 480 : timeElapsed < 1080 ? 1080 : timeElapsed < 1920 ? 1920 : timeElapsed < 3000 ? 3000 : timeElapsed < 4320 ? 4320 : ceil(timeElapsed / 1960) * 1960;
  21270. }
  21271. function computeMsUntilSuspenseLoadingDelay(mostRecentEventTime, committedExpirationTime, suspenseConfig) {
  21272. var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0;
  21273. if (busyMinDurationMs <= 0) {
  21274. return 0;
  21275. }
  21276. var busyDelayMs = suspenseConfig.busyDelayMs | 0;
  21277. // Compute the time until this render pass would expire.
  21278. var currentTimeMs = now();
  21279. var eventTimeMs = inferTimeFromExpirationTimeWithSuspenseConfig(mostRecentEventTime, suspenseConfig);
  21280. var timeElapsed = currentTimeMs - eventTimeMs;
  21281. if (timeElapsed <= busyDelayMs) {
  21282. // If we haven't yet waited longer than the initial delay, we don't
  21283. // have to wait any additional time.
  21284. return 0;
  21285. }
  21286. var msUntilTimeout = busyDelayMs + busyMinDurationMs - timeElapsed;
  21287. // This is the value that is passed to `setTimeout`.
  21288. return msUntilTimeout;
  21289. }
  21290. function checkForNestedUpdates() {
  21291. if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
  21292. nestedUpdateCount = 0;
  21293. rootWithNestedUpdates = null;
  21294. (function () {
  21295. {
  21296. {
  21297. throw ReactError(Error('Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.'));
  21298. }
  21299. }
  21300. })();
  21301. }
  21302. {
  21303. if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) {
  21304. nestedPassiveUpdateCount = 0;
  21305. warning$1(false, 'Maximum update depth exceeded. This can happen when a component ' + "calls setState inside useEffect, but useEffect either doesn't " + 'have a dependency array, or one of the dependencies changes on ' + 'every render.');
  21306. }
  21307. }
  21308. }
  21309. function flushRenderPhaseStrictModeWarningsInDEV() {
  21310. {
  21311. ReactStrictModeWarnings.flushLegacyContextWarning();
  21312. if (warnAboutDeprecatedLifecycles) {
  21313. ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
  21314. }
  21315. }
  21316. }
  21317. function stopFinishedWorkLoopTimer() {
  21318. var didCompleteRoot = true;
  21319. stopWorkLoopTimer(interruptedBy, didCompleteRoot);
  21320. interruptedBy = null;
  21321. }
  21322. function stopInterruptedWorkLoopTimer() {
  21323. // TODO: Track which fiber caused the interruption.
  21324. var didCompleteRoot = false;
  21325. stopWorkLoopTimer(interruptedBy, didCompleteRoot);
  21326. interruptedBy = null;
  21327. }
  21328. function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) {
  21329. if (enableUserTimingAPI && workInProgressRoot !== null && updateExpirationTime > renderExpirationTime) {
  21330. interruptedBy = fiberThatReceivedUpdate;
  21331. }
  21332. }
  21333. var didWarnStateUpdateForUnmountedComponent = null;
  21334. function warnAboutUpdateOnUnmountedFiberInDEV(fiber) {
  21335. {
  21336. var tag = fiber.tag;
  21337. if (tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent) {
  21338. // Only warn for user-defined components, not internal ones like Suspense.
  21339. return;
  21340. }
  21341. // We show the whole stack but dedupe on the top component's name because
  21342. // the problematic code almost always lies inside that component.
  21343. var componentName = getComponentName(fiber.type) || 'ReactComponent';
  21344. if (didWarnStateUpdateForUnmountedComponent !== null) {
  21345. if (didWarnStateUpdateForUnmountedComponent.has(componentName)) {
  21346. return;
  21347. }
  21348. didWarnStateUpdateForUnmountedComponent.add(componentName);
  21349. } else {
  21350. didWarnStateUpdateForUnmountedComponent = new Set([componentName]);
  21351. }
  21352. warningWithoutStack$1(false, "Can't perform a React state update on an unmounted component. This " + 'is a no-op, but it indicates a memory leak in your application. To ' + 'fix, cancel all subscriptions and asynchronous tasks in %s.%s', tag === ClassComponent ? 'the componentWillUnmount method' : 'a useEffect cleanup function', getStackByFiberInDevAndProd(fiber));
  21353. }
  21354. }
  21355. var beginWork$$1 = void 0;
  21356. if ( true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
  21357. var dummyFiber = null;
  21358. beginWork$$1 = function (current$$1, unitOfWork, expirationTime) {
  21359. // If a component throws an error, we replay it again in a synchronously
  21360. // dispatched event, so that the debugger will treat it as an uncaught
  21361. // error See ReactErrorUtils for more information.
  21362. // Before entering the begin phase, copy the work-in-progress onto a dummy
  21363. // fiber. If beginWork throws, we'll use this to reset the state.
  21364. var originalWorkInProgressCopy = assignFiberPropertiesInDEV(dummyFiber, unitOfWork);
  21365. try {
  21366. return beginWork$1(current$$1, unitOfWork, expirationTime);
  21367. } catch (originalError) {
  21368. if (originalError !== null && typeof originalError === 'object' && typeof originalError.then === 'function') {
  21369. // Don't replay promises. Treat everything else like an error.
  21370. throw originalError;
  21371. }
  21372. // Keep this code in sync with renderRoot; any changes here must have
  21373. // corresponding changes there.
  21374. resetContextDependencies();
  21375. resetHooks();
  21376. // Unwind the failed stack frame
  21377. unwindInterruptedWork(unitOfWork);
  21378. // Restore the original properties of the fiber.
  21379. assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy);
  21380. if (enableProfilerTimer && unitOfWork.mode & ProfileMode) {
  21381. // Reset the profiler timer.
  21382. startProfilerTimer(unitOfWork);
  21383. }
  21384. // Run beginWork again.
  21385. invokeGuardedCallback(null, beginWork$1, null, current$$1, unitOfWork, expirationTime);
  21386. if (hasCaughtError()) {
  21387. var replayError = clearCaughtError();
  21388. // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`.
  21389. // Rethrow this error instead of the original one.
  21390. throw replayError;
  21391. } else {
  21392. // This branch is reachable if the render phase is impure.
  21393. throw originalError;
  21394. }
  21395. }
  21396. };
  21397. } else {
  21398. beginWork$$1 = beginWork$1;
  21399. }
  21400. var didWarnAboutUpdateInRender = false;
  21401. var didWarnAboutUpdateInGetChildContext = false;
  21402. function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) {
  21403. {
  21404. if (fiber.tag === ClassComponent) {
  21405. switch (phase) {
  21406. case 'getChildContext':
  21407. if (didWarnAboutUpdateInGetChildContext) {
  21408. return;
  21409. }
  21410. warningWithoutStack$1(false, 'setState(...): Cannot call setState() inside getChildContext()');
  21411. didWarnAboutUpdateInGetChildContext = true;
  21412. break;
  21413. case 'render':
  21414. if (didWarnAboutUpdateInRender) {
  21415. return;
  21416. }
  21417. 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.');
  21418. didWarnAboutUpdateInRender = true;
  21419. break;
  21420. }
  21421. }
  21422. }
  21423. }
  21424. // a 'shared' variable that changes when act() opens/closes in tests.
  21425. var IsThisRendererActing = { current: false };
  21426. function warnIfNotScopedWithMatchingAct(fiber) {
  21427. {
  21428. if (warnsIfNotActing === true && IsSomeRendererActing.current === true && IsThisRendererActing.current !== true) {
  21429. warningWithoutStack$1(false, "It looks like you're using the wrong act() around your test interactions.\n" + 'Be sure to use the matching version of act() corresponding to your renderer:\n\n' + '// for react-dom:\n' + "import {act} from 'react-dom/test-utils';\n" + '//...\n' + 'act(() => ...);\n\n' + '// for react-test-renderer:\n' + "import TestRenderer from 'react-test-renderer';\n" + 'const {act} = TestRenderer;\n' + '//...\n' + 'act(() => ...);' + '%s', getStackByFiberInDevAndProd(fiber));
  21430. }
  21431. }
  21432. }
  21433. function warnIfNotCurrentlyActingEffectsInDEV(fiber) {
  21434. {
  21435. if (warnsIfNotActing === true && (fiber.mode & StrictMode) !== NoMode && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
  21436. warningWithoutStack$1(false, 'An update to %s ran an effect, but was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://fb.me/react-wrap-tests-with-act' + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber));
  21437. }
  21438. }
  21439. }
  21440. function warnIfNotCurrentlyActingUpdatesInDEV(fiber) {
  21441. {
  21442. if (warnsIfNotActing === true && executionContext === NoContext && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
  21443. warningWithoutStack$1(false, 'An update to %s inside a test was not wrapped in act(...).\n\n' + 'When testing, code that causes React state updates should be ' + 'wrapped into act(...):\n\n' + 'act(() => {\n' + ' /* fire events that update state */\n' + '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see " + 'in the browser.' + ' Learn more at https://fb.me/react-wrap-tests-with-act' + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber));
  21444. }
  21445. }
  21446. }
  21447. var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV;
  21448. // In tests, we want to enforce a mocked scheduler.
  21449. var didWarnAboutUnmockedScheduler = false;
  21450. // TODO Before we release concurrent mode, revisit this and decide whether a mocked
  21451. // scheduler is the actual recommendation. The alternative could be a testing build,
  21452. // a new lib, or whatever; we dunno just yet. This message is for early adopters
  21453. // to get their tests right.
  21454. function warnIfUnmockedScheduler(fiber) {
  21455. {
  21456. if (didWarnAboutUnmockedScheduler === false && Scheduler.unstable_flushAllWithoutAsserting === undefined) {
  21457. if (fiber.mode & BatchedMode || fiber.mode & ConcurrentMode) {
  21458. didWarnAboutUnmockedScheduler = true;
  21459. warningWithoutStack$1(false, 'In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' + 'to guarantee consistent behaviour across tests and browsers. ' + 'For example, with jest: \n' + "jest.mock('scheduler', () => require('scheduler/unstable_mock'));\n\n" + 'For more info, visit https://fb.me/react-mock-scheduler');
  21460. } else if (warnAboutUnmockedScheduler === true) {
  21461. didWarnAboutUnmockedScheduler = true;
  21462. warningWithoutStack$1(false, 'Starting from React v17, the "scheduler" module will need to be mocked ' + 'to guarantee consistent behaviour across tests and browsers. ' + 'For example, with jest: \n' + "jest.mock('scheduler', () => require('scheduler/unstable_mock'));\n\n" + 'For more info, visit https://fb.me/react-mock-scheduler');
  21463. }
  21464. }
  21465. }
  21466. }
  21467. var componentsThatTriggeredHighPriSuspend = null;
  21468. function checkForWrongSuspensePriorityInDEV(sourceFiber) {
  21469. {
  21470. var currentPriorityLevel = getCurrentPriorityLevel();
  21471. if ((sourceFiber.mode & ConcurrentMode) !== NoEffect && (currentPriorityLevel === UserBlockingPriority$2 || currentPriorityLevel === ImmediatePriority)) {
  21472. var workInProgressNode = sourceFiber;
  21473. while (workInProgressNode !== null) {
  21474. // Add the component that triggered the suspense
  21475. var current$$1 = workInProgressNode.alternate;
  21476. if (current$$1 !== null) {
  21477. // TODO: warn component that triggers the high priority
  21478. // suspend is the HostRoot
  21479. switch (workInProgressNode.tag) {
  21480. case ClassComponent:
  21481. // Loop through the component's update queue and see whether the component
  21482. // has triggered any high priority updates
  21483. var updateQueue = current$$1.updateQueue;
  21484. if (updateQueue !== null) {
  21485. var update = updateQueue.firstUpdate;
  21486. while (update !== null) {
  21487. var priorityLevel = update.priority;
  21488. if (priorityLevel === UserBlockingPriority$2 || priorityLevel === ImmediatePriority) {
  21489. if (componentsThatTriggeredHighPriSuspend === null) {
  21490. componentsThatTriggeredHighPriSuspend = new Set([getComponentName(workInProgressNode.type)]);
  21491. } else {
  21492. componentsThatTriggeredHighPriSuspend.add(getComponentName(workInProgressNode.type));
  21493. }
  21494. break;
  21495. }
  21496. update = update.next;
  21497. }
  21498. }
  21499. break;
  21500. case FunctionComponent:
  21501. case ForwardRef:
  21502. case SimpleMemoComponent:
  21503. if (workInProgressNode.memoizedState !== null && workInProgressNode.memoizedState.baseUpdate !== null) {
  21504. var _update = workInProgressNode.memoizedState.baseUpdate;
  21505. // Loop through the functional component's memoized state to see whether
  21506. // the component has triggered any high pri updates
  21507. while (_update !== null) {
  21508. var priority = _update.priority;
  21509. if (priority === UserBlockingPriority$2 || priority === ImmediatePriority) {
  21510. if (componentsThatTriggeredHighPriSuspend === null) {
  21511. componentsThatTriggeredHighPriSuspend = new Set([getComponentName(workInProgressNode.type)]);
  21512. } else {
  21513. componentsThatTriggeredHighPriSuspend.add(getComponentName(workInProgressNode.type));
  21514. }
  21515. break;
  21516. }
  21517. if (_update.next === workInProgressNode.memoizedState.baseUpdate) {
  21518. break;
  21519. }
  21520. _update = _update.next;
  21521. }
  21522. }
  21523. break;
  21524. default:
  21525. break;
  21526. }
  21527. }
  21528. workInProgressNode = workInProgressNode.return;
  21529. }
  21530. }
  21531. }
  21532. }
  21533. function flushSuspensePriorityWarningInDEV() {
  21534. {
  21535. if (componentsThatTriggeredHighPriSuspend !== null) {
  21536. var componentNames = [];
  21537. componentsThatTriggeredHighPriSuspend.forEach(function (name) {
  21538. return componentNames.push(name);
  21539. });
  21540. componentsThatTriggeredHighPriSuspend = null;
  21541. if (componentNames.length > 0) {
  21542. warningWithoutStack$1(false, '%s triggered a user-blocking update that suspended.' + '\n\n' + 'The fix is to split the update into multiple parts: a user-blocking ' + 'update to provide immediate feedback, and another update that ' + 'triggers the bulk of the changes.' + '\n\n' + 'Refer to the documentation for useSuspenseTransition to learn how ' + 'to implement this pattern.',
  21543. // TODO: Add link to React docs with more information, once it exists
  21544. componentNames.sort().join(', '));
  21545. }
  21546. }
  21547. }
  21548. }
  21549. function computeThreadID(root, expirationTime) {
  21550. // Interaction threads are unique per root and expiration time.
  21551. return expirationTime * 1000 + root.interactionThreadID;
  21552. }
  21553. function markSpawnedWork(expirationTime) {
  21554. if (!enableSchedulerTracing) {
  21555. return;
  21556. }
  21557. if (spawnedWorkDuringRender === null) {
  21558. spawnedWorkDuringRender = [expirationTime];
  21559. } else {
  21560. spawnedWorkDuringRender.push(expirationTime);
  21561. }
  21562. }
  21563. function scheduleInteractions(root, expirationTime, interactions) {
  21564. if (!enableSchedulerTracing) {
  21565. return;
  21566. }
  21567. if (interactions.size > 0) {
  21568. var pendingInteractionMap = root.pendingInteractionMap;
  21569. var pendingInteractions = pendingInteractionMap.get(expirationTime);
  21570. if (pendingInteractions != null) {
  21571. interactions.forEach(function (interaction) {
  21572. if (!pendingInteractions.has(interaction)) {
  21573. // Update the pending async work count for previously unscheduled interaction.
  21574. interaction.__count++;
  21575. }
  21576. pendingInteractions.add(interaction);
  21577. });
  21578. } else {
  21579. pendingInteractionMap.set(expirationTime, new Set(interactions));
  21580. // Update the pending async work count for the current interactions.
  21581. interactions.forEach(function (interaction) {
  21582. interaction.__count++;
  21583. });
  21584. }
  21585. var subscriber = tracing.__subscriberRef.current;
  21586. if (subscriber !== null) {
  21587. var threadID = computeThreadID(root, expirationTime);
  21588. subscriber.onWorkScheduled(interactions, threadID);
  21589. }
  21590. }
  21591. }
  21592. function schedulePendingInteractions(root, expirationTime) {
  21593. // This is called when work is scheduled on a root.
  21594. // It associates the current interactions with the newly-scheduled expiration.
  21595. // They will be restored when that expiration is later committed.
  21596. if (!enableSchedulerTracing) {
  21597. return;
  21598. }
  21599. scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current);
  21600. }
  21601. function startWorkOnPendingInteractions(root, expirationTime) {
  21602. // This is called when new work is started on a root.
  21603. if (!enableSchedulerTracing) {
  21604. return;
  21605. }
  21606. // Determine which interactions this batch of work currently includes, So that
  21607. // we can accurately attribute time spent working on it, And so that cascading
  21608. // work triggered during the render phase will be associated with it.
  21609. var interactions = new Set();
  21610. root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
  21611. if (scheduledExpirationTime >= expirationTime) {
  21612. scheduledInteractions.forEach(function (interaction) {
  21613. return interactions.add(interaction);
  21614. });
  21615. }
  21616. });
  21617. // Store the current set of interactions on the FiberRoot for a few reasons:
  21618. // We can re-use it in hot functions like renderRoot() without having to
  21619. // recalculate it. We will also use it in commitWork() to pass to any Profiler
  21620. // onRender() hooks. This also provides DevTools with a way to access it when
  21621. // the onCommitRoot() hook is called.
  21622. root.memoizedInteractions = interactions;
  21623. if (interactions.size > 0) {
  21624. var subscriber = tracing.__subscriberRef.current;
  21625. if (subscriber !== null) {
  21626. var threadID = computeThreadID(root, expirationTime);
  21627. try {
  21628. subscriber.onWorkStarted(interactions, threadID);
  21629. } catch (error) {
  21630. // If the subscriber throws, rethrow it in a separate task
  21631. scheduleCallback(ImmediatePriority, function () {
  21632. throw error;
  21633. });
  21634. }
  21635. }
  21636. }
  21637. }
  21638. function finishPendingInteractions(root, committedExpirationTime) {
  21639. if (!enableSchedulerTracing) {
  21640. return;
  21641. }
  21642. var earliestRemainingTimeAfterCommit = root.firstPendingTime;
  21643. var subscriber = void 0;
  21644. try {
  21645. subscriber = tracing.__subscriberRef.current;
  21646. if (subscriber !== null && root.memoizedInteractions.size > 0) {
  21647. var threadID = computeThreadID(root, committedExpirationTime);
  21648. subscriber.onWorkStopped(root.memoizedInteractions, threadID);
  21649. }
  21650. } catch (error) {
  21651. // If the subscriber throws, rethrow it in a separate task
  21652. scheduleCallback(ImmediatePriority, function () {
  21653. throw error;
  21654. });
  21655. } finally {
  21656. // Clear completed interactions from the pending Map.
  21657. // Unless the render was suspended or cascading work was scheduled,
  21658. // In which case– leave pending interactions until the subsequent render.
  21659. var pendingInteractionMap = root.pendingInteractionMap;
  21660. pendingInteractionMap.forEach(function (scheduledInteractions, scheduledExpirationTime) {
  21661. // Only decrement the pending interaction count if we're done.
  21662. // If there's still work at the current priority,
  21663. // That indicates that we are waiting for suspense data.
  21664. if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) {
  21665. pendingInteractionMap.delete(scheduledExpirationTime);
  21666. scheduledInteractions.forEach(function (interaction) {
  21667. interaction.__count--;
  21668. if (subscriber !== null && interaction.__count === 0) {
  21669. try {
  21670. subscriber.onInteractionScheduledWorkCompleted(interaction);
  21671. } catch (error) {
  21672. // If the subscriber throws, rethrow it in a separate task
  21673. scheduleCallback(ImmediatePriority, function () {
  21674. throw error;
  21675. });
  21676. }
  21677. }
  21678. });
  21679. }
  21680. });
  21681. }
  21682. }
  21683. var onCommitFiberRoot = null;
  21684. var onCommitFiberUnmount = null;
  21685. var hasLoggedError = false;
  21686. var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined';
  21687. function injectInternals(internals) {
  21688. if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
  21689. // No DevTools
  21690. return false;
  21691. }
  21692. var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
  21693. if (hook.isDisabled) {
  21694. // This isn't a real property on the hook, but it can be set to opt out
  21695. // of DevTools integration and associated warnings and logs.
  21696. // https://github.com/facebook/react/issues/3877
  21697. return true;
  21698. }
  21699. if (!hook.supportsFiber) {
  21700. {
  21701. 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');
  21702. }
  21703. // DevTools exists, even though it doesn't support Fiber.
  21704. return true;
  21705. }
  21706. try {
  21707. var rendererID = hook.inject(internals);
  21708. // We have successfully injected, so now it is safe to set up hooks.
  21709. onCommitFiberRoot = function (root, expirationTime) {
  21710. try {
  21711. var didError = (root.current.effectTag & DidCapture) === DidCapture;
  21712. if (enableProfilerTimer) {
  21713. var currentTime = requestCurrentTime();
  21714. var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime);
  21715. hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError);
  21716. } else {
  21717. hook.onCommitFiberRoot(rendererID, root, undefined, didError);
  21718. }
  21719. } catch (err) {
  21720. if ( true && !hasLoggedError) {
  21721. hasLoggedError = true;
  21722. warningWithoutStack$1(false, 'React DevTools encountered an error: %s', err);
  21723. }
  21724. }
  21725. };
  21726. onCommitFiberUnmount = function (fiber) {
  21727. try {
  21728. hook.onCommitFiberUnmount(rendererID, fiber);
  21729. } catch (err) {
  21730. if ( true && !hasLoggedError) {
  21731. hasLoggedError = true;
  21732. warningWithoutStack$1(false, 'React DevTools encountered an error: %s', err);
  21733. }
  21734. }
  21735. };
  21736. } catch (err) {
  21737. // Catch all errors because it is unsafe to throw during initialization.
  21738. {
  21739. warningWithoutStack$1(false, 'React DevTools encountered an error: %s.', err);
  21740. }
  21741. }
  21742. // DevTools exists
  21743. return true;
  21744. }
  21745. function onCommitRoot(root, expirationTime) {
  21746. if (typeof onCommitFiberRoot === 'function') {
  21747. onCommitFiberRoot(root, expirationTime);
  21748. }
  21749. }
  21750. function onCommitUnmount(fiber) {
  21751. if (typeof onCommitFiberUnmount === 'function') {
  21752. onCommitFiberUnmount(fiber);
  21753. }
  21754. }
  21755. var hasBadMapPolyfill = void 0;
  21756. {
  21757. hasBadMapPolyfill = false;
  21758. try {
  21759. var nonExtensibleObject = Object.preventExtensions({});
  21760. var testMap = new Map([[nonExtensibleObject, null]]);
  21761. var testSet = new Set([nonExtensibleObject]);
  21762. // This is necessary for Rollup to not consider these unused.
  21763. // https://github.com/rollup/rollup/issues/1771
  21764. // TODO: we can remove these if Rollup fixes the bug.
  21765. testMap.set(0, 0);
  21766. testSet.add(0);
  21767. } catch (e) {
  21768. // TODO: Consider warning about bad polyfills
  21769. hasBadMapPolyfill = true;
  21770. }
  21771. }
  21772. // A Fiber is work on a Component that needs to be done or was done. There can
  21773. // be more than one per component.
  21774. var debugCounter = void 0;
  21775. {
  21776. debugCounter = 1;
  21777. }
  21778. function FiberNode(tag, pendingProps, key, mode) {
  21779. // Instance
  21780. this.tag = tag;
  21781. this.key = key;
  21782. this.elementType = null;
  21783. this.type = null;
  21784. this.stateNode = null;
  21785. // Fiber
  21786. this.return = null;
  21787. this.child = null;
  21788. this.sibling = null;
  21789. this.index = 0;
  21790. this.ref = null;
  21791. this.pendingProps = pendingProps;
  21792. this.memoizedProps = null;
  21793. this.updateQueue = null;
  21794. this.memoizedState = null;
  21795. this.dependencies = null;
  21796. this.mode = mode;
  21797. // Effects
  21798. this.effectTag = NoEffect;
  21799. this.nextEffect = null;
  21800. this.firstEffect = null;
  21801. this.lastEffect = null;
  21802. this.expirationTime = NoWork;
  21803. this.childExpirationTime = NoWork;
  21804. this.alternate = null;
  21805. if (enableProfilerTimer) {
  21806. // Note: The following is done to avoid a v8 performance cliff.
  21807. //
  21808. // Initializing the fields below to smis and later updating them with
  21809. // double values will cause Fibers to end up having separate shapes.
  21810. // This behavior/bug has something to do with Object.preventExtension().
  21811. // Fortunately this only impacts DEV builds.
  21812. // Unfortunately it makes React unusably slow for some applications.
  21813. // To work around this, initialize the fields below with doubles.
  21814. //
  21815. // Learn more about this here:
  21816. // https://github.com/facebook/react/issues/14365
  21817. // https://bugs.chromium.org/p/v8/issues/detail?id=8538
  21818. this.actualDuration = Number.NaN;
  21819. this.actualStartTime = Number.NaN;
  21820. this.selfBaseDuration = Number.NaN;
  21821. this.treeBaseDuration = Number.NaN;
  21822. // It's okay to replace the initial doubles with smis after initialization.
  21823. // This won't trigger the performance cliff mentioned above,
  21824. // and it simplifies other profiler code (including DevTools).
  21825. this.actualDuration = 0;
  21826. this.actualStartTime = -1;
  21827. this.selfBaseDuration = 0;
  21828. this.treeBaseDuration = 0;
  21829. }
  21830. {
  21831. this._debugID = debugCounter++;
  21832. this._debugSource = null;
  21833. this._debugOwner = null;
  21834. this._debugIsCurrentlyTiming = false;
  21835. this._debugNeedsRemount = false;
  21836. this._debugHookTypes = null;
  21837. if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
  21838. Object.preventExtensions(this);
  21839. }
  21840. }
  21841. }
  21842. // This is a constructor function, rather than a POJO constructor, still
  21843. // please ensure we do the following:
  21844. // 1) Nobody should add any instance methods on this. Instance methods can be
  21845. // more difficult to predict when they get optimized and they are almost
  21846. // never inlined properly in static compilers.
  21847. // 2) Nobody should rely on `instanceof Fiber` for type testing. We should
  21848. // always know when it is a fiber.
  21849. // 3) We might want to experiment with using numeric keys since they are easier
  21850. // to optimize in a non-JIT environment.
  21851. // 4) We can easily go from a constructor to a createFiber object literal if that
  21852. // is faster.
  21853. // 5) It should be easy to port this to a C struct and keep a C implementation
  21854. // compatible.
  21855. var createFiber = function (tag, pendingProps, key, mode) {
  21856. // $FlowFixMe: the shapes are exact here but Flow doesn't like constructors
  21857. return new FiberNode(tag, pendingProps, key, mode);
  21858. };
  21859. function shouldConstruct(Component) {
  21860. var prototype = Component.prototype;
  21861. return !!(prototype && prototype.isReactComponent);
  21862. }
  21863. function isSimpleFunctionComponent(type) {
  21864. return typeof type === 'function' && !shouldConstruct(type) && type.defaultProps === undefined;
  21865. }
  21866. function resolveLazyComponentTag(Component) {
  21867. if (typeof Component === 'function') {
  21868. return shouldConstruct(Component) ? ClassComponent : FunctionComponent;
  21869. } else if (Component !== undefined && Component !== null) {
  21870. var $$typeof = Component.$$typeof;
  21871. if ($$typeof === REACT_FORWARD_REF_TYPE) {
  21872. return ForwardRef;
  21873. }
  21874. if ($$typeof === REACT_MEMO_TYPE) {
  21875. return MemoComponent;
  21876. }
  21877. }
  21878. return IndeterminateComponent;
  21879. }
  21880. // This is used to create an alternate fiber to do work on.
  21881. function createWorkInProgress(current, pendingProps, expirationTime) {
  21882. var workInProgress = current.alternate;
  21883. if (workInProgress === null) {
  21884. // We use a double buffering pooling technique because we know that we'll
  21885. // only ever need at most two versions of a tree. We pool the "other" unused
  21886. // node that we're free to reuse. This is lazily created to avoid allocating
  21887. // extra objects for things that are never updated. It also allow us to
  21888. // reclaim the extra memory if needed.
  21889. workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
  21890. workInProgress.elementType = current.elementType;
  21891. workInProgress.type = current.type;
  21892. workInProgress.stateNode = current.stateNode;
  21893. {
  21894. // DEV-only fields
  21895. workInProgress._debugID = current._debugID;
  21896. workInProgress._debugSource = current._debugSource;
  21897. workInProgress._debugOwner = current._debugOwner;
  21898. workInProgress._debugHookTypes = current._debugHookTypes;
  21899. }
  21900. workInProgress.alternate = current;
  21901. current.alternate = workInProgress;
  21902. } else {
  21903. workInProgress.pendingProps = pendingProps;
  21904. // We already have an alternate.
  21905. // Reset the effect tag.
  21906. workInProgress.effectTag = NoEffect;
  21907. // The effect list is no longer valid.
  21908. workInProgress.nextEffect = null;
  21909. workInProgress.firstEffect = null;
  21910. workInProgress.lastEffect = null;
  21911. if (enableProfilerTimer) {
  21912. // We intentionally reset, rather than copy, actualDuration & actualStartTime.
  21913. // This prevents time from endlessly accumulating in new commits.
  21914. // This has the downside of resetting values for different priority renders,
  21915. // But works for yielding (the common case) and should support resuming.
  21916. workInProgress.actualDuration = 0;
  21917. workInProgress.actualStartTime = -1;
  21918. }
  21919. }
  21920. workInProgress.childExpirationTime = current.childExpirationTime;
  21921. workInProgress.expirationTime = current.expirationTime;
  21922. workInProgress.child = current.child;
  21923. workInProgress.memoizedProps = current.memoizedProps;
  21924. workInProgress.memoizedState = current.memoizedState;
  21925. workInProgress.updateQueue = current.updateQueue;
  21926. // Clone the dependencies object. This is mutated during the render phase, so
  21927. // it cannot be shared with the current fiber.
  21928. var currentDependencies = current.dependencies;
  21929. workInProgress.dependencies = currentDependencies === null ? null : {
  21930. expirationTime: currentDependencies.expirationTime,
  21931. firstContext: currentDependencies.firstContext,
  21932. responders: currentDependencies.responders
  21933. };
  21934. // These will be overridden during the parent's reconciliation
  21935. workInProgress.sibling = current.sibling;
  21936. workInProgress.index = current.index;
  21937. workInProgress.ref = current.ref;
  21938. if (enableProfilerTimer) {
  21939. workInProgress.selfBaseDuration = current.selfBaseDuration;
  21940. workInProgress.treeBaseDuration = current.treeBaseDuration;
  21941. }
  21942. {
  21943. workInProgress._debugNeedsRemount = current._debugNeedsRemount;
  21944. switch (workInProgress.tag) {
  21945. case IndeterminateComponent:
  21946. case FunctionComponent:
  21947. case SimpleMemoComponent:
  21948. workInProgress.type = resolveFunctionForHotReloading(current.type);
  21949. break;
  21950. case ClassComponent:
  21951. workInProgress.type = resolveClassForHotReloading(current.type);
  21952. break;
  21953. case ForwardRef:
  21954. workInProgress.type = resolveForwardRefForHotReloading(current.type);
  21955. break;
  21956. default:
  21957. break;
  21958. }
  21959. }
  21960. return workInProgress;
  21961. }
  21962. // Used to reuse a Fiber for a second pass.
  21963. function resetWorkInProgress(workInProgress, renderExpirationTime) {
  21964. // This resets the Fiber to what createFiber or createWorkInProgress would
  21965. // have set the values to before during the first pass. Ideally this wouldn't
  21966. // be necessary but unfortunately many code paths reads from the workInProgress
  21967. // when they should be reading from current and writing to workInProgress.
  21968. // We assume pendingProps, index, key, ref, return are still untouched to
  21969. // avoid doing another reconciliation.
  21970. // Reset the effect tag but keep any Placement tags, since that's something
  21971. // that child fiber is setting, not the reconciliation.
  21972. workInProgress.effectTag &= Placement;
  21973. // The effect list is no longer valid.
  21974. workInProgress.nextEffect = null;
  21975. workInProgress.firstEffect = null;
  21976. workInProgress.lastEffect = null;
  21977. var current = workInProgress.alternate;
  21978. if (current === null) {
  21979. // Reset to createFiber's initial values.
  21980. workInProgress.childExpirationTime = NoWork;
  21981. workInProgress.expirationTime = renderExpirationTime;
  21982. workInProgress.child = null;
  21983. workInProgress.memoizedProps = null;
  21984. workInProgress.memoizedState = null;
  21985. workInProgress.updateQueue = null;
  21986. workInProgress.dependencies = null;
  21987. if (enableProfilerTimer) {
  21988. // Note: We don't reset the actualTime counts. It's useful to accumulate
  21989. // actual time across multiple render passes.
  21990. workInProgress.selfBaseDuration = 0;
  21991. workInProgress.treeBaseDuration = 0;
  21992. }
  21993. } else {
  21994. // Reset to the cloned values that createWorkInProgress would've.
  21995. workInProgress.childExpirationTime = current.childExpirationTime;
  21996. workInProgress.expirationTime = current.expirationTime;
  21997. workInProgress.child = current.child;
  21998. workInProgress.memoizedProps = current.memoizedProps;
  21999. workInProgress.memoizedState = current.memoizedState;
  22000. workInProgress.updateQueue = current.updateQueue;
  22001. // Clone the dependencies object. This is mutated during the render phase, so
  22002. // it cannot be shared with the current fiber.
  22003. var currentDependencies = current.dependencies;
  22004. workInProgress.dependencies = currentDependencies === null ? null : {
  22005. expirationTime: currentDependencies.expirationTime,
  22006. firstContext: currentDependencies.firstContext,
  22007. responders: currentDependencies.responders
  22008. };
  22009. if (enableProfilerTimer) {
  22010. // Note: We don't reset the actualTime counts. It's useful to accumulate
  22011. // actual time across multiple render passes.
  22012. workInProgress.selfBaseDuration = current.selfBaseDuration;
  22013. workInProgress.treeBaseDuration = current.treeBaseDuration;
  22014. }
  22015. }
  22016. return workInProgress;
  22017. }
  22018. function createHostRootFiber(tag) {
  22019. var mode = void 0;
  22020. if (tag === ConcurrentRoot) {
  22021. mode = ConcurrentMode | BatchedMode | StrictMode;
  22022. } else if (tag === BatchedRoot) {
  22023. mode = BatchedMode | StrictMode;
  22024. } else {
  22025. mode = NoMode;
  22026. }
  22027. if (enableProfilerTimer && isDevToolsPresent) {
  22028. // Always collect profile timings when DevTools are present.
  22029. // This enables DevTools to start capturing timing at any point–
  22030. // Without some nodes in the tree having empty base times.
  22031. mode |= ProfileMode;
  22032. }
  22033. return createFiber(HostRoot, null, null, mode);
  22034. }
  22035. function createFiberFromTypeAndProps(type, // React$ElementType
  22036. key, pendingProps, owner, mode, expirationTime) {
  22037. var fiber = void 0;
  22038. var fiberTag = IndeterminateComponent;
  22039. // The resolved type is set if we know what the final type will be. I.e. it's not lazy.
  22040. var resolvedType = type;
  22041. if (typeof type === 'function') {
  22042. if (shouldConstruct(type)) {
  22043. fiberTag = ClassComponent;
  22044. {
  22045. resolvedType = resolveClassForHotReloading(resolvedType);
  22046. }
  22047. } else {
  22048. {
  22049. resolvedType = resolveFunctionForHotReloading(resolvedType);
  22050. }
  22051. }
  22052. } else if (typeof type === 'string') {
  22053. fiberTag = HostComponent;
  22054. } else {
  22055. getTag: switch (type) {
  22056. case REACT_FRAGMENT_TYPE:
  22057. return createFiberFromFragment(pendingProps.children, mode, expirationTime, key);
  22058. case REACT_CONCURRENT_MODE_TYPE:
  22059. fiberTag = Mode;
  22060. mode |= ConcurrentMode | BatchedMode | StrictMode;
  22061. break;
  22062. case REACT_STRICT_MODE_TYPE:
  22063. fiberTag = Mode;
  22064. mode |= StrictMode;
  22065. break;
  22066. case REACT_PROFILER_TYPE:
  22067. return createFiberFromProfiler(pendingProps, mode, expirationTime, key);
  22068. case REACT_SUSPENSE_TYPE:
  22069. return createFiberFromSuspense(pendingProps, mode, expirationTime, key);
  22070. case REACT_SUSPENSE_LIST_TYPE:
  22071. return createFiberFromSuspenseList(pendingProps, mode, expirationTime, key);
  22072. default:
  22073. {
  22074. if (typeof type === 'object' && type !== null) {
  22075. switch (type.$$typeof) {
  22076. case REACT_PROVIDER_TYPE:
  22077. fiberTag = ContextProvider;
  22078. break getTag;
  22079. case REACT_CONTEXT_TYPE:
  22080. // This is a consumer
  22081. fiberTag = ContextConsumer;
  22082. break getTag;
  22083. case REACT_FORWARD_REF_TYPE:
  22084. fiberTag = ForwardRef;
  22085. {
  22086. resolvedType = resolveForwardRefForHotReloading(resolvedType);
  22087. }
  22088. break getTag;
  22089. case REACT_MEMO_TYPE:
  22090. fiberTag = MemoComponent;
  22091. break getTag;
  22092. case REACT_LAZY_TYPE:
  22093. fiberTag = LazyComponent;
  22094. resolvedType = null;
  22095. break getTag;
  22096. case REACT_FUNDAMENTAL_TYPE:
  22097. if (enableFundamentalAPI) {
  22098. return createFiberFromFundamental(type, pendingProps, mode, expirationTime, key);
  22099. }
  22100. break;
  22101. }
  22102. }
  22103. var info = '';
  22104. {
  22105. if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
  22106. 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.';
  22107. }
  22108. var ownerName = owner ? getComponentName(owner.type) : null;
  22109. if (ownerName) {
  22110. info += '\n\nCheck the render method of `' + ownerName + '`.';
  22111. }
  22112. }
  22113. (function () {
  22114. {
  22115. {
  22116. throw ReactError(Error('Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: ' + (type == null ? type : typeof type) + '.' + info));
  22117. }
  22118. }
  22119. })();
  22120. }
  22121. }
  22122. }
  22123. fiber = createFiber(fiberTag, pendingProps, key, mode);
  22124. fiber.elementType = type;
  22125. fiber.type = resolvedType;
  22126. fiber.expirationTime = expirationTime;
  22127. return fiber;
  22128. }
  22129. function createFiberFromElement(element, mode, expirationTime) {
  22130. var owner = null;
  22131. {
  22132. owner = element._owner;
  22133. }
  22134. var type = element.type;
  22135. var key = element.key;
  22136. var pendingProps = element.props;
  22137. var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, expirationTime);
  22138. {
  22139. fiber._debugSource = element._source;
  22140. fiber._debugOwner = element._owner;
  22141. }
  22142. return fiber;
  22143. }
  22144. function createFiberFromFragment(elements, mode, expirationTime, key) {
  22145. var fiber = createFiber(Fragment, elements, key, mode);
  22146. fiber.expirationTime = expirationTime;
  22147. return fiber;
  22148. }
  22149. function createFiberFromFundamental(fundamentalComponent, pendingProps, mode, expirationTime, key) {
  22150. var fiber = createFiber(FundamentalComponent, pendingProps, key, mode);
  22151. fiber.elementType = fundamentalComponent;
  22152. fiber.type = fundamentalComponent;
  22153. fiber.expirationTime = expirationTime;
  22154. return fiber;
  22155. }
  22156. function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
  22157. {
  22158. if (typeof pendingProps.id !== 'string' || typeof pendingProps.onRender !== 'function') {
  22159. warningWithoutStack$1(false, 'Profiler must specify an "id" string and "onRender" function as props');
  22160. }
  22161. }
  22162. var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode);
  22163. // TODO: The Profiler fiber shouldn't have a type. It has a tag.
  22164. fiber.elementType = REACT_PROFILER_TYPE;
  22165. fiber.type = REACT_PROFILER_TYPE;
  22166. fiber.expirationTime = expirationTime;
  22167. return fiber;
  22168. }
  22169. function createFiberFromSuspense(pendingProps, mode, expirationTime, key) {
  22170. var fiber = createFiber(SuspenseComponent, pendingProps, key, mode);
  22171. // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag.
  22172. // This needs to be fixed in getComponentName so that it relies on the tag
  22173. // instead.
  22174. fiber.type = REACT_SUSPENSE_TYPE;
  22175. fiber.elementType = REACT_SUSPENSE_TYPE;
  22176. fiber.expirationTime = expirationTime;
  22177. return fiber;
  22178. }
  22179. function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) {
  22180. var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode);
  22181. {
  22182. // TODO: The SuspenseListComponent fiber shouldn't have a type. It has a tag.
  22183. // This needs to be fixed in getComponentName so that it relies on the tag
  22184. // instead.
  22185. fiber.type = REACT_SUSPENSE_LIST_TYPE;
  22186. }
  22187. fiber.elementType = REACT_SUSPENSE_LIST_TYPE;
  22188. fiber.expirationTime = expirationTime;
  22189. return fiber;
  22190. }
  22191. function createFiberFromText(content, mode, expirationTime) {
  22192. var fiber = createFiber(HostText, content, null, mode);
  22193. fiber.expirationTime = expirationTime;
  22194. return fiber;
  22195. }
  22196. function createFiberFromHostInstanceForDeletion() {
  22197. var fiber = createFiber(HostComponent, null, null, NoMode);
  22198. // TODO: These should not need a type.
  22199. fiber.elementType = 'DELETED';
  22200. fiber.type = 'DELETED';
  22201. return fiber;
  22202. }
  22203. function createFiberFromPortal(portal, mode, expirationTime) {
  22204. var pendingProps = portal.children !== null ? portal.children : [];
  22205. var fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
  22206. fiber.expirationTime = expirationTime;
  22207. fiber.stateNode = {
  22208. containerInfo: portal.containerInfo,
  22209. pendingChildren: null, // Used by persistent updates
  22210. implementation: portal.implementation
  22211. };
  22212. return fiber;
  22213. }
  22214. // Used for stashing WIP properties to replay failed work in DEV.
  22215. function assignFiberPropertiesInDEV(target, source) {
  22216. if (target === null) {
  22217. // This Fiber's initial properties will always be overwritten.
  22218. // We only use a Fiber to ensure the same hidden class so DEV isn't slow.
  22219. target = createFiber(IndeterminateComponent, null, null, NoMode);
  22220. }
  22221. // This is intentionally written as a list of all properties.
  22222. // We tried to use Object.assign() instead but this is called in
  22223. // the hottest path, and Object.assign() was too slow:
  22224. // https://github.com/facebook/react/issues/12502
  22225. // This code is DEV-only so size is not a concern.
  22226. target.tag = source.tag;
  22227. target.key = source.key;
  22228. target.elementType = source.elementType;
  22229. target.type = source.type;
  22230. target.stateNode = source.stateNode;
  22231. target.return = source.return;
  22232. target.child = source.child;
  22233. target.sibling = source.sibling;
  22234. target.index = source.index;
  22235. target.ref = source.ref;
  22236. target.pendingProps = source.pendingProps;
  22237. target.memoizedProps = source.memoizedProps;
  22238. target.updateQueue = source.updateQueue;
  22239. target.memoizedState = source.memoizedState;
  22240. target.dependencies = source.dependencies;
  22241. target.mode = source.mode;
  22242. target.effectTag = source.effectTag;
  22243. target.nextEffect = source.nextEffect;
  22244. target.firstEffect = source.firstEffect;
  22245. target.lastEffect = source.lastEffect;
  22246. target.expirationTime = source.expirationTime;
  22247. target.childExpirationTime = source.childExpirationTime;
  22248. target.alternate = source.alternate;
  22249. if (enableProfilerTimer) {
  22250. target.actualDuration = source.actualDuration;
  22251. target.actualStartTime = source.actualStartTime;
  22252. target.selfBaseDuration = source.selfBaseDuration;
  22253. target.treeBaseDuration = source.treeBaseDuration;
  22254. }
  22255. target._debugID = source._debugID;
  22256. target._debugSource = source._debugSource;
  22257. target._debugOwner = source._debugOwner;
  22258. target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming;
  22259. target._debugNeedsRemount = source._debugNeedsRemount;
  22260. target._debugHookTypes = source._debugHookTypes;
  22261. return target;
  22262. }
  22263. // TODO: This should be lifted into the renderer.
  22264. // The following attributes are only used by interaction tracing builds.
  22265. // They enable interactions to be associated with their async work,
  22266. // And expose interaction metadata to the React DevTools Profiler plugin.
  22267. // Note that these attributes are only defined when the enableSchedulerTracing flag is enabled.
  22268. // Exported FiberRoot type includes all properties,
  22269. // To avoid requiring potentially error-prone :any casts throughout the project.
  22270. // Profiling properties are only safe to access in profiling builds (when enableSchedulerTracing is true).
  22271. // The types are defined separately within this file to ensure they stay in sync.
  22272. // (We don't have to use an inline :any cast when enableSchedulerTracing is disabled.)
  22273. function FiberRootNode(containerInfo, tag, hydrate) {
  22274. this.tag = tag;
  22275. this.current = null;
  22276. this.containerInfo = containerInfo;
  22277. this.pendingChildren = null;
  22278. this.pingCache = null;
  22279. this.finishedExpirationTime = NoWork;
  22280. this.finishedWork = null;
  22281. this.timeoutHandle = noTimeout;
  22282. this.context = null;
  22283. this.pendingContext = null;
  22284. this.hydrate = hydrate;
  22285. this.firstBatch = null;
  22286. this.callbackNode = null;
  22287. this.callbackExpirationTime = NoWork;
  22288. this.firstPendingTime = NoWork;
  22289. this.lastPendingTime = NoWork;
  22290. this.pingTime = NoWork;
  22291. if (enableSchedulerTracing) {
  22292. this.interactionThreadID = tracing.unstable_getThreadID();
  22293. this.memoizedInteractions = new Set();
  22294. this.pendingInteractionMap = new Map();
  22295. }
  22296. }
  22297. function createFiberRoot(containerInfo, tag, hydrate) {
  22298. var root = new FiberRootNode(containerInfo, tag, hydrate);
  22299. // Cyclic construction. This cheats the type system right now because
  22300. // stateNode is any.
  22301. var uninitializedFiber = createHostRootFiber(tag);
  22302. root.current = uninitializedFiber;
  22303. uninitializedFiber.stateNode = root;
  22304. return root;
  22305. }
  22306. // This lets us hook into Fiber to debug what it's doing.
  22307. // See https://github.com/facebook/react/pull/8033.
  22308. // This is not part of the public API, not even for React DevTools.
  22309. // You may only inject a debugTool if you work on React Fiber itself.
  22310. var ReactFiberInstrumentation = {
  22311. debugTool: null
  22312. };
  22313. var ReactFiberInstrumentation_1 = ReactFiberInstrumentation;
  22314. // 0 is PROD, 1 is DEV.
  22315. // Might add PROFILE later.
  22316. var didWarnAboutNestedUpdates = void 0;
  22317. var didWarnAboutFindNodeInStrictMode = void 0;
  22318. {
  22319. didWarnAboutNestedUpdates = false;
  22320. didWarnAboutFindNodeInStrictMode = {};
  22321. }
  22322. function getContextForSubtree(parentComponent) {
  22323. if (!parentComponent) {
  22324. return emptyContextObject;
  22325. }
  22326. var fiber = get(parentComponent);
  22327. var parentContext = findCurrentUnmaskedContext(fiber);
  22328. if (fiber.tag === ClassComponent) {
  22329. var Component = fiber.type;
  22330. if (isContextProvider(Component)) {
  22331. return processChildContext(fiber, Component, parentContext);
  22332. }
  22333. }
  22334. return parentContext;
  22335. }
  22336. function scheduleRootUpdate(current$$1, element, expirationTime, suspenseConfig, callback) {
  22337. {
  22338. if (phase === 'render' && current !== null && !didWarnAboutNestedUpdates) {
  22339. didWarnAboutNestedUpdates = true;
  22340. 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');
  22341. }
  22342. }
  22343. var update = createUpdate(expirationTime, suspenseConfig);
  22344. // Caution: React DevTools currently depends on this property
  22345. // being called "element".
  22346. update.payload = { element: element };
  22347. callback = callback === undefined ? null : callback;
  22348. if (callback !== null) {
  22349. !(typeof callback === 'function') ? warningWithoutStack$1(false, 'render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback) : void 0;
  22350. update.callback = callback;
  22351. }
  22352. if (revertPassiveEffectsChange) {
  22353. flushPassiveEffects();
  22354. }
  22355. enqueueUpdate(current$$1, update);
  22356. scheduleWork(current$$1, expirationTime);
  22357. return expirationTime;
  22358. }
  22359. function updateContainerAtExpirationTime(element, container, parentComponent, expirationTime, suspenseConfig, callback) {
  22360. // TODO: If this is a nested container, this won't be the root.
  22361. var current$$1 = container.current;
  22362. {
  22363. if (ReactFiberInstrumentation_1.debugTool) {
  22364. if (current$$1.alternate === null) {
  22365. ReactFiberInstrumentation_1.debugTool.onMountContainer(container);
  22366. } else if (element === null) {
  22367. ReactFiberInstrumentation_1.debugTool.onUnmountContainer(container);
  22368. } else {
  22369. ReactFiberInstrumentation_1.debugTool.onUpdateContainer(container);
  22370. }
  22371. }
  22372. }
  22373. var context = getContextForSubtree(parentComponent);
  22374. if (container.context === null) {
  22375. container.context = context;
  22376. } else {
  22377. container.pendingContext = context;
  22378. }
  22379. return scheduleRootUpdate(current$$1, element, expirationTime, suspenseConfig, callback);
  22380. }
  22381. function findHostInstance(component) {
  22382. var fiber = get(component);
  22383. if (fiber === undefined) {
  22384. if (typeof component.render === 'function') {
  22385. (function () {
  22386. {
  22387. {
  22388. throw ReactError(Error('Unable to find node on an unmounted component.'));
  22389. }
  22390. }
  22391. })();
  22392. } else {
  22393. (function () {
  22394. {
  22395. {
  22396. throw ReactError(Error('Argument appears to not be a ReactComponent. Keys: ' + Object.keys(component)));
  22397. }
  22398. }
  22399. })();
  22400. }
  22401. }
  22402. var hostFiber = findCurrentHostFiber(fiber);
  22403. if (hostFiber === null) {
  22404. return null;
  22405. }
  22406. return hostFiber.stateNode;
  22407. }
  22408. function findHostInstanceWithWarning(component, methodName) {
  22409. {
  22410. var fiber = get(component);
  22411. if (fiber === undefined) {
  22412. if (typeof component.render === 'function') {
  22413. (function () {
  22414. {
  22415. {
  22416. throw ReactError(Error('Unable to find node on an unmounted component.'));
  22417. }
  22418. }
  22419. })();
  22420. } else {
  22421. (function () {
  22422. {
  22423. {
  22424. throw ReactError(Error('Argument appears to not be a ReactComponent. Keys: ' + Object.keys(component)));
  22425. }
  22426. }
  22427. })();
  22428. }
  22429. }
  22430. var hostFiber = findCurrentHostFiber(fiber);
  22431. if (hostFiber === null) {
  22432. return null;
  22433. }
  22434. if (hostFiber.mode & StrictMode) {
  22435. var componentName = getComponentName(fiber.type) || 'Component';
  22436. if (!didWarnAboutFindNodeInStrictMode[componentName]) {
  22437. didWarnAboutFindNodeInStrictMode[componentName] = true;
  22438. if (fiber.mode & StrictMode) {
  22439. 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));
  22440. } else {
  22441. 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));
  22442. }
  22443. }
  22444. }
  22445. return hostFiber.stateNode;
  22446. }
  22447. return findHostInstance(component);
  22448. }
  22449. function createContainer(containerInfo, tag, hydrate) {
  22450. return createFiberRoot(containerInfo, tag, hydrate);
  22451. }
  22452. function updateContainer(element, container, parentComponent, callback) {
  22453. var current$$1 = container.current;
  22454. var currentTime = requestCurrentTime();
  22455. {
  22456. // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
  22457. if ('undefined' !== typeof jest) {
  22458. warnIfUnmockedScheduler(current$$1);
  22459. warnIfNotScopedWithMatchingAct(current$$1);
  22460. }
  22461. }
  22462. var suspenseConfig = requestCurrentSuspenseConfig();
  22463. var expirationTime = computeExpirationForFiber(currentTime, current$$1, suspenseConfig);
  22464. return updateContainerAtExpirationTime(element, container, parentComponent, expirationTime, suspenseConfig, callback);
  22465. }
  22466. function getPublicRootInstance(container) {
  22467. var containerFiber = container.current;
  22468. if (!containerFiber.child) {
  22469. return null;
  22470. }
  22471. switch (containerFiber.child.tag) {
  22472. case HostComponent:
  22473. return getPublicInstance(containerFiber.child.stateNode);
  22474. default:
  22475. return containerFiber.child.stateNode;
  22476. }
  22477. }
  22478. function findHostInstanceWithNoPortals(fiber) {
  22479. var hostFiber = findCurrentHostFiberWithNoPortals(fiber);
  22480. if (hostFiber === null) {
  22481. return null;
  22482. }
  22483. if (hostFiber.tag === FundamentalComponent) {
  22484. return hostFiber.stateNode.instance;
  22485. }
  22486. return hostFiber.stateNode;
  22487. }
  22488. var shouldSuspendImpl = function (fiber) {
  22489. return false;
  22490. };
  22491. function shouldSuspend(fiber) {
  22492. return shouldSuspendImpl(fiber);
  22493. }
  22494. var overrideHookState = null;
  22495. var overrideProps = null;
  22496. var scheduleUpdate = null;
  22497. var setSuspenseHandler = null;
  22498. {
  22499. var copyWithSetImpl = function (obj, path, idx, value) {
  22500. if (idx >= path.length) {
  22501. return value;
  22502. }
  22503. var key = path[idx];
  22504. var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj);
  22505. // $FlowFixMe number or string is fine here
  22506. updated[key] = copyWithSetImpl(obj[key], path, idx + 1, value);
  22507. return updated;
  22508. };
  22509. var copyWithSet = function (obj, path, value) {
  22510. return copyWithSetImpl(obj, path, 0, value);
  22511. };
  22512. // Support DevTools editable values for useState and useReducer.
  22513. overrideHookState = function (fiber, id, path, value) {
  22514. // For now, the "id" of stateful hooks is just the stateful hook index.
  22515. // This may change in the future with e.g. nested hooks.
  22516. var currentHook = fiber.memoizedState;
  22517. while (currentHook !== null && id > 0) {
  22518. currentHook = currentHook.next;
  22519. id--;
  22520. }
  22521. if (currentHook !== null) {
  22522. if (revertPassiveEffectsChange) {
  22523. flushPassiveEffects();
  22524. }
  22525. var newState = copyWithSet(currentHook.memoizedState, path, value);
  22526. currentHook.memoizedState = newState;
  22527. currentHook.baseState = newState;
  22528. // We aren't actually adding an update to the queue,
  22529. // because there is no update we can add for useReducer hooks that won't trigger an error.
  22530. // (There's no appropriate action type for DevTools overrides.)
  22531. // As a result though, React will see the scheduled update as a noop and bailout.
  22532. // Shallow cloning props works as a workaround for now to bypass the bailout check.
  22533. fiber.memoizedProps = _assign({}, fiber.memoizedProps);
  22534. scheduleWork(fiber, Sync);
  22535. }
  22536. };
  22537. // Support DevTools props for function components, forwardRef, memo, host components, etc.
  22538. overrideProps = function (fiber, path, value) {
  22539. if (revertPassiveEffectsChange) {
  22540. flushPassiveEffects();
  22541. }
  22542. fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value);
  22543. if (fiber.alternate) {
  22544. fiber.alternate.pendingProps = fiber.pendingProps;
  22545. }
  22546. scheduleWork(fiber, Sync);
  22547. };
  22548. scheduleUpdate = function (fiber) {
  22549. if (revertPassiveEffectsChange) {
  22550. flushPassiveEffects();
  22551. }
  22552. scheduleWork(fiber, Sync);
  22553. };
  22554. setSuspenseHandler = function (newShouldSuspendImpl) {
  22555. shouldSuspendImpl = newShouldSuspendImpl;
  22556. };
  22557. }
  22558. function injectIntoDevTools(devToolsConfig) {
  22559. var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
  22560. var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
  22561. return injectInternals(_assign({}, devToolsConfig, {
  22562. overrideHookState: overrideHookState,
  22563. overrideProps: overrideProps,
  22564. setSuspenseHandler: setSuspenseHandler,
  22565. scheduleUpdate: scheduleUpdate,
  22566. currentDispatcherRef: ReactCurrentDispatcher,
  22567. findHostInstanceByFiber: function (fiber) {
  22568. var hostFiber = findCurrentHostFiber(fiber);
  22569. if (hostFiber === null) {
  22570. return null;
  22571. }
  22572. return hostFiber.stateNode;
  22573. },
  22574. findFiberByHostInstance: function (instance) {
  22575. if (!findFiberByHostInstance) {
  22576. // Might not be implemented by the renderer.
  22577. return null;
  22578. }
  22579. return findFiberByHostInstance(instance);
  22580. },
  22581. // React Refresh
  22582. findHostInstancesForRefresh: findHostInstancesForRefresh,
  22583. scheduleRefresh: scheduleRefresh,
  22584. scheduleRoot: scheduleRoot,
  22585. setRefreshHandler: setRefreshHandler,
  22586. // Enables DevTools to append owner stacks to error messages in DEV mode.
  22587. getCurrentFiber: function () {
  22588. return current;
  22589. }
  22590. }));
  22591. }
  22592. // This file intentionally does *not* have the Flow annotation.
  22593. // Don't add it. See `./inline-typed.js` for an explanation.
  22594. function createPortal$1(children, containerInfo,
  22595. // TODO: figure out the API for cross-renderer implementation.
  22596. implementation) {
  22597. var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  22598. return {
  22599. // This tag allow us to uniquely identify this as a React Portal
  22600. $$typeof: REACT_PORTAL_TYPE,
  22601. key: key == null ? null : '' + key,
  22602. children: children,
  22603. containerInfo: containerInfo,
  22604. implementation: implementation
  22605. };
  22606. }
  22607. // TODO: this is special because it gets imported during build.
  22608. var ReactVersion = '16.9.0';
  22609. // TODO: This type is shared between the reconciler and ReactDOM, but will
  22610. // eventually be lifted out to the renderer.
  22611. var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
  22612. var topLevelUpdateWarnings = void 0;
  22613. var warnOnInvalidCallback = void 0;
  22614. var didWarnAboutUnstableCreatePortal = false;
  22615. {
  22616. if (typeof Map !== 'function' ||
  22617. // $FlowIssue Flow incorrectly thinks Map has no prototype
  22618. Map.prototype == null || typeof Map.prototype.forEach !== 'function' || typeof Set !== 'function' ||
  22619. // $FlowIssue Flow incorrectly thinks Set has no prototype
  22620. Set.prototype == null || typeof Set.prototype.clear !== 'function' || typeof Set.prototype.forEach !== 'function') {
  22621. 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');
  22622. }
  22623. topLevelUpdateWarnings = function (container) {
  22624. if (container._reactRootContainer && container.nodeType !== COMMENT_NODE) {
  22625. var hostInstance = findHostInstanceWithNoPortals(container._reactRootContainer._internalRoot.current);
  22626. if (hostInstance) {
  22627. !(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;
  22628. }
  22629. }
  22630. var isRootRenderedBySomeReact = !!container._reactRootContainer;
  22631. var rootEl = getReactRootElementInContainer(container);
  22632. var hasNonRootReactChild = !!(rootEl && getInstanceFromNode$1(rootEl));
  22633. !(!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;
  22634. !(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;
  22635. };
  22636. warnOnInvalidCallback = function (callback, callerName) {
  22637. !(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;
  22638. };
  22639. }
  22640. setRestoreImplementation(restoreControlledState$1);
  22641. function ReactBatch(root) {
  22642. var expirationTime = computeUniqueAsyncExpiration();
  22643. this._expirationTime = expirationTime;
  22644. this._root = root;
  22645. this._next = null;
  22646. this._callbacks = null;
  22647. this._didComplete = false;
  22648. this._hasChildren = false;
  22649. this._children = null;
  22650. this._defer = true;
  22651. }
  22652. ReactBatch.prototype.render = function (children) {
  22653. var _this = this;
  22654. (function () {
  22655. if (!_this._defer) {
  22656. {
  22657. throw ReactError(Error('batch.render: Cannot render a batch that already committed.'));
  22658. }
  22659. }
  22660. })();
  22661. this._hasChildren = true;
  22662. this._children = children;
  22663. var internalRoot = this._root._internalRoot;
  22664. var expirationTime = this._expirationTime;
  22665. var work = new ReactWork();
  22666. updateContainerAtExpirationTime(children, internalRoot, null, expirationTime, null, work._onCommit);
  22667. return work;
  22668. };
  22669. ReactBatch.prototype.then = function (onComplete) {
  22670. if (this._didComplete) {
  22671. onComplete();
  22672. return;
  22673. }
  22674. var callbacks = this._callbacks;
  22675. if (callbacks === null) {
  22676. callbacks = this._callbacks = [];
  22677. }
  22678. callbacks.push(onComplete);
  22679. };
  22680. ReactBatch.prototype.commit = function () {
  22681. var _this2 = this;
  22682. var internalRoot = this._root._internalRoot;
  22683. var firstBatch = internalRoot.firstBatch;
  22684. (function () {
  22685. if (!(_this2._defer && firstBatch !== null)) {
  22686. {
  22687. throw ReactError(Error('batch.commit: Cannot commit a batch multiple times.'));
  22688. }
  22689. }
  22690. })();
  22691. if (!this._hasChildren) {
  22692. // This batch is empty. Return.
  22693. this._next = null;
  22694. this._defer = false;
  22695. return;
  22696. }
  22697. var expirationTime = this._expirationTime;
  22698. // Ensure this is the first batch in the list.
  22699. if (firstBatch !== this) {
  22700. // This batch is not the earliest batch. We need to move it to the front.
  22701. // Update its expiration time to be the expiration time of the earliest
  22702. // batch, so that we can flush it without flushing the other batches.
  22703. if (this._hasChildren) {
  22704. expirationTime = this._expirationTime = firstBatch._expirationTime;
  22705. // Rendering this batch again ensures its children will be the final state
  22706. // when we flush (updates are processed in insertion order: last
  22707. // update wins).
  22708. // TODO: This forces a restart. Should we print a warning?
  22709. this.render(this._children);
  22710. }
  22711. // Remove the batch from the list.
  22712. var previous = null;
  22713. var batch = firstBatch;
  22714. while (batch !== this) {
  22715. previous = batch;
  22716. batch = batch._next;
  22717. }
  22718. (function () {
  22719. if (!(previous !== null)) {
  22720. {
  22721. throw ReactError(Error('batch.commit: Cannot commit a batch multiple times.'));
  22722. }
  22723. }
  22724. })();
  22725. previous._next = batch._next;
  22726. // Add it to the front.
  22727. this._next = firstBatch;
  22728. firstBatch = internalRoot.firstBatch = this;
  22729. }
  22730. // Synchronously flush all the work up to this batch's expiration time.
  22731. this._defer = false;
  22732. flushRoot(internalRoot, expirationTime);
  22733. // Pop the batch from the list.
  22734. var next = this._next;
  22735. this._next = null;
  22736. firstBatch = internalRoot.firstBatch = next;
  22737. // Append the next earliest batch's children to the update queue.
  22738. if (firstBatch !== null && firstBatch._hasChildren) {
  22739. firstBatch.render(firstBatch._children);
  22740. }
  22741. };
  22742. ReactBatch.prototype._onComplete = function () {
  22743. if (this._didComplete) {
  22744. return;
  22745. }
  22746. this._didComplete = true;
  22747. var callbacks = this._callbacks;
  22748. if (callbacks === null) {
  22749. return;
  22750. }
  22751. // TODO: Error handling.
  22752. for (var i = 0; i < callbacks.length; i++) {
  22753. var _callback = callbacks[i];
  22754. _callback();
  22755. }
  22756. };
  22757. function ReactWork() {
  22758. this._callbacks = null;
  22759. this._didCommit = false;
  22760. // TODO: Avoid need to bind by replacing callbacks in the update queue with
  22761. // list of Work objects.
  22762. this._onCommit = this._onCommit.bind(this);
  22763. }
  22764. ReactWork.prototype.then = function (onCommit) {
  22765. if (this._didCommit) {
  22766. onCommit();
  22767. return;
  22768. }
  22769. var callbacks = this._callbacks;
  22770. if (callbacks === null) {
  22771. callbacks = this._callbacks = [];
  22772. }
  22773. callbacks.push(onCommit);
  22774. };
  22775. ReactWork.prototype._onCommit = function () {
  22776. if (this._didCommit) {
  22777. return;
  22778. }
  22779. this._didCommit = true;
  22780. var callbacks = this._callbacks;
  22781. if (callbacks === null) {
  22782. return;
  22783. }
  22784. // TODO: Error handling.
  22785. for (var i = 0; i < callbacks.length; i++) {
  22786. var _callback2 = callbacks[i];
  22787. (function () {
  22788. if (!(typeof _callback2 === 'function')) {
  22789. {
  22790. throw ReactError(Error('Invalid argument passed as callback. Expected a function. Instead received: ' + _callback2));
  22791. }
  22792. }
  22793. })();
  22794. _callback2();
  22795. }
  22796. };
  22797. function ReactSyncRoot(container, tag, hydrate) {
  22798. // Tag is either LegacyRoot or Concurrent Root
  22799. var root = createContainer(container, tag, hydrate);
  22800. this._internalRoot = root;
  22801. }
  22802. function ReactRoot(container, hydrate) {
  22803. var root = createContainer(container, ConcurrentRoot, hydrate);
  22804. this._internalRoot = root;
  22805. }
  22806. ReactRoot.prototype.render = ReactSyncRoot.prototype.render = function (children, callback) {
  22807. var root = this._internalRoot;
  22808. var work = new ReactWork();
  22809. callback = callback === undefined ? null : callback;
  22810. {
  22811. warnOnInvalidCallback(callback, 'render');
  22812. }
  22813. if (callback !== null) {
  22814. work.then(callback);
  22815. }
  22816. updateContainer(children, root, null, work._onCommit);
  22817. return work;
  22818. };
  22819. ReactRoot.prototype.unmount = ReactSyncRoot.prototype.unmount = function (callback) {
  22820. var root = this._internalRoot;
  22821. var work = new ReactWork();
  22822. callback = callback === undefined ? null : callback;
  22823. {
  22824. warnOnInvalidCallback(callback, 'render');
  22825. }
  22826. if (callback !== null) {
  22827. work.then(callback);
  22828. }
  22829. updateContainer(null, root, null, work._onCommit);
  22830. return work;
  22831. };
  22832. // Sync roots cannot create batches. Only concurrent ones.
  22833. ReactRoot.prototype.createBatch = function () {
  22834. var batch = new ReactBatch(this);
  22835. var expirationTime = batch._expirationTime;
  22836. var internalRoot = this._internalRoot;
  22837. var firstBatch = internalRoot.firstBatch;
  22838. if (firstBatch === null) {
  22839. internalRoot.firstBatch = batch;
  22840. batch._next = null;
  22841. } else {
  22842. // Insert sorted by expiration time then insertion order
  22843. var insertAfter = null;
  22844. var insertBefore = firstBatch;
  22845. while (insertBefore !== null && insertBefore._expirationTime >= expirationTime) {
  22846. insertAfter = insertBefore;
  22847. insertBefore = insertBefore._next;
  22848. }
  22849. batch._next = insertBefore;
  22850. if (insertAfter !== null) {
  22851. insertAfter._next = batch;
  22852. }
  22853. }
  22854. return batch;
  22855. };
  22856. /**
  22857. * True if the supplied DOM node is a valid node element.
  22858. *
  22859. * @param {?DOMElement} node The candidate DOM node.
  22860. * @return {boolean} True if the DOM is a valid DOM node.
  22861. * @internal
  22862. */
  22863. function isValidContainer(node) {
  22864. 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 '));
  22865. }
  22866. function getReactRootElementInContainer(container) {
  22867. if (!container) {
  22868. return null;
  22869. }
  22870. if (container.nodeType === DOCUMENT_NODE) {
  22871. return container.documentElement;
  22872. } else {
  22873. return container.firstChild;
  22874. }
  22875. }
  22876. function shouldHydrateDueToLegacyHeuristic(container) {
  22877. var rootElement = getReactRootElementInContainer(container);
  22878. return !!(rootElement && rootElement.nodeType === ELEMENT_NODE && rootElement.hasAttribute(ROOT_ATTRIBUTE_NAME));
  22879. }
  22880. setBatchingImplementation(batchedUpdates$1, discreteUpdates$1, flushDiscreteUpdates, batchedEventUpdates$1);
  22881. var warnedAboutHydrateAPI = false;
  22882. function legacyCreateRootFromDOMContainer(container, forceHydrate) {
  22883. var shouldHydrate = forceHydrate || shouldHydrateDueToLegacyHeuristic(container);
  22884. // First clear any existing content.
  22885. if (!shouldHydrate) {
  22886. var warned = false;
  22887. var rootSibling = void 0;
  22888. while (rootSibling = container.lastChild) {
  22889. {
  22890. if (!warned && rootSibling.nodeType === ELEMENT_NODE && rootSibling.hasAttribute(ROOT_ATTRIBUTE_NAME)) {
  22891. warned = true;
  22892. 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.');
  22893. }
  22894. }
  22895. container.removeChild(rootSibling);
  22896. }
  22897. }
  22898. {
  22899. if (shouldHydrate && !forceHydrate && !warnedAboutHydrateAPI) {
  22900. warnedAboutHydrateAPI = true;
  22901. 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.');
  22902. }
  22903. }
  22904. // Legacy roots are not batched.
  22905. return new ReactSyncRoot(container, LegacyRoot, shouldHydrate);
  22906. }
  22907. function legacyRenderSubtreeIntoContainer(parentComponent, children, container, forceHydrate, callback) {
  22908. {
  22909. topLevelUpdateWarnings(container);
  22910. warnOnInvalidCallback(callback === undefined ? null : callback, 'render');
  22911. }
  22912. // TODO: Without `any` type, Flow says "Property cannot be accessed on any
  22913. // member of intersection type." Whyyyyyy.
  22914. var root = container._reactRootContainer;
  22915. var fiberRoot = void 0;
  22916. if (!root) {
  22917. // Initial mount
  22918. root = container._reactRootContainer = legacyCreateRootFromDOMContainer(container, forceHydrate);
  22919. fiberRoot = root._internalRoot;
  22920. if (typeof callback === 'function') {
  22921. var originalCallback = callback;
  22922. callback = function () {
  22923. var instance = getPublicRootInstance(fiberRoot);
  22924. originalCallback.call(instance);
  22925. };
  22926. }
  22927. // Initial mount should not be batched.
  22928. unbatchedUpdates(function () {
  22929. updateContainer(children, fiberRoot, parentComponent, callback);
  22930. });
  22931. } else {
  22932. fiberRoot = root._internalRoot;
  22933. if (typeof callback === 'function') {
  22934. var _originalCallback = callback;
  22935. callback = function () {
  22936. var instance = getPublicRootInstance(fiberRoot);
  22937. _originalCallback.call(instance);
  22938. };
  22939. }
  22940. // Update
  22941. updateContainer(children, fiberRoot, parentComponent, callback);
  22942. }
  22943. return getPublicRootInstance(fiberRoot);
  22944. }
  22945. function createPortal$$1(children, container) {
  22946. var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  22947. (function () {
  22948. if (!isValidContainer(container)) {
  22949. {
  22950. throw ReactError(Error('Target container is not a DOM element.'));
  22951. }
  22952. }
  22953. })();
  22954. // TODO: pass ReactDOM portal implementation as third argument
  22955. return createPortal$1(children, container, null, key);
  22956. }
  22957. var ReactDOM = {
  22958. createPortal: createPortal$$1,
  22959. findDOMNode: function (componentOrElement) {
  22960. {
  22961. var owner = ReactCurrentOwner.current;
  22962. if (owner !== null && owner.stateNode !== null) {
  22963. var warnedAboutRefsInRender = owner.stateNode._warnedAboutRefsInRender;
  22964. !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;
  22965. owner.stateNode._warnedAboutRefsInRender = true;
  22966. }
  22967. }
  22968. if (componentOrElement == null) {
  22969. return null;
  22970. }
  22971. if (componentOrElement.nodeType === ELEMENT_NODE) {
  22972. return componentOrElement;
  22973. }
  22974. {
  22975. return findHostInstanceWithWarning(componentOrElement, 'findDOMNode');
  22976. }
  22977. return findHostInstance(componentOrElement);
  22978. },
  22979. hydrate: function (element, container, callback) {
  22980. (function () {
  22981. if (!isValidContainer(container)) {
  22982. {
  22983. throw ReactError(Error('Target container is not a DOM element.'));
  22984. }
  22985. }
  22986. })();
  22987. {
  22988. !!container._reactHasBeenPassedToCreateRootDEV ? warningWithoutStack$1(false, 'You are calling ReactDOM.hydrate() on a container that was previously ' + 'passed to ReactDOM.%s(). This is not supported. ' + 'Did you mean to call createRoot(container, {hydrate: true}).render(element)?', enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot') : void 0;
  22989. }
  22990. // TODO: throw or warn if we couldn't hydrate?
  22991. return legacyRenderSubtreeIntoContainer(null, element, container, true, callback);
  22992. },
  22993. render: function (element, container, callback) {
  22994. (function () {
  22995. if (!isValidContainer(container)) {
  22996. {
  22997. throw ReactError(Error('Target container is not a DOM element.'));
  22998. }
  22999. }
  23000. })();
  23001. {
  23002. !!container._reactHasBeenPassedToCreateRootDEV ? warningWithoutStack$1(false, 'You are calling ReactDOM.render() on a container that was previously ' + 'passed to ReactDOM.%s(). This is not supported. ' + 'Did you mean to call root.render(element)?', enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot') : void 0;
  23003. }
  23004. return legacyRenderSubtreeIntoContainer(null, element, container, false, callback);
  23005. },
  23006. unstable_renderSubtreeIntoContainer: function (parentComponent, element, containerNode, callback) {
  23007. (function () {
  23008. if (!isValidContainer(containerNode)) {
  23009. {
  23010. throw ReactError(Error('Target container is not a DOM element.'));
  23011. }
  23012. }
  23013. })();
  23014. (function () {
  23015. if (!(parentComponent != null && has(parentComponent))) {
  23016. {
  23017. throw ReactError(Error('parentComponent must be a valid React Component'));
  23018. }
  23019. }
  23020. })();
  23021. return legacyRenderSubtreeIntoContainer(parentComponent, element, containerNode, false, callback);
  23022. },
  23023. unmountComponentAtNode: function (container) {
  23024. (function () {
  23025. if (!isValidContainer(container)) {
  23026. {
  23027. throw ReactError(Error('unmountComponentAtNode(...): Target container is not a DOM element.'));
  23028. }
  23029. }
  23030. })();
  23031. {
  23032. !!container._reactHasBeenPassedToCreateRootDEV ? warningWithoutStack$1(false, 'You are calling ReactDOM.unmountComponentAtNode() on a container that was previously ' + 'passed to ReactDOM.%s(). This is not supported. Did you mean to call root.unmount()?', enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot') : void 0;
  23033. }
  23034. if (container._reactRootContainer) {
  23035. {
  23036. var rootEl = getReactRootElementInContainer(container);
  23037. var renderedByDifferentReact = rootEl && !getInstanceFromNode$1(rootEl);
  23038. !!renderedByDifferentReact ? warningWithoutStack$1(false, "unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by another copy of React.') : void 0;
  23039. }
  23040. // Unmount should not be batched.
  23041. unbatchedUpdates(function () {
  23042. legacyRenderSubtreeIntoContainer(null, null, container, false, function () {
  23043. container._reactRootContainer = null;
  23044. });
  23045. });
  23046. // If you call unmountComponentAtNode twice in quick succession, you'll
  23047. // get `true` twice. That's probably fine?
  23048. return true;
  23049. } else {
  23050. {
  23051. var _rootEl = getReactRootElementInContainer(container);
  23052. var hasNonRootReactChild = !!(_rootEl && getInstanceFromNode$1(_rootEl));
  23053. // Check if the container itself is a React root node.
  23054. var isContainerReactRoot = container.nodeType === ELEMENT_NODE && isValidContainer(container.parentNode) && !!container.parentNode._reactRootContainer;
  23055. !!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;
  23056. }
  23057. return false;
  23058. }
  23059. },
  23060. // Temporary alias since we already shipped React 16 RC with it.
  23061. // TODO: remove in React 17.
  23062. unstable_createPortal: function () {
  23063. if (!didWarnAboutUnstableCreatePortal) {
  23064. didWarnAboutUnstableCreatePortal = true;
  23065. 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.');
  23066. }
  23067. return createPortal$$1.apply(undefined, arguments);
  23068. },
  23069. unstable_batchedUpdates: batchedUpdates$1,
  23070. // TODO remove this legacy method, unstable_discreteUpdates replaces it
  23071. unstable_interactiveUpdates: function (fn, a, b, c) {
  23072. flushDiscreteUpdates();
  23073. return discreteUpdates$1(fn, a, b, c);
  23074. },
  23075. unstable_discreteUpdates: discreteUpdates$1,
  23076. unstable_flushDiscreteUpdates: flushDiscreteUpdates,
  23077. flushSync: flushSync,
  23078. unstable_createRoot: createRoot,
  23079. unstable_createSyncRoot: createSyncRoot,
  23080. unstable_flushControlled: flushControlled,
  23081. __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
  23082. // Keep in sync with ReactDOMUnstableNativeDependencies.js
  23083. // ReactTestUtils.js, and ReactTestUtilsAct.js. This is an array for better minification.
  23084. Events: [getInstanceFromNode$1, getNodeFromInstance$1, getFiberCurrentPropsFromNode$1, injection.injectEventPluginsByName, eventNameDispatchConfigs, accumulateTwoPhaseDispatches, accumulateDirectDispatches, enqueueStateRestore, restoreStateIfNeeded, dispatchEvent, runEventsInBatch, flushPassiveEffects, IsThisRendererActing]
  23085. }
  23086. };
  23087. function createRoot(container, options) {
  23088. var functionName = enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot';
  23089. (function () {
  23090. if (!isValidContainer(container)) {
  23091. {
  23092. throw ReactError(Error(functionName + '(...): Target container is not a DOM element.'));
  23093. }
  23094. }
  23095. })();
  23096. warnIfReactDOMContainerInDEV(container);
  23097. var hydrate = options != null && options.hydrate === true;
  23098. return new ReactRoot(container, hydrate);
  23099. }
  23100. function createSyncRoot(container, options) {
  23101. var functionName = enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot';
  23102. (function () {
  23103. if (!isValidContainer(container)) {
  23104. {
  23105. throw ReactError(Error(functionName + '(...): Target container is not a DOM element.'));
  23106. }
  23107. }
  23108. })();
  23109. warnIfReactDOMContainerInDEV(container);
  23110. var hydrate = options != null && options.hydrate === true;
  23111. return new ReactSyncRoot(container, BatchedRoot, hydrate);
  23112. }
  23113. function warnIfReactDOMContainerInDEV(container) {
  23114. {
  23115. !!container._reactRootContainer ? warningWithoutStack$1(false, 'You are calling ReactDOM.%s() on a container that was previously ' + 'passed to ReactDOM.render(). This is not supported.', enableStableConcurrentModeAPIs ? 'createRoot' : 'unstable_createRoot') : void 0;
  23116. container._reactHasBeenPassedToCreateRootDEV = true;
  23117. }
  23118. }
  23119. if (enableStableConcurrentModeAPIs) {
  23120. ReactDOM.createRoot = createRoot;
  23121. ReactDOM.createSyncRoot = createSyncRoot;
  23122. }
  23123. var foundDevTools = injectIntoDevTools({
  23124. findFiberByHostInstance: getClosestInstanceFromNode,
  23125. bundleType: 1,
  23126. version: ReactVersion,
  23127. rendererPackageName: 'react-dom'
  23128. });
  23129. {
  23130. if (!foundDevTools && canUseDOM && window.top === window.self) {
  23131. // If we're in Chrome or Firefox, provide a download link if not installed.
  23132. if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) {
  23133. var protocol = window.location.protocol;
  23134. // Don't warn in exotic cases like chrome-extension://.
  23135. if (/^(https?|file):$/.test(protocol)) {
  23136. 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');
  23137. }
  23138. }
  23139. }
  23140. }
  23141. var ReactDOM$2 = Object.freeze({
  23142. default: ReactDOM
  23143. });
  23144. var ReactDOM$3 = ( ReactDOM$2 && ReactDOM ) || ReactDOM$2;
  23145. // TODO: decide on the top-level export form.
  23146. // This is hacky but makes it work with both Rollup and Jest.
  23147. var reactDom = ReactDOM$3.default || ReactDOM$3;
  23148. module.exports = reactDom;
  23149. })();
  23150. }
  23151. /***/ }),
  23152. /***/ "../../node_modules/react-dom/index.js":
  23153. /*!***********************************************************!*\
  23154. !*** D:/Repos/Babylon.js/node_modules/react-dom/index.js ***!
  23155. \***********************************************************/
  23156. /*! no static exports found */
  23157. /***/ (function(module, exports, __webpack_require__) {
  23158. "use strict";
  23159. function checkDCE() {
  23160. /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
  23161. if (
  23162. typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined' ||
  23163. typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== 'function'
  23164. ) {
  23165. return;
  23166. }
  23167. if (true) {
  23168. // This branch is unreachable because this function is only called
  23169. // in production, but the condition is true only in development.
  23170. // Therefore if the branch is still here, dead code elimination wasn't
  23171. // properly applied.
  23172. // Don't change the message. React DevTools relies on it. Also make sure
  23173. // this message doesn't occur elsewhere in this function, or it will cause
  23174. // a false positive.
  23175. throw new Error('^_^');
  23176. }
  23177. try {
  23178. // Verify that the code above has been dead code eliminated (DCE'd).
  23179. __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE);
  23180. } catch (err) {
  23181. // DevTools shouldn't crash React, no matter what.
  23182. // We should still report in case we break this code.
  23183. console.error(err);
  23184. }
  23185. }
  23186. if (false) {} else {
  23187. module.exports = __webpack_require__(/*! ./cjs/react-dom.development.js */ "../../node_modules/react-dom/cjs/react-dom.development.js");
  23188. }
  23189. /***/ }),
  23190. /***/ "../../node_modules/react/cjs/react.development.js":
  23191. /*!***********************************************************************!*\
  23192. !*** D:/Repos/Babylon.js/node_modules/react/cjs/react.development.js ***!
  23193. \***********************************************************************/
  23194. /*! no static exports found */
  23195. /***/ (function(module, exports, __webpack_require__) {
  23196. "use strict";
  23197. /** @license React v16.9.0
  23198. * react.development.js
  23199. *
  23200. * Copyright (c) Facebook, Inc. and its affiliates.
  23201. *
  23202. * This source code is licensed under the MIT license found in the
  23203. * LICENSE file in the root directory of this source tree.
  23204. */
  23205. if (true) {
  23206. (function() {
  23207. 'use strict';
  23208. var _assign = __webpack_require__(/*! object-assign */ "../../node_modules/object-assign/index.js");
  23209. var checkPropTypes = __webpack_require__(/*! prop-types/checkPropTypes */ "../../node_modules/prop-types/checkPropTypes.js");
  23210. // TODO: this is special because it gets imported during build.
  23211. var ReactVersion = '16.9.0';
  23212. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  23213. // nor polyfill, then a plain number is used for performance.
  23214. var hasSymbol = typeof Symbol === 'function' && Symbol.for;
  23215. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
  23216. var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
  23217. var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
  23218. var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
  23219. var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
  23220. var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
  23221. var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
  23222. // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
  23223. // (unstable) APIs that have been removed. Can we remove the symbols?
  23224. var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
  23225. var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
  23226. var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
  23227. var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
  23228. var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
  23229. var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
  23230. var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
  23231. var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
  23232. var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  23233. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  23234. function getIteratorFn(maybeIterable) {
  23235. if (maybeIterable === null || typeof maybeIterable !== 'object') {
  23236. return null;
  23237. }
  23238. var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
  23239. if (typeof maybeIterator === 'function') {
  23240. return maybeIterator;
  23241. }
  23242. return null;
  23243. }
  23244. // Do not require this module directly! Use normal `invariant` calls with
  23245. // template literal strings. The messages will be converted to ReactError during
  23246. // build, and in production they will be minified.
  23247. // Do not require this module directly! Use normal `invariant` calls with
  23248. // template literal strings. The messages will be converted to ReactError during
  23249. // build, and in production they will be minified.
  23250. function ReactError(error) {
  23251. error.name = 'Invariant Violation';
  23252. return error;
  23253. }
  23254. /**
  23255. * Use invariant() to assert state which your program assumes to be true.
  23256. *
  23257. * Provide sprintf-style format (only %s is supported) and arguments
  23258. * to provide information about what broke and what you were
  23259. * expecting.
  23260. *
  23261. * The invariant message will be stripped in production, but the invariant
  23262. * will remain to ensure logic does not differ in production.
  23263. */
  23264. /**
  23265. * Forked from fbjs/warning:
  23266. * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
  23267. *
  23268. * Only change is we use console.warn instead of console.error,
  23269. * and do nothing when 'console' is not supported.
  23270. * This really simplifies the code.
  23271. * ---
  23272. * Similar to invariant but only logs a warning if the condition is not met.
  23273. * This can be used to log issues in development environments in critical
  23274. * paths. Removing the logging code for production environments will keep the
  23275. * same logic and follow the same code paths.
  23276. */
  23277. var lowPriorityWarning = function () {};
  23278. {
  23279. var printWarning = function (format) {
  23280. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  23281. args[_key - 1] = arguments[_key];
  23282. }
  23283. var argIndex = 0;
  23284. var message = 'Warning: ' + format.replace(/%s/g, function () {
  23285. return args[argIndex++];
  23286. });
  23287. if (typeof console !== 'undefined') {
  23288. console.warn(message);
  23289. }
  23290. try {
  23291. // --- Welcome to debugging React ---
  23292. // This error was thrown as a convenience so that you can use this stack
  23293. // to find the callsite that caused this warning to fire.
  23294. throw new Error(message);
  23295. } catch (x) {}
  23296. };
  23297. lowPriorityWarning = function (condition, format) {
  23298. if (format === undefined) {
  23299. throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
  23300. }
  23301. if (!condition) {
  23302. for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  23303. args[_key2 - 2] = arguments[_key2];
  23304. }
  23305. printWarning.apply(undefined, [format].concat(args));
  23306. }
  23307. };
  23308. }
  23309. var lowPriorityWarning$1 = lowPriorityWarning;
  23310. /**
  23311. * Similar to invariant but only logs a warning if the condition is not met.
  23312. * This can be used to log issues in development environments in critical
  23313. * paths. Removing the logging code for production environments will keep the
  23314. * same logic and follow the same code paths.
  23315. */
  23316. var warningWithoutStack = function () {};
  23317. {
  23318. warningWithoutStack = function (condition, format) {
  23319. for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  23320. args[_key - 2] = arguments[_key];
  23321. }
  23322. if (format === undefined) {
  23323. throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
  23324. }
  23325. if (args.length > 8) {
  23326. // Check before the condition to catch violations early.
  23327. throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
  23328. }
  23329. if (condition) {
  23330. return;
  23331. }
  23332. if (typeof console !== 'undefined') {
  23333. var argsWithFormat = args.map(function (item) {
  23334. return '' + item;
  23335. });
  23336. argsWithFormat.unshift('Warning: ' + format);
  23337. // We intentionally don't use spread (or .apply) directly because it
  23338. // breaks IE9: https://github.com/facebook/react/issues/13610
  23339. Function.prototype.apply.call(console.error, console, argsWithFormat);
  23340. }
  23341. try {
  23342. // --- Welcome to debugging React ---
  23343. // This error was thrown as a convenience so that you can use this stack
  23344. // to find the callsite that caused this warning to fire.
  23345. var argIndex = 0;
  23346. var message = 'Warning: ' + format.replace(/%s/g, function () {
  23347. return args[argIndex++];
  23348. });
  23349. throw new Error(message);
  23350. } catch (x) {}
  23351. };
  23352. }
  23353. var warningWithoutStack$1 = warningWithoutStack;
  23354. var didWarnStateUpdateForUnmountedComponent = {};
  23355. function warnNoop(publicInstance, callerName) {
  23356. {
  23357. var _constructor = publicInstance.constructor;
  23358. var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
  23359. var warningKey = componentName + '.' + callerName;
  23360. if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
  23361. return;
  23362. }
  23363. 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);
  23364. didWarnStateUpdateForUnmountedComponent[warningKey] = true;
  23365. }
  23366. }
  23367. /**
  23368. * This is the abstract API for an update queue.
  23369. */
  23370. var ReactNoopUpdateQueue = {
  23371. /**
  23372. * Checks whether or not this composite component is mounted.
  23373. * @param {ReactClass} publicInstance The instance we want to test.
  23374. * @return {boolean} True if mounted, false otherwise.
  23375. * @protected
  23376. * @final
  23377. */
  23378. isMounted: function (publicInstance) {
  23379. return false;
  23380. },
  23381. /**
  23382. * Forces an update. This should only be invoked when it is known with
  23383. * certainty that we are **not** in a DOM transaction.
  23384. *
  23385. * You may want to call this when you know that some deeper aspect of the
  23386. * component's state has changed but `setState` was not called.
  23387. *
  23388. * This will not invoke `shouldComponentUpdate`, but it will invoke
  23389. * `componentWillUpdate` and `componentDidUpdate`.
  23390. *
  23391. * @param {ReactClass} publicInstance The instance that should rerender.
  23392. * @param {?function} callback Called after component is updated.
  23393. * @param {?string} callerName name of the calling function in the public API.
  23394. * @internal
  23395. */
  23396. enqueueForceUpdate: function (publicInstance, callback, callerName) {
  23397. warnNoop(publicInstance, 'forceUpdate');
  23398. },
  23399. /**
  23400. * Replaces all of the state. Always use this or `setState` to mutate state.
  23401. * You should treat `this.state` as immutable.
  23402. *
  23403. * There is no guarantee that `this.state` will be immediately updated, so
  23404. * accessing `this.state` after calling this method may return the old value.
  23405. *
  23406. * @param {ReactClass} publicInstance The instance that should rerender.
  23407. * @param {object} completeState Next state.
  23408. * @param {?function} callback Called after component is updated.
  23409. * @param {?string} callerName name of the calling function in the public API.
  23410. * @internal
  23411. */
  23412. enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {
  23413. warnNoop(publicInstance, 'replaceState');
  23414. },
  23415. /**
  23416. * Sets a subset of the state. This only exists because _pendingState is
  23417. * internal. This provides a merging strategy that is not available to deep
  23418. * properties which is confusing. TODO: Expose pendingState or don't use it
  23419. * during the merge.
  23420. *
  23421. * @param {ReactClass} publicInstance The instance that should rerender.
  23422. * @param {object} partialState Next partial state to be merged with state.
  23423. * @param {?function} callback Called after component is updated.
  23424. * @param {?string} Name of the calling function in the public API.
  23425. * @internal
  23426. */
  23427. enqueueSetState: function (publicInstance, partialState, callback, callerName) {
  23428. warnNoop(publicInstance, 'setState');
  23429. }
  23430. };
  23431. var emptyObject = {};
  23432. {
  23433. Object.freeze(emptyObject);
  23434. }
  23435. /**
  23436. * Base class helpers for the updating state of a component.
  23437. */
  23438. function Component(props, context, updater) {
  23439. this.props = props;
  23440. this.context = context;
  23441. // If a component has string refs, we will assign a different object later.
  23442. this.refs = emptyObject;
  23443. // We initialize the default updater but the real one gets injected by the
  23444. // renderer.
  23445. this.updater = updater || ReactNoopUpdateQueue;
  23446. }
  23447. Component.prototype.isReactComponent = {};
  23448. /**
  23449. * Sets a subset of the state. Always use this to mutate
  23450. * state. You should treat `this.state` as immutable.
  23451. *
  23452. * There is no guarantee that `this.state` will be immediately updated, so
  23453. * accessing `this.state` after calling this method may return the old value.
  23454. *
  23455. * There is no guarantee that calls to `setState` will run synchronously,
  23456. * as they may eventually be batched together. You can provide an optional
  23457. * callback that will be executed when the call to setState is actually
  23458. * completed.
  23459. *
  23460. * When a function is provided to setState, it will be called at some point in
  23461. * the future (not synchronously). It will be called with the up to date
  23462. * component arguments (state, props, context). These values can be different
  23463. * from this.* because your function may be called after receiveProps but before
  23464. * shouldComponentUpdate, and this new state, props, and context will not yet be
  23465. * assigned to this.
  23466. *
  23467. * @param {object|function} partialState Next partial state or function to
  23468. * produce next partial state to be merged with current state.
  23469. * @param {?function} callback Called after state is updated.
  23470. * @final
  23471. * @protected
  23472. */
  23473. Component.prototype.setState = function (partialState, callback) {
  23474. (function () {
  23475. if (!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)) {
  23476. {
  23477. throw ReactError(Error('setState(...): takes an object of state variables to update or a function which returns an object of state variables.'));
  23478. }
  23479. }
  23480. })();
  23481. this.updater.enqueueSetState(this, partialState, callback, 'setState');
  23482. };
  23483. /**
  23484. * Forces an update. This should only be invoked when it is known with
  23485. * certainty that we are **not** in a DOM transaction.
  23486. *
  23487. * You may want to call this when you know that some deeper aspect of the
  23488. * component's state has changed but `setState` was not called.
  23489. *
  23490. * This will not invoke `shouldComponentUpdate`, but it will invoke
  23491. * `componentWillUpdate` and `componentDidUpdate`.
  23492. *
  23493. * @param {?function} callback Called after update is complete.
  23494. * @final
  23495. * @protected
  23496. */
  23497. Component.prototype.forceUpdate = function (callback) {
  23498. this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
  23499. };
  23500. /**
  23501. * Deprecated APIs. These APIs used to exist on classic React classes but since
  23502. * we would like to deprecate them, we're not going to move them over to this
  23503. * modern base class. Instead, we define a getter that warns if it's accessed.
  23504. */
  23505. {
  23506. var deprecatedAPIs = {
  23507. isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
  23508. replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
  23509. };
  23510. var defineDeprecationWarning = function (methodName, info) {
  23511. Object.defineProperty(Component.prototype, methodName, {
  23512. get: function () {
  23513. lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
  23514. return undefined;
  23515. }
  23516. });
  23517. };
  23518. for (var fnName in deprecatedAPIs) {
  23519. if (deprecatedAPIs.hasOwnProperty(fnName)) {
  23520. defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
  23521. }
  23522. }
  23523. }
  23524. function ComponentDummy() {}
  23525. ComponentDummy.prototype = Component.prototype;
  23526. /**
  23527. * Convenience component with default shallow equality check for sCU.
  23528. */
  23529. function PureComponent(props, context, updater) {
  23530. this.props = props;
  23531. this.context = context;
  23532. // If a component has string refs, we will assign a different object later.
  23533. this.refs = emptyObject;
  23534. this.updater = updater || ReactNoopUpdateQueue;
  23535. }
  23536. var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
  23537. pureComponentPrototype.constructor = PureComponent;
  23538. // Avoid an extra prototype jump for these methods.
  23539. _assign(pureComponentPrototype, Component.prototype);
  23540. pureComponentPrototype.isPureReactComponent = true;
  23541. // an immutable object with a single mutable value
  23542. function createRef() {
  23543. var refObject = {
  23544. current: null
  23545. };
  23546. {
  23547. Object.seal(refObject);
  23548. }
  23549. return refObject;
  23550. }
  23551. /**
  23552. * Keeps track of the current dispatcher.
  23553. */
  23554. var ReactCurrentDispatcher = {
  23555. /**
  23556. * @internal
  23557. * @type {ReactComponent}
  23558. */
  23559. current: null
  23560. };
  23561. /**
  23562. * Keeps track of the current batch's configuration such as how long an update
  23563. * should suspend for if it needs to.
  23564. */
  23565. var ReactCurrentBatchConfig = {
  23566. suspense: null
  23567. };
  23568. /**
  23569. * Keeps track of the current owner.
  23570. *
  23571. * The current owner is the component who should own any components that are
  23572. * currently being constructed.
  23573. */
  23574. var ReactCurrentOwner = {
  23575. /**
  23576. * @internal
  23577. * @type {ReactComponent}
  23578. */
  23579. current: null
  23580. };
  23581. var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
  23582. var describeComponentFrame = function (name, source, ownerName) {
  23583. var sourceInfo = '';
  23584. if (source) {
  23585. var path = source.fileName;
  23586. var fileName = path.replace(BEFORE_SLASH_RE, '');
  23587. {
  23588. // In DEV, include code for a common special case:
  23589. // prefer "folder/index.js" instead of just "index.js".
  23590. if (/^index\./.test(fileName)) {
  23591. var match = path.match(BEFORE_SLASH_RE);
  23592. if (match) {
  23593. var pathBeforeSlash = match[1];
  23594. if (pathBeforeSlash) {
  23595. var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
  23596. fileName = folderName + '/' + fileName;
  23597. }
  23598. }
  23599. }
  23600. }
  23601. sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
  23602. } else if (ownerName) {
  23603. sourceInfo = ' (created by ' + ownerName + ')';
  23604. }
  23605. return '\n in ' + (name || 'Unknown') + sourceInfo;
  23606. };
  23607. var Resolved = 1;
  23608. function refineResolvedLazyComponent(lazyComponent) {
  23609. return lazyComponent._status === Resolved ? lazyComponent._result : null;
  23610. }
  23611. function getWrappedName(outerType, innerType, wrapperName) {
  23612. var functionName = innerType.displayName || innerType.name || '';
  23613. return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName);
  23614. }
  23615. function getComponentName(type) {
  23616. if (type == null) {
  23617. // Host root, text node or just invalid type.
  23618. return null;
  23619. }
  23620. {
  23621. if (typeof type.tag === 'number') {
  23622. warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
  23623. }
  23624. }
  23625. if (typeof type === 'function') {
  23626. return type.displayName || type.name || null;
  23627. }
  23628. if (typeof type === 'string') {
  23629. return type;
  23630. }
  23631. switch (type) {
  23632. case REACT_FRAGMENT_TYPE:
  23633. return 'Fragment';
  23634. case REACT_PORTAL_TYPE:
  23635. return 'Portal';
  23636. case REACT_PROFILER_TYPE:
  23637. return 'Profiler';
  23638. case REACT_STRICT_MODE_TYPE:
  23639. return 'StrictMode';
  23640. case REACT_SUSPENSE_TYPE:
  23641. return 'Suspense';
  23642. case REACT_SUSPENSE_LIST_TYPE:
  23643. return 'SuspenseList';
  23644. }
  23645. if (typeof type === 'object') {
  23646. switch (type.$$typeof) {
  23647. case REACT_CONTEXT_TYPE:
  23648. return 'Context.Consumer';
  23649. case REACT_PROVIDER_TYPE:
  23650. return 'Context.Provider';
  23651. case REACT_FORWARD_REF_TYPE:
  23652. return getWrappedName(type, type.render, 'ForwardRef');
  23653. case REACT_MEMO_TYPE:
  23654. return getComponentName(type.type);
  23655. case REACT_LAZY_TYPE:
  23656. {
  23657. var thenable = type;
  23658. var resolvedThenable = refineResolvedLazyComponent(thenable);
  23659. if (resolvedThenable) {
  23660. return getComponentName(resolvedThenable);
  23661. }
  23662. break;
  23663. }
  23664. }
  23665. }
  23666. return null;
  23667. }
  23668. var ReactDebugCurrentFrame = {};
  23669. var currentlyValidatingElement = null;
  23670. function setCurrentlyValidatingElement(element) {
  23671. {
  23672. currentlyValidatingElement = element;
  23673. }
  23674. }
  23675. {
  23676. // Stack implementation injected by the current renderer.
  23677. ReactDebugCurrentFrame.getCurrentStack = null;
  23678. ReactDebugCurrentFrame.getStackAddendum = function () {
  23679. var stack = '';
  23680. // Add an extra top frame while an element is being validated
  23681. if (currentlyValidatingElement) {
  23682. var name = getComponentName(currentlyValidatingElement.type);
  23683. var owner = currentlyValidatingElement._owner;
  23684. stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
  23685. }
  23686. // Delegate to the injected renderer-specific implementation
  23687. var impl = ReactDebugCurrentFrame.getCurrentStack;
  23688. if (impl) {
  23689. stack += impl() || '';
  23690. }
  23691. return stack;
  23692. };
  23693. }
  23694. /**
  23695. * Used by act() to track whether you're inside an act() scope.
  23696. */
  23697. var IsSomeRendererActing = {
  23698. current: false
  23699. };
  23700. var ReactSharedInternals = {
  23701. ReactCurrentDispatcher: ReactCurrentDispatcher,
  23702. ReactCurrentBatchConfig: ReactCurrentBatchConfig,
  23703. ReactCurrentOwner: ReactCurrentOwner,
  23704. IsSomeRendererActing: IsSomeRendererActing,
  23705. // Used by renderers to avoid bundling object-assign twice in UMD bundles:
  23706. assign: _assign
  23707. };
  23708. {
  23709. _assign(ReactSharedInternals, {
  23710. // These should not be included in production.
  23711. ReactDebugCurrentFrame: ReactDebugCurrentFrame,
  23712. // Shim for React DOM 16.0.0 which still destructured (but not used) this.
  23713. // TODO: remove in React 17.0.
  23714. ReactComponentTreeHook: {}
  23715. });
  23716. }
  23717. /**
  23718. * Similar to invariant but only logs a warning if the condition is not met.
  23719. * This can be used to log issues in development environments in critical
  23720. * paths. Removing the logging code for production environments will keep the
  23721. * same logic and follow the same code paths.
  23722. */
  23723. var warning = warningWithoutStack$1;
  23724. {
  23725. warning = function (condition, format) {
  23726. if (condition) {
  23727. return;
  23728. }
  23729. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  23730. var stack = ReactDebugCurrentFrame.getStackAddendum();
  23731. // eslint-disable-next-line react-internal/warning-and-invariant-args
  23732. for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  23733. args[_key - 2] = arguments[_key];
  23734. }
  23735. warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
  23736. };
  23737. }
  23738. var warning$1 = warning;
  23739. var hasOwnProperty = Object.prototype.hasOwnProperty;
  23740. var RESERVED_PROPS = {
  23741. key: true,
  23742. ref: true,
  23743. __self: true,
  23744. __source: true
  23745. };
  23746. var specialPropKeyWarningShown = void 0;
  23747. var specialPropRefWarningShown = void 0;
  23748. function hasValidRef(config) {
  23749. {
  23750. if (hasOwnProperty.call(config, 'ref')) {
  23751. var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
  23752. if (getter && getter.isReactWarning) {
  23753. return false;
  23754. }
  23755. }
  23756. }
  23757. return config.ref !== undefined;
  23758. }
  23759. function hasValidKey(config) {
  23760. {
  23761. if (hasOwnProperty.call(config, 'key')) {
  23762. var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
  23763. if (getter && getter.isReactWarning) {
  23764. return false;
  23765. }
  23766. }
  23767. }
  23768. return config.key !== undefined;
  23769. }
  23770. function defineKeyPropWarningGetter(props, displayName) {
  23771. var warnAboutAccessingKey = function () {
  23772. if (!specialPropKeyWarningShown) {
  23773. specialPropKeyWarningShown = true;
  23774. 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);
  23775. }
  23776. };
  23777. warnAboutAccessingKey.isReactWarning = true;
  23778. Object.defineProperty(props, 'key', {
  23779. get: warnAboutAccessingKey,
  23780. configurable: true
  23781. });
  23782. }
  23783. function defineRefPropWarningGetter(props, displayName) {
  23784. var warnAboutAccessingRef = function () {
  23785. if (!specialPropRefWarningShown) {
  23786. specialPropRefWarningShown = true;
  23787. 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);
  23788. }
  23789. };
  23790. warnAboutAccessingRef.isReactWarning = true;
  23791. Object.defineProperty(props, 'ref', {
  23792. get: warnAboutAccessingRef,
  23793. configurable: true
  23794. });
  23795. }
  23796. /**
  23797. * Factory method to create a new React element. This no longer adheres to
  23798. * the class pattern, so do not use new to call it. Also, no instanceof check
  23799. * will work. Instead test $$typeof field against Symbol.for('react.element') to check
  23800. * if something is a React Element.
  23801. *
  23802. * @param {*} type
  23803. * @param {*} props
  23804. * @param {*} key
  23805. * @param {string|object} ref
  23806. * @param {*} owner
  23807. * @param {*} self A *temporary* helper to detect places where `this` is
  23808. * different from the `owner` when React.createElement is called, so that we
  23809. * can warn. We want to get rid of owner and replace string `ref`s with arrow
  23810. * functions, and as long as `this` and owner are the same, there will be no
  23811. * change in behavior.
  23812. * @param {*} source An annotation object (added by a transpiler or otherwise)
  23813. * indicating filename, line number, and/or other information.
  23814. * @internal
  23815. */
  23816. var ReactElement = function (type, key, ref, self, source, owner, props) {
  23817. var element = {
  23818. // This tag allows us to uniquely identify this as a React Element
  23819. $$typeof: REACT_ELEMENT_TYPE,
  23820. // Built-in properties that belong on the element
  23821. type: type,
  23822. key: key,
  23823. ref: ref,
  23824. props: props,
  23825. // Record the component responsible for creating this element.
  23826. _owner: owner
  23827. };
  23828. {
  23829. // The validation flag is currently mutative. We put it on
  23830. // an external backing store so that we can freeze the whole object.
  23831. // This can be replaced with a WeakMap once they are implemented in
  23832. // commonly used development environments.
  23833. element._store = {};
  23834. // To make comparing ReactElements easier for testing purposes, we make
  23835. // the validation flag non-enumerable (where possible, which should
  23836. // include every environment we run tests in), so the test framework
  23837. // ignores it.
  23838. Object.defineProperty(element._store, 'validated', {
  23839. configurable: false,
  23840. enumerable: false,
  23841. writable: true,
  23842. value: false
  23843. });
  23844. // self and source are DEV only properties.
  23845. Object.defineProperty(element, '_self', {
  23846. configurable: false,
  23847. enumerable: false,
  23848. writable: false,
  23849. value: self
  23850. });
  23851. // Two elements created in two different places should be considered
  23852. // equal for testing purposes and therefore we hide it from enumeration.
  23853. Object.defineProperty(element, '_source', {
  23854. configurable: false,
  23855. enumerable: false,
  23856. writable: false,
  23857. value: source
  23858. });
  23859. if (Object.freeze) {
  23860. Object.freeze(element.props);
  23861. Object.freeze(element);
  23862. }
  23863. }
  23864. return element;
  23865. };
  23866. /**
  23867. * https://github.com/reactjs/rfcs/pull/107
  23868. * @param {*} type
  23869. * @param {object} props
  23870. * @param {string} key
  23871. */
  23872. /**
  23873. * https://github.com/reactjs/rfcs/pull/107
  23874. * @param {*} type
  23875. * @param {object} props
  23876. * @param {string} key
  23877. */
  23878. function jsxDEV(type, config, maybeKey, source, self) {
  23879. var propName = void 0;
  23880. // Reserved names are extracted
  23881. var props = {};
  23882. var key = null;
  23883. var ref = null;
  23884. if (hasValidRef(config)) {
  23885. ref = config.ref;
  23886. }
  23887. if (hasValidKey(config)) {
  23888. key = '' + config.key;
  23889. }
  23890. // Remaining properties are added to a new props object
  23891. for (propName in config) {
  23892. if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
  23893. props[propName] = config[propName];
  23894. }
  23895. }
  23896. // intentionally not checking if key was set above
  23897. // this key is higher priority as it's static
  23898. if (maybeKey !== undefined) {
  23899. key = '' + maybeKey;
  23900. }
  23901. // Resolve default props
  23902. if (type && type.defaultProps) {
  23903. var defaultProps = type.defaultProps;
  23904. for (propName in defaultProps) {
  23905. if (props[propName] === undefined) {
  23906. props[propName] = defaultProps[propName];
  23907. }
  23908. }
  23909. }
  23910. if (key || ref) {
  23911. var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
  23912. if (key) {
  23913. defineKeyPropWarningGetter(props, displayName);
  23914. }
  23915. if (ref) {
  23916. defineRefPropWarningGetter(props, displayName);
  23917. }
  23918. }
  23919. return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
  23920. }
  23921. /**
  23922. * Create and return a new ReactElement of the given type.
  23923. * See https://reactjs.org/docs/react-api.html#createelement
  23924. */
  23925. function createElement(type, config, children) {
  23926. var propName = void 0;
  23927. // Reserved names are extracted
  23928. var props = {};
  23929. var key = null;
  23930. var ref = null;
  23931. var self = null;
  23932. var source = null;
  23933. if (config != null) {
  23934. if (hasValidRef(config)) {
  23935. ref = config.ref;
  23936. }
  23937. if (hasValidKey(config)) {
  23938. key = '' + config.key;
  23939. }
  23940. self = config.__self === undefined ? null : config.__self;
  23941. source = config.__source === undefined ? null : config.__source;
  23942. // Remaining properties are added to a new props object
  23943. for (propName in config) {
  23944. if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
  23945. props[propName] = config[propName];
  23946. }
  23947. }
  23948. }
  23949. // Children can be more than one argument, and those are transferred onto
  23950. // the newly allocated props object.
  23951. var childrenLength = arguments.length - 2;
  23952. if (childrenLength === 1) {
  23953. props.children = children;
  23954. } else if (childrenLength > 1) {
  23955. var childArray = Array(childrenLength);
  23956. for (var i = 0; i < childrenLength; i++) {
  23957. childArray[i] = arguments[i + 2];
  23958. }
  23959. {
  23960. if (Object.freeze) {
  23961. Object.freeze(childArray);
  23962. }
  23963. }
  23964. props.children = childArray;
  23965. }
  23966. // Resolve default props
  23967. if (type && type.defaultProps) {
  23968. var defaultProps = type.defaultProps;
  23969. for (propName in defaultProps) {
  23970. if (props[propName] === undefined) {
  23971. props[propName] = defaultProps[propName];
  23972. }
  23973. }
  23974. }
  23975. {
  23976. if (key || ref) {
  23977. var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
  23978. if (key) {
  23979. defineKeyPropWarningGetter(props, displayName);
  23980. }
  23981. if (ref) {
  23982. defineRefPropWarningGetter(props, displayName);
  23983. }
  23984. }
  23985. }
  23986. return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
  23987. }
  23988. /**
  23989. * Return a function that produces ReactElements of a given type.
  23990. * See https://reactjs.org/docs/react-api.html#createfactory
  23991. */
  23992. function cloneAndReplaceKey(oldElement, newKey) {
  23993. var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
  23994. return newElement;
  23995. }
  23996. /**
  23997. * Clone and return a new ReactElement using element as the starting point.
  23998. * See https://reactjs.org/docs/react-api.html#cloneelement
  23999. */
  24000. function cloneElement(element, config, children) {
  24001. (function () {
  24002. if (!!(element === null || element === undefined)) {
  24003. {
  24004. throw ReactError(Error('React.cloneElement(...): The argument must be a React element, but you passed ' + element + '.'));
  24005. }
  24006. }
  24007. })();
  24008. var propName = void 0;
  24009. // Original props are copied
  24010. var props = _assign({}, element.props);
  24011. // Reserved names are extracted
  24012. var key = element.key;
  24013. var ref = element.ref;
  24014. // Self is preserved since the owner is preserved.
  24015. var self = element._self;
  24016. // Source is preserved since cloneElement is unlikely to be targeted by a
  24017. // transpiler, and the original source is probably a better indicator of the
  24018. // true owner.
  24019. var source = element._source;
  24020. // Owner will be preserved, unless ref is overridden
  24021. var owner = element._owner;
  24022. if (config != null) {
  24023. if (hasValidRef(config)) {
  24024. // Silently steal the ref from the parent.
  24025. ref = config.ref;
  24026. owner = ReactCurrentOwner.current;
  24027. }
  24028. if (hasValidKey(config)) {
  24029. key = '' + config.key;
  24030. }
  24031. // Remaining properties override existing props
  24032. var defaultProps = void 0;
  24033. if (element.type && element.type.defaultProps) {
  24034. defaultProps = element.type.defaultProps;
  24035. }
  24036. for (propName in config) {
  24037. if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
  24038. if (config[propName] === undefined && defaultProps !== undefined) {
  24039. // Resolve default props
  24040. props[propName] = defaultProps[propName];
  24041. } else {
  24042. props[propName] = config[propName];
  24043. }
  24044. }
  24045. }
  24046. }
  24047. // Children can be more than one argument, and those are transferred onto
  24048. // the newly allocated props object.
  24049. var childrenLength = arguments.length - 2;
  24050. if (childrenLength === 1) {
  24051. props.children = children;
  24052. } else if (childrenLength > 1) {
  24053. var childArray = Array(childrenLength);
  24054. for (var i = 0; i < childrenLength; i++) {
  24055. childArray[i] = arguments[i + 2];
  24056. }
  24057. props.children = childArray;
  24058. }
  24059. return ReactElement(element.type, key, ref, self, source, owner, props);
  24060. }
  24061. /**
  24062. * Verifies the object is a ReactElement.
  24063. * See https://reactjs.org/docs/react-api.html#isvalidelement
  24064. * @param {?object} object
  24065. * @return {boolean} True if `object` is a ReactElement.
  24066. * @final
  24067. */
  24068. function isValidElement(object) {
  24069. return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
  24070. }
  24071. var SEPARATOR = '.';
  24072. var SUBSEPARATOR = ':';
  24073. /**
  24074. * Escape and wrap key so it is safe to use as a reactid
  24075. *
  24076. * @param {string} key to be escaped.
  24077. * @return {string} the escaped key.
  24078. */
  24079. function escape(key) {
  24080. var escapeRegex = /[=:]/g;
  24081. var escaperLookup = {
  24082. '=': '=0',
  24083. ':': '=2'
  24084. };
  24085. var escapedString = ('' + key).replace(escapeRegex, function (match) {
  24086. return escaperLookup[match];
  24087. });
  24088. return '$' + escapedString;
  24089. }
  24090. /**
  24091. * TODO: Test that a single child and an array with one item have the same key
  24092. * pattern.
  24093. */
  24094. var didWarnAboutMaps = false;
  24095. var userProvidedKeyEscapeRegex = /\/+/g;
  24096. function escapeUserProvidedKey(text) {
  24097. return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
  24098. }
  24099. var POOL_SIZE = 10;
  24100. var traverseContextPool = [];
  24101. function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
  24102. if (traverseContextPool.length) {
  24103. var traverseContext = traverseContextPool.pop();
  24104. traverseContext.result = mapResult;
  24105. traverseContext.keyPrefix = keyPrefix;
  24106. traverseContext.func = mapFunction;
  24107. traverseContext.context = mapContext;
  24108. traverseContext.count = 0;
  24109. return traverseContext;
  24110. } else {
  24111. return {
  24112. result: mapResult,
  24113. keyPrefix: keyPrefix,
  24114. func: mapFunction,
  24115. context: mapContext,
  24116. count: 0
  24117. };
  24118. }
  24119. }
  24120. function releaseTraverseContext(traverseContext) {
  24121. traverseContext.result = null;
  24122. traverseContext.keyPrefix = null;
  24123. traverseContext.func = null;
  24124. traverseContext.context = null;
  24125. traverseContext.count = 0;
  24126. if (traverseContextPool.length < POOL_SIZE) {
  24127. traverseContextPool.push(traverseContext);
  24128. }
  24129. }
  24130. /**
  24131. * @param {?*} children Children tree container.
  24132. * @param {!string} nameSoFar Name of the key path so far.
  24133. * @param {!function} callback Callback to invoke with each child found.
  24134. * @param {?*} traverseContext Used to pass information throughout the traversal
  24135. * process.
  24136. * @return {!number} The number of children in this subtree.
  24137. */
  24138. function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
  24139. var type = typeof children;
  24140. if (type === 'undefined' || type === 'boolean') {
  24141. // All of the above are perceived as null.
  24142. children = null;
  24143. }
  24144. var invokeCallback = false;
  24145. if (children === null) {
  24146. invokeCallback = true;
  24147. } else {
  24148. switch (type) {
  24149. case 'string':
  24150. case 'number':
  24151. invokeCallback = true;
  24152. break;
  24153. case 'object':
  24154. switch (children.$$typeof) {
  24155. case REACT_ELEMENT_TYPE:
  24156. case REACT_PORTAL_TYPE:
  24157. invokeCallback = true;
  24158. }
  24159. }
  24160. }
  24161. if (invokeCallback) {
  24162. callback(traverseContext, children,
  24163. // If it's the only child, treat the name as if it was wrapped in an array
  24164. // so that it's consistent if the number of children grows.
  24165. nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
  24166. return 1;
  24167. }
  24168. var child = void 0;
  24169. var nextName = void 0;
  24170. var subtreeCount = 0; // Count of children found in the current subtree.
  24171. var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
  24172. if (Array.isArray(children)) {
  24173. for (var i = 0; i < children.length; i++) {
  24174. child = children[i];
  24175. nextName = nextNamePrefix + getComponentKey(child, i);
  24176. subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
  24177. }
  24178. } else {
  24179. var iteratorFn = getIteratorFn(children);
  24180. if (typeof iteratorFn === 'function') {
  24181. {
  24182. // Warn about using Maps as children
  24183. if (iteratorFn === children.entries) {
  24184. !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;
  24185. didWarnAboutMaps = true;
  24186. }
  24187. }
  24188. var iterator = iteratorFn.call(children);
  24189. var step = void 0;
  24190. var ii = 0;
  24191. while (!(step = iterator.next()).done) {
  24192. child = step.value;
  24193. nextName = nextNamePrefix + getComponentKey(child, ii++);
  24194. subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
  24195. }
  24196. } else if (type === 'object') {
  24197. var addendum = '';
  24198. {
  24199. addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
  24200. }
  24201. var childrenString = '' + children;
  24202. (function () {
  24203. {
  24204. {
  24205. throw ReactError(Error('Objects are not valid as a React child (found: ' + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + ').' + addendum));
  24206. }
  24207. }
  24208. })();
  24209. }
  24210. }
  24211. return subtreeCount;
  24212. }
  24213. /**
  24214. * Traverses children that are typically specified as `props.children`, but
  24215. * might also be specified through attributes:
  24216. *
  24217. * - `traverseAllChildren(this.props.children, ...)`
  24218. * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
  24219. *
  24220. * The `traverseContext` is an optional argument that is passed through the
  24221. * entire traversal. It can be used to store accumulations or anything else that
  24222. * the callback might find relevant.
  24223. *
  24224. * @param {?*} children Children tree object.
  24225. * @param {!function} callback To invoke upon traversing each child.
  24226. * @param {?*} traverseContext Context for traversal.
  24227. * @return {!number} The number of children in this subtree.
  24228. */
  24229. function traverseAllChildren(children, callback, traverseContext) {
  24230. if (children == null) {
  24231. return 0;
  24232. }
  24233. return traverseAllChildrenImpl(children, '', callback, traverseContext);
  24234. }
  24235. /**
  24236. * Generate a key string that identifies a component within a set.
  24237. *
  24238. * @param {*} component A component that could contain a manual key.
  24239. * @param {number} index Index that is used if a manual key is not provided.
  24240. * @return {string}
  24241. */
  24242. function getComponentKey(component, index) {
  24243. // Do some typechecking here since we call this blindly. We want to ensure
  24244. // that we don't block potential future ES APIs.
  24245. if (typeof component === 'object' && component !== null && component.key != null) {
  24246. // Explicit key
  24247. return escape(component.key);
  24248. }
  24249. // Implicit key determined by the index in the set
  24250. return index.toString(36);
  24251. }
  24252. function forEachSingleChild(bookKeeping, child, name) {
  24253. var func = bookKeeping.func,
  24254. context = bookKeeping.context;
  24255. func.call(context, child, bookKeeping.count++);
  24256. }
  24257. /**
  24258. * Iterates through children that are typically specified as `props.children`.
  24259. *
  24260. * See https://reactjs.org/docs/react-api.html#reactchildrenforeach
  24261. *
  24262. * The provided forEachFunc(child, index) will be called for each
  24263. * leaf child.
  24264. *
  24265. * @param {?*} children Children tree container.
  24266. * @param {function(*, int)} forEachFunc
  24267. * @param {*} forEachContext Context for forEachContext.
  24268. */
  24269. function forEachChildren(children, forEachFunc, forEachContext) {
  24270. if (children == null) {
  24271. return children;
  24272. }
  24273. var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
  24274. traverseAllChildren(children, forEachSingleChild, traverseContext);
  24275. releaseTraverseContext(traverseContext);
  24276. }
  24277. function mapSingleChildIntoContext(bookKeeping, child, childKey) {
  24278. var result = bookKeeping.result,
  24279. keyPrefix = bookKeeping.keyPrefix,
  24280. func = bookKeeping.func,
  24281. context = bookKeeping.context;
  24282. var mappedChild = func.call(context, child, bookKeeping.count++);
  24283. if (Array.isArray(mappedChild)) {
  24284. mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) {
  24285. return c;
  24286. });
  24287. } else if (mappedChild != null) {
  24288. if (isValidElement(mappedChild)) {
  24289. mappedChild = cloneAndReplaceKey(mappedChild,
  24290. // Keep both the (mapped) and old keys if they differ, just as
  24291. // traverseAllChildren used to do for objects as children
  24292. keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
  24293. }
  24294. result.push(mappedChild);
  24295. }
  24296. }
  24297. function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
  24298. var escapedPrefix = '';
  24299. if (prefix != null) {
  24300. escapedPrefix = escapeUserProvidedKey(prefix) + '/';
  24301. }
  24302. var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
  24303. traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
  24304. releaseTraverseContext(traverseContext);
  24305. }
  24306. /**
  24307. * Maps children that are typically specified as `props.children`.
  24308. *
  24309. * See https://reactjs.org/docs/react-api.html#reactchildrenmap
  24310. *
  24311. * The provided mapFunction(child, key, index) will be called for each
  24312. * leaf child.
  24313. *
  24314. * @param {?*} children Children tree container.
  24315. * @param {function(*, int)} func The map function.
  24316. * @param {*} context Context for mapFunction.
  24317. * @return {object} Object containing the ordered map of results.
  24318. */
  24319. function mapChildren(children, func, context) {
  24320. if (children == null) {
  24321. return children;
  24322. }
  24323. var result = [];
  24324. mapIntoWithKeyPrefixInternal(children, result, null, func, context);
  24325. return result;
  24326. }
  24327. /**
  24328. * Count the number of children that are typically specified as
  24329. * `props.children`.
  24330. *
  24331. * See https://reactjs.org/docs/react-api.html#reactchildrencount
  24332. *
  24333. * @param {?*} children Children tree container.
  24334. * @return {number} The number of children.
  24335. */
  24336. function countChildren(children) {
  24337. return traverseAllChildren(children, function () {
  24338. return null;
  24339. }, null);
  24340. }
  24341. /**
  24342. * Flatten a children object (typically specified as `props.children`) and
  24343. * return an array with appropriately re-keyed children.
  24344. *
  24345. * See https://reactjs.org/docs/react-api.html#reactchildrentoarray
  24346. */
  24347. function toArray(children) {
  24348. var result = [];
  24349. mapIntoWithKeyPrefixInternal(children, result, null, function (child) {
  24350. return child;
  24351. });
  24352. return result;
  24353. }
  24354. /**
  24355. * Returns the first child in a collection of children and verifies that there
  24356. * is only one child in the collection.
  24357. *
  24358. * See https://reactjs.org/docs/react-api.html#reactchildrenonly
  24359. *
  24360. * The current implementation of this function assumes that a single child gets
  24361. * passed without a wrapper, but the purpose of this helper function is to
  24362. * abstract away the particular structure of children.
  24363. *
  24364. * @param {?object} children Child collection structure.
  24365. * @return {ReactElement} The first and only `ReactElement` contained in the
  24366. * structure.
  24367. */
  24368. function onlyChild(children) {
  24369. (function () {
  24370. if (!isValidElement(children)) {
  24371. {
  24372. throw ReactError(Error('React.Children.only expected to receive a single React element child.'));
  24373. }
  24374. }
  24375. })();
  24376. return children;
  24377. }
  24378. function createContext(defaultValue, calculateChangedBits) {
  24379. if (calculateChangedBits === undefined) {
  24380. calculateChangedBits = null;
  24381. } else {
  24382. {
  24383. !(calculateChangedBits === null || typeof calculateChangedBits === 'function') ? warningWithoutStack$1(false, 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits) : void 0;
  24384. }
  24385. }
  24386. var context = {
  24387. $$typeof: REACT_CONTEXT_TYPE,
  24388. _calculateChangedBits: calculateChangedBits,
  24389. // As a workaround to support multiple concurrent renderers, we categorize
  24390. // some renderers as primary and others as secondary. We only expect
  24391. // there to be two concurrent renderers at most: React Native (primary) and
  24392. // Fabric (secondary); React DOM (primary) and React ART (secondary).
  24393. // Secondary renderers store their context values on separate fields.
  24394. _currentValue: defaultValue,
  24395. _currentValue2: defaultValue,
  24396. // Used to track how many concurrent renderers this context currently
  24397. // supports within in a single renderer. Such as parallel server rendering.
  24398. _threadCount: 0,
  24399. // These are circular
  24400. Provider: null,
  24401. Consumer: null
  24402. };
  24403. context.Provider = {
  24404. $$typeof: REACT_PROVIDER_TYPE,
  24405. _context: context
  24406. };
  24407. var hasWarnedAboutUsingNestedContextConsumers = false;
  24408. var hasWarnedAboutUsingConsumerProvider = false;
  24409. {
  24410. // A separate object, but proxies back to the original context object for
  24411. // backwards compatibility. It has a different $$typeof, so we can properly
  24412. // warn for the incorrect usage of Context as a Consumer.
  24413. var Consumer = {
  24414. $$typeof: REACT_CONTEXT_TYPE,
  24415. _context: context,
  24416. _calculateChangedBits: context._calculateChangedBits
  24417. };
  24418. // $FlowFixMe: Flow complains about not setting a value, which is intentional here
  24419. Object.defineProperties(Consumer, {
  24420. Provider: {
  24421. get: function () {
  24422. if (!hasWarnedAboutUsingConsumerProvider) {
  24423. hasWarnedAboutUsingConsumerProvider = true;
  24424. 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?');
  24425. }
  24426. return context.Provider;
  24427. },
  24428. set: function (_Provider) {
  24429. context.Provider = _Provider;
  24430. }
  24431. },
  24432. _currentValue: {
  24433. get: function () {
  24434. return context._currentValue;
  24435. },
  24436. set: function (_currentValue) {
  24437. context._currentValue = _currentValue;
  24438. }
  24439. },
  24440. _currentValue2: {
  24441. get: function () {
  24442. return context._currentValue2;
  24443. },
  24444. set: function (_currentValue2) {
  24445. context._currentValue2 = _currentValue2;
  24446. }
  24447. },
  24448. _threadCount: {
  24449. get: function () {
  24450. return context._threadCount;
  24451. },
  24452. set: function (_threadCount) {
  24453. context._threadCount = _threadCount;
  24454. }
  24455. },
  24456. Consumer: {
  24457. get: function () {
  24458. if (!hasWarnedAboutUsingNestedContextConsumers) {
  24459. hasWarnedAboutUsingNestedContextConsumers = true;
  24460. 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?');
  24461. }
  24462. return context.Consumer;
  24463. }
  24464. }
  24465. });
  24466. // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
  24467. context.Consumer = Consumer;
  24468. }
  24469. {
  24470. context._currentRenderer = null;
  24471. context._currentRenderer2 = null;
  24472. }
  24473. return context;
  24474. }
  24475. function lazy(ctor) {
  24476. var lazyType = {
  24477. $$typeof: REACT_LAZY_TYPE,
  24478. _ctor: ctor,
  24479. // React uses these fields to store the result.
  24480. _status: -1,
  24481. _result: null
  24482. };
  24483. {
  24484. // In production, this would just set it on the object.
  24485. var defaultProps = void 0;
  24486. var propTypes = void 0;
  24487. Object.defineProperties(lazyType, {
  24488. defaultProps: {
  24489. configurable: true,
  24490. get: function () {
  24491. return defaultProps;
  24492. },
  24493. set: function (newDefaultProps) {
  24494. warning$1(false, 'React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
  24495. defaultProps = newDefaultProps;
  24496. // Match production behavior more closely:
  24497. Object.defineProperty(lazyType, 'defaultProps', {
  24498. enumerable: true
  24499. });
  24500. }
  24501. },
  24502. propTypes: {
  24503. configurable: true,
  24504. get: function () {
  24505. return propTypes;
  24506. },
  24507. set: function (newPropTypes) {
  24508. warning$1(false, 'React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
  24509. propTypes = newPropTypes;
  24510. // Match production behavior more closely:
  24511. Object.defineProperty(lazyType, 'propTypes', {
  24512. enumerable: true
  24513. });
  24514. }
  24515. }
  24516. });
  24517. }
  24518. return lazyType;
  24519. }
  24520. function forwardRef(render) {
  24521. {
  24522. if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
  24523. warningWithoutStack$1(false, 'forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
  24524. } else if (typeof render !== 'function') {
  24525. warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
  24526. } else {
  24527. !(
  24528. // Do not warn for 0 arguments because it could be due to usage of the 'arguments' object
  24529. 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;
  24530. }
  24531. if (render != null) {
  24532. !(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;
  24533. }
  24534. }
  24535. return {
  24536. $$typeof: REACT_FORWARD_REF_TYPE,
  24537. render: render
  24538. };
  24539. }
  24540. function isValidElementType(type) {
  24541. return typeof type === 'string' || typeof type === 'function' ||
  24542. // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
  24543. type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE);
  24544. }
  24545. function memo(type, compare) {
  24546. {
  24547. if (!isValidElementType(type)) {
  24548. warningWithoutStack$1(false, 'memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
  24549. }
  24550. }
  24551. return {
  24552. $$typeof: REACT_MEMO_TYPE,
  24553. type: type,
  24554. compare: compare === undefined ? null : compare
  24555. };
  24556. }
  24557. function resolveDispatcher() {
  24558. var dispatcher = ReactCurrentDispatcher.current;
  24559. (function () {
  24560. if (!(dispatcher !== null)) {
  24561. {
  24562. throw ReactError(Error('Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.'));
  24563. }
  24564. }
  24565. })();
  24566. return dispatcher;
  24567. }
  24568. function useContext(Context, unstable_observedBits) {
  24569. var dispatcher = resolveDispatcher();
  24570. {
  24571. !(unstable_observedBits === undefined) ? warning$1(false, 'useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://fb.me/rules-of-hooks' : '') : void 0;
  24572. // TODO: add a more generic warning for invalid values.
  24573. if (Context._context !== undefined) {
  24574. var realContext = Context._context;
  24575. // Don't deduplicate because this legitimately causes bugs
  24576. // and nobody should be using this in existing code.
  24577. if (realContext.Consumer === Context) {
  24578. 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?');
  24579. } else if (realContext.Provider === Context) {
  24580. warning$1(false, 'Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
  24581. }
  24582. }
  24583. }
  24584. return dispatcher.useContext(Context, unstable_observedBits);
  24585. }
  24586. function useState(initialState) {
  24587. var dispatcher = resolveDispatcher();
  24588. return dispatcher.useState(initialState);
  24589. }
  24590. function useReducer(reducer, initialArg, init) {
  24591. var dispatcher = resolveDispatcher();
  24592. return dispatcher.useReducer(reducer, initialArg, init);
  24593. }
  24594. function useRef(initialValue) {
  24595. var dispatcher = resolveDispatcher();
  24596. return dispatcher.useRef(initialValue);
  24597. }
  24598. function useEffect(create, inputs) {
  24599. var dispatcher = resolveDispatcher();
  24600. return dispatcher.useEffect(create, inputs);
  24601. }
  24602. function useLayoutEffect(create, inputs) {
  24603. var dispatcher = resolveDispatcher();
  24604. return dispatcher.useLayoutEffect(create, inputs);
  24605. }
  24606. function useCallback(callback, inputs) {
  24607. var dispatcher = resolveDispatcher();
  24608. return dispatcher.useCallback(callback, inputs);
  24609. }
  24610. function useMemo(create, inputs) {
  24611. var dispatcher = resolveDispatcher();
  24612. return dispatcher.useMemo(create, inputs);
  24613. }
  24614. function useImperativeHandle(ref, create, inputs) {
  24615. var dispatcher = resolveDispatcher();
  24616. return dispatcher.useImperativeHandle(ref, create, inputs);
  24617. }
  24618. function useDebugValue(value, formatterFn) {
  24619. {
  24620. var dispatcher = resolveDispatcher();
  24621. return dispatcher.useDebugValue(value, formatterFn);
  24622. }
  24623. }
  24624. var emptyObject$1 = {};
  24625. function useResponder(responder, listenerProps) {
  24626. var dispatcher = resolveDispatcher();
  24627. {
  24628. if (responder == null || responder.$$typeof !== REACT_RESPONDER_TYPE) {
  24629. warning$1(false, 'useResponder: invalid first argument. Expected an event responder, but instead got %s', responder);
  24630. return;
  24631. }
  24632. }
  24633. return dispatcher.useResponder(responder, listenerProps || emptyObject$1);
  24634. }
  24635. // Within the scope of the callback, mark all updates as being allowed to suspend.
  24636. function withSuspenseConfig(scope, config) {
  24637. var previousConfig = ReactCurrentBatchConfig.suspense;
  24638. ReactCurrentBatchConfig.suspense = config === undefined ? null : config;
  24639. try {
  24640. scope();
  24641. } finally {
  24642. ReactCurrentBatchConfig.suspense = previousConfig;
  24643. }
  24644. }
  24645. /**
  24646. * ReactElementValidator provides a wrapper around a element factory
  24647. * which validates the props passed to the element. This is intended to be
  24648. * used only in DEV and could be replaced by a static type checker for languages
  24649. * that support it.
  24650. */
  24651. var propTypesMisspellWarningShown = void 0;
  24652. {
  24653. propTypesMisspellWarningShown = false;
  24654. }
  24655. function getDeclarationErrorAddendum() {
  24656. if (ReactCurrentOwner.current) {
  24657. var name = getComponentName(ReactCurrentOwner.current.type);
  24658. if (name) {
  24659. return '\n\nCheck the render method of `' + name + '`.';
  24660. }
  24661. }
  24662. return '';
  24663. }
  24664. function getSourceInfoErrorAddendum(source) {
  24665. if (source !== undefined) {
  24666. var fileName = source.fileName.replace(/^.*[\\\/]/, '');
  24667. var lineNumber = source.lineNumber;
  24668. return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
  24669. }
  24670. return '';
  24671. }
  24672. function getSourceInfoErrorAddendumForProps(elementProps) {
  24673. if (elementProps !== null && elementProps !== undefined) {
  24674. return getSourceInfoErrorAddendum(elementProps.__source);
  24675. }
  24676. return '';
  24677. }
  24678. /**
  24679. * Warn if there's no key explicitly set on dynamic arrays of children or
  24680. * object keys are not valid. This allows us to keep track of children between
  24681. * updates.
  24682. */
  24683. var ownerHasKeyUseWarning = {};
  24684. function getCurrentComponentErrorInfo(parentType) {
  24685. var info = getDeclarationErrorAddendum();
  24686. if (!info) {
  24687. var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
  24688. if (parentName) {
  24689. info = '\n\nCheck the top-level render call using <' + parentName + '>.';
  24690. }
  24691. }
  24692. return info;
  24693. }
  24694. /**
  24695. * Warn if the element doesn't have an explicit key assigned to it.
  24696. * This element is in an array. The array could grow and shrink or be
  24697. * reordered. All children that haven't already been validated are required to
  24698. * have a "key" property assigned to it. Error statuses are cached so a warning
  24699. * will only be shown once.
  24700. *
  24701. * @internal
  24702. * @param {ReactElement} element Element that requires a key.
  24703. * @param {*} parentType element's parent's type.
  24704. */
  24705. function validateExplicitKey(element, parentType) {
  24706. if (!element._store || element._store.validated || element.key != null) {
  24707. return;
  24708. }
  24709. element._store.validated = true;
  24710. var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
  24711. if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
  24712. return;
  24713. }
  24714. ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
  24715. // Usually the current owner is the offender, but if it accepts children as a
  24716. // property, it may be the creator of the child that's responsible for
  24717. // assigning it a key.
  24718. var childOwner = '';
  24719. if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
  24720. // Give the component that originally created this child.
  24721. childOwner = ' It was passed a child from ' + getComponentName(element._owner.type) + '.';
  24722. }
  24723. setCurrentlyValidatingElement(element);
  24724. {
  24725. warning$1(false, 'Each child in a list should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner);
  24726. }
  24727. setCurrentlyValidatingElement(null);
  24728. }
  24729. /**
  24730. * Ensure that every element either is passed in a static location, in an
  24731. * array with an explicit keys property defined, or in an object literal
  24732. * with valid key property.
  24733. *
  24734. * @internal
  24735. * @param {ReactNode} node Statically passed child of any type.
  24736. * @param {*} parentType node's parent's type.
  24737. */
  24738. function validateChildKeys(node, parentType) {
  24739. if (typeof node !== 'object') {
  24740. return;
  24741. }
  24742. if (Array.isArray(node)) {
  24743. for (var i = 0; i < node.length; i++) {
  24744. var child = node[i];
  24745. if (isValidElement(child)) {
  24746. validateExplicitKey(child, parentType);
  24747. }
  24748. }
  24749. } else if (isValidElement(node)) {
  24750. // This element was passed in a valid location.
  24751. if (node._store) {
  24752. node._store.validated = true;
  24753. }
  24754. } else if (node) {
  24755. var iteratorFn = getIteratorFn(node);
  24756. if (typeof iteratorFn === 'function') {
  24757. // Entry iterators used to provide implicit keys,
  24758. // but now we print a separate warning for them later.
  24759. if (iteratorFn !== node.entries) {
  24760. var iterator = iteratorFn.call(node);
  24761. var step = void 0;
  24762. while (!(step = iterator.next()).done) {
  24763. if (isValidElement(step.value)) {
  24764. validateExplicitKey(step.value, parentType);
  24765. }
  24766. }
  24767. }
  24768. }
  24769. }
  24770. }
  24771. /**
  24772. * Given an element, validate that its props follow the propTypes definition,
  24773. * provided by the type.
  24774. *
  24775. * @param {ReactElement} element
  24776. */
  24777. function validatePropTypes(element) {
  24778. var type = element.type;
  24779. if (type === null || type === undefined || typeof type === 'string') {
  24780. return;
  24781. }
  24782. var name = getComponentName(type);
  24783. var propTypes = void 0;
  24784. if (typeof type === 'function') {
  24785. propTypes = type.propTypes;
  24786. } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE ||
  24787. // Note: Memo only checks outer props here.
  24788. // Inner props are checked in the reconciler.
  24789. type.$$typeof === REACT_MEMO_TYPE)) {
  24790. propTypes = type.propTypes;
  24791. } else {
  24792. return;
  24793. }
  24794. if (propTypes) {
  24795. setCurrentlyValidatingElement(element);
  24796. checkPropTypes(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
  24797. setCurrentlyValidatingElement(null);
  24798. } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
  24799. propTypesMisspellWarningShown = true;
  24800. warningWithoutStack$1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
  24801. }
  24802. if (typeof type.getDefaultProps === 'function') {
  24803. !type.getDefaultProps.isReactClassApproved ? warningWithoutStack$1(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
  24804. }
  24805. }
  24806. /**
  24807. * Given a fragment, validate that it can only be provided with fragment props
  24808. * @param {ReactElement} fragment
  24809. */
  24810. function validateFragmentProps(fragment) {
  24811. setCurrentlyValidatingElement(fragment);
  24812. var keys = Object.keys(fragment.props);
  24813. for (var i = 0; i < keys.length; i++) {
  24814. var key = keys[i];
  24815. if (key !== 'children' && key !== 'key') {
  24816. warning$1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
  24817. break;
  24818. }
  24819. }
  24820. if (fragment.ref !== null) {
  24821. warning$1(false, 'Invalid attribute `ref` supplied to `React.Fragment`.');
  24822. }
  24823. setCurrentlyValidatingElement(null);
  24824. }
  24825. function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
  24826. var validType = isValidElementType(type);
  24827. // We warn in this case but don't throw. We expect the element creation to
  24828. // succeed and there will likely be errors in render.
  24829. if (!validType) {
  24830. var info = '';
  24831. if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
  24832. 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.";
  24833. }
  24834. var sourceInfo = getSourceInfoErrorAddendum(source);
  24835. if (sourceInfo) {
  24836. info += sourceInfo;
  24837. } else {
  24838. info += getDeclarationErrorAddendum();
  24839. }
  24840. var typeString = void 0;
  24841. if (type === null) {
  24842. typeString = 'null';
  24843. } else if (Array.isArray(type)) {
  24844. typeString = 'array';
  24845. } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
  24846. typeString = '<' + (getComponentName(type.type) || 'Unknown') + ' />';
  24847. info = ' Did you accidentally export a JSX literal instead of a component?';
  24848. } else {
  24849. typeString = typeof type;
  24850. }
  24851. warning$1(false, 'React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
  24852. }
  24853. var element = jsxDEV(type, props, key, source, self);
  24854. // The result can be nullish if a mock or a custom function is used.
  24855. // TODO: Drop this when these are no longer allowed as the type argument.
  24856. if (element == null) {
  24857. return element;
  24858. }
  24859. // Skip key warning if the type isn't valid since our key validation logic
  24860. // doesn't expect a non-string/function type and can throw confusing errors.
  24861. // We don't want exception behavior to differ between dev and prod.
  24862. // (Rendering will throw with a helpful message and as soon as the type is
  24863. // fixed, the key warnings will appear.)
  24864. if (validType) {
  24865. var children = props.children;
  24866. if (children !== undefined) {
  24867. if (isStaticChildren) {
  24868. for (var i = 0; i < children.length; i++) {
  24869. validateChildKeys(children[i], type);
  24870. }
  24871. } else {
  24872. validateChildKeys(children, type);
  24873. }
  24874. }
  24875. }
  24876. if (props.key !== undefined) {
  24877. warning$1(false, 'React.jsx: Spreading a key to JSX is a deprecated pattern. ' + 'Explicitly pass a key after spreading props in your JSX call. ' + 'E.g. <ComponentName {...props} key={key} />');
  24878. }
  24879. if (type === REACT_FRAGMENT_TYPE) {
  24880. validateFragmentProps(element);
  24881. } else {
  24882. validatePropTypes(element);
  24883. }
  24884. return element;
  24885. }
  24886. // These two functions exist to still get child warnings in dev
  24887. // even with the prod transform. This means that jsxDEV is purely
  24888. // opt-in behavior for better messages but that we won't stop
  24889. // giving you warnings if you use production apis.
  24890. function jsxWithValidationStatic(type, props, key) {
  24891. return jsxWithValidation(type, props, key, true);
  24892. }
  24893. function jsxWithValidationDynamic(type, props, key) {
  24894. return jsxWithValidation(type, props, key, false);
  24895. }
  24896. function createElementWithValidation(type, props, children) {
  24897. var validType = isValidElementType(type);
  24898. // We warn in this case but don't throw. We expect the element creation to
  24899. // succeed and there will likely be errors in render.
  24900. if (!validType) {
  24901. var info = '';
  24902. if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
  24903. 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.";
  24904. }
  24905. var sourceInfo = getSourceInfoErrorAddendumForProps(props);
  24906. if (sourceInfo) {
  24907. info += sourceInfo;
  24908. } else {
  24909. info += getDeclarationErrorAddendum();
  24910. }
  24911. var typeString = void 0;
  24912. if (type === null) {
  24913. typeString = 'null';
  24914. } else if (Array.isArray(type)) {
  24915. typeString = 'array';
  24916. } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
  24917. typeString = '<' + (getComponentName(type.type) || 'Unknown') + ' />';
  24918. info = ' Did you accidentally export a JSX literal instead of a component?';
  24919. } else {
  24920. typeString = typeof type;
  24921. }
  24922. 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);
  24923. }
  24924. var element = createElement.apply(this, arguments);
  24925. // The result can be nullish if a mock or a custom function is used.
  24926. // TODO: Drop this when these are no longer allowed as the type argument.
  24927. if (element == null) {
  24928. return element;
  24929. }
  24930. // Skip key warning if the type isn't valid since our key validation logic
  24931. // doesn't expect a non-string/function type and can throw confusing errors.
  24932. // We don't want exception behavior to differ between dev and prod.
  24933. // (Rendering will throw with a helpful message and as soon as the type is
  24934. // fixed, the key warnings will appear.)
  24935. if (validType) {
  24936. for (var i = 2; i < arguments.length; i++) {
  24937. validateChildKeys(arguments[i], type);
  24938. }
  24939. }
  24940. if (type === REACT_FRAGMENT_TYPE) {
  24941. validateFragmentProps(element);
  24942. } else {
  24943. validatePropTypes(element);
  24944. }
  24945. return element;
  24946. }
  24947. function createFactoryWithValidation(type) {
  24948. var validatedFactory = createElementWithValidation.bind(null, type);
  24949. validatedFactory.type = type;
  24950. // Legacy hook: remove it
  24951. {
  24952. Object.defineProperty(validatedFactory, 'type', {
  24953. enumerable: false,
  24954. get: function () {
  24955. lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
  24956. Object.defineProperty(this, 'type', {
  24957. value: type
  24958. });
  24959. return type;
  24960. }
  24961. });
  24962. }
  24963. return validatedFactory;
  24964. }
  24965. function cloneElementWithValidation(element, props, children) {
  24966. var newElement = cloneElement.apply(this, arguments);
  24967. for (var i = 2; i < arguments.length; i++) {
  24968. validateChildKeys(arguments[i], newElement.type);
  24969. }
  24970. validatePropTypes(newElement);
  24971. return newElement;
  24972. }
  24973. var hasBadMapPolyfill = void 0;
  24974. {
  24975. hasBadMapPolyfill = false;
  24976. try {
  24977. var frozenObject = Object.freeze({});
  24978. var testMap = new Map([[frozenObject, null]]);
  24979. var testSet = new Set([frozenObject]);
  24980. // This is necessary for Rollup to not consider these unused.
  24981. // https://github.com/rollup/rollup/issues/1771
  24982. // TODO: we can remove these if Rollup fixes the bug.
  24983. testMap.set(0, 0);
  24984. testSet.add(0);
  24985. } catch (e) {
  24986. // TODO: Consider warning about bad polyfills
  24987. hasBadMapPolyfill = true;
  24988. }
  24989. }
  24990. function createFundamentalComponent(impl) {
  24991. // We use responder as a Map key later on. When we have a bad
  24992. // polyfill, then we can't use it as a key as the polyfill tries
  24993. // to add a property to the object.
  24994. if ( true && !hasBadMapPolyfill) {
  24995. Object.freeze(impl);
  24996. }
  24997. var fundamantalComponent = {
  24998. $$typeof: REACT_FUNDAMENTAL_TYPE,
  24999. impl: impl
  25000. };
  25001. {
  25002. Object.freeze(fundamantalComponent);
  25003. }
  25004. return fundamantalComponent;
  25005. }
  25006. function createEventResponder(displayName, responderConfig) {
  25007. var getInitialState = responderConfig.getInitialState,
  25008. onEvent = responderConfig.onEvent,
  25009. onMount = responderConfig.onMount,
  25010. onUnmount = responderConfig.onUnmount,
  25011. onOwnershipChange = responderConfig.onOwnershipChange,
  25012. onRootEvent = responderConfig.onRootEvent,
  25013. rootEventTypes = responderConfig.rootEventTypes,
  25014. targetEventTypes = responderConfig.targetEventTypes;
  25015. var eventResponder = {
  25016. $$typeof: REACT_RESPONDER_TYPE,
  25017. displayName: displayName,
  25018. getInitialState: getInitialState || null,
  25019. onEvent: onEvent || null,
  25020. onMount: onMount || null,
  25021. onOwnershipChange: onOwnershipChange || null,
  25022. onRootEvent: onRootEvent || null,
  25023. onUnmount: onUnmount || null,
  25024. rootEventTypes: rootEventTypes || null,
  25025. targetEventTypes: targetEventTypes || null
  25026. };
  25027. // We use responder as a Map key later on. When we have a bad
  25028. // polyfill, then we can't use it as a key as the polyfill tries
  25029. // to add a property to the object.
  25030. if ( true && !hasBadMapPolyfill) {
  25031. Object.freeze(eventResponder);
  25032. }
  25033. return eventResponder;
  25034. }
  25035. // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
  25036. // In some cases, StrictMode should also double-render lifecycles.
  25037. // This can be confusing for tests though,
  25038. // And it can be bad for performance in production.
  25039. // This feature flag can be used to control the behavior:
  25040. // To preserve the "Pause on caught exceptions" behavior of the debugger, we
  25041. // replay the begin phase of a failed component inside invokeGuardedCallback.
  25042. // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
  25043. // Gather advanced timing metrics for Profiler subtrees.
  25044. // Trace which interactions trigger each commit.
  25045. // Only used in www builds.
  25046. // TODO: true? Here it might just be false.
  25047. // Only used in www builds.
  25048. // Only used in www builds.
  25049. // Disable javascript: URL strings in href for XSS protection.
  25050. // React Fire: prevent the value and checked attributes from syncing
  25051. // with their related DOM properties
  25052. // These APIs will no longer be "unstable" in the upcoming 16.7 release,
  25053. // Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
  25054. // See https://github.com/react-native-community/discussions-and-proposals/issues/72 for more information
  25055. // This is a flag so we can fix warnings in RN core before turning it on
  25056. // Experimental React Flare event system and event components support.
  25057. var enableFlareAPI = false;
  25058. // Experimental Host Component support.
  25059. var enableFundamentalAPI = false;
  25060. // New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
  25061. var enableJSXTransformAPI = false;
  25062. // We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)
  25063. // Till then, we warn about the missing mock, but still fallback to a sync mode compatible version
  25064. // Temporary flag to revert the fix in #15650
  25065. // For tests, we flush suspense fallbacks in an act scope;
  25066. // *except* in some of our own tests, where we test incremental loading states.
  25067. // Changes priority of some events like mousemove to user-blocking priority,
  25068. // but without making them discrete. The flag exists in case it causes
  25069. // starvation problems.
  25070. // Add a callback property to suspense to notify which promises are currently
  25071. // in the update queue. This allows reporting and tracing of what is causing
  25072. // the user to see a loading state.
  25073. // Part of the simplification of React.createElement so we can eventually move
  25074. // from React.createElement to React.jsx
  25075. // https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
  25076. var React = {
  25077. Children: {
  25078. map: mapChildren,
  25079. forEach: forEachChildren,
  25080. count: countChildren,
  25081. toArray: toArray,
  25082. only: onlyChild
  25083. },
  25084. createRef: createRef,
  25085. Component: Component,
  25086. PureComponent: PureComponent,
  25087. createContext: createContext,
  25088. forwardRef: forwardRef,
  25089. lazy: lazy,
  25090. memo: memo,
  25091. useCallback: useCallback,
  25092. useContext: useContext,
  25093. useEffect: useEffect,
  25094. useImperativeHandle: useImperativeHandle,
  25095. useDebugValue: useDebugValue,
  25096. useLayoutEffect: useLayoutEffect,
  25097. useMemo: useMemo,
  25098. useReducer: useReducer,
  25099. useRef: useRef,
  25100. useState: useState,
  25101. Fragment: REACT_FRAGMENT_TYPE,
  25102. Profiler: REACT_PROFILER_TYPE,
  25103. StrictMode: REACT_STRICT_MODE_TYPE,
  25104. Suspense: REACT_SUSPENSE_TYPE,
  25105. unstable_SuspenseList: REACT_SUSPENSE_LIST_TYPE,
  25106. createElement: createElementWithValidation,
  25107. cloneElement: cloneElementWithValidation,
  25108. createFactory: createFactoryWithValidation,
  25109. isValidElement: isValidElement,
  25110. version: ReactVersion,
  25111. unstable_withSuspenseConfig: withSuspenseConfig,
  25112. __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals
  25113. };
  25114. if (enableFlareAPI) {
  25115. React.unstable_useResponder = useResponder;
  25116. React.unstable_createResponder = createEventResponder;
  25117. }
  25118. if (enableFundamentalAPI) {
  25119. React.unstable_createFundamental = createFundamentalComponent;
  25120. }
  25121. // Note: some APIs are added with feature flags.
  25122. // Make sure that stable builds for open source
  25123. // don't modify the React object to avoid deopts.
  25124. // Also let's not expose their names in stable builds.
  25125. if (enableJSXTransformAPI) {
  25126. {
  25127. React.jsxDEV = jsxWithValidation;
  25128. React.jsx = jsxWithValidationDynamic;
  25129. React.jsxs = jsxWithValidationStatic;
  25130. }
  25131. }
  25132. var React$2 = Object.freeze({
  25133. default: React
  25134. });
  25135. var React$3 = ( React$2 && React ) || React$2;
  25136. // TODO: decide on the top-level export form.
  25137. // This is hacky but makes it work with both Rollup and Jest.
  25138. var react = React$3.default || React$3;
  25139. module.exports = react;
  25140. })();
  25141. }
  25142. /***/ }),
  25143. /***/ "../../node_modules/react/index.js":
  25144. /*!*******************************************************!*\
  25145. !*** D:/Repos/Babylon.js/node_modules/react/index.js ***!
  25146. \*******************************************************/
  25147. /*! no static exports found */
  25148. /***/ (function(module, exports, __webpack_require__) {
  25149. "use strict";
  25150. if (false) {} else {
  25151. module.exports = __webpack_require__(/*! ./cjs/react.development.js */ "../../node_modules/react/cjs/react.development.js");
  25152. }
  25153. /***/ }),
  25154. /***/ "../../node_modules/scheduler/cjs/scheduler-tracing.development.js":
  25155. /*!***************************************************************************************!*\
  25156. !*** D:/Repos/Babylon.js/node_modules/scheduler/cjs/scheduler-tracing.development.js ***!
  25157. \***************************************************************************************/
  25158. /*! no static exports found */
  25159. /***/ (function(module, exports, __webpack_require__) {
  25160. "use strict";
  25161. /** @license React v0.15.0
  25162. * scheduler-tracing.development.js
  25163. *
  25164. * Copyright (c) Facebook, Inc. and its affiliates.
  25165. *
  25166. * This source code is licensed under the MIT license found in the
  25167. * LICENSE file in the root directory of this source tree.
  25168. */
  25169. if (true) {
  25170. (function() {
  25171. 'use strict';
  25172. Object.defineProperty(exports, '__esModule', { value: true });
  25173. // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
  25174. // In some cases, StrictMode should also double-render lifecycles.
  25175. // This can be confusing for tests though,
  25176. // And it can be bad for performance in production.
  25177. // This feature flag can be used to control the behavior:
  25178. // To preserve the "Pause on caught exceptions" behavior of the debugger, we
  25179. // replay the begin phase of a failed component inside invokeGuardedCallback.
  25180. // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
  25181. // Gather advanced timing metrics for Profiler subtrees.
  25182. // Trace which interactions trigger each commit.
  25183. var enableSchedulerTracing = true;
  25184. // Only used in www builds.
  25185. // TODO: true? Here it might just be false.
  25186. // Only used in www builds.
  25187. // Only used in www builds.
  25188. // Disable javascript: URL strings in href for XSS protection.
  25189. // React Fire: prevent the value and checked attributes from syncing
  25190. // with their related DOM properties
  25191. // These APIs will no longer be "unstable" in the upcoming 16.7 release,
  25192. // Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
  25193. // See https://github.com/react-native-community/discussions-and-proposals/issues/72 for more information
  25194. // This is a flag so we can fix warnings in RN core before turning it on
  25195. // Experimental React Flare event system and event components support.
  25196. // Experimental Host Component support.
  25197. // New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
  25198. // We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)
  25199. // Till then, we warn about the missing mock, but still fallback to a sync mode compatible version
  25200. // Temporary flag to revert the fix in #15650
  25201. // For tests, we flush suspense fallbacks in an act scope;
  25202. // *except* in some of our own tests, where we test incremental loading states.
  25203. // Changes priority of some events like mousemove to user-blocking priority,
  25204. // but without making them discrete. The flag exists in case it causes
  25205. // starvation problems.
  25206. // Add a callback property to suspense to notify which promises are currently
  25207. // in the update queue. This allows reporting and tracing of what is causing
  25208. // the user to see a loading state.
  25209. // Part of the simplification of React.createElement so we can eventually move
  25210. // from React.createElement to React.jsx
  25211. // https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
  25212. var DEFAULT_THREAD_ID = 0;
  25213. // Counters used to generate unique IDs.
  25214. var interactionIDCounter = 0;
  25215. var threadIDCounter = 0;
  25216. // Set of currently traced interactions.
  25217. // Interactions "stack"–
  25218. // Meaning that newly traced interactions are appended to the previously active set.
  25219. // When an interaction goes out of scope, the previous set (if any) is restored.
  25220. exports.__interactionsRef = null;
  25221. // Listener(s) to notify when interactions begin and end.
  25222. exports.__subscriberRef = null;
  25223. if (enableSchedulerTracing) {
  25224. exports.__interactionsRef = {
  25225. current: new Set()
  25226. };
  25227. exports.__subscriberRef = {
  25228. current: null
  25229. };
  25230. }
  25231. function unstable_clear(callback) {
  25232. if (!enableSchedulerTracing) {
  25233. return callback();
  25234. }
  25235. var prevInteractions = exports.__interactionsRef.current;
  25236. exports.__interactionsRef.current = new Set();
  25237. try {
  25238. return callback();
  25239. } finally {
  25240. exports.__interactionsRef.current = prevInteractions;
  25241. }
  25242. }
  25243. function unstable_getCurrent() {
  25244. if (!enableSchedulerTracing) {
  25245. return null;
  25246. } else {
  25247. return exports.__interactionsRef.current;
  25248. }
  25249. }
  25250. function unstable_getThreadID() {
  25251. return ++threadIDCounter;
  25252. }
  25253. function unstable_trace(name, timestamp, callback) {
  25254. var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID;
  25255. if (!enableSchedulerTracing) {
  25256. return callback();
  25257. }
  25258. var interaction = {
  25259. __count: 1,
  25260. id: interactionIDCounter++,
  25261. name: name,
  25262. timestamp: timestamp
  25263. };
  25264. var prevInteractions = exports.__interactionsRef.current;
  25265. // Traced interactions should stack/accumulate.
  25266. // To do that, clone the current interactions.
  25267. // The previous set will be restored upon completion.
  25268. var interactions = new Set(prevInteractions);
  25269. interactions.add(interaction);
  25270. exports.__interactionsRef.current = interactions;
  25271. var subscriber = exports.__subscriberRef.current;
  25272. var returnValue = void 0;
  25273. try {
  25274. if (subscriber !== null) {
  25275. subscriber.onInteractionTraced(interaction);
  25276. }
  25277. } finally {
  25278. try {
  25279. if (subscriber !== null) {
  25280. subscriber.onWorkStarted(interactions, threadID);
  25281. }
  25282. } finally {
  25283. try {
  25284. returnValue = callback();
  25285. } finally {
  25286. exports.__interactionsRef.current = prevInteractions;
  25287. try {
  25288. if (subscriber !== null) {
  25289. subscriber.onWorkStopped(interactions, threadID);
  25290. }
  25291. } finally {
  25292. interaction.__count--;
  25293. // If no async work was scheduled for this interaction,
  25294. // Notify subscribers that it's completed.
  25295. if (subscriber !== null && interaction.__count === 0) {
  25296. subscriber.onInteractionScheduledWorkCompleted(interaction);
  25297. }
  25298. }
  25299. }
  25300. }
  25301. }
  25302. return returnValue;
  25303. }
  25304. function unstable_wrap(callback) {
  25305. var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID;
  25306. if (!enableSchedulerTracing) {
  25307. return callback;
  25308. }
  25309. var wrappedInteractions = exports.__interactionsRef.current;
  25310. var subscriber = exports.__subscriberRef.current;
  25311. if (subscriber !== null) {
  25312. subscriber.onWorkScheduled(wrappedInteractions, threadID);
  25313. }
  25314. // Update the pending async work count for the current interactions.
  25315. // Update after calling subscribers in case of error.
  25316. wrappedInteractions.forEach(function (interaction) {
  25317. interaction.__count++;
  25318. });
  25319. var hasRun = false;
  25320. function wrapped() {
  25321. var prevInteractions = exports.__interactionsRef.current;
  25322. exports.__interactionsRef.current = wrappedInteractions;
  25323. subscriber = exports.__subscriberRef.current;
  25324. try {
  25325. var returnValue = void 0;
  25326. try {
  25327. if (subscriber !== null) {
  25328. subscriber.onWorkStarted(wrappedInteractions, threadID);
  25329. }
  25330. } finally {
  25331. try {
  25332. returnValue = callback.apply(undefined, arguments);
  25333. } finally {
  25334. exports.__interactionsRef.current = prevInteractions;
  25335. if (subscriber !== null) {
  25336. subscriber.onWorkStopped(wrappedInteractions, threadID);
  25337. }
  25338. }
  25339. }
  25340. return returnValue;
  25341. } finally {
  25342. if (!hasRun) {
  25343. // We only expect a wrapped function to be executed once,
  25344. // But in the event that it's executed more than once–
  25345. // Only decrement the outstanding interaction counts once.
  25346. hasRun = true;
  25347. // Update pending async counts for all wrapped interactions.
  25348. // If this was the last scheduled async work for any of them,
  25349. // Mark them as completed.
  25350. wrappedInteractions.forEach(function (interaction) {
  25351. interaction.__count--;
  25352. if (subscriber !== null && interaction.__count === 0) {
  25353. subscriber.onInteractionScheduledWorkCompleted(interaction);
  25354. }
  25355. });
  25356. }
  25357. }
  25358. }
  25359. wrapped.cancel = function cancel() {
  25360. subscriber = exports.__subscriberRef.current;
  25361. try {
  25362. if (subscriber !== null) {
  25363. subscriber.onWorkCanceled(wrappedInteractions, threadID);
  25364. }
  25365. } finally {
  25366. // Update pending async counts for all wrapped interactions.
  25367. // If this was the last scheduled async work for any of them,
  25368. // Mark them as completed.
  25369. wrappedInteractions.forEach(function (interaction) {
  25370. interaction.__count--;
  25371. if (subscriber && interaction.__count === 0) {
  25372. subscriber.onInteractionScheduledWorkCompleted(interaction);
  25373. }
  25374. });
  25375. }
  25376. };
  25377. return wrapped;
  25378. }
  25379. var subscribers = null;
  25380. if (enableSchedulerTracing) {
  25381. subscribers = new Set();
  25382. }
  25383. function unstable_subscribe(subscriber) {
  25384. if (enableSchedulerTracing) {
  25385. subscribers.add(subscriber);
  25386. if (subscribers.size === 1) {
  25387. exports.__subscriberRef.current = {
  25388. onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted,
  25389. onInteractionTraced: onInteractionTraced,
  25390. onWorkCanceled: onWorkCanceled,
  25391. onWorkScheduled: onWorkScheduled,
  25392. onWorkStarted: onWorkStarted,
  25393. onWorkStopped: onWorkStopped
  25394. };
  25395. }
  25396. }
  25397. }
  25398. function unstable_unsubscribe(subscriber) {
  25399. if (enableSchedulerTracing) {
  25400. subscribers.delete(subscriber);
  25401. if (subscribers.size === 0) {
  25402. exports.__subscriberRef.current = null;
  25403. }
  25404. }
  25405. }
  25406. function onInteractionTraced(interaction) {
  25407. var didCatchError = false;
  25408. var caughtError = null;
  25409. subscribers.forEach(function (subscriber) {
  25410. try {
  25411. subscriber.onInteractionTraced(interaction);
  25412. } catch (error) {
  25413. if (!didCatchError) {
  25414. didCatchError = true;
  25415. caughtError = error;
  25416. }
  25417. }
  25418. });
  25419. if (didCatchError) {
  25420. throw caughtError;
  25421. }
  25422. }
  25423. function onInteractionScheduledWorkCompleted(interaction) {
  25424. var didCatchError = false;
  25425. var caughtError = null;
  25426. subscribers.forEach(function (subscriber) {
  25427. try {
  25428. subscriber.onInteractionScheduledWorkCompleted(interaction);
  25429. } catch (error) {
  25430. if (!didCatchError) {
  25431. didCatchError = true;
  25432. caughtError = error;
  25433. }
  25434. }
  25435. });
  25436. if (didCatchError) {
  25437. throw caughtError;
  25438. }
  25439. }
  25440. function onWorkScheduled(interactions, threadID) {
  25441. var didCatchError = false;
  25442. var caughtError = null;
  25443. subscribers.forEach(function (subscriber) {
  25444. try {
  25445. subscriber.onWorkScheduled(interactions, threadID);
  25446. } catch (error) {
  25447. if (!didCatchError) {
  25448. didCatchError = true;
  25449. caughtError = error;
  25450. }
  25451. }
  25452. });
  25453. if (didCatchError) {
  25454. throw caughtError;
  25455. }
  25456. }
  25457. function onWorkStarted(interactions, threadID) {
  25458. var didCatchError = false;
  25459. var caughtError = null;
  25460. subscribers.forEach(function (subscriber) {
  25461. try {
  25462. subscriber.onWorkStarted(interactions, threadID);
  25463. } catch (error) {
  25464. if (!didCatchError) {
  25465. didCatchError = true;
  25466. caughtError = error;
  25467. }
  25468. }
  25469. });
  25470. if (didCatchError) {
  25471. throw caughtError;
  25472. }
  25473. }
  25474. function onWorkStopped(interactions, threadID) {
  25475. var didCatchError = false;
  25476. var caughtError = null;
  25477. subscribers.forEach(function (subscriber) {
  25478. try {
  25479. subscriber.onWorkStopped(interactions, threadID);
  25480. } catch (error) {
  25481. if (!didCatchError) {
  25482. didCatchError = true;
  25483. caughtError = error;
  25484. }
  25485. }
  25486. });
  25487. if (didCatchError) {
  25488. throw caughtError;
  25489. }
  25490. }
  25491. function onWorkCanceled(interactions, threadID) {
  25492. var didCatchError = false;
  25493. var caughtError = null;
  25494. subscribers.forEach(function (subscriber) {
  25495. try {
  25496. subscriber.onWorkCanceled(interactions, threadID);
  25497. } catch (error) {
  25498. if (!didCatchError) {
  25499. didCatchError = true;
  25500. caughtError = error;
  25501. }
  25502. }
  25503. });
  25504. if (didCatchError) {
  25505. throw caughtError;
  25506. }
  25507. }
  25508. exports.unstable_clear = unstable_clear;
  25509. exports.unstable_getCurrent = unstable_getCurrent;
  25510. exports.unstable_getThreadID = unstable_getThreadID;
  25511. exports.unstable_trace = unstable_trace;
  25512. exports.unstable_wrap = unstable_wrap;
  25513. exports.unstable_subscribe = unstable_subscribe;
  25514. exports.unstable_unsubscribe = unstable_unsubscribe;
  25515. })();
  25516. }
  25517. /***/ }),
  25518. /***/ "../../node_modules/scheduler/cjs/scheduler.development.js":
  25519. /*!*******************************************************************************!*\
  25520. !*** D:/Repos/Babylon.js/node_modules/scheduler/cjs/scheduler.development.js ***!
  25521. \*******************************************************************************/
  25522. /*! no static exports found */
  25523. /***/ (function(module, exports, __webpack_require__) {
  25524. "use strict";
  25525. /** @license React v0.15.0
  25526. * scheduler.development.js
  25527. *
  25528. * Copyright (c) Facebook, Inc. and its affiliates.
  25529. *
  25530. * This source code is licensed under the MIT license found in the
  25531. * LICENSE file in the root directory of this source tree.
  25532. */
  25533. if (true) {
  25534. (function() {
  25535. 'use strict';
  25536. Object.defineProperty(exports, '__esModule', { value: true });
  25537. var enableSchedulerDebugging = false;
  25538. var enableIsInputPending = false;
  25539. var requestIdleCallbackBeforeFirstFrame = false;
  25540. var requestTimerEventBeforeFirstFrame = false;
  25541. var enableMessageLoopImplementation = false;
  25542. // The DOM Scheduler implementation is similar to requestIdleCallback. It
  25543. // works by scheduling a requestAnimationFrame, storing the time for the start
  25544. // of the frame, then scheduling a postMessage which gets scheduled after paint.
  25545. // Within the postMessage handler do as much work as possible until time + frame
  25546. // rate. By separating the idle call into a separate event tick we ensure that
  25547. // layout, paint and other browser work is counted against the available time.
  25548. // The frame rate is dynamically adjusted.
  25549. var requestHostCallback = void 0;
  25550. var requestHostTimeout = void 0;
  25551. var cancelHostTimeout = void 0;
  25552. var shouldYieldToHost = void 0;
  25553. var requestPaint = void 0;
  25554. exports.unstable_now = void 0;
  25555. exports.unstable_forceFrameRate = void 0;
  25556. if (
  25557. // If Scheduler runs in a non-DOM environment, it falls back to a naive
  25558. // implementation using setTimeout.
  25559. typeof window === 'undefined' ||
  25560. // Check if MessageChannel is supported, too.
  25561. typeof MessageChannel !== 'function') {
  25562. // If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore,
  25563. // fallback to a naive implementation.
  25564. var _callback = null;
  25565. var _timeoutID = null;
  25566. var _flushCallback = function () {
  25567. if (_callback !== null) {
  25568. try {
  25569. var currentTime = exports.unstable_now();
  25570. var hasRemainingTime = true;
  25571. _callback(hasRemainingTime, currentTime);
  25572. _callback = null;
  25573. } catch (e) {
  25574. setTimeout(_flushCallback, 0);
  25575. throw e;
  25576. }
  25577. }
  25578. };
  25579. exports.unstable_now = function () {
  25580. return Date.now();
  25581. };
  25582. requestHostCallback = function (cb) {
  25583. if (_callback !== null) {
  25584. // Protect against re-entrancy.
  25585. setTimeout(requestHostCallback, 0, cb);
  25586. } else {
  25587. _callback = cb;
  25588. setTimeout(_flushCallback, 0);
  25589. }
  25590. };
  25591. requestHostTimeout = function (cb, ms) {
  25592. _timeoutID = setTimeout(cb, ms);
  25593. };
  25594. cancelHostTimeout = function () {
  25595. clearTimeout(_timeoutID);
  25596. };
  25597. shouldYieldToHost = function () {
  25598. return false;
  25599. };
  25600. requestPaint = exports.unstable_forceFrameRate = function () {};
  25601. } else {
  25602. // Capture local references to native APIs, in case a polyfill overrides them.
  25603. var performance = window.performance;
  25604. var _Date = window.Date;
  25605. var _setTimeout = window.setTimeout;
  25606. var _clearTimeout = window.clearTimeout;
  25607. var requestAnimationFrame = window.requestAnimationFrame;
  25608. var cancelAnimationFrame = window.cancelAnimationFrame;
  25609. var requestIdleCallback = window.requestIdleCallback;
  25610. if (typeof console !== 'undefined') {
  25611. // TODO: Remove fb.me link
  25612. if (typeof requestAnimationFrame !== 'function') {
  25613. console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
  25614. }
  25615. if (typeof cancelAnimationFrame !== 'function') {
  25616. console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
  25617. }
  25618. }
  25619. var requestIdleCallbackBeforeFirstFrame$1 = requestIdleCallbackBeforeFirstFrame && typeof requestIdleCallback === 'function' && typeof cancelIdleCallback === 'function';
  25620. exports.unstable_now = typeof performance === 'object' && typeof performance.now === 'function' ? function () {
  25621. return performance.now();
  25622. } : function () {
  25623. return _Date.now();
  25624. };
  25625. var isRAFLoopRunning = false;
  25626. var isMessageLoopRunning = false;
  25627. var scheduledHostCallback = null;
  25628. var rAFTimeoutID = -1;
  25629. var taskTimeoutID = -1;
  25630. var frameLength = enableMessageLoopImplementation ? // We won't attempt to align with the vsync. Instead we'll yield multiple
  25631. // times per frame, often enough to keep it responsive even at really
  25632. // high frame rates > 120.
  25633. 5 : // Use a heuristic to measure the frame rate and yield at the end of the
  25634. // frame. We start out assuming that we run at 30fps but then the
  25635. // heuristic tracking will adjust this value to a faster fps if we get
  25636. // more frequent animation frames.
  25637. 33.33;
  25638. var prevRAFTime = -1;
  25639. var prevRAFInterval = -1;
  25640. var frameDeadline = 0;
  25641. var fpsLocked = false;
  25642. // TODO: Make this configurable
  25643. // TODO: Adjust this based on priority?
  25644. var maxFrameLength = 300;
  25645. var needsPaint = false;
  25646. if (enableIsInputPending && navigator !== undefined && navigator.scheduling !== undefined && navigator.scheduling.isInputPending !== undefined) {
  25647. var scheduling = navigator.scheduling;
  25648. shouldYieldToHost = function () {
  25649. var currentTime = exports.unstable_now();
  25650. if (currentTime >= frameDeadline) {
  25651. // There's no time left in the frame. We may want to yield control of
  25652. // the main thread, so the browser can perform high priority tasks. The
  25653. // main ones are painting and user input. If there's a pending paint or
  25654. // a pending input, then we should yield. But if there's neither, then
  25655. // we can yield less often while remaining responsive. We'll eventually
  25656. // yield regardless, since there could be a pending paint that wasn't
  25657. // accompanied by a call to `requestPaint`, or other main thread tasks
  25658. // like network events.
  25659. if (needsPaint || scheduling.isInputPending()) {
  25660. // There is either a pending paint or a pending input.
  25661. return true;
  25662. }
  25663. // There's no pending input. Only yield if we've reached the max
  25664. // frame length.
  25665. return currentTime >= frameDeadline + maxFrameLength;
  25666. } else {
  25667. // There's still time left in the frame.
  25668. return false;
  25669. }
  25670. };
  25671. requestPaint = function () {
  25672. needsPaint = true;
  25673. };
  25674. } else {
  25675. // `isInputPending` is not available. Since we have no way of knowing if
  25676. // there's pending input, always yield at the end of the frame.
  25677. shouldYieldToHost = function () {
  25678. return exports.unstable_now() >= frameDeadline;
  25679. };
  25680. // Since we yield every frame regardless, `requestPaint` has no effect.
  25681. requestPaint = function () {};
  25682. }
  25683. exports.unstable_forceFrameRate = function (fps) {
  25684. if (fps < 0 || fps > 125) {
  25685. console.error('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing framerates higher than 125 fps is not unsupported');
  25686. return;
  25687. }
  25688. if (fps > 0) {
  25689. frameLength = Math.floor(1000 / fps);
  25690. fpsLocked = true;
  25691. } else {
  25692. // reset the framerate
  25693. frameLength = 33.33;
  25694. fpsLocked = false;
  25695. }
  25696. };
  25697. var performWorkUntilDeadline = function () {
  25698. if (enableMessageLoopImplementation) {
  25699. if (scheduledHostCallback !== null) {
  25700. var currentTime = exports.unstable_now();
  25701. // Yield after `frameLength` ms, regardless of where we are in the vsync
  25702. // cycle. This means there's always time remaining at the beginning of
  25703. // the message event.
  25704. frameDeadline = currentTime + frameLength;
  25705. var hasTimeRemaining = true;
  25706. try {
  25707. var hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);
  25708. if (!hasMoreWork) {
  25709. isMessageLoopRunning = false;
  25710. scheduledHostCallback = null;
  25711. } else {
  25712. // If there's more work, schedule the next message event at the end
  25713. // of the preceding one.
  25714. port.postMessage(null);
  25715. }
  25716. } catch (error) {
  25717. // If a scheduler task throws, exit the current browser task so the
  25718. // error can be observed.
  25719. port.postMessage(null);
  25720. throw error;
  25721. }
  25722. }
  25723. // Yielding to the browser will give it a chance to paint, so we can
  25724. // reset this.
  25725. needsPaint = false;
  25726. } else {
  25727. if (scheduledHostCallback !== null) {
  25728. var _currentTime = exports.unstable_now();
  25729. var _hasTimeRemaining = frameDeadline - _currentTime > 0;
  25730. try {
  25731. var _hasMoreWork = scheduledHostCallback(_hasTimeRemaining, _currentTime);
  25732. if (!_hasMoreWork) {
  25733. scheduledHostCallback = null;
  25734. }
  25735. } catch (error) {
  25736. // If a scheduler task throws, exit the current browser task so the
  25737. // error can be observed, and post a new task as soon as possible
  25738. // so we can continue where we left off.
  25739. port.postMessage(null);
  25740. throw error;
  25741. }
  25742. }
  25743. // Yielding to the browser will give it a chance to paint, so we can
  25744. // reset this.
  25745. needsPaint = false;
  25746. }
  25747. };
  25748. var channel = new MessageChannel();
  25749. var port = channel.port2;
  25750. channel.port1.onmessage = performWorkUntilDeadline;
  25751. var onAnimationFrame = function (rAFTime) {
  25752. if (scheduledHostCallback === null) {
  25753. // No scheduled work. Exit.
  25754. prevRAFTime = -1;
  25755. prevRAFInterval = -1;
  25756. isRAFLoopRunning = false;
  25757. return;
  25758. }
  25759. // Eagerly schedule the next animation callback at the beginning of the
  25760. // frame. If the scheduler queue is not empty at the end of the frame, it
  25761. // will continue flushing inside that callback. If the queue *is* empty,
  25762. // then it will exit immediately. Posting the callback at the start of the
  25763. // frame ensures it's fired within the earliest possible frame. If we
  25764. // waited until the end of the frame to post the callback, we risk the
  25765. // browser skipping a frame and not firing the callback until the frame
  25766. // after that.
  25767. isRAFLoopRunning = true;
  25768. requestAnimationFrame(function (nextRAFTime) {
  25769. _clearTimeout(rAFTimeoutID);
  25770. onAnimationFrame(nextRAFTime);
  25771. });
  25772. // requestAnimationFrame is throttled when the tab is backgrounded. We
  25773. // don't want to stop working entirely. So we'll fallback to a timeout loop.
  25774. // TODO: Need a better heuristic for backgrounded work.
  25775. var onTimeout = function () {
  25776. frameDeadline = exports.unstable_now() + frameLength / 2;
  25777. performWorkUntilDeadline();
  25778. rAFTimeoutID = _setTimeout(onTimeout, frameLength * 3);
  25779. };
  25780. rAFTimeoutID = _setTimeout(onTimeout, frameLength * 3);
  25781. if (prevRAFTime !== -1 &&
  25782. // Make sure this rAF time is different from the previous one. This check
  25783. // could fail if two rAFs fire in the same frame.
  25784. rAFTime - prevRAFTime > 0.1) {
  25785. var rAFInterval = rAFTime - prevRAFTime;
  25786. if (!fpsLocked && prevRAFInterval !== -1) {
  25787. // We've observed two consecutive frame intervals. We'll use this to
  25788. // dynamically adjust the frame rate.
  25789. //
  25790. // If one frame goes long, then the next one can be short to catch up.
  25791. // If two frames are short in a row, then that's an indication that we
  25792. // actually have a higher frame rate than what we're currently
  25793. // optimizing. For example, if we're running on 120hz display or 90hz VR
  25794. // display. Take the max of the two in case one of them was an anomaly
  25795. // due to missed frame deadlines.
  25796. if (rAFInterval < frameLength && prevRAFInterval < frameLength) {
  25797. frameLength = rAFInterval < prevRAFInterval ? prevRAFInterval : rAFInterval;
  25798. if (frameLength < 8.33) {
  25799. // Defensive coding. We don't support higher frame rates than 120hz.
  25800. // If the calculated frame length gets lower than 8, it is probably
  25801. // a bug.
  25802. frameLength = 8.33;
  25803. }
  25804. }
  25805. }
  25806. prevRAFInterval = rAFInterval;
  25807. }
  25808. prevRAFTime = rAFTime;
  25809. frameDeadline = rAFTime + frameLength;
  25810. // We use the postMessage trick to defer idle work until after the repaint.
  25811. port.postMessage(null);
  25812. };
  25813. requestHostCallback = function (callback) {
  25814. scheduledHostCallback = callback;
  25815. if (enableMessageLoopImplementation) {
  25816. if (!isMessageLoopRunning) {
  25817. isMessageLoopRunning = true;
  25818. port.postMessage(null);
  25819. }
  25820. } else {
  25821. if (!isRAFLoopRunning) {
  25822. // Start a rAF loop.
  25823. isRAFLoopRunning = true;
  25824. requestAnimationFrame(function (rAFTime) {
  25825. if (requestIdleCallbackBeforeFirstFrame$1) {
  25826. cancelIdleCallback(idleCallbackID);
  25827. }
  25828. if (requestTimerEventBeforeFirstFrame) {
  25829. _clearTimeout(idleTimeoutID);
  25830. }
  25831. onAnimationFrame(rAFTime);
  25832. });
  25833. // If we just missed the last vsync, the next rAF might not happen for
  25834. // another frame. To claim as much idle time as possible, post a
  25835. // callback with `requestIdleCallback`, which should fire if there's
  25836. // idle time left in the frame.
  25837. //
  25838. // This should only be an issue for the first rAF in the loop;
  25839. // subsequent rAFs are scheduled at the beginning of the
  25840. // preceding frame.
  25841. var idleCallbackID = void 0;
  25842. if (requestIdleCallbackBeforeFirstFrame$1) {
  25843. idleCallbackID = requestIdleCallback(function onIdleCallbackBeforeFirstFrame() {
  25844. if (requestTimerEventBeforeFirstFrame) {
  25845. _clearTimeout(idleTimeoutID);
  25846. }
  25847. frameDeadline = exports.unstable_now() + frameLength;
  25848. performWorkUntilDeadline();
  25849. });
  25850. }
  25851. // Alternate strategy to address the same problem. Scheduler a timer
  25852. // with no delay. If this fires before the rAF, that likely indicates
  25853. // that there's idle time before the next vsync. This isn't always the
  25854. // case, but we'll be aggressive and assume it is, as a trade off to
  25855. // prevent idle periods.
  25856. var idleTimeoutID = void 0;
  25857. if (requestTimerEventBeforeFirstFrame) {
  25858. idleTimeoutID = _setTimeout(function onTimerEventBeforeFirstFrame() {
  25859. if (requestIdleCallbackBeforeFirstFrame$1) {
  25860. cancelIdleCallback(idleCallbackID);
  25861. }
  25862. frameDeadline = exports.unstable_now() + frameLength;
  25863. performWorkUntilDeadline();
  25864. }, 0);
  25865. }
  25866. }
  25867. }
  25868. };
  25869. requestHostTimeout = function (callback, ms) {
  25870. taskTimeoutID = _setTimeout(function () {
  25871. callback(exports.unstable_now());
  25872. }, ms);
  25873. };
  25874. cancelHostTimeout = function () {
  25875. _clearTimeout(taskTimeoutID);
  25876. taskTimeoutID = -1;
  25877. };
  25878. }
  25879. /* eslint-disable no-var */
  25880. // TODO: Use symbols?
  25881. var ImmediatePriority = 1;
  25882. var UserBlockingPriority = 2;
  25883. var NormalPriority = 3;
  25884. var LowPriority = 4;
  25885. var IdlePriority = 5;
  25886. // Max 31 bit integer. The max integer size in V8 for 32-bit systems.
  25887. // Math.pow(2, 30) - 1
  25888. // 0b111111111111111111111111111111
  25889. var maxSigned31BitInt = 1073741823;
  25890. // Times out immediately
  25891. var IMMEDIATE_PRIORITY_TIMEOUT = -1;
  25892. // Eventually times out
  25893. var USER_BLOCKING_PRIORITY = 250;
  25894. var NORMAL_PRIORITY_TIMEOUT = 5000;
  25895. var LOW_PRIORITY_TIMEOUT = 10000;
  25896. // Never times out
  25897. var IDLE_PRIORITY = maxSigned31BitInt;
  25898. // Tasks are stored as a circular, doubly linked list.
  25899. var firstTask = null;
  25900. var firstDelayedTask = null;
  25901. // Pausing the scheduler is useful for debugging.
  25902. var isSchedulerPaused = false;
  25903. var currentTask = null;
  25904. var currentPriorityLevel = NormalPriority;
  25905. // This is set while performing work, to prevent re-entrancy.
  25906. var isPerformingWork = false;
  25907. var isHostCallbackScheduled = false;
  25908. var isHostTimeoutScheduled = false;
  25909. function scheduler_flushTaskAtPriority_Immediate(callback, didTimeout) {
  25910. return callback(didTimeout);
  25911. }
  25912. function scheduler_flushTaskAtPriority_UserBlocking(callback, didTimeout) {
  25913. return callback(didTimeout);
  25914. }
  25915. function scheduler_flushTaskAtPriority_Normal(callback, didTimeout) {
  25916. return callback(didTimeout);
  25917. }
  25918. function scheduler_flushTaskAtPriority_Low(callback, didTimeout) {
  25919. return callback(didTimeout);
  25920. }
  25921. function scheduler_flushTaskAtPriority_Idle(callback, didTimeout) {
  25922. return callback(didTimeout);
  25923. }
  25924. function flushTask(task, currentTime) {
  25925. // Remove the task from the list before calling the callback. That way the
  25926. // list is in a consistent state even if the callback throws.
  25927. var next = task.next;
  25928. if (next === task) {
  25929. // This is the only scheduled task. Clear the list.
  25930. firstTask = null;
  25931. } else {
  25932. // Remove the task from its position in the list.
  25933. if (task === firstTask) {
  25934. firstTask = next;
  25935. }
  25936. var previous = task.previous;
  25937. previous.next = next;
  25938. next.previous = previous;
  25939. }
  25940. task.next = task.previous = null;
  25941. // Now it's safe to execute the task.
  25942. var callback = task.callback;
  25943. var previousPriorityLevel = currentPriorityLevel;
  25944. var previousTask = currentTask;
  25945. currentPriorityLevel = task.priorityLevel;
  25946. currentTask = task;
  25947. var continuationCallback;
  25948. try {
  25949. var didUserCallbackTimeout = task.expirationTime <= currentTime;
  25950. // Add an extra function to the callstack. Profiling tools can use this
  25951. // to infer the priority of work that appears higher in the stack.
  25952. switch (currentPriorityLevel) {
  25953. case ImmediatePriority:
  25954. continuationCallback = scheduler_flushTaskAtPriority_Immediate(callback, didUserCallbackTimeout);
  25955. break;
  25956. case UserBlockingPriority:
  25957. continuationCallback = scheduler_flushTaskAtPriority_UserBlocking(callback, didUserCallbackTimeout);
  25958. break;
  25959. case NormalPriority:
  25960. continuationCallback = scheduler_flushTaskAtPriority_Normal(callback, didUserCallbackTimeout);
  25961. break;
  25962. case LowPriority:
  25963. continuationCallback = scheduler_flushTaskAtPriority_Low(callback, didUserCallbackTimeout);
  25964. break;
  25965. case IdlePriority:
  25966. continuationCallback = scheduler_flushTaskAtPriority_Idle(callback, didUserCallbackTimeout);
  25967. break;
  25968. }
  25969. } catch (error) {
  25970. throw error;
  25971. } finally {
  25972. currentPriorityLevel = previousPriorityLevel;
  25973. currentTask = previousTask;
  25974. }
  25975. // A callback may return a continuation. The continuation should be scheduled
  25976. // with the same priority and expiration as the just-finished callback.
  25977. if (typeof continuationCallback === 'function') {
  25978. var expirationTime = task.expirationTime;
  25979. var continuationTask = task;
  25980. continuationTask.callback = continuationCallback;
  25981. // Insert the new callback into the list, sorted by its timeout. This is
  25982. // almost the same as the code in `scheduleCallback`, except the callback
  25983. // is inserted into the list *before* callbacks of equal timeout instead
  25984. // of after.
  25985. if (firstTask === null) {
  25986. // This is the first callback in the list.
  25987. firstTask = continuationTask.next = continuationTask.previous = continuationTask;
  25988. } else {
  25989. var nextAfterContinuation = null;
  25990. var t = firstTask;
  25991. do {
  25992. if (expirationTime <= t.expirationTime) {
  25993. // This task times out at or after the continuation. We will insert
  25994. // the continuation *before* this task.
  25995. nextAfterContinuation = t;
  25996. break;
  25997. }
  25998. t = t.next;
  25999. } while (t !== firstTask);
  26000. if (nextAfterContinuation === null) {
  26001. // No equal or lower priority task was found, which means the new task
  26002. // is the lowest priority task in the list.
  26003. nextAfterContinuation = firstTask;
  26004. } else if (nextAfterContinuation === firstTask) {
  26005. // The new task is the highest priority task in the list.
  26006. firstTask = continuationTask;
  26007. }
  26008. var _previous = nextAfterContinuation.previous;
  26009. _previous.next = nextAfterContinuation.previous = continuationTask;
  26010. continuationTask.next = nextAfterContinuation;
  26011. continuationTask.previous = _previous;
  26012. }
  26013. }
  26014. }
  26015. function advanceTimers(currentTime) {
  26016. // Check for tasks that are no longer delayed and add them to the queue.
  26017. if (firstDelayedTask !== null && firstDelayedTask.startTime <= currentTime) {
  26018. do {
  26019. var task = firstDelayedTask;
  26020. var next = task.next;
  26021. if (task === next) {
  26022. firstDelayedTask = null;
  26023. } else {
  26024. firstDelayedTask = next;
  26025. var previous = task.previous;
  26026. previous.next = next;
  26027. next.previous = previous;
  26028. }
  26029. task.next = task.previous = null;
  26030. insertScheduledTask(task, task.expirationTime);
  26031. } while (firstDelayedTask !== null && firstDelayedTask.startTime <= currentTime);
  26032. }
  26033. }
  26034. function handleTimeout(currentTime) {
  26035. isHostTimeoutScheduled = false;
  26036. advanceTimers(currentTime);
  26037. if (!isHostCallbackScheduled) {
  26038. if (firstTask !== null) {
  26039. isHostCallbackScheduled = true;
  26040. requestHostCallback(flushWork);
  26041. } else if (firstDelayedTask !== null) {
  26042. requestHostTimeout(handleTimeout, firstDelayedTask.startTime - currentTime);
  26043. }
  26044. }
  26045. }
  26046. function flushWork(hasTimeRemaining, initialTime) {
  26047. // Exit right away if we're currently paused
  26048. if (enableSchedulerDebugging && isSchedulerPaused) {
  26049. return;
  26050. }
  26051. // We'll need a host callback the next time work is scheduled.
  26052. isHostCallbackScheduled = false;
  26053. if (isHostTimeoutScheduled) {
  26054. // We scheduled a timeout but it's no longer needed. Cancel it.
  26055. isHostTimeoutScheduled = false;
  26056. cancelHostTimeout();
  26057. }
  26058. var currentTime = initialTime;
  26059. advanceTimers(currentTime);
  26060. isPerformingWork = true;
  26061. try {
  26062. if (!hasTimeRemaining) {
  26063. // Flush all the expired callbacks without yielding.
  26064. // TODO: Split flushWork into two separate functions instead of using
  26065. // a boolean argument?
  26066. while (firstTask !== null && firstTask.expirationTime <= currentTime && !(enableSchedulerDebugging && isSchedulerPaused)) {
  26067. flushTask(firstTask, currentTime);
  26068. currentTime = exports.unstable_now();
  26069. advanceTimers(currentTime);
  26070. }
  26071. } else {
  26072. // Keep flushing callbacks until we run out of time in the frame.
  26073. if (firstTask !== null) {
  26074. do {
  26075. flushTask(firstTask, currentTime);
  26076. currentTime = exports.unstable_now();
  26077. advanceTimers(currentTime);
  26078. } while (firstTask !== null && !shouldYieldToHost() && !(enableSchedulerDebugging && isSchedulerPaused));
  26079. }
  26080. }
  26081. // Return whether there's additional work
  26082. if (firstTask !== null) {
  26083. return true;
  26084. } else {
  26085. if (firstDelayedTask !== null) {
  26086. requestHostTimeout(handleTimeout, firstDelayedTask.startTime - currentTime);
  26087. }
  26088. return false;
  26089. }
  26090. } finally {
  26091. isPerformingWork = false;
  26092. }
  26093. }
  26094. function unstable_runWithPriority(priorityLevel, eventHandler) {
  26095. switch (priorityLevel) {
  26096. case ImmediatePriority:
  26097. case UserBlockingPriority:
  26098. case NormalPriority:
  26099. case LowPriority:
  26100. case IdlePriority:
  26101. break;
  26102. default:
  26103. priorityLevel = NormalPriority;
  26104. }
  26105. var previousPriorityLevel = currentPriorityLevel;
  26106. currentPriorityLevel = priorityLevel;
  26107. try {
  26108. return eventHandler();
  26109. } finally {
  26110. currentPriorityLevel = previousPriorityLevel;
  26111. }
  26112. }
  26113. function unstable_next(eventHandler) {
  26114. var priorityLevel;
  26115. switch (currentPriorityLevel) {
  26116. case ImmediatePriority:
  26117. case UserBlockingPriority:
  26118. case NormalPriority:
  26119. // Shift down to normal priority
  26120. priorityLevel = NormalPriority;
  26121. break;
  26122. default:
  26123. // Anything lower than normal priority should remain at the current level.
  26124. priorityLevel = currentPriorityLevel;
  26125. break;
  26126. }
  26127. var previousPriorityLevel = currentPriorityLevel;
  26128. currentPriorityLevel = priorityLevel;
  26129. try {
  26130. return eventHandler();
  26131. } finally {
  26132. currentPriorityLevel = previousPriorityLevel;
  26133. }
  26134. }
  26135. function unstable_wrapCallback(callback) {
  26136. var parentPriorityLevel = currentPriorityLevel;
  26137. return function () {
  26138. // This is a fork of runWithPriority, inlined for performance.
  26139. var previousPriorityLevel = currentPriorityLevel;
  26140. currentPriorityLevel = parentPriorityLevel;
  26141. try {
  26142. return callback.apply(this, arguments);
  26143. } finally {
  26144. currentPriorityLevel = previousPriorityLevel;
  26145. }
  26146. };
  26147. }
  26148. function timeoutForPriorityLevel(priorityLevel) {
  26149. switch (priorityLevel) {
  26150. case ImmediatePriority:
  26151. return IMMEDIATE_PRIORITY_TIMEOUT;
  26152. case UserBlockingPriority:
  26153. return USER_BLOCKING_PRIORITY;
  26154. case IdlePriority:
  26155. return IDLE_PRIORITY;
  26156. case LowPriority:
  26157. return LOW_PRIORITY_TIMEOUT;
  26158. case NormalPriority:
  26159. default:
  26160. return NORMAL_PRIORITY_TIMEOUT;
  26161. }
  26162. }
  26163. function unstable_scheduleCallback(priorityLevel, callback, options) {
  26164. var currentTime = exports.unstable_now();
  26165. var startTime;
  26166. var timeout;
  26167. if (typeof options === 'object' && options !== null) {
  26168. var delay = options.delay;
  26169. if (typeof delay === 'number' && delay > 0) {
  26170. startTime = currentTime + delay;
  26171. } else {
  26172. startTime = currentTime;
  26173. }
  26174. timeout = typeof options.timeout === 'number' ? options.timeout : timeoutForPriorityLevel(priorityLevel);
  26175. } else {
  26176. timeout = timeoutForPriorityLevel(priorityLevel);
  26177. startTime = currentTime;
  26178. }
  26179. var expirationTime = startTime + timeout;
  26180. var newTask = {
  26181. callback: callback,
  26182. priorityLevel: priorityLevel,
  26183. startTime: startTime,
  26184. expirationTime: expirationTime,
  26185. next: null,
  26186. previous: null
  26187. };
  26188. if (startTime > currentTime) {
  26189. // This is a delayed task.
  26190. insertDelayedTask(newTask, startTime);
  26191. if (firstTask === null && firstDelayedTask === newTask) {
  26192. // All tasks are delayed, and this is the task with the earliest delay.
  26193. if (isHostTimeoutScheduled) {
  26194. // Cancel an existing timeout.
  26195. cancelHostTimeout();
  26196. } else {
  26197. isHostTimeoutScheduled = true;
  26198. }
  26199. // Schedule a timeout.
  26200. requestHostTimeout(handleTimeout, startTime - currentTime);
  26201. }
  26202. } else {
  26203. insertScheduledTask(newTask, expirationTime);
  26204. // Schedule a host callback, if needed. If we're already performing work,
  26205. // wait until the next time we yield.
  26206. if (!isHostCallbackScheduled && !isPerformingWork) {
  26207. isHostCallbackScheduled = true;
  26208. requestHostCallback(flushWork);
  26209. }
  26210. }
  26211. return newTask;
  26212. }
  26213. function insertScheduledTask(newTask, expirationTime) {
  26214. // Insert the new task into the list, ordered first by its timeout, then by
  26215. // insertion. So the new task is inserted after any other task the
  26216. // same timeout
  26217. if (firstTask === null) {
  26218. // This is the first task in the list.
  26219. firstTask = newTask.next = newTask.previous = newTask;
  26220. } else {
  26221. var next = null;
  26222. var task = firstTask;
  26223. do {
  26224. if (expirationTime < task.expirationTime) {
  26225. // The new task times out before this one.
  26226. next = task;
  26227. break;
  26228. }
  26229. task = task.next;
  26230. } while (task !== firstTask);
  26231. if (next === null) {
  26232. // No task with a later timeout was found, which means the new task has
  26233. // the latest timeout in the list.
  26234. next = firstTask;
  26235. } else if (next === firstTask) {
  26236. // The new task has the earliest expiration in the entire list.
  26237. firstTask = newTask;
  26238. }
  26239. var previous = next.previous;
  26240. previous.next = next.previous = newTask;
  26241. newTask.next = next;
  26242. newTask.previous = previous;
  26243. }
  26244. }
  26245. function insertDelayedTask(newTask, startTime) {
  26246. // Insert the new task into the list, ordered by its start time.
  26247. if (firstDelayedTask === null) {
  26248. // This is the first task in the list.
  26249. firstDelayedTask = newTask.next = newTask.previous = newTask;
  26250. } else {
  26251. var next = null;
  26252. var task = firstDelayedTask;
  26253. do {
  26254. if (startTime < task.startTime) {
  26255. // The new task times out before this one.
  26256. next = task;
  26257. break;
  26258. }
  26259. task = task.next;
  26260. } while (task !== firstDelayedTask);
  26261. if (next === null) {
  26262. // No task with a later timeout was found, which means the new task has
  26263. // the latest timeout in the list.
  26264. next = firstDelayedTask;
  26265. } else if (next === firstDelayedTask) {
  26266. // The new task has the earliest expiration in the entire list.
  26267. firstDelayedTask = newTask;
  26268. }
  26269. var previous = next.previous;
  26270. previous.next = next.previous = newTask;
  26271. newTask.next = next;
  26272. newTask.previous = previous;
  26273. }
  26274. }
  26275. function unstable_pauseExecution() {
  26276. isSchedulerPaused = true;
  26277. }
  26278. function unstable_continueExecution() {
  26279. isSchedulerPaused = false;
  26280. if (!isHostCallbackScheduled && !isPerformingWork) {
  26281. isHostCallbackScheduled = true;
  26282. requestHostCallback(flushWork);
  26283. }
  26284. }
  26285. function unstable_getFirstCallbackNode() {
  26286. return firstTask;
  26287. }
  26288. function unstable_cancelCallback(task) {
  26289. var next = task.next;
  26290. if (next === null) {
  26291. // Already cancelled.
  26292. return;
  26293. }
  26294. if (task === next) {
  26295. if (task === firstTask) {
  26296. firstTask = null;
  26297. } else if (task === firstDelayedTask) {
  26298. firstDelayedTask = null;
  26299. }
  26300. } else {
  26301. if (task === firstTask) {
  26302. firstTask = next;
  26303. } else if (task === firstDelayedTask) {
  26304. firstDelayedTask = next;
  26305. }
  26306. var previous = task.previous;
  26307. previous.next = next;
  26308. next.previous = previous;
  26309. }
  26310. task.next = task.previous = null;
  26311. }
  26312. function unstable_getCurrentPriorityLevel() {
  26313. return currentPriorityLevel;
  26314. }
  26315. function unstable_shouldYield() {
  26316. var currentTime = exports.unstable_now();
  26317. advanceTimers(currentTime);
  26318. return currentTask !== null && firstTask !== null && firstTask.startTime <= currentTime && firstTask.expirationTime < currentTask.expirationTime || shouldYieldToHost();
  26319. }
  26320. var unstable_requestPaint = requestPaint;
  26321. exports.unstable_ImmediatePriority = ImmediatePriority;
  26322. exports.unstable_UserBlockingPriority = UserBlockingPriority;
  26323. exports.unstable_NormalPriority = NormalPriority;
  26324. exports.unstable_IdlePriority = IdlePriority;
  26325. exports.unstable_LowPriority = LowPriority;
  26326. exports.unstable_runWithPriority = unstable_runWithPriority;
  26327. exports.unstable_next = unstable_next;
  26328. exports.unstable_scheduleCallback = unstable_scheduleCallback;
  26329. exports.unstable_cancelCallback = unstable_cancelCallback;
  26330. exports.unstable_wrapCallback = unstable_wrapCallback;
  26331. exports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel;
  26332. exports.unstable_shouldYield = unstable_shouldYield;
  26333. exports.unstable_requestPaint = unstable_requestPaint;
  26334. exports.unstable_continueExecution = unstable_continueExecution;
  26335. exports.unstable_pauseExecution = unstable_pauseExecution;
  26336. exports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode;
  26337. })();
  26338. }
  26339. /***/ }),
  26340. /***/ "../../node_modules/scheduler/index.js":
  26341. /*!***********************************************************!*\
  26342. !*** D:/Repos/Babylon.js/node_modules/scheduler/index.js ***!
  26343. \***********************************************************/
  26344. /*! no static exports found */
  26345. /***/ (function(module, exports, __webpack_require__) {
  26346. "use strict";
  26347. if (false) {} else {
  26348. module.exports = __webpack_require__(/*! ./cjs/scheduler.development.js */ "../../node_modules/scheduler/cjs/scheduler.development.js");
  26349. }
  26350. /***/ }),
  26351. /***/ "../../node_modules/scheduler/tracing.js":
  26352. /*!*************************************************************!*\
  26353. !*** D:/Repos/Babylon.js/node_modules/scheduler/tracing.js ***!
  26354. \*************************************************************/
  26355. /*! no static exports found */
  26356. /***/ (function(module, exports, __webpack_require__) {
  26357. "use strict";
  26358. if (false) {} else {
  26359. module.exports = __webpack_require__(/*! ./cjs/scheduler-tracing.development.js */ "../../node_modules/scheduler/cjs/scheduler-tracing.development.js");
  26360. }
  26361. /***/ }),
  26362. /***/ "../../node_modules/style-loader/lib/addStyles.js":
  26363. /*!**********************************************************************!*\
  26364. !*** D:/Repos/Babylon.js/node_modules/style-loader/lib/addStyles.js ***!
  26365. \**********************************************************************/
  26366. /*! no static exports found */
  26367. /***/ (function(module, exports, __webpack_require__) {
  26368. /*
  26369. MIT License http://www.opensource.org/licenses/mit-license.php
  26370. Author Tobias Koppers @sokra
  26371. */
  26372. var stylesInDom = {};
  26373. var memoize = function (fn) {
  26374. var memo;
  26375. return function () {
  26376. if (typeof memo === "undefined") memo = fn.apply(this, arguments);
  26377. return memo;
  26378. };
  26379. };
  26380. var isOldIE = memoize(function () {
  26381. // Test for IE <= 9 as proposed by Browserhacks
  26382. // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
  26383. // Tests for existence of standard globals is to allow style-loader
  26384. // to operate correctly into non-standard environments
  26385. // @see https://github.com/webpack-contrib/style-loader/issues/177
  26386. return window && document && document.all && !window.atob;
  26387. });
  26388. var getTarget = function (target) {
  26389. return document.querySelector(target);
  26390. };
  26391. var getElement = (function (fn) {
  26392. var memo = {};
  26393. return function(target) {
  26394. // If passing function in options, then use it for resolve "head" element.
  26395. // Useful for Shadow Root style i.e
  26396. // {
  26397. // insertInto: function () { return document.querySelector("#foo").shadowRoot }
  26398. // }
  26399. if (typeof target === 'function') {
  26400. return target();
  26401. }
  26402. if (typeof memo[target] === "undefined") {
  26403. var styleTarget = getTarget.call(this, target);
  26404. // Special case to return head of iframe instead of iframe itself
  26405. if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
  26406. try {
  26407. // This will throw an exception if access to iframe is blocked
  26408. // due to cross-origin restrictions
  26409. styleTarget = styleTarget.contentDocument.head;
  26410. } catch(e) {
  26411. styleTarget = null;
  26412. }
  26413. }
  26414. memo[target] = styleTarget;
  26415. }
  26416. return memo[target]
  26417. };
  26418. })();
  26419. var singleton = null;
  26420. var singletonCounter = 0;
  26421. var stylesInsertedAtTop = [];
  26422. var fixUrls = __webpack_require__(/*! ./urls */ "../../node_modules/style-loader/lib/urls.js");
  26423. module.exports = function(list, options) {
  26424. if (typeof DEBUG !== "undefined" && DEBUG) {
  26425. if (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
  26426. }
  26427. options = options || {};
  26428. options.attrs = typeof options.attrs === "object" ? options.attrs : {};
  26429. // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
  26430. // tags it will allow on a page
  26431. if (!options.singleton && typeof options.singleton !== "boolean") options.singleton = isOldIE();
  26432. // By default, add <style> tags to the <head> element
  26433. if (!options.insertInto) options.insertInto = "head";
  26434. // By default, add <style> tags to the bottom of the target
  26435. if (!options.insertAt) options.insertAt = "bottom";
  26436. var styles = listToStyles(list, options);
  26437. addStylesToDom(styles, options);
  26438. return function update (newList) {
  26439. var mayRemove = [];
  26440. for (var i = 0; i < styles.length; i++) {
  26441. var item = styles[i];
  26442. var domStyle = stylesInDom[item.id];
  26443. domStyle.refs--;
  26444. mayRemove.push(domStyle);
  26445. }
  26446. if(newList) {
  26447. var newStyles = listToStyles(newList, options);
  26448. addStylesToDom(newStyles, options);
  26449. }
  26450. for (var i = 0; i < mayRemove.length; i++) {
  26451. var domStyle = mayRemove[i];
  26452. if(domStyle.refs === 0) {
  26453. for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j]();
  26454. delete stylesInDom[domStyle.id];
  26455. }
  26456. }
  26457. };
  26458. };
  26459. function addStylesToDom (styles, options) {
  26460. for (var i = 0; i < styles.length; i++) {
  26461. var item = styles[i];
  26462. var domStyle = stylesInDom[item.id];
  26463. if(domStyle) {
  26464. domStyle.refs++;
  26465. for(var j = 0; j < domStyle.parts.length; j++) {
  26466. domStyle.parts[j](item.parts[j]);
  26467. }
  26468. for(; j < item.parts.length; j++) {
  26469. domStyle.parts.push(addStyle(item.parts[j], options));
  26470. }
  26471. } else {
  26472. var parts = [];
  26473. for(var j = 0; j < item.parts.length; j++) {
  26474. parts.push(addStyle(item.parts[j], options));
  26475. }
  26476. stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
  26477. }
  26478. }
  26479. }
  26480. function listToStyles (list, options) {
  26481. var styles = [];
  26482. var newStyles = {};
  26483. for (var i = 0; i < list.length; i++) {
  26484. var item = list[i];
  26485. var id = options.base ? item[0] + options.base : item[0];
  26486. var css = item[1];
  26487. var media = item[2];
  26488. var sourceMap = item[3];
  26489. var part = {css: css, media: media, sourceMap: sourceMap};
  26490. if(!newStyles[id]) styles.push(newStyles[id] = {id: id, parts: [part]});
  26491. else newStyles[id].parts.push(part);
  26492. }
  26493. return styles;
  26494. }
  26495. function insertStyleElement (options, style) {
  26496. var target = getElement(options.insertInto)
  26497. if (!target) {
  26498. throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");
  26499. }
  26500. var lastStyleElementInsertedAtTop = stylesInsertedAtTop[stylesInsertedAtTop.length - 1];
  26501. if (options.insertAt === "top") {
  26502. if (!lastStyleElementInsertedAtTop) {
  26503. target.insertBefore(style, target.firstChild);
  26504. } else if (lastStyleElementInsertedAtTop.nextSibling) {
  26505. target.insertBefore(style, lastStyleElementInsertedAtTop.nextSibling);
  26506. } else {
  26507. target.appendChild(style);
  26508. }
  26509. stylesInsertedAtTop.push(style);
  26510. } else if (options.insertAt === "bottom") {
  26511. target.appendChild(style);
  26512. } else if (typeof options.insertAt === "object" && options.insertAt.before) {
  26513. var nextSibling = getElement(options.insertInto + " " + options.insertAt.before);
  26514. target.insertBefore(style, nextSibling);
  26515. } else {
  26516. throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");
  26517. }
  26518. }
  26519. function removeStyleElement (style) {
  26520. if (style.parentNode === null) return false;
  26521. style.parentNode.removeChild(style);
  26522. var idx = stylesInsertedAtTop.indexOf(style);
  26523. if(idx >= 0) {
  26524. stylesInsertedAtTop.splice(idx, 1);
  26525. }
  26526. }
  26527. function createStyleElement (options) {
  26528. var style = document.createElement("style");
  26529. if(options.attrs.type === undefined) {
  26530. options.attrs.type = "text/css";
  26531. }
  26532. addAttrs(style, options.attrs);
  26533. insertStyleElement(options, style);
  26534. return style;
  26535. }
  26536. function createLinkElement (options) {
  26537. var link = document.createElement("link");
  26538. if(options.attrs.type === undefined) {
  26539. options.attrs.type = "text/css";
  26540. }
  26541. options.attrs.rel = "stylesheet";
  26542. addAttrs(link, options.attrs);
  26543. insertStyleElement(options, link);
  26544. return link;
  26545. }
  26546. function addAttrs (el, attrs) {
  26547. Object.keys(attrs).forEach(function (key) {
  26548. el.setAttribute(key, attrs[key]);
  26549. });
  26550. }
  26551. function addStyle (obj, options) {
  26552. var style, update, remove, result;
  26553. // If a transform function was defined, run it on the css
  26554. if (options.transform && obj.css) {
  26555. result = options.transform(obj.css);
  26556. if (result) {
  26557. // If transform returns a value, use that instead of the original css.
  26558. // This allows running runtime transformations on the css.
  26559. obj.css = result;
  26560. } else {
  26561. // If the transform function returns a falsy value, don't add this css.
  26562. // This allows conditional loading of css
  26563. return function() {
  26564. // noop
  26565. };
  26566. }
  26567. }
  26568. if (options.singleton) {
  26569. var styleIndex = singletonCounter++;
  26570. style = singleton || (singleton = createStyleElement(options));
  26571. update = applyToSingletonTag.bind(null, style, styleIndex, false);
  26572. remove = applyToSingletonTag.bind(null, style, styleIndex, true);
  26573. } else if (
  26574. obj.sourceMap &&
  26575. typeof URL === "function" &&
  26576. typeof URL.createObjectURL === "function" &&
  26577. typeof URL.revokeObjectURL === "function" &&
  26578. typeof Blob === "function" &&
  26579. typeof btoa === "function"
  26580. ) {
  26581. style = createLinkElement(options);
  26582. update = updateLink.bind(null, style, options);
  26583. remove = function () {
  26584. removeStyleElement(style);
  26585. if(style.href) URL.revokeObjectURL(style.href);
  26586. };
  26587. } else {
  26588. style = createStyleElement(options);
  26589. update = applyToTag.bind(null, style);
  26590. remove = function () {
  26591. removeStyleElement(style);
  26592. };
  26593. }
  26594. update(obj);
  26595. return function updateStyle (newObj) {
  26596. if (newObj) {
  26597. if (
  26598. newObj.css === obj.css &&
  26599. newObj.media === obj.media &&
  26600. newObj.sourceMap === obj.sourceMap
  26601. ) {
  26602. return;
  26603. }
  26604. update(obj = newObj);
  26605. } else {
  26606. remove();
  26607. }
  26608. };
  26609. }
  26610. var replaceText = (function () {
  26611. var textStore = [];
  26612. return function (index, replacement) {
  26613. textStore[index] = replacement;
  26614. return textStore.filter(Boolean).join('\n');
  26615. };
  26616. })();
  26617. function applyToSingletonTag (style, index, remove, obj) {
  26618. var css = remove ? "" : obj.css;
  26619. if (style.styleSheet) {
  26620. style.styleSheet.cssText = replaceText(index, css);
  26621. } else {
  26622. var cssNode = document.createTextNode(css);
  26623. var childNodes = style.childNodes;
  26624. if (childNodes[index]) style.removeChild(childNodes[index]);
  26625. if (childNodes.length) {
  26626. style.insertBefore(cssNode, childNodes[index]);
  26627. } else {
  26628. style.appendChild(cssNode);
  26629. }
  26630. }
  26631. }
  26632. function applyToTag (style, obj) {
  26633. var css = obj.css;
  26634. var media = obj.media;
  26635. if(media) {
  26636. style.setAttribute("media", media)
  26637. }
  26638. if(style.styleSheet) {
  26639. style.styleSheet.cssText = css;
  26640. } else {
  26641. while(style.firstChild) {
  26642. style.removeChild(style.firstChild);
  26643. }
  26644. style.appendChild(document.createTextNode(css));
  26645. }
  26646. }
  26647. function updateLink (link, options, obj) {
  26648. var css = obj.css;
  26649. var sourceMap = obj.sourceMap;
  26650. /*
  26651. If convertToAbsoluteUrls isn't defined, but sourcemaps are enabled
  26652. and there is no publicPath defined then lets turn convertToAbsoluteUrls
  26653. on by default. Otherwise default to the convertToAbsoluteUrls option
  26654. directly
  26655. */
  26656. var autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap;
  26657. if (options.convertToAbsoluteUrls || autoFixUrls) {
  26658. css = fixUrls(css);
  26659. }
  26660. if (sourceMap) {
  26661. // http://stackoverflow.com/a/26603875
  26662. css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
  26663. }
  26664. var blob = new Blob([css], { type: "text/css" });
  26665. var oldSrc = link.href;
  26666. link.href = URL.createObjectURL(blob);
  26667. if(oldSrc) URL.revokeObjectURL(oldSrc);
  26668. }
  26669. /***/ }),
  26670. /***/ "../../node_modules/style-loader/lib/urls.js":
  26671. /*!*****************************************************************!*\
  26672. !*** D:/Repos/Babylon.js/node_modules/style-loader/lib/urls.js ***!
  26673. \*****************************************************************/
  26674. /*! no static exports found */
  26675. /***/ (function(module, exports) {
  26676. /**
  26677. * When source maps are enabled, `style-loader` uses a link element with a data-uri to
  26678. * embed the css on the page. This breaks all relative urls because now they are relative to a
  26679. * bundle instead of the current page.
  26680. *
  26681. * One solution is to only use full urls, but that may be impossible.
  26682. *
  26683. * Instead, this function "fixes" the relative urls to be absolute according to the current page location.
  26684. *
  26685. * A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command.
  26686. *
  26687. */
  26688. module.exports = function (css) {
  26689. // get current location
  26690. var location = typeof window !== "undefined" && window.location;
  26691. if (!location) {
  26692. throw new Error("fixUrls requires window.location");
  26693. }
  26694. // blank or null?
  26695. if (!css || typeof css !== "string") {
  26696. return css;
  26697. }
  26698. var baseUrl = location.protocol + "//" + location.host;
  26699. var currentDir = baseUrl + location.pathname.replace(/\/[^\/]*$/, "/");
  26700. // convert each url(...)
  26701. /*
  26702. This regular expression is just a way to recursively match brackets within
  26703. a string.
  26704. /url\s*\( = Match on the word "url" with any whitespace after it and then a parens
  26705. ( = Start a capturing group
  26706. (?: = Start a non-capturing group
  26707. [^)(] = Match anything that isn't a parentheses
  26708. | = OR
  26709. \( = Match a start parentheses
  26710. (?: = Start another non-capturing groups
  26711. [^)(]+ = Match anything that isn't a parentheses
  26712. | = OR
  26713. \( = Match a start parentheses
  26714. [^)(]* = Match anything that isn't a parentheses
  26715. \) = Match a end parentheses
  26716. ) = End Group
  26717. *\) = Match anything and then a close parens
  26718. ) = Close non-capturing group
  26719. * = Match anything
  26720. ) = Close capturing group
  26721. \) = Match a close parens
  26722. /gi = Get all matches, not the first. Be case insensitive.
  26723. */
  26724. var fixedCss = css.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi, function(fullMatch, origUrl) {
  26725. // strip quotes (if they exist)
  26726. var unquotedOrigUrl = origUrl
  26727. .trim()
  26728. .replace(/^"(.*)"$/, function(o, $1){ return $1; })
  26729. .replace(/^'(.*)'$/, function(o, $1){ return $1; });
  26730. // already a full url? no change
  26731. if (/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(unquotedOrigUrl)) {
  26732. return fullMatch;
  26733. }
  26734. // convert the url to a full url
  26735. var newUrl;
  26736. if (unquotedOrigUrl.indexOf("//") === 0) {
  26737. //TODO: should we add protocol?
  26738. newUrl = unquotedOrigUrl;
  26739. } else if (unquotedOrigUrl.indexOf("/") === 0) {
  26740. // path should be relative to the base url
  26741. newUrl = baseUrl + unquotedOrigUrl; // already starts with '/'
  26742. } else {
  26743. // path should be relative to current directory
  26744. newUrl = currentDir + unquotedOrigUrl.replace(/^\.\//, ""); // Strip leading './'
  26745. }
  26746. // send back the fixed url(...)
  26747. return "url(" + JSON.stringify(newUrl) + ")";
  26748. });
  26749. // send back the fixed css
  26750. return fixedCss;
  26751. };
  26752. /***/ }),
  26753. /***/ "../../node_modules/tslib/tslib.es6.js":
  26754. /*!***********************************************************!*\
  26755. !*** D:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  26756. \***********************************************************/
  26757. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  26758. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26759. "use strict";
  26760. __webpack_require__.r(__webpack_exports__);
  26761. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  26762. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  26763. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  26764. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  26765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  26766. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  26767. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  26768. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  26769. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  26770. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  26771. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  26772. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  26773. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  26774. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  26775. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  26776. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  26777. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  26778. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  26779. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  26780. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  26781. /*! *****************************************************************************
  26782. Copyright (c) Microsoft Corporation. All rights reserved.
  26783. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  26784. this file except in compliance with the License. You may obtain a copy of the
  26785. License at http://www.apache.org/licenses/LICENSE-2.0
  26786. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  26787. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  26788. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  26789. MERCHANTABLITY OR NON-INFRINGEMENT.
  26790. See the Apache Version 2.0 License for specific language governing permissions
  26791. and limitations under the License.
  26792. ***************************************************************************** */
  26793. /* global Reflect, Promise */
  26794. var extendStatics = function(d, b) {
  26795. extendStatics = Object.setPrototypeOf ||
  26796. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  26797. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  26798. return extendStatics(d, b);
  26799. };
  26800. function __extends(d, b) {
  26801. extendStatics(d, b);
  26802. function __() { this.constructor = d; }
  26803. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26804. }
  26805. var __assign = function() {
  26806. __assign = Object.assign || function __assign(t) {
  26807. for (var s, i = 1, n = arguments.length; i < n; i++) {
  26808. s = arguments[i];
  26809. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  26810. }
  26811. return t;
  26812. }
  26813. return __assign.apply(this, arguments);
  26814. }
  26815. function __rest(s, e) {
  26816. var t = {};
  26817. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  26818. t[p] = s[p];
  26819. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  26820. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  26821. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  26822. t[p[i]] = s[p[i]];
  26823. }
  26824. return t;
  26825. }
  26826. function __decorate(decorators, target, key, desc) {
  26827. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  26828. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  26829. 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;
  26830. return c > 3 && r && Object.defineProperty(target, key, r), r;
  26831. }
  26832. function __param(paramIndex, decorator) {
  26833. return function (target, key) { decorator(target, key, paramIndex); }
  26834. }
  26835. function __metadata(metadataKey, metadataValue) {
  26836. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  26837. }
  26838. function __awaiter(thisArg, _arguments, P, generator) {
  26839. return new (P || (P = Promise))(function (resolve, reject) {
  26840. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  26841. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  26842. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  26843. step((generator = generator.apply(thisArg, _arguments || [])).next());
  26844. });
  26845. }
  26846. function __generator(thisArg, body) {
  26847. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  26848. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  26849. function verb(n) { return function (v) { return step([n, v]); }; }
  26850. function step(op) {
  26851. if (f) throw new TypeError("Generator is already executing.");
  26852. while (_) try {
  26853. 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;
  26854. if (y = 0, t) op = [op[0] & 2, t.value];
  26855. switch (op[0]) {
  26856. case 0: case 1: t = op; break;
  26857. case 4: _.label++; return { value: op[1], done: false };
  26858. case 5: _.label++; y = op[1]; op = [0]; continue;
  26859. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  26860. default:
  26861. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  26862. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  26863. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  26864. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  26865. if (t[2]) _.ops.pop();
  26866. _.trys.pop(); continue;
  26867. }
  26868. op = body.call(thisArg, _);
  26869. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  26870. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  26871. }
  26872. }
  26873. function __exportStar(m, exports) {
  26874. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  26875. }
  26876. function __values(o) {
  26877. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  26878. if (m) return m.call(o);
  26879. return {
  26880. next: function () {
  26881. if (o && i >= o.length) o = void 0;
  26882. return { value: o && o[i++], done: !o };
  26883. }
  26884. };
  26885. }
  26886. function __read(o, n) {
  26887. var m = typeof Symbol === "function" && o[Symbol.iterator];
  26888. if (!m) return o;
  26889. var i = m.call(o), r, ar = [], e;
  26890. try {
  26891. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  26892. }
  26893. catch (error) { e = { error: error }; }
  26894. finally {
  26895. try {
  26896. if (r && !r.done && (m = i["return"])) m.call(i);
  26897. }
  26898. finally { if (e) throw e.error; }
  26899. }
  26900. return ar;
  26901. }
  26902. function __spread() {
  26903. for (var ar = [], i = 0; i < arguments.length; i++)
  26904. ar = ar.concat(__read(arguments[i]));
  26905. return ar;
  26906. }
  26907. function __spreadArrays() {
  26908. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  26909. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  26910. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  26911. r[k] = a[j];
  26912. return r;
  26913. };
  26914. function __await(v) {
  26915. return this instanceof __await ? (this.v = v, this) : new __await(v);
  26916. }
  26917. function __asyncGenerator(thisArg, _arguments, generator) {
  26918. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  26919. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  26920. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  26921. 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); }); }; }
  26922. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  26923. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  26924. function fulfill(value) { resume("next", value); }
  26925. function reject(value) { resume("throw", value); }
  26926. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  26927. }
  26928. function __asyncDelegator(o) {
  26929. var i, p;
  26930. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  26931. 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; }
  26932. }
  26933. function __asyncValues(o) {
  26934. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  26935. var m = o[Symbol.asyncIterator], i;
  26936. 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);
  26937. 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); }); }; }
  26938. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  26939. }
  26940. function __makeTemplateObject(cooked, raw) {
  26941. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  26942. return cooked;
  26943. };
  26944. function __importStar(mod) {
  26945. if (mod && mod.__esModule) return mod;
  26946. var result = {};
  26947. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  26948. result.default = mod;
  26949. return result;
  26950. }
  26951. function __importDefault(mod) {
  26952. return (mod && mod.__esModule) ? mod : { default: mod };
  26953. }
  26954. /***/ }),
  26955. /***/ "../../node_modules/webpack/buildin/global.js":
  26956. /*!***********************************!*\
  26957. !*** (webpack)/buildin/global.js ***!
  26958. \***********************************/
  26959. /*! no static exports found */
  26960. /***/ (function(module, exports) {
  26961. var g;
  26962. // This works in non-strict mode
  26963. g = (function() {
  26964. return this;
  26965. })();
  26966. try {
  26967. // This works if eval is allowed (see CSP)
  26968. g = g || new Function("return this")();
  26969. } catch (e) {
  26970. // This works if the window reference is available
  26971. if (typeof window === "object") g = window;
  26972. }
  26973. // g can still be undefined, but nothing to do about it...
  26974. // We return undefined, instead of nothing here, so it's
  26975. // easier to handle this case. if(!global) { ...}
  26976. module.exports = g;
  26977. /***/ }),
  26978. /***/ "./components/animationBar.tsx":
  26979. /*!*************************************!*\
  26980. !*** ./components/animationBar.tsx ***!
  26981. \*************************************/
  26982. /*! exports provided: AnimationBar */
  26983. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26984. "use strict";
  26985. __webpack_require__.r(__webpack_exports__);
  26986. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationBar", function() { return AnimationBar; });
  26987. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  26988. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js");
  26989. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  26990. /* harmony import */ var _dropUpButton__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dropUpButton */ "./components/dropUpButton.tsx");
  26991. var iconPlay = __webpack_require__(/*! ../img/icon-play.svg */ "./img/icon-play.svg");
  26992. var iconPause = __webpack_require__(/*! ../img/icon-pause.svg */ "./img/icon-pause.svg");
  26993. __webpack_require__(/*! ../scss/animationBar.scss */ "./scss/animationBar.scss");
  26994. var AnimationBar = /** @class */ (function (_super) {
  26995. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AnimationBar, _super);
  26996. function AnimationBar(props) {
  26997. var _this = _super.call(this, props) || this;
  26998. _this._sliderRef = react__WEBPACK_IMPORTED_MODULE_1__["createRef"]();
  26999. _this.state = { groupIndex: 0 };
  27000. props.globalState.onSceneLoaded.add(function (info) {
  27001. _this.registerBeforeRender(info.scene);
  27002. });
  27003. if (_this.props.globalState.currentScene) {
  27004. _this.registerBeforeRender(_this.props.globalState.currentScene);
  27005. }
  27006. return _this;
  27007. }
  27008. AnimationBar.prototype.getCurrentPosition = function () {
  27009. if (!this._currentGroup) {
  27010. return "0";
  27011. }
  27012. var targetedAnimations = this._currentGroup.targetedAnimations;
  27013. if (targetedAnimations.length > 0) {
  27014. var runtimeAnimations = this._currentGroup.targetedAnimations[0].animation.runtimeAnimations;
  27015. if (runtimeAnimations.length > 0) {
  27016. return runtimeAnimations[0].currentFrame.toString();
  27017. }
  27018. }
  27019. return "0";
  27020. };
  27021. AnimationBar.prototype.registerBeforeRender = function (newScene) {
  27022. var _this = this;
  27023. if (this._currentScene) {
  27024. this._currentScene.onBeforeRenderObservable.remove(this._sliderSyncObserver);
  27025. }
  27026. this._currentScene = newScene;
  27027. this._sliderSyncObserver = this._currentScene.onBeforeRenderObservable.add(function () {
  27028. if (_this._currentGroup && _this._sliderRef.current) {
  27029. _this._sliderRef.current.value = _this.getCurrentPosition();
  27030. if (_this._currentPlayingState !== _this._currentGroup.isPlaying) {
  27031. _this.forceUpdate();
  27032. }
  27033. }
  27034. });
  27035. };
  27036. AnimationBar.prototype.pause = function () {
  27037. if (!this._currentGroup) {
  27038. return;
  27039. }
  27040. this._currentGroup.pause();
  27041. this.forceUpdate();
  27042. };
  27043. AnimationBar.prototype.play = function () {
  27044. if (!this._currentGroup) {
  27045. return;
  27046. }
  27047. this._currentGroup.play();
  27048. this.forceUpdate();
  27049. };
  27050. AnimationBar.prototype.sliderInput = function (evt) {
  27051. if (!this._currentGroup) {
  27052. return;
  27053. }
  27054. var value = parseFloat(evt.target.value);
  27055. if (!this._currentGroup.isPlaying) {
  27056. this._currentGroup.play(true);
  27057. this._currentGroup.goToFrame(value);
  27058. this._currentGroup.pause();
  27059. }
  27060. else {
  27061. this._currentGroup.goToFrame(value);
  27062. }
  27063. };
  27064. AnimationBar.prototype.render = function () {
  27065. var _this = this;
  27066. if (!this.props.enabled) {
  27067. this._currentGroup = null;
  27068. return null;
  27069. }
  27070. var scene = this.props.globalState.currentScene;
  27071. if (scene.animationGroups.length === 0) {
  27072. this._currentGroup = null;
  27073. return null;
  27074. }
  27075. var groupNames = scene.animationGroups.map(function (g) { return g.name; });
  27076. this._currentGroup = scene.animationGroups[this.state.groupIndex];
  27077. this._currentPlayingState = this._currentGroup.isPlaying;
  27078. return (react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "animationBar" },
  27079. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "row" },
  27080. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("button", { id: "playBtn" },
  27081. this._currentGroup.isPlaying &&
  27082. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("img", { id: "pauseImg", src: iconPause, onClick: function () { return _this.pause(); } }),
  27083. !this._currentGroup.isPlaying &&
  27084. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("img", { id: "playImg", src: iconPlay, onClick: function () { return _this.play(); } })),
  27085. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("input", { ref: this._sliderRef, className: "slider", type: "range", onInput: function (evt) { return _this.sliderInput(evt); }, min: this._currentGroup.from, max: this._currentGroup.to, onChange: function () { }, value: this.getCurrentPosition(), step: "any" })),
  27086. react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_dropUpButton__WEBPACK_IMPORTED_MODULE_2__["DropUpButton"], { globalState: this.props.globalState, label: "Active animation group", options: groupNames, selectedOption: this._currentGroup.name, onOptionPicked: function (option) {
  27087. _this._currentGroup.stop();
  27088. var newIndex = groupNames.indexOf(option);
  27089. _this.setState({ groupIndex: newIndex });
  27090. scene.animationGroups[newIndex].play(true);
  27091. }, enabled: true })));
  27092. };
  27093. return AnimationBar;
  27094. }(react__WEBPACK_IMPORTED_MODULE_1__["Component"]));
  27095. /***/ }),
  27096. /***/ "./components/dropUpButton.tsx":
  27097. /*!*************************************!*\
  27098. !*** ./components/dropUpButton.tsx ***!
  27099. \*************************************/
  27100. /*! exports provided: DropUpButton */
  27101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27102. "use strict";
  27103. __webpack_require__.r(__webpack_exports__);
  27104. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DropUpButton", function() { return DropUpButton; });
  27105. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  27106. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js");
  27107. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  27108. var iconUp = __webpack_require__(/*! ../img/icon-up.svg */ "./img/icon-up.svg");
  27109. var iconDown = __webpack_require__(/*! ../img/icon-down.svg */ "./img/icon-down.svg");
  27110. var DropUpButton = /** @class */ (function (_super) {
  27111. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DropUpButton, _super);
  27112. function DropUpButton(props) {
  27113. var _this = _super.call(this, props) || this;
  27114. _this.state = { isOpen: false };
  27115. _this._onClickInterceptorClickedObserver = props.globalState.onClickInterceptorClicked.add(function () {
  27116. _this.setState({ isOpen: false });
  27117. });
  27118. return _this;
  27119. }
  27120. DropUpButton.prototype.componentWillUnmount = function () {
  27121. this.props.globalState.onClickInterceptorClicked.remove(this._onClickInterceptorClickedObserver);
  27122. };
  27123. DropUpButton.prototype.switchDropUp = function () {
  27124. this.props.globalState.onRequestClickInterceptor.notifyObservers();
  27125. this.setState({ isOpen: !this.state.isOpen });
  27126. };
  27127. DropUpButton.prototype.clickOption = function (option) {
  27128. this.switchDropUp();
  27129. this.props.onOptionPicked(option);
  27130. };
  27131. DropUpButton.prototype.render = function () {
  27132. var _this = this;
  27133. if (!this.props.enabled) {
  27134. return null;
  27135. }
  27136. return (react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "dropup" },
  27137. this.props.icon &&
  27138. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "button" + (this.state.isOpen ? " active" : ""), onClick: function () { return _this.switchDropUp(); } },
  27139. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("img", { src: this.props.icon, alt: this.props.label, title: this.props.label })),
  27140. this.props.selectedOption &&
  27141. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "button long" + (this.state.isOpen ? " active" : ""), onClick: function () { return _this.switchDropUp(); } },
  27142. this.state.isOpen &&
  27143. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("img", { className: "button-icon", src: iconDown, alt: "Close the list", title: "Close the list" }),
  27144. !this.state.isOpen &&
  27145. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("img", { className: "button-icon", src: iconUp, alt: "Open the list", title: "Open the list" }),
  27146. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "button-text", title: this.props.selectedOption }, this.props.selectedOption)),
  27147. this.state.isOpen &&
  27148. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "dropup-content" + (this.props.selectedOption ? " long-mode" : "") }, this.props.options.map(function (o) {
  27149. return (react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { key: o, onClick: function () { return _this.clickOption(o); } }, o));
  27150. }))));
  27151. };
  27152. return DropUpButton;
  27153. }(react__WEBPACK_IMPORTED_MODULE_1__["Component"]));
  27154. /***/ }),
  27155. /***/ "./components/footer.tsx":
  27156. /*!*******************************!*\
  27157. !*** ./components/footer.tsx ***!
  27158. \*******************************/
  27159. /*! exports provided: Footer */
  27160. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27161. "use strict";
  27162. __webpack_require__.r(__webpack_exports__);
  27163. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Footer", function() { return Footer; });
  27164. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  27165. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js");
  27166. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  27167. /* harmony import */ var _footerButton__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./footerButton */ "./components/footerButton.tsx");
  27168. /* harmony import */ var _dropUpButton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dropUpButton */ "./components/dropUpButton.tsx");
  27169. /* harmony import */ var _tools_environmentTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../tools/environmentTools */ "./tools/environmentTools.ts");
  27170. /* harmony import */ var _footerFileButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./footerFileButton */ "./components/footerFileButton.tsx");
  27171. /* harmony import */ var _animationBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./animationBar */ "./components/animationBar.tsx");
  27172. __webpack_require__(/*! ../scss/footer.scss */ "./scss/footer.scss");
  27173. var babylonIdentity = __webpack_require__(/*! ../img/babylon-identity.svg */ "./img/babylon-identity.svg");
  27174. var iconEdit = __webpack_require__(/*! ../img/icon-edit.svg */ "./img/icon-edit.svg");
  27175. var iconOpen = __webpack_require__(/*! ../img/icon-open.svg */ "./img/icon-open.svg");
  27176. var iconIBL = __webpack_require__(/*! ../img/icon-ibl.svg */ "./img/icon-ibl.svg");
  27177. var Footer = /** @class */ (function (_super) {
  27178. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Footer, _super);
  27179. function Footer(props) {
  27180. var _this = _super.call(this, props) || this;
  27181. props.globalState.onSceneLoaded.add(function (info) {
  27182. _this.forceUpdate();
  27183. });
  27184. return _this;
  27185. }
  27186. Footer.prototype.showInspector = function () {
  27187. if (this.props.globalState.currentScene) {
  27188. if (this.props.globalState.currentScene.debugLayer.isVisible()) {
  27189. this.props.globalState.hideDebugLayer();
  27190. }
  27191. else {
  27192. this.props.globalState.showDebugLayer();
  27193. }
  27194. }
  27195. };
  27196. Footer.prototype.render = function () {
  27197. var _this = this;
  27198. return (react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { id: "footer", className: "footer" },
  27199. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "footerLeft" },
  27200. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("img", { id: "logoImg", src: babylonIdentity })),
  27201. react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_animationBar__WEBPACK_IMPORTED_MODULE_6__["AnimationBar"], { globalState: this.props.globalState, enabled: !!this.props.globalState.currentScene }),
  27202. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "footerRight" },
  27203. react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_footerFileButton__WEBPACK_IMPORTED_MODULE_5__["FooterFileButton"], { globalState: this.props.globalState, enabled: true, icon: iconOpen, onFilesPicked: function (evt, files) {
  27204. _this.props.globalState.filesInput.loadFiles(evt);
  27205. }, label: "Open your scene from your hard drive (.babylon, .gltf, .glb, .obj)" }),
  27206. react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_dropUpButton__WEBPACK_IMPORTED_MODULE_3__["DropUpButton"], { globalState: this.props.globalState, icon: iconIBL, label: "Select environment", options: _tools_environmentTools__WEBPACK_IMPORTED_MODULE_4__["EnvironmentTools"].SkyboxesNames, onOptionPicked: function (option) { return _this.props.globalState.onEnvironmentChanged.notifyObservers(option); }, enabled: !!this.props.globalState.currentScene }),
  27207. react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_footerButton__WEBPACK_IMPORTED_MODULE_2__["FooterButton"], { globalState: this.props.globalState, icon: iconEdit, label: "Display inspector", onClick: function () { return _this.showInspector(); }, enabled: !!this.props.globalState.currentScene }))));
  27208. };
  27209. return Footer;
  27210. }(react__WEBPACK_IMPORTED_MODULE_1__["Component"]));
  27211. /***/ }),
  27212. /***/ "./components/footerButton.tsx":
  27213. /*!*************************************!*\
  27214. !*** ./components/footerButton.tsx ***!
  27215. \*************************************/
  27216. /*! exports provided: FooterButton */
  27217. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27218. "use strict";
  27219. __webpack_require__.r(__webpack_exports__);
  27220. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FooterButton", function() { return FooterButton; });
  27221. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  27222. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js");
  27223. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  27224. var FooterButton = /** @class */ (function (_super) {
  27225. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FooterButton, _super);
  27226. function FooterButton() {
  27227. return _super !== null && _super.apply(this, arguments) || this;
  27228. }
  27229. FooterButton.prototype.render = function () {
  27230. var _this = this;
  27231. if (!this.props.enabled) {
  27232. return null;
  27233. }
  27234. return (react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "button", onClick: function () { return _this.props.onClick(); } },
  27235. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("img", { src: this.props.icon, alt: this.props.label, title: this.props.label })));
  27236. };
  27237. return FooterButton;
  27238. }(react__WEBPACK_IMPORTED_MODULE_1__["Component"]));
  27239. /***/ }),
  27240. /***/ "./components/footerFileButton.tsx":
  27241. /*!*****************************************!*\
  27242. !*** ./components/footerFileButton.tsx ***!
  27243. \*****************************************/
  27244. /*! exports provided: FooterFileButton */
  27245. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27246. "use strict";
  27247. __webpack_require__.r(__webpack_exports__);
  27248. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FooterFileButton", function() { return FooterFileButton; });
  27249. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  27250. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js");
  27251. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  27252. var FooterFileButton = /** @class */ (function (_super) {
  27253. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FooterFileButton, _super);
  27254. function FooterFileButton() {
  27255. return _super !== null && _super.apply(this, arguments) || this;
  27256. }
  27257. FooterFileButton.prototype.onFilePicked = function (evt) {
  27258. this.props.onFilesPicked(evt.nativeEvent, evt.target.files);
  27259. };
  27260. FooterFileButton.prototype.render = function () {
  27261. var _this = this;
  27262. if (!this.props.enabled) {
  27263. return null;
  27264. }
  27265. return (react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "custom-upload", title: this.props.label },
  27266. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("img", { src: this.props.icon }),
  27267. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("input", { type: "file", id: "files", multiple: true, onChange: function (evt) { return _this.onFilePicked(evt); } })));
  27268. };
  27269. return FooterFileButton;
  27270. }(react__WEBPACK_IMPORTED_MODULE_1__["Component"]));
  27271. /***/ }),
  27272. /***/ "./components/renderingZone.tsx":
  27273. /*!**************************************!*\
  27274. !*** ./components/renderingZone.tsx ***!
  27275. \**************************************/
  27276. /*! exports provided: RenderingZone */
  27277. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27278. "use strict";
  27279. __webpack_require__.r(__webpack_exports__);
  27280. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingZone", function() { return RenderingZone; });
  27281. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  27282. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js");
  27283. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  27284. /* harmony import */ var babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Engines/engine */ "babylonjs/Maths/math.vector");
  27285. /* harmony import */ var babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__);
  27286. /* harmony import */ var babylonjs_loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs-loaders/glTF/glTFFileLoader */ "babylonjs-loaders/glTF/glTFFileLoader");
  27287. /* harmony import */ var babylonjs_loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__);
  27288. /* harmony import */ var _tools_environmentTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../tools/environmentTools */ "./tools/environmentTools.ts");
  27289. __webpack_require__(/*! ../scss/renderingZone.scss */ "./scss/renderingZone.scss");
  27290. var RenderingZone = /** @class */ (function (_super) {
  27291. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RenderingZone, _super);
  27292. function RenderingZone(props) {
  27293. return _super.call(this, props) || this;
  27294. }
  27295. RenderingZone.prototype.initEngine = function () {
  27296. var _this = this;
  27297. this._canvas = document.getElementById("renderCanvas");
  27298. this._engine = new babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"](this._canvas, true, { premultipliedAlpha: false, preserveDrawingBuffer: true });
  27299. this._engine.loadingUIBackgroundColor = "#2A2342";
  27300. // Resize
  27301. window.addEventListener("resize", function () {
  27302. _this._engine.resize();
  27303. });
  27304. this.loadAsset();
  27305. // File inputs
  27306. var filesInput = new babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["FilesInput"](this._engine, null, function (sceneFile, scene) {
  27307. _this._scene = scene;
  27308. _this.onSceneLoaded(sceneFile.name);
  27309. }, null, null, null, function () {
  27310. babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Tools"].ClearLogCache();
  27311. if (_this._scene) {
  27312. _this.props.globalState.isDebugLayerEnabled = _this.props.globalState.currentScene.debugLayer.isVisible();
  27313. if (_this.props.globalState.isDebugLayerEnabled) {
  27314. _this._scene.debugLayer.hide();
  27315. }
  27316. }
  27317. }, null, null);
  27318. filesInput.onProcessFileCallback = function (file, name, extension) {
  27319. if (filesInput.filesToLoad && filesInput.filesToLoad.length === 1 && extension) {
  27320. if (extension.toLowerCase() === "dds" ||
  27321. extension.toLowerCase() === "env" ||
  27322. extension.toLowerCase() === "hdr") {
  27323. babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["FilesInput"].FilesToLoad[name] = file;
  27324. _tools_environmentTools__WEBPACK_IMPORTED_MODULE_4__["EnvironmentTools"].SkyboxPath = "file:" + file.correctName;
  27325. return false;
  27326. }
  27327. }
  27328. return true;
  27329. };
  27330. filesInput.monitorElementForDragNDrop(this._canvas);
  27331. this.props.globalState.filesInput = filesInput;
  27332. };
  27333. RenderingZone.prototype.prepareCamera = function () {
  27334. var camera;
  27335. // Attach camera to canvas inputs
  27336. if (!this._scene.activeCamera || this._scene.lights.length === 0) {
  27337. this._scene.createDefaultCamera(true);
  27338. camera = this._scene.activeCamera;
  27339. if (this.props.cameraPosition) {
  27340. camera.setPosition(this.props.cameraPosition);
  27341. }
  27342. else {
  27343. if (this._currentPluginName === "gltf") {
  27344. // glTF assets use a +Z forward convention while the default camera faces +Z. Rotate the camera to look at the front of the asset.
  27345. camera.alpha += Math.PI;
  27346. }
  27347. // Enable camera's behaviors
  27348. camera.useFramingBehavior = true;
  27349. var framingBehavior = camera.getBehaviorByName("Framing");
  27350. framingBehavior.framingTime = 0;
  27351. framingBehavior.elevationReturnTime = -1;
  27352. if (this._scene.meshes.length) {
  27353. camera.lowerRadiusLimit = null;
  27354. var worldExtends = this._scene.getWorldExtends(function (mesh) {
  27355. return mesh.isVisible && mesh.isEnabled();
  27356. });
  27357. framingBehavior.zoomOnBoundingInfo(worldExtends.min, worldExtends.max);
  27358. }
  27359. }
  27360. camera.pinchPrecision = 200 / camera.radius;
  27361. camera.upperRadiusLimit = 5 * camera.radius;
  27362. camera.wheelDeltaPercentage = 0.01;
  27363. camera.pinchDeltaPercentage = 0.01;
  27364. }
  27365. this._scene.activeCamera.attachControl(this._canvas);
  27366. };
  27367. RenderingZone.prototype.handleErrors = function () {
  27368. // In case of error during loading, meshes will be empty and clearColor is set to red
  27369. if (this._scene.meshes.length === 0 && this._scene.clearColor.r === 1 && this._scene.clearColor.g === 0 && this._scene.clearColor.b === 0) {
  27370. this._canvas.style.opacity = "0";
  27371. this.props.globalState.onError.notifyObservers({ scene: this._scene, message: "No mesh found in your scene" });
  27372. }
  27373. else {
  27374. if (babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Tools"].errorsCount > 0) {
  27375. this.props.globalState.onError.notifyObservers({ scene: this._scene, message: "Scene loaded but several errors were found" });
  27376. }
  27377. // this._canvas.style.opacity = "1";
  27378. var camera = this._scene.activeCamera;
  27379. if (camera.keysUp) {
  27380. camera.keysUp.push(90); // Z
  27381. camera.keysUp.push(87); // W
  27382. camera.keysDown.push(83); // S
  27383. camera.keysLeft.push(65); // A
  27384. camera.keysLeft.push(81); // Q
  27385. camera.keysRight.push(69); // E
  27386. camera.keysRight.push(68); // D
  27387. }
  27388. }
  27389. };
  27390. RenderingZone.prototype.prepareLighting = function () {
  27391. if (this._currentPluginName === "gltf") {
  27392. if (!this._scene.environmentTexture) {
  27393. this._scene.environmentTexture = _tools_environmentTools__WEBPACK_IMPORTED_MODULE_4__["EnvironmentTools"].LoadSkyboxPathTexture(this._scene);
  27394. }
  27395. if (this._scene.environmentTexture) {
  27396. this._scene.createDefaultSkybox(this._scene.environmentTexture, true, (this._scene.activeCamera.maxZ - this._scene.activeCamera.minZ) / 2, 0.3, false);
  27397. }
  27398. }
  27399. else {
  27400. var pbrPresent = false;
  27401. for (var i = 0; i < this._scene.materials.length; i++) {
  27402. if (this._scene.materials[i].transparencyMode !== undefined) {
  27403. pbrPresent = true;
  27404. break;
  27405. }
  27406. }
  27407. if (pbrPresent) {
  27408. if (!this._scene.environmentTexture) {
  27409. this._scene.environmentTexture = _tools_environmentTools__WEBPACK_IMPORTED_MODULE_4__["EnvironmentTools"].LoadSkyboxPathTexture(this._scene);
  27410. }
  27411. }
  27412. else {
  27413. this._scene.createDefaultLight();
  27414. }
  27415. }
  27416. };
  27417. RenderingZone.prototype.onSceneLoaded = function (filename) {
  27418. this._engine.clearInternalTexturesCache();
  27419. this._scene.skipFrustumClipping = true;
  27420. this.props.globalState.onSceneLoaded.notifyObservers({ scene: this._scene, filename: filename });
  27421. this.prepareCamera();
  27422. this.prepareLighting();
  27423. this.handleErrors();
  27424. if (this.props.globalState.isDebugLayerEnabled) {
  27425. this.props.globalState.showDebugLayer();
  27426. }
  27427. };
  27428. RenderingZone.prototype.loadAssetFromUrl = function () {
  27429. var _this = this;
  27430. var assetUrl = this.props.assetUrl;
  27431. var rootUrl = babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetFolderPath(assetUrl);
  27432. var fileName = babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetFilename(assetUrl);
  27433. babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].LoadAsync(rootUrl, fileName, this._engine).then(function (scene) {
  27434. if (_this._scene) {
  27435. _this._scene.dispose();
  27436. }
  27437. _this._scene = scene;
  27438. _this.onSceneLoaded(fileName);
  27439. scene.whenReadyAsync().then(function () {
  27440. _this._engine.runRenderLoop(function () {
  27441. scene.render();
  27442. });
  27443. });
  27444. }).catch(function (reason) {
  27445. _this.props.globalState.onError.notifyObservers({ message: reason.message });
  27446. //TODO sceneError({ name: fileName }, null, reason.message || reason);
  27447. });
  27448. };
  27449. RenderingZone.prototype.loadAsset = function () {
  27450. if (this.props.assetUrl) {
  27451. this.loadAssetFromUrl();
  27452. return;
  27453. }
  27454. };
  27455. RenderingZone.prototype.componentDidMount = function () {
  27456. var _this = this;
  27457. if (!babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].isSupported()) {
  27458. return;
  27459. }
  27460. babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].ShadersRepository = "/src/Shaders/";
  27461. // This is really important to tell Babylon.js to use decomposeLerp and matrix interpolation
  27462. babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Animation"].AllowMatricesInterpolation = true;
  27463. // Setting up some GLTF values
  27464. babylonjs_loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__["GLTFFileLoader"].IncrementalLoading = false;
  27465. babylonjs_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].OnPluginActivatedObservable.add(function (plugin) {
  27466. _this._currentPluginName = plugin.name;
  27467. if (_this._currentPluginName === "gltf") {
  27468. plugin.onValidatedObservable.add(function (results) {
  27469. if (results.issues.numErrors > 0) {
  27470. _this.props.globalState.showDebugLayer();
  27471. }
  27472. });
  27473. }
  27474. });
  27475. this.initEngine();
  27476. };
  27477. RenderingZone.prototype.shouldComponentUpdate = function (nextProps) {
  27478. var _this = this;
  27479. if (nextProps.expanded !== this.props.expanded) {
  27480. setTimeout(function () { return _this._engine.resize(); });
  27481. return true;
  27482. }
  27483. return false;
  27484. };
  27485. RenderingZone.prototype.render = function () {
  27486. return (react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { id: "canvasZone", className: this.props.expanded ? "expanded" : "" },
  27487. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("canvas", { id: "renderCanvas", "touch-action": "none", onContextMenu: function (evt) { return evt.preventDefault(); } })));
  27488. };
  27489. return RenderingZone;
  27490. }(react__WEBPACK_IMPORTED_MODULE_1__["Component"]));
  27491. /***/ }),
  27492. /***/ "./globalState.ts":
  27493. /*!************************!*\
  27494. !*** ./globalState.ts ***!
  27495. \************************/
  27496. /*! exports provided: GlobalState */
  27497. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27498. "use strict";
  27499. __webpack_require__.r(__webpack_exports__);
  27500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlobalState", function() { return GlobalState; });
  27501. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  27502. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  27503. var GlobalState = /** @class */ (function () {
  27504. function GlobalState() {
  27505. this.onSceneLoaded = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  27506. this.onError = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  27507. this.onEnvironmentChanged = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  27508. this.onRequestClickInterceptor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  27509. this.onClickInterceptorClicked = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  27510. this.isDebugLayerEnabled = false;
  27511. }
  27512. GlobalState.prototype.showDebugLayer = function () {
  27513. this.isDebugLayerEnabled = true;
  27514. if (this.currentScene) {
  27515. this.currentScene.debugLayer.show();
  27516. }
  27517. };
  27518. GlobalState.prototype.hideDebugLayer = function () {
  27519. this.isDebugLayerEnabled = false;
  27520. if (this.currentScene) {
  27521. this.currentScene.debugLayer.hide();
  27522. }
  27523. };
  27524. return GlobalState;
  27525. }());
  27526. /***/ }),
  27527. /***/ "./img/babylon-identity.svg":
  27528. /*!**********************************!*\
  27529. !*** ./img/babylon-identity.svg ***!
  27530. \**********************************/
  27531. /*! no static exports found */
  27532. /***/ (function(module, exports) {
  27533. module.exports = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160.63 40.18'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23d5d2ca;%7D.cls-2%7Bfill:%23fff;%7D.cls-3%7Bfill:%23e0684b;%7D.cls-4%7Bfill:%23bb464b;%7D.cls-5%7Bfill:%23e0ded8;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3EBabylonIdentity%3C/title%3E%3Cg id='Layer_2' data-name='Layer 2'%3E%3Cg id='Page_Elements' data-name='Page Elements'%3E%3Cpath class='cls-1' d='M41.27,10h3.41v7.65c.61-1,1.82-2,4.21-2,3.74,0,5.78,3.08,5.78,7.13s-2.12,7.68-6.16,7.68c-2.15,0-3.17-.72-3.85-1.85a11.47,11.47,0,0,1-.14,1.52H41.24c0-1.55,0-3.11,0-4.68Zm6.63,8.42c-2.47,0-3.38,1.65-3.38,4.68,0,2.59.8,4.59,3.33,4.59,2.14,0,3.33-1.92,3.33-4.84C51.18,20.27,50.13,18.43,47.9,18.43Z'/%3E%3Cpath class='cls-1' d='M68.59,26.66a26.61,26.61,0,0,0,.2,3.47H65.51a7.37,7.37,0,0,1-.22-1.55c-.49.86-1.51,1.88-4.1,1.88-3.38,0-4.81-2.23-4.81-4.41,0-3.19,2.56-4.67,6.71-4.67h2.15v-1c0-1.1-.36-2.25-2.48-2.25-1.87,0-2.26.85-2.45,1.89H57c.19-2.31,1.65-4.43,5.86-4.4,3.68,0,5.69,1.49,5.69,4.79Zm-3.33-3.14H63.42c-2.5,0-3.6.74-3.6,2.34A2,2,0,0,0,62.1,28c2.81,0,3.16-1.92,3.16-4Z'/%3E%3Cpath class='cls-1' d='M71.67,10h3.42v7.65c.6-1,1.81-2,4.21-2,3.74,0,5.77,3.08,5.77,7.13S83,30.46,78.91,30.46c-2.15,0-3.16-.72-3.85-1.85a10,10,0,0,1-.14,1.52H71.65c0-1.55,0-3.11,0-4.68Zm6.64,8.42c-2.48,0-3.39,1.65-3.39,4.68,0,2.59.8,4.59,3.33,4.59,2.15,0,3.33-1.92,3.33-4.84C81.58,20.27,80.53,18.43,78.31,18.43Z'/%3E%3Cpath class='cls-1' d='M89.37,16c1.76,5.53,3,9.66,3.3,11h0c.35-1.49,1.23-4.68,3.13-11h3.41L94.37,30.62c-1.37,4.1-2.47,5.26-5.69,5.26A15.34,15.34,0,0,1,87,35.77V33c.3,0,.71,0,1.07,0,1.54,0,2.25-.57,2.89-2.42L85.71,16Z'/%3E%3Cpath class='cls-1' d='M100.76,30.13V10h3.41V30.13Z'/%3E%3Cpath class='cls-1' d='M120.32,23c0,4.21-2.48,7.43-6.91,7.43s-6.79-3.14-6.79-7.38,2.56-7.43,7-7.43C117.68,15.65,120.32,18.6,120.32,23Zm-10.23,0c0,2.87,1.29,4.68,3.41,4.68s3.33-1.79,3.33-4.65c0-3-1.19-4.7-3.39-4.7S110.09,20,110.09,23.05Z'/%3E%3Cpath class='cls-1' d='M122.8,19.53c0-1.21,0-2.47,0-3.55h3.3a15.77,15.77,0,0,1,.14,2,4.32,4.32,0,0,1,4.21-2.31c2.78,0,4.7,1.82,4.7,5.45v9h-3.41V21.49c0-1.77-.63-3-2.5-3s-3,1.29-3,3.91v7.76H122.8Z'/%3E%3Cpath class='cls-1' d='M138.37,30.13V25.56H142v4.57Z'/%3E%3Cpath class='cls-1' d='M147.67,16.28V30.87c0,3.77-.91,5-3.6,5-.11,0-.66,0-.86,0V34.2c.2,0,.42,0,.58,0,1.84,0,2-1,2-3.08V16.28Zm-1.84-3.57V9.87h1.84v2.84Z'/%3E%3Cpath class='cls-1' d='M151.85,26.25a3.45,3.45,0,0,0,3.69,2.66c2.26,0,3.16-1,3.16-2.44s-.63-2.15-3.52-2.84c-3.77-.91-4.62-2.06-4.62-3.91S152,16,155.32,16s4.81,2,5,3.94h-1.81a3,3,0,0,0-3.28-2.39c-2.2,0-2.83,1.07-2.83,2.09s.61,1.73,3.25,2.36c4,1,4.95,2.31,4.95,4.38,0,2.47-2,4.13-5.15,4.13-3.35,0-5.11-1.74-5.47-4.21Z'/%3E%3Cpolygon class='cls-2' points='17.4 0 0 10.04 0 30.13 17.4 40.18 34.8 30.13 34.8 10.04 17.4 0'/%3E%3Cpolygon class='cls-3' points='34.8 10.04 29.35 6.9 24.11 9.93 29.56 13.07 34.8 10.04'/%3E%3Cpolygon class='cls-3' points='5.24 13.07 22.64 3.02 17.4 0 0 10.04 5.24 13.07'/%3E%3Cpolygon class='cls-3' points='11.95 23.23 17.4 26.38 22.84 23.23 17.4 20.09 11.95 23.23'/%3E%3Cpolygon class='cls-4' points='29.56 13.07 29.56 27.11 17.4 34.13 5.24 27.11 5.24 13.07 0 10.04 0 30.13 17.4 40.18 34.8 30.13 34.8 10.04 29.56 13.07'/%3E%3Cpolygon class='cls-4' points='17.4 13.8 11.95 16.95 11.95 23.23 17.4 20.09 22.84 23.23 22.84 16.95 17.4 13.8'/%3E%3Cpolygon class='cls-5' points='29.56 13.07 22.84 16.95 22.84 23.23 17.4 26.38 17.4 34.13 29.56 27.11 29.56 13.07'/%3E%3Cpolygon class='cls-1' points='5.24 13.07 11.95 16.95 11.95 23.23 17.4 26.38 17.4 34.13 5.24 27.11 5.24 13.07'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"
  27534. /***/ }),
  27535. /***/ "./img/icon-down.svg":
  27536. /*!***************************!*\
  27537. !*** ./img/icon-down.svg ***!
  27538. \***************************/
  27539. /*! no static exports found */
  27540. /***/ (function(module, exports) {
  27541. module.exports = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 70'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fff;%7D.cls-2%7Bfill:none;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3EDownArrowIcon%3C/title%3E%3Cg id='Layer_2' data-name='Layer 2'%3E%3Cg id='Redlines'%3E%3Cpath class='cls-1' d='M23.14,30.07l1.42-1.42L34.85,38.94,45.14,28.65l1.41,1.42L34.85,41.78Z'/%3E%3Crect class='cls-2' width='70' height='70'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"
  27542. /***/ }),
  27543. /***/ "./img/icon-edit.svg":
  27544. /*!***************************!*\
  27545. !*** ./img/icon-edit.svg ***!
  27546. \***************************/
  27547. /*! no static exports found */
  27548. /***/ (function(module, exports) {
  27549. module.exports = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 70'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fff;%7D.cls-2%7Bfill:none;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3EEditIcon%3C/title%3E%3Cg id='Layer_2' data-name='Layer 2'%3E%3Cg id='Page_Elements' data-name='Page Elements'%3E%3Cpath class='cls-1' d='M44.25,30.78a2.56,2.56,0,0,1,1-.64,3.64,3.64,0,0,1,1.17-.2,3.29,3.29,0,0,1,1.21.23,2.73,2.73,0,0,1,1,.62,3,3,0,0,1,.65,1A2.84,2.84,0,0,1,49.5,33a3.14,3.14,0,0,1-.23,1.18,2.84,2.84,0,0,1-.67,1L37.52,46.25l-5.85,1.46,1.46-5.84Zm3,3a1.06,1.06,0,0,0,.33-.79,1,1,0,0,0-.32-.78,1.16,1.16,0,0,0-.8-.29A1.23,1.23,0,0,0,46,32a.88.88,0,0,0-.36.21L34.93,42.89,34.4,45l2.09-.52Z'/%3E%3Cpath class='cls-1' d='M31.94,41.2l1-1V31.9l5.94-3v5.32l2-2V26.73L32,22.27l-8.92,4.46V38.5l8.5,4.26Zm0-16.7,5.7,2.85L32,30.18l-5.71-2.83ZM25,37.27V28.94l5.94,3v8.34Z'/%3E%3Crect class='cls-2' width='70' height='70'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"
  27550. /***/ }),
  27551. /***/ "./img/icon-ibl.svg":
  27552. /*!**************************!*\
  27553. !*** ./img/icon-ibl.svg ***!
  27554. \**************************/
  27555. /*! no static exports found */
  27556. /***/ (function(module, exports) {
  27557. module.exports = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 70'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fff;%7D.cls-2%7Bfill:none;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3EEnvironmentIcon%3C/title%3E%3Cg id='Layer_2' data-name='Layer 2'%3E%3Cg id='Page_Elements' data-name='Page Elements'%3E%3Cpath class='cls-1' d='M34.89,21.24A13.19,13.19,0,1,0,48.07,34.42,13.19,13.19,0,0,0,34.89,21.24ZM34,33.43a.31.31,0,0,0,.44,0l1.13-1.14a.29.29,0,0,0,0-.32h.46a2.38,2.38,0,0,0,2.6.12l.61,0a.36.36,0,0,0,.07.17l1.14,1.14a.31.31,0,0,0,.22.09.3.3,0,0,0,.21-.09A.3.3,0,0,0,41,33l-.78-.79c3.69.41,6.21,1.23,6.21,2.18,0,1.36-5.14,2.46-11.49,2.46S23.4,35.78,23.4,34.42,28.54,32,34.89,32h.17l-1,1A.32.32,0,0,0,34,33.43Zm3.48-1.61A1.84,1.84,0,1,1,39.34,30,1.84,1.84,0,0,1,37.5,31.82Zm-2.61-8.9A11.5,11.5,0,0,1,46.35,33.54c-1.13-1-4.17-1.56-7.14-1.81A2.42,2.42,0,0,0,40,30a2.45,2.45,0,1,0-4.89,0,2.41,2.41,0,0,0,.58,1.57h-.75c-3.53,0-9.76.45-11.46,2A11.5,11.5,0,0,1,34.89,22.92Zm0,23a11.48,11.48,0,0,1-11.4-10.07c2.68,1.81,10.36,1.87,11.4,1.87s8.72-.06,11.4-1.87A11.48,11.48,0,0,1,34.89,45.92Z'/%3E%3Cpath class='cls-1' d='M37.52,27.3h0a.31.31,0,0,0,.31-.3V24.89a.3.3,0,0,0-.3-.31h0a.31.31,0,0,0-.31.31V27A.31.31,0,0,0,37.52,27.3Z'/%3E%3Cpath class='cls-1' d='M35.19,28.07a.31.31,0,0,0,.22.09.27.27,0,0,0,.21-.09.3.3,0,0,0,0-.43L34.49,26.5a.3.3,0,0,0-.43,0,.31.31,0,0,0,0,.43Z'/%3E%3Cpath class='cls-1' d='M39.63,28.19a.31.31,0,0,0,.22-.09L41,27a.3.3,0,1,0-.43-.43l-1.14,1.14a.3.3,0,0,0,0,.43A.31.31,0,0,0,39.63,28.19Z'/%3E%3Cpath class='cls-1' d='M38.6,27.4l.07,0a.19.19,0,0,0,.17-.12l.25-.61a.2.2,0,0,0-.1-.25.2.2,0,0,0-.25.11l-.25.61A.19.19,0,0,0,38.6,27.4Z'/%3E%3Cpath class='cls-1' d='M36.21,27.29a.18.18,0,0,0,.17.11l.07,0a.17.17,0,0,0,.1-.24l-.26-.61a.18.18,0,0,0-.24-.1.19.19,0,0,0-.1.24Z'/%3E%3Cpath class='cls-1' d='M34.82,28.65l-.61-.25a.18.18,0,0,0-.24.1.19.19,0,0,0,.1.24l.61.25h.07a.18.18,0,0,0,.07-.35Z'/%3E%3Cpath class='cls-1' d='M34.67,30.93l-.61.26a.18.18,0,0,0-.1.24.18.18,0,0,0,.17.11h.07l.61-.26a.18.18,0,0,0,.1-.24A.19.19,0,0,0,34.67,30.93Z'/%3E%3Cpath class='cls-1' d='M36,33.51l.07,0a.18.18,0,0,0,.17-.12l.25-.61a.18.18,0,0,0-.1-.24.18.18,0,0,0-.24.1l-.25.61A.18.18,0,0,0,36,33.51Z'/%3E%3Cpath class='cls-1' d='M38.71,33.43a.18.18,0,0,0,.17.11H39a.18.18,0,0,0,.09-.25l-.25-.61a.19.19,0,1,0-.34.15Z'/%3E%3Cpath class='cls-1' d='M40.94,31.22,40.32,31a.19.19,0,0,0-.24.1.18.18,0,0,0,.1.24l.62.25.07,0a.19.19,0,0,0,.17-.12A.19.19,0,0,0,40.94,31.22Z'/%3E%3Cpath class='cls-1' d='M40.27,29h.07l.61-.26a.18.18,0,0,0-.14-.34l-.61.26a.18.18,0,0,0-.1.24A.18.18,0,0,0,40.27,29Z'/%3E%3Cpath class='cls-1' d='M32.41,30.26h2.11a.31.31,0,1,0,0-.61H32.41a.31.31,0,0,0,0,.61Z'/%3E%3Cpath class='cls-1' d='M37.48,35.38h0a.32.32,0,0,0,.31-.31V33a.31.31,0,0,0-.31-.3h0a.3.3,0,0,0-.3.3v2.11A.31.31,0,0,0,37.48,35.38Z'/%3E%3Cpath class='cls-1' d='M40.49,29.69a.31.31,0,1,0,0,.62H42.6a.31.31,0,0,0,.3-.31.3.3,0,0,0-.3-.3Z'/%3E%3Crect class='cls-2' width='70' height='70'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"
  27558. /***/ }),
  27559. /***/ "./img/icon-open.svg":
  27560. /*!***************************!*\
  27561. !*** ./img/icon-open.svg ***!
  27562. \***************************/
  27563. /*! no static exports found */
  27564. /***/ (function(module, exports) {
  27565. module.exports = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 70'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fff;%7D.cls-2%7Bfill:none;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3EAsset 11%3C/title%3E%3Cg id='Layer_2' data-name='Layer 2'%3E%3Cg id='Page_Elements' data-name='Page Elements'%3E%3Cpath class='cls-1' d='M26.67,44.77H41.88v1.52H25.15V22H38.4l6.52,6.52v5.64H43.4V29.56H37.31V23.48H26.67ZM38.83,28h3.49l-3.49-3.48Zm8,12.13-1.93-1.92v8H43.4v-8l-1.94,1.92L40.39,39.1l3.77-3.77,3.76,3.77Z'/%3E%3Crect class='cls-2' width='70' height='70'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"
  27566. /***/ }),
  27567. /***/ "./img/icon-pause.svg":
  27568. /*!****************************!*\
  27569. !*** ./img/icon-pause.svg ***!
  27570. \****************************/
  27571. /*! no static exports found */
  27572. /***/ (function(module, exports) {
  27573. module.exports = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 70'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:none;%7D.cls-2%7Bfill:%23fff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3EPauseIcon%3C/title%3E%3Cg id='Layer_2' data-name='Layer 2'%3E%3Cg id='Redlines'%3E%3Crect class='cls-1' width='70' height='70'/%3E%3Cpath class='cls-2' d='M28.83,44.37v-20h2v20Zm10-20h2v20h-2Z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"
  27574. /***/ }),
  27575. /***/ "./img/icon-play.svg":
  27576. /*!***************************!*\
  27577. !*** ./img/icon-play.svg ***!
  27578. \***************************/
  27579. /*! no static exports found */
  27580. /***/ (function(module, exports) {
  27581. module.exports = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 70'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:none;%7D.cls-2%7Bfill:%23fff;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3EPlayIcon%3C/title%3E%3Cg id='Layer_2' data-name='Layer 2'%3E%3Cg id='Redlines'%3E%3Crect class='cls-1' width='70' height='70'/%3E%3Cpath class='cls-2' d='M28.83,25.13l16,10-16,10Zm2,3.61V41.52l10.22-6.39Z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"
  27582. /***/ }),
  27583. /***/ "./img/icon-up.svg":
  27584. /*!*************************!*\
  27585. !*** ./img/icon-up.svg ***!
  27586. \*************************/
  27587. /*! no static exports found */
  27588. /***/ (function(module, exports) {
  27589. module.exports = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 70'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fff;%7D.cls-2%7Bfill:none;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3EUpArrowIcon%3C/title%3E%3Cg id='Layer_2' data-name='Layer 2'%3E%3Cg id='Redlines'%3E%3Cpath class='cls-1' d='M34.85,29.78,24.56,40.06l-1.42-1.41L34.85,26.94l11.7,11.71-1.42,1.41Z'/%3E%3Crect class='cls-2' width='70' height='70'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"
  27590. /***/ }),
  27591. /***/ "./img/logo-fullscreen.svg":
  27592. /*!*********************************!*\
  27593. !*** ./img/logo-fullscreen.svg ***!
  27594. \*********************************/
  27595. /*! no static exports found */
  27596. /***/ (function(module, exports) {
  27597. module.exports = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 180.17 208.04'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23fff;%7D.cls-2%7Bfill:%23e0684b;%7D.cls-3%7Bfill:%23bb464b;%7D.cls-4%7Bfill:%23e0ded8;%7D.cls-5%7Bfill:%23d5d2ca;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3EBabylonLogo%3C/title%3E%3Cg id='Layer_2' data-name='Layer 2'%3E%3Cg id='Page_Elements' data-name='Page Elements'%3E%3Cpath class='cls-1' d='M90.09,0,0,52V156l90.09,52,90.08-52V52Z'/%3E%3Cpolygon class='cls-2' points='180.17 52.01 151.97 35.73 124.85 51.39 153.05 67.67 180.17 52.01'/%3E%3Cpolygon class='cls-2' points='27.12 67.67 117.21 15.66 90.08 0 0 52.01 27.12 67.67'/%3E%3Cpolygon class='cls-2' points='61.89 120.3 90.08 136.58 118.28 120.3 90.08 104.02 61.89 120.3'/%3E%3Cpolygon class='cls-3' points='153.05 67.67 153.05 140.37 90.08 176.72 27.12 140.37 27.12 67.67 0 52.01 0 156.03 90.08 208.04 180.17 156.03 180.17 52.01 153.05 67.67'/%3E%3Cpolygon class='cls-3' points='90.08 71.46 61.89 87.74 61.89 120.3 90.08 104.02 118.28 120.3 118.28 87.74 90.08 71.46'/%3E%3Cpolygon class='cls-4' points='153.05 67.67 118.28 87.74 118.28 120.3 90.08 136.58 90.08 176.72 153.05 140.37 153.05 67.67'/%3E%3Cpolygon class='cls-5' points='27.12 67.67 61.89 87.74 61.89 120.3 90.08 136.58 90.08 176.72 27.12 140.37 27.12 67.67'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"
  27598. /***/ }),
  27599. /***/ "./index.ts":
  27600. /*!******************!*\
  27601. !*** ./index.ts ***!
  27602. \******************/
  27603. /*! exports provided: Sandbox */
  27604. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27605. "use strict";
  27606. __webpack_require__.r(__webpack_exports__);
  27607. /* harmony import */ var _sandbox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sandbox */ "./sandbox.tsx");
  27608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sandbox", function() { return _sandbox__WEBPACK_IMPORTED_MODULE_0__["Sandbox"]; });
  27609. /***/ }),
  27610. /***/ "./legacy/legacy.ts":
  27611. /*!**************************!*\
  27612. !*** ./legacy/legacy.ts ***!
  27613. \**************************/
  27614. /*! exports provided: Sandbox */
  27615. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27616. "use strict";
  27617. __webpack_require__.r(__webpack_exports__);
  27618. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  27619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sandbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sandbox"]; });
  27620. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  27621. if (typeof globalObject !== "undefined") {
  27622. globalObject.BABYLON = globalObject.BABYLON || {};
  27623. globalObject.BABYLON.Sandbox = _index__WEBPACK_IMPORTED_MODULE_0__["Sandbox"];
  27624. }
  27625. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  27626. /***/ }),
  27627. /***/ "./sandbox.tsx":
  27628. /*!*********************!*\
  27629. !*** ./sandbox.tsx ***!
  27630. \*********************/
  27631. /*! exports provided: Sandbox */
  27632. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27633. "use strict";
  27634. __webpack_require__.r(__webpack_exports__);
  27635. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sandbox", function() { return Sandbox; });
  27636. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  27637. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "../../node_modules/react/index.js");
  27638. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  27639. /* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-dom */ "../../node_modules/react-dom/index.js");
  27640. /* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_dom__WEBPACK_IMPORTED_MODULE_2__);
  27641. /* harmony import */ var _globalState__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./globalState */ "./globalState.ts");
  27642. /* harmony import */ var _components_renderingZone__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./components/renderingZone */ "./components/renderingZone.tsx");
  27643. /* harmony import */ var _components_footer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./components/footer */ "./components/footer.tsx");
  27644. /* harmony import */ var _tools_environmentTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./tools/environmentTools */ "./tools/environmentTools.ts");
  27645. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  27646. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__);
  27647. __webpack_require__(/*! ./scss/main.scss */ "./scss/main.scss");
  27648. var fullScreenLogo = __webpack_require__(/*! ./img/logo-fullscreen.svg */ "./img/logo-fullscreen.svg");
  27649. var Sandbox = /** @class */ (function (_super) {
  27650. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Sandbox, _super);
  27651. function Sandbox(props) {
  27652. var _this = _super.call(this, props) || this;
  27653. _this._globalState = new _globalState__WEBPACK_IMPORTED_MODULE_3__["GlobalState"]();
  27654. _this._logoRef = react__WEBPACK_IMPORTED_MODULE_1__["createRef"]();
  27655. _this._dropTextRef = react__WEBPACK_IMPORTED_MODULE_1__["createRef"]();
  27656. _this._clickInterceptorRef = react__WEBPACK_IMPORTED_MODULE_1__["createRef"]();
  27657. _this.state = { isFooterVisible: true, errorMessage: "" };
  27658. _this.checkUrl();
  27659. _tools_environmentTools__WEBPACK_IMPORTED_MODULE_6__["EnvironmentTools"].HookWithEnvironmentChange(_this._globalState);
  27660. // Events
  27661. _this._globalState.onSceneLoaded.add(function (info) {
  27662. document.title = "Babylon.js - " + info.filename;
  27663. _this._globalState.currentScene = info.scene;
  27664. if (_this._globalState.currentScene.meshes.length === 0 && _this._globalState.currentScene.clearColor.r === 1 && _this._globalState.currentScene.clearColor.g === 0 && _this._globalState.currentScene.clearColor.b === 0) {
  27665. _this._logoRef.current.className = "";
  27666. }
  27667. else {
  27668. _this._logoRef.current.className = "hidden";
  27669. _this._dropTextRef.current.className = "hidden";
  27670. }
  27671. });
  27672. _this._globalState.onError.add(function (error) {
  27673. if (error.scene) {
  27674. _this._globalState.showDebugLayer();
  27675. }
  27676. if (error.message) {
  27677. _this.setState({ errorMessage: error.message });
  27678. }
  27679. });
  27680. _this._globalState.onRequestClickInterceptor.add(function () {
  27681. var div = _this._clickInterceptorRef.current;
  27682. if (div.classList.contains("hidden")) {
  27683. div.classList.remove("hidden");
  27684. }
  27685. else {
  27686. div.classList.add("hidden");
  27687. }
  27688. });
  27689. // Keyboard
  27690. window.addEventListener("keydown", function (event) {
  27691. // Press space to toggle footer
  27692. if (event.keyCode === 32 && event.target && event.target.nodeName !== "INPUT") {
  27693. _this.setState({ isFooterVisible: !_this.state.isFooterVisible });
  27694. }
  27695. });
  27696. return _this;
  27697. }
  27698. Sandbox.prototype.checkUrl = function () {
  27699. // Check URL
  27700. var indexOf = location.href.indexOf("?");
  27701. if (indexOf !== -1) {
  27702. var params = location.href.substr(indexOf + 1).split("&");
  27703. for (var index = 0; index < params.length; index++) {
  27704. var param = params[index].split("=");
  27705. var name = param[0];
  27706. var value = param[1];
  27707. switch (name) {
  27708. case "assetUrl": {
  27709. this._assetUrl = value;
  27710. break;
  27711. }
  27712. case "cameraPosition": {
  27713. this._cameraPosition = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_7__["Vector3"].FromArray(value.split(",").map(function (component) { return +component; }));
  27714. break;
  27715. }
  27716. case "kiosk": {
  27717. this.state = { isFooterVisible: value === "true" ? false : true, errorMessage: "" };
  27718. break;
  27719. }
  27720. }
  27721. }
  27722. }
  27723. };
  27724. Sandbox.prototype.componentDidUpdate = function () {
  27725. this._assetUrl = undefined;
  27726. this._cameraPosition = undefined;
  27727. };
  27728. Sandbox.prototype.render = function () {
  27729. var _this = this;
  27730. return (react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { id: "root" },
  27731. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("p", { id: "droptext", ref: this._dropTextRef }, "Drag and drop gltf, glb, obj or babylon files to view them"),
  27732. react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_components_renderingZone__WEBPACK_IMPORTED_MODULE_4__["RenderingZone"], { globalState: this._globalState, assetUrl: this._assetUrl, cameraPosition: this._cameraPosition, expanded: !this.state.isFooterVisible }),
  27733. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { ref: this._clickInterceptorRef, onClick: function () {
  27734. _this._globalState.onClickInterceptorClicked.notifyObservers();
  27735. _this._clickInterceptorRef.current.classList.add("hidden");
  27736. }, className: "clickInterceptor hidden" }),
  27737. this.state.isFooterVisible &&
  27738. react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_components_footer__WEBPACK_IMPORTED_MODULE_5__["Footer"], { globalState: this._globalState }),
  27739. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { id: "logoContainer" },
  27740. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("img", { id: "logo", src: fullScreenLogo, ref: this._logoRef })),
  27741. this.state.errorMessage &&
  27742. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { id: "errorZone" },
  27743. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("div", { className: "message" }, this.state.errorMessage),
  27744. react__WEBPACK_IMPORTED_MODULE_1__["createElement"]("button", { type: "button", className: "close", onClick: function () { return _this.setState({ errorMessage: "" }); }, "data-dismiss": "alert" }, "\u00D7"))));
  27745. };
  27746. Sandbox.Show = function (hostElement) {
  27747. var sandBox = react__WEBPACK_IMPORTED_MODULE_1__["createElement"](Sandbox, {});
  27748. react_dom__WEBPACK_IMPORTED_MODULE_2__["render"](sandBox, hostElement);
  27749. };
  27750. return Sandbox;
  27751. }(react__WEBPACK_IMPORTED_MODULE_1__["Component"]));
  27752. /***/ }),
  27753. /***/ "./scss/animationBar.scss":
  27754. /*!********************************!*\
  27755. !*** ./scss/animationBar.scss ***!
  27756. \********************************/
  27757. /*! no static exports found */
  27758. /***/ (function(module, exports, __webpack_require__) {
  27759. var content = __webpack_require__(/*! !../../../node_modules/css-loader!../../../node_modules/sass-loader/dist/cjs.js!./animationBar.scss */ "../../node_modules/css-loader/index.js!../../node_modules/sass-loader/dist/cjs.js!./scss/animationBar.scss");
  27760. if(typeof content === 'string') content = [[module.i, content, '']];
  27761. var transform;
  27762. var insertInto;
  27763. var options = {"hmr":true}
  27764. options.transform = transform
  27765. options.insertInto = undefined;
  27766. var update = __webpack_require__(/*! ../../../node_modules/style-loader/lib/addStyles.js */ "../../node_modules/style-loader/lib/addStyles.js")(content, options);
  27767. if(content.locals) module.exports = content.locals;
  27768. if(false) {}
  27769. /***/ }),
  27770. /***/ "./scss/footer.scss":
  27771. /*!**************************!*\
  27772. !*** ./scss/footer.scss ***!
  27773. \**************************/
  27774. /*! no static exports found */
  27775. /***/ (function(module, exports, __webpack_require__) {
  27776. var content = __webpack_require__(/*! !../../../node_modules/css-loader!../../../node_modules/sass-loader/dist/cjs.js!./footer.scss */ "../../node_modules/css-loader/index.js!../../node_modules/sass-loader/dist/cjs.js!./scss/footer.scss");
  27777. if(typeof content === 'string') content = [[module.i, content, '']];
  27778. var transform;
  27779. var insertInto;
  27780. var options = {"hmr":true}
  27781. options.transform = transform
  27782. options.insertInto = undefined;
  27783. var update = __webpack_require__(/*! ../../../node_modules/style-loader/lib/addStyles.js */ "../../node_modules/style-loader/lib/addStyles.js")(content, options);
  27784. if(content.locals) module.exports = content.locals;
  27785. if(false) {}
  27786. /***/ }),
  27787. /***/ "./scss/main.scss":
  27788. /*!************************!*\
  27789. !*** ./scss/main.scss ***!
  27790. \************************/
  27791. /*! no static exports found */
  27792. /***/ (function(module, exports, __webpack_require__) {
  27793. var content = __webpack_require__(/*! !../../../node_modules/css-loader!../../../node_modules/sass-loader/dist/cjs.js!./main.scss */ "../../node_modules/css-loader/index.js!../../node_modules/sass-loader/dist/cjs.js!./scss/main.scss");
  27794. if(typeof content === 'string') content = [[module.i, content, '']];
  27795. var transform;
  27796. var insertInto;
  27797. var options = {"hmr":true}
  27798. options.transform = transform
  27799. options.insertInto = undefined;
  27800. var update = __webpack_require__(/*! ../../../node_modules/style-loader/lib/addStyles.js */ "../../node_modules/style-loader/lib/addStyles.js")(content, options);
  27801. if(content.locals) module.exports = content.locals;
  27802. if(false) {}
  27803. /***/ }),
  27804. /***/ "./scss/renderingZone.scss":
  27805. /*!*********************************!*\
  27806. !*** ./scss/renderingZone.scss ***!
  27807. \*********************************/
  27808. /*! no static exports found */
  27809. /***/ (function(module, exports, __webpack_require__) {
  27810. var content = __webpack_require__(/*! !../../../node_modules/css-loader!../../../node_modules/sass-loader/dist/cjs.js!./renderingZone.scss */ "../../node_modules/css-loader/index.js!../../node_modules/sass-loader/dist/cjs.js!./scss/renderingZone.scss");
  27811. if(typeof content === 'string') content = [[module.i, content, '']];
  27812. var transform;
  27813. var insertInto;
  27814. var options = {"hmr":true}
  27815. options.transform = transform
  27816. options.insertInto = undefined;
  27817. var update = __webpack_require__(/*! ../../../node_modules/style-loader/lib/addStyles.js */ "../../node_modules/style-loader/lib/addStyles.js")(content, options);
  27818. if(content.locals) module.exports = content.locals;
  27819. if(false) {}
  27820. /***/ }),
  27821. /***/ "./tools/environmentTools.ts":
  27822. /*!***********************************!*\
  27823. !*** ./tools/environmentTools.ts ***!
  27824. \***********************************/
  27825. /*! exports provided: EnvironmentTools */
  27826. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27827. "use strict";
  27828. __webpack_require__.r(__webpack_exports__);
  27829. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTools", function() { return EnvironmentTools; });
  27830. /* harmony import */ var babylonjs_Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/Textures/hdrCubeTexture */ "babylonjs/Maths/math.vector");
  27831. /* harmony import */ var babylonjs_Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_0__);
  27832. /* harmony import */ var _localStorageHelper__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./localStorageHelper */ "./tools/localStorageHelper.ts");
  27833. var EnvironmentTools = /** @class */ (function () {
  27834. function EnvironmentTools() {
  27835. }
  27836. EnvironmentTools.LoadSkyboxPathTexture = function (scene) {
  27837. var defaultSkyboxIndex = Math.max(0, _localStorageHelper__WEBPACK_IMPORTED_MODULE_1__["LocalStorageHelper"].ReadLocalStorageValue("defaultSkyboxId", 0));
  27838. var path = this.SkyboxPath || this.Skyboxes[defaultSkyboxIndex];
  27839. if (path.indexOf(".hdr") === (path.length - 4)) {
  27840. return new babylonjs_Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"](path, scene, 256, false, true, false, true);
  27841. }
  27842. return babylonjs_Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"].CreateFromPrefilteredData(path, scene);
  27843. };
  27844. EnvironmentTools.HookWithEnvironmentChange = function (globalState) {
  27845. var _this = this;
  27846. globalState.onEnvironmentChanged.add(function (option) {
  27847. _this.SkyboxPath = "";
  27848. var index = EnvironmentTools.SkyboxesNames.indexOf(option);
  27849. if (typeof (Storage) !== "undefined") {
  27850. localStorage.setItem("defaultSkyboxId", index.toString());
  27851. }
  27852. var currentScene = babylonjs_Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_0__["Engine"].LastCreatedScene;
  27853. currentScene.environmentTexture = _this.LoadSkyboxPathTexture(currentScene);
  27854. for (var i = 0; i < currentScene.materials.length; i++) {
  27855. var material = currentScene.materials[i];
  27856. if (material.name === "skyBox") {
  27857. var reflectionTexture = material.reflectionTexture;
  27858. if (reflectionTexture && reflectionTexture.coordinatesMode === babylonjs_Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_0__["Texture"].SKYBOX_MODE) {
  27859. material.reflectionTexture = currentScene.environmentTexture.clone();
  27860. if (material.reflectionTexture) {
  27861. material.reflectionTexture.coordinatesMode = babylonjs_Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_0__["Texture"].SKYBOX_MODE;
  27862. }
  27863. }
  27864. }
  27865. }
  27866. });
  27867. };
  27868. EnvironmentTools.SkyboxPath = "";
  27869. EnvironmentTools.Skyboxes = [
  27870. "https://assets.babylonjs.com/environments/environmentSpecular.env",
  27871. "https://assets.babylonjs.com/environments/studio.env",
  27872. ];
  27873. EnvironmentTools.SkyboxesNames = [
  27874. "Default",
  27875. "Studio",
  27876. ];
  27877. return EnvironmentTools;
  27878. }());
  27879. /***/ }),
  27880. /***/ "./tools/localStorageHelper.ts":
  27881. /*!*************************************!*\
  27882. !*** ./tools/localStorageHelper.ts ***!
  27883. \*************************************/
  27884. /*! exports provided: LocalStorageHelper */
  27885. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27886. "use strict";
  27887. __webpack_require__.r(__webpack_exports__);
  27888. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LocalStorageHelper", function() { return LocalStorageHelper; });
  27889. var LocalStorageHelper = /** @class */ (function () {
  27890. function LocalStorageHelper() {
  27891. }
  27892. LocalStorageHelper.ReadLocalStorageValue = function (key, defaultValue) {
  27893. if (typeof (Storage) !== "undefined" && localStorage.getItem(key) !== null) {
  27894. return parseInt(localStorage.getItem(key));
  27895. }
  27896. return defaultValue;
  27897. };
  27898. return LocalStorageHelper;
  27899. }());
  27900. /***/ }),
  27901. /***/ "babylonjs-loaders/glTF/glTFFileLoader":
  27902. /*!****************************************************************************************************************************!*\
  27903. !*** external {"root":"BABYLON","commonjs":"babylonjs-loaders","commonjs2":"babylonjs-loaders","amd":"babylonjs-loaders"} ***!
  27904. \****************************************************************************************************************************/
  27905. /*! no static exports found */
  27906. /***/ (function(module, exports) {
  27907. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_loaders_glTF_glTFFileLoader__;
  27908. /***/ }),
  27909. /***/ "babylonjs/Maths/math.vector":
  27910. /*!****************************************************************************************************!*\
  27911. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  27912. \****************************************************************************************************/
  27913. /*! no static exports found */
  27914. /***/ (function(module, exports) {
  27915. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math_vector__;
  27916. /***/ })
  27917. /******/ });
  27918. });
  27919. //# sourceMappingURL=babylon.sandbox.max.js.map