react-dom.development.js 874 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262
  1. /** @license React v17.0.2
  2. * react-dom.development.js
  3. *
  4. * Copyright (c) Facebook, Inc. and its affiliates.
  5. *
  6. * This source code is licensed under the MIT license found in the
  7. * LICENSE file in the root directory of this source tree.
  8. */
  9. 'use strict';
  10. if (process.env.NODE_ENV !== "production") {
  11. (function() {
  12. 'use strict';
  13. var React = require('react');
  14. var _assign = require('object-assign');
  15. var Scheduler = require('scheduler');
  16. var tracing = require('scheduler/tracing');
  17. var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
  18. // by calls to these methods by a Babel plugin.
  19. //
  20. // In PROD (or in packages without access to React internals),
  21. // they are left as they are instead.
  22. function warn(format) {
  23. {
  24. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  25. args[_key - 1] = arguments[_key];
  26. }
  27. printWarning('warn', format, args);
  28. }
  29. }
  30. function error(format) {
  31. {
  32. for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  33. args[_key2 - 1] = arguments[_key2];
  34. }
  35. printWarning('error', format, args);
  36. }
  37. }
  38. function printWarning(level, format, args) {
  39. // When changing this logic, you might want to also
  40. // update consoleWithStackDev.www.js as well.
  41. {
  42. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  43. var stack = ReactDebugCurrentFrame.getStackAddendum();
  44. if (stack !== '') {
  45. format += '%s';
  46. args = args.concat([stack]);
  47. }
  48. var argsWithFormat = args.map(function (item) {
  49. return '' + item;
  50. }); // Careful: RN currently depends on this prefix
  51. argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
  52. // breaks IE9: https://github.com/facebook/react/issues/13610
  53. // eslint-disable-next-line react-internal/no-production-logging
  54. Function.prototype.apply.call(console[level], console, argsWithFormat);
  55. }
  56. }
  57. if (!React) {
  58. {
  59. throw Error( "ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM." );
  60. }
  61. }
  62. var FunctionComponent = 0;
  63. var ClassComponent = 1;
  64. var IndeterminateComponent = 2; // Before we know whether it is function or class
  65. var HostRoot = 3; // Root of a host tree. Could be nested inside another node.
  66. var HostPortal = 4; // A subtree. Could be an entry point to a different renderer.
  67. var HostComponent = 5;
  68. var HostText = 6;
  69. var Fragment = 7;
  70. var Mode = 8;
  71. var ContextConsumer = 9;
  72. var ContextProvider = 10;
  73. var ForwardRef = 11;
  74. var Profiler = 12;
  75. var SuspenseComponent = 13;
  76. var MemoComponent = 14;
  77. var SimpleMemoComponent = 15;
  78. var LazyComponent = 16;
  79. var IncompleteClassComponent = 17;
  80. var DehydratedFragment = 18;
  81. var SuspenseListComponent = 19;
  82. var FundamentalComponent = 20;
  83. var ScopeComponent = 21;
  84. var Block = 22;
  85. var OffscreenComponent = 23;
  86. var LegacyHiddenComponent = 24;
  87. // Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
  88. var enableProfilerTimer = true; // Record durations for commit and passive effects phases.
  89. var enableFundamentalAPI = false; // Experimental Scope support.
  90. var enableNewReconciler = false; // Errors that are thrown while unmounting (or after in the case of passive effects)
  91. var warnAboutStringRefs = false;
  92. var allNativeEvents = new Set();
  93. /**
  94. * Mapping from registration name to event name
  95. */
  96. var registrationNameDependencies = {};
  97. /**
  98. * Mapping from lowercase registration names to the properly cased version,
  99. * used to warn in the case of missing event handlers. Available
  100. * only in true.
  101. * @type {Object}
  102. */
  103. var possibleRegistrationNames = {} ; // Trust the developer to only use possibleRegistrationNames in true
  104. function registerTwoPhaseEvent(registrationName, dependencies) {
  105. registerDirectEvent(registrationName, dependencies);
  106. registerDirectEvent(registrationName + 'Capture', dependencies);
  107. }
  108. function registerDirectEvent(registrationName, dependencies) {
  109. {
  110. if (registrationNameDependencies[registrationName]) {
  111. error('EventRegistry: More than one plugin attempted to publish the same ' + 'registration name, `%s`.', registrationName);
  112. }
  113. }
  114. registrationNameDependencies[registrationName] = dependencies;
  115. {
  116. var lowerCasedName = registrationName.toLowerCase();
  117. possibleRegistrationNames[lowerCasedName] = registrationName;
  118. if (registrationName === 'onDoubleClick') {
  119. possibleRegistrationNames.ondblclick = registrationName;
  120. }
  121. }
  122. for (var i = 0; i < dependencies.length; i++) {
  123. allNativeEvents.add(dependencies[i]);
  124. }
  125. }
  126. var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
  127. // A reserved attribute.
  128. // It is handled by React separately and shouldn't be written to the DOM.
  129. var RESERVED = 0; // A simple string attribute.
  130. // Attributes that aren't in the filter are presumed to have this type.
  131. var STRING = 1; // A string attribute that accepts booleans in React. In HTML, these are called
  132. // "enumerated" attributes with "true" and "false" as possible values.
  133. // When true, it should be set to a "true" string.
  134. // When false, it should be set to a "false" string.
  135. var BOOLEANISH_STRING = 2; // A real boolean attribute.
  136. // When true, it should be present (set either to an empty string or its name).
  137. // When false, it should be omitted.
  138. var BOOLEAN = 3; // An attribute that can be used as a flag as well as with a value.
  139. // When true, it should be present (set either to an empty string or its name).
  140. // When false, it should be omitted.
  141. // For any other value, should be present with that value.
  142. var OVERLOADED_BOOLEAN = 4; // An attribute that must be numeric or parse as a numeric.
  143. // When falsy, it should be removed.
  144. var NUMERIC = 5; // An attribute that must be positive numeric or parse as a positive numeric.
  145. // When falsy, it should be removed.
  146. var POSITIVE_NUMERIC = 6;
  147. /* eslint-disable max-len */
  148. 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";
  149. /* eslint-enable max-len */
  150. var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
  151. var ROOT_ATTRIBUTE_NAME = 'data-reactroot';
  152. var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$');
  153. var hasOwnProperty = Object.prototype.hasOwnProperty;
  154. var illegalAttributeNameCache = {};
  155. var validatedAttributeNameCache = {};
  156. function isAttributeNameSafe(attributeName) {
  157. if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) {
  158. return true;
  159. }
  160. if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) {
  161. return false;
  162. }
  163. if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
  164. validatedAttributeNameCache[attributeName] = true;
  165. return true;
  166. }
  167. illegalAttributeNameCache[attributeName] = true;
  168. {
  169. error('Invalid attribute name: `%s`', attributeName);
  170. }
  171. return false;
  172. }
  173. function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) {
  174. if (propertyInfo !== null) {
  175. return propertyInfo.type === RESERVED;
  176. }
  177. if (isCustomComponentTag) {
  178. return false;
  179. }
  180. if (name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) {
  181. return true;
  182. }
  183. return false;
  184. }
  185. function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) {
  186. if (propertyInfo !== null && propertyInfo.type === RESERVED) {
  187. return false;
  188. }
  189. switch (typeof value) {
  190. case 'function': // $FlowIssue symbol is perfectly valid here
  191. case 'symbol':
  192. // eslint-disable-line
  193. return true;
  194. case 'boolean':
  195. {
  196. if (isCustomComponentTag) {
  197. return false;
  198. }
  199. if (propertyInfo !== null) {
  200. return !propertyInfo.acceptsBooleans;
  201. } else {
  202. var prefix = name.toLowerCase().slice(0, 5);
  203. return prefix !== 'data-' && prefix !== 'aria-';
  204. }
  205. }
  206. default:
  207. return false;
  208. }
  209. }
  210. function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) {
  211. if (value === null || typeof value === 'undefined') {
  212. return true;
  213. }
  214. if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) {
  215. return true;
  216. }
  217. if (isCustomComponentTag) {
  218. return false;
  219. }
  220. if (propertyInfo !== null) {
  221. switch (propertyInfo.type) {
  222. case BOOLEAN:
  223. return !value;
  224. case OVERLOADED_BOOLEAN:
  225. return value === false;
  226. case NUMERIC:
  227. return isNaN(value);
  228. case POSITIVE_NUMERIC:
  229. return isNaN(value) || value < 1;
  230. }
  231. }
  232. return false;
  233. }
  234. function getPropertyInfo(name) {
  235. return properties.hasOwnProperty(name) ? properties[name] : null;
  236. }
  237. function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL, removeEmptyString) {
  238. this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN;
  239. this.attributeName = attributeName;
  240. this.attributeNamespace = attributeNamespace;
  241. this.mustUseProperty = mustUseProperty;
  242. this.propertyName = name;
  243. this.type = type;
  244. this.sanitizeURL = sanitizeURL;
  245. this.removeEmptyString = removeEmptyString;
  246. } // When adding attributes to this list, be sure to also add them to
  247. // the `possibleStandardNames` module to ensure casing and incorrect
  248. // name warnings.
  249. var properties = {}; // These props are reserved by React. They shouldn't be written to the DOM.
  250. var reservedProps = ['children', 'dangerouslySetInnerHTML', // TODO: This prevents the assignment of defaultValue to regular
  251. // elements (not just inputs). Now that ReactDOMInput assigns to the
  252. // defaultValue property -- do we need this?
  253. 'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style'];
  254. reservedProps.forEach(function (name) {
  255. properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty
  256. name, // attributeName
  257. null, // attributeNamespace
  258. false, // sanitizeURL
  259. false);
  260. }); // A few React string attributes have a different name.
  261. // This is a mapping from React prop names to the attribute names.
  262. [['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) {
  263. var name = _ref[0],
  264. attributeName = _ref[1];
  265. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  266. attributeName, // attributeName
  267. null, // attributeNamespace
  268. false, // sanitizeURL
  269. false);
  270. }); // These are "enumerated" HTML attributes that accept "true" and "false".
  271. // In React, we let users pass `true` and `false` even though technically
  272. // these aren't boolean attributes (they are coerced to strings).
  273. ['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) {
  274. properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
  275. name.toLowerCase(), // attributeName
  276. null, // attributeNamespace
  277. false, // sanitizeURL
  278. false);
  279. }); // These are "enumerated" SVG attributes that accept "true" and "false".
  280. // In React, we let users pass `true` and `false` even though technically
  281. // these aren't boolean attributes (they are coerced to strings).
  282. // Since these are SVG attributes, their attribute names are case-sensitive.
  283. ['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) {
  284. properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
  285. name, // attributeName
  286. null, // attributeNamespace
  287. false, // sanitizeURL
  288. false);
  289. }); // These are HTML boolean attributes.
  290. ['allowFullScreen', 'async', // Note: there is a special case that prevents it from being written to the DOM
  291. // on the client side because the browsers are inconsistent. Instead we call focus().
  292. 'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'disableRemotePlayback', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', // Microdata
  293. 'itemScope'].forEach(function (name) {
  294. properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty
  295. name.toLowerCase(), // attributeName
  296. null, // attributeNamespace
  297. false, // sanitizeURL
  298. false);
  299. }); // These are the few React props that we set as DOM properties
  300. // rather than attributes. These are all booleans.
  301. ['checked', // Note: `option.selected` is not updated if `select.multiple` is
  302. // disabled with `removeAttribute`. We have special logic for handling this.
  303. 'multiple', 'muted', 'selected' // NOTE: if you add a camelCased prop to this list,
  304. // you'll need to set attributeName to name.toLowerCase()
  305. // instead in the assignment below.
  306. ].forEach(function (name) {
  307. properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty
  308. name, // attributeName
  309. null, // attributeNamespace
  310. false, // sanitizeURL
  311. false);
  312. }); // These are HTML attributes that are "overloaded booleans": they behave like
  313. // booleans, but can also accept a string value.
  314. ['capture', 'download' // NOTE: if you add a camelCased prop to this list,
  315. // you'll need to set attributeName to name.toLowerCase()
  316. // instead in the assignment below.
  317. ].forEach(function (name) {
  318. properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty
  319. name, // attributeName
  320. null, // attributeNamespace
  321. false, // sanitizeURL
  322. false);
  323. }); // These are HTML attributes that must be positive numbers.
  324. ['cols', 'rows', 'size', 'span' // NOTE: if you add a camelCased prop to this list,
  325. // you'll need to set attributeName to name.toLowerCase()
  326. // instead in the assignment below.
  327. ].forEach(function (name) {
  328. properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty
  329. name, // attributeName
  330. null, // attributeNamespace
  331. false, // sanitizeURL
  332. false);
  333. }); // These are HTML attributes that must be numbers.
  334. ['rowSpan', 'start'].forEach(function (name) {
  335. properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty
  336. name.toLowerCase(), // attributeName
  337. null, // attributeNamespace
  338. false, // sanitizeURL
  339. false);
  340. });
  341. var CAMELIZE = /[\-\:]([a-z])/g;
  342. var capitalize = function (token) {
  343. return token[1].toUpperCase();
  344. }; // This is a list of all SVG attributes that need special casing, namespacing,
  345. // or boolean value assignment. Regular attributes that just accept strings
  346. // and have the same names are omitted, just like in the HTML attribute filter.
  347. // Some of these attributes can be hard to find. This list was created by
  348. // scraping the MDN documentation.
  349. ['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' // NOTE: if you add a camelCased prop to this list,
  350. // you'll need to set attributeName to name.toLowerCase()
  351. // instead in the assignment below.
  352. ].forEach(function (attributeName) {
  353. var name = attributeName.replace(CAMELIZE, capitalize);
  354. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  355. attributeName, null, // attributeNamespace
  356. false, // sanitizeURL
  357. false);
  358. }); // String SVG attributes with the xlink namespace.
  359. ['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type' // NOTE: if you add a camelCased prop to this list,
  360. // you'll need to set attributeName to name.toLowerCase()
  361. // instead in the assignment below.
  362. ].forEach(function (attributeName) {
  363. var name = attributeName.replace(CAMELIZE, capitalize);
  364. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  365. attributeName, 'http://www.w3.org/1999/xlink', false, // sanitizeURL
  366. false);
  367. }); // String SVG attributes with the xml namespace.
  368. ['xml:base', 'xml:lang', 'xml:space' // NOTE: if you add a camelCased prop to this list,
  369. // you'll need to set attributeName to name.toLowerCase()
  370. // instead in the assignment below.
  371. ].forEach(function (attributeName) {
  372. var name = attributeName.replace(CAMELIZE, capitalize);
  373. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  374. attributeName, 'http://www.w3.org/XML/1998/namespace', false, // sanitizeURL
  375. false);
  376. }); // These attribute exists both in HTML and SVG.
  377. // The attribute name is case-sensitive in SVG so we can't just use
  378. // the React name like we do for attributes that exist only in HTML.
  379. ['tabIndex', 'crossOrigin'].forEach(function (attributeName) {
  380. properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
  381. attributeName.toLowerCase(), // attributeName
  382. null, // attributeNamespace
  383. false, // sanitizeURL
  384. false);
  385. }); // These attributes accept URLs. These must not allow javascript: URLS.
  386. // These will also need to accept Trusted Types object in the future.
  387. var xlinkHref = 'xlinkHref';
  388. properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty
  389. 'xlink:href', 'http://www.w3.org/1999/xlink', true, // sanitizeURL
  390. false);
  391. ['src', 'href', 'action', 'formAction'].forEach(function (attributeName) {
  392. properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
  393. attributeName.toLowerCase(), // attributeName
  394. null, // attributeNamespace
  395. true, // sanitizeURL
  396. true);
  397. });
  398. // and any newline or tab are filtered out as if they're not part of the URL.
  399. // https://url.spec.whatwg.org/#url-parsing
  400. // Tab or newline are defined as \r\n\t:
  401. // https://infra.spec.whatwg.org/#ascii-tab-or-newline
  402. // A C0 control is a code point in the range \u0000 NULL to \u001F
  403. // INFORMATION SEPARATOR ONE, inclusive:
  404. // https://infra.spec.whatwg.org/#c0-control-or-space
  405. /* eslint-disable max-len */
  406. 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;
  407. var didWarn = false;
  408. function sanitizeURL(url) {
  409. {
  410. if (!didWarn && isJavaScriptProtocol.test(url)) {
  411. didWarn = true;
  412. error('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));
  413. }
  414. }
  415. }
  416. /**
  417. * Get the value for a property on a node. Only used in DEV for SSR validation.
  418. * The "expected" argument is used as a hint of what the expected value is.
  419. * Some properties have multiple equivalent values.
  420. */
  421. function getValueForProperty(node, name, expected, propertyInfo) {
  422. {
  423. if (propertyInfo.mustUseProperty) {
  424. var propertyName = propertyInfo.propertyName;
  425. return node[propertyName];
  426. } else {
  427. if ( propertyInfo.sanitizeURL) {
  428. // If we haven't fully disabled javascript: URLs, and if
  429. // the hydration is successful of a javascript: URL, we
  430. // still want to warn on the client.
  431. sanitizeURL('' + expected);
  432. }
  433. var attributeName = propertyInfo.attributeName;
  434. var stringValue = null;
  435. if (propertyInfo.type === OVERLOADED_BOOLEAN) {
  436. if (node.hasAttribute(attributeName)) {
  437. var value = node.getAttribute(attributeName);
  438. if (value === '') {
  439. return true;
  440. }
  441. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  442. return value;
  443. }
  444. if (value === '' + expected) {
  445. return expected;
  446. }
  447. return value;
  448. }
  449. } else if (node.hasAttribute(attributeName)) {
  450. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  451. // We had an attribute but shouldn't have had one, so read it
  452. // for the error message.
  453. return node.getAttribute(attributeName);
  454. }
  455. if (propertyInfo.type === BOOLEAN) {
  456. // If this was a boolean, it doesn't matter what the value is
  457. // the fact that we have it is the same as the expected.
  458. return expected;
  459. } // Even if this property uses a namespace we use getAttribute
  460. // because we assume its namespaced name is the same as our config.
  461. // To use getAttributeNS we need the local name which we don't have
  462. // in our config atm.
  463. stringValue = node.getAttribute(attributeName);
  464. }
  465. if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
  466. return stringValue === null ? expected : stringValue;
  467. } else if (stringValue === '' + expected) {
  468. return expected;
  469. } else {
  470. return stringValue;
  471. }
  472. }
  473. }
  474. }
  475. /**
  476. * Get the value for a attribute on a node. Only used in DEV for SSR validation.
  477. * The third argument is used as a hint of what the expected value is. Some
  478. * attributes have multiple equivalent values.
  479. */
  480. function getValueForAttribute(node, name, expected) {
  481. {
  482. if (!isAttributeNameSafe(name)) {
  483. return;
  484. } // If the object is an opaque reference ID, it's expected that
  485. // the next prop is different than the server value, so just return
  486. // expected
  487. if (isOpaqueHydratingObject(expected)) {
  488. return expected;
  489. }
  490. if (!node.hasAttribute(name)) {
  491. return expected === undefined ? undefined : null;
  492. }
  493. var value = node.getAttribute(name);
  494. if (value === '' + expected) {
  495. return expected;
  496. }
  497. return value;
  498. }
  499. }
  500. /**
  501. * Sets the value for a property on a node.
  502. *
  503. * @param {DOMElement} node
  504. * @param {string} name
  505. * @param {*} value
  506. */
  507. function setValueForProperty(node, name, value, isCustomComponentTag) {
  508. var propertyInfo = getPropertyInfo(name);
  509. if (shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag)) {
  510. return;
  511. }
  512. if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) {
  513. value = null;
  514. } // If the prop isn't in the special list, treat it as a simple attribute.
  515. if (isCustomComponentTag || propertyInfo === null) {
  516. if (isAttributeNameSafe(name)) {
  517. var _attributeName = name;
  518. if (value === null) {
  519. node.removeAttribute(_attributeName);
  520. } else {
  521. node.setAttribute(_attributeName, '' + value);
  522. }
  523. }
  524. return;
  525. }
  526. var mustUseProperty = propertyInfo.mustUseProperty;
  527. if (mustUseProperty) {
  528. var propertyName = propertyInfo.propertyName;
  529. if (value === null) {
  530. var type = propertyInfo.type;
  531. node[propertyName] = type === BOOLEAN ? false : '';
  532. } else {
  533. // Contrary to `setAttribute`, object properties are properly
  534. // `toString`ed by IE8/9.
  535. node[propertyName] = value;
  536. }
  537. return;
  538. } // The rest are treated as attributes with special cases.
  539. var attributeName = propertyInfo.attributeName,
  540. attributeNamespace = propertyInfo.attributeNamespace;
  541. if (value === null) {
  542. node.removeAttribute(attributeName);
  543. } else {
  544. var _type = propertyInfo.type;
  545. var attributeValue;
  546. if (_type === BOOLEAN || _type === OVERLOADED_BOOLEAN && value === true) {
  547. // If attribute type is boolean, we know for sure it won't be an execution sink
  548. // and we won't require Trusted Type here.
  549. attributeValue = '';
  550. } else {
  551. // `setAttribute` with objects becomes only `[object]` in IE8/9,
  552. // ('' + value) makes it output the correct toString()-value.
  553. {
  554. attributeValue = '' + value;
  555. }
  556. if (propertyInfo.sanitizeURL) {
  557. sanitizeURL(attributeValue.toString());
  558. }
  559. }
  560. if (attributeNamespace) {
  561. node.setAttributeNS(attributeNamespace, attributeName, attributeValue);
  562. } else {
  563. node.setAttribute(attributeName, attributeValue);
  564. }
  565. }
  566. }
  567. // ATTENTION
  568. // When adding new symbols to this file,
  569. // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
  570. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  571. // nor polyfill, then a plain number is used for performance.
  572. var REACT_ELEMENT_TYPE = 0xeac7;
  573. var REACT_PORTAL_TYPE = 0xeaca;
  574. var REACT_FRAGMENT_TYPE = 0xeacb;
  575. var REACT_STRICT_MODE_TYPE = 0xeacc;
  576. var REACT_PROFILER_TYPE = 0xead2;
  577. var REACT_PROVIDER_TYPE = 0xeacd;
  578. var REACT_CONTEXT_TYPE = 0xeace;
  579. var REACT_FORWARD_REF_TYPE = 0xead0;
  580. var REACT_SUSPENSE_TYPE = 0xead1;
  581. var REACT_SUSPENSE_LIST_TYPE = 0xead8;
  582. var REACT_MEMO_TYPE = 0xead3;
  583. var REACT_LAZY_TYPE = 0xead4;
  584. var REACT_BLOCK_TYPE = 0xead9;
  585. var REACT_SERVER_BLOCK_TYPE = 0xeada;
  586. var REACT_FUNDAMENTAL_TYPE = 0xead5;
  587. var REACT_SCOPE_TYPE = 0xead7;
  588. var REACT_OPAQUE_ID_TYPE = 0xeae0;
  589. var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
  590. var REACT_OFFSCREEN_TYPE = 0xeae2;
  591. var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
  592. if (typeof Symbol === 'function' && Symbol.for) {
  593. var symbolFor = Symbol.for;
  594. REACT_ELEMENT_TYPE = symbolFor('react.element');
  595. REACT_PORTAL_TYPE = symbolFor('react.portal');
  596. REACT_FRAGMENT_TYPE = symbolFor('react.fragment');
  597. REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
  598. REACT_PROFILER_TYPE = symbolFor('react.profiler');
  599. REACT_PROVIDER_TYPE = symbolFor('react.provider');
  600. REACT_CONTEXT_TYPE = symbolFor('react.context');
  601. REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
  602. REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
  603. REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
  604. REACT_MEMO_TYPE = symbolFor('react.memo');
  605. REACT_LAZY_TYPE = symbolFor('react.lazy');
  606. REACT_BLOCK_TYPE = symbolFor('react.block');
  607. REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
  608. REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
  609. REACT_SCOPE_TYPE = symbolFor('react.scope');
  610. REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
  611. REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
  612. REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
  613. REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
  614. }
  615. var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  616. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  617. function getIteratorFn(maybeIterable) {
  618. if (maybeIterable === null || typeof maybeIterable !== 'object') {
  619. return null;
  620. }
  621. var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
  622. if (typeof maybeIterator === 'function') {
  623. return maybeIterator;
  624. }
  625. return null;
  626. }
  627. // Helpers to patch console.logs to avoid logging during side-effect free
  628. // replaying on render function. This currently only patches the object
  629. // lazily which won't cover if the log function was extracted eagerly.
  630. // We could also eagerly patch the method.
  631. var disabledDepth = 0;
  632. var prevLog;
  633. var prevInfo;
  634. var prevWarn;
  635. var prevError;
  636. var prevGroup;
  637. var prevGroupCollapsed;
  638. var prevGroupEnd;
  639. function disabledLog() {}
  640. disabledLog.__reactDisabledLog = true;
  641. function disableLogs() {
  642. {
  643. if (disabledDepth === 0) {
  644. /* eslint-disable react-internal/no-production-logging */
  645. prevLog = console.log;
  646. prevInfo = console.info;
  647. prevWarn = console.warn;
  648. prevError = console.error;
  649. prevGroup = console.group;
  650. prevGroupCollapsed = console.groupCollapsed;
  651. prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
  652. var props = {
  653. configurable: true,
  654. enumerable: true,
  655. value: disabledLog,
  656. writable: true
  657. }; // $FlowFixMe Flow thinks console is immutable.
  658. Object.defineProperties(console, {
  659. info: props,
  660. log: props,
  661. warn: props,
  662. error: props,
  663. group: props,
  664. groupCollapsed: props,
  665. groupEnd: props
  666. });
  667. /* eslint-enable react-internal/no-production-logging */
  668. }
  669. disabledDepth++;
  670. }
  671. }
  672. function reenableLogs() {
  673. {
  674. disabledDepth--;
  675. if (disabledDepth === 0) {
  676. /* eslint-disable react-internal/no-production-logging */
  677. var props = {
  678. configurable: true,
  679. enumerable: true,
  680. writable: true
  681. }; // $FlowFixMe Flow thinks console is immutable.
  682. Object.defineProperties(console, {
  683. log: _assign({}, props, {
  684. value: prevLog
  685. }),
  686. info: _assign({}, props, {
  687. value: prevInfo
  688. }),
  689. warn: _assign({}, props, {
  690. value: prevWarn
  691. }),
  692. error: _assign({}, props, {
  693. value: prevError
  694. }),
  695. group: _assign({}, props, {
  696. value: prevGroup
  697. }),
  698. groupCollapsed: _assign({}, props, {
  699. value: prevGroupCollapsed
  700. }),
  701. groupEnd: _assign({}, props, {
  702. value: prevGroupEnd
  703. })
  704. });
  705. /* eslint-enable react-internal/no-production-logging */
  706. }
  707. if (disabledDepth < 0) {
  708. error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
  709. }
  710. }
  711. }
  712. var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
  713. var prefix;
  714. function describeBuiltInComponentFrame(name, source, ownerFn) {
  715. {
  716. if (prefix === undefined) {
  717. // Extract the VM specific prefix used by each line.
  718. try {
  719. throw Error();
  720. } catch (x) {
  721. var match = x.stack.trim().match(/\n( *(at )?)/);
  722. prefix = match && match[1] || '';
  723. }
  724. } // We use the prefix to ensure our stacks line up with native stack frames.
  725. return '\n' + prefix + name;
  726. }
  727. }
  728. var reentry = false;
  729. var componentFrameCache;
  730. {
  731. var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
  732. componentFrameCache = new PossiblyWeakMap();
  733. }
  734. function describeNativeComponentFrame(fn, construct) {
  735. // If something asked for a stack inside a fake render, it should get ignored.
  736. if (!fn || reentry) {
  737. return '';
  738. }
  739. {
  740. var frame = componentFrameCache.get(fn);
  741. if (frame !== undefined) {
  742. return frame;
  743. }
  744. }
  745. var control;
  746. reentry = true;
  747. var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
  748. Error.prepareStackTrace = undefined;
  749. var previousDispatcher;
  750. {
  751. previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function
  752. // for warnings.
  753. ReactCurrentDispatcher.current = null;
  754. disableLogs();
  755. }
  756. try {
  757. // This should throw.
  758. if (construct) {
  759. // Something should be setting the props in the constructor.
  760. var Fake = function () {
  761. throw Error();
  762. }; // $FlowFixMe
  763. Object.defineProperty(Fake.prototype, 'props', {
  764. set: function () {
  765. // We use a throwing setter instead of frozen or non-writable props
  766. // because that won't throw in a non-strict mode function.
  767. throw Error();
  768. }
  769. });
  770. if (typeof Reflect === 'object' && Reflect.construct) {
  771. // We construct a different control for this case to include any extra
  772. // frames added by the construct call.
  773. try {
  774. Reflect.construct(Fake, []);
  775. } catch (x) {
  776. control = x;
  777. }
  778. Reflect.construct(fn, [], Fake);
  779. } else {
  780. try {
  781. Fake.call();
  782. } catch (x) {
  783. control = x;
  784. }
  785. fn.call(Fake.prototype);
  786. }
  787. } else {
  788. try {
  789. throw Error();
  790. } catch (x) {
  791. control = x;
  792. }
  793. fn();
  794. }
  795. } catch (sample) {
  796. // This is inlined manually because closure doesn't do it for us.
  797. if (sample && control && typeof sample.stack === 'string') {
  798. // This extracts the first frame from the sample that isn't also in the control.
  799. // Skipping one frame that we assume is the frame that calls the two.
  800. var sampleLines = sample.stack.split('\n');
  801. var controlLines = control.stack.split('\n');
  802. var s = sampleLines.length - 1;
  803. var c = controlLines.length - 1;
  804. while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
  805. // We expect at least one stack frame to be shared.
  806. // Typically this will be the root most one. However, stack frames may be
  807. // cut off due to maximum stack limits. In this case, one maybe cut off
  808. // earlier than the other. We assume that the sample is longer or the same
  809. // and there for cut off earlier. So we should find the root most frame in
  810. // the sample somewhere in the control.
  811. c--;
  812. }
  813. for (; s >= 1 && c >= 0; s--, c--) {
  814. // Next we find the first one that isn't the same which should be the
  815. // frame that called our sample function and the control.
  816. if (sampleLines[s] !== controlLines[c]) {
  817. // In V8, the first line is describing the message but other VMs don't.
  818. // If we're about to return the first line, and the control is also on the same
  819. // line, that's a pretty good indicator that our sample threw at same line as
  820. // the control. I.e. before we entered the sample frame. So we ignore this result.
  821. // This can happen if you passed a class to function component, or non-function.
  822. if (s !== 1 || c !== 1) {
  823. do {
  824. s--;
  825. c--; // We may still have similar intermediate frames from the construct call.
  826. // The next one that isn't the same should be our match though.
  827. if (c < 0 || sampleLines[s] !== controlLines[c]) {
  828. // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
  829. var _frame = '\n' + sampleLines[s].replace(' at new ', ' at ');
  830. {
  831. if (typeof fn === 'function') {
  832. componentFrameCache.set(fn, _frame);
  833. }
  834. } // Return the line we found.
  835. return _frame;
  836. }
  837. } while (s >= 1 && c >= 0);
  838. }
  839. break;
  840. }
  841. }
  842. }
  843. } finally {
  844. reentry = false;
  845. {
  846. ReactCurrentDispatcher.current = previousDispatcher;
  847. reenableLogs();
  848. }
  849. Error.prepareStackTrace = previousPrepareStackTrace;
  850. } // Fallback to just using the name if we couldn't make it throw.
  851. var name = fn ? fn.displayName || fn.name : '';
  852. var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
  853. {
  854. if (typeof fn === 'function') {
  855. componentFrameCache.set(fn, syntheticFrame);
  856. }
  857. }
  858. return syntheticFrame;
  859. }
  860. function describeClassComponentFrame(ctor, source, ownerFn) {
  861. {
  862. return describeNativeComponentFrame(ctor, true);
  863. }
  864. }
  865. function describeFunctionComponentFrame(fn, source, ownerFn) {
  866. {
  867. return describeNativeComponentFrame(fn, false);
  868. }
  869. }
  870. function shouldConstruct(Component) {
  871. var prototype = Component.prototype;
  872. return !!(prototype && prototype.isReactComponent);
  873. }
  874. function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
  875. if (type == null) {
  876. return '';
  877. }
  878. if (typeof type === 'function') {
  879. {
  880. return describeNativeComponentFrame(type, shouldConstruct(type));
  881. }
  882. }
  883. if (typeof type === 'string') {
  884. return describeBuiltInComponentFrame(type);
  885. }
  886. switch (type) {
  887. case REACT_SUSPENSE_TYPE:
  888. return describeBuiltInComponentFrame('Suspense');
  889. case REACT_SUSPENSE_LIST_TYPE:
  890. return describeBuiltInComponentFrame('SuspenseList');
  891. }
  892. if (typeof type === 'object') {
  893. switch (type.$$typeof) {
  894. case REACT_FORWARD_REF_TYPE:
  895. return describeFunctionComponentFrame(type.render);
  896. case REACT_MEMO_TYPE:
  897. // Memo may contain any component type so we recursively resolve it.
  898. return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
  899. case REACT_BLOCK_TYPE:
  900. return describeFunctionComponentFrame(type._render);
  901. case REACT_LAZY_TYPE:
  902. {
  903. var lazyComponent = type;
  904. var payload = lazyComponent._payload;
  905. var init = lazyComponent._init;
  906. try {
  907. // Lazy may contain any component type so we recursively resolve it.
  908. return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
  909. } catch (x) {}
  910. }
  911. }
  912. }
  913. return '';
  914. }
  915. function describeFiber(fiber) {
  916. var owner = fiber._debugOwner ? fiber._debugOwner.type : null ;
  917. var source = fiber._debugSource ;
  918. switch (fiber.tag) {
  919. case HostComponent:
  920. return describeBuiltInComponentFrame(fiber.type);
  921. case LazyComponent:
  922. return describeBuiltInComponentFrame('Lazy');
  923. case SuspenseComponent:
  924. return describeBuiltInComponentFrame('Suspense');
  925. case SuspenseListComponent:
  926. return describeBuiltInComponentFrame('SuspenseList');
  927. case FunctionComponent:
  928. case IndeterminateComponent:
  929. case SimpleMemoComponent:
  930. return describeFunctionComponentFrame(fiber.type);
  931. case ForwardRef:
  932. return describeFunctionComponentFrame(fiber.type.render);
  933. case Block:
  934. return describeFunctionComponentFrame(fiber.type._render);
  935. case ClassComponent:
  936. return describeClassComponentFrame(fiber.type);
  937. default:
  938. return '';
  939. }
  940. }
  941. function getStackByFiberInDevAndProd(workInProgress) {
  942. try {
  943. var info = '';
  944. var node = workInProgress;
  945. do {
  946. info += describeFiber(node);
  947. node = node.return;
  948. } while (node);
  949. return info;
  950. } catch (x) {
  951. return '\nError generating stack: ' + x.message + '\n' + x.stack;
  952. }
  953. }
  954. function getWrappedName(outerType, innerType, wrapperName) {
  955. var functionName = innerType.displayName || innerType.name || '';
  956. return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
  957. }
  958. function getContextName(type) {
  959. return type.displayName || 'Context';
  960. }
  961. function getComponentName(type) {
  962. if (type == null) {
  963. // Host root, text node or just invalid type.
  964. return null;
  965. }
  966. {
  967. if (typeof type.tag === 'number') {
  968. error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
  969. }
  970. }
  971. if (typeof type === 'function') {
  972. return type.displayName || type.name || null;
  973. }
  974. if (typeof type === 'string') {
  975. return type;
  976. }
  977. switch (type) {
  978. case REACT_FRAGMENT_TYPE:
  979. return 'Fragment';
  980. case REACT_PORTAL_TYPE:
  981. return 'Portal';
  982. case REACT_PROFILER_TYPE:
  983. return 'Profiler';
  984. case REACT_STRICT_MODE_TYPE:
  985. return 'StrictMode';
  986. case REACT_SUSPENSE_TYPE:
  987. return 'Suspense';
  988. case REACT_SUSPENSE_LIST_TYPE:
  989. return 'SuspenseList';
  990. }
  991. if (typeof type === 'object') {
  992. switch (type.$$typeof) {
  993. case REACT_CONTEXT_TYPE:
  994. var context = type;
  995. return getContextName(context) + '.Consumer';
  996. case REACT_PROVIDER_TYPE:
  997. var provider = type;
  998. return getContextName(provider._context) + '.Provider';
  999. case REACT_FORWARD_REF_TYPE:
  1000. return getWrappedName(type, type.render, 'ForwardRef');
  1001. case REACT_MEMO_TYPE:
  1002. return getComponentName(type.type);
  1003. case REACT_BLOCK_TYPE:
  1004. return getComponentName(type._render);
  1005. case REACT_LAZY_TYPE:
  1006. {
  1007. var lazyComponent = type;
  1008. var payload = lazyComponent._payload;
  1009. var init = lazyComponent._init;
  1010. try {
  1011. return getComponentName(init(payload));
  1012. } catch (x) {
  1013. return null;
  1014. }
  1015. }
  1016. }
  1017. }
  1018. return null;
  1019. }
  1020. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  1021. var current = null;
  1022. var isRendering = false;
  1023. function getCurrentFiberOwnerNameInDevOrNull() {
  1024. {
  1025. if (current === null) {
  1026. return null;
  1027. }
  1028. var owner = current._debugOwner;
  1029. if (owner !== null && typeof owner !== 'undefined') {
  1030. return getComponentName(owner.type);
  1031. }
  1032. }
  1033. return null;
  1034. }
  1035. function getCurrentFiberStackInDev() {
  1036. {
  1037. if (current === null) {
  1038. return '';
  1039. } // Safe because if current fiber exists, we are reconciling,
  1040. // and it is guaranteed to be the work-in-progress version.
  1041. return getStackByFiberInDevAndProd(current);
  1042. }
  1043. }
  1044. function resetCurrentFiber() {
  1045. {
  1046. ReactDebugCurrentFrame.getCurrentStack = null;
  1047. current = null;
  1048. isRendering = false;
  1049. }
  1050. }
  1051. function setCurrentFiber(fiber) {
  1052. {
  1053. ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev;
  1054. current = fiber;
  1055. isRendering = false;
  1056. }
  1057. }
  1058. function setIsRendering(rendering) {
  1059. {
  1060. isRendering = rendering;
  1061. }
  1062. }
  1063. function getIsRendering() {
  1064. {
  1065. return isRendering;
  1066. }
  1067. }
  1068. // Flow does not allow string concatenation of most non-string types. To work
  1069. // around this limitation, we use an opaque type that can only be obtained by
  1070. // passing the value through getToStringValue first.
  1071. function toString(value) {
  1072. return '' + value;
  1073. }
  1074. function getToStringValue(value) {
  1075. switch (typeof value) {
  1076. case 'boolean':
  1077. case 'number':
  1078. case 'object':
  1079. case 'string':
  1080. case 'undefined':
  1081. return value;
  1082. default:
  1083. // function, symbol are assigned as empty strings
  1084. return '';
  1085. }
  1086. }
  1087. var hasReadOnlyValue = {
  1088. button: true,
  1089. checkbox: true,
  1090. image: true,
  1091. hidden: true,
  1092. radio: true,
  1093. reset: true,
  1094. submit: true
  1095. };
  1096. function checkControlledValueProps(tagName, props) {
  1097. {
  1098. if (!(hasReadOnlyValue[props.type] || props.onChange || props.onInput || props.readOnly || props.disabled || props.value == null)) {
  1099. 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`.');
  1100. }
  1101. if (!(props.onChange || props.readOnly || props.disabled || props.checked == null)) {
  1102. 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`.');
  1103. }
  1104. }
  1105. }
  1106. function isCheckable(elem) {
  1107. var type = elem.type;
  1108. var nodeName = elem.nodeName;
  1109. return nodeName && nodeName.toLowerCase() === 'input' && (type === 'checkbox' || type === 'radio');
  1110. }
  1111. function getTracker(node) {
  1112. return node._valueTracker;
  1113. }
  1114. function detachTracker(node) {
  1115. node._valueTracker = null;
  1116. }
  1117. function getValueFromNode(node) {
  1118. var value = '';
  1119. if (!node) {
  1120. return value;
  1121. }
  1122. if (isCheckable(node)) {
  1123. value = node.checked ? 'true' : 'false';
  1124. } else {
  1125. value = node.value;
  1126. }
  1127. return value;
  1128. }
  1129. function trackValueOnNode(node) {
  1130. var valueField = isCheckable(node) ? 'checked' : 'value';
  1131. var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField);
  1132. var currentValue = '' + node[valueField]; // if someone has already defined a value or Safari, then bail
  1133. // and don't track value will cause over reporting of changes,
  1134. // but it's better then a hard failure
  1135. // (needed for certain tests that spyOn input values and Safari)
  1136. if (node.hasOwnProperty(valueField) || typeof descriptor === 'undefined' || typeof descriptor.get !== 'function' || typeof descriptor.set !== 'function') {
  1137. return;
  1138. }
  1139. var get = descriptor.get,
  1140. set = descriptor.set;
  1141. Object.defineProperty(node, valueField, {
  1142. configurable: true,
  1143. get: function () {
  1144. return get.call(this);
  1145. },
  1146. set: function (value) {
  1147. currentValue = '' + value;
  1148. set.call(this, value);
  1149. }
  1150. }); // We could've passed this the first time
  1151. // but it triggers a bug in IE11 and Edge 14/15.
  1152. // Calling defineProperty() again should be equivalent.
  1153. // https://github.com/facebook/react/issues/11768
  1154. Object.defineProperty(node, valueField, {
  1155. enumerable: descriptor.enumerable
  1156. });
  1157. var tracker = {
  1158. getValue: function () {
  1159. return currentValue;
  1160. },
  1161. setValue: function (value) {
  1162. currentValue = '' + value;
  1163. },
  1164. stopTracking: function () {
  1165. detachTracker(node);
  1166. delete node[valueField];
  1167. }
  1168. };
  1169. return tracker;
  1170. }
  1171. function track(node) {
  1172. if (getTracker(node)) {
  1173. return;
  1174. } // TODO: Once it's just Fiber we can move this to node._wrapperState
  1175. node._valueTracker = trackValueOnNode(node);
  1176. }
  1177. function updateValueIfChanged(node) {
  1178. if (!node) {
  1179. return false;
  1180. }
  1181. var tracker = getTracker(node); // if there is no tracker at this point it's unlikely
  1182. // that trying again will succeed
  1183. if (!tracker) {
  1184. return true;
  1185. }
  1186. var lastValue = tracker.getValue();
  1187. var nextValue = getValueFromNode(node);
  1188. if (nextValue !== lastValue) {
  1189. tracker.setValue(nextValue);
  1190. return true;
  1191. }
  1192. return false;
  1193. }
  1194. function getActiveElement(doc) {
  1195. doc = doc || (typeof document !== 'undefined' ? document : undefined);
  1196. if (typeof doc === 'undefined') {
  1197. return null;
  1198. }
  1199. try {
  1200. return doc.activeElement || doc.body;
  1201. } catch (e) {
  1202. return doc.body;
  1203. }
  1204. }
  1205. var didWarnValueDefaultValue = false;
  1206. var didWarnCheckedDefaultChecked = false;
  1207. var didWarnControlledToUncontrolled = false;
  1208. var didWarnUncontrolledToControlled = false;
  1209. function isControlled(props) {
  1210. var usesChecked = props.type === 'checkbox' || props.type === 'radio';
  1211. return usesChecked ? props.checked != null : props.value != null;
  1212. }
  1213. /**
  1214. * Implements an <input> host component that allows setting these optional
  1215. * props: `checked`, `value`, `defaultChecked`, and `defaultValue`.
  1216. *
  1217. * If `checked` or `value` are not supplied (or null/undefined), user actions
  1218. * that affect the checked state or value will trigger updates to the element.
  1219. *
  1220. * If they are supplied (and not null/undefined), the rendered element will not
  1221. * trigger updates to the element. Instead, the props must change in order for
  1222. * the rendered element to be updated.
  1223. *
  1224. * The rendered element will be initialized as unchecked (or `defaultChecked`)
  1225. * with an empty value (or `defaultValue`).
  1226. *
  1227. * See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html
  1228. */
  1229. function getHostProps(element, props) {
  1230. var node = element;
  1231. var checked = props.checked;
  1232. var hostProps = _assign({}, props, {
  1233. defaultChecked: undefined,
  1234. defaultValue: undefined,
  1235. value: undefined,
  1236. checked: checked != null ? checked : node._wrapperState.initialChecked
  1237. });
  1238. return hostProps;
  1239. }
  1240. function initWrapperState(element, props) {
  1241. {
  1242. checkControlledValueProps('input', props);
  1243. if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnCheckedDefaultChecked) {
  1244. error('%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://reactjs.org/link/controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type);
  1245. didWarnCheckedDefaultChecked = true;
  1246. }
  1247. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue) {
  1248. error('%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://reactjs.org/link/controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component', props.type);
  1249. didWarnValueDefaultValue = true;
  1250. }
  1251. }
  1252. var node = element;
  1253. var defaultValue = props.defaultValue == null ? '' : props.defaultValue;
  1254. node._wrapperState = {
  1255. initialChecked: props.checked != null ? props.checked : props.defaultChecked,
  1256. initialValue: getToStringValue(props.value != null ? props.value : defaultValue),
  1257. controlled: isControlled(props)
  1258. };
  1259. }
  1260. function updateChecked(element, props) {
  1261. var node = element;
  1262. var checked = props.checked;
  1263. if (checked != null) {
  1264. setValueForProperty(node, 'checked', checked, false);
  1265. }
  1266. }
  1267. function updateWrapper(element, props) {
  1268. var node = element;
  1269. {
  1270. var controlled = isControlled(props);
  1271. if (!node._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) {
  1272. error('A component is changing an uncontrolled input to be controlled. ' + 'This is likely caused by the value changing from undefined to ' + 'a defined value, which should not happen. ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components');
  1273. didWarnUncontrolledToControlled = true;
  1274. }
  1275. if (node._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) {
  1276. error('A component is changing a controlled input to be uncontrolled. ' + 'This is likely caused by the value changing from a defined to ' + 'undefined, which should not happen. ' + 'Decide between using a controlled or uncontrolled input ' + 'element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components');
  1277. didWarnControlledToUncontrolled = true;
  1278. }
  1279. }
  1280. updateChecked(element, props);
  1281. var value = getToStringValue(props.value);
  1282. var type = props.type;
  1283. if (value != null) {
  1284. if (type === 'number') {
  1285. if (value === 0 && node.value === '' || // We explicitly want to coerce to number here if possible.
  1286. // eslint-disable-next-line
  1287. node.value != value) {
  1288. node.value = toString(value);
  1289. }
  1290. } else if (node.value !== toString(value)) {
  1291. node.value = toString(value);
  1292. }
  1293. } else if (type === 'submit' || type === 'reset') {
  1294. // Submit/reset inputs need the attribute removed completely to avoid
  1295. // blank-text buttons.
  1296. node.removeAttribute('value');
  1297. return;
  1298. }
  1299. {
  1300. // When syncing the value attribute, the value comes from a cascade of
  1301. // properties:
  1302. // 1. The value React property
  1303. // 2. The defaultValue React property
  1304. // 3. Otherwise there should be no change
  1305. if (props.hasOwnProperty('value')) {
  1306. setDefaultValue(node, props.type, value);
  1307. } else if (props.hasOwnProperty('defaultValue')) {
  1308. setDefaultValue(node, props.type, getToStringValue(props.defaultValue));
  1309. }
  1310. }
  1311. {
  1312. // When syncing the checked attribute, it only changes when it needs
  1313. // to be removed, such as transitioning from a checkbox into a text input
  1314. if (props.checked == null && props.defaultChecked != null) {
  1315. node.defaultChecked = !!props.defaultChecked;
  1316. }
  1317. }
  1318. }
  1319. function postMountWrapper(element, props, isHydrating) {
  1320. var node = element; // Do not assign value if it is already set. This prevents user text input
  1321. // from being lost during SSR hydration.
  1322. if (props.hasOwnProperty('value') || props.hasOwnProperty('defaultValue')) {
  1323. var type = props.type;
  1324. var isButton = type === 'submit' || type === 'reset'; // Avoid setting value attribute on submit/reset inputs as it overrides the
  1325. // default value provided by the browser. See: #12872
  1326. if (isButton && (props.value === undefined || props.value === null)) {
  1327. return;
  1328. }
  1329. var initialValue = toString(node._wrapperState.initialValue); // Do not assign value if it is already set. This prevents user text input
  1330. // from being lost during SSR hydration.
  1331. if (!isHydrating) {
  1332. {
  1333. // When syncing the value attribute, the value property should use
  1334. // the wrapperState._initialValue property. This uses:
  1335. //
  1336. // 1. The value React property when present
  1337. // 2. The defaultValue React property when present
  1338. // 3. An empty string
  1339. if (initialValue !== node.value) {
  1340. node.value = initialValue;
  1341. }
  1342. }
  1343. }
  1344. {
  1345. // Otherwise, the value attribute is synchronized to the property,
  1346. // so we assign defaultValue to the same thing as the value property
  1347. // assignment step above.
  1348. node.defaultValue = initialValue;
  1349. }
  1350. } // Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug
  1351. // this is needed to work around a chrome bug where setting defaultChecked
  1352. // will sometimes influence the value of checked (even after detachment).
  1353. // Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=608416
  1354. // We need to temporarily unset name to avoid disrupting radio button groups.
  1355. var name = node.name;
  1356. if (name !== '') {
  1357. node.name = '';
  1358. }
  1359. {
  1360. // When syncing the checked attribute, both the checked property and
  1361. // attribute are assigned at the same time using defaultChecked. This uses:
  1362. //
  1363. // 1. The checked React property when present
  1364. // 2. The defaultChecked React property when present
  1365. // 3. Otherwise, false
  1366. node.defaultChecked = !node.defaultChecked;
  1367. node.defaultChecked = !!node._wrapperState.initialChecked;
  1368. }
  1369. if (name !== '') {
  1370. node.name = name;
  1371. }
  1372. }
  1373. function restoreControlledState(element, props) {
  1374. var node = element;
  1375. updateWrapper(node, props);
  1376. updateNamedCousins(node, props);
  1377. }
  1378. function updateNamedCousins(rootNode, props) {
  1379. var name = props.name;
  1380. if (props.type === 'radio' && name != null) {
  1381. var queryRoot = rootNode;
  1382. while (queryRoot.parentNode) {
  1383. queryRoot = queryRoot.parentNode;
  1384. } // If `rootNode.form` was non-null, then we could try `form.elements`,
  1385. // but that sometimes behaves strangely in IE8. We could also try using
  1386. // `form.getElementsByName`, but that will only return direct children
  1387. // and won't include inputs that use the HTML5 `form=` attribute. Since
  1388. // the input might not even be in a form. It might not even be in the
  1389. // document. Let's just use the local `querySelectorAll` to ensure we don't
  1390. // miss anything.
  1391. var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]');
  1392. for (var i = 0; i < group.length; i++) {
  1393. var otherNode = group[i];
  1394. if (otherNode === rootNode || otherNode.form !== rootNode.form) {
  1395. continue;
  1396. } // This will throw if radio buttons rendered by different copies of React
  1397. // and the same name are rendered into the same form (same as #1939).
  1398. // That's probably okay; we don't support it just as we don't support
  1399. // mixing React radio buttons with non-React ones.
  1400. var otherProps = getFiberCurrentPropsFromNode(otherNode);
  1401. if (!otherProps) {
  1402. {
  1403. throw Error( "ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported." );
  1404. }
  1405. } // We need update the tracked value on the named cousin since the value
  1406. // was changed but the input saw no event or value set
  1407. updateValueIfChanged(otherNode); // If this is a controlled radio button group, forcing the input that
  1408. // was previously checked to update will cause it to be come re-checked
  1409. // as appropriate.
  1410. updateWrapper(otherNode, otherProps);
  1411. }
  1412. }
  1413. } // In Chrome, assigning defaultValue to certain input types triggers input validation.
  1414. // For number inputs, the display value loses trailing decimal points. For email inputs,
  1415. // Chrome raises "The specified value <x> is not a valid email address".
  1416. //
  1417. // Here we check to see if the defaultValue has actually changed, avoiding these problems
  1418. // when the user is inputting text
  1419. //
  1420. // https://github.com/facebook/react/issues/7253
  1421. function setDefaultValue(node, type, value) {
  1422. if ( // Focused number inputs synchronize on blur. See ChangeEventPlugin.js
  1423. type !== 'number' || getActiveElement(node.ownerDocument) !== node) {
  1424. if (value == null) {
  1425. node.defaultValue = toString(node._wrapperState.initialValue);
  1426. } else if (node.defaultValue !== toString(value)) {
  1427. node.defaultValue = toString(value);
  1428. }
  1429. }
  1430. }
  1431. var didWarnSelectedSetOnOption = false;
  1432. var didWarnInvalidChild = false;
  1433. function flattenChildren(children) {
  1434. var content = ''; // Flatten children. We'll warn if they are invalid
  1435. // during validateProps() which runs for hydration too.
  1436. // Note that this would throw on non-element objects.
  1437. // Elements are stringified (which is normally irrelevant
  1438. // but matters for <fbt>).
  1439. React.Children.forEach(children, function (child) {
  1440. if (child == null) {
  1441. return;
  1442. }
  1443. content += child; // Note: we don't warn about invalid children here.
  1444. // Instead, this is done separately below so that
  1445. // it happens during the hydration code path too.
  1446. });
  1447. return content;
  1448. }
  1449. /**
  1450. * Implements an <option> host component that warns when `selected` is set.
  1451. */
  1452. function validateProps(element, props) {
  1453. {
  1454. // This mirrors the code path above, but runs for hydration too.
  1455. // Warn about invalid children here so that client and hydration are consistent.
  1456. // TODO: this seems like it could cause a DEV-only throw for hydration
  1457. // if children contains a non-element object. We should try to avoid that.
  1458. if (typeof props.children === 'object' && props.children !== null) {
  1459. React.Children.forEach(props.children, function (child) {
  1460. if (child == null) {
  1461. return;
  1462. }
  1463. if (typeof child === 'string' || typeof child === 'number') {
  1464. return;
  1465. }
  1466. if (typeof child.type !== 'string') {
  1467. return;
  1468. }
  1469. if (!didWarnInvalidChild) {
  1470. didWarnInvalidChild = true;
  1471. error('Only strings and numbers are supported as <option> children.');
  1472. }
  1473. });
  1474. } // TODO: Remove support for `selected` in <option>.
  1475. if (props.selected != null && !didWarnSelectedSetOnOption) {
  1476. error('Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.');
  1477. didWarnSelectedSetOnOption = true;
  1478. }
  1479. }
  1480. }
  1481. function postMountWrapper$1(element, props) {
  1482. // value="" should make a value attribute (#6219)
  1483. if (props.value != null) {
  1484. element.setAttribute('value', toString(getToStringValue(props.value)));
  1485. }
  1486. }
  1487. function getHostProps$1(element, props) {
  1488. var hostProps = _assign({
  1489. children: undefined
  1490. }, props);
  1491. var content = flattenChildren(props.children);
  1492. if (content) {
  1493. hostProps.children = content;
  1494. }
  1495. return hostProps;
  1496. }
  1497. var didWarnValueDefaultValue$1;
  1498. {
  1499. didWarnValueDefaultValue$1 = false;
  1500. }
  1501. function getDeclarationErrorAddendum() {
  1502. var ownerName = getCurrentFiberOwnerNameInDevOrNull();
  1503. if (ownerName) {
  1504. return '\n\nCheck the render method of `' + ownerName + '`.';
  1505. }
  1506. return '';
  1507. }
  1508. var valuePropNames = ['value', 'defaultValue'];
  1509. /**
  1510. * Validation function for `value` and `defaultValue`.
  1511. */
  1512. function checkSelectPropTypes(props) {
  1513. {
  1514. checkControlledValueProps('select', props);
  1515. for (var i = 0; i < valuePropNames.length; i++) {
  1516. var propName = valuePropNames[i];
  1517. if (props[propName] == null) {
  1518. continue;
  1519. }
  1520. var isArray = Array.isArray(props[propName]);
  1521. if (props.multiple && !isArray) {
  1522. error('The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum());
  1523. } else if (!props.multiple && isArray) {
  1524. error('The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum());
  1525. }
  1526. }
  1527. }
  1528. }
  1529. function updateOptions(node, multiple, propValue, setDefaultSelected) {
  1530. var options = node.options;
  1531. if (multiple) {
  1532. var selectedValues = propValue;
  1533. var selectedValue = {};
  1534. for (var i = 0; i < selectedValues.length; i++) {
  1535. // Prefix to avoid chaos with special keys.
  1536. selectedValue['$' + selectedValues[i]] = true;
  1537. }
  1538. for (var _i = 0; _i < options.length; _i++) {
  1539. var selected = selectedValue.hasOwnProperty('$' + options[_i].value);
  1540. if (options[_i].selected !== selected) {
  1541. options[_i].selected = selected;
  1542. }
  1543. if (selected && setDefaultSelected) {
  1544. options[_i].defaultSelected = true;
  1545. }
  1546. }
  1547. } else {
  1548. // Do not set `select.value` as exact behavior isn't consistent across all
  1549. // browsers for all cases.
  1550. var _selectedValue = toString(getToStringValue(propValue));
  1551. var defaultSelected = null;
  1552. for (var _i2 = 0; _i2 < options.length; _i2++) {
  1553. if (options[_i2].value === _selectedValue) {
  1554. options[_i2].selected = true;
  1555. if (setDefaultSelected) {
  1556. options[_i2].defaultSelected = true;
  1557. }
  1558. return;
  1559. }
  1560. if (defaultSelected === null && !options[_i2].disabled) {
  1561. defaultSelected = options[_i2];
  1562. }
  1563. }
  1564. if (defaultSelected !== null) {
  1565. defaultSelected.selected = true;
  1566. }
  1567. }
  1568. }
  1569. /**
  1570. * Implements a <select> host component that allows optionally setting the
  1571. * props `value` and `defaultValue`. If `multiple` is false, the prop must be a
  1572. * stringable. If `multiple` is true, the prop must be an array of stringables.
  1573. *
  1574. * If `value` is not supplied (or null/undefined), user actions that change the
  1575. * selected option will trigger updates to the rendered options.
  1576. *
  1577. * If it is supplied (and not null/undefined), the rendered options will not
  1578. * update in response to user actions. Instead, the `value` prop must change in
  1579. * order for the rendered options to update.
  1580. *
  1581. * If `defaultValue` is provided, any options with the supplied values will be
  1582. * selected.
  1583. */
  1584. function getHostProps$2(element, props) {
  1585. return _assign({}, props, {
  1586. value: undefined
  1587. });
  1588. }
  1589. function initWrapperState$1(element, props) {
  1590. var node = element;
  1591. {
  1592. checkSelectPropTypes(props);
  1593. }
  1594. node._wrapperState = {
  1595. wasMultiple: !!props.multiple
  1596. };
  1597. {
  1598. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValueDefaultValue$1) {
  1599. error('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://reactjs.org/link/controlled-components');
  1600. didWarnValueDefaultValue$1 = true;
  1601. }
  1602. }
  1603. }
  1604. function postMountWrapper$2(element, props) {
  1605. var node = element;
  1606. node.multiple = !!props.multiple;
  1607. var value = props.value;
  1608. if (value != null) {
  1609. updateOptions(node, !!props.multiple, value, false);
  1610. } else if (props.defaultValue != null) {
  1611. updateOptions(node, !!props.multiple, props.defaultValue, true);
  1612. }
  1613. }
  1614. function postUpdateWrapper(element, props) {
  1615. var node = element;
  1616. var wasMultiple = node._wrapperState.wasMultiple;
  1617. node._wrapperState.wasMultiple = !!props.multiple;
  1618. var value = props.value;
  1619. if (value != null) {
  1620. updateOptions(node, !!props.multiple, value, false);
  1621. } else if (wasMultiple !== !!props.multiple) {
  1622. // For simplicity, reapply `defaultValue` if `multiple` is toggled.
  1623. if (props.defaultValue != null) {
  1624. updateOptions(node, !!props.multiple, props.defaultValue, true);
  1625. } else {
  1626. // Revert the select back to its default unselected state.
  1627. updateOptions(node, !!props.multiple, props.multiple ? [] : '', false);
  1628. }
  1629. }
  1630. }
  1631. function restoreControlledState$1(element, props) {
  1632. var node = element;
  1633. var value = props.value;
  1634. if (value != null) {
  1635. updateOptions(node, !!props.multiple, value, false);
  1636. }
  1637. }
  1638. var didWarnValDefaultVal = false;
  1639. /**
  1640. * Implements a <textarea> host component that allows setting `value`, and
  1641. * `defaultValue`. This differs from the traditional DOM API because value is
  1642. * usually set as PCDATA children.
  1643. *
  1644. * If `value` is not supplied (or null/undefined), user actions that affect the
  1645. * value will trigger updates to the element.
  1646. *
  1647. * If `value` is supplied (and not null/undefined), the rendered element will
  1648. * not trigger updates to the element. Instead, the `value` prop must change in
  1649. * order for the rendered element to be updated.
  1650. *
  1651. * The rendered element will be initialized with an empty value, the prop
  1652. * `defaultValue` if specified, or the children content (deprecated).
  1653. */
  1654. function getHostProps$3(element, props) {
  1655. var node = element;
  1656. if (!(props.dangerouslySetInnerHTML == null)) {
  1657. {
  1658. throw Error( "`dangerouslySetInnerHTML` does not make sense on <textarea>." );
  1659. }
  1660. } // Always set children to the same thing. In IE9, the selection range will
  1661. // get reset if `textContent` is mutated. We could add a check in setTextContent
  1662. // to only set the value if/when the value differs from the node value (which would
  1663. // completely solve this IE9 bug), but Sebastian+Sophie seemed to like this
  1664. // solution. The value can be a boolean or object so that's why it's forced
  1665. // to be a string.
  1666. var hostProps = _assign({}, props, {
  1667. value: undefined,
  1668. defaultValue: undefined,
  1669. children: toString(node._wrapperState.initialValue)
  1670. });
  1671. return hostProps;
  1672. }
  1673. function initWrapperState$2(element, props) {
  1674. var node = element;
  1675. {
  1676. checkControlledValueProps('textarea', props);
  1677. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnValDefaultVal) {
  1678. error('%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://reactjs.org/link/controlled-components', getCurrentFiberOwnerNameInDevOrNull() || 'A component');
  1679. didWarnValDefaultVal = true;
  1680. }
  1681. }
  1682. var initialValue = props.value; // Only bother fetching default value if we're going to use it
  1683. if (initialValue == null) {
  1684. var children = props.children,
  1685. defaultValue = props.defaultValue;
  1686. if (children != null) {
  1687. {
  1688. error('Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.');
  1689. }
  1690. {
  1691. if (!(defaultValue == null)) {
  1692. {
  1693. throw Error( "If you supply `defaultValue` on a <textarea>, do not pass children." );
  1694. }
  1695. }
  1696. if (Array.isArray(children)) {
  1697. if (!(children.length <= 1)) {
  1698. {
  1699. throw Error( "<textarea> can only have at most one child." );
  1700. }
  1701. }
  1702. children = children[0];
  1703. }
  1704. defaultValue = children;
  1705. }
  1706. }
  1707. if (defaultValue == null) {
  1708. defaultValue = '';
  1709. }
  1710. initialValue = defaultValue;
  1711. }
  1712. node._wrapperState = {
  1713. initialValue: getToStringValue(initialValue)
  1714. };
  1715. }
  1716. function updateWrapper$1(element, props) {
  1717. var node = element;
  1718. var value = getToStringValue(props.value);
  1719. var defaultValue = getToStringValue(props.defaultValue);
  1720. if (value != null) {
  1721. // Cast `value` to a string to ensure the value is set correctly. While
  1722. // browsers typically do this as necessary, jsdom doesn't.
  1723. var newValue = toString(value); // To avoid side effects (such as losing text selection), only set value if changed
  1724. if (newValue !== node.value) {
  1725. node.value = newValue;
  1726. }
  1727. if (props.defaultValue == null && node.defaultValue !== newValue) {
  1728. node.defaultValue = newValue;
  1729. }
  1730. }
  1731. if (defaultValue != null) {
  1732. node.defaultValue = toString(defaultValue);
  1733. }
  1734. }
  1735. function postMountWrapper$3(element, props) {
  1736. var node = element; // This is in postMount because we need access to the DOM node, which is not
  1737. // available until after the component has mounted.
  1738. var textContent = node.textContent; // Only set node.value if textContent is equal to the expected
  1739. // initial value. In IE10/IE11 there is a bug where the placeholder attribute
  1740. // will populate textContent as well.
  1741. // https://developer.microsoft.com/microsoft-edge/platform/issues/101525/
  1742. if (textContent === node._wrapperState.initialValue) {
  1743. if (textContent !== '' && textContent !== null) {
  1744. node.value = textContent;
  1745. }
  1746. }
  1747. }
  1748. function restoreControlledState$2(element, props) {
  1749. // DOM component is still mounted; update
  1750. updateWrapper$1(element, props);
  1751. }
  1752. var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
  1753. var MATH_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
  1754. var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
  1755. var Namespaces = {
  1756. html: HTML_NAMESPACE,
  1757. mathml: MATH_NAMESPACE,
  1758. svg: SVG_NAMESPACE
  1759. }; // Assumes there is no parent namespace.
  1760. function getIntrinsicNamespace(type) {
  1761. switch (type) {
  1762. case 'svg':
  1763. return SVG_NAMESPACE;
  1764. case 'math':
  1765. return MATH_NAMESPACE;
  1766. default:
  1767. return HTML_NAMESPACE;
  1768. }
  1769. }
  1770. function getChildNamespace(parentNamespace, type) {
  1771. if (parentNamespace == null || parentNamespace === HTML_NAMESPACE) {
  1772. // No (or default) parent namespace: potential entry point.
  1773. return getIntrinsicNamespace(type);
  1774. }
  1775. if (parentNamespace === SVG_NAMESPACE && type === 'foreignObject') {
  1776. // We're leaving SVG.
  1777. return HTML_NAMESPACE;
  1778. } // By default, pass namespace below.
  1779. return parentNamespace;
  1780. }
  1781. /* globals MSApp */
  1782. /**
  1783. * Create a function which has 'unsafe' privileges (required by windows8 apps)
  1784. */
  1785. var createMicrosoftUnsafeLocalFunction = function (func) {
  1786. if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
  1787. return function (arg0, arg1, arg2, arg3) {
  1788. MSApp.execUnsafeLocalFunction(function () {
  1789. return func(arg0, arg1, arg2, arg3);
  1790. });
  1791. };
  1792. } else {
  1793. return func;
  1794. }
  1795. };
  1796. var reusableSVGContainer;
  1797. /**
  1798. * Set the innerHTML property of a node
  1799. *
  1800. * @param {DOMElement} node
  1801. * @param {string} html
  1802. * @internal
  1803. */
  1804. var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) {
  1805. if (node.namespaceURI === Namespaces.svg) {
  1806. if (!('innerHTML' in node)) {
  1807. // IE does not have innerHTML for SVG nodes, so instead we inject the
  1808. // new markup in a temp node and then move the child nodes across into
  1809. // the target node
  1810. reusableSVGContainer = reusableSVGContainer || document.createElement('div');
  1811. reusableSVGContainer.innerHTML = '<svg>' + html.valueOf().toString() + '</svg>';
  1812. var svgNode = reusableSVGContainer.firstChild;
  1813. while (node.firstChild) {
  1814. node.removeChild(node.firstChild);
  1815. }
  1816. while (svgNode.firstChild) {
  1817. node.appendChild(svgNode.firstChild);
  1818. }
  1819. return;
  1820. }
  1821. }
  1822. node.innerHTML = html;
  1823. });
  1824. /**
  1825. * HTML nodeType values that represent the type of the node
  1826. */
  1827. var ELEMENT_NODE = 1;
  1828. var TEXT_NODE = 3;
  1829. var COMMENT_NODE = 8;
  1830. var DOCUMENT_NODE = 9;
  1831. var DOCUMENT_FRAGMENT_NODE = 11;
  1832. /**
  1833. * Set the textContent property of a node. For text updates, it's faster
  1834. * to set the `nodeValue` of the Text node directly instead of using
  1835. * `.textContent` which will remove the existing node and create a new one.
  1836. *
  1837. * @param {DOMElement} node
  1838. * @param {string} text
  1839. * @internal
  1840. */
  1841. var setTextContent = function (node, text) {
  1842. if (text) {
  1843. var firstChild = node.firstChild;
  1844. if (firstChild && firstChild === node.lastChild && firstChild.nodeType === TEXT_NODE) {
  1845. firstChild.nodeValue = text;
  1846. return;
  1847. }
  1848. }
  1849. node.textContent = text;
  1850. };
  1851. // List derived from Gecko source code:
  1852. // https://github.com/mozilla/gecko-dev/blob/4e638efc71/layout/style/test/property_database.js
  1853. var shorthandToLonghand = {
  1854. animation: ['animationDelay', 'animationDirection', 'animationDuration', 'animationFillMode', 'animationIterationCount', 'animationName', 'animationPlayState', 'animationTimingFunction'],
  1855. background: ['backgroundAttachment', 'backgroundClip', 'backgroundColor', 'backgroundImage', 'backgroundOrigin', 'backgroundPositionX', 'backgroundPositionY', 'backgroundRepeat', 'backgroundSize'],
  1856. backgroundPosition: ['backgroundPositionX', 'backgroundPositionY'],
  1857. border: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth', 'borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth', 'borderLeftColor', 'borderLeftStyle', 'borderLeftWidth', 'borderRightColor', 'borderRightStyle', 'borderRightWidth', 'borderTopColor', 'borderTopStyle', 'borderTopWidth'],
  1858. borderBlockEnd: ['borderBlockEndColor', 'borderBlockEndStyle', 'borderBlockEndWidth'],
  1859. borderBlockStart: ['borderBlockStartColor', 'borderBlockStartStyle', 'borderBlockStartWidth'],
  1860. borderBottom: ['borderBottomColor', 'borderBottomStyle', 'borderBottomWidth'],
  1861. borderColor: ['borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor'],
  1862. borderImage: ['borderImageOutset', 'borderImageRepeat', 'borderImageSlice', 'borderImageSource', 'borderImageWidth'],
  1863. borderInlineEnd: ['borderInlineEndColor', 'borderInlineEndStyle', 'borderInlineEndWidth'],
  1864. borderInlineStart: ['borderInlineStartColor', 'borderInlineStartStyle', 'borderInlineStartWidth'],
  1865. borderLeft: ['borderLeftColor', 'borderLeftStyle', 'borderLeftWidth'],
  1866. borderRadius: ['borderBottomLeftRadius', 'borderBottomRightRadius', 'borderTopLeftRadius', 'borderTopRightRadius'],
  1867. borderRight: ['borderRightColor', 'borderRightStyle', 'borderRightWidth'],
  1868. borderStyle: ['borderBottomStyle', 'borderLeftStyle', 'borderRightStyle', 'borderTopStyle'],
  1869. borderTop: ['borderTopColor', 'borderTopStyle', 'borderTopWidth'],
  1870. borderWidth: ['borderBottomWidth', 'borderLeftWidth', 'borderRightWidth', 'borderTopWidth'],
  1871. columnRule: ['columnRuleColor', 'columnRuleStyle', 'columnRuleWidth'],
  1872. columns: ['columnCount', 'columnWidth'],
  1873. flex: ['flexBasis', 'flexGrow', 'flexShrink'],
  1874. flexFlow: ['flexDirection', 'flexWrap'],
  1875. font: ['fontFamily', 'fontFeatureSettings', 'fontKerning', 'fontLanguageOverride', 'fontSize', 'fontSizeAdjust', 'fontStretch', 'fontStyle', 'fontVariant', 'fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition', 'fontWeight', 'lineHeight'],
  1876. fontVariant: ['fontVariantAlternates', 'fontVariantCaps', 'fontVariantEastAsian', 'fontVariantLigatures', 'fontVariantNumeric', 'fontVariantPosition'],
  1877. gap: ['columnGap', 'rowGap'],
  1878. grid: ['gridAutoColumns', 'gridAutoFlow', 'gridAutoRows', 'gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'],
  1879. gridArea: ['gridColumnEnd', 'gridColumnStart', 'gridRowEnd', 'gridRowStart'],
  1880. gridColumn: ['gridColumnEnd', 'gridColumnStart'],
  1881. gridColumnGap: ['columnGap'],
  1882. gridGap: ['columnGap', 'rowGap'],
  1883. gridRow: ['gridRowEnd', 'gridRowStart'],
  1884. gridRowGap: ['rowGap'],
  1885. gridTemplate: ['gridTemplateAreas', 'gridTemplateColumns', 'gridTemplateRows'],
  1886. listStyle: ['listStyleImage', 'listStylePosition', 'listStyleType'],
  1887. margin: ['marginBottom', 'marginLeft', 'marginRight', 'marginTop'],
  1888. marker: ['markerEnd', 'markerMid', 'markerStart'],
  1889. mask: ['maskClip', 'maskComposite', 'maskImage', 'maskMode', 'maskOrigin', 'maskPositionX', 'maskPositionY', 'maskRepeat', 'maskSize'],
  1890. maskPosition: ['maskPositionX', 'maskPositionY'],
  1891. outline: ['outlineColor', 'outlineStyle', 'outlineWidth'],
  1892. overflow: ['overflowX', 'overflowY'],
  1893. padding: ['paddingBottom', 'paddingLeft', 'paddingRight', 'paddingTop'],
  1894. placeContent: ['alignContent', 'justifyContent'],
  1895. placeItems: ['alignItems', 'justifyItems'],
  1896. placeSelf: ['alignSelf', 'justifySelf'],
  1897. textDecoration: ['textDecorationColor', 'textDecorationLine', 'textDecorationStyle'],
  1898. textEmphasis: ['textEmphasisColor', 'textEmphasisStyle'],
  1899. transition: ['transitionDelay', 'transitionDuration', 'transitionProperty', 'transitionTimingFunction'],
  1900. wordWrap: ['overflowWrap']
  1901. };
  1902. /**
  1903. * CSS properties which accept numbers but are not in units of "px".
  1904. */
  1905. var isUnitlessNumber = {
  1906. animationIterationCount: true,
  1907. borderImageOutset: true,
  1908. borderImageSlice: true,
  1909. borderImageWidth: true,
  1910. boxFlex: true,
  1911. boxFlexGroup: true,
  1912. boxOrdinalGroup: true,
  1913. columnCount: true,
  1914. columns: true,
  1915. flex: true,
  1916. flexGrow: true,
  1917. flexPositive: true,
  1918. flexShrink: true,
  1919. flexNegative: true,
  1920. flexOrder: true,
  1921. gridArea: true,
  1922. gridRow: true,
  1923. gridRowEnd: true,
  1924. gridRowSpan: true,
  1925. gridRowStart: true,
  1926. gridColumn: true,
  1927. gridColumnEnd: true,
  1928. gridColumnSpan: true,
  1929. gridColumnStart: true,
  1930. fontWeight: true,
  1931. lineClamp: true,
  1932. lineHeight: true,
  1933. opacity: true,
  1934. order: true,
  1935. orphans: true,
  1936. tabSize: true,
  1937. widows: true,
  1938. zIndex: true,
  1939. zoom: true,
  1940. // SVG-related properties
  1941. fillOpacity: true,
  1942. floodOpacity: true,
  1943. stopOpacity: true,
  1944. strokeDasharray: true,
  1945. strokeDashoffset: true,
  1946. strokeMiterlimit: true,
  1947. strokeOpacity: true,
  1948. strokeWidth: true
  1949. };
  1950. /**
  1951. * @param {string} prefix vendor-specific prefix, eg: Webkit
  1952. * @param {string} key style name, eg: transitionDuration
  1953. * @return {string} style name prefixed with `prefix`, properly camelCased, eg:
  1954. * WebkitTransitionDuration
  1955. */
  1956. function prefixKey(prefix, key) {
  1957. return prefix + key.charAt(0).toUpperCase() + key.substring(1);
  1958. }
  1959. /**
  1960. * Support style names that may come passed in prefixed by adding permutations
  1961. * of vendor prefixes.
  1962. */
  1963. var prefixes = ['Webkit', 'ms', 'Moz', 'O']; // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
  1964. // infinite loop, because it iterates over the newly added props too.
  1965. Object.keys(isUnitlessNumber).forEach(function (prop) {
  1966. prefixes.forEach(function (prefix) {
  1967. isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
  1968. });
  1969. });
  1970. /**
  1971. * Convert a value into the proper css writable value. The style name `name`
  1972. * should be logical (no hyphens), as specified
  1973. * in `CSSProperty.isUnitlessNumber`.
  1974. *
  1975. * @param {string} name CSS property name such as `topMargin`.
  1976. * @param {*} value CSS property value such as `10px`.
  1977. * @return {string} Normalized style value with dimensions applied.
  1978. */
  1979. function dangerousStyleValue(name, value, isCustomProperty) {
  1980. // Note that we've removed escapeTextForBrowser() calls here since the
  1981. // whole string will be escaped when the attribute is injected into
  1982. // the markup. If you provide unsafe user data here they can inject
  1983. // arbitrary CSS which may be problematic (I couldn't repro this):
  1984. // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
  1985. // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
  1986. // This is not an XSS hole but instead a potential CSS injection issue
  1987. // which has lead to a greater discussion about how we're going to
  1988. // trust URLs moving forward. See #2115901
  1989. var isEmpty = value == null || typeof value === 'boolean' || value === '';
  1990. if (isEmpty) {
  1991. return '';
  1992. }
  1993. if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) {
  1994. return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers
  1995. }
  1996. return ('' + value).trim();
  1997. }
  1998. var uppercasePattern = /([A-Z])/g;
  1999. var msPattern = /^ms-/;
  2000. /**
  2001. * Hyphenates a camelcased CSS property name, for example:
  2002. *
  2003. * > hyphenateStyleName('backgroundColor')
  2004. * < "background-color"
  2005. * > hyphenateStyleName('MozTransition')
  2006. * < "-moz-transition"
  2007. * > hyphenateStyleName('msTransition')
  2008. * < "-ms-transition"
  2009. *
  2010. * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
  2011. * is converted to `-ms-`.
  2012. */
  2013. function hyphenateStyleName(name) {
  2014. return name.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern, '-ms-');
  2015. }
  2016. var warnValidStyle = function () {};
  2017. {
  2018. // 'msTransform' is correct, but the other prefixes should be capitalized
  2019. var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
  2020. var msPattern$1 = /^-ms-/;
  2021. var hyphenPattern = /-(.)/g; // style values shouldn't contain a semicolon
  2022. var badStyleValueWithSemicolonPattern = /;\s*$/;
  2023. var warnedStyleNames = {};
  2024. var warnedStyleValues = {};
  2025. var warnedForNaNValue = false;
  2026. var warnedForInfinityValue = false;
  2027. var camelize = function (string) {
  2028. return string.replace(hyphenPattern, function (_, character) {
  2029. return character.toUpperCase();
  2030. });
  2031. };
  2032. var warnHyphenatedStyleName = function (name) {
  2033. if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
  2034. return;
  2035. }
  2036. warnedStyleNames[name] = true;
  2037. error('Unsupported style property %s. Did you mean %s?', name, // As Andi Smith suggests
  2038. // (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
  2039. // is converted to lowercase `ms`.
  2040. camelize(name.replace(msPattern$1, 'ms-')));
  2041. };
  2042. var warnBadVendoredStyleName = function (name) {
  2043. if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
  2044. return;
  2045. }
  2046. warnedStyleNames[name] = true;
  2047. error('Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1));
  2048. };
  2049. var warnStyleValueWithSemicolon = function (name, value) {
  2050. if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
  2051. return;
  2052. }
  2053. warnedStyleValues[value] = true;
  2054. error("Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, ''));
  2055. };
  2056. var warnStyleValueIsNaN = function (name, value) {
  2057. if (warnedForNaNValue) {
  2058. return;
  2059. }
  2060. warnedForNaNValue = true;
  2061. error('`NaN` is an invalid value for the `%s` css style property.', name);
  2062. };
  2063. var warnStyleValueIsInfinity = function (name, value) {
  2064. if (warnedForInfinityValue) {
  2065. return;
  2066. }
  2067. warnedForInfinityValue = true;
  2068. error('`Infinity` is an invalid value for the `%s` css style property.', name);
  2069. };
  2070. warnValidStyle = function (name, value) {
  2071. if (name.indexOf('-') > -1) {
  2072. warnHyphenatedStyleName(name);
  2073. } else if (badVendoredStyleNamePattern.test(name)) {
  2074. warnBadVendoredStyleName(name);
  2075. } else if (badStyleValueWithSemicolonPattern.test(value)) {
  2076. warnStyleValueWithSemicolon(name, value);
  2077. }
  2078. if (typeof value === 'number') {
  2079. if (isNaN(value)) {
  2080. warnStyleValueIsNaN(name, value);
  2081. } else if (!isFinite(value)) {
  2082. warnStyleValueIsInfinity(name, value);
  2083. }
  2084. }
  2085. };
  2086. }
  2087. var warnValidStyle$1 = warnValidStyle;
  2088. /**
  2089. * Operations for dealing with CSS properties.
  2090. */
  2091. /**
  2092. * This creates a string that is expected to be equivalent to the style
  2093. * attribute generated by server-side rendering. It by-passes warnings and
  2094. * security checks so it's not safe to use this value for anything other than
  2095. * comparison. It is only used in DEV for SSR validation.
  2096. */
  2097. function createDangerousStringForStyles(styles) {
  2098. {
  2099. var serialized = '';
  2100. var delimiter = '';
  2101. for (var styleName in styles) {
  2102. if (!styles.hasOwnProperty(styleName)) {
  2103. continue;
  2104. }
  2105. var styleValue = styles[styleName];
  2106. if (styleValue != null) {
  2107. var isCustomProperty = styleName.indexOf('--') === 0;
  2108. serialized += delimiter + (isCustomProperty ? styleName : hyphenateStyleName(styleName)) + ':';
  2109. serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty);
  2110. delimiter = ';';
  2111. }
  2112. }
  2113. return serialized || null;
  2114. }
  2115. }
  2116. /**
  2117. * Sets the value for multiple styles on a node. If a value is specified as
  2118. * '' (empty string), the corresponding style property will be unset.
  2119. *
  2120. * @param {DOMElement} node
  2121. * @param {object} styles
  2122. */
  2123. function setValueForStyles(node, styles) {
  2124. var style = node.style;
  2125. for (var styleName in styles) {
  2126. if (!styles.hasOwnProperty(styleName)) {
  2127. continue;
  2128. }
  2129. var isCustomProperty = styleName.indexOf('--') === 0;
  2130. {
  2131. if (!isCustomProperty) {
  2132. warnValidStyle$1(styleName, styles[styleName]);
  2133. }
  2134. }
  2135. var styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty);
  2136. if (styleName === 'float') {
  2137. styleName = 'cssFloat';
  2138. }
  2139. if (isCustomProperty) {
  2140. style.setProperty(styleName, styleValue);
  2141. } else {
  2142. style[styleName] = styleValue;
  2143. }
  2144. }
  2145. }
  2146. function isValueEmpty(value) {
  2147. return value == null || typeof value === 'boolean' || value === '';
  2148. }
  2149. /**
  2150. * Given {color: 'red', overflow: 'hidden'} returns {
  2151. * color: 'color',
  2152. * overflowX: 'overflow',
  2153. * overflowY: 'overflow',
  2154. * }. This can be read as "the overflowY property was set by the overflow
  2155. * shorthand". That is, the values are the property that each was derived from.
  2156. */
  2157. function expandShorthandMap(styles) {
  2158. var expanded = {};
  2159. for (var key in styles) {
  2160. var longhands = shorthandToLonghand[key] || [key];
  2161. for (var i = 0; i < longhands.length; i++) {
  2162. expanded[longhands[i]] = key;
  2163. }
  2164. }
  2165. return expanded;
  2166. }
  2167. /**
  2168. * When mixing shorthand and longhand property names, we warn during updates if
  2169. * we expect an incorrect result to occur. In particular, we warn for:
  2170. *
  2171. * Updating a shorthand property (longhand gets overwritten):
  2172. * {font: 'foo', fontVariant: 'bar'} -> {font: 'baz', fontVariant: 'bar'}
  2173. * becomes .style.font = 'baz'
  2174. * Removing a shorthand property (longhand gets lost too):
  2175. * {font: 'foo', fontVariant: 'bar'} -> {fontVariant: 'bar'}
  2176. * becomes .style.font = ''
  2177. * Removing a longhand property (should revert to shorthand; doesn't):
  2178. * {font: 'foo', fontVariant: 'bar'} -> {font: 'foo'}
  2179. * becomes .style.fontVariant = ''
  2180. */
  2181. function validateShorthandPropertyCollisionInDev(styleUpdates, nextStyles) {
  2182. {
  2183. if (!nextStyles) {
  2184. return;
  2185. }
  2186. var expandedUpdates = expandShorthandMap(styleUpdates);
  2187. var expandedStyles = expandShorthandMap(nextStyles);
  2188. var warnedAbout = {};
  2189. for (var key in expandedUpdates) {
  2190. var originalKey = expandedUpdates[key];
  2191. var correctOriginalKey = expandedStyles[key];
  2192. if (correctOriginalKey && originalKey !== correctOriginalKey) {
  2193. var warningKey = originalKey + ',' + correctOriginalKey;
  2194. if (warnedAbout[warningKey]) {
  2195. continue;
  2196. }
  2197. warnedAbout[warningKey] = true;
  2198. error('%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);
  2199. }
  2200. }
  2201. }
  2202. }
  2203. // For HTML, certain tags should omit their close tag. We keep a list for
  2204. // those special-case tags.
  2205. var omittedCloseTags = {
  2206. area: true,
  2207. base: true,
  2208. br: true,
  2209. col: true,
  2210. embed: true,
  2211. hr: true,
  2212. img: true,
  2213. input: true,
  2214. keygen: true,
  2215. link: true,
  2216. meta: true,
  2217. param: true,
  2218. source: true,
  2219. track: true,
  2220. wbr: true // NOTE: menuitem's close tag should be omitted, but that causes problems.
  2221. };
  2222. // `omittedCloseTags` except that `menuitem` should still have its closing tag.
  2223. var voidElementTags = _assign({
  2224. menuitem: true
  2225. }, omittedCloseTags);
  2226. var HTML = '__html';
  2227. function assertValidProps(tag, props) {
  2228. if (!props) {
  2229. return;
  2230. } // Note the use of `==` which checks for null or undefined.
  2231. if (voidElementTags[tag]) {
  2232. if (!(props.children == null && props.dangerouslySetInnerHTML == null)) {
  2233. {
  2234. throw Error( tag + " is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`." );
  2235. }
  2236. }
  2237. }
  2238. if (props.dangerouslySetInnerHTML != null) {
  2239. if (!(props.children == null)) {
  2240. {
  2241. throw Error( "Can only set one of `children` or `props.dangerouslySetInnerHTML`." );
  2242. }
  2243. }
  2244. if (!(typeof props.dangerouslySetInnerHTML === 'object' && HTML in props.dangerouslySetInnerHTML)) {
  2245. {
  2246. throw Error( "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information." );
  2247. }
  2248. }
  2249. }
  2250. {
  2251. if (!props.suppressContentEditableWarning && props.contentEditable && props.children != null) {
  2252. error('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.');
  2253. }
  2254. }
  2255. if (!(props.style == null || typeof props.style === 'object')) {
  2256. {
  2257. throw Error( "The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX." );
  2258. }
  2259. }
  2260. }
  2261. function isCustomComponent(tagName, props) {
  2262. if (tagName.indexOf('-') === -1) {
  2263. return typeof props.is === 'string';
  2264. }
  2265. switch (tagName) {
  2266. // These are reserved SVG and MathML elements.
  2267. // We don't mind this list too much because we expect it to never grow.
  2268. // The alternative is to track the namespace in a few places which is convoluted.
  2269. // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
  2270. case 'annotation-xml':
  2271. case 'color-profile':
  2272. case 'font-face':
  2273. case 'font-face-src':
  2274. case 'font-face-uri':
  2275. case 'font-face-format':
  2276. case 'font-face-name':
  2277. case 'missing-glyph':
  2278. return false;
  2279. default:
  2280. return true;
  2281. }
  2282. }
  2283. // When adding attributes to the HTML or SVG allowed attribute list, be sure to
  2284. // also add them to this module to ensure casing and incorrect name
  2285. // warnings.
  2286. var possibleStandardNames = {
  2287. // HTML
  2288. accept: 'accept',
  2289. acceptcharset: 'acceptCharset',
  2290. 'accept-charset': 'acceptCharset',
  2291. accesskey: 'accessKey',
  2292. action: 'action',
  2293. allowfullscreen: 'allowFullScreen',
  2294. alt: 'alt',
  2295. as: 'as',
  2296. async: 'async',
  2297. autocapitalize: 'autoCapitalize',
  2298. autocomplete: 'autoComplete',
  2299. autocorrect: 'autoCorrect',
  2300. autofocus: 'autoFocus',
  2301. autoplay: 'autoPlay',
  2302. autosave: 'autoSave',
  2303. capture: 'capture',
  2304. cellpadding: 'cellPadding',
  2305. cellspacing: 'cellSpacing',
  2306. challenge: 'challenge',
  2307. charset: 'charSet',
  2308. checked: 'checked',
  2309. children: 'children',
  2310. cite: 'cite',
  2311. class: 'className',
  2312. classid: 'classID',
  2313. classname: 'className',
  2314. cols: 'cols',
  2315. colspan: 'colSpan',
  2316. content: 'content',
  2317. contenteditable: 'contentEditable',
  2318. contextmenu: 'contextMenu',
  2319. controls: 'controls',
  2320. controlslist: 'controlsList',
  2321. coords: 'coords',
  2322. crossorigin: 'crossOrigin',
  2323. dangerouslysetinnerhtml: 'dangerouslySetInnerHTML',
  2324. data: 'data',
  2325. datetime: 'dateTime',
  2326. default: 'default',
  2327. defaultchecked: 'defaultChecked',
  2328. defaultvalue: 'defaultValue',
  2329. defer: 'defer',
  2330. dir: 'dir',
  2331. disabled: 'disabled',
  2332. disablepictureinpicture: 'disablePictureInPicture',
  2333. disableremoteplayback: 'disableRemotePlayback',
  2334. download: 'download',
  2335. draggable: 'draggable',
  2336. enctype: 'encType',
  2337. enterkeyhint: 'enterKeyHint',
  2338. for: 'htmlFor',
  2339. form: 'form',
  2340. formmethod: 'formMethod',
  2341. formaction: 'formAction',
  2342. formenctype: 'formEncType',
  2343. formnovalidate: 'formNoValidate',
  2344. formtarget: 'formTarget',
  2345. frameborder: 'frameBorder',
  2346. headers: 'headers',
  2347. height: 'height',
  2348. hidden: 'hidden',
  2349. high: 'high',
  2350. href: 'href',
  2351. hreflang: 'hrefLang',
  2352. htmlfor: 'htmlFor',
  2353. httpequiv: 'httpEquiv',
  2354. 'http-equiv': 'httpEquiv',
  2355. icon: 'icon',
  2356. id: 'id',
  2357. innerhtml: 'innerHTML',
  2358. inputmode: 'inputMode',
  2359. integrity: 'integrity',
  2360. is: 'is',
  2361. itemid: 'itemID',
  2362. itemprop: 'itemProp',
  2363. itemref: 'itemRef',
  2364. itemscope: 'itemScope',
  2365. itemtype: 'itemType',
  2366. keyparams: 'keyParams',
  2367. keytype: 'keyType',
  2368. kind: 'kind',
  2369. label: 'label',
  2370. lang: 'lang',
  2371. list: 'list',
  2372. loop: 'loop',
  2373. low: 'low',
  2374. manifest: 'manifest',
  2375. marginwidth: 'marginWidth',
  2376. marginheight: 'marginHeight',
  2377. max: 'max',
  2378. maxlength: 'maxLength',
  2379. media: 'media',
  2380. mediagroup: 'mediaGroup',
  2381. method: 'method',
  2382. min: 'min',
  2383. minlength: 'minLength',
  2384. multiple: 'multiple',
  2385. muted: 'muted',
  2386. name: 'name',
  2387. nomodule: 'noModule',
  2388. nonce: 'nonce',
  2389. novalidate: 'noValidate',
  2390. open: 'open',
  2391. optimum: 'optimum',
  2392. pattern: 'pattern',
  2393. placeholder: 'placeholder',
  2394. playsinline: 'playsInline',
  2395. poster: 'poster',
  2396. preload: 'preload',
  2397. profile: 'profile',
  2398. radiogroup: 'radioGroup',
  2399. readonly: 'readOnly',
  2400. referrerpolicy: 'referrerPolicy',
  2401. rel: 'rel',
  2402. required: 'required',
  2403. reversed: 'reversed',
  2404. role: 'role',
  2405. rows: 'rows',
  2406. rowspan: 'rowSpan',
  2407. sandbox: 'sandbox',
  2408. scope: 'scope',
  2409. scoped: 'scoped',
  2410. scrolling: 'scrolling',
  2411. seamless: 'seamless',
  2412. selected: 'selected',
  2413. shape: 'shape',
  2414. size: 'size',
  2415. sizes: 'sizes',
  2416. span: 'span',
  2417. spellcheck: 'spellCheck',
  2418. src: 'src',
  2419. srcdoc: 'srcDoc',
  2420. srclang: 'srcLang',
  2421. srcset: 'srcSet',
  2422. start: 'start',
  2423. step: 'step',
  2424. style: 'style',
  2425. summary: 'summary',
  2426. tabindex: 'tabIndex',
  2427. target: 'target',
  2428. title: 'title',
  2429. type: 'type',
  2430. usemap: 'useMap',
  2431. value: 'value',
  2432. width: 'width',
  2433. wmode: 'wmode',
  2434. wrap: 'wrap',
  2435. // SVG
  2436. about: 'about',
  2437. accentheight: 'accentHeight',
  2438. 'accent-height': 'accentHeight',
  2439. accumulate: 'accumulate',
  2440. additive: 'additive',
  2441. alignmentbaseline: 'alignmentBaseline',
  2442. 'alignment-baseline': 'alignmentBaseline',
  2443. allowreorder: 'allowReorder',
  2444. alphabetic: 'alphabetic',
  2445. amplitude: 'amplitude',
  2446. arabicform: 'arabicForm',
  2447. 'arabic-form': 'arabicForm',
  2448. ascent: 'ascent',
  2449. attributename: 'attributeName',
  2450. attributetype: 'attributeType',
  2451. autoreverse: 'autoReverse',
  2452. azimuth: 'azimuth',
  2453. basefrequency: 'baseFrequency',
  2454. baselineshift: 'baselineShift',
  2455. 'baseline-shift': 'baselineShift',
  2456. baseprofile: 'baseProfile',
  2457. bbox: 'bbox',
  2458. begin: 'begin',
  2459. bias: 'bias',
  2460. by: 'by',
  2461. calcmode: 'calcMode',
  2462. capheight: 'capHeight',
  2463. 'cap-height': 'capHeight',
  2464. clip: 'clip',
  2465. clippath: 'clipPath',
  2466. 'clip-path': 'clipPath',
  2467. clippathunits: 'clipPathUnits',
  2468. cliprule: 'clipRule',
  2469. 'clip-rule': 'clipRule',
  2470. color: 'color',
  2471. colorinterpolation: 'colorInterpolation',
  2472. 'color-interpolation': 'colorInterpolation',
  2473. colorinterpolationfilters: 'colorInterpolationFilters',
  2474. 'color-interpolation-filters': 'colorInterpolationFilters',
  2475. colorprofile: 'colorProfile',
  2476. 'color-profile': 'colorProfile',
  2477. colorrendering: 'colorRendering',
  2478. 'color-rendering': 'colorRendering',
  2479. contentscripttype: 'contentScriptType',
  2480. contentstyletype: 'contentStyleType',
  2481. cursor: 'cursor',
  2482. cx: 'cx',
  2483. cy: 'cy',
  2484. d: 'd',
  2485. datatype: 'datatype',
  2486. decelerate: 'decelerate',
  2487. descent: 'descent',
  2488. diffuseconstant: 'diffuseConstant',
  2489. direction: 'direction',
  2490. display: 'display',
  2491. divisor: 'divisor',
  2492. dominantbaseline: 'dominantBaseline',
  2493. 'dominant-baseline': 'dominantBaseline',
  2494. dur: 'dur',
  2495. dx: 'dx',
  2496. dy: 'dy',
  2497. edgemode: 'edgeMode',
  2498. elevation: 'elevation',
  2499. enablebackground: 'enableBackground',
  2500. 'enable-background': 'enableBackground',
  2501. end: 'end',
  2502. exponent: 'exponent',
  2503. externalresourcesrequired: 'externalResourcesRequired',
  2504. fill: 'fill',
  2505. fillopacity: 'fillOpacity',
  2506. 'fill-opacity': 'fillOpacity',
  2507. fillrule: 'fillRule',
  2508. 'fill-rule': 'fillRule',
  2509. filter: 'filter',
  2510. filterres: 'filterRes',
  2511. filterunits: 'filterUnits',
  2512. floodopacity: 'floodOpacity',
  2513. 'flood-opacity': 'floodOpacity',
  2514. floodcolor: 'floodColor',
  2515. 'flood-color': 'floodColor',
  2516. focusable: 'focusable',
  2517. fontfamily: 'fontFamily',
  2518. 'font-family': 'fontFamily',
  2519. fontsize: 'fontSize',
  2520. 'font-size': 'fontSize',
  2521. fontsizeadjust: 'fontSizeAdjust',
  2522. 'font-size-adjust': 'fontSizeAdjust',
  2523. fontstretch: 'fontStretch',
  2524. 'font-stretch': 'fontStretch',
  2525. fontstyle: 'fontStyle',
  2526. 'font-style': 'fontStyle',
  2527. fontvariant: 'fontVariant',
  2528. 'font-variant': 'fontVariant',
  2529. fontweight: 'fontWeight',
  2530. 'font-weight': 'fontWeight',
  2531. format: 'format',
  2532. from: 'from',
  2533. fx: 'fx',
  2534. fy: 'fy',
  2535. g1: 'g1',
  2536. g2: 'g2',
  2537. glyphname: 'glyphName',
  2538. 'glyph-name': 'glyphName',
  2539. glyphorientationhorizontal: 'glyphOrientationHorizontal',
  2540. 'glyph-orientation-horizontal': 'glyphOrientationHorizontal',
  2541. glyphorientationvertical: 'glyphOrientationVertical',
  2542. 'glyph-orientation-vertical': 'glyphOrientationVertical',
  2543. glyphref: 'glyphRef',
  2544. gradienttransform: 'gradientTransform',
  2545. gradientunits: 'gradientUnits',
  2546. hanging: 'hanging',
  2547. horizadvx: 'horizAdvX',
  2548. 'horiz-adv-x': 'horizAdvX',
  2549. horizoriginx: 'horizOriginX',
  2550. 'horiz-origin-x': 'horizOriginX',
  2551. ideographic: 'ideographic',
  2552. imagerendering: 'imageRendering',
  2553. 'image-rendering': 'imageRendering',
  2554. in2: 'in2',
  2555. in: 'in',
  2556. inlist: 'inlist',
  2557. intercept: 'intercept',
  2558. k1: 'k1',
  2559. k2: 'k2',
  2560. k3: 'k3',
  2561. k4: 'k4',
  2562. k: 'k',
  2563. kernelmatrix: 'kernelMatrix',
  2564. kernelunitlength: 'kernelUnitLength',
  2565. kerning: 'kerning',
  2566. keypoints: 'keyPoints',
  2567. keysplines: 'keySplines',
  2568. keytimes: 'keyTimes',
  2569. lengthadjust: 'lengthAdjust',
  2570. letterspacing: 'letterSpacing',
  2571. 'letter-spacing': 'letterSpacing',
  2572. lightingcolor: 'lightingColor',
  2573. 'lighting-color': 'lightingColor',
  2574. limitingconeangle: 'limitingConeAngle',
  2575. local: 'local',
  2576. markerend: 'markerEnd',
  2577. 'marker-end': 'markerEnd',
  2578. markerheight: 'markerHeight',
  2579. markermid: 'markerMid',
  2580. 'marker-mid': 'markerMid',
  2581. markerstart: 'markerStart',
  2582. 'marker-start': 'markerStart',
  2583. markerunits: 'markerUnits',
  2584. markerwidth: 'markerWidth',
  2585. mask: 'mask',
  2586. maskcontentunits: 'maskContentUnits',
  2587. maskunits: 'maskUnits',
  2588. mathematical: 'mathematical',
  2589. mode: 'mode',
  2590. numoctaves: 'numOctaves',
  2591. offset: 'offset',
  2592. opacity: 'opacity',
  2593. operator: 'operator',
  2594. order: 'order',
  2595. orient: 'orient',
  2596. orientation: 'orientation',
  2597. origin: 'origin',
  2598. overflow: 'overflow',
  2599. overlineposition: 'overlinePosition',
  2600. 'overline-position': 'overlinePosition',
  2601. overlinethickness: 'overlineThickness',
  2602. 'overline-thickness': 'overlineThickness',
  2603. paintorder: 'paintOrder',
  2604. 'paint-order': 'paintOrder',
  2605. panose1: 'panose1',
  2606. 'panose-1': 'panose1',
  2607. pathlength: 'pathLength',
  2608. patterncontentunits: 'patternContentUnits',
  2609. patterntransform: 'patternTransform',
  2610. patternunits: 'patternUnits',
  2611. pointerevents: 'pointerEvents',
  2612. 'pointer-events': 'pointerEvents',
  2613. points: 'points',
  2614. pointsatx: 'pointsAtX',
  2615. pointsaty: 'pointsAtY',
  2616. pointsatz: 'pointsAtZ',
  2617. prefix: 'prefix',
  2618. preservealpha: 'preserveAlpha',
  2619. preserveaspectratio: 'preserveAspectRatio',
  2620. primitiveunits: 'primitiveUnits',
  2621. property: 'property',
  2622. r: 'r',
  2623. radius: 'radius',
  2624. refx: 'refX',
  2625. refy: 'refY',
  2626. renderingintent: 'renderingIntent',
  2627. 'rendering-intent': 'renderingIntent',
  2628. repeatcount: 'repeatCount',
  2629. repeatdur: 'repeatDur',
  2630. requiredextensions: 'requiredExtensions',
  2631. requiredfeatures: 'requiredFeatures',
  2632. resource: 'resource',
  2633. restart: 'restart',
  2634. result: 'result',
  2635. results: 'results',
  2636. rotate: 'rotate',
  2637. rx: 'rx',
  2638. ry: 'ry',
  2639. scale: 'scale',
  2640. security: 'security',
  2641. seed: 'seed',
  2642. shaperendering: 'shapeRendering',
  2643. 'shape-rendering': 'shapeRendering',
  2644. slope: 'slope',
  2645. spacing: 'spacing',
  2646. specularconstant: 'specularConstant',
  2647. specularexponent: 'specularExponent',
  2648. speed: 'speed',
  2649. spreadmethod: 'spreadMethod',
  2650. startoffset: 'startOffset',
  2651. stddeviation: 'stdDeviation',
  2652. stemh: 'stemh',
  2653. stemv: 'stemv',
  2654. stitchtiles: 'stitchTiles',
  2655. stopcolor: 'stopColor',
  2656. 'stop-color': 'stopColor',
  2657. stopopacity: 'stopOpacity',
  2658. 'stop-opacity': 'stopOpacity',
  2659. strikethroughposition: 'strikethroughPosition',
  2660. 'strikethrough-position': 'strikethroughPosition',
  2661. strikethroughthickness: 'strikethroughThickness',
  2662. 'strikethrough-thickness': 'strikethroughThickness',
  2663. string: 'string',
  2664. stroke: 'stroke',
  2665. strokedasharray: 'strokeDasharray',
  2666. 'stroke-dasharray': 'strokeDasharray',
  2667. strokedashoffset: 'strokeDashoffset',
  2668. 'stroke-dashoffset': 'strokeDashoffset',
  2669. strokelinecap: 'strokeLinecap',
  2670. 'stroke-linecap': 'strokeLinecap',
  2671. strokelinejoin: 'strokeLinejoin',
  2672. 'stroke-linejoin': 'strokeLinejoin',
  2673. strokemiterlimit: 'strokeMiterlimit',
  2674. 'stroke-miterlimit': 'strokeMiterlimit',
  2675. strokewidth: 'strokeWidth',
  2676. 'stroke-width': 'strokeWidth',
  2677. strokeopacity: 'strokeOpacity',
  2678. 'stroke-opacity': 'strokeOpacity',
  2679. suppresscontenteditablewarning: 'suppressContentEditableWarning',
  2680. suppresshydrationwarning: 'suppressHydrationWarning',
  2681. surfacescale: 'surfaceScale',
  2682. systemlanguage: 'systemLanguage',
  2683. tablevalues: 'tableValues',
  2684. targetx: 'targetX',
  2685. targety: 'targetY',
  2686. textanchor: 'textAnchor',
  2687. 'text-anchor': 'textAnchor',
  2688. textdecoration: 'textDecoration',
  2689. 'text-decoration': 'textDecoration',
  2690. textlength: 'textLength',
  2691. textrendering: 'textRendering',
  2692. 'text-rendering': 'textRendering',
  2693. to: 'to',
  2694. transform: 'transform',
  2695. typeof: 'typeof',
  2696. u1: 'u1',
  2697. u2: 'u2',
  2698. underlineposition: 'underlinePosition',
  2699. 'underline-position': 'underlinePosition',
  2700. underlinethickness: 'underlineThickness',
  2701. 'underline-thickness': 'underlineThickness',
  2702. unicode: 'unicode',
  2703. unicodebidi: 'unicodeBidi',
  2704. 'unicode-bidi': 'unicodeBidi',
  2705. unicoderange: 'unicodeRange',
  2706. 'unicode-range': 'unicodeRange',
  2707. unitsperem: 'unitsPerEm',
  2708. 'units-per-em': 'unitsPerEm',
  2709. unselectable: 'unselectable',
  2710. valphabetic: 'vAlphabetic',
  2711. 'v-alphabetic': 'vAlphabetic',
  2712. values: 'values',
  2713. vectoreffect: 'vectorEffect',
  2714. 'vector-effect': 'vectorEffect',
  2715. version: 'version',
  2716. vertadvy: 'vertAdvY',
  2717. 'vert-adv-y': 'vertAdvY',
  2718. vertoriginx: 'vertOriginX',
  2719. 'vert-origin-x': 'vertOriginX',
  2720. vertoriginy: 'vertOriginY',
  2721. 'vert-origin-y': 'vertOriginY',
  2722. vhanging: 'vHanging',
  2723. 'v-hanging': 'vHanging',
  2724. videographic: 'vIdeographic',
  2725. 'v-ideographic': 'vIdeographic',
  2726. viewbox: 'viewBox',
  2727. viewtarget: 'viewTarget',
  2728. visibility: 'visibility',
  2729. vmathematical: 'vMathematical',
  2730. 'v-mathematical': 'vMathematical',
  2731. vocab: 'vocab',
  2732. widths: 'widths',
  2733. wordspacing: 'wordSpacing',
  2734. 'word-spacing': 'wordSpacing',
  2735. writingmode: 'writingMode',
  2736. 'writing-mode': 'writingMode',
  2737. x1: 'x1',
  2738. x2: 'x2',
  2739. x: 'x',
  2740. xchannelselector: 'xChannelSelector',
  2741. xheight: 'xHeight',
  2742. 'x-height': 'xHeight',
  2743. xlinkactuate: 'xlinkActuate',
  2744. 'xlink:actuate': 'xlinkActuate',
  2745. xlinkarcrole: 'xlinkArcrole',
  2746. 'xlink:arcrole': 'xlinkArcrole',
  2747. xlinkhref: 'xlinkHref',
  2748. 'xlink:href': 'xlinkHref',
  2749. xlinkrole: 'xlinkRole',
  2750. 'xlink:role': 'xlinkRole',
  2751. xlinkshow: 'xlinkShow',
  2752. 'xlink:show': 'xlinkShow',
  2753. xlinktitle: 'xlinkTitle',
  2754. 'xlink:title': 'xlinkTitle',
  2755. xlinktype: 'xlinkType',
  2756. 'xlink:type': 'xlinkType',
  2757. xmlbase: 'xmlBase',
  2758. 'xml:base': 'xmlBase',
  2759. xmllang: 'xmlLang',
  2760. 'xml:lang': 'xmlLang',
  2761. xmlns: 'xmlns',
  2762. 'xml:space': 'xmlSpace',
  2763. xmlnsxlink: 'xmlnsXlink',
  2764. 'xmlns:xlink': 'xmlnsXlink',
  2765. xmlspace: 'xmlSpace',
  2766. y1: 'y1',
  2767. y2: 'y2',
  2768. y: 'y',
  2769. ychannelselector: 'yChannelSelector',
  2770. z: 'z',
  2771. zoomandpan: 'zoomAndPan'
  2772. };
  2773. var ariaProperties = {
  2774. 'aria-current': 0,
  2775. // state
  2776. 'aria-details': 0,
  2777. 'aria-disabled': 0,
  2778. // state
  2779. 'aria-hidden': 0,
  2780. // state
  2781. 'aria-invalid': 0,
  2782. // state
  2783. 'aria-keyshortcuts': 0,
  2784. 'aria-label': 0,
  2785. 'aria-roledescription': 0,
  2786. // Widget Attributes
  2787. 'aria-autocomplete': 0,
  2788. 'aria-checked': 0,
  2789. 'aria-expanded': 0,
  2790. 'aria-haspopup': 0,
  2791. 'aria-level': 0,
  2792. 'aria-modal': 0,
  2793. 'aria-multiline': 0,
  2794. 'aria-multiselectable': 0,
  2795. 'aria-orientation': 0,
  2796. 'aria-placeholder': 0,
  2797. 'aria-pressed': 0,
  2798. 'aria-readonly': 0,
  2799. 'aria-required': 0,
  2800. 'aria-selected': 0,
  2801. 'aria-sort': 0,
  2802. 'aria-valuemax': 0,
  2803. 'aria-valuemin': 0,
  2804. 'aria-valuenow': 0,
  2805. 'aria-valuetext': 0,
  2806. // Live Region Attributes
  2807. 'aria-atomic': 0,
  2808. 'aria-busy': 0,
  2809. 'aria-live': 0,
  2810. 'aria-relevant': 0,
  2811. // Drag-and-Drop Attributes
  2812. 'aria-dropeffect': 0,
  2813. 'aria-grabbed': 0,
  2814. // Relationship Attributes
  2815. 'aria-activedescendant': 0,
  2816. 'aria-colcount': 0,
  2817. 'aria-colindex': 0,
  2818. 'aria-colspan': 0,
  2819. 'aria-controls': 0,
  2820. 'aria-describedby': 0,
  2821. 'aria-errormessage': 0,
  2822. 'aria-flowto': 0,
  2823. 'aria-labelledby': 0,
  2824. 'aria-owns': 0,
  2825. 'aria-posinset': 0,
  2826. 'aria-rowcount': 0,
  2827. 'aria-rowindex': 0,
  2828. 'aria-rowspan': 0,
  2829. 'aria-setsize': 0
  2830. };
  2831. var warnedProperties = {};
  2832. var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
  2833. var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
  2834. var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  2835. function validateProperty(tagName, name) {
  2836. {
  2837. if (hasOwnProperty$1.call(warnedProperties, name) && warnedProperties[name]) {
  2838. return true;
  2839. }
  2840. if (rARIACamel.test(name)) {
  2841. var ariaName = 'aria-' + name.slice(4).toLowerCase();
  2842. var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null; // If this is an aria-* attribute, but is not listed in the known DOM
  2843. // DOM properties, then it is an invalid aria-* attribute.
  2844. if (correctName == null) {
  2845. error('Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.', name);
  2846. warnedProperties[name] = true;
  2847. return true;
  2848. } // aria-* attributes should be lowercase; suggest the lowercase version.
  2849. if (name !== correctName) {
  2850. error('Invalid ARIA attribute `%s`. Did you mean `%s`?', name, correctName);
  2851. warnedProperties[name] = true;
  2852. return true;
  2853. }
  2854. }
  2855. if (rARIA.test(name)) {
  2856. var lowerCasedName = name.toLowerCase();
  2857. var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null; // If this is an aria-* attribute, but is not listed in the known DOM
  2858. // DOM properties, then it is an invalid aria-* attribute.
  2859. if (standardName == null) {
  2860. warnedProperties[name] = true;
  2861. return false;
  2862. } // aria-* attributes should be lowercase; suggest the lowercase version.
  2863. if (name !== standardName) {
  2864. error('Unknown ARIA attribute `%s`. Did you mean `%s`?', name, standardName);
  2865. warnedProperties[name] = true;
  2866. return true;
  2867. }
  2868. }
  2869. }
  2870. return true;
  2871. }
  2872. function warnInvalidARIAProps(type, props) {
  2873. {
  2874. var invalidProps = [];
  2875. for (var key in props) {
  2876. var isValid = validateProperty(type, key);
  2877. if (!isValid) {
  2878. invalidProps.push(key);
  2879. }
  2880. }
  2881. var unknownPropString = invalidProps.map(function (prop) {
  2882. return '`' + prop + '`';
  2883. }).join(', ');
  2884. if (invalidProps.length === 1) {
  2885. error('Invalid aria prop %s on <%s> tag. ' + 'For details, see https://reactjs.org/link/invalid-aria-props', unknownPropString, type);
  2886. } else if (invalidProps.length > 1) {
  2887. error('Invalid aria props %s on <%s> tag. ' + 'For details, see https://reactjs.org/link/invalid-aria-props', unknownPropString, type);
  2888. }
  2889. }
  2890. }
  2891. function validateProperties(type, props) {
  2892. if (isCustomComponent(type, props)) {
  2893. return;
  2894. }
  2895. warnInvalidARIAProps(type, props);
  2896. }
  2897. var didWarnValueNull = false;
  2898. function validateProperties$1(type, props) {
  2899. {
  2900. if (type !== 'input' && type !== 'textarea' && type !== 'select') {
  2901. return;
  2902. }
  2903. if (props != null && props.value === null && !didWarnValueNull) {
  2904. didWarnValueNull = true;
  2905. if (type === 'select' && props.multiple) {
  2906. error('`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);
  2907. } else {
  2908. error('`value` prop on `%s` should not be null. ' + 'Consider using an empty string to clear the component or `undefined` ' + 'for uncontrolled components.', type);
  2909. }
  2910. }
  2911. }
  2912. }
  2913. var validateProperty$1 = function () {};
  2914. {
  2915. var warnedProperties$1 = {};
  2916. var _hasOwnProperty = Object.prototype.hasOwnProperty;
  2917. var EVENT_NAME_REGEX = /^on./;
  2918. var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/;
  2919. var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
  2920. var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
  2921. validateProperty$1 = function (tagName, name, value, eventRegistry) {
  2922. if (_hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) {
  2923. return true;
  2924. }
  2925. var lowerCasedName = name.toLowerCase();
  2926. if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') {
  2927. error('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.');
  2928. warnedProperties$1[name] = true;
  2929. return true;
  2930. } // We can't rely on the event system being injected on the server.
  2931. if (eventRegistry != null) {
  2932. var registrationNameDependencies = eventRegistry.registrationNameDependencies,
  2933. possibleRegistrationNames = eventRegistry.possibleRegistrationNames;
  2934. if (registrationNameDependencies.hasOwnProperty(name)) {
  2935. return true;
  2936. }
  2937. var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null;
  2938. if (registrationName != null) {
  2939. error('Invalid event handler property `%s`. Did you mean `%s`?', name, registrationName);
  2940. warnedProperties$1[name] = true;
  2941. return true;
  2942. }
  2943. if (EVENT_NAME_REGEX.test(name)) {
  2944. error('Unknown event handler property `%s`. It will be ignored.', name);
  2945. warnedProperties$1[name] = true;
  2946. return true;
  2947. }
  2948. } else if (EVENT_NAME_REGEX.test(name)) {
  2949. // If no event plugins have been injected, we are in a server environment.
  2950. // So we can't tell if the event name is correct for sure, but we can filter
  2951. // out known bad ones like `onclick`. We can't suggest a specific replacement though.
  2952. if (INVALID_EVENT_NAME_REGEX.test(name)) {
  2953. error('Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.', name);
  2954. }
  2955. warnedProperties$1[name] = true;
  2956. return true;
  2957. } // Let the ARIA attribute hook validate ARIA attributes
  2958. if (rARIA$1.test(name) || rARIACamel$1.test(name)) {
  2959. return true;
  2960. }
  2961. if (lowerCasedName === 'innerhtml') {
  2962. error('Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.');
  2963. warnedProperties$1[name] = true;
  2964. return true;
  2965. }
  2966. if (lowerCasedName === 'aria') {
  2967. error('The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.');
  2968. warnedProperties$1[name] = true;
  2969. return true;
  2970. }
  2971. if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') {
  2972. error('Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.', typeof value);
  2973. warnedProperties$1[name] = true;
  2974. return true;
  2975. }
  2976. if (typeof value === 'number' && isNaN(value)) {
  2977. error('Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.', name);
  2978. warnedProperties$1[name] = true;
  2979. return true;
  2980. }
  2981. var propertyInfo = getPropertyInfo(name);
  2982. var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED; // Known attributes should match the casing specified in the property config.
  2983. if (possibleStandardNames.hasOwnProperty(lowerCasedName)) {
  2984. var standardName = possibleStandardNames[lowerCasedName];
  2985. if (standardName !== name) {
  2986. error('Invalid DOM property `%s`. Did you mean `%s`?', name, standardName);
  2987. warnedProperties$1[name] = true;
  2988. return true;
  2989. }
  2990. } else if (!isReserved && name !== lowerCasedName) {
  2991. // Unknown attributes should have lowercase casing since that's how they
  2992. // will be cased anyway with server rendering.
  2993. error('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);
  2994. warnedProperties$1[name] = true;
  2995. return true;
  2996. }
  2997. if (typeof value === 'boolean' && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
  2998. if (value) {
  2999. error('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);
  3000. } else {
  3001. error('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);
  3002. }
  3003. warnedProperties$1[name] = true;
  3004. return true;
  3005. } // Now that we've validated casing, do not validate
  3006. // data types for reserved props
  3007. if (isReserved) {
  3008. return true;
  3009. } // Warn when a known attribute is a bad type
  3010. if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
  3011. warnedProperties$1[name] = true;
  3012. return false;
  3013. } // Warn when passing the strings 'false' or 'true' into a boolean prop
  3014. if ((value === 'false' || value === 'true') && propertyInfo !== null && propertyInfo.type === BOOLEAN) {
  3015. error('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);
  3016. warnedProperties$1[name] = true;
  3017. return true;
  3018. }
  3019. return true;
  3020. };
  3021. }
  3022. var warnUnknownProperties = function (type, props, eventRegistry) {
  3023. {
  3024. var unknownProps = [];
  3025. for (var key in props) {
  3026. var isValid = validateProperty$1(type, key, props[key], eventRegistry);
  3027. if (!isValid) {
  3028. unknownProps.push(key);
  3029. }
  3030. }
  3031. var unknownPropString = unknownProps.map(function (prop) {
  3032. return '`' + prop + '`';
  3033. }).join(', ');
  3034. if (unknownProps.length === 1) {
  3035. error('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://reactjs.org/link/attribute-behavior ', unknownPropString, type);
  3036. } else if (unknownProps.length > 1) {
  3037. error('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://reactjs.org/link/attribute-behavior ', unknownPropString, type);
  3038. }
  3039. }
  3040. };
  3041. function validateProperties$2(type, props, eventRegistry) {
  3042. if (isCustomComponent(type, props)) {
  3043. return;
  3044. }
  3045. warnUnknownProperties(type, props, eventRegistry);
  3046. }
  3047. var IS_EVENT_HANDLE_NON_MANAGED_NODE = 1;
  3048. var IS_NON_DELEGATED = 1 << 1;
  3049. var IS_CAPTURE_PHASE = 1 << 2;
  3050. var IS_REPLAYED = 1 << 4;
  3051. // set to LEGACY_FB_SUPPORT. LEGACY_FB_SUPPORT only gets set when
  3052. // we call willDeferLaterForLegacyFBSupport, thus not bailing out
  3053. // will result in endless cycles like an infinite loop.
  3054. // We also don't want to defer during event replaying.
  3055. var SHOULD_NOT_PROCESS_POLYFILL_EVENT_PLUGINS = IS_EVENT_HANDLE_NON_MANAGED_NODE | IS_NON_DELEGATED | IS_CAPTURE_PHASE;
  3056. /**
  3057. * Gets the target node from a native browser event by accounting for
  3058. * inconsistencies in browser DOM APIs.
  3059. *
  3060. * @param {object} nativeEvent Native browser event.
  3061. * @return {DOMEventTarget} Target node.
  3062. */
  3063. function getEventTarget(nativeEvent) {
  3064. // Fallback to nativeEvent.srcElement for IE9
  3065. // https://github.com/facebook/react/issues/12506
  3066. var target = nativeEvent.target || nativeEvent.srcElement || window; // Normalize SVG <use> element events #4963
  3067. if (target.correspondingUseElement) {
  3068. target = target.correspondingUseElement;
  3069. } // Safari may fire events on text nodes (Node.TEXT_NODE is 3).
  3070. // @see http://www.quirksmode.org/js/events_properties.html
  3071. return target.nodeType === TEXT_NODE ? target.parentNode : target;
  3072. }
  3073. var restoreImpl = null;
  3074. var restoreTarget = null;
  3075. var restoreQueue = null;
  3076. function restoreStateOfTarget(target) {
  3077. // We perform this translation at the end of the event loop so that we
  3078. // always receive the correct fiber here
  3079. var internalInstance = getInstanceFromNode(target);
  3080. if (!internalInstance) {
  3081. // Unmounted
  3082. return;
  3083. }
  3084. if (!(typeof restoreImpl === 'function')) {
  3085. {
  3086. throw Error( "setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue." );
  3087. }
  3088. }
  3089. var stateNode = internalInstance.stateNode; // Guard against Fiber being unmounted.
  3090. if (stateNode) {
  3091. var _props = getFiberCurrentPropsFromNode(stateNode);
  3092. restoreImpl(internalInstance.stateNode, internalInstance.type, _props);
  3093. }
  3094. }
  3095. function setRestoreImplementation(impl) {
  3096. restoreImpl = impl;
  3097. }
  3098. function enqueueStateRestore(target) {
  3099. if (restoreTarget) {
  3100. if (restoreQueue) {
  3101. restoreQueue.push(target);
  3102. } else {
  3103. restoreQueue = [target];
  3104. }
  3105. } else {
  3106. restoreTarget = target;
  3107. }
  3108. }
  3109. function needsStateRestore() {
  3110. return restoreTarget !== null || restoreQueue !== null;
  3111. }
  3112. function restoreStateIfNeeded() {
  3113. if (!restoreTarget) {
  3114. return;
  3115. }
  3116. var target = restoreTarget;
  3117. var queuedTargets = restoreQueue;
  3118. restoreTarget = null;
  3119. restoreQueue = null;
  3120. restoreStateOfTarget(target);
  3121. if (queuedTargets) {
  3122. for (var i = 0; i < queuedTargets.length; i++) {
  3123. restoreStateOfTarget(queuedTargets[i]);
  3124. }
  3125. }
  3126. }
  3127. // the renderer. Such as when we're dispatching events or if third party
  3128. // libraries need to call batchedUpdates. Eventually, this API will go away when
  3129. // everything is batched by default. We'll then have a similar API to opt-out of
  3130. // scheduled work and instead do synchronous work.
  3131. // Defaults
  3132. var batchedUpdatesImpl = function (fn, bookkeeping) {
  3133. return fn(bookkeeping);
  3134. };
  3135. var discreteUpdatesImpl = function (fn, a, b, c, d) {
  3136. return fn(a, b, c, d);
  3137. };
  3138. var flushDiscreteUpdatesImpl = function () {};
  3139. var batchedEventUpdatesImpl = batchedUpdatesImpl;
  3140. var isInsideEventHandler = false;
  3141. var isBatchingEventUpdates = false;
  3142. function finishEventHandler() {
  3143. // Here we wait until all updates have propagated, which is important
  3144. // when using controlled components within layers:
  3145. // https://github.com/facebook/react/issues/1698
  3146. // Then we restore state of any controlled component.
  3147. var controlledComponentsHavePendingUpdates = needsStateRestore();
  3148. if (controlledComponentsHavePendingUpdates) {
  3149. // If a controlled event was fired, we may need to restore the state of
  3150. // the DOM node back to the controlled value. This is necessary when React
  3151. // bails out of the update without touching the DOM.
  3152. flushDiscreteUpdatesImpl();
  3153. restoreStateIfNeeded();
  3154. }
  3155. }
  3156. function batchedUpdates(fn, bookkeeping) {
  3157. if (isInsideEventHandler) {
  3158. // If we are currently inside another batch, we need to wait until it
  3159. // fully completes before restoring state.
  3160. return fn(bookkeeping);
  3161. }
  3162. isInsideEventHandler = true;
  3163. try {
  3164. return batchedUpdatesImpl(fn, bookkeeping);
  3165. } finally {
  3166. isInsideEventHandler = false;
  3167. finishEventHandler();
  3168. }
  3169. }
  3170. function batchedEventUpdates(fn, a, b) {
  3171. if (isBatchingEventUpdates) {
  3172. // If we are currently inside another batch, we need to wait until it
  3173. // fully completes before restoring state.
  3174. return fn(a, b);
  3175. }
  3176. isBatchingEventUpdates = true;
  3177. try {
  3178. return batchedEventUpdatesImpl(fn, a, b);
  3179. } finally {
  3180. isBatchingEventUpdates = false;
  3181. finishEventHandler();
  3182. }
  3183. }
  3184. function discreteUpdates(fn, a, b, c, d) {
  3185. var prevIsInsideEventHandler = isInsideEventHandler;
  3186. isInsideEventHandler = true;
  3187. try {
  3188. return discreteUpdatesImpl(fn, a, b, c, d);
  3189. } finally {
  3190. isInsideEventHandler = prevIsInsideEventHandler;
  3191. if (!isInsideEventHandler) {
  3192. finishEventHandler();
  3193. }
  3194. }
  3195. }
  3196. function flushDiscreteUpdatesIfNeeded(timeStamp) {
  3197. {
  3198. if (!isInsideEventHandler) {
  3199. flushDiscreteUpdatesImpl();
  3200. }
  3201. }
  3202. }
  3203. function setBatchingImplementation(_batchedUpdatesImpl, _discreteUpdatesImpl, _flushDiscreteUpdatesImpl, _batchedEventUpdatesImpl) {
  3204. batchedUpdatesImpl = _batchedUpdatesImpl;
  3205. discreteUpdatesImpl = _discreteUpdatesImpl;
  3206. flushDiscreteUpdatesImpl = _flushDiscreteUpdatesImpl;
  3207. batchedEventUpdatesImpl = _batchedEventUpdatesImpl;
  3208. }
  3209. function isInteractive(tag) {
  3210. return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea';
  3211. }
  3212. function shouldPreventMouseEvent(name, type, props) {
  3213. switch (name) {
  3214. case 'onClick':
  3215. case 'onClickCapture':
  3216. case 'onDoubleClick':
  3217. case 'onDoubleClickCapture':
  3218. case 'onMouseDown':
  3219. case 'onMouseDownCapture':
  3220. case 'onMouseMove':
  3221. case 'onMouseMoveCapture':
  3222. case 'onMouseUp':
  3223. case 'onMouseUpCapture':
  3224. case 'onMouseEnter':
  3225. return !!(props.disabled && isInteractive(type));
  3226. default:
  3227. return false;
  3228. }
  3229. }
  3230. /**
  3231. * @param {object} inst The instance, which is the source of events.
  3232. * @param {string} registrationName Name of listener (e.g. `onClick`).
  3233. * @return {?function} The stored callback.
  3234. */
  3235. function getListener(inst, registrationName) {
  3236. var stateNode = inst.stateNode;
  3237. if (stateNode === null) {
  3238. // Work in progress (ex: onload events in incremental mode).
  3239. return null;
  3240. }
  3241. var props = getFiberCurrentPropsFromNode(stateNode);
  3242. if (props === null) {
  3243. // Work in progress.
  3244. return null;
  3245. }
  3246. var listener = props[registrationName];
  3247. if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
  3248. return null;
  3249. }
  3250. if (!(!listener || typeof listener === 'function')) {
  3251. {
  3252. throw Error( "Expected `" + registrationName + "` listener to be a function, instead got a value of `" + typeof listener + "` type." );
  3253. }
  3254. }
  3255. return listener;
  3256. }
  3257. var passiveBrowserEventsSupported = false; // Check if browser support events with passive listeners
  3258. // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
  3259. if (canUseDOM) {
  3260. try {
  3261. var options = {}; // $FlowFixMe: Ignore Flow complaining about needing a value
  3262. Object.defineProperty(options, 'passive', {
  3263. get: function () {
  3264. passiveBrowserEventsSupported = true;
  3265. }
  3266. });
  3267. window.addEventListener('test', options, options);
  3268. window.removeEventListener('test', options, options);
  3269. } catch (e) {
  3270. passiveBrowserEventsSupported = false;
  3271. }
  3272. }
  3273. function invokeGuardedCallbackProd(name, func, context, a, b, c, d, e, f) {
  3274. var funcArgs = Array.prototype.slice.call(arguments, 3);
  3275. try {
  3276. func.apply(context, funcArgs);
  3277. } catch (error) {
  3278. this.onError(error);
  3279. }
  3280. }
  3281. var invokeGuardedCallbackImpl = invokeGuardedCallbackProd;
  3282. {
  3283. // In DEV mode, we swap out invokeGuardedCallback for a special version
  3284. // that plays more nicely with the browser's DevTools. The idea is to preserve
  3285. // "Pause on exceptions" behavior. Because React wraps all user-provided
  3286. // functions in invokeGuardedCallback, and the production version of
  3287. // invokeGuardedCallback uses a try-catch, all user exceptions are treated
  3288. // like caught exceptions, and the DevTools won't pause unless the developer
  3289. // takes the extra step of enabling pause on caught exceptions. This is
  3290. // unintuitive, though, because even though React has caught the error, from
  3291. // the developer's perspective, the error is uncaught.
  3292. //
  3293. // To preserve the expected "Pause on exceptions" behavior, we don't use a
  3294. // try-catch in DEV. Instead, we synchronously dispatch a fake event to a fake
  3295. // DOM node, and call the user-provided callback from inside an event handler
  3296. // for that fake event. If the callback throws, the error is "captured" using
  3297. // a global event handler. But because the error happens in a different
  3298. // event loop context, it does not interrupt the normal program flow.
  3299. // Effectively, this gives us try-catch behavior without actually using
  3300. // try-catch. Neat!
  3301. // Check that the browser supports the APIs we need to implement our special
  3302. // DEV version of invokeGuardedCallback
  3303. if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
  3304. var fakeNode = document.createElement('react');
  3305. invokeGuardedCallbackImpl = function invokeGuardedCallbackDev(name, func, context, a, b, c, d, e, f) {
  3306. // If document doesn't exist we know for sure we will crash in this method
  3307. // when we call document.createEvent(). However this can cause confusing
  3308. // errors: https://github.com/facebookincubator/create-react-app/issues/3482
  3309. // So we preemptively throw with a better message instead.
  3310. if (!(typeof document !== 'undefined')) {
  3311. {
  3312. throw Error( "The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous." );
  3313. }
  3314. }
  3315. var evt = document.createEvent('Event');
  3316. var didCall = false; // Keeps track of whether the user-provided callback threw an error. We
  3317. // set this to true at the beginning, then set it to false right after
  3318. // calling the function. If the function errors, `didError` will never be
  3319. // set to false. This strategy works even if the browser is flaky and
  3320. // fails to call our global error handler, because it doesn't rely on
  3321. // the error event at all.
  3322. var didError = true; // Keeps track of the value of window.event so that we can reset it
  3323. // during the callback to let user code access window.event in the
  3324. // browsers that support it.
  3325. var windowEvent = window.event; // Keeps track of the descriptor of window.event to restore it after event
  3326. // dispatching: https://github.com/facebook/react/issues/13688
  3327. var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, 'event');
  3328. function restoreAfterDispatch() {
  3329. // We immediately remove the callback from event listeners so that
  3330. // nested `invokeGuardedCallback` calls do not clash. Otherwise, a
  3331. // nested call would trigger the fake event handlers of any call higher
  3332. // in the stack.
  3333. fakeNode.removeEventListener(evtType, callCallback, false); // We check for window.hasOwnProperty('event') to prevent the
  3334. // window.event assignment in both IE <= 10 as they throw an error
  3335. // "Member not found" in strict mode, and in Firefox which does not
  3336. // support window.event.
  3337. if (typeof window.event !== 'undefined' && window.hasOwnProperty('event')) {
  3338. window.event = windowEvent;
  3339. }
  3340. } // Create an event handler for our fake event. We will synchronously
  3341. // dispatch our fake event using `dispatchEvent`. Inside the handler, we
  3342. // call the user-provided callback.
  3343. var funcArgs = Array.prototype.slice.call(arguments, 3);
  3344. function callCallback() {
  3345. didCall = true;
  3346. restoreAfterDispatch();
  3347. func.apply(context, funcArgs);
  3348. didError = false;
  3349. } // Create a global error event handler. We use this to capture the value
  3350. // that was thrown. It's possible that this error handler will fire more
  3351. // than once; for example, if non-React code also calls `dispatchEvent`
  3352. // and a handler for that event throws. We should be resilient to most of
  3353. // those cases. Even if our error event handler fires more than once, the
  3354. // last error event is always used. If the callback actually does error,
  3355. // we know that the last error event is the correct one, because it's not
  3356. // possible for anything else to have happened in between our callback
  3357. // erroring and the code that follows the `dispatchEvent` call below. If
  3358. // the callback doesn't error, but the error event was fired, we know to
  3359. // ignore it because `didError` will be false, as described above.
  3360. var error; // Use this to track whether the error event is ever called.
  3361. var didSetError = false;
  3362. var isCrossOriginError = false;
  3363. function handleWindowError(event) {
  3364. error = event.error;
  3365. didSetError = true;
  3366. if (error === null && event.colno === 0 && event.lineno === 0) {
  3367. isCrossOriginError = true;
  3368. }
  3369. if (event.defaultPrevented) {
  3370. // Some other error handler has prevented default.
  3371. // Browsers silence the error report if this happens.
  3372. // We'll remember this to later decide whether to log it or not.
  3373. if (error != null && typeof error === 'object') {
  3374. try {
  3375. error._suppressLogging = true;
  3376. } catch (inner) {// Ignore.
  3377. }
  3378. }
  3379. }
  3380. } // Create a fake event type.
  3381. var evtType = "react-" + (name ? name : 'invokeguardedcallback'); // Attach our event handlers
  3382. window.addEventListener('error', handleWindowError);
  3383. fakeNode.addEventListener(evtType, callCallback, false); // Synchronously dispatch our fake event. If the user-provided function
  3384. // errors, it will trigger our global error handler.
  3385. evt.initEvent(evtType, false, false);
  3386. fakeNode.dispatchEvent(evt);
  3387. if (windowEventDescriptor) {
  3388. Object.defineProperty(window, 'event', windowEventDescriptor);
  3389. }
  3390. if (didCall && didError) {
  3391. if (!didSetError) {
  3392. // The callback errored, but the error event never fired.
  3393. 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.');
  3394. } else if (isCrossOriginError) {
  3395. error = new Error("A cross-origin error was thrown. React doesn't have access to " + 'the actual error object in development. ' + 'See https://reactjs.org/link/crossorigin-error for more information.');
  3396. }
  3397. this.onError(error);
  3398. } // Remove our event listeners
  3399. window.removeEventListener('error', handleWindowError);
  3400. if (!didCall) {
  3401. // Something went really wrong, and our event was not dispatched.
  3402. // https://github.com/facebook/react/issues/16734
  3403. // https://github.com/facebook/react/issues/16585
  3404. // Fall back to the production implementation.
  3405. restoreAfterDispatch();
  3406. return invokeGuardedCallbackProd.apply(this, arguments);
  3407. }
  3408. };
  3409. }
  3410. }
  3411. var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl;
  3412. var hasError = false;
  3413. var caughtError = null; // Used by event system to capture/rethrow the first error.
  3414. var hasRethrowError = false;
  3415. var rethrowError = null;
  3416. var reporter = {
  3417. onError: function (error) {
  3418. hasError = true;
  3419. caughtError = error;
  3420. }
  3421. };
  3422. /**
  3423. * Call a function while guarding against errors that happens within it.
  3424. * Returns an error if it throws, otherwise null.
  3425. *
  3426. * In production, this is implemented using a try-catch. The reason we don't
  3427. * use a try-catch directly is so that we can swap out a different
  3428. * implementation in DEV mode.
  3429. *
  3430. * @param {String} name of the guard to use for logging or debugging
  3431. * @param {Function} func The function to invoke
  3432. * @param {*} context The context to use when calling the function
  3433. * @param {...*} args Arguments for function
  3434. */
  3435. function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) {
  3436. hasError = false;
  3437. caughtError = null;
  3438. invokeGuardedCallbackImpl$1.apply(reporter, arguments);
  3439. }
  3440. /**
  3441. * Same as invokeGuardedCallback, but instead of returning an error, it stores
  3442. * it in a global so it can be rethrown by `rethrowCaughtError` later.
  3443. * TODO: See if caughtError and rethrowError can be unified.
  3444. *
  3445. * @param {String} name of the guard to use for logging or debugging
  3446. * @param {Function} func The function to invoke
  3447. * @param {*} context The context to use when calling the function
  3448. * @param {...*} args Arguments for function
  3449. */
  3450. function invokeGuardedCallbackAndCatchFirstError(name, func, context, a, b, c, d, e, f) {
  3451. invokeGuardedCallback.apply(this, arguments);
  3452. if (hasError) {
  3453. var error = clearCaughtError();
  3454. if (!hasRethrowError) {
  3455. hasRethrowError = true;
  3456. rethrowError = error;
  3457. }
  3458. }
  3459. }
  3460. /**
  3461. * During execution of guarded functions we will capture the first error which
  3462. * we will rethrow to be handled by the top level error handler.
  3463. */
  3464. function rethrowCaughtError() {
  3465. if (hasRethrowError) {
  3466. var error = rethrowError;
  3467. hasRethrowError = false;
  3468. rethrowError = null;
  3469. throw error;
  3470. }
  3471. }
  3472. function hasCaughtError() {
  3473. return hasError;
  3474. }
  3475. function clearCaughtError() {
  3476. if (hasError) {
  3477. var error = caughtError;
  3478. hasError = false;
  3479. caughtError = null;
  3480. return error;
  3481. } else {
  3482. {
  3483. {
  3484. throw Error( "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." );
  3485. }
  3486. }
  3487. }
  3488. }
  3489. /**
  3490. * `ReactInstanceMap` maintains a mapping from a public facing stateful
  3491. * instance (key) and the internal representation (value). This allows public
  3492. * methods to accept the user facing instance as an argument and map them back
  3493. * to internal methods.
  3494. *
  3495. * Note that this module is currently shared and assumed to be stateless.
  3496. * If this becomes an actual Map, that will break.
  3497. */
  3498. function get(key) {
  3499. return key._reactInternals;
  3500. }
  3501. function has(key) {
  3502. return key._reactInternals !== undefined;
  3503. }
  3504. function set(key, value) {
  3505. key._reactInternals = value;
  3506. }
  3507. // Don't change these two values. They're used by React Dev Tools.
  3508. var NoFlags =
  3509. /* */
  3510. 0;
  3511. var PerformedWork =
  3512. /* */
  3513. 1; // You can change the rest (and add more).
  3514. var Placement =
  3515. /* */
  3516. 2;
  3517. var Update =
  3518. /* */
  3519. 4;
  3520. var PlacementAndUpdate =
  3521. /* */
  3522. 6;
  3523. var Deletion =
  3524. /* */
  3525. 8;
  3526. var ContentReset =
  3527. /* */
  3528. 16;
  3529. var Callback =
  3530. /* */
  3531. 32;
  3532. var DidCapture =
  3533. /* */
  3534. 64;
  3535. var Ref =
  3536. /* */
  3537. 128;
  3538. var Snapshot =
  3539. /* */
  3540. 256;
  3541. var Passive =
  3542. /* */
  3543. 512; // TODO (effects) Remove this bit once the new reconciler is synced to the old.
  3544. var PassiveUnmountPendingDev =
  3545. /* */
  3546. 8192;
  3547. var Hydrating =
  3548. /* */
  3549. 1024;
  3550. var HydratingAndUpdate =
  3551. /* */
  3552. 1028; // Passive & Update & Callback & Ref & Snapshot
  3553. var LifecycleEffectMask =
  3554. /* */
  3555. 932; // Union of all host effects
  3556. var HostEffectMask =
  3557. /* */
  3558. 2047; // These are not really side effects, but we still reuse this field.
  3559. var Incomplete =
  3560. /* */
  3561. 2048;
  3562. var ShouldCapture =
  3563. /* */
  3564. 4096;
  3565. var ForceUpdateForLegacySuspense =
  3566. /* */
  3567. 16384; // Static tags describe aspects of a fiber that are not specific to a render,
  3568. var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
  3569. function getNearestMountedFiber(fiber) {
  3570. var node = fiber;
  3571. var nearestMounted = fiber;
  3572. if (!fiber.alternate) {
  3573. // If there is no alternate, this might be a new tree that isn't inserted
  3574. // yet. If it is, then it will have a pending insertion effect on it.
  3575. var nextNode = node;
  3576. do {
  3577. node = nextNode;
  3578. if ((node.flags & (Placement | Hydrating)) !== NoFlags) {
  3579. // This is an insertion or in-progress hydration. The nearest possible
  3580. // mounted fiber is the parent but we need to continue to figure out
  3581. // if that one is still mounted.
  3582. nearestMounted = node.return;
  3583. }
  3584. nextNode = node.return;
  3585. } while (nextNode);
  3586. } else {
  3587. while (node.return) {
  3588. node = node.return;
  3589. }
  3590. }
  3591. if (node.tag === HostRoot) {
  3592. // TODO: Check if this was a nested HostRoot when used with
  3593. // renderContainerIntoSubtree.
  3594. return nearestMounted;
  3595. } // If we didn't hit the root, that means that we're in an disconnected tree
  3596. // that has been unmounted.
  3597. return null;
  3598. }
  3599. function getSuspenseInstanceFromFiber(fiber) {
  3600. if (fiber.tag === SuspenseComponent) {
  3601. var suspenseState = fiber.memoizedState;
  3602. if (suspenseState === null) {
  3603. var current = fiber.alternate;
  3604. if (current !== null) {
  3605. suspenseState = current.memoizedState;
  3606. }
  3607. }
  3608. if (suspenseState !== null) {
  3609. return suspenseState.dehydrated;
  3610. }
  3611. }
  3612. return null;
  3613. }
  3614. function getContainerFromFiber(fiber) {
  3615. return fiber.tag === HostRoot ? fiber.stateNode.containerInfo : null;
  3616. }
  3617. function isFiberMounted(fiber) {
  3618. return getNearestMountedFiber(fiber) === fiber;
  3619. }
  3620. function isMounted(component) {
  3621. {
  3622. var owner = ReactCurrentOwner.current;
  3623. if (owner !== null && owner.tag === ClassComponent) {
  3624. var ownerFiber = owner;
  3625. var instance = ownerFiber.stateNode;
  3626. if (!instance._warnedAboutRefsInRender) {
  3627. error('%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');
  3628. }
  3629. instance._warnedAboutRefsInRender = true;
  3630. }
  3631. }
  3632. var fiber = get(component);
  3633. if (!fiber) {
  3634. return false;
  3635. }
  3636. return getNearestMountedFiber(fiber) === fiber;
  3637. }
  3638. function assertIsMounted(fiber) {
  3639. if (!(getNearestMountedFiber(fiber) === fiber)) {
  3640. {
  3641. throw Error( "Unable to find node on an unmounted component." );
  3642. }
  3643. }
  3644. }
  3645. function findCurrentFiberUsingSlowPath(fiber) {
  3646. var alternate = fiber.alternate;
  3647. if (!alternate) {
  3648. // If there is no alternate, then we only need to check if it is mounted.
  3649. var nearestMounted = getNearestMountedFiber(fiber);
  3650. if (!(nearestMounted !== null)) {
  3651. {
  3652. throw Error( "Unable to find node on an unmounted component." );
  3653. }
  3654. }
  3655. if (nearestMounted !== fiber) {
  3656. return null;
  3657. }
  3658. return fiber;
  3659. } // If we have two possible branches, we'll walk backwards up to the root
  3660. // to see what path the root points to. On the way we may hit one of the
  3661. // special cases and we'll deal with them.
  3662. var a = fiber;
  3663. var b = alternate;
  3664. while (true) {
  3665. var parentA = a.return;
  3666. if (parentA === null) {
  3667. // We're at the root.
  3668. break;
  3669. }
  3670. var parentB = parentA.alternate;
  3671. if (parentB === null) {
  3672. // There is no alternate. This is an unusual case. Currently, it only
  3673. // happens when a Suspense component is hidden. An extra fragment fiber
  3674. // is inserted in between the Suspense fiber and its children. Skip
  3675. // over this extra fragment fiber and proceed to the next parent.
  3676. var nextParent = parentA.return;
  3677. if (nextParent !== null) {
  3678. a = b = nextParent;
  3679. continue;
  3680. } // If there's no parent, we're at the root.
  3681. break;
  3682. } // If both copies of the parent fiber point to the same child, we can
  3683. // assume that the child is current. This happens when we bailout on low
  3684. // priority: the bailed out fiber's child reuses the current child.
  3685. if (parentA.child === parentB.child) {
  3686. var child = parentA.child;
  3687. while (child) {
  3688. if (child === a) {
  3689. // We've determined that A is the current branch.
  3690. assertIsMounted(parentA);
  3691. return fiber;
  3692. }
  3693. if (child === b) {
  3694. // We've determined that B is the current branch.
  3695. assertIsMounted(parentA);
  3696. return alternate;
  3697. }
  3698. child = child.sibling;
  3699. } // We should never have an alternate for any mounting node. So the only
  3700. // way this could possibly happen is if this was unmounted, if at all.
  3701. {
  3702. {
  3703. throw Error( "Unable to find node on an unmounted component." );
  3704. }
  3705. }
  3706. }
  3707. if (a.return !== b.return) {
  3708. // The return pointer of A and the return pointer of B point to different
  3709. // fibers. We assume that return pointers never criss-cross, so A must
  3710. // belong to the child set of A.return, and B must belong to the child
  3711. // set of B.return.
  3712. a = parentA;
  3713. b = parentB;
  3714. } else {
  3715. // The return pointers point to the same fiber. We'll have to use the
  3716. // default, slow path: scan the child sets of each parent alternate to see
  3717. // which child belongs to which set.
  3718. //
  3719. // Search parent A's child set
  3720. var didFindChild = false;
  3721. var _child = parentA.child;
  3722. while (_child) {
  3723. if (_child === a) {
  3724. didFindChild = true;
  3725. a = parentA;
  3726. b = parentB;
  3727. break;
  3728. }
  3729. if (_child === b) {
  3730. didFindChild = true;
  3731. b = parentA;
  3732. a = parentB;
  3733. break;
  3734. }
  3735. _child = _child.sibling;
  3736. }
  3737. if (!didFindChild) {
  3738. // Search parent B's child set
  3739. _child = parentB.child;
  3740. while (_child) {
  3741. if (_child === a) {
  3742. didFindChild = true;
  3743. a = parentB;
  3744. b = parentA;
  3745. break;
  3746. }
  3747. if (_child === b) {
  3748. didFindChild = true;
  3749. b = parentB;
  3750. a = parentA;
  3751. break;
  3752. }
  3753. _child = _child.sibling;
  3754. }
  3755. if (!didFindChild) {
  3756. {
  3757. throw Error( "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." );
  3758. }
  3759. }
  3760. }
  3761. }
  3762. if (!(a.alternate === b)) {
  3763. {
  3764. throw Error( "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." );
  3765. }
  3766. }
  3767. } // If the root is not a host container, we're in a disconnected tree. I.e.
  3768. // unmounted.
  3769. if (!(a.tag === HostRoot)) {
  3770. {
  3771. throw Error( "Unable to find node on an unmounted component." );
  3772. }
  3773. }
  3774. if (a.stateNode.current === a) {
  3775. // We've determined that A is the current branch.
  3776. return fiber;
  3777. } // Otherwise B has to be current branch.
  3778. return alternate;
  3779. }
  3780. function findCurrentHostFiber(parent) {
  3781. var currentParent = findCurrentFiberUsingSlowPath(parent);
  3782. if (!currentParent) {
  3783. return null;
  3784. } // Next we'll drill down this component to find the first HostComponent/Text.
  3785. var node = currentParent;
  3786. while (true) {
  3787. if (node.tag === HostComponent || node.tag === HostText) {
  3788. return node;
  3789. } else if (node.child) {
  3790. node.child.return = node;
  3791. node = node.child;
  3792. continue;
  3793. }
  3794. if (node === currentParent) {
  3795. return null;
  3796. }
  3797. while (!node.sibling) {
  3798. if (!node.return || node.return === currentParent) {
  3799. return null;
  3800. }
  3801. node = node.return;
  3802. }
  3803. node.sibling.return = node.return;
  3804. node = node.sibling;
  3805. } // Flow needs the return null here, but ESLint complains about it.
  3806. // eslint-disable-next-line no-unreachable
  3807. return null;
  3808. }
  3809. function findCurrentHostFiberWithNoPortals(parent) {
  3810. var currentParent = findCurrentFiberUsingSlowPath(parent);
  3811. if (!currentParent) {
  3812. return null;
  3813. } // Next we'll drill down this component to find the first HostComponent/Text.
  3814. var node = currentParent;
  3815. while (true) {
  3816. if (node.tag === HostComponent || node.tag === HostText || enableFundamentalAPI ) {
  3817. return node;
  3818. } else if (node.child && node.tag !== HostPortal) {
  3819. node.child.return = node;
  3820. node = node.child;
  3821. continue;
  3822. }
  3823. if (node === currentParent) {
  3824. return null;
  3825. }
  3826. while (!node.sibling) {
  3827. if (!node.return || node.return === currentParent) {
  3828. return null;
  3829. }
  3830. node = node.return;
  3831. }
  3832. node.sibling.return = node.return;
  3833. node = node.sibling;
  3834. } // Flow needs the return null here, but ESLint complains about it.
  3835. // eslint-disable-next-line no-unreachable
  3836. return null;
  3837. }
  3838. function doesFiberContain(parentFiber, childFiber) {
  3839. var node = childFiber;
  3840. var parentFiberAlternate = parentFiber.alternate;
  3841. while (node !== null) {
  3842. if (node === parentFiber || node === parentFiberAlternate) {
  3843. return true;
  3844. }
  3845. node = node.return;
  3846. }
  3847. return false;
  3848. }
  3849. var attemptUserBlockingHydration;
  3850. function setAttemptUserBlockingHydration(fn) {
  3851. attemptUserBlockingHydration = fn;
  3852. }
  3853. var attemptContinuousHydration;
  3854. function setAttemptContinuousHydration(fn) {
  3855. attemptContinuousHydration = fn;
  3856. }
  3857. var attemptHydrationAtCurrentPriority;
  3858. function setAttemptHydrationAtCurrentPriority(fn) {
  3859. attemptHydrationAtCurrentPriority = fn;
  3860. }
  3861. var attemptHydrationAtPriority;
  3862. function setAttemptHydrationAtPriority(fn) {
  3863. attemptHydrationAtPriority = fn;
  3864. } // TODO: Upgrade this definition once we're on a newer version of Flow that
  3865. var hasScheduledReplayAttempt = false; // The queue of discrete events to be replayed.
  3866. var queuedDiscreteEvents = []; // Indicates if any continuous event targets are non-null for early bailout.
  3867. // if the last target was dehydrated.
  3868. var queuedFocus = null;
  3869. var queuedDrag = null;
  3870. var queuedMouse = null; // For pointer events there can be one latest event per pointerId.
  3871. var queuedPointers = new Map();
  3872. var queuedPointerCaptures = new Map(); // We could consider replaying selectionchange and touchmoves too.
  3873. var queuedExplicitHydrationTargets = [];
  3874. function hasQueuedDiscreteEvents() {
  3875. return queuedDiscreteEvents.length > 0;
  3876. }
  3877. var discreteReplayableEvents = ['mousedown', 'mouseup', 'touchcancel', 'touchend', 'touchstart', 'auxclick', 'dblclick', 'pointercancel', 'pointerdown', 'pointerup', 'dragend', 'dragstart', 'drop', 'compositionend', 'compositionstart', 'keydown', 'keypress', 'keyup', 'input', 'textInput', // Intentionally camelCase
  3878. 'copy', 'cut', 'paste', 'click', 'change', 'contextmenu', 'reset', 'submit'];
  3879. function isReplayableDiscreteEvent(eventType) {
  3880. return discreteReplayableEvents.indexOf(eventType) > -1;
  3881. }
  3882. function createQueuedReplayableEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) {
  3883. return {
  3884. blockedOn: blockedOn,
  3885. domEventName: domEventName,
  3886. eventSystemFlags: eventSystemFlags | IS_REPLAYED,
  3887. nativeEvent: nativeEvent,
  3888. targetContainers: [targetContainer]
  3889. };
  3890. }
  3891. function queueDiscreteEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) {
  3892. var queuedEvent = createQueuedReplayableEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent);
  3893. queuedDiscreteEvents.push(queuedEvent);
  3894. } // Resets the replaying for this type of continuous event to no event.
  3895. function clearIfContinuousEvent(domEventName, nativeEvent) {
  3896. switch (domEventName) {
  3897. case 'focusin':
  3898. case 'focusout':
  3899. queuedFocus = null;
  3900. break;
  3901. case 'dragenter':
  3902. case 'dragleave':
  3903. queuedDrag = null;
  3904. break;
  3905. case 'mouseover':
  3906. case 'mouseout':
  3907. queuedMouse = null;
  3908. break;
  3909. case 'pointerover':
  3910. case 'pointerout':
  3911. {
  3912. var pointerId = nativeEvent.pointerId;
  3913. queuedPointers.delete(pointerId);
  3914. break;
  3915. }
  3916. case 'gotpointercapture':
  3917. case 'lostpointercapture':
  3918. {
  3919. var _pointerId = nativeEvent.pointerId;
  3920. queuedPointerCaptures.delete(_pointerId);
  3921. break;
  3922. }
  3923. }
  3924. }
  3925. function accumulateOrCreateContinuousQueuedReplayableEvent(existingQueuedEvent, blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) {
  3926. if (existingQueuedEvent === null || existingQueuedEvent.nativeEvent !== nativeEvent) {
  3927. var queuedEvent = createQueuedReplayableEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent);
  3928. if (blockedOn !== null) {
  3929. var _fiber2 = getInstanceFromNode(blockedOn);
  3930. if (_fiber2 !== null) {
  3931. // Attempt to increase the priority of this target.
  3932. attemptContinuousHydration(_fiber2);
  3933. }
  3934. }
  3935. return queuedEvent;
  3936. } // If we have already queued this exact event, then it's because
  3937. // the different event systems have different DOM event listeners.
  3938. // We can accumulate the flags, and the targetContainers, and
  3939. // store a single event to be replayed.
  3940. existingQueuedEvent.eventSystemFlags |= eventSystemFlags;
  3941. var targetContainers = existingQueuedEvent.targetContainers;
  3942. if (targetContainer !== null && targetContainers.indexOf(targetContainer) === -1) {
  3943. targetContainers.push(targetContainer);
  3944. }
  3945. return existingQueuedEvent;
  3946. }
  3947. function queueIfContinuousEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) {
  3948. // These set relatedTarget to null because the replayed event will be treated as if we
  3949. // moved from outside the window (no target) onto the target once it hydrates.
  3950. // Instead of mutating we could clone the event.
  3951. switch (domEventName) {
  3952. case 'focusin':
  3953. {
  3954. var focusEvent = nativeEvent;
  3955. queuedFocus = accumulateOrCreateContinuousQueuedReplayableEvent(queuedFocus, blockedOn, domEventName, eventSystemFlags, targetContainer, focusEvent);
  3956. return true;
  3957. }
  3958. case 'dragenter':
  3959. {
  3960. var dragEvent = nativeEvent;
  3961. queuedDrag = accumulateOrCreateContinuousQueuedReplayableEvent(queuedDrag, blockedOn, domEventName, eventSystemFlags, targetContainer, dragEvent);
  3962. return true;
  3963. }
  3964. case 'mouseover':
  3965. {
  3966. var mouseEvent = nativeEvent;
  3967. queuedMouse = accumulateOrCreateContinuousQueuedReplayableEvent(queuedMouse, blockedOn, domEventName, eventSystemFlags, targetContainer, mouseEvent);
  3968. return true;
  3969. }
  3970. case 'pointerover':
  3971. {
  3972. var pointerEvent = nativeEvent;
  3973. var pointerId = pointerEvent.pointerId;
  3974. queuedPointers.set(pointerId, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointers.get(pointerId) || null, blockedOn, domEventName, eventSystemFlags, targetContainer, pointerEvent));
  3975. return true;
  3976. }
  3977. case 'gotpointercapture':
  3978. {
  3979. var _pointerEvent = nativeEvent;
  3980. var _pointerId2 = _pointerEvent.pointerId;
  3981. queuedPointerCaptures.set(_pointerId2, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointerCaptures.get(_pointerId2) || null, blockedOn, domEventName, eventSystemFlags, targetContainer, _pointerEvent));
  3982. return true;
  3983. }
  3984. }
  3985. return false;
  3986. } // Check if this target is unblocked. Returns true if it's unblocked.
  3987. function attemptExplicitHydrationTarget(queuedTarget) {
  3988. // TODO: This function shares a lot of logic with attemptToDispatchEvent.
  3989. // Try to unify them. It's a bit tricky since it would require two return
  3990. // values.
  3991. var targetInst = getClosestInstanceFromNode(queuedTarget.target);
  3992. if (targetInst !== null) {
  3993. var nearestMounted = getNearestMountedFiber(targetInst);
  3994. if (nearestMounted !== null) {
  3995. var tag = nearestMounted.tag;
  3996. if (tag === SuspenseComponent) {
  3997. var instance = getSuspenseInstanceFromFiber(nearestMounted);
  3998. if (instance !== null) {
  3999. // We're blocked on hydrating this boundary.
  4000. // Increase its priority.
  4001. queuedTarget.blockedOn = instance;
  4002. attemptHydrationAtPriority(queuedTarget.lanePriority, function () {
  4003. Scheduler.unstable_runWithPriority(queuedTarget.priority, function () {
  4004. attemptHydrationAtCurrentPriority(nearestMounted);
  4005. });
  4006. });
  4007. return;
  4008. }
  4009. } else if (tag === HostRoot) {
  4010. var root = nearestMounted.stateNode;
  4011. if (root.hydrate) {
  4012. queuedTarget.blockedOn = getContainerFromFiber(nearestMounted); // We don't currently have a way to increase the priority of
  4013. // a root other than sync.
  4014. return;
  4015. }
  4016. }
  4017. }
  4018. }
  4019. queuedTarget.blockedOn = null;
  4020. }
  4021. function attemptReplayContinuousQueuedEvent(queuedEvent) {
  4022. if (queuedEvent.blockedOn !== null) {
  4023. return false;
  4024. }
  4025. var targetContainers = queuedEvent.targetContainers;
  4026. while (targetContainers.length > 0) {
  4027. var targetContainer = targetContainers[0];
  4028. var nextBlockedOn = attemptToDispatchEvent(queuedEvent.domEventName, queuedEvent.eventSystemFlags, targetContainer, queuedEvent.nativeEvent);
  4029. if (nextBlockedOn !== null) {
  4030. // We're still blocked. Try again later.
  4031. var _fiber3 = getInstanceFromNode(nextBlockedOn);
  4032. if (_fiber3 !== null) {
  4033. attemptContinuousHydration(_fiber3);
  4034. }
  4035. queuedEvent.blockedOn = nextBlockedOn;
  4036. return false;
  4037. } // This target container was successfully dispatched. Try the next.
  4038. targetContainers.shift();
  4039. }
  4040. return true;
  4041. }
  4042. function attemptReplayContinuousQueuedEventInMap(queuedEvent, key, map) {
  4043. if (attemptReplayContinuousQueuedEvent(queuedEvent)) {
  4044. map.delete(key);
  4045. }
  4046. }
  4047. function replayUnblockedEvents() {
  4048. hasScheduledReplayAttempt = false; // First replay discrete events.
  4049. while (queuedDiscreteEvents.length > 0) {
  4050. var nextDiscreteEvent = queuedDiscreteEvents[0];
  4051. if (nextDiscreteEvent.blockedOn !== null) {
  4052. // We're still blocked.
  4053. // Increase the priority of this boundary to unblock
  4054. // the next discrete event.
  4055. var _fiber4 = getInstanceFromNode(nextDiscreteEvent.blockedOn);
  4056. if (_fiber4 !== null) {
  4057. attemptUserBlockingHydration(_fiber4);
  4058. }
  4059. break;
  4060. }
  4061. var targetContainers = nextDiscreteEvent.targetContainers;
  4062. while (targetContainers.length > 0) {
  4063. var targetContainer = targetContainers[0];
  4064. var nextBlockedOn = attemptToDispatchEvent(nextDiscreteEvent.domEventName, nextDiscreteEvent.eventSystemFlags, targetContainer, nextDiscreteEvent.nativeEvent);
  4065. if (nextBlockedOn !== null) {
  4066. // We're still blocked. Try again later.
  4067. nextDiscreteEvent.blockedOn = nextBlockedOn;
  4068. break;
  4069. } // This target container was successfully dispatched. Try the next.
  4070. targetContainers.shift();
  4071. }
  4072. if (nextDiscreteEvent.blockedOn === null) {
  4073. // We've successfully replayed the first event. Let's try the next one.
  4074. queuedDiscreteEvents.shift();
  4075. }
  4076. } // Next replay any continuous events.
  4077. if (queuedFocus !== null && attemptReplayContinuousQueuedEvent(queuedFocus)) {
  4078. queuedFocus = null;
  4079. }
  4080. if (queuedDrag !== null && attemptReplayContinuousQueuedEvent(queuedDrag)) {
  4081. queuedDrag = null;
  4082. }
  4083. if (queuedMouse !== null && attemptReplayContinuousQueuedEvent(queuedMouse)) {
  4084. queuedMouse = null;
  4085. }
  4086. queuedPointers.forEach(attemptReplayContinuousQueuedEventInMap);
  4087. queuedPointerCaptures.forEach(attemptReplayContinuousQueuedEventInMap);
  4088. }
  4089. function scheduleCallbackIfUnblocked(queuedEvent, unblocked) {
  4090. if (queuedEvent.blockedOn === unblocked) {
  4091. queuedEvent.blockedOn = null;
  4092. if (!hasScheduledReplayAttempt) {
  4093. hasScheduledReplayAttempt = true; // Schedule a callback to attempt replaying as many events as are
  4094. // now unblocked. This first might not actually be unblocked yet.
  4095. // We could check it early to avoid scheduling an unnecessary callback.
  4096. Scheduler.unstable_scheduleCallback(Scheduler.unstable_NormalPriority, replayUnblockedEvents);
  4097. }
  4098. }
  4099. }
  4100. function retryIfBlockedOn(unblocked) {
  4101. // Mark anything that was blocked on this as no longer blocked
  4102. // and eligible for a replay.
  4103. if (queuedDiscreteEvents.length > 0) {
  4104. scheduleCallbackIfUnblocked(queuedDiscreteEvents[0], unblocked); // This is a exponential search for each boundary that commits. I think it's
  4105. // worth it because we expect very few discrete events to queue up and once
  4106. // we are actually fully unblocked it will be fast to replay them.
  4107. for (var i = 1; i < queuedDiscreteEvents.length; i++) {
  4108. var queuedEvent = queuedDiscreteEvents[i];
  4109. if (queuedEvent.blockedOn === unblocked) {
  4110. queuedEvent.blockedOn = null;
  4111. }
  4112. }
  4113. }
  4114. if (queuedFocus !== null) {
  4115. scheduleCallbackIfUnblocked(queuedFocus, unblocked);
  4116. }
  4117. if (queuedDrag !== null) {
  4118. scheduleCallbackIfUnblocked(queuedDrag, unblocked);
  4119. }
  4120. if (queuedMouse !== null) {
  4121. scheduleCallbackIfUnblocked(queuedMouse, unblocked);
  4122. }
  4123. var unblock = function (queuedEvent) {
  4124. return scheduleCallbackIfUnblocked(queuedEvent, unblocked);
  4125. };
  4126. queuedPointers.forEach(unblock);
  4127. queuedPointerCaptures.forEach(unblock);
  4128. for (var _i = 0; _i < queuedExplicitHydrationTargets.length; _i++) {
  4129. var queuedTarget = queuedExplicitHydrationTargets[_i];
  4130. if (queuedTarget.blockedOn === unblocked) {
  4131. queuedTarget.blockedOn = null;
  4132. }
  4133. }
  4134. while (queuedExplicitHydrationTargets.length > 0) {
  4135. var nextExplicitTarget = queuedExplicitHydrationTargets[0];
  4136. if (nextExplicitTarget.blockedOn !== null) {
  4137. // We're still blocked.
  4138. break;
  4139. } else {
  4140. attemptExplicitHydrationTarget(nextExplicitTarget);
  4141. if (nextExplicitTarget.blockedOn === null) {
  4142. // We're unblocked.
  4143. queuedExplicitHydrationTargets.shift();
  4144. }
  4145. }
  4146. }
  4147. }
  4148. var DiscreteEvent = 0;
  4149. var UserBlockingEvent = 1;
  4150. var ContinuousEvent = 2;
  4151. /**
  4152. * Generate a mapping of standard vendor prefixes using the defined style property and event name.
  4153. *
  4154. * @param {string} styleProp
  4155. * @param {string} eventName
  4156. * @returns {object}
  4157. */
  4158. function makePrefixMap(styleProp, eventName) {
  4159. var prefixes = {};
  4160. prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
  4161. prefixes['Webkit' + styleProp] = 'webkit' + eventName;
  4162. prefixes['Moz' + styleProp] = 'moz' + eventName;
  4163. return prefixes;
  4164. }
  4165. /**
  4166. * A list of event names to a configurable list of vendor prefixes.
  4167. */
  4168. var vendorPrefixes = {
  4169. animationend: makePrefixMap('Animation', 'AnimationEnd'),
  4170. animationiteration: makePrefixMap('Animation', 'AnimationIteration'),
  4171. animationstart: makePrefixMap('Animation', 'AnimationStart'),
  4172. transitionend: makePrefixMap('Transition', 'TransitionEnd')
  4173. };
  4174. /**
  4175. * Event names that have already been detected and prefixed (if applicable).
  4176. */
  4177. var prefixedEventNames = {};
  4178. /**
  4179. * Element to check for prefixes on.
  4180. */
  4181. var style = {};
  4182. /**
  4183. * Bootstrap if a DOM exists.
  4184. */
  4185. if (canUseDOM) {
  4186. style = document.createElement('div').style; // On some platforms, in particular some releases of Android 4.x,
  4187. // the un-prefixed "animation" and "transition" properties are defined on the
  4188. // style object but the events that fire will still be prefixed, so we need
  4189. // to check if the un-prefixed events are usable, and if not remove them from the map.
  4190. if (!('AnimationEvent' in window)) {
  4191. delete vendorPrefixes.animationend.animation;
  4192. delete vendorPrefixes.animationiteration.animation;
  4193. delete vendorPrefixes.animationstart.animation;
  4194. } // Same as above
  4195. if (!('TransitionEvent' in window)) {
  4196. delete vendorPrefixes.transitionend.transition;
  4197. }
  4198. }
  4199. /**
  4200. * Attempts to determine the correct vendor prefixed event name.
  4201. *
  4202. * @param {string} eventName
  4203. * @returns {string}
  4204. */
  4205. function getVendorPrefixedEventName(eventName) {
  4206. if (prefixedEventNames[eventName]) {
  4207. return prefixedEventNames[eventName];
  4208. } else if (!vendorPrefixes[eventName]) {
  4209. return eventName;
  4210. }
  4211. var prefixMap = vendorPrefixes[eventName];
  4212. for (var styleProp in prefixMap) {
  4213. if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) {
  4214. return prefixedEventNames[eventName] = prefixMap[styleProp];
  4215. }
  4216. }
  4217. return eventName;
  4218. }
  4219. var ANIMATION_END = getVendorPrefixedEventName('animationend');
  4220. var ANIMATION_ITERATION = getVendorPrefixedEventName('animationiteration');
  4221. var ANIMATION_START = getVendorPrefixedEventName('animationstart');
  4222. var TRANSITION_END = getVendorPrefixedEventName('transitionend');
  4223. var topLevelEventsToReactNames = new Map();
  4224. var eventPriorities = new Map(); // We store most of the events in this module in pairs of two strings so we can re-use
  4225. // the code required to apply the same logic for event prioritization and that of the
  4226. // SimpleEventPlugin. This complicates things slightly, but the aim is to reduce code
  4227. // duplication (for which there would be quite a bit). For the events that are not needed
  4228. // for the SimpleEventPlugin (otherDiscreteEvents) we process them separately as an
  4229. // array of top level events.
  4230. // Lastly, we ignore prettier so we can keep the formatting sane.
  4231. // prettier-ignore
  4232. var discreteEventPairsForSimpleEventPlugin = ['cancel', 'cancel', 'click', 'click', 'close', 'close', 'contextmenu', 'contextMenu', 'copy', 'copy', 'cut', 'cut', 'auxclick', 'auxClick', 'dblclick', 'doubleClick', // Careful!
  4233. 'dragend', 'dragEnd', 'dragstart', 'dragStart', 'drop', 'drop', 'focusin', 'focus', // Careful!
  4234. 'focusout', 'blur', // Careful!
  4235. 'input', 'input', 'invalid', 'invalid', 'keydown', 'keyDown', 'keypress', 'keyPress', 'keyup', 'keyUp', 'mousedown', 'mouseDown', 'mouseup', 'mouseUp', 'paste', 'paste', 'pause', 'pause', 'play', 'play', 'pointercancel', 'pointerCancel', 'pointerdown', 'pointerDown', 'pointerup', 'pointerUp', 'ratechange', 'rateChange', 'reset', 'reset', 'seeked', 'seeked', 'submit', 'submit', 'touchcancel', 'touchCancel', 'touchend', 'touchEnd', 'touchstart', 'touchStart', 'volumechange', 'volumeChange'];
  4236. var otherDiscreteEvents = ['change', 'selectionchange', 'textInput', 'compositionstart', 'compositionend', 'compositionupdate'];
  4237. var userBlockingPairsForSimpleEventPlugin = ['drag', 'drag', 'dragenter', 'dragEnter', 'dragexit', 'dragExit', 'dragleave', 'dragLeave', 'dragover', 'dragOver', 'mousemove', 'mouseMove', 'mouseout', 'mouseOut', 'mouseover', 'mouseOver', 'pointermove', 'pointerMove', 'pointerout', 'pointerOut', 'pointerover', 'pointerOver', 'scroll', 'scroll', 'toggle', 'toggle', 'touchmove', 'touchMove', 'wheel', 'wheel']; // prettier-ignore
  4238. var continuousPairsForSimpleEventPlugin = ['abort', 'abort', ANIMATION_END, 'animationEnd', ANIMATION_ITERATION, 'animationIteration', ANIMATION_START, 'animationStart', 'canplay', 'canPlay', 'canplaythrough', 'canPlayThrough', 'durationchange', 'durationChange', 'emptied', 'emptied', 'encrypted', 'encrypted', 'ended', 'ended', 'error', 'error', 'gotpointercapture', 'gotPointerCapture', 'load', 'load', 'loadeddata', 'loadedData', 'loadedmetadata', 'loadedMetadata', 'loadstart', 'loadStart', 'lostpointercapture', 'lostPointerCapture', 'playing', 'playing', 'progress', 'progress', 'seeking', 'seeking', 'stalled', 'stalled', 'suspend', 'suspend', 'timeupdate', 'timeUpdate', TRANSITION_END, 'transitionEnd', 'waiting', 'waiting'];
  4239. /**
  4240. * Turns
  4241. * ['abort', ...]
  4242. *
  4243. * into
  4244. *
  4245. * topLevelEventsToReactNames = new Map([
  4246. * ['abort', 'onAbort'],
  4247. * ]);
  4248. *
  4249. * and registers them.
  4250. */
  4251. function registerSimplePluginEventsAndSetTheirPriorities(eventTypes, priority) {
  4252. // As the event types are in pairs of two, we need to iterate
  4253. // through in twos. The events are in pairs of two to save code
  4254. // and improve init perf of processing this array, as it will
  4255. // result in far fewer object allocations and property accesses
  4256. // if we only use three arrays to process all the categories of
  4257. // instead of tuples.
  4258. for (var i = 0; i < eventTypes.length; i += 2) {
  4259. var topEvent = eventTypes[i];
  4260. var event = eventTypes[i + 1];
  4261. var capitalizedEvent = event[0].toUpperCase() + event.slice(1);
  4262. var reactName = 'on' + capitalizedEvent;
  4263. eventPriorities.set(topEvent, priority);
  4264. topLevelEventsToReactNames.set(topEvent, reactName);
  4265. registerTwoPhaseEvent(reactName, [topEvent]);
  4266. }
  4267. }
  4268. function setEventPriorities(eventTypes, priority) {
  4269. for (var i = 0; i < eventTypes.length; i++) {
  4270. eventPriorities.set(eventTypes[i], priority);
  4271. }
  4272. }
  4273. function getEventPriorityForPluginSystem(domEventName) {
  4274. var priority = eventPriorities.get(domEventName); // Default to a ContinuousEvent. Note: we might
  4275. // want to warn if we can't detect the priority
  4276. // for the event.
  4277. return priority === undefined ? ContinuousEvent : priority;
  4278. }
  4279. function registerSimpleEvents() {
  4280. registerSimplePluginEventsAndSetTheirPriorities(discreteEventPairsForSimpleEventPlugin, DiscreteEvent);
  4281. registerSimplePluginEventsAndSetTheirPriorities(userBlockingPairsForSimpleEventPlugin, UserBlockingEvent);
  4282. registerSimplePluginEventsAndSetTheirPriorities(continuousPairsForSimpleEventPlugin, ContinuousEvent);
  4283. setEventPriorities(otherDiscreteEvents, DiscreteEvent);
  4284. }
  4285. var Scheduler_now = Scheduler.unstable_now;
  4286. {
  4287. // Provide explicit error message when production+profiling bundle of e.g.
  4288. // react-dom is used with production (non-profiling) bundle of
  4289. // scheduler/tracing
  4290. if (!(tracing.__interactionsRef != null && tracing.__interactionsRef.current != null)) {
  4291. {
  4292. throw Error( "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at https://reactjs.org/link/profiling" );
  4293. }
  4294. }
  4295. }
  4296. // ascending numbers so we can compare them like numbers. They start at 90 to
  4297. // avoid clashing with Scheduler's priorities.
  4298. var ImmediatePriority = 99;
  4299. var UserBlockingPriority = 98;
  4300. var NormalPriority = 97;
  4301. var LowPriority = 96;
  4302. var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only.
  4303. var NoPriority = 90;
  4304. var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly.
  4305. var SyncLanePriority = 15;
  4306. var SyncBatchedLanePriority = 14;
  4307. var InputDiscreteHydrationLanePriority = 13;
  4308. var InputDiscreteLanePriority = 12;
  4309. var InputContinuousHydrationLanePriority = 11;
  4310. var InputContinuousLanePriority = 10;
  4311. var DefaultHydrationLanePriority = 9;
  4312. var DefaultLanePriority = 8;
  4313. var TransitionHydrationPriority = 7;
  4314. var TransitionPriority = 6;
  4315. var RetryLanePriority = 5;
  4316. var SelectiveHydrationLanePriority = 4;
  4317. var IdleHydrationLanePriority = 3;
  4318. var IdleLanePriority = 2;
  4319. var OffscreenLanePriority = 1;
  4320. var NoLanePriority = 0;
  4321. var TotalLanes = 31;
  4322. var NoLanes =
  4323. /* */
  4324. 0;
  4325. var NoLane =
  4326. /* */
  4327. 0;
  4328. var SyncLane =
  4329. /* */
  4330. 1;
  4331. var SyncBatchedLane =
  4332. /* */
  4333. 2;
  4334. var InputDiscreteHydrationLane =
  4335. /* */
  4336. 4;
  4337. var InputDiscreteLanes =
  4338. /* */
  4339. 24;
  4340. var InputContinuousHydrationLane =
  4341. /* */
  4342. 32;
  4343. var InputContinuousLanes =
  4344. /* */
  4345. 192;
  4346. var DefaultHydrationLane =
  4347. /* */
  4348. 256;
  4349. var DefaultLanes =
  4350. /* */
  4351. 3584;
  4352. var TransitionHydrationLane =
  4353. /* */
  4354. 4096;
  4355. var TransitionLanes =
  4356. /* */
  4357. 4186112;
  4358. var RetryLanes =
  4359. /* */
  4360. 62914560;
  4361. var SomeRetryLane =
  4362. /* */
  4363. 33554432;
  4364. var SelectiveHydrationLane =
  4365. /* */
  4366. 67108864;
  4367. var NonIdleLanes =
  4368. /* */
  4369. 134217727;
  4370. var IdleHydrationLane =
  4371. /* */
  4372. 134217728;
  4373. var IdleLanes =
  4374. /* */
  4375. 805306368;
  4376. var OffscreenLane =
  4377. /* */
  4378. 1073741824;
  4379. var NoTimestamp = -1;
  4380. function setCurrentUpdateLanePriority(newLanePriority) {
  4381. } // "Registers" used to "return" multiple values
  4382. // Used by getHighestPriorityLanes and getNextLanes:
  4383. var return_highestLanePriority = DefaultLanePriority;
  4384. function getHighestPriorityLanes(lanes) {
  4385. if ((SyncLane & lanes) !== NoLanes) {
  4386. return_highestLanePriority = SyncLanePriority;
  4387. return SyncLane;
  4388. }
  4389. if ((SyncBatchedLane & lanes) !== NoLanes) {
  4390. return_highestLanePriority = SyncBatchedLanePriority;
  4391. return SyncBatchedLane;
  4392. }
  4393. if ((InputDiscreteHydrationLane & lanes) !== NoLanes) {
  4394. return_highestLanePriority = InputDiscreteHydrationLanePriority;
  4395. return InputDiscreteHydrationLane;
  4396. }
  4397. var inputDiscreteLanes = InputDiscreteLanes & lanes;
  4398. if (inputDiscreteLanes !== NoLanes) {
  4399. return_highestLanePriority = InputDiscreteLanePriority;
  4400. return inputDiscreteLanes;
  4401. }
  4402. if ((lanes & InputContinuousHydrationLane) !== NoLanes) {
  4403. return_highestLanePriority = InputContinuousHydrationLanePriority;
  4404. return InputContinuousHydrationLane;
  4405. }
  4406. var inputContinuousLanes = InputContinuousLanes & lanes;
  4407. if (inputContinuousLanes !== NoLanes) {
  4408. return_highestLanePriority = InputContinuousLanePriority;
  4409. return inputContinuousLanes;
  4410. }
  4411. if ((lanes & DefaultHydrationLane) !== NoLanes) {
  4412. return_highestLanePriority = DefaultHydrationLanePriority;
  4413. return DefaultHydrationLane;
  4414. }
  4415. var defaultLanes = DefaultLanes & lanes;
  4416. if (defaultLanes !== NoLanes) {
  4417. return_highestLanePriority = DefaultLanePriority;
  4418. return defaultLanes;
  4419. }
  4420. if ((lanes & TransitionHydrationLane) !== NoLanes) {
  4421. return_highestLanePriority = TransitionHydrationPriority;
  4422. return TransitionHydrationLane;
  4423. }
  4424. var transitionLanes = TransitionLanes & lanes;
  4425. if (transitionLanes !== NoLanes) {
  4426. return_highestLanePriority = TransitionPriority;
  4427. return transitionLanes;
  4428. }
  4429. var retryLanes = RetryLanes & lanes;
  4430. if (retryLanes !== NoLanes) {
  4431. return_highestLanePriority = RetryLanePriority;
  4432. return retryLanes;
  4433. }
  4434. if (lanes & SelectiveHydrationLane) {
  4435. return_highestLanePriority = SelectiveHydrationLanePriority;
  4436. return SelectiveHydrationLane;
  4437. }
  4438. if ((lanes & IdleHydrationLane) !== NoLanes) {
  4439. return_highestLanePriority = IdleHydrationLanePriority;
  4440. return IdleHydrationLane;
  4441. }
  4442. var idleLanes = IdleLanes & lanes;
  4443. if (idleLanes !== NoLanes) {
  4444. return_highestLanePriority = IdleLanePriority;
  4445. return idleLanes;
  4446. }
  4447. if ((OffscreenLane & lanes) !== NoLanes) {
  4448. return_highestLanePriority = OffscreenLanePriority;
  4449. return OffscreenLane;
  4450. }
  4451. {
  4452. error('Should have found matching lanes. This is a bug in React.');
  4453. } // This shouldn't be reachable, but as a fallback, return the entire bitmask.
  4454. return_highestLanePriority = DefaultLanePriority;
  4455. return lanes;
  4456. }
  4457. function schedulerPriorityToLanePriority(schedulerPriorityLevel) {
  4458. switch (schedulerPriorityLevel) {
  4459. case ImmediatePriority:
  4460. return SyncLanePriority;
  4461. case UserBlockingPriority:
  4462. return InputContinuousLanePriority;
  4463. case NormalPriority:
  4464. case LowPriority:
  4465. // TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration.
  4466. return DefaultLanePriority;
  4467. case IdlePriority:
  4468. return IdleLanePriority;
  4469. default:
  4470. return NoLanePriority;
  4471. }
  4472. }
  4473. function lanePriorityToSchedulerPriority(lanePriority) {
  4474. switch (lanePriority) {
  4475. case SyncLanePriority:
  4476. case SyncBatchedLanePriority:
  4477. return ImmediatePriority;
  4478. case InputDiscreteHydrationLanePriority:
  4479. case InputDiscreteLanePriority:
  4480. case InputContinuousHydrationLanePriority:
  4481. case InputContinuousLanePriority:
  4482. return UserBlockingPriority;
  4483. case DefaultHydrationLanePriority:
  4484. case DefaultLanePriority:
  4485. case TransitionHydrationPriority:
  4486. case TransitionPriority:
  4487. case SelectiveHydrationLanePriority:
  4488. case RetryLanePriority:
  4489. return NormalPriority;
  4490. case IdleHydrationLanePriority:
  4491. case IdleLanePriority:
  4492. case OffscreenLanePriority:
  4493. return IdlePriority;
  4494. case NoLanePriority:
  4495. return NoPriority;
  4496. default:
  4497. {
  4498. {
  4499. throw Error( "Invalid update priority: " + lanePriority + ". This is a bug in React." );
  4500. }
  4501. }
  4502. }
  4503. }
  4504. function getNextLanes(root, wipLanes) {
  4505. // Early bailout if there's no pending work left.
  4506. var pendingLanes = root.pendingLanes;
  4507. if (pendingLanes === NoLanes) {
  4508. return_highestLanePriority = NoLanePriority;
  4509. return NoLanes;
  4510. }
  4511. var nextLanes = NoLanes;
  4512. var nextLanePriority = NoLanePriority;
  4513. var expiredLanes = root.expiredLanes;
  4514. var suspendedLanes = root.suspendedLanes;
  4515. var pingedLanes = root.pingedLanes; // Check if any work has expired.
  4516. if (expiredLanes !== NoLanes) {
  4517. nextLanes = expiredLanes;
  4518. nextLanePriority = return_highestLanePriority = SyncLanePriority;
  4519. } else {
  4520. // Do not work on any idle work until all the non-idle work has finished,
  4521. // even if the work is suspended.
  4522. var nonIdlePendingLanes = pendingLanes & NonIdleLanes;
  4523. if (nonIdlePendingLanes !== NoLanes) {
  4524. var nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes;
  4525. if (nonIdleUnblockedLanes !== NoLanes) {
  4526. nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes);
  4527. nextLanePriority = return_highestLanePriority;
  4528. } else {
  4529. var nonIdlePingedLanes = nonIdlePendingLanes & pingedLanes;
  4530. if (nonIdlePingedLanes !== NoLanes) {
  4531. nextLanes = getHighestPriorityLanes(nonIdlePingedLanes);
  4532. nextLanePriority = return_highestLanePriority;
  4533. }
  4534. }
  4535. } else {
  4536. // The only remaining work is Idle.
  4537. var unblockedLanes = pendingLanes & ~suspendedLanes;
  4538. if (unblockedLanes !== NoLanes) {
  4539. nextLanes = getHighestPriorityLanes(unblockedLanes);
  4540. nextLanePriority = return_highestLanePriority;
  4541. } else {
  4542. if (pingedLanes !== NoLanes) {
  4543. nextLanes = getHighestPriorityLanes(pingedLanes);
  4544. nextLanePriority = return_highestLanePriority;
  4545. }
  4546. }
  4547. }
  4548. }
  4549. if (nextLanes === NoLanes) {
  4550. // This should only be reachable if we're suspended
  4551. // TODO: Consider warning in this path if a fallback timer is not scheduled.
  4552. return NoLanes;
  4553. } // If there are higher priority lanes, we'll include them even if they
  4554. // are suspended.
  4555. nextLanes = pendingLanes & getEqualOrHigherPriorityLanes(nextLanes); // If we're already in the middle of a render, switching lanes will interrupt
  4556. // it and we'll lose our progress. We should only do this if the new lanes are
  4557. // higher priority.
  4558. if (wipLanes !== NoLanes && wipLanes !== nextLanes && // If we already suspended with a delay, then interrupting is fine. Don't
  4559. // bother waiting until the root is complete.
  4560. (wipLanes & suspendedLanes) === NoLanes) {
  4561. getHighestPriorityLanes(wipLanes);
  4562. var wipLanePriority = return_highestLanePriority;
  4563. if (nextLanePriority <= wipLanePriority) {
  4564. return wipLanes;
  4565. } else {
  4566. return_highestLanePriority = nextLanePriority;
  4567. }
  4568. } // Check for entangled lanes and add them to the batch.
  4569. //
  4570. // A lane is said to be entangled with another when it's not allowed to render
  4571. // in a batch that does not also include the other lane. Typically we do this
  4572. // when multiple updates have the same source, and we only want to respond to
  4573. // the most recent event from that source.
  4574. //
  4575. // Note that we apply entanglements *after* checking for partial work above.
  4576. // This means that if a lane is entangled during an interleaved event while
  4577. // it's already rendering, we won't interrupt it. This is intentional, since
  4578. // entanglement is usually "best effort": we'll try our best to render the
  4579. // lanes in the same batch, but it's not worth throwing out partially
  4580. // completed work in order to do it.
  4581. //
  4582. // For those exceptions where entanglement is semantically important, like
  4583. // useMutableSource, we should ensure that there is no partial work at the
  4584. // time we apply the entanglement.
  4585. var entangledLanes = root.entangledLanes;
  4586. if (entangledLanes !== NoLanes) {
  4587. var entanglements = root.entanglements;
  4588. var lanes = nextLanes & entangledLanes;
  4589. while (lanes > 0) {
  4590. var index = pickArbitraryLaneIndex(lanes);
  4591. var lane = 1 << index;
  4592. nextLanes |= entanglements[index];
  4593. lanes &= ~lane;
  4594. }
  4595. }
  4596. return nextLanes;
  4597. }
  4598. function getMostRecentEventTime(root, lanes) {
  4599. var eventTimes = root.eventTimes;
  4600. var mostRecentEventTime = NoTimestamp;
  4601. while (lanes > 0) {
  4602. var index = pickArbitraryLaneIndex(lanes);
  4603. var lane = 1 << index;
  4604. var eventTime = eventTimes[index];
  4605. if (eventTime > mostRecentEventTime) {
  4606. mostRecentEventTime = eventTime;
  4607. }
  4608. lanes &= ~lane;
  4609. }
  4610. return mostRecentEventTime;
  4611. }
  4612. function computeExpirationTime(lane, currentTime) {
  4613. // TODO: Expiration heuristic is constant per lane, so could use a map.
  4614. getHighestPriorityLanes(lane);
  4615. var priority = return_highestLanePriority;
  4616. if (priority >= InputContinuousLanePriority) {
  4617. // User interactions should expire slightly more quickly.
  4618. //
  4619. // NOTE: This is set to the corresponding constant as in Scheduler.js. When
  4620. // we made it larger, a product metric in www regressed, suggesting there's
  4621. // a user interaction that's being starved by a series of synchronous
  4622. // updates. If that theory is correct, the proper solution is to fix the
  4623. // starvation. However, this scenario supports the idea that expiration
  4624. // times are an important safeguard when starvation does happen.
  4625. //
  4626. // Also note that, in the case of user input specifically, this will soon no
  4627. // longer be an issue because we plan to make user input synchronous by
  4628. // default (until you enter `startTransition`, of course.)
  4629. //
  4630. // If weren't planning to make these updates synchronous soon anyway, I
  4631. // would probably make this number a configurable parameter.
  4632. return currentTime + 250;
  4633. } else if (priority >= TransitionPriority) {
  4634. return currentTime + 5000;
  4635. } else {
  4636. // Anything idle priority or lower should never expire.
  4637. return NoTimestamp;
  4638. }
  4639. }
  4640. function markStarvedLanesAsExpired(root, currentTime) {
  4641. // TODO: This gets called every time we yield. We can optimize by storing
  4642. // the earliest expiration time on the root. Then use that to quickly bail out
  4643. // of this function.
  4644. var pendingLanes = root.pendingLanes;
  4645. var suspendedLanes = root.suspendedLanes;
  4646. var pingedLanes = root.pingedLanes;
  4647. var expirationTimes = root.expirationTimes; // Iterate through the pending lanes and check if we've reached their
  4648. // expiration time. If so, we'll assume the update is being starved and mark
  4649. // it as expired to force it to finish.
  4650. var lanes = pendingLanes;
  4651. while (lanes > 0) {
  4652. var index = pickArbitraryLaneIndex(lanes);
  4653. var lane = 1 << index;
  4654. var expirationTime = expirationTimes[index];
  4655. if (expirationTime === NoTimestamp) {
  4656. // Found a pending lane with no expiration time. If it's not suspended, or
  4657. // if it's pinged, assume it's CPU-bound. Compute a new expiration time
  4658. // using the current time.
  4659. if ((lane & suspendedLanes) === NoLanes || (lane & pingedLanes) !== NoLanes) {
  4660. // Assumes timestamps are monotonically increasing.
  4661. expirationTimes[index] = computeExpirationTime(lane, currentTime);
  4662. }
  4663. } else if (expirationTime <= currentTime) {
  4664. // This lane expired
  4665. root.expiredLanes |= lane;
  4666. }
  4667. lanes &= ~lane;
  4668. }
  4669. } // This returns the highest priority pending lanes regardless of whether they
  4670. function getLanesToRetrySynchronouslyOnError(root) {
  4671. var everythingButOffscreen = root.pendingLanes & ~OffscreenLane;
  4672. if (everythingButOffscreen !== NoLanes) {
  4673. return everythingButOffscreen;
  4674. }
  4675. if (everythingButOffscreen & OffscreenLane) {
  4676. return OffscreenLane;
  4677. }
  4678. return NoLanes;
  4679. }
  4680. function returnNextLanesPriority() {
  4681. return return_highestLanePriority;
  4682. }
  4683. function includesNonIdleWork(lanes) {
  4684. return (lanes & NonIdleLanes) !== NoLanes;
  4685. }
  4686. function includesOnlyRetries(lanes) {
  4687. return (lanes & RetryLanes) === lanes;
  4688. }
  4689. function includesOnlyTransitions(lanes) {
  4690. return (lanes & TransitionLanes) === lanes;
  4691. } // To ensure consistency across multiple updates in the same event, this should
  4692. // be a pure function, so that it always returns the same lane for given inputs.
  4693. function findUpdateLane(lanePriority, wipLanes) {
  4694. switch (lanePriority) {
  4695. case NoLanePriority:
  4696. break;
  4697. case SyncLanePriority:
  4698. return SyncLane;
  4699. case SyncBatchedLanePriority:
  4700. return SyncBatchedLane;
  4701. case InputDiscreteLanePriority:
  4702. {
  4703. var _lane = pickArbitraryLane(InputDiscreteLanes & ~wipLanes);
  4704. if (_lane === NoLane) {
  4705. // Shift to the next priority level
  4706. return findUpdateLane(InputContinuousLanePriority, wipLanes);
  4707. }
  4708. return _lane;
  4709. }
  4710. case InputContinuousLanePriority:
  4711. {
  4712. var _lane2 = pickArbitraryLane(InputContinuousLanes & ~wipLanes);
  4713. if (_lane2 === NoLane) {
  4714. // Shift to the next priority level
  4715. return findUpdateLane(DefaultLanePriority, wipLanes);
  4716. }
  4717. return _lane2;
  4718. }
  4719. case DefaultLanePriority:
  4720. {
  4721. var _lane3 = pickArbitraryLane(DefaultLanes & ~wipLanes);
  4722. if (_lane3 === NoLane) {
  4723. // If all the default lanes are already being worked on, look for a
  4724. // lane in the transition range.
  4725. _lane3 = pickArbitraryLane(TransitionLanes & ~wipLanes);
  4726. if (_lane3 === NoLane) {
  4727. // All the transition lanes are taken, too. This should be very
  4728. // rare, but as a last resort, pick a default lane. This will have
  4729. // the effect of interrupting the current work-in-progress render.
  4730. _lane3 = pickArbitraryLane(DefaultLanes);
  4731. }
  4732. }
  4733. return _lane3;
  4734. }
  4735. case TransitionPriority: // Should be handled by findTransitionLane instead
  4736. case RetryLanePriority:
  4737. // Should be handled by findRetryLane instead
  4738. break;
  4739. case IdleLanePriority:
  4740. var lane = pickArbitraryLane(IdleLanes & ~wipLanes);
  4741. if (lane === NoLane) {
  4742. lane = pickArbitraryLane(IdleLanes);
  4743. }
  4744. return lane;
  4745. }
  4746. {
  4747. {
  4748. throw Error( "Invalid update priority: " + lanePriority + ". This is a bug in React." );
  4749. }
  4750. }
  4751. } // To ensure consistency across multiple updates in the same event, this should
  4752. // be pure function, so that it always returns the same lane for given inputs.
  4753. function findTransitionLane(wipLanes, pendingLanes) {
  4754. // First look for lanes that are completely unclaimed, i.e. have no
  4755. // pending work.
  4756. var lane = pickArbitraryLane(TransitionLanes & ~pendingLanes);
  4757. if (lane === NoLane) {
  4758. // If all lanes have pending work, look for a lane that isn't currently
  4759. // being worked on.
  4760. lane = pickArbitraryLane(TransitionLanes & ~wipLanes);
  4761. if (lane === NoLane) {
  4762. // If everything is being worked on, pick any lane. This has the
  4763. // effect of interrupting the current work-in-progress.
  4764. lane = pickArbitraryLane(TransitionLanes);
  4765. }
  4766. }
  4767. return lane;
  4768. } // To ensure consistency across multiple updates in the same event, this should
  4769. // be pure function, so that it always returns the same lane for given inputs.
  4770. function findRetryLane(wipLanes) {
  4771. // This is a fork of `findUpdateLane` designed specifically for Suspense
  4772. // "retries" — a special update that attempts to flip a Suspense boundary
  4773. // from its placeholder state to its primary/resolved state.
  4774. var lane = pickArbitraryLane(RetryLanes & ~wipLanes);
  4775. if (lane === NoLane) {
  4776. lane = pickArbitraryLane(RetryLanes);
  4777. }
  4778. return lane;
  4779. }
  4780. function getHighestPriorityLane(lanes) {
  4781. return lanes & -lanes;
  4782. }
  4783. function getLowestPriorityLane(lanes) {
  4784. // This finds the most significant non-zero bit.
  4785. var index = 31 - clz32(lanes);
  4786. return index < 0 ? NoLanes : 1 << index;
  4787. }
  4788. function getEqualOrHigherPriorityLanes(lanes) {
  4789. return (getLowestPriorityLane(lanes) << 1) - 1;
  4790. }
  4791. function pickArbitraryLane(lanes) {
  4792. // This wrapper function gets inlined. Only exists so to communicate that it
  4793. // doesn't matter which bit is selected; you can pick any bit without
  4794. // affecting the algorithms where its used. Here I'm using
  4795. // getHighestPriorityLane because it requires the fewest operations.
  4796. return getHighestPriorityLane(lanes);
  4797. }
  4798. function pickArbitraryLaneIndex(lanes) {
  4799. return 31 - clz32(lanes);
  4800. }
  4801. function laneToIndex(lane) {
  4802. return pickArbitraryLaneIndex(lane);
  4803. }
  4804. function includesSomeLane(a, b) {
  4805. return (a & b) !== NoLanes;
  4806. }
  4807. function isSubsetOfLanes(set, subset) {
  4808. return (set & subset) === subset;
  4809. }
  4810. function mergeLanes(a, b) {
  4811. return a | b;
  4812. }
  4813. function removeLanes(set, subset) {
  4814. return set & ~subset;
  4815. } // Seems redundant, but it changes the type from a single lane (used for
  4816. // updates) to a group of lanes (used for flushing work).
  4817. function laneToLanes(lane) {
  4818. return lane;
  4819. }
  4820. function higherPriorityLane(a, b) {
  4821. // This works because the bit ranges decrease in priority as you go left.
  4822. return a !== NoLane && a < b ? a : b;
  4823. }
  4824. function createLaneMap(initial) {
  4825. // Intentionally pushing one by one.
  4826. // https://v8.dev/blog/elements-kinds#avoid-creating-holes
  4827. var laneMap = [];
  4828. for (var i = 0; i < TotalLanes; i++) {
  4829. laneMap.push(initial);
  4830. }
  4831. return laneMap;
  4832. }
  4833. function markRootUpdated(root, updateLane, eventTime) {
  4834. root.pendingLanes |= updateLane; // TODO: Theoretically, any update to any lane can unblock any other lane. But
  4835. // it's not practical to try every single possible combination. We need a
  4836. // heuristic to decide which lanes to attempt to render, and in which batches.
  4837. // For now, we use the same heuristic as in the old ExpirationTimes model:
  4838. // retry any lane at equal or lower priority, but don't try updates at higher
  4839. // priority without also including the lower priority updates. This works well
  4840. // when considering updates across different priority levels, but isn't
  4841. // sufficient for updates within the same priority, since we want to treat
  4842. // those updates as parallel.
  4843. // Unsuspend any update at equal or lower priority.
  4844. var higherPriorityLanes = updateLane - 1; // Turns 0b1000 into 0b0111
  4845. root.suspendedLanes &= higherPriorityLanes;
  4846. root.pingedLanes &= higherPriorityLanes;
  4847. var eventTimes = root.eventTimes;
  4848. var index = laneToIndex(updateLane); // We can always overwrite an existing timestamp because we prefer the most
  4849. // recent event, and we assume time is monotonically increasing.
  4850. eventTimes[index] = eventTime;
  4851. }
  4852. function markRootSuspended(root, suspendedLanes) {
  4853. root.suspendedLanes |= suspendedLanes;
  4854. root.pingedLanes &= ~suspendedLanes; // The suspended lanes are no longer CPU-bound. Clear their expiration times.
  4855. var expirationTimes = root.expirationTimes;
  4856. var lanes = suspendedLanes;
  4857. while (lanes > 0) {
  4858. var index = pickArbitraryLaneIndex(lanes);
  4859. var lane = 1 << index;
  4860. expirationTimes[index] = NoTimestamp;
  4861. lanes &= ~lane;
  4862. }
  4863. }
  4864. function markRootPinged(root, pingedLanes, eventTime) {
  4865. root.pingedLanes |= root.suspendedLanes & pingedLanes;
  4866. }
  4867. function markDiscreteUpdatesExpired(root) {
  4868. root.expiredLanes |= InputDiscreteLanes & root.pendingLanes;
  4869. }
  4870. function hasDiscreteLanes(lanes) {
  4871. return (lanes & InputDiscreteLanes) !== NoLanes;
  4872. }
  4873. function markRootMutableRead(root, updateLane) {
  4874. root.mutableReadLanes |= updateLane & root.pendingLanes;
  4875. }
  4876. function markRootFinished(root, remainingLanes) {
  4877. var noLongerPendingLanes = root.pendingLanes & ~remainingLanes;
  4878. root.pendingLanes = remainingLanes; // Let's try everything again
  4879. root.suspendedLanes = 0;
  4880. root.pingedLanes = 0;
  4881. root.expiredLanes &= remainingLanes;
  4882. root.mutableReadLanes &= remainingLanes;
  4883. root.entangledLanes &= remainingLanes;
  4884. var entanglements = root.entanglements;
  4885. var eventTimes = root.eventTimes;
  4886. var expirationTimes = root.expirationTimes; // Clear the lanes that no longer have pending work
  4887. var lanes = noLongerPendingLanes;
  4888. while (lanes > 0) {
  4889. var index = pickArbitraryLaneIndex(lanes);
  4890. var lane = 1 << index;
  4891. entanglements[index] = NoLanes;
  4892. eventTimes[index] = NoTimestamp;
  4893. expirationTimes[index] = NoTimestamp;
  4894. lanes &= ~lane;
  4895. }
  4896. }
  4897. function markRootEntangled(root, entangledLanes) {
  4898. root.entangledLanes |= entangledLanes;
  4899. var entanglements = root.entanglements;
  4900. var lanes = entangledLanes;
  4901. while (lanes > 0) {
  4902. var index = pickArbitraryLaneIndex(lanes);
  4903. var lane = 1 << index;
  4904. entanglements[index] |= entangledLanes;
  4905. lanes &= ~lane;
  4906. }
  4907. }
  4908. var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback; // Count leading zeros. Only used on lanes, so assume input is an integer.
  4909. // Based on:
  4910. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
  4911. var log = Math.log;
  4912. var LN2 = Math.LN2;
  4913. function clz32Fallback(lanes) {
  4914. if (lanes === 0) {
  4915. return 32;
  4916. }
  4917. return 31 - (log(lanes) / LN2 | 0) | 0;
  4918. }
  4919. // Intentionally not named imports because Rollup would use dynamic dispatch for
  4920. var UserBlockingPriority$1 = Scheduler.unstable_UserBlockingPriority,
  4921. runWithPriority = Scheduler.unstable_runWithPriority; // TODO: can we stop exporting these?
  4922. var _enabled = true; // This is exported in FB builds for use by legacy FB layer infra.
  4923. // We'd like to remove this but it's not clear if this is safe.
  4924. function setEnabled(enabled) {
  4925. _enabled = !!enabled;
  4926. }
  4927. function isEnabled() {
  4928. return _enabled;
  4929. }
  4930. function createEventListenerWrapperWithPriority(targetContainer, domEventName, eventSystemFlags) {
  4931. var eventPriority = getEventPriorityForPluginSystem(domEventName);
  4932. var listenerWrapper;
  4933. switch (eventPriority) {
  4934. case DiscreteEvent:
  4935. listenerWrapper = dispatchDiscreteEvent;
  4936. break;
  4937. case UserBlockingEvent:
  4938. listenerWrapper = dispatchUserBlockingUpdate;
  4939. break;
  4940. case ContinuousEvent:
  4941. default:
  4942. listenerWrapper = dispatchEvent;
  4943. break;
  4944. }
  4945. return listenerWrapper.bind(null, domEventName, eventSystemFlags, targetContainer);
  4946. }
  4947. function dispatchDiscreteEvent(domEventName, eventSystemFlags, container, nativeEvent) {
  4948. {
  4949. flushDiscreteUpdatesIfNeeded(nativeEvent.timeStamp);
  4950. }
  4951. discreteUpdates(dispatchEvent, domEventName, eventSystemFlags, container, nativeEvent);
  4952. }
  4953. function dispatchUserBlockingUpdate(domEventName, eventSystemFlags, container, nativeEvent) {
  4954. {
  4955. runWithPriority(UserBlockingPriority$1, dispatchEvent.bind(null, domEventName, eventSystemFlags, container, nativeEvent));
  4956. }
  4957. }
  4958. function dispatchEvent(domEventName, eventSystemFlags, targetContainer, nativeEvent) {
  4959. if (!_enabled) {
  4960. return;
  4961. }
  4962. var allowReplay = true;
  4963. {
  4964. // TODO: replaying capture phase events is currently broken
  4965. // because we used to do it during top-level native bubble handlers
  4966. // but now we use different bubble and capture handlers.
  4967. // In eager mode, we attach capture listeners early, so we need
  4968. // to filter them out until we fix the logic to handle them correctly.
  4969. // This could've been outside the flag but I put it inside to reduce risk.
  4970. allowReplay = (eventSystemFlags & IS_CAPTURE_PHASE) === 0;
  4971. }
  4972. if (allowReplay && hasQueuedDiscreteEvents() && isReplayableDiscreteEvent(domEventName)) {
  4973. // If we already have a queue of discrete events, and this is another discrete
  4974. // event, then we can't dispatch it regardless of its target, since they
  4975. // need to dispatch in order.
  4976. queueDiscreteEvent(null, // Flags that we're not actually blocked on anything as far as we know.
  4977. domEventName, eventSystemFlags, targetContainer, nativeEvent);
  4978. return;
  4979. }
  4980. var blockedOn = attemptToDispatchEvent(domEventName, eventSystemFlags, targetContainer, nativeEvent);
  4981. if (blockedOn === null) {
  4982. // We successfully dispatched this event.
  4983. if (allowReplay) {
  4984. clearIfContinuousEvent(domEventName, nativeEvent);
  4985. }
  4986. return;
  4987. }
  4988. if (allowReplay) {
  4989. if (isReplayableDiscreteEvent(domEventName)) {
  4990. // This this to be replayed later once the target is available.
  4991. queueDiscreteEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent);
  4992. return;
  4993. }
  4994. if (queueIfContinuousEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent)) {
  4995. return;
  4996. } // We need to clear only if we didn't queue because
  4997. // queueing is accummulative.
  4998. clearIfContinuousEvent(domEventName, nativeEvent);
  4999. } // This is not replayable so we'll invoke it but without a target,
  5000. // in case the event system needs to trace it.
  5001. dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativeEvent, null, targetContainer);
  5002. } // Attempt dispatching an event. Returns a SuspenseInstance or Container if it's blocked.
  5003. function attemptToDispatchEvent(domEventName, eventSystemFlags, targetContainer, nativeEvent) {
  5004. // TODO: Warn if _enabled is false.
  5005. var nativeEventTarget = getEventTarget(nativeEvent);
  5006. var targetInst = getClosestInstanceFromNode(nativeEventTarget);
  5007. if (targetInst !== null) {
  5008. var nearestMounted = getNearestMountedFiber(targetInst);
  5009. if (nearestMounted === null) {
  5010. // This tree has been unmounted already. Dispatch without a target.
  5011. targetInst = null;
  5012. } else {
  5013. var tag = nearestMounted.tag;
  5014. if (tag === SuspenseComponent) {
  5015. var instance = getSuspenseInstanceFromFiber(nearestMounted);
  5016. if (instance !== null) {
  5017. // Queue the event to be replayed later. Abort dispatching since we
  5018. // don't want this event dispatched twice through the event system.
  5019. // TODO: If this is the first discrete event in the queue. Schedule an increased
  5020. // priority for this boundary.
  5021. return instance;
  5022. } // This shouldn't happen, something went wrong but to avoid blocking
  5023. // the whole system, dispatch the event without a target.
  5024. // TODO: Warn.
  5025. targetInst = null;
  5026. } else if (tag === HostRoot) {
  5027. var root = nearestMounted.stateNode;
  5028. if (root.hydrate) {
  5029. // If this happens during a replay something went wrong and it might block
  5030. // the whole system.
  5031. return getContainerFromFiber(nearestMounted);
  5032. }
  5033. targetInst = null;
  5034. } else if (nearestMounted !== targetInst) {
  5035. // If we get an event (ex: img onload) before committing that
  5036. // component's mount, ignore it for now (that is, treat it as if it was an
  5037. // event on a non-React tree). We might also consider queueing events and
  5038. // dispatching them after the mount.
  5039. targetInst = null;
  5040. }
  5041. }
  5042. }
  5043. dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativeEvent, targetInst, targetContainer); // We're not blocked on anything.
  5044. return null;
  5045. }
  5046. function addEventBubbleListener(target, eventType, listener) {
  5047. target.addEventListener(eventType, listener, false);
  5048. return listener;
  5049. }
  5050. function addEventCaptureListener(target, eventType, listener) {
  5051. target.addEventListener(eventType, listener, true);
  5052. return listener;
  5053. }
  5054. function addEventCaptureListenerWithPassiveFlag(target, eventType, listener, passive) {
  5055. target.addEventListener(eventType, listener, {
  5056. capture: true,
  5057. passive: passive
  5058. });
  5059. return listener;
  5060. }
  5061. function addEventBubbleListenerWithPassiveFlag(target, eventType, listener, passive) {
  5062. target.addEventListener(eventType, listener, {
  5063. passive: passive
  5064. });
  5065. return listener;
  5066. }
  5067. /**
  5068. * These variables store information about text content of a target node,
  5069. * allowing comparison of content before and after a given event.
  5070. *
  5071. * Identify the node where selection currently begins, then observe
  5072. * both its text content and its current position in the DOM. Since the
  5073. * browser may natively replace the target node during composition, we can
  5074. * use its position to find its replacement.
  5075. *
  5076. *
  5077. */
  5078. var root = null;
  5079. var startText = null;
  5080. var fallbackText = null;
  5081. function initialize(nativeEventTarget) {
  5082. root = nativeEventTarget;
  5083. startText = getText();
  5084. return true;
  5085. }
  5086. function reset() {
  5087. root = null;
  5088. startText = null;
  5089. fallbackText = null;
  5090. }
  5091. function getData() {
  5092. if (fallbackText) {
  5093. return fallbackText;
  5094. }
  5095. var start;
  5096. var startValue = startText;
  5097. var startLength = startValue.length;
  5098. var end;
  5099. var endValue = getText();
  5100. var endLength = endValue.length;
  5101. for (start = 0; start < startLength; start++) {
  5102. if (startValue[start] !== endValue[start]) {
  5103. break;
  5104. }
  5105. }
  5106. var minEnd = startLength - start;
  5107. for (end = 1; end <= minEnd; end++) {
  5108. if (startValue[startLength - end] !== endValue[endLength - end]) {
  5109. break;
  5110. }
  5111. }
  5112. var sliceTail = end > 1 ? 1 - end : undefined;
  5113. fallbackText = endValue.slice(start, sliceTail);
  5114. return fallbackText;
  5115. }
  5116. function getText() {
  5117. if ('value' in root) {
  5118. return root.value;
  5119. }
  5120. return root.textContent;
  5121. }
  5122. /**
  5123. * `charCode` represents the actual "character code" and is safe to use with
  5124. * `String.fromCharCode`. As such, only keys that correspond to printable
  5125. * characters produce a valid `charCode`, the only exception to this is Enter.
  5126. * The Tab-key is considered non-printable and does not have a `charCode`,
  5127. * presumably because it does not produce a tab-character in browsers.
  5128. *
  5129. * @param {object} nativeEvent Native browser event.
  5130. * @return {number} Normalized `charCode` property.
  5131. */
  5132. function getEventCharCode(nativeEvent) {
  5133. var charCode;
  5134. var keyCode = nativeEvent.keyCode;
  5135. if ('charCode' in nativeEvent) {
  5136. charCode = nativeEvent.charCode; // FF does not set `charCode` for the Enter-key, check against `keyCode`.
  5137. if (charCode === 0 && keyCode === 13) {
  5138. charCode = 13;
  5139. }
  5140. } else {
  5141. // IE8 does not implement `charCode`, but `keyCode` has the correct value.
  5142. charCode = keyCode;
  5143. } // IE and Edge (on Windows) and Chrome / Safari (on Windows and Linux)
  5144. // report Enter as charCode 10 when ctrl is pressed.
  5145. if (charCode === 10) {
  5146. charCode = 13;
  5147. } // Some non-printable keys are reported in `charCode`/`keyCode`, discard them.
  5148. // Must not discard the (non-)printable Enter-key.
  5149. if (charCode >= 32 || charCode === 13) {
  5150. return charCode;
  5151. }
  5152. return 0;
  5153. }
  5154. function functionThatReturnsTrue() {
  5155. return true;
  5156. }
  5157. function functionThatReturnsFalse() {
  5158. return false;
  5159. } // This is intentionally a factory so that we have different returned constructors.
  5160. // If we had a single constructor, it would be megamorphic and engines would deopt.
  5161. function createSyntheticEvent(Interface) {
  5162. /**
  5163. * Synthetic events are dispatched by event plugins, typically in response to a
  5164. * top-level event delegation handler.
  5165. *
  5166. * These systems should generally use pooling to reduce the frequency of garbage
  5167. * collection. The system should check `isPersistent` to determine whether the
  5168. * event should be released into the pool after being dispatched. Users that
  5169. * need a persisted event should invoke `persist`.
  5170. *
  5171. * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
  5172. * normalizing browser quirks. Subclasses do not necessarily have to implement a
  5173. * DOM interface; custom application-specific events can also subclass this.
  5174. */
  5175. function SyntheticBaseEvent(reactName, reactEventType, targetInst, nativeEvent, nativeEventTarget) {
  5176. this._reactName = reactName;
  5177. this._targetInst = targetInst;
  5178. this.type = reactEventType;
  5179. this.nativeEvent = nativeEvent;
  5180. this.target = nativeEventTarget;
  5181. this.currentTarget = null;
  5182. for (var _propName in Interface) {
  5183. if (!Interface.hasOwnProperty(_propName)) {
  5184. continue;
  5185. }
  5186. var normalize = Interface[_propName];
  5187. if (normalize) {
  5188. this[_propName] = normalize(nativeEvent);
  5189. } else {
  5190. this[_propName] = nativeEvent[_propName];
  5191. }
  5192. }
  5193. var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
  5194. if (defaultPrevented) {
  5195. this.isDefaultPrevented = functionThatReturnsTrue;
  5196. } else {
  5197. this.isDefaultPrevented = functionThatReturnsFalse;
  5198. }
  5199. this.isPropagationStopped = functionThatReturnsFalse;
  5200. return this;
  5201. }
  5202. _assign(SyntheticBaseEvent.prototype, {
  5203. preventDefault: function () {
  5204. this.defaultPrevented = true;
  5205. var event = this.nativeEvent;
  5206. if (!event) {
  5207. return;
  5208. }
  5209. if (event.preventDefault) {
  5210. event.preventDefault(); // $FlowFixMe - flow is not aware of `unknown` in IE
  5211. } else if (typeof event.returnValue !== 'unknown') {
  5212. event.returnValue = false;
  5213. }
  5214. this.isDefaultPrevented = functionThatReturnsTrue;
  5215. },
  5216. stopPropagation: function () {
  5217. var event = this.nativeEvent;
  5218. if (!event) {
  5219. return;
  5220. }
  5221. if (event.stopPropagation) {
  5222. event.stopPropagation(); // $FlowFixMe - flow is not aware of `unknown` in IE
  5223. } else if (typeof event.cancelBubble !== 'unknown') {
  5224. // The ChangeEventPlugin registers a "propertychange" event for
  5225. // IE. This event does not support bubbling or cancelling, and
  5226. // any references to cancelBubble throw "Member not found". A
  5227. // typeof check of "unknown" circumvents this issue (and is also
  5228. // IE specific).
  5229. event.cancelBubble = true;
  5230. }
  5231. this.isPropagationStopped = functionThatReturnsTrue;
  5232. },
  5233. /**
  5234. * We release all dispatched `SyntheticEvent`s after each event loop, adding
  5235. * them back into the pool. This allows a way to hold onto a reference that
  5236. * won't be added back into the pool.
  5237. */
  5238. persist: function () {// Modern event system doesn't use pooling.
  5239. },
  5240. /**
  5241. * Checks if this event should be released back into the pool.
  5242. *
  5243. * @return {boolean} True if this should not be released, false otherwise.
  5244. */
  5245. isPersistent: functionThatReturnsTrue
  5246. });
  5247. return SyntheticBaseEvent;
  5248. }
  5249. /**
  5250. * @interface Event
  5251. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  5252. */
  5253. var EventInterface = {
  5254. eventPhase: 0,
  5255. bubbles: 0,
  5256. cancelable: 0,
  5257. timeStamp: function (event) {
  5258. return event.timeStamp || Date.now();
  5259. },
  5260. defaultPrevented: 0,
  5261. isTrusted: 0
  5262. };
  5263. var SyntheticEvent = createSyntheticEvent(EventInterface);
  5264. var UIEventInterface = _assign({}, EventInterface, {
  5265. view: 0,
  5266. detail: 0
  5267. });
  5268. var SyntheticUIEvent = createSyntheticEvent(UIEventInterface);
  5269. var lastMovementX;
  5270. var lastMovementY;
  5271. var lastMouseEvent;
  5272. function updateMouseMovementPolyfillState(event) {
  5273. if (event !== lastMouseEvent) {
  5274. if (lastMouseEvent && event.type === 'mousemove') {
  5275. lastMovementX = event.screenX - lastMouseEvent.screenX;
  5276. lastMovementY = event.screenY - lastMouseEvent.screenY;
  5277. } else {
  5278. lastMovementX = 0;
  5279. lastMovementY = 0;
  5280. }
  5281. lastMouseEvent = event;
  5282. }
  5283. }
  5284. /**
  5285. * @interface MouseEvent
  5286. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  5287. */
  5288. var MouseEventInterface = _assign({}, UIEventInterface, {
  5289. screenX: 0,
  5290. screenY: 0,
  5291. clientX: 0,
  5292. clientY: 0,
  5293. pageX: 0,
  5294. pageY: 0,
  5295. ctrlKey: 0,
  5296. shiftKey: 0,
  5297. altKey: 0,
  5298. metaKey: 0,
  5299. getModifierState: getEventModifierState,
  5300. button: 0,
  5301. buttons: 0,
  5302. relatedTarget: function (event) {
  5303. if (event.relatedTarget === undefined) return event.fromElement === event.srcElement ? event.toElement : event.fromElement;
  5304. return event.relatedTarget;
  5305. },
  5306. movementX: function (event) {
  5307. if ('movementX' in event) {
  5308. return event.movementX;
  5309. }
  5310. updateMouseMovementPolyfillState(event);
  5311. return lastMovementX;
  5312. },
  5313. movementY: function (event) {
  5314. if ('movementY' in event) {
  5315. return event.movementY;
  5316. } // Don't need to call updateMouseMovementPolyfillState() here
  5317. // because it's guaranteed to have already run when movementX
  5318. // was copied.
  5319. return lastMovementY;
  5320. }
  5321. });
  5322. var SyntheticMouseEvent = createSyntheticEvent(MouseEventInterface);
  5323. /**
  5324. * @interface DragEvent
  5325. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  5326. */
  5327. var DragEventInterface = _assign({}, MouseEventInterface, {
  5328. dataTransfer: 0
  5329. });
  5330. var SyntheticDragEvent = createSyntheticEvent(DragEventInterface);
  5331. /**
  5332. * @interface FocusEvent
  5333. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  5334. */
  5335. var FocusEventInterface = _assign({}, UIEventInterface, {
  5336. relatedTarget: 0
  5337. });
  5338. var SyntheticFocusEvent = createSyntheticEvent(FocusEventInterface);
  5339. /**
  5340. * @interface Event
  5341. * @see http://www.w3.org/TR/css3-animations/#AnimationEvent-interface
  5342. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationEvent
  5343. */
  5344. var AnimationEventInterface = _assign({}, EventInterface, {
  5345. animationName: 0,
  5346. elapsedTime: 0,
  5347. pseudoElement: 0
  5348. });
  5349. var SyntheticAnimationEvent = createSyntheticEvent(AnimationEventInterface);
  5350. /**
  5351. * @interface Event
  5352. * @see http://www.w3.org/TR/clipboard-apis/
  5353. */
  5354. var ClipboardEventInterface = _assign({}, EventInterface, {
  5355. clipboardData: function (event) {
  5356. return 'clipboardData' in event ? event.clipboardData : window.clipboardData;
  5357. }
  5358. });
  5359. var SyntheticClipboardEvent = createSyntheticEvent(ClipboardEventInterface);
  5360. /**
  5361. * @interface Event
  5362. * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents
  5363. */
  5364. var CompositionEventInterface = _assign({}, EventInterface, {
  5365. data: 0
  5366. });
  5367. var SyntheticCompositionEvent = createSyntheticEvent(CompositionEventInterface);
  5368. /**
  5369. * @interface Event
  5370. * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105
  5371. * /#events-inputevents
  5372. */
  5373. // Happens to share the same list for now.
  5374. var SyntheticInputEvent = SyntheticCompositionEvent;
  5375. /**
  5376. * Normalization of deprecated HTML5 `key` values
  5377. * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
  5378. */
  5379. var normalizeKey = {
  5380. Esc: 'Escape',
  5381. Spacebar: ' ',
  5382. Left: 'ArrowLeft',
  5383. Up: 'ArrowUp',
  5384. Right: 'ArrowRight',
  5385. Down: 'ArrowDown',
  5386. Del: 'Delete',
  5387. Win: 'OS',
  5388. Menu: 'ContextMenu',
  5389. Apps: 'ContextMenu',
  5390. Scroll: 'ScrollLock',
  5391. MozPrintableKey: 'Unidentified'
  5392. };
  5393. /**
  5394. * Translation from legacy `keyCode` to HTML5 `key`
  5395. * Only special keys supported, all others depend on keyboard layout or browser
  5396. * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
  5397. */
  5398. var translateToKey = {
  5399. '8': 'Backspace',
  5400. '9': 'Tab',
  5401. '12': 'Clear',
  5402. '13': 'Enter',
  5403. '16': 'Shift',
  5404. '17': 'Control',
  5405. '18': 'Alt',
  5406. '19': 'Pause',
  5407. '20': 'CapsLock',
  5408. '27': 'Escape',
  5409. '32': ' ',
  5410. '33': 'PageUp',
  5411. '34': 'PageDown',
  5412. '35': 'End',
  5413. '36': 'Home',
  5414. '37': 'ArrowLeft',
  5415. '38': 'ArrowUp',
  5416. '39': 'ArrowRight',
  5417. '40': 'ArrowDown',
  5418. '45': 'Insert',
  5419. '46': 'Delete',
  5420. '112': 'F1',
  5421. '113': 'F2',
  5422. '114': 'F3',
  5423. '115': 'F4',
  5424. '116': 'F5',
  5425. '117': 'F6',
  5426. '118': 'F7',
  5427. '119': 'F8',
  5428. '120': 'F9',
  5429. '121': 'F10',
  5430. '122': 'F11',
  5431. '123': 'F12',
  5432. '144': 'NumLock',
  5433. '145': 'ScrollLock',
  5434. '224': 'Meta'
  5435. };
  5436. /**
  5437. * @param {object} nativeEvent Native browser event.
  5438. * @return {string} Normalized `key` property.
  5439. */
  5440. function getEventKey(nativeEvent) {
  5441. if (nativeEvent.key) {
  5442. // Normalize inconsistent values reported by browsers due to
  5443. // implementations of a working draft specification.
  5444. // FireFox implements `key` but returns `MozPrintableKey` for all
  5445. // printable characters (normalized to `Unidentified`), ignore it.
  5446. var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
  5447. if (key !== 'Unidentified') {
  5448. return key;
  5449. }
  5450. } // Browser does not implement `key`, polyfill as much of it as we can.
  5451. if (nativeEvent.type === 'keypress') {
  5452. var charCode = getEventCharCode(nativeEvent); // The enter-key is technically both printable and non-printable and can
  5453. // thus be captured by `keypress`, no other non-printable key should.
  5454. return charCode === 13 ? 'Enter' : String.fromCharCode(charCode);
  5455. }
  5456. if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {
  5457. // While user keyboard layout determines the actual meaning of each
  5458. // `keyCode` value, almost all function keys have a universal value.
  5459. return translateToKey[nativeEvent.keyCode] || 'Unidentified';
  5460. }
  5461. return '';
  5462. }
  5463. /**
  5464. * Translation from modifier key to the associated property in the event.
  5465. * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
  5466. */
  5467. var modifierKeyToProp = {
  5468. Alt: 'altKey',
  5469. Control: 'ctrlKey',
  5470. Meta: 'metaKey',
  5471. Shift: 'shiftKey'
  5472. }; // Older browsers (Safari <= 10, iOS Safari <= 10.2) do not support
  5473. // getModifierState. If getModifierState is not supported, we map it to a set of
  5474. // modifier keys exposed by the event. In this case, Lock-keys are not supported.
  5475. function modifierStateGetter(keyArg) {
  5476. var syntheticEvent = this;
  5477. var nativeEvent = syntheticEvent.nativeEvent;
  5478. if (nativeEvent.getModifierState) {
  5479. return nativeEvent.getModifierState(keyArg);
  5480. }
  5481. var keyProp = modifierKeyToProp[keyArg];
  5482. return keyProp ? !!nativeEvent[keyProp] : false;
  5483. }
  5484. function getEventModifierState(nativeEvent) {
  5485. return modifierStateGetter;
  5486. }
  5487. /**
  5488. * @interface KeyboardEvent
  5489. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  5490. */
  5491. var KeyboardEventInterface = _assign({}, UIEventInterface, {
  5492. key: getEventKey,
  5493. code: 0,
  5494. location: 0,
  5495. ctrlKey: 0,
  5496. shiftKey: 0,
  5497. altKey: 0,
  5498. metaKey: 0,
  5499. repeat: 0,
  5500. locale: 0,
  5501. getModifierState: getEventModifierState,
  5502. // Legacy Interface
  5503. charCode: function (event) {
  5504. // `charCode` is the result of a KeyPress event and represents the value of
  5505. // the actual printable character.
  5506. // KeyPress is deprecated, but its replacement is not yet final and not
  5507. // implemented in any major browser. Only KeyPress has charCode.
  5508. if (event.type === 'keypress') {
  5509. return getEventCharCode(event);
  5510. }
  5511. return 0;
  5512. },
  5513. keyCode: function (event) {
  5514. // `keyCode` is the result of a KeyDown/Up event and represents the value of
  5515. // physical keyboard key.
  5516. // The actual meaning of the value depends on the users' keyboard layout
  5517. // which cannot be detected. Assuming that it is a US keyboard layout
  5518. // provides a surprisingly accurate mapping for US and European users.
  5519. // Due to this, it is left to the user to implement at this time.
  5520. if (event.type === 'keydown' || event.type === 'keyup') {
  5521. return event.keyCode;
  5522. }
  5523. return 0;
  5524. },
  5525. which: function (event) {
  5526. // `which` is an alias for either `keyCode` or `charCode` depending on the
  5527. // type of the event.
  5528. if (event.type === 'keypress') {
  5529. return getEventCharCode(event);
  5530. }
  5531. if (event.type === 'keydown' || event.type === 'keyup') {
  5532. return event.keyCode;
  5533. }
  5534. return 0;
  5535. }
  5536. });
  5537. var SyntheticKeyboardEvent = createSyntheticEvent(KeyboardEventInterface);
  5538. /**
  5539. * @interface PointerEvent
  5540. * @see http://www.w3.org/TR/pointerevents/
  5541. */
  5542. var PointerEventInterface = _assign({}, MouseEventInterface, {
  5543. pointerId: 0,
  5544. width: 0,
  5545. height: 0,
  5546. pressure: 0,
  5547. tangentialPressure: 0,
  5548. tiltX: 0,
  5549. tiltY: 0,
  5550. twist: 0,
  5551. pointerType: 0,
  5552. isPrimary: 0
  5553. });
  5554. var SyntheticPointerEvent = createSyntheticEvent(PointerEventInterface);
  5555. /**
  5556. * @interface TouchEvent
  5557. * @see http://www.w3.org/TR/touch-events/
  5558. */
  5559. var TouchEventInterface = _assign({}, UIEventInterface, {
  5560. touches: 0,
  5561. targetTouches: 0,
  5562. changedTouches: 0,
  5563. altKey: 0,
  5564. metaKey: 0,
  5565. ctrlKey: 0,
  5566. shiftKey: 0,
  5567. getModifierState: getEventModifierState
  5568. });
  5569. var SyntheticTouchEvent = createSyntheticEvent(TouchEventInterface);
  5570. /**
  5571. * @interface Event
  5572. * @see http://www.w3.org/TR/2009/WD-css3-transitions-20090320/#transition-events-
  5573. * @see https://developer.mozilla.org/en-US/docs/Web/API/TransitionEvent
  5574. */
  5575. var TransitionEventInterface = _assign({}, EventInterface, {
  5576. propertyName: 0,
  5577. elapsedTime: 0,
  5578. pseudoElement: 0
  5579. });
  5580. var SyntheticTransitionEvent = createSyntheticEvent(TransitionEventInterface);
  5581. /**
  5582. * @interface WheelEvent
  5583. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  5584. */
  5585. var WheelEventInterface = _assign({}, MouseEventInterface, {
  5586. deltaX: function (event) {
  5587. return 'deltaX' in event ? event.deltaX : // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
  5588. 'wheelDeltaX' in event ? -event.wheelDeltaX : 0;
  5589. },
  5590. deltaY: function (event) {
  5591. return 'deltaY' in event ? event.deltaY : // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
  5592. 'wheelDeltaY' in event ? -event.wheelDeltaY : // Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
  5593. 'wheelDelta' in event ? -event.wheelDelta : 0;
  5594. },
  5595. deltaZ: 0,
  5596. // Browsers without "deltaMode" is reporting in raw wheel delta where one
  5597. // notch on the scroll is always +/- 120, roughly equivalent to pixels.
  5598. // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or
  5599. // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size.
  5600. deltaMode: 0
  5601. });
  5602. var SyntheticWheelEvent = createSyntheticEvent(WheelEventInterface);
  5603. var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
  5604. var START_KEYCODE = 229;
  5605. var canUseCompositionEvent = canUseDOM && 'CompositionEvent' in window;
  5606. var documentMode = null;
  5607. if (canUseDOM && 'documentMode' in document) {
  5608. documentMode = document.documentMode;
  5609. } // Webkit offers a very useful `textInput` event that can be used to
  5610. // directly represent `beforeInput`. The IE `textinput` event is not as
  5611. // useful, so we don't use it.
  5612. var canUseTextInputEvent = canUseDOM && 'TextEvent' in window && !documentMode; // In IE9+, we have access to composition events, but the data supplied
  5613. // by the native compositionend event may be incorrect. Japanese ideographic
  5614. // spaces, for instance (\u3000) are not recorded correctly.
  5615. var useFallbackCompositionData = canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11);
  5616. var SPACEBAR_CODE = 32;
  5617. var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);
  5618. function registerEvents() {
  5619. registerTwoPhaseEvent('onBeforeInput', ['compositionend', 'keypress', 'textInput', 'paste']);
  5620. registerTwoPhaseEvent('onCompositionEnd', ['compositionend', 'focusout', 'keydown', 'keypress', 'keyup', 'mousedown']);
  5621. registerTwoPhaseEvent('onCompositionStart', ['compositionstart', 'focusout', 'keydown', 'keypress', 'keyup', 'mousedown']);
  5622. registerTwoPhaseEvent('onCompositionUpdate', ['compositionupdate', 'focusout', 'keydown', 'keypress', 'keyup', 'mousedown']);
  5623. } // Track whether we've ever handled a keypress on the space key.
  5624. var hasSpaceKeypress = false;
  5625. /**
  5626. * Return whether a native keypress event is assumed to be a command.
  5627. * This is required because Firefox fires `keypress` events for key commands
  5628. * (cut, copy, select-all, etc.) even though no character is inserted.
  5629. */
  5630. function isKeypressCommand(nativeEvent) {
  5631. return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) && // ctrlKey && altKey is equivalent to AltGr, and is not a command.
  5632. !(nativeEvent.ctrlKey && nativeEvent.altKey);
  5633. }
  5634. /**
  5635. * Translate native top level events into event types.
  5636. */
  5637. function getCompositionEventType(domEventName) {
  5638. switch (domEventName) {
  5639. case 'compositionstart':
  5640. return 'onCompositionStart';
  5641. case 'compositionend':
  5642. return 'onCompositionEnd';
  5643. case 'compositionupdate':
  5644. return 'onCompositionUpdate';
  5645. }
  5646. }
  5647. /**
  5648. * Does our fallback best-guess model think this event signifies that
  5649. * composition has begun?
  5650. */
  5651. function isFallbackCompositionStart(domEventName, nativeEvent) {
  5652. return domEventName === 'keydown' && nativeEvent.keyCode === START_KEYCODE;
  5653. }
  5654. /**
  5655. * Does our fallback mode think that this event is the end of composition?
  5656. */
  5657. function isFallbackCompositionEnd(domEventName, nativeEvent) {
  5658. switch (domEventName) {
  5659. case 'keyup':
  5660. // Command keys insert or clear IME input.
  5661. return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1;
  5662. case 'keydown':
  5663. // Expect IME keyCode on each keydown. If we get any other
  5664. // code we must have exited earlier.
  5665. return nativeEvent.keyCode !== START_KEYCODE;
  5666. case 'keypress':
  5667. case 'mousedown':
  5668. case 'focusout':
  5669. // Events are not possible without cancelling IME.
  5670. return true;
  5671. default:
  5672. return false;
  5673. }
  5674. }
  5675. /**
  5676. * Google Input Tools provides composition data via a CustomEvent,
  5677. * with the `data` property populated in the `detail` object. If this
  5678. * is available on the event object, use it. If not, this is a plain
  5679. * composition event and we have nothing special to extract.
  5680. *
  5681. * @param {object} nativeEvent
  5682. * @return {?string}
  5683. */
  5684. function getDataFromCustomEvent(nativeEvent) {
  5685. var detail = nativeEvent.detail;
  5686. if (typeof detail === 'object' && 'data' in detail) {
  5687. return detail.data;
  5688. }
  5689. return null;
  5690. }
  5691. /**
  5692. * Check if a composition event was triggered by Korean IME.
  5693. * Our fallback mode does not work well with IE's Korean IME,
  5694. * so just use native composition events when Korean IME is used.
  5695. * Although CompositionEvent.locale property is deprecated,
  5696. * it is available in IE, where our fallback mode is enabled.
  5697. *
  5698. * @param {object} nativeEvent
  5699. * @return {boolean}
  5700. */
  5701. function isUsingKoreanIME(nativeEvent) {
  5702. return nativeEvent.locale === 'ko';
  5703. } // Track the current IME composition status, if any.
  5704. var isComposing = false;
  5705. /**
  5706. * @return {?object} A SyntheticCompositionEvent.
  5707. */
  5708. function extractCompositionEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget) {
  5709. var eventType;
  5710. var fallbackData;
  5711. if (canUseCompositionEvent) {
  5712. eventType = getCompositionEventType(domEventName);
  5713. } else if (!isComposing) {
  5714. if (isFallbackCompositionStart(domEventName, nativeEvent)) {
  5715. eventType = 'onCompositionStart';
  5716. }
  5717. } else if (isFallbackCompositionEnd(domEventName, nativeEvent)) {
  5718. eventType = 'onCompositionEnd';
  5719. }
  5720. if (!eventType) {
  5721. return null;
  5722. }
  5723. if (useFallbackCompositionData && !isUsingKoreanIME(nativeEvent)) {
  5724. // The current composition is stored statically and must not be
  5725. // overwritten while composition continues.
  5726. if (!isComposing && eventType === 'onCompositionStart') {
  5727. isComposing = initialize(nativeEventTarget);
  5728. } else if (eventType === 'onCompositionEnd') {
  5729. if (isComposing) {
  5730. fallbackData = getData();
  5731. }
  5732. }
  5733. }
  5734. var listeners = accumulateTwoPhaseListeners(targetInst, eventType);
  5735. if (listeners.length > 0) {
  5736. var event = new SyntheticCompositionEvent(eventType, domEventName, null, nativeEvent, nativeEventTarget);
  5737. dispatchQueue.push({
  5738. event: event,
  5739. listeners: listeners
  5740. });
  5741. if (fallbackData) {
  5742. // Inject data generated from fallback path into the synthetic event.
  5743. // This matches the property of native CompositionEventInterface.
  5744. event.data = fallbackData;
  5745. } else {
  5746. var customData = getDataFromCustomEvent(nativeEvent);
  5747. if (customData !== null) {
  5748. event.data = customData;
  5749. }
  5750. }
  5751. }
  5752. }
  5753. function getNativeBeforeInputChars(domEventName, nativeEvent) {
  5754. switch (domEventName) {
  5755. case 'compositionend':
  5756. return getDataFromCustomEvent(nativeEvent);
  5757. case 'keypress':
  5758. /**
  5759. * If native `textInput` events are available, our goal is to make
  5760. * use of them. However, there is a special case: the spacebar key.
  5761. * In Webkit, preventing default on a spacebar `textInput` event
  5762. * cancels character insertion, but it *also* causes the browser
  5763. * to fall back to its default spacebar behavior of scrolling the
  5764. * page.
  5765. *
  5766. * Tracking at:
  5767. * https://code.google.com/p/chromium/issues/detail?id=355103
  5768. *
  5769. * To avoid this issue, use the keypress event as if no `textInput`
  5770. * event is available.
  5771. */
  5772. var which = nativeEvent.which;
  5773. if (which !== SPACEBAR_CODE) {
  5774. return null;
  5775. }
  5776. hasSpaceKeypress = true;
  5777. return SPACEBAR_CHAR;
  5778. case 'textInput':
  5779. // Record the characters to be added to the DOM.
  5780. var chars = nativeEvent.data; // If it's a spacebar character, assume that we have already handled
  5781. // it at the keypress level and bail immediately. Android Chrome
  5782. // doesn't give us keycodes, so we need to ignore it.
  5783. if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
  5784. return null;
  5785. }
  5786. return chars;
  5787. default:
  5788. // For other native event types, do nothing.
  5789. return null;
  5790. }
  5791. }
  5792. /**
  5793. * For browsers that do not provide the `textInput` event, extract the
  5794. * appropriate string to use for SyntheticInputEvent.
  5795. */
  5796. function getFallbackBeforeInputChars(domEventName, nativeEvent) {
  5797. // If we are currently composing (IME) and using a fallback to do so,
  5798. // try to extract the composed characters from the fallback object.
  5799. // If composition event is available, we extract a string only at
  5800. // compositionevent, otherwise extract it at fallback events.
  5801. if (isComposing) {
  5802. if (domEventName === 'compositionend' || !canUseCompositionEvent && isFallbackCompositionEnd(domEventName, nativeEvent)) {
  5803. var chars = getData();
  5804. reset();
  5805. isComposing = false;
  5806. return chars;
  5807. }
  5808. return null;
  5809. }
  5810. switch (domEventName) {
  5811. case 'paste':
  5812. // If a paste event occurs after a keypress, throw out the input
  5813. // chars. Paste events should not lead to BeforeInput events.
  5814. return null;
  5815. case 'keypress':
  5816. /**
  5817. * As of v27, Firefox may fire keypress events even when no character
  5818. * will be inserted. A few possibilities:
  5819. *
  5820. * - `which` is `0`. Arrow keys, Esc key, etc.
  5821. *
  5822. * - `which` is the pressed key code, but no char is available.
  5823. * Ex: 'AltGr + d` in Polish. There is no modified character for
  5824. * this key combination and no character is inserted into the
  5825. * document, but FF fires the keypress for char code `100` anyway.
  5826. * No `input` event will occur.
  5827. *
  5828. * - `which` is the pressed key code, but a command combination is
  5829. * being used. Ex: `Cmd+C`. No character is inserted, and no
  5830. * `input` event will occur.
  5831. */
  5832. if (!isKeypressCommand(nativeEvent)) {
  5833. // IE fires the `keypress` event when a user types an emoji via
  5834. // Touch keyboard of Windows. In such a case, the `char` property
  5835. // holds an emoji character like `\uD83D\uDE0A`. Because its length
  5836. // is 2, the property `which` does not represent an emoji correctly.
  5837. // In such a case, we directly return the `char` property instead of
  5838. // using `which`.
  5839. if (nativeEvent.char && nativeEvent.char.length > 1) {
  5840. return nativeEvent.char;
  5841. } else if (nativeEvent.which) {
  5842. return String.fromCharCode(nativeEvent.which);
  5843. }
  5844. }
  5845. return null;
  5846. case 'compositionend':
  5847. return useFallbackCompositionData && !isUsingKoreanIME(nativeEvent) ? null : nativeEvent.data;
  5848. default:
  5849. return null;
  5850. }
  5851. }
  5852. /**
  5853. * Extract a SyntheticInputEvent for `beforeInput`, based on either native
  5854. * `textInput` or fallback behavior.
  5855. *
  5856. * @return {?object} A SyntheticInputEvent.
  5857. */
  5858. function extractBeforeInputEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget) {
  5859. var chars;
  5860. if (canUseTextInputEvent) {
  5861. chars = getNativeBeforeInputChars(domEventName, nativeEvent);
  5862. } else {
  5863. chars = getFallbackBeforeInputChars(domEventName, nativeEvent);
  5864. } // If no characters are being inserted, no BeforeInput event should
  5865. // be fired.
  5866. if (!chars) {
  5867. return null;
  5868. }
  5869. var listeners = accumulateTwoPhaseListeners(targetInst, 'onBeforeInput');
  5870. if (listeners.length > 0) {
  5871. var event = new SyntheticInputEvent('onBeforeInput', 'beforeinput', null, nativeEvent, nativeEventTarget);
  5872. dispatchQueue.push({
  5873. event: event,
  5874. listeners: listeners
  5875. });
  5876. event.data = chars;
  5877. }
  5878. }
  5879. /**
  5880. * Create an `onBeforeInput` event to match
  5881. * http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents.
  5882. *
  5883. * This event plugin is based on the native `textInput` event
  5884. * available in Chrome, Safari, Opera, and IE. This event fires after
  5885. * `onKeyPress` and `onCompositionEnd`, but before `onInput`.
  5886. *
  5887. * `beforeInput` is spec'd but not implemented in any browsers, and
  5888. * the `input` event does not provide any useful information about what has
  5889. * actually been added, contrary to the spec. Thus, `textInput` is the best
  5890. * available event to identify the characters that have actually been inserted
  5891. * into the target node.
  5892. *
  5893. * This plugin is also responsible for emitting `composition` events, thus
  5894. * allowing us to share composition fallback code for both `beforeInput` and
  5895. * `composition` event types.
  5896. */
  5897. function extractEvents(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) {
  5898. extractCompositionEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget);
  5899. extractBeforeInputEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget);
  5900. }
  5901. /**
  5902. * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
  5903. */
  5904. var supportedInputTypes = {
  5905. color: true,
  5906. date: true,
  5907. datetime: true,
  5908. 'datetime-local': true,
  5909. email: true,
  5910. month: true,
  5911. number: true,
  5912. password: true,
  5913. range: true,
  5914. search: true,
  5915. tel: true,
  5916. text: true,
  5917. time: true,
  5918. url: true,
  5919. week: true
  5920. };
  5921. function isTextInputElement(elem) {
  5922. var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
  5923. if (nodeName === 'input') {
  5924. return !!supportedInputTypes[elem.type];
  5925. }
  5926. if (nodeName === 'textarea') {
  5927. return true;
  5928. }
  5929. return false;
  5930. }
  5931. /**
  5932. * Checks if an event is supported in the current execution environment.
  5933. *
  5934. * NOTE: This will not work correctly for non-generic events such as `change`,
  5935. * `reset`, `load`, `error`, and `select`.
  5936. *
  5937. * Borrows from Modernizr.
  5938. *
  5939. * @param {string} eventNameSuffix Event name, e.g. "click".
  5940. * @return {boolean} True if the event is supported.
  5941. * @internal
  5942. * @license Modernizr 3.0.0pre (Custom Build) | MIT
  5943. */
  5944. function isEventSupported(eventNameSuffix) {
  5945. if (!canUseDOM) {
  5946. return false;
  5947. }
  5948. var eventName = 'on' + eventNameSuffix;
  5949. var isSupported = (eventName in document);
  5950. if (!isSupported) {
  5951. var element = document.createElement('div');
  5952. element.setAttribute(eventName, 'return;');
  5953. isSupported = typeof element[eventName] === 'function';
  5954. }
  5955. return isSupported;
  5956. }
  5957. function registerEvents$1() {
  5958. registerTwoPhaseEvent('onChange', ['change', 'click', 'focusin', 'focusout', 'input', 'keydown', 'keyup', 'selectionchange']);
  5959. }
  5960. function createAndAccumulateChangeEvent(dispatchQueue, inst, nativeEvent, target) {
  5961. // Flag this event loop as needing state restore.
  5962. enqueueStateRestore(target);
  5963. var listeners = accumulateTwoPhaseListeners(inst, 'onChange');
  5964. if (listeners.length > 0) {
  5965. var event = new SyntheticEvent('onChange', 'change', null, nativeEvent, target);
  5966. dispatchQueue.push({
  5967. event: event,
  5968. listeners: listeners
  5969. });
  5970. }
  5971. }
  5972. /**
  5973. * For IE shims
  5974. */
  5975. var activeElement = null;
  5976. var activeElementInst = null;
  5977. /**
  5978. * SECTION: handle `change` event
  5979. */
  5980. function shouldUseChangeEvent(elem) {
  5981. var nodeName = elem.nodeName && elem.nodeName.toLowerCase();
  5982. return nodeName === 'select' || nodeName === 'input' && elem.type === 'file';
  5983. }
  5984. function manualDispatchChangeEvent(nativeEvent) {
  5985. var dispatchQueue = [];
  5986. createAndAccumulateChangeEvent(dispatchQueue, activeElementInst, nativeEvent, getEventTarget(nativeEvent)); // If change and propertychange bubbled, we'd just bind to it like all the
  5987. // other events and have it go through ReactBrowserEventEmitter. Since it
  5988. // doesn't, we manually listen for the events and so we have to enqueue and
  5989. // process the abstract event manually.
  5990. //
  5991. // Batching is necessary here in order to ensure that all event handlers run
  5992. // before the next rerender (including event handlers attached to ancestor
  5993. // elements instead of directly on the input). Without this, controlled
  5994. // components don't work properly in conjunction with event bubbling because
  5995. // the component is rerendered and the value reverted before all the event
  5996. // handlers can run. See https://github.com/facebook/react/issues/708.
  5997. batchedUpdates(runEventInBatch, dispatchQueue);
  5998. }
  5999. function runEventInBatch(dispatchQueue) {
  6000. processDispatchQueue(dispatchQueue, 0);
  6001. }
  6002. function getInstIfValueChanged(targetInst) {
  6003. var targetNode = getNodeFromInstance(targetInst);
  6004. if (updateValueIfChanged(targetNode)) {
  6005. return targetInst;
  6006. }
  6007. }
  6008. function getTargetInstForChangeEvent(domEventName, targetInst) {
  6009. if (domEventName === 'change') {
  6010. return targetInst;
  6011. }
  6012. }
  6013. /**
  6014. * SECTION: handle `input` event
  6015. */
  6016. var isInputEventSupported = false;
  6017. if (canUseDOM) {
  6018. // IE9 claims to support the input event but fails to trigger it when
  6019. // deleting text, so we ignore its input events.
  6020. isInputEventSupported = isEventSupported('input') && (!document.documentMode || document.documentMode > 9);
  6021. }
  6022. /**
  6023. * (For IE <=9) Starts tracking propertychange events on the passed-in element
  6024. * and override the value property so that we can distinguish user events from
  6025. * value changes in JS.
  6026. */
  6027. function startWatchingForValueChange(target, targetInst) {
  6028. activeElement = target;
  6029. activeElementInst = targetInst;
  6030. activeElement.attachEvent('onpropertychange', handlePropertyChange);
  6031. }
  6032. /**
  6033. * (For IE <=9) Removes the event listeners from the currently-tracked element,
  6034. * if any exists.
  6035. */
  6036. function stopWatchingForValueChange() {
  6037. if (!activeElement) {
  6038. return;
  6039. }
  6040. activeElement.detachEvent('onpropertychange', handlePropertyChange);
  6041. activeElement = null;
  6042. activeElementInst = null;
  6043. }
  6044. /**
  6045. * (For IE <=9) Handles a propertychange event, sending a `change` event if
  6046. * the value of the active element has changed.
  6047. */
  6048. function handlePropertyChange(nativeEvent) {
  6049. if (nativeEvent.propertyName !== 'value') {
  6050. return;
  6051. }
  6052. if (getInstIfValueChanged(activeElementInst)) {
  6053. manualDispatchChangeEvent(nativeEvent);
  6054. }
  6055. }
  6056. function handleEventsForInputEventPolyfill(domEventName, target, targetInst) {
  6057. if (domEventName === 'focusin') {
  6058. // In IE9, propertychange fires for most input events but is buggy and
  6059. // doesn't fire when text is deleted, but conveniently, selectionchange
  6060. // appears to fire in all of the remaining cases so we catch those and
  6061. // forward the event if the value has changed
  6062. // In either case, we don't want to call the event handler if the value
  6063. // is changed from JS so we redefine a setter for `.value` that updates
  6064. // our activeElementValue variable, allowing us to ignore those changes
  6065. //
  6066. // stopWatching() should be a noop here but we call it just in case we
  6067. // missed a blur event somehow.
  6068. stopWatchingForValueChange();
  6069. startWatchingForValueChange(target, targetInst);
  6070. } else if (domEventName === 'focusout') {
  6071. stopWatchingForValueChange();
  6072. }
  6073. } // For IE8 and IE9.
  6074. function getTargetInstForInputEventPolyfill(domEventName, targetInst) {
  6075. if (domEventName === 'selectionchange' || domEventName === 'keyup' || domEventName === 'keydown') {
  6076. // On the selectionchange event, the target is just document which isn't
  6077. // helpful for us so just check activeElement instead.
  6078. //
  6079. // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire
  6080. // propertychange on the first input event after setting `value` from a
  6081. // script and fires only keydown, keypress, keyup. Catching keyup usually
  6082. // gets it and catching keydown lets us fire an event for the first
  6083. // keystroke if user does a key repeat (it'll be a little delayed: right
  6084. // before the second keystroke). Other input methods (e.g., paste) seem to
  6085. // fire selectionchange normally.
  6086. return getInstIfValueChanged(activeElementInst);
  6087. }
  6088. }
  6089. /**
  6090. * SECTION: handle `click` event
  6091. */
  6092. function shouldUseClickEvent(elem) {
  6093. // Use the `click` event to detect changes to checkbox and radio inputs.
  6094. // This approach works across all browsers, whereas `change` does not fire
  6095. // until `blur` in IE8.
  6096. var nodeName = elem.nodeName;
  6097. return nodeName && nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio');
  6098. }
  6099. function getTargetInstForClickEvent(domEventName, targetInst) {
  6100. if (domEventName === 'click') {
  6101. return getInstIfValueChanged(targetInst);
  6102. }
  6103. }
  6104. function getTargetInstForInputOrChangeEvent(domEventName, targetInst) {
  6105. if (domEventName === 'input' || domEventName === 'change') {
  6106. return getInstIfValueChanged(targetInst);
  6107. }
  6108. }
  6109. function handleControlledInputBlur(node) {
  6110. var state = node._wrapperState;
  6111. if (!state || !state.controlled || node.type !== 'number') {
  6112. return;
  6113. }
  6114. {
  6115. // If controlled, assign the value attribute to the current value on blur
  6116. setDefaultValue(node, 'number', node.value);
  6117. }
  6118. }
  6119. /**
  6120. * This plugin creates an `onChange` event that normalizes change events
  6121. * across form elements. This event fires at a time when it's possible to
  6122. * change the element's value without seeing a flicker.
  6123. *
  6124. * Supported elements are:
  6125. * - input (see `isTextInputElement`)
  6126. * - textarea
  6127. * - select
  6128. */
  6129. function extractEvents$1(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) {
  6130. var targetNode = targetInst ? getNodeFromInstance(targetInst) : window;
  6131. var getTargetInstFunc, handleEventFunc;
  6132. if (shouldUseChangeEvent(targetNode)) {
  6133. getTargetInstFunc = getTargetInstForChangeEvent;
  6134. } else if (isTextInputElement(targetNode)) {
  6135. if (isInputEventSupported) {
  6136. getTargetInstFunc = getTargetInstForInputOrChangeEvent;
  6137. } else {
  6138. getTargetInstFunc = getTargetInstForInputEventPolyfill;
  6139. handleEventFunc = handleEventsForInputEventPolyfill;
  6140. }
  6141. } else if (shouldUseClickEvent(targetNode)) {
  6142. getTargetInstFunc = getTargetInstForClickEvent;
  6143. }
  6144. if (getTargetInstFunc) {
  6145. var inst = getTargetInstFunc(domEventName, targetInst);
  6146. if (inst) {
  6147. createAndAccumulateChangeEvent(dispatchQueue, inst, nativeEvent, nativeEventTarget);
  6148. return;
  6149. }
  6150. }
  6151. if (handleEventFunc) {
  6152. handleEventFunc(domEventName, targetNode, targetInst);
  6153. } // When blurring, set the value attribute for number inputs
  6154. if (domEventName === 'focusout') {
  6155. handleControlledInputBlur(targetNode);
  6156. }
  6157. }
  6158. function registerEvents$2() {
  6159. registerDirectEvent('onMouseEnter', ['mouseout', 'mouseover']);
  6160. registerDirectEvent('onMouseLeave', ['mouseout', 'mouseover']);
  6161. registerDirectEvent('onPointerEnter', ['pointerout', 'pointerover']);
  6162. registerDirectEvent('onPointerLeave', ['pointerout', 'pointerover']);
  6163. }
  6164. /**
  6165. * For almost every interaction we care about, there will be both a top-level
  6166. * `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that
  6167. * we do not extract duplicate events. However, moving the mouse into the
  6168. * browser from outside will not fire a `mouseout` event. In this case, we use
  6169. * the `mouseover` top-level event.
  6170. */
  6171. function extractEvents$2(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) {
  6172. var isOverEvent = domEventName === 'mouseover' || domEventName === 'pointerover';
  6173. var isOutEvent = domEventName === 'mouseout' || domEventName === 'pointerout';
  6174. if (isOverEvent && (eventSystemFlags & IS_REPLAYED) === 0) {
  6175. // If this is an over event with a target, we might have already dispatched
  6176. // the event in the out event of the other target. If this is replayed,
  6177. // then it's because we couldn't dispatch against this target previously
  6178. // so we have to do it now instead.
  6179. var related = nativeEvent.relatedTarget || nativeEvent.fromElement;
  6180. if (related) {
  6181. // If the related node is managed by React, we can assume that we have
  6182. // already dispatched the corresponding events during its mouseout.
  6183. if (getClosestInstanceFromNode(related) || isContainerMarkedAsRoot(related)) {
  6184. return;
  6185. }
  6186. }
  6187. }
  6188. if (!isOutEvent && !isOverEvent) {
  6189. // Must not be a mouse or pointer in or out - ignoring.
  6190. return;
  6191. }
  6192. var win; // TODO: why is this nullable in the types but we read from it?
  6193. if (nativeEventTarget.window === nativeEventTarget) {
  6194. // `nativeEventTarget` is probably a window object.
  6195. win = nativeEventTarget;
  6196. } else {
  6197. // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
  6198. var doc = nativeEventTarget.ownerDocument;
  6199. if (doc) {
  6200. win = doc.defaultView || doc.parentWindow;
  6201. } else {
  6202. win = window;
  6203. }
  6204. }
  6205. var from;
  6206. var to;
  6207. if (isOutEvent) {
  6208. var _related = nativeEvent.relatedTarget || nativeEvent.toElement;
  6209. from = targetInst;
  6210. to = _related ? getClosestInstanceFromNode(_related) : null;
  6211. if (to !== null) {
  6212. var nearestMounted = getNearestMountedFiber(to);
  6213. if (to !== nearestMounted || to.tag !== HostComponent && to.tag !== HostText) {
  6214. to = null;
  6215. }
  6216. }
  6217. } else {
  6218. // Moving to a node from outside the window.
  6219. from = null;
  6220. to = targetInst;
  6221. }
  6222. if (from === to) {
  6223. // Nothing pertains to our managed components.
  6224. return;
  6225. }
  6226. var SyntheticEventCtor = SyntheticMouseEvent;
  6227. var leaveEventType = 'onMouseLeave';
  6228. var enterEventType = 'onMouseEnter';
  6229. var eventTypePrefix = 'mouse';
  6230. if (domEventName === 'pointerout' || domEventName === 'pointerover') {
  6231. SyntheticEventCtor = SyntheticPointerEvent;
  6232. leaveEventType = 'onPointerLeave';
  6233. enterEventType = 'onPointerEnter';
  6234. eventTypePrefix = 'pointer';
  6235. }
  6236. var fromNode = from == null ? win : getNodeFromInstance(from);
  6237. var toNode = to == null ? win : getNodeFromInstance(to);
  6238. var leave = new SyntheticEventCtor(leaveEventType, eventTypePrefix + 'leave', from, nativeEvent, nativeEventTarget);
  6239. leave.target = fromNode;
  6240. leave.relatedTarget = toNode;
  6241. var enter = null; // We should only process this nativeEvent if we are processing
  6242. // the first ancestor. Next time, we will ignore the event.
  6243. var nativeTargetInst = getClosestInstanceFromNode(nativeEventTarget);
  6244. if (nativeTargetInst === targetInst) {
  6245. var enterEvent = new SyntheticEventCtor(enterEventType, eventTypePrefix + 'enter', to, nativeEvent, nativeEventTarget);
  6246. enterEvent.target = toNode;
  6247. enterEvent.relatedTarget = fromNode;
  6248. enter = enterEvent;
  6249. }
  6250. accumulateEnterLeaveTwoPhaseListeners(dispatchQueue, leave, enter, from, to);
  6251. }
  6252. /**
  6253. * inlined Object.is polyfill to avoid requiring consumers ship their own
  6254. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  6255. */
  6256. function is(x, y) {
  6257. return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
  6258. ;
  6259. }
  6260. var objectIs = typeof Object.is === 'function' ? Object.is : is;
  6261. var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
  6262. /**
  6263. * Performs equality by iterating through keys on an object and returning false
  6264. * when any key has values which are not strictly equal between the arguments.
  6265. * Returns true when the values of all keys are strictly equal.
  6266. */
  6267. function shallowEqual(objA, objB) {
  6268. if (objectIs(objA, objB)) {
  6269. return true;
  6270. }
  6271. if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
  6272. return false;
  6273. }
  6274. var keysA = Object.keys(objA);
  6275. var keysB = Object.keys(objB);
  6276. if (keysA.length !== keysB.length) {
  6277. return false;
  6278. } // Test for A's keys different from B.
  6279. for (var i = 0; i < keysA.length; i++) {
  6280. if (!hasOwnProperty$2.call(objB, keysA[i]) || !objectIs(objA[keysA[i]], objB[keysA[i]])) {
  6281. return false;
  6282. }
  6283. }
  6284. return true;
  6285. }
  6286. /**
  6287. * Given any node return the first leaf node without children.
  6288. *
  6289. * @param {DOMElement|DOMTextNode} node
  6290. * @return {DOMElement|DOMTextNode}
  6291. */
  6292. function getLeafNode(node) {
  6293. while (node && node.firstChild) {
  6294. node = node.firstChild;
  6295. }
  6296. return node;
  6297. }
  6298. /**
  6299. * Get the next sibling within a container. This will walk up the
  6300. * DOM if a node's siblings have been exhausted.
  6301. *
  6302. * @param {DOMElement|DOMTextNode} node
  6303. * @return {?DOMElement|DOMTextNode}
  6304. */
  6305. function getSiblingNode(node) {
  6306. while (node) {
  6307. if (node.nextSibling) {
  6308. return node.nextSibling;
  6309. }
  6310. node = node.parentNode;
  6311. }
  6312. }
  6313. /**
  6314. * Get object describing the nodes which contain characters at offset.
  6315. *
  6316. * @param {DOMElement|DOMTextNode} root
  6317. * @param {number} offset
  6318. * @return {?object}
  6319. */
  6320. function getNodeForCharacterOffset(root, offset) {
  6321. var node = getLeafNode(root);
  6322. var nodeStart = 0;
  6323. var nodeEnd = 0;
  6324. while (node) {
  6325. if (node.nodeType === TEXT_NODE) {
  6326. nodeEnd = nodeStart + node.textContent.length;
  6327. if (nodeStart <= offset && nodeEnd >= offset) {
  6328. return {
  6329. node: node,
  6330. offset: offset - nodeStart
  6331. };
  6332. }
  6333. nodeStart = nodeEnd;
  6334. }
  6335. node = getLeafNode(getSiblingNode(node));
  6336. }
  6337. }
  6338. /**
  6339. * @param {DOMElement} outerNode
  6340. * @return {?object}
  6341. */
  6342. function getOffsets(outerNode) {
  6343. var ownerDocument = outerNode.ownerDocument;
  6344. var win = ownerDocument && ownerDocument.defaultView || window;
  6345. var selection = win.getSelection && win.getSelection();
  6346. if (!selection || selection.rangeCount === 0) {
  6347. return null;
  6348. }
  6349. var anchorNode = selection.anchorNode,
  6350. anchorOffset = selection.anchorOffset,
  6351. focusNode = selection.focusNode,
  6352. focusOffset = selection.focusOffset; // In Firefox, anchorNode and focusNode can be "anonymous divs", e.g. the
  6353. // up/down buttons on an <input type="number">. Anonymous divs do not seem to
  6354. // expose properties, triggering a "Permission denied error" if any of its
  6355. // properties are accessed. The only seemingly possible way to avoid erroring
  6356. // is to access a property that typically works for non-anonymous divs and
  6357. // catch any error that may otherwise arise. See
  6358. // https://bugzilla.mozilla.org/show_bug.cgi?id=208427
  6359. try {
  6360. /* eslint-disable no-unused-expressions */
  6361. anchorNode.nodeType;
  6362. focusNode.nodeType;
  6363. /* eslint-enable no-unused-expressions */
  6364. } catch (e) {
  6365. return null;
  6366. }
  6367. return getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset);
  6368. }
  6369. /**
  6370. * Returns {start, end} where `start` is the character/codepoint index of
  6371. * (anchorNode, anchorOffset) within the textContent of `outerNode`, and
  6372. * `end` is the index of (focusNode, focusOffset).
  6373. *
  6374. * Returns null if you pass in garbage input but we should probably just crash.
  6375. *
  6376. * Exported only for testing.
  6377. */
  6378. function getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset) {
  6379. var length = 0;
  6380. var start = -1;
  6381. var end = -1;
  6382. var indexWithinAnchor = 0;
  6383. var indexWithinFocus = 0;
  6384. var node = outerNode;
  6385. var parentNode = null;
  6386. outer: while (true) {
  6387. var next = null;
  6388. while (true) {
  6389. if (node === anchorNode && (anchorOffset === 0 || node.nodeType === TEXT_NODE)) {
  6390. start = length + anchorOffset;
  6391. }
  6392. if (node === focusNode && (focusOffset === 0 || node.nodeType === TEXT_NODE)) {
  6393. end = length + focusOffset;
  6394. }
  6395. if (node.nodeType === TEXT_NODE) {
  6396. length += node.nodeValue.length;
  6397. }
  6398. if ((next = node.firstChild) === null) {
  6399. break;
  6400. } // Moving from `node` to its first child `next`.
  6401. parentNode = node;
  6402. node = next;
  6403. }
  6404. while (true) {
  6405. if (node === outerNode) {
  6406. // If `outerNode` has children, this is always the second time visiting
  6407. // it. If it has no children, this is still the first loop, and the only
  6408. // valid selection is anchorNode and focusNode both equal to this node
  6409. // and both offsets 0, in which case we will have handled above.
  6410. break outer;
  6411. }
  6412. if (parentNode === anchorNode && ++indexWithinAnchor === anchorOffset) {
  6413. start = length;
  6414. }
  6415. if (parentNode === focusNode && ++indexWithinFocus === focusOffset) {
  6416. end = length;
  6417. }
  6418. if ((next = node.nextSibling) !== null) {
  6419. break;
  6420. }
  6421. node = parentNode;
  6422. parentNode = node.parentNode;
  6423. } // Moving from `node` to its next sibling `next`.
  6424. node = next;
  6425. }
  6426. if (start === -1 || end === -1) {
  6427. // This should never happen. (Would happen if the anchor/focus nodes aren't
  6428. // actually inside the passed-in node.)
  6429. return null;
  6430. }
  6431. return {
  6432. start: start,
  6433. end: end
  6434. };
  6435. }
  6436. /**
  6437. * In modern non-IE browsers, we can support both forward and backward
  6438. * selections.
  6439. *
  6440. * Note: IE10+ supports the Selection object, but it does not support
  6441. * the `extend` method, which means that even in modern IE, it's not possible
  6442. * to programmatically create a backward selection. Thus, for all IE
  6443. * versions, we use the old IE API to create our selections.
  6444. *
  6445. * @param {DOMElement|DOMTextNode} node
  6446. * @param {object} offsets
  6447. */
  6448. function setOffsets(node, offsets) {
  6449. var doc = node.ownerDocument || document;
  6450. var win = doc && doc.defaultView || window; // Edge fails with "Object expected" in some scenarios.
  6451. // (For instance: TinyMCE editor used in a list component that supports pasting to add more,
  6452. // fails when pasting 100+ items)
  6453. if (!win.getSelection) {
  6454. return;
  6455. }
  6456. var selection = win.getSelection();
  6457. var length = node.textContent.length;
  6458. var start = Math.min(offsets.start, length);
  6459. var end = offsets.end === undefined ? start : Math.min(offsets.end, length); // IE 11 uses modern selection, but doesn't support the extend method.
  6460. // Flip backward selections, so we can set with a single range.
  6461. if (!selection.extend && start > end) {
  6462. var temp = end;
  6463. end = start;
  6464. start = temp;
  6465. }
  6466. var startMarker = getNodeForCharacterOffset(node, start);
  6467. var endMarker = getNodeForCharacterOffset(node, end);
  6468. if (startMarker && endMarker) {
  6469. if (selection.rangeCount === 1 && selection.anchorNode === startMarker.node && selection.anchorOffset === startMarker.offset && selection.focusNode === endMarker.node && selection.focusOffset === endMarker.offset) {
  6470. return;
  6471. }
  6472. var range = doc.createRange();
  6473. range.setStart(startMarker.node, startMarker.offset);
  6474. selection.removeAllRanges();
  6475. if (start > end) {
  6476. selection.addRange(range);
  6477. selection.extend(endMarker.node, endMarker.offset);
  6478. } else {
  6479. range.setEnd(endMarker.node, endMarker.offset);
  6480. selection.addRange(range);
  6481. }
  6482. }
  6483. }
  6484. function isTextNode(node) {
  6485. return node && node.nodeType === TEXT_NODE;
  6486. }
  6487. function containsNode(outerNode, innerNode) {
  6488. if (!outerNode || !innerNode) {
  6489. return false;
  6490. } else if (outerNode === innerNode) {
  6491. return true;
  6492. } else if (isTextNode(outerNode)) {
  6493. return false;
  6494. } else if (isTextNode(innerNode)) {
  6495. return containsNode(outerNode, innerNode.parentNode);
  6496. } else if ('contains' in outerNode) {
  6497. return outerNode.contains(innerNode);
  6498. } else if (outerNode.compareDocumentPosition) {
  6499. return !!(outerNode.compareDocumentPosition(innerNode) & 16);
  6500. } else {
  6501. return false;
  6502. }
  6503. }
  6504. function isInDocument(node) {
  6505. return node && node.ownerDocument && containsNode(node.ownerDocument.documentElement, node);
  6506. }
  6507. function isSameOriginFrame(iframe) {
  6508. try {
  6509. // Accessing the contentDocument of a HTMLIframeElement can cause the browser
  6510. // to throw, e.g. if it has a cross-origin src attribute.
  6511. // Safari will show an error in the console when the access results in "Blocked a frame with origin". e.g:
  6512. // iframe.contentDocument.defaultView;
  6513. // A safety way is to access one of the cross origin properties: Window or Location
  6514. // Which might result in "SecurityError" DOM Exception and it is compatible to Safari.
  6515. // https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl
  6516. return typeof iframe.contentWindow.location.href === 'string';
  6517. } catch (err) {
  6518. return false;
  6519. }
  6520. }
  6521. function getActiveElementDeep() {
  6522. var win = window;
  6523. var element = getActiveElement();
  6524. while (element instanceof win.HTMLIFrameElement) {
  6525. if (isSameOriginFrame(element)) {
  6526. win = element.contentWindow;
  6527. } else {
  6528. return element;
  6529. }
  6530. element = getActiveElement(win.document);
  6531. }
  6532. return element;
  6533. }
  6534. /**
  6535. * @ReactInputSelection: React input selection module. Based on Selection.js,
  6536. * but modified to be suitable for react and has a couple of bug fixes (doesn't
  6537. * assume buttons have range selections allowed).
  6538. * Input selection module for React.
  6539. */
  6540. /**
  6541. * @hasSelectionCapabilities: we get the element types that support selection
  6542. * from https://html.spec.whatwg.org/#do-not-apply, looking at `selectionStart`
  6543. * and `selectionEnd` rows.
  6544. */
  6545. function hasSelectionCapabilities(elem) {
  6546. var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
  6547. return nodeName && (nodeName === 'input' && (elem.type === 'text' || elem.type === 'search' || elem.type === 'tel' || elem.type === 'url' || elem.type === 'password') || nodeName === 'textarea' || elem.contentEditable === 'true');
  6548. }
  6549. function getSelectionInformation() {
  6550. var focusedElem = getActiveElementDeep();
  6551. return {
  6552. focusedElem: focusedElem,
  6553. selectionRange: hasSelectionCapabilities(focusedElem) ? getSelection(focusedElem) : null
  6554. };
  6555. }
  6556. /**
  6557. * @restoreSelection: If any selection information was potentially lost,
  6558. * restore it. This is useful when performing operations that could remove dom
  6559. * nodes and place them back in, resulting in focus being lost.
  6560. */
  6561. function restoreSelection(priorSelectionInformation) {
  6562. var curFocusedElem = getActiveElementDeep();
  6563. var priorFocusedElem = priorSelectionInformation.focusedElem;
  6564. var priorSelectionRange = priorSelectionInformation.selectionRange;
  6565. if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) {
  6566. if (priorSelectionRange !== null && hasSelectionCapabilities(priorFocusedElem)) {
  6567. setSelection(priorFocusedElem, priorSelectionRange);
  6568. } // Focusing a node can change the scroll position, which is undesirable
  6569. var ancestors = [];
  6570. var ancestor = priorFocusedElem;
  6571. while (ancestor = ancestor.parentNode) {
  6572. if (ancestor.nodeType === ELEMENT_NODE) {
  6573. ancestors.push({
  6574. element: ancestor,
  6575. left: ancestor.scrollLeft,
  6576. top: ancestor.scrollTop
  6577. });
  6578. }
  6579. }
  6580. if (typeof priorFocusedElem.focus === 'function') {
  6581. priorFocusedElem.focus();
  6582. }
  6583. for (var i = 0; i < ancestors.length; i++) {
  6584. var info = ancestors[i];
  6585. info.element.scrollLeft = info.left;
  6586. info.element.scrollTop = info.top;
  6587. }
  6588. }
  6589. }
  6590. /**
  6591. * @getSelection: Gets the selection bounds of a focused textarea, input or
  6592. * contentEditable node.
  6593. * -@input: Look up selection bounds of this input
  6594. * -@return {start: selectionStart, end: selectionEnd}
  6595. */
  6596. function getSelection(input) {
  6597. var selection;
  6598. if ('selectionStart' in input) {
  6599. // Modern browser with input or textarea.
  6600. selection = {
  6601. start: input.selectionStart,
  6602. end: input.selectionEnd
  6603. };
  6604. } else {
  6605. // Content editable or old IE textarea.
  6606. selection = getOffsets(input);
  6607. }
  6608. return selection || {
  6609. start: 0,
  6610. end: 0
  6611. };
  6612. }
  6613. /**
  6614. * @setSelection: Sets the selection bounds of a textarea or input and focuses
  6615. * the input.
  6616. * -@input Set selection bounds of this input or textarea
  6617. * -@offsets Object of same form that is returned from get*
  6618. */
  6619. function setSelection(input, offsets) {
  6620. var start = offsets.start;
  6621. var end = offsets.end;
  6622. if (end === undefined) {
  6623. end = start;
  6624. }
  6625. if ('selectionStart' in input) {
  6626. input.selectionStart = start;
  6627. input.selectionEnd = Math.min(end, input.value.length);
  6628. } else {
  6629. setOffsets(input, offsets);
  6630. }
  6631. }
  6632. var skipSelectionChangeEvent = canUseDOM && 'documentMode' in document && document.documentMode <= 11;
  6633. function registerEvents$3() {
  6634. registerTwoPhaseEvent('onSelect', ['focusout', 'contextmenu', 'dragend', 'focusin', 'keydown', 'keyup', 'mousedown', 'mouseup', 'selectionchange']);
  6635. }
  6636. var activeElement$1 = null;
  6637. var activeElementInst$1 = null;
  6638. var lastSelection = null;
  6639. var mouseDown = false;
  6640. /**
  6641. * Get an object which is a unique representation of the current selection.
  6642. *
  6643. * The return value will not be consistent across nodes or browsers, but
  6644. * two identical selections on the same node will return identical objects.
  6645. */
  6646. function getSelection$1(node) {
  6647. if ('selectionStart' in node && hasSelectionCapabilities(node)) {
  6648. return {
  6649. start: node.selectionStart,
  6650. end: node.selectionEnd
  6651. };
  6652. } else {
  6653. var win = node.ownerDocument && node.ownerDocument.defaultView || window;
  6654. var selection = win.getSelection();
  6655. return {
  6656. anchorNode: selection.anchorNode,
  6657. anchorOffset: selection.anchorOffset,
  6658. focusNode: selection.focusNode,
  6659. focusOffset: selection.focusOffset
  6660. };
  6661. }
  6662. }
  6663. /**
  6664. * Get document associated with the event target.
  6665. */
  6666. function getEventTargetDocument(eventTarget) {
  6667. return eventTarget.window === eventTarget ? eventTarget.document : eventTarget.nodeType === DOCUMENT_NODE ? eventTarget : eventTarget.ownerDocument;
  6668. }
  6669. /**
  6670. * Poll selection to see whether it's changed.
  6671. *
  6672. * @param {object} nativeEvent
  6673. * @param {object} nativeEventTarget
  6674. * @return {?SyntheticEvent}
  6675. */
  6676. function constructSelectEvent(dispatchQueue, nativeEvent, nativeEventTarget) {
  6677. // Ensure we have the right element, and that the user is not dragging a
  6678. // selection (this matches native `select` event behavior). In HTML5, select
  6679. // fires only on input and textarea thus if there's no focused element we
  6680. // won't dispatch.
  6681. var doc = getEventTargetDocument(nativeEventTarget);
  6682. if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement(doc)) {
  6683. return;
  6684. } // Only fire when selection has actually changed.
  6685. var currentSelection = getSelection$1(activeElement$1);
  6686. if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
  6687. lastSelection = currentSelection;
  6688. var listeners = accumulateTwoPhaseListeners(activeElementInst$1, 'onSelect');
  6689. if (listeners.length > 0) {
  6690. var event = new SyntheticEvent('onSelect', 'select', null, nativeEvent, nativeEventTarget);
  6691. dispatchQueue.push({
  6692. event: event,
  6693. listeners: listeners
  6694. });
  6695. event.target = activeElement$1;
  6696. }
  6697. }
  6698. }
  6699. /**
  6700. * This plugin creates an `onSelect` event that normalizes select events
  6701. * across form elements.
  6702. *
  6703. * Supported elements are:
  6704. * - input (see `isTextInputElement`)
  6705. * - textarea
  6706. * - contentEditable
  6707. *
  6708. * This differs from native browser implementations in the following ways:
  6709. * - Fires on contentEditable fields as well as inputs.
  6710. * - Fires for collapsed selection.
  6711. * - Fires after user input.
  6712. */
  6713. function extractEvents$3(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) {
  6714. var targetNode = targetInst ? getNodeFromInstance(targetInst) : window;
  6715. switch (domEventName) {
  6716. // Track the input node that has focus.
  6717. case 'focusin':
  6718. if (isTextInputElement(targetNode) || targetNode.contentEditable === 'true') {
  6719. activeElement$1 = targetNode;
  6720. activeElementInst$1 = targetInst;
  6721. lastSelection = null;
  6722. }
  6723. break;
  6724. case 'focusout':
  6725. activeElement$1 = null;
  6726. activeElementInst$1 = null;
  6727. lastSelection = null;
  6728. break;
  6729. // Don't fire the event while the user is dragging. This matches the
  6730. // semantics of the native select event.
  6731. case 'mousedown':
  6732. mouseDown = true;
  6733. break;
  6734. case 'contextmenu':
  6735. case 'mouseup':
  6736. case 'dragend':
  6737. mouseDown = false;
  6738. constructSelectEvent(dispatchQueue, nativeEvent, nativeEventTarget);
  6739. break;
  6740. // Chrome and IE fire non-standard event when selection is changed (and
  6741. // sometimes when it hasn't). IE's event fires out of order with respect
  6742. // to key and input events on deletion, so we discard it.
  6743. //
  6744. // Firefox doesn't support selectionchange, so check selection status
  6745. // after each key entry. The selection changes after keydown and before
  6746. // keyup, but we check on keydown as well in the case of holding down a
  6747. // key, when multiple keydown events are fired but only one keyup is.
  6748. // This is also our approach for IE handling, for the reason above.
  6749. case 'selectionchange':
  6750. if (skipSelectionChangeEvent) {
  6751. break;
  6752. }
  6753. // falls through
  6754. case 'keydown':
  6755. case 'keyup':
  6756. constructSelectEvent(dispatchQueue, nativeEvent, nativeEventTarget);
  6757. }
  6758. }
  6759. function extractEvents$4(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) {
  6760. var reactName = topLevelEventsToReactNames.get(domEventName);
  6761. if (reactName === undefined) {
  6762. return;
  6763. }
  6764. var SyntheticEventCtor = SyntheticEvent;
  6765. var reactEventType = domEventName;
  6766. switch (domEventName) {
  6767. case 'keypress':
  6768. // Firefox creates a keypress event for function keys too. This removes
  6769. // the unwanted keypress events. Enter is however both printable and
  6770. // non-printable. One would expect Tab to be as well (but it isn't).
  6771. if (getEventCharCode(nativeEvent) === 0) {
  6772. return;
  6773. }
  6774. /* falls through */
  6775. case 'keydown':
  6776. case 'keyup':
  6777. SyntheticEventCtor = SyntheticKeyboardEvent;
  6778. break;
  6779. case 'focusin':
  6780. reactEventType = 'focus';
  6781. SyntheticEventCtor = SyntheticFocusEvent;
  6782. break;
  6783. case 'focusout':
  6784. reactEventType = 'blur';
  6785. SyntheticEventCtor = SyntheticFocusEvent;
  6786. break;
  6787. case 'beforeblur':
  6788. case 'afterblur':
  6789. SyntheticEventCtor = SyntheticFocusEvent;
  6790. break;
  6791. case 'click':
  6792. // Firefox creates a click event on right mouse clicks. This removes the
  6793. // unwanted click events.
  6794. if (nativeEvent.button === 2) {
  6795. return;
  6796. }
  6797. /* falls through */
  6798. case 'auxclick':
  6799. case 'dblclick':
  6800. case 'mousedown':
  6801. case 'mousemove':
  6802. case 'mouseup': // TODO: Disabled elements should not respond to mouse events
  6803. /* falls through */
  6804. case 'mouseout':
  6805. case 'mouseover':
  6806. case 'contextmenu':
  6807. SyntheticEventCtor = SyntheticMouseEvent;
  6808. break;
  6809. case 'drag':
  6810. case 'dragend':
  6811. case 'dragenter':
  6812. case 'dragexit':
  6813. case 'dragleave':
  6814. case 'dragover':
  6815. case 'dragstart':
  6816. case 'drop':
  6817. SyntheticEventCtor = SyntheticDragEvent;
  6818. break;
  6819. case 'touchcancel':
  6820. case 'touchend':
  6821. case 'touchmove':
  6822. case 'touchstart':
  6823. SyntheticEventCtor = SyntheticTouchEvent;
  6824. break;
  6825. case ANIMATION_END:
  6826. case ANIMATION_ITERATION:
  6827. case ANIMATION_START:
  6828. SyntheticEventCtor = SyntheticAnimationEvent;
  6829. break;
  6830. case TRANSITION_END:
  6831. SyntheticEventCtor = SyntheticTransitionEvent;
  6832. break;
  6833. case 'scroll':
  6834. SyntheticEventCtor = SyntheticUIEvent;
  6835. break;
  6836. case 'wheel':
  6837. SyntheticEventCtor = SyntheticWheelEvent;
  6838. break;
  6839. case 'copy':
  6840. case 'cut':
  6841. case 'paste':
  6842. SyntheticEventCtor = SyntheticClipboardEvent;
  6843. break;
  6844. case 'gotpointercapture':
  6845. case 'lostpointercapture':
  6846. case 'pointercancel':
  6847. case 'pointerdown':
  6848. case 'pointermove':
  6849. case 'pointerout':
  6850. case 'pointerover':
  6851. case 'pointerup':
  6852. SyntheticEventCtor = SyntheticPointerEvent;
  6853. break;
  6854. }
  6855. var inCapturePhase = (eventSystemFlags & IS_CAPTURE_PHASE) !== 0;
  6856. {
  6857. // Some events don't bubble in the browser.
  6858. // In the past, React has always bubbled them, but this can be surprising.
  6859. // We're going to try aligning closer to the browser behavior by not bubbling
  6860. // them in React either. We'll start by not bubbling onScroll, and then expand.
  6861. var accumulateTargetOnly = !inCapturePhase && // TODO: ideally, we'd eventually add all events from
  6862. // nonDelegatedEvents list in DOMPluginEventSystem.
  6863. // Then we can remove this special list.
  6864. // This is a breaking change that can wait until React 18.
  6865. domEventName === 'scroll';
  6866. var _listeners = accumulateSinglePhaseListeners(targetInst, reactName, nativeEvent.type, inCapturePhase, accumulateTargetOnly);
  6867. if (_listeners.length > 0) {
  6868. // Intentionally create event lazily.
  6869. var _event = new SyntheticEventCtor(reactName, reactEventType, null, nativeEvent, nativeEventTarget);
  6870. dispatchQueue.push({
  6871. event: _event,
  6872. listeners: _listeners
  6873. });
  6874. }
  6875. }
  6876. }
  6877. // TODO: remove top-level side effect.
  6878. registerSimpleEvents();
  6879. registerEvents$2();
  6880. registerEvents$1();
  6881. registerEvents$3();
  6882. registerEvents();
  6883. function extractEvents$5(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) {
  6884. // TODO: we should remove the concept of a "SimpleEventPlugin".
  6885. // This is the basic functionality of the event system. All
  6886. // the other plugins are essentially polyfills. So the plugin
  6887. // should probably be inlined somewhere and have its logic
  6888. // be core the to event system. This would potentially allow
  6889. // us to ship builds of React without the polyfilled plugins below.
  6890. extractEvents$4(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags);
  6891. var shouldProcessPolyfillPlugins = (eventSystemFlags & SHOULD_NOT_PROCESS_POLYFILL_EVENT_PLUGINS) === 0; // We don't process these events unless we are in the
  6892. // event's native "bubble" phase, which means that we're
  6893. // not in the capture phase. That's because we emulate
  6894. // the capture phase here still. This is a trade-off,
  6895. // because in an ideal world we would not emulate and use
  6896. // the phases properly, like we do with the SimpleEvent
  6897. // plugin. However, the plugins below either expect
  6898. // emulation (EnterLeave) or use state localized to that
  6899. // plugin (BeforeInput, Change, Select). The state in
  6900. // these modules complicates things, as you'll essentially
  6901. // get the case where the capture phase event might change
  6902. // state, only for the following bubble event to come in
  6903. // later and not trigger anything as the state now
  6904. // invalidates the heuristics of the event plugin. We
  6905. // could alter all these plugins to work in such ways, but
  6906. // that might cause other unknown side-effects that we
  6907. // can't forsee right now.
  6908. if (shouldProcessPolyfillPlugins) {
  6909. extractEvents$2(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags);
  6910. extractEvents$1(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget);
  6911. extractEvents$3(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget);
  6912. extractEvents(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget);
  6913. }
  6914. } // List of events that need to be individually attached to media elements.
  6915. var mediaEventTypes = ['abort', 'canplay', 'canplaythrough', 'durationchange', 'emptied', 'encrypted', 'ended', 'error', 'loadeddata', 'loadedmetadata', 'loadstart', 'pause', 'play', 'playing', 'progress', 'ratechange', 'seeked', 'seeking', 'stalled', 'suspend', 'timeupdate', 'volumechange', 'waiting']; // We should not delegate these events to the container, but rather
  6916. // set them on the actual target element itself. This is primarily
  6917. // because these events do not consistently bubble in the DOM.
  6918. var nonDelegatedEvents = new Set(['cancel', 'close', 'invalid', 'load', 'scroll', 'toggle'].concat(mediaEventTypes));
  6919. function executeDispatch(event, listener, currentTarget) {
  6920. var type = event.type || 'unknown-event';
  6921. event.currentTarget = currentTarget;
  6922. invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event);
  6923. event.currentTarget = null;
  6924. }
  6925. function processDispatchQueueItemsInOrder(event, dispatchListeners, inCapturePhase) {
  6926. var previousInstance;
  6927. if (inCapturePhase) {
  6928. for (var i = dispatchListeners.length - 1; i >= 0; i--) {
  6929. var _dispatchListeners$i = dispatchListeners[i],
  6930. instance = _dispatchListeners$i.instance,
  6931. currentTarget = _dispatchListeners$i.currentTarget,
  6932. listener = _dispatchListeners$i.listener;
  6933. if (instance !== previousInstance && event.isPropagationStopped()) {
  6934. return;
  6935. }
  6936. executeDispatch(event, listener, currentTarget);
  6937. previousInstance = instance;
  6938. }
  6939. } else {
  6940. for (var _i = 0; _i < dispatchListeners.length; _i++) {
  6941. var _dispatchListeners$_i = dispatchListeners[_i],
  6942. _instance = _dispatchListeners$_i.instance,
  6943. _currentTarget = _dispatchListeners$_i.currentTarget,
  6944. _listener = _dispatchListeners$_i.listener;
  6945. if (_instance !== previousInstance && event.isPropagationStopped()) {
  6946. return;
  6947. }
  6948. executeDispatch(event, _listener, _currentTarget);
  6949. previousInstance = _instance;
  6950. }
  6951. }
  6952. }
  6953. function processDispatchQueue(dispatchQueue, eventSystemFlags) {
  6954. var inCapturePhase = (eventSystemFlags & IS_CAPTURE_PHASE) !== 0;
  6955. for (var i = 0; i < dispatchQueue.length; i++) {
  6956. var _dispatchQueue$i = dispatchQueue[i],
  6957. event = _dispatchQueue$i.event,
  6958. listeners = _dispatchQueue$i.listeners;
  6959. processDispatchQueueItemsInOrder(event, listeners, inCapturePhase); // event system doesn't use pooling.
  6960. } // This would be a good time to rethrow if any of the event handlers threw.
  6961. rethrowCaughtError();
  6962. }
  6963. function dispatchEventsForPlugins(domEventName, eventSystemFlags, nativeEvent, targetInst, targetContainer) {
  6964. var nativeEventTarget = getEventTarget(nativeEvent);
  6965. var dispatchQueue = [];
  6966. extractEvents$5(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags);
  6967. processDispatchQueue(dispatchQueue, eventSystemFlags);
  6968. }
  6969. function listenToNonDelegatedEvent(domEventName, targetElement) {
  6970. var isCapturePhaseListener = false;
  6971. var listenerSet = getEventListenerSet(targetElement);
  6972. var listenerSetKey = getListenerSetKey(domEventName, isCapturePhaseListener);
  6973. if (!listenerSet.has(listenerSetKey)) {
  6974. addTrappedEventListener(targetElement, domEventName, IS_NON_DELEGATED, isCapturePhaseListener);
  6975. listenerSet.add(listenerSetKey);
  6976. }
  6977. }
  6978. var listeningMarker = '_reactListening' + Math.random().toString(36).slice(2);
  6979. function listenToAllSupportedEvents(rootContainerElement) {
  6980. {
  6981. if (rootContainerElement[listeningMarker]) {
  6982. // Performance optimization: don't iterate through events
  6983. // for the same portal container or root node more than once.
  6984. // TODO: once we remove the flag, we may be able to also
  6985. // remove some of the bookkeeping maps used for laziness.
  6986. return;
  6987. }
  6988. rootContainerElement[listeningMarker] = true;
  6989. allNativeEvents.forEach(function (domEventName) {
  6990. if (!nonDelegatedEvents.has(domEventName)) {
  6991. listenToNativeEvent(domEventName, false, rootContainerElement, null);
  6992. }
  6993. listenToNativeEvent(domEventName, true, rootContainerElement, null);
  6994. });
  6995. }
  6996. }
  6997. function listenToNativeEvent(domEventName, isCapturePhaseListener, rootContainerElement, targetElement) {
  6998. var eventSystemFlags = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
  6999. var target = rootContainerElement; // selectionchange needs to be attached to the document
  7000. // otherwise it won't capture incoming events that are only
  7001. // triggered on the document directly.
  7002. if (domEventName === 'selectionchange' && rootContainerElement.nodeType !== DOCUMENT_NODE) {
  7003. target = rootContainerElement.ownerDocument;
  7004. } // If the event can be delegated (or is capture phase), we can
  7005. // register it to the root container. Otherwise, we should
  7006. // register the event to the target element and mark it as
  7007. // a non-delegated event.
  7008. if (targetElement !== null && !isCapturePhaseListener && nonDelegatedEvents.has(domEventName)) {
  7009. // For all non-delegated events, apart from scroll, we attach
  7010. // their event listeners to the respective elements that their
  7011. // events fire on. That means we can skip this step, as event
  7012. // listener has already been added previously. However, we
  7013. // special case the scroll event because the reality is that any
  7014. // element can scroll.
  7015. // TODO: ideally, we'd eventually apply the same logic to all
  7016. // events from the nonDelegatedEvents list. Then we can remove
  7017. // this special case and use the same logic for all events.
  7018. if (domEventName !== 'scroll') {
  7019. return;
  7020. }
  7021. eventSystemFlags |= IS_NON_DELEGATED;
  7022. target = targetElement;
  7023. }
  7024. var listenerSet = getEventListenerSet(target);
  7025. var listenerSetKey = getListenerSetKey(domEventName, isCapturePhaseListener); // If the listener entry is empty or we should upgrade, then
  7026. // we need to trap an event listener onto the target.
  7027. if (!listenerSet.has(listenerSetKey)) {
  7028. if (isCapturePhaseListener) {
  7029. eventSystemFlags |= IS_CAPTURE_PHASE;
  7030. }
  7031. addTrappedEventListener(target, domEventName, eventSystemFlags, isCapturePhaseListener);
  7032. listenerSet.add(listenerSetKey);
  7033. }
  7034. }
  7035. function addTrappedEventListener(targetContainer, domEventName, eventSystemFlags, isCapturePhaseListener, isDeferredListenerForLegacyFBSupport) {
  7036. var listener = createEventListenerWrapperWithPriority(targetContainer, domEventName, eventSystemFlags); // If passive option is not supported, then the event will be
  7037. // active and not passive.
  7038. var isPassiveListener = undefined;
  7039. if (passiveBrowserEventsSupported) {
  7040. // Browsers introduced an intervention, making these events
  7041. // passive by default on document. React doesn't bind them
  7042. // to document anymore, but changing this now would undo
  7043. // the performance wins from the change. So we emulate
  7044. // the existing behavior manually on the roots now.
  7045. // https://github.com/facebook/react/issues/19651
  7046. if (domEventName === 'touchstart' || domEventName === 'touchmove' || domEventName === 'wheel') {
  7047. isPassiveListener = true;
  7048. }
  7049. }
  7050. targetContainer = targetContainer;
  7051. var unsubscribeListener; // When legacyFBSupport is enabled, it's for when we
  7052. if (isCapturePhaseListener) {
  7053. if (isPassiveListener !== undefined) {
  7054. unsubscribeListener = addEventCaptureListenerWithPassiveFlag(targetContainer, domEventName, listener, isPassiveListener);
  7055. } else {
  7056. unsubscribeListener = addEventCaptureListener(targetContainer, domEventName, listener);
  7057. }
  7058. } else {
  7059. if (isPassiveListener !== undefined) {
  7060. unsubscribeListener = addEventBubbleListenerWithPassiveFlag(targetContainer, domEventName, listener, isPassiveListener);
  7061. } else {
  7062. unsubscribeListener = addEventBubbleListener(targetContainer, domEventName, listener);
  7063. }
  7064. }
  7065. }
  7066. function isMatchingRootContainer(grandContainer, targetContainer) {
  7067. return grandContainer === targetContainer || grandContainer.nodeType === COMMENT_NODE && grandContainer.parentNode === targetContainer;
  7068. }
  7069. function dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativeEvent, targetInst, targetContainer) {
  7070. var ancestorInst = targetInst;
  7071. if ((eventSystemFlags & IS_EVENT_HANDLE_NON_MANAGED_NODE) === 0 && (eventSystemFlags & IS_NON_DELEGATED) === 0) {
  7072. var targetContainerNode = targetContainer; // If we are using the legacy FB support flag, we
  7073. if (targetInst !== null) {
  7074. // The below logic attempts to work out if we need to change
  7075. // the target fiber to a different ancestor. We had similar logic
  7076. // in the legacy event system, except the big difference between
  7077. // systems is that the modern event system now has an event listener
  7078. // attached to each React Root and React Portal Root. Together,
  7079. // the DOM nodes representing these roots are the "rootContainer".
  7080. // To figure out which ancestor instance we should use, we traverse
  7081. // up the fiber tree from the target instance and attempt to find
  7082. // root boundaries that match that of our current "rootContainer".
  7083. // If we find that "rootContainer", we find the parent fiber
  7084. // sub-tree for that root and make that our ancestor instance.
  7085. var node = targetInst;
  7086. mainLoop: while (true) {
  7087. if (node === null) {
  7088. return;
  7089. }
  7090. var nodeTag = node.tag;
  7091. if (nodeTag === HostRoot || nodeTag === HostPortal) {
  7092. var container = node.stateNode.containerInfo;
  7093. if (isMatchingRootContainer(container, targetContainerNode)) {
  7094. break;
  7095. }
  7096. if (nodeTag === HostPortal) {
  7097. // The target is a portal, but it's not the rootContainer we're looking for.
  7098. // Normally portals handle their own events all the way down to the root.
  7099. // So we should be able to stop now. However, we don't know if this portal
  7100. // was part of *our* root.
  7101. var grandNode = node.return;
  7102. while (grandNode !== null) {
  7103. var grandTag = grandNode.tag;
  7104. if (grandTag === HostRoot || grandTag === HostPortal) {
  7105. var grandContainer = grandNode.stateNode.containerInfo;
  7106. if (isMatchingRootContainer(grandContainer, targetContainerNode)) {
  7107. // This is the rootContainer we're looking for and we found it as
  7108. // a parent of the Portal. That means we can ignore it because the
  7109. // Portal will bubble through to us.
  7110. return;
  7111. }
  7112. }
  7113. grandNode = grandNode.return;
  7114. }
  7115. } // Now we need to find it's corresponding host fiber in the other
  7116. // tree. To do this we can use getClosestInstanceFromNode, but we
  7117. // need to validate that the fiber is a host instance, otherwise
  7118. // we need to traverse up through the DOM till we find the correct
  7119. // node that is from the other tree.
  7120. while (container !== null) {
  7121. var parentNode = getClosestInstanceFromNode(container);
  7122. if (parentNode === null) {
  7123. return;
  7124. }
  7125. var parentTag = parentNode.tag;
  7126. if (parentTag === HostComponent || parentTag === HostText) {
  7127. node = ancestorInst = parentNode;
  7128. continue mainLoop;
  7129. }
  7130. container = container.parentNode;
  7131. }
  7132. }
  7133. node = node.return;
  7134. }
  7135. }
  7136. }
  7137. batchedEventUpdates(function () {
  7138. return dispatchEventsForPlugins(domEventName, eventSystemFlags, nativeEvent, ancestorInst);
  7139. });
  7140. }
  7141. function createDispatchListener(instance, listener, currentTarget) {
  7142. return {
  7143. instance: instance,
  7144. listener: listener,
  7145. currentTarget: currentTarget
  7146. };
  7147. }
  7148. function accumulateSinglePhaseListeners(targetFiber, reactName, nativeEventType, inCapturePhase, accumulateTargetOnly) {
  7149. var captureName = reactName !== null ? reactName + 'Capture' : null;
  7150. var reactEventName = inCapturePhase ? captureName : reactName;
  7151. var listeners = [];
  7152. var instance = targetFiber;
  7153. var lastHostComponent = null; // Accumulate all instances and listeners via the target -> root path.
  7154. while (instance !== null) {
  7155. var _instance2 = instance,
  7156. stateNode = _instance2.stateNode,
  7157. tag = _instance2.tag; // Handle listeners that are on HostComponents (i.e. <div>)
  7158. if (tag === HostComponent && stateNode !== null) {
  7159. lastHostComponent = stateNode; // createEventHandle listeners
  7160. if (reactEventName !== null) {
  7161. var listener = getListener(instance, reactEventName);
  7162. if (listener != null) {
  7163. listeners.push(createDispatchListener(instance, listener, lastHostComponent));
  7164. }
  7165. }
  7166. } // If we are only accumulating events for the target, then we don't
  7167. // continue to propagate through the React fiber tree to find other
  7168. // listeners.
  7169. if (accumulateTargetOnly) {
  7170. break;
  7171. }
  7172. instance = instance.return;
  7173. }
  7174. return listeners;
  7175. } // We should only use this function for:
  7176. // - BeforeInputEventPlugin
  7177. // - ChangeEventPlugin
  7178. // - SelectEventPlugin
  7179. // This is because we only process these plugins
  7180. // in the bubble phase, so we need to accumulate two
  7181. // phase event listeners (via emulation).
  7182. function accumulateTwoPhaseListeners(targetFiber, reactName) {
  7183. var captureName = reactName + 'Capture';
  7184. var listeners = [];
  7185. var instance = targetFiber; // Accumulate all instances and listeners via the target -> root path.
  7186. while (instance !== null) {
  7187. var _instance3 = instance,
  7188. stateNode = _instance3.stateNode,
  7189. tag = _instance3.tag; // Handle listeners that are on HostComponents (i.e. <div>)
  7190. if (tag === HostComponent && stateNode !== null) {
  7191. var currentTarget = stateNode;
  7192. var captureListener = getListener(instance, captureName);
  7193. if (captureListener != null) {
  7194. listeners.unshift(createDispatchListener(instance, captureListener, currentTarget));
  7195. }
  7196. var bubbleListener = getListener(instance, reactName);
  7197. if (bubbleListener != null) {
  7198. listeners.push(createDispatchListener(instance, bubbleListener, currentTarget));
  7199. }
  7200. }
  7201. instance = instance.return;
  7202. }
  7203. return listeners;
  7204. }
  7205. function getParent(inst) {
  7206. if (inst === null) {
  7207. return null;
  7208. }
  7209. do {
  7210. inst = inst.return; // TODO: If this is a HostRoot we might want to bail out.
  7211. // That is depending on if we want nested subtrees (layers) to bubble
  7212. // events to their parent. We could also go through parentNode on the
  7213. // host node but that wouldn't work for React Native and doesn't let us
  7214. // do the portal feature.
  7215. } while (inst && inst.tag !== HostComponent);
  7216. if (inst) {
  7217. return inst;
  7218. }
  7219. return null;
  7220. }
  7221. /**
  7222. * Return the lowest common ancestor of A and B, or null if they are in
  7223. * different trees.
  7224. */
  7225. function getLowestCommonAncestor(instA, instB) {
  7226. var nodeA = instA;
  7227. var nodeB = instB;
  7228. var depthA = 0;
  7229. for (var tempA = nodeA; tempA; tempA = getParent(tempA)) {
  7230. depthA++;
  7231. }
  7232. var depthB = 0;
  7233. for (var tempB = nodeB; tempB; tempB = getParent(tempB)) {
  7234. depthB++;
  7235. } // If A is deeper, crawl up.
  7236. while (depthA - depthB > 0) {
  7237. nodeA = getParent(nodeA);
  7238. depthA--;
  7239. } // If B is deeper, crawl up.
  7240. while (depthB - depthA > 0) {
  7241. nodeB = getParent(nodeB);
  7242. depthB--;
  7243. } // Walk in lockstep until we find a match.
  7244. var depth = depthA;
  7245. while (depth--) {
  7246. if (nodeA === nodeB || nodeB !== null && nodeA === nodeB.alternate) {
  7247. return nodeA;
  7248. }
  7249. nodeA = getParent(nodeA);
  7250. nodeB = getParent(nodeB);
  7251. }
  7252. return null;
  7253. }
  7254. function accumulateEnterLeaveListenersForEvent(dispatchQueue, event, target, common, inCapturePhase) {
  7255. var registrationName = event._reactName;
  7256. var listeners = [];
  7257. var instance = target;
  7258. while (instance !== null) {
  7259. if (instance === common) {
  7260. break;
  7261. }
  7262. var _instance4 = instance,
  7263. alternate = _instance4.alternate,
  7264. stateNode = _instance4.stateNode,
  7265. tag = _instance4.tag;
  7266. if (alternate !== null && alternate === common) {
  7267. break;
  7268. }
  7269. if (tag === HostComponent && stateNode !== null) {
  7270. var currentTarget = stateNode;
  7271. if (inCapturePhase) {
  7272. var captureListener = getListener(instance, registrationName);
  7273. if (captureListener != null) {
  7274. listeners.unshift(createDispatchListener(instance, captureListener, currentTarget));
  7275. }
  7276. } else if (!inCapturePhase) {
  7277. var bubbleListener = getListener(instance, registrationName);
  7278. if (bubbleListener != null) {
  7279. listeners.push(createDispatchListener(instance, bubbleListener, currentTarget));
  7280. }
  7281. }
  7282. }
  7283. instance = instance.return;
  7284. }
  7285. if (listeners.length !== 0) {
  7286. dispatchQueue.push({
  7287. event: event,
  7288. listeners: listeners
  7289. });
  7290. }
  7291. } // We should only use this function for:
  7292. // - EnterLeaveEventPlugin
  7293. // This is because we only process this plugin
  7294. // in the bubble phase, so we need to accumulate two
  7295. // phase event listeners.
  7296. function accumulateEnterLeaveTwoPhaseListeners(dispatchQueue, leaveEvent, enterEvent, from, to) {
  7297. var common = from && to ? getLowestCommonAncestor(from, to) : null;
  7298. if (from !== null) {
  7299. accumulateEnterLeaveListenersForEvent(dispatchQueue, leaveEvent, from, common, false);
  7300. }
  7301. if (to !== null && enterEvent !== null) {
  7302. accumulateEnterLeaveListenersForEvent(dispatchQueue, enterEvent, to, common, true);
  7303. }
  7304. }
  7305. function getListenerSetKey(domEventName, capture) {
  7306. return domEventName + "__" + (capture ? 'capture' : 'bubble');
  7307. }
  7308. var didWarnInvalidHydration = false;
  7309. var DANGEROUSLY_SET_INNER_HTML = 'dangerouslySetInnerHTML';
  7310. var SUPPRESS_CONTENT_EDITABLE_WARNING = 'suppressContentEditableWarning';
  7311. var SUPPRESS_HYDRATION_WARNING = 'suppressHydrationWarning';
  7312. var AUTOFOCUS = 'autoFocus';
  7313. var CHILDREN = 'children';
  7314. var STYLE = 'style';
  7315. var HTML$1 = '__html';
  7316. var HTML_NAMESPACE$1 = Namespaces.html;
  7317. var warnedUnknownTags;
  7318. var suppressHydrationWarning;
  7319. var validatePropertiesInDevelopment;
  7320. var warnForTextDifference;
  7321. var warnForPropDifference;
  7322. var warnForExtraAttributes;
  7323. var warnForInvalidEventListener;
  7324. var canDiffStyleForHydrationWarning;
  7325. var normalizeMarkupForTextOrAttribute;
  7326. var normalizeHTML;
  7327. {
  7328. warnedUnknownTags = {
  7329. // There are working polyfills for <dialog>. Let people use it.
  7330. dialog: true,
  7331. // Electron ships a custom <webview> tag to display external web content in
  7332. // an isolated frame and process.
  7333. // This tag is not present in non Electron environments such as JSDom which
  7334. // is often used for testing purposes.
  7335. // @see https://electronjs.org/docs/api/webview-tag
  7336. webview: true
  7337. };
  7338. validatePropertiesInDevelopment = function (type, props) {
  7339. validateProperties(type, props);
  7340. validateProperties$1(type, props);
  7341. validateProperties$2(type, props, {
  7342. registrationNameDependencies: registrationNameDependencies,
  7343. possibleRegistrationNames: possibleRegistrationNames
  7344. });
  7345. }; // IE 11 parses & normalizes the style attribute as opposed to other
  7346. // browsers. It adds spaces and sorts the properties in some
  7347. // non-alphabetical order. Handling that would require sorting CSS
  7348. // properties in the client & server versions or applying
  7349. // `expectedStyle` to a temporary DOM node to read its `style` attribute
  7350. // normalized. Since it only affects IE, we're skipping style warnings
  7351. // in that browser completely in favor of doing all that work.
  7352. // See https://github.com/facebook/react/issues/11807
  7353. canDiffStyleForHydrationWarning = canUseDOM && !document.documentMode; // HTML parsing normalizes CR and CRLF to LF.
  7354. // It also can turn \u0000 into \uFFFD inside attributes.
  7355. // https://www.w3.org/TR/html5/single-page.html#preprocessing-the-input-stream
  7356. // If we have a mismatch, it might be caused by that.
  7357. // We will still patch up in this case but not fire the warning.
  7358. var NORMALIZE_NEWLINES_REGEX = /\r\n?/g;
  7359. var NORMALIZE_NULL_AND_REPLACEMENT_REGEX = /\u0000|\uFFFD/g;
  7360. normalizeMarkupForTextOrAttribute = function (markup) {
  7361. var markupString = typeof markup === 'string' ? markup : '' + markup;
  7362. return markupString.replace(NORMALIZE_NEWLINES_REGEX, '\n').replace(NORMALIZE_NULL_AND_REPLACEMENT_REGEX, '');
  7363. };
  7364. warnForTextDifference = function (serverText, clientText) {
  7365. if (didWarnInvalidHydration) {
  7366. return;
  7367. }
  7368. var normalizedClientText = normalizeMarkupForTextOrAttribute(clientText);
  7369. var normalizedServerText = normalizeMarkupForTextOrAttribute(serverText);
  7370. if (normalizedServerText === normalizedClientText) {
  7371. return;
  7372. }
  7373. didWarnInvalidHydration = true;
  7374. error('Text content did not match. Server: "%s" Client: "%s"', normalizedServerText, normalizedClientText);
  7375. };
  7376. warnForPropDifference = function (propName, serverValue, clientValue) {
  7377. if (didWarnInvalidHydration) {
  7378. return;
  7379. }
  7380. var normalizedClientValue = normalizeMarkupForTextOrAttribute(clientValue);
  7381. var normalizedServerValue = normalizeMarkupForTextOrAttribute(serverValue);
  7382. if (normalizedServerValue === normalizedClientValue) {
  7383. return;
  7384. }
  7385. didWarnInvalidHydration = true;
  7386. error('Prop `%s` did not match. Server: %s Client: %s', propName, JSON.stringify(normalizedServerValue), JSON.stringify(normalizedClientValue));
  7387. };
  7388. warnForExtraAttributes = function (attributeNames) {
  7389. if (didWarnInvalidHydration) {
  7390. return;
  7391. }
  7392. didWarnInvalidHydration = true;
  7393. var names = [];
  7394. attributeNames.forEach(function (name) {
  7395. names.push(name);
  7396. });
  7397. error('Extra attributes from the server: %s', names);
  7398. };
  7399. warnForInvalidEventListener = function (registrationName, listener) {
  7400. if (listener === false) {
  7401. error('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);
  7402. } else {
  7403. error('Expected `%s` listener to be a function, instead got a value of `%s` type.', registrationName, typeof listener);
  7404. }
  7405. }; // Parse the HTML and read it back to normalize the HTML string so that it
  7406. // can be used for comparison.
  7407. normalizeHTML = function (parent, html) {
  7408. // We could have created a separate document here to avoid
  7409. // re-initializing custom elements if they exist. But this breaks
  7410. // how <noscript> is being handled. So we use the same document.
  7411. // See the discussion in https://github.com/facebook/react/pull/11157.
  7412. var testElement = parent.namespaceURI === HTML_NAMESPACE$1 ? parent.ownerDocument.createElement(parent.tagName) : parent.ownerDocument.createElementNS(parent.namespaceURI, parent.tagName);
  7413. testElement.innerHTML = html;
  7414. return testElement.innerHTML;
  7415. };
  7416. }
  7417. function getOwnerDocumentFromRootContainer(rootContainerElement) {
  7418. return rootContainerElement.nodeType === DOCUMENT_NODE ? rootContainerElement : rootContainerElement.ownerDocument;
  7419. }
  7420. function noop() {}
  7421. function trapClickOnNonInteractiveElement(node) {
  7422. // Mobile Safari does not fire properly bubble click events on
  7423. // non-interactive elements, which means delegated click listeners do not
  7424. // fire. The workaround for this bug involves attaching an empty click
  7425. // listener on the target node.
  7426. // https://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
  7427. // Just set it using the onclick property so that we don't have to manage any
  7428. // bookkeeping for it. Not sure if we need to clear it when the listener is
  7429. // removed.
  7430. // TODO: Only do this for the relevant Safaris maybe?
  7431. node.onclick = noop;
  7432. }
  7433. function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) {
  7434. for (var propKey in nextProps) {
  7435. if (!nextProps.hasOwnProperty(propKey)) {
  7436. continue;
  7437. }
  7438. var nextProp = nextProps[propKey];
  7439. if (propKey === STYLE) {
  7440. {
  7441. if (nextProp) {
  7442. // Freeze the next style object so that we can assume it won't be
  7443. // mutated. We have already warned for this in the past.
  7444. Object.freeze(nextProp);
  7445. }
  7446. } // Relies on `updateStylesByID` not mutating `styleUpdates`.
  7447. setValueForStyles(domElement, nextProp);
  7448. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  7449. var nextHtml = nextProp ? nextProp[HTML$1] : undefined;
  7450. if (nextHtml != null) {
  7451. setInnerHTML(domElement, nextHtml);
  7452. }
  7453. } else if (propKey === CHILDREN) {
  7454. if (typeof nextProp === 'string') {
  7455. // Avoid setting initial textContent when the text is empty. In IE11 setting
  7456. // textContent on a <textarea> will cause the placeholder to not
  7457. // show within the <textarea> until it has been focused and blurred again.
  7458. // https://github.com/facebook/react/issues/6731#issuecomment-254874553
  7459. var canSetTextContent = tag !== 'textarea' || nextProp !== '';
  7460. if (canSetTextContent) {
  7461. setTextContent(domElement, nextProp);
  7462. }
  7463. } else if (typeof nextProp === 'number') {
  7464. setTextContent(domElement, '' + nextProp);
  7465. }
  7466. } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (propKey === AUTOFOCUS) ; else if (registrationNameDependencies.hasOwnProperty(propKey)) {
  7467. if (nextProp != null) {
  7468. if ( typeof nextProp !== 'function') {
  7469. warnForInvalidEventListener(propKey, nextProp);
  7470. }
  7471. if (propKey === 'onScroll') {
  7472. listenToNonDelegatedEvent('scroll', domElement);
  7473. }
  7474. }
  7475. } else if (nextProp != null) {
  7476. setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag);
  7477. }
  7478. }
  7479. }
  7480. function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) {
  7481. // TODO: Handle wasCustomComponentTag
  7482. for (var i = 0; i < updatePayload.length; i += 2) {
  7483. var propKey = updatePayload[i];
  7484. var propValue = updatePayload[i + 1];
  7485. if (propKey === STYLE) {
  7486. setValueForStyles(domElement, propValue);
  7487. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  7488. setInnerHTML(domElement, propValue);
  7489. } else if (propKey === CHILDREN) {
  7490. setTextContent(domElement, propValue);
  7491. } else {
  7492. setValueForProperty(domElement, propKey, propValue, isCustomComponentTag);
  7493. }
  7494. }
  7495. }
  7496. function createElement(type, props, rootContainerElement, parentNamespace) {
  7497. var isCustomComponentTag; // We create tags in the namespace of their parent container, except HTML
  7498. // tags get no namespace.
  7499. var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement);
  7500. var domElement;
  7501. var namespaceURI = parentNamespace;
  7502. if (namespaceURI === HTML_NAMESPACE$1) {
  7503. namespaceURI = getIntrinsicNamespace(type);
  7504. }
  7505. if (namespaceURI === HTML_NAMESPACE$1) {
  7506. {
  7507. isCustomComponentTag = isCustomComponent(type, props); // Should this check be gated by parent namespace? Not sure we want to
  7508. // allow <SVG> or <mATH>.
  7509. if (!isCustomComponentTag && type !== type.toLowerCase()) {
  7510. error('<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', type);
  7511. }
  7512. }
  7513. if (type === 'script') {
  7514. // Create the script via .innerHTML so its "parser-inserted" flag is
  7515. // set to true and it does not execute
  7516. var div = ownerDocument.createElement('div');
  7517. div.innerHTML = '<script><' + '/script>'; // eslint-disable-line
  7518. // This is guaranteed to yield a script element.
  7519. var firstChild = div.firstChild;
  7520. domElement = div.removeChild(firstChild);
  7521. } else if (typeof props.is === 'string') {
  7522. // $FlowIssue `createElement` should be updated for Web Components
  7523. domElement = ownerDocument.createElement(type, {
  7524. is: props.is
  7525. });
  7526. } else {
  7527. // Separate else branch instead of using `props.is || undefined` above because of a Firefox bug.
  7528. // See discussion in https://github.com/facebook/react/pull/6896
  7529. // and discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1276240
  7530. domElement = ownerDocument.createElement(type); // Normally attributes are assigned in `setInitialDOMProperties`, however the `multiple` and `size`
  7531. // attributes on `select`s needs to be added before `option`s are inserted.
  7532. // This prevents:
  7533. // - a bug where the `select` does not scroll to the correct option because singular
  7534. // `select` elements automatically pick the first item #13222
  7535. // - a bug where the `select` set the first item as selected despite the `size` attribute #14239
  7536. // See https://github.com/facebook/react/issues/13222
  7537. // and https://github.com/facebook/react/issues/14239
  7538. if (type === 'select') {
  7539. var node = domElement;
  7540. if (props.multiple) {
  7541. node.multiple = true;
  7542. } else if (props.size) {
  7543. // Setting a size greater than 1 causes a select to behave like `multiple=true`, where
  7544. // it is possible that no option is selected.
  7545. //
  7546. // This is only necessary when a select in "single selection mode".
  7547. node.size = props.size;
  7548. }
  7549. }
  7550. }
  7551. } else {
  7552. domElement = ownerDocument.createElementNS(namespaceURI, type);
  7553. }
  7554. {
  7555. if (namespaceURI === HTML_NAMESPACE$1) {
  7556. if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === '[object HTMLUnknownElement]' && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) {
  7557. warnedUnknownTags[type] = true;
  7558. error('The tag <%s> is unrecognized in this browser. ' + 'If you meant to render a React component, start its name with ' + 'an uppercase letter.', type);
  7559. }
  7560. }
  7561. }
  7562. return domElement;
  7563. }
  7564. function createTextNode(text, rootContainerElement) {
  7565. return getOwnerDocumentFromRootContainer(rootContainerElement).createTextNode(text);
  7566. }
  7567. function setInitialProperties(domElement, tag, rawProps, rootContainerElement) {
  7568. var isCustomComponentTag = isCustomComponent(tag, rawProps);
  7569. {
  7570. validatePropertiesInDevelopment(tag, rawProps);
  7571. } // TODO: Make sure that we check isMounted before firing any of these events.
  7572. var props;
  7573. switch (tag) {
  7574. case 'dialog':
  7575. listenToNonDelegatedEvent('cancel', domElement);
  7576. listenToNonDelegatedEvent('close', domElement);
  7577. props = rawProps;
  7578. break;
  7579. case 'iframe':
  7580. case 'object':
  7581. case 'embed':
  7582. // We listen to this event in case to ensure emulated bubble
  7583. // listeners still fire for the load event.
  7584. listenToNonDelegatedEvent('load', domElement);
  7585. props = rawProps;
  7586. break;
  7587. case 'video':
  7588. case 'audio':
  7589. // We listen to these events in case to ensure emulated bubble
  7590. // listeners still fire for all the media events.
  7591. for (var i = 0; i < mediaEventTypes.length; i++) {
  7592. listenToNonDelegatedEvent(mediaEventTypes[i], domElement);
  7593. }
  7594. props = rawProps;
  7595. break;
  7596. case 'source':
  7597. // We listen to this event in case to ensure emulated bubble
  7598. // listeners still fire for the error event.
  7599. listenToNonDelegatedEvent('error', domElement);
  7600. props = rawProps;
  7601. break;
  7602. case 'img':
  7603. case 'image':
  7604. case 'link':
  7605. // We listen to these events in case to ensure emulated bubble
  7606. // listeners still fire for error and load events.
  7607. listenToNonDelegatedEvent('error', domElement);
  7608. listenToNonDelegatedEvent('load', domElement);
  7609. props = rawProps;
  7610. break;
  7611. case 'details':
  7612. // We listen to this event in case to ensure emulated bubble
  7613. // listeners still fire for the toggle event.
  7614. listenToNonDelegatedEvent('toggle', domElement);
  7615. props = rawProps;
  7616. break;
  7617. case 'input':
  7618. initWrapperState(domElement, rawProps);
  7619. props = getHostProps(domElement, rawProps); // We listen to this event in case to ensure emulated bubble
  7620. // listeners still fire for the invalid event.
  7621. listenToNonDelegatedEvent('invalid', domElement);
  7622. break;
  7623. case 'option':
  7624. validateProps(domElement, rawProps);
  7625. props = getHostProps$1(domElement, rawProps);
  7626. break;
  7627. case 'select':
  7628. initWrapperState$1(domElement, rawProps);
  7629. props = getHostProps$2(domElement, rawProps); // We listen to this event in case to ensure emulated bubble
  7630. // listeners still fire for the invalid event.
  7631. listenToNonDelegatedEvent('invalid', domElement);
  7632. break;
  7633. case 'textarea':
  7634. initWrapperState$2(domElement, rawProps);
  7635. props = getHostProps$3(domElement, rawProps); // We listen to this event in case to ensure emulated bubble
  7636. // listeners still fire for the invalid event.
  7637. listenToNonDelegatedEvent('invalid', domElement);
  7638. break;
  7639. default:
  7640. props = rawProps;
  7641. }
  7642. assertValidProps(tag, props);
  7643. setInitialDOMProperties(tag, domElement, rootContainerElement, props, isCustomComponentTag);
  7644. switch (tag) {
  7645. case 'input':
  7646. // TODO: Make sure we check if this is still unmounted or do any clean
  7647. // up necessary since we never stop tracking anymore.
  7648. track(domElement);
  7649. postMountWrapper(domElement, rawProps, false);
  7650. break;
  7651. case 'textarea':
  7652. // TODO: Make sure we check if this is still unmounted or do any clean
  7653. // up necessary since we never stop tracking anymore.
  7654. track(domElement);
  7655. postMountWrapper$3(domElement);
  7656. break;
  7657. case 'option':
  7658. postMountWrapper$1(domElement, rawProps);
  7659. break;
  7660. case 'select':
  7661. postMountWrapper$2(domElement, rawProps);
  7662. break;
  7663. default:
  7664. if (typeof props.onClick === 'function') {
  7665. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  7666. trapClickOnNonInteractiveElement(domElement);
  7667. }
  7668. break;
  7669. }
  7670. } // Calculate the diff between the two objects.
  7671. function diffProperties(domElement, tag, lastRawProps, nextRawProps, rootContainerElement) {
  7672. {
  7673. validatePropertiesInDevelopment(tag, nextRawProps);
  7674. }
  7675. var updatePayload = null;
  7676. var lastProps;
  7677. var nextProps;
  7678. switch (tag) {
  7679. case 'input':
  7680. lastProps = getHostProps(domElement, lastRawProps);
  7681. nextProps = getHostProps(domElement, nextRawProps);
  7682. updatePayload = [];
  7683. break;
  7684. case 'option':
  7685. lastProps = getHostProps$1(domElement, lastRawProps);
  7686. nextProps = getHostProps$1(domElement, nextRawProps);
  7687. updatePayload = [];
  7688. break;
  7689. case 'select':
  7690. lastProps = getHostProps$2(domElement, lastRawProps);
  7691. nextProps = getHostProps$2(domElement, nextRawProps);
  7692. updatePayload = [];
  7693. break;
  7694. case 'textarea':
  7695. lastProps = getHostProps$3(domElement, lastRawProps);
  7696. nextProps = getHostProps$3(domElement, nextRawProps);
  7697. updatePayload = [];
  7698. break;
  7699. default:
  7700. lastProps = lastRawProps;
  7701. nextProps = nextRawProps;
  7702. if (typeof lastProps.onClick !== 'function' && typeof nextProps.onClick === 'function') {
  7703. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  7704. trapClickOnNonInteractiveElement(domElement);
  7705. }
  7706. break;
  7707. }
  7708. assertValidProps(tag, nextProps);
  7709. var propKey;
  7710. var styleName;
  7711. var styleUpdates = null;
  7712. for (propKey in lastProps) {
  7713. if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) {
  7714. continue;
  7715. }
  7716. if (propKey === STYLE) {
  7717. var lastStyle = lastProps[propKey];
  7718. for (styleName in lastStyle) {
  7719. if (lastStyle.hasOwnProperty(styleName)) {
  7720. if (!styleUpdates) {
  7721. styleUpdates = {};
  7722. }
  7723. styleUpdates[styleName] = '';
  7724. }
  7725. }
  7726. } else if (propKey === DANGEROUSLY_SET_INNER_HTML || propKey === CHILDREN) ; else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (propKey === AUTOFOCUS) ; else if (registrationNameDependencies.hasOwnProperty(propKey)) {
  7727. // This is a special case. If any listener updates we need to ensure
  7728. // that the "current" fiber pointer gets updated so we need a commit
  7729. // to update this element.
  7730. if (!updatePayload) {
  7731. updatePayload = [];
  7732. }
  7733. } else {
  7734. // For all other deleted properties we add it to the queue. We use
  7735. // the allowed property list in the commit phase instead.
  7736. (updatePayload = updatePayload || []).push(propKey, null);
  7737. }
  7738. }
  7739. for (propKey in nextProps) {
  7740. var nextProp = nextProps[propKey];
  7741. var lastProp = lastProps != null ? lastProps[propKey] : undefined;
  7742. if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) {
  7743. continue;
  7744. }
  7745. if (propKey === STYLE) {
  7746. {
  7747. if (nextProp) {
  7748. // Freeze the next style object so that we can assume it won't be
  7749. // mutated. We have already warned for this in the past.
  7750. Object.freeze(nextProp);
  7751. }
  7752. }
  7753. if (lastProp) {
  7754. // Unset styles on `lastProp` but not on `nextProp`.
  7755. for (styleName in lastProp) {
  7756. if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) {
  7757. if (!styleUpdates) {
  7758. styleUpdates = {};
  7759. }
  7760. styleUpdates[styleName] = '';
  7761. }
  7762. } // Update styles that changed since `lastProp`.
  7763. for (styleName in nextProp) {
  7764. if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) {
  7765. if (!styleUpdates) {
  7766. styleUpdates = {};
  7767. }
  7768. styleUpdates[styleName] = nextProp[styleName];
  7769. }
  7770. }
  7771. } else {
  7772. // Relies on `updateStylesByID` not mutating `styleUpdates`.
  7773. if (!styleUpdates) {
  7774. if (!updatePayload) {
  7775. updatePayload = [];
  7776. }
  7777. updatePayload.push(propKey, styleUpdates);
  7778. }
  7779. styleUpdates = nextProp;
  7780. }
  7781. } else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  7782. var nextHtml = nextProp ? nextProp[HTML$1] : undefined;
  7783. var lastHtml = lastProp ? lastProp[HTML$1] : undefined;
  7784. if (nextHtml != null) {
  7785. if (lastHtml !== nextHtml) {
  7786. (updatePayload = updatePayload || []).push(propKey, nextHtml);
  7787. }
  7788. }
  7789. } else if (propKey === CHILDREN) {
  7790. if (typeof nextProp === 'string' || typeof nextProp === 'number') {
  7791. (updatePayload = updatePayload || []).push(propKey, '' + nextProp);
  7792. }
  7793. } else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING) ; else if (registrationNameDependencies.hasOwnProperty(propKey)) {
  7794. if (nextProp != null) {
  7795. // We eagerly listen to this even though we haven't committed yet.
  7796. if ( typeof nextProp !== 'function') {
  7797. warnForInvalidEventListener(propKey, nextProp);
  7798. }
  7799. if (propKey === 'onScroll') {
  7800. listenToNonDelegatedEvent('scroll', domElement);
  7801. }
  7802. }
  7803. if (!updatePayload && lastProp !== nextProp) {
  7804. // This is a special case. If any listener updates we need to ensure
  7805. // that the "current" props pointer gets updated so we need a commit
  7806. // to update this element.
  7807. updatePayload = [];
  7808. }
  7809. } else if (typeof nextProp === 'object' && nextProp !== null && nextProp.$$typeof === REACT_OPAQUE_ID_TYPE) {
  7810. // If we encounter useOpaqueReference's opaque object, this means we are hydrating.
  7811. // In this case, call the opaque object's toString function which generates a new client
  7812. // ID so client and server IDs match and throws to rerender.
  7813. nextProp.toString();
  7814. } else {
  7815. // For any other property we always add it to the queue and then we
  7816. // filter it out using the allowed property list during the commit.
  7817. (updatePayload = updatePayload || []).push(propKey, nextProp);
  7818. }
  7819. }
  7820. if (styleUpdates) {
  7821. {
  7822. validateShorthandPropertyCollisionInDev(styleUpdates, nextProps[STYLE]);
  7823. }
  7824. (updatePayload = updatePayload || []).push(STYLE, styleUpdates);
  7825. }
  7826. return updatePayload;
  7827. } // Apply the diff.
  7828. function updateProperties(domElement, updatePayload, tag, lastRawProps, nextRawProps) {
  7829. // Update checked *before* name.
  7830. // In the middle of an update, it is possible to have multiple checked.
  7831. // When a checked radio tries to change name, browser makes another radio's checked false.
  7832. if (tag === 'input' && nextRawProps.type === 'radio' && nextRawProps.name != null) {
  7833. updateChecked(domElement, nextRawProps);
  7834. }
  7835. var wasCustomComponentTag = isCustomComponent(tag, lastRawProps);
  7836. var isCustomComponentTag = isCustomComponent(tag, nextRawProps); // Apply the diff.
  7837. updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag); // TODO: Ensure that an update gets scheduled if any of the special props
  7838. // changed.
  7839. switch (tag) {
  7840. case 'input':
  7841. // Update the wrapper around inputs *after* updating props. This has to
  7842. // happen after `updateDOMProperties`. Otherwise HTML5 input validations
  7843. // raise warnings and prevent the new value from being assigned.
  7844. updateWrapper(domElement, nextRawProps);
  7845. break;
  7846. case 'textarea':
  7847. updateWrapper$1(domElement, nextRawProps);
  7848. break;
  7849. case 'select':
  7850. // <select> value update needs to occur after <option> children
  7851. // reconciliation
  7852. postUpdateWrapper(domElement, nextRawProps);
  7853. break;
  7854. }
  7855. }
  7856. function getPossibleStandardName(propName) {
  7857. {
  7858. var lowerCasedName = propName.toLowerCase();
  7859. if (!possibleStandardNames.hasOwnProperty(lowerCasedName)) {
  7860. return null;
  7861. }
  7862. return possibleStandardNames[lowerCasedName] || null;
  7863. }
  7864. }
  7865. function diffHydratedProperties(domElement, tag, rawProps, parentNamespace, rootContainerElement) {
  7866. var isCustomComponentTag;
  7867. var extraAttributeNames;
  7868. {
  7869. suppressHydrationWarning = rawProps[SUPPRESS_HYDRATION_WARNING] === true;
  7870. isCustomComponentTag = isCustomComponent(tag, rawProps);
  7871. validatePropertiesInDevelopment(tag, rawProps);
  7872. } // TODO: Make sure that we check isMounted before firing any of these events.
  7873. switch (tag) {
  7874. case 'dialog':
  7875. listenToNonDelegatedEvent('cancel', domElement);
  7876. listenToNonDelegatedEvent('close', domElement);
  7877. break;
  7878. case 'iframe':
  7879. case 'object':
  7880. case 'embed':
  7881. // We listen to this event in case to ensure emulated bubble
  7882. // listeners still fire for the load event.
  7883. listenToNonDelegatedEvent('load', domElement);
  7884. break;
  7885. case 'video':
  7886. case 'audio':
  7887. // We listen to these events in case to ensure emulated bubble
  7888. // listeners still fire for all the media events.
  7889. for (var i = 0; i < mediaEventTypes.length; i++) {
  7890. listenToNonDelegatedEvent(mediaEventTypes[i], domElement);
  7891. }
  7892. break;
  7893. case 'source':
  7894. // We listen to this event in case to ensure emulated bubble
  7895. // listeners still fire for the error event.
  7896. listenToNonDelegatedEvent('error', domElement);
  7897. break;
  7898. case 'img':
  7899. case 'image':
  7900. case 'link':
  7901. // We listen to these events in case to ensure emulated bubble
  7902. // listeners still fire for error and load events.
  7903. listenToNonDelegatedEvent('error', domElement);
  7904. listenToNonDelegatedEvent('load', domElement);
  7905. break;
  7906. case 'details':
  7907. // We listen to this event in case to ensure emulated bubble
  7908. // listeners still fire for the toggle event.
  7909. listenToNonDelegatedEvent('toggle', domElement);
  7910. break;
  7911. case 'input':
  7912. initWrapperState(domElement, rawProps); // We listen to this event in case to ensure emulated bubble
  7913. // listeners still fire for the invalid event.
  7914. listenToNonDelegatedEvent('invalid', domElement);
  7915. break;
  7916. case 'option':
  7917. validateProps(domElement, rawProps);
  7918. break;
  7919. case 'select':
  7920. initWrapperState$1(domElement, rawProps); // We listen to this event in case to ensure emulated bubble
  7921. // listeners still fire for the invalid event.
  7922. listenToNonDelegatedEvent('invalid', domElement);
  7923. break;
  7924. case 'textarea':
  7925. initWrapperState$2(domElement, rawProps); // We listen to this event in case to ensure emulated bubble
  7926. // listeners still fire for the invalid event.
  7927. listenToNonDelegatedEvent('invalid', domElement);
  7928. break;
  7929. }
  7930. assertValidProps(tag, rawProps);
  7931. {
  7932. extraAttributeNames = new Set();
  7933. var attributes = domElement.attributes;
  7934. for (var _i = 0; _i < attributes.length; _i++) {
  7935. var name = attributes[_i].name.toLowerCase();
  7936. switch (name) {
  7937. // Built-in SSR attribute is allowed
  7938. case 'data-reactroot':
  7939. break;
  7940. // Controlled attributes are not validated
  7941. // TODO: Only ignore them on controlled tags.
  7942. case 'value':
  7943. break;
  7944. case 'checked':
  7945. break;
  7946. case 'selected':
  7947. break;
  7948. default:
  7949. // Intentionally use the original name.
  7950. // See discussion in https://github.com/facebook/react/pull/10676.
  7951. extraAttributeNames.add(attributes[_i].name);
  7952. }
  7953. }
  7954. }
  7955. var updatePayload = null;
  7956. for (var propKey in rawProps) {
  7957. if (!rawProps.hasOwnProperty(propKey)) {
  7958. continue;
  7959. }
  7960. var nextProp = rawProps[propKey];
  7961. if (propKey === CHILDREN) {
  7962. // For text content children we compare against textContent. This
  7963. // might match additional HTML that is hidden when we read it using
  7964. // textContent. E.g. "foo" will match "f<span>oo</span>" but that still
  7965. // satisfies our requirement. Our requirement is not to produce perfect
  7966. // HTML and attributes. Ideally we should preserve structure but it's
  7967. // ok not to if the visible content is still enough to indicate what
  7968. // even listeners these nodes might be wired up to.
  7969. // TODO: Warn if there is more than a single textNode as a child.
  7970. // TODO: Should we use domElement.firstChild.nodeValue to compare?
  7971. if (typeof nextProp === 'string') {
  7972. if (domElement.textContent !== nextProp) {
  7973. if ( !suppressHydrationWarning) {
  7974. warnForTextDifference(domElement.textContent, nextProp);
  7975. }
  7976. updatePayload = [CHILDREN, nextProp];
  7977. }
  7978. } else if (typeof nextProp === 'number') {
  7979. if (domElement.textContent !== '' + nextProp) {
  7980. if ( !suppressHydrationWarning) {
  7981. warnForTextDifference(domElement.textContent, nextProp);
  7982. }
  7983. updatePayload = [CHILDREN, '' + nextProp];
  7984. }
  7985. }
  7986. } else if (registrationNameDependencies.hasOwnProperty(propKey)) {
  7987. if (nextProp != null) {
  7988. if ( typeof nextProp !== 'function') {
  7989. warnForInvalidEventListener(propKey, nextProp);
  7990. }
  7991. if (propKey === 'onScroll') {
  7992. listenToNonDelegatedEvent('scroll', domElement);
  7993. }
  7994. }
  7995. } else if ( // Convince Flow we've calculated it (it's DEV-only in this method.)
  7996. typeof isCustomComponentTag === 'boolean') {
  7997. // Validate that the properties correspond to their expected values.
  7998. var serverValue = void 0;
  7999. var propertyInfo = getPropertyInfo(propKey);
  8000. if (suppressHydrationWarning) ; else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING || // Controlled attributes are not validated
  8001. // TODO: Only ignore them on controlled tags.
  8002. propKey === 'value' || propKey === 'checked' || propKey === 'selected') ; else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
  8003. var serverHTML = domElement.innerHTML;
  8004. var nextHtml = nextProp ? nextProp[HTML$1] : undefined;
  8005. if (nextHtml != null) {
  8006. var expectedHTML = normalizeHTML(domElement, nextHtml);
  8007. if (expectedHTML !== serverHTML) {
  8008. warnForPropDifference(propKey, serverHTML, expectedHTML);
  8009. }
  8010. }
  8011. } else if (propKey === STYLE) {
  8012. // $FlowFixMe - Should be inferred as not undefined.
  8013. extraAttributeNames.delete(propKey);
  8014. if (canDiffStyleForHydrationWarning) {
  8015. var expectedStyle = createDangerousStringForStyles(nextProp);
  8016. serverValue = domElement.getAttribute('style');
  8017. if (expectedStyle !== serverValue) {
  8018. warnForPropDifference(propKey, serverValue, expectedStyle);
  8019. }
  8020. }
  8021. } else if (isCustomComponentTag) {
  8022. // $FlowFixMe - Should be inferred as not undefined.
  8023. extraAttributeNames.delete(propKey.toLowerCase());
  8024. serverValue = getValueForAttribute(domElement, propKey, nextProp);
  8025. if (nextProp !== serverValue) {
  8026. warnForPropDifference(propKey, serverValue, nextProp);
  8027. }
  8028. } else if (!shouldIgnoreAttribute(propKey, propertyInfo, isCustomComponentTag) && !shouldRemoveAttribute(propKey, nextProp, propertyInfo, isCustomComponentTag)) {
  8029. var isMismatchDueToBadCasing = false;
  8030. if (propertyInfo !== null) {
  8031. // $FlowFixMe - Should be inferred as not undefined.
  8032. extraAttributeNames.delete(propertyInfo.attributeName);
  8033. serverValue = getValueForProperty(domElement, propKey, nextProp, propertyInfo);
  8034. } else {
  8035. var ownNamespace = parentNamespace;
  8036. if (ownNamespace === HTML_NAMESPACE$1) {
  8037. ownNamespace = getIntrinsicNamespace(tag);
  8038. }
  8039. if (ownNamespace === HTML_NAMESPACE$1) {
  8040. // $FlowFixMe - Should be inferred as not undefined.
  8041. extraAttributeNames.delete(propKey.toLowerCase());
  8042. } else {
  8043. var standardName = getPossibleStandardName(propKey);
  8044. if (standardName !== null && standardName !== propKey) {
  8045. // If an SVG prop is supplied with bad casing, it will
  8046. // be successfully parsed from HTML, but will produce a mismatch
  8047. // (and would be incorrectly rendered on the client).
  8048. // However, we already warn about bad casing elsewhere.
  8049. // So we'll skip the misleading extra mismatch warning in this case.
  8050. isMismatchDueToBadCasing = true; // $FlowFixMe - Should be inferred as not undefined.
  8051. extraAttributeNames.delete(standardName);
  8052. } // $FlowFixMe - Should be inferred as not undefined.
  8053. extraAttributeNames.delete(propKey);
  8054. }
  8055. serverValue = getValueForAttribute(domElement, propKey, nextProp);
  8056. }
  8057. if (nextProp !== serverValue && !isMismatchDueToBadCasing) {
  8058. warnForPropDifference(propKey, serverValue, nextProp);
  8059. }
  8060. }
  8061. }
  8062. }
  8063. {
  8064. // $FlowFixMe - Should be inferred as not undefined.
  8065. if (extraAttributeNames.size > 0 && !suppressHydrationWarning) {
  8066. // $FlowFixMe - Should be inferred as not undefined.
  8067. warnForExtraAttributes(extraAttributeNames);
  8068. }
  8069. }
  8070. switch (tag) {
  8071. case 'input':
  8072. // TODO: Make sure we check if this is still unmounted or do any clean
  8073. // up necessary since we never stop tracking anymore.
  8074. track(domElement);
  8075. postMountWrapper(domElement, rawProps, true);
  8076. break;
  8077. case 'textarea':
  8078. // TODO: Make sure we check if this is still unmounted or do any clean
  8079. // up necessary since we never stop tracking anymore.
  8080. track(domElement);
  8081. postMountWrapper$3(domElement);
  8082. break;
  8083. case 'select':
  8084. case 'option':
  8085. // For input and textarea we current always set the value property at
  8086. // post mount to force it to diverge from attributes. However, for
  8087. // option and select we don't quite do the same thing and select
  8088. // is not resilient to the DOM state changing so we don't do that here.
  8089. // TODO: Consider not doing this for input and textarea.
  8090. break;
  8091. default:
  8092. if (typeof rawProps.onClick === 'function') {
  8093. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  8094. trapClickOnNonInteractiveElement(domElement);
  8095. }
  8096. break;
  8097. }
  8098. return updatePayload;
  8099. }
  8100. function diffHydratedText(textNode, text) {
  8101. var isDifferent = textNode.nodeValue !== text;
  8102. return isDifferent;
  8103. }
  8104. function warnForUnmatchedText(textNode, text) {
  8105. {
  8106. warnForTextDifference(textNode.nodeValue, text);
  8107. }
  8108. }
  8109. function warnForDeletedHydratableElement(parentNode, child) {
  8110. {
  8111. if (didWarnInvalidHydration) {
  8112. return;
  8113. }
  8114. didWarnInvalidHydration = true;
  8115. error('Did not expect server HTML to contain a <%s> in <%s>.', child.nodeName.toLowerCase(), parentNode.nodeName.toLowerCase());
  8116. }
  8117. }
  8118. function warnForDeletedHydratableText(parentNode, child) {
  8119. {
  8120. if (didWarnInvalidHydration) {
  8121. return;
  8122. }
  8123. didWarnInvalidHydration = true;
  8124. error('Did not expect server HTML to contain the text node "%s" in <%s>.', child.nodeValue, parentNode.nodeName.toLowerCase());
  8125. }
  8126. }
  8127. function warnForInsertedHydratedElement(parentNode, tag, props) {
  8128. {
  8129. if (didWarnInvalidHydration) {
  8130. return;
  8131. }
  8132. didWarnInvalidHydration = true;
  8133. error('Expected server HTML to contain a matching <%s> in <%s>.', tag, parentNode.nodeName.toLowerCase());
  8134. }
  8135. }
  8136. function warnForInsertedHydratedText(parentNode, text) {
  8137. {
  8138. if (text === '') {
  8139. // We expect to insert empty text nodes since they're not represented in
  8140. // the HTML.
  8141. // TODO: Remove this special case if we can just avoid inserting empty
  8142. // text nodes.
  8143. return;
  8144. }
  8145. if (didWarnInvalidHydration) {
  8146. return;
  8147. }
  8148. didWarnInvalidHydration = true;
  8149. error('Expected server HTML to contain a matching text node for "%s" in <%s>.', text, parentNode.nodeName.toLowerCase());
  8150. }
  8151. }
  8152. function restoreControlledState$3(domElement, tag, props) {
  8153. switch (tag) {
  8154. case 'input':
  8155. restoreControlledState(domElement, props);
  8156. return;
  8157. case 'textarea':
  8158. restoreControlledState$2(domElement, props);
  8159. return;
  8160. case 'select':
  8161. restoreControlledState$1(domElement, props);
  8162. return;
  8163. }
  8164. }
  8165. var validateDOMNesting = function () {};
  8166. var updatedAncestorInfo = function () {};
  8167. {
  8168. // This validation code was written based on the HTML5 parsing spec:
  8169. // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope
  8170. //
  8171. // Note: this does not catch all invalid nesting, nor does it try to (as it's
  8172. // not clear what practical benefit doing so provides); instead, we warn only
  8173. // for cases where the parser will give a parse tree differing from what React
  8174. // intended. For example, <b><div></div></b> is invalid but we don't warn
  8175. // because it still parses correctly; we do warn for other cases like nested
  8176. // <p> tags where the beginning of the second element implicitly closes the
  8177. // first, causing a confusing mess.
  8178. // https://html.spec.whatwg.org/multipage/syntax.html#special
  8179. var specialTags = ['address', 'applet', 'area', 'article', 'aside', 'base', 'basefont', 'bgsound', 'blockquote', 'body', 'br', 'button', 'caption', 'center', 'col', 'colgroup', 'dd', 'details', 'dir', 'div', 'dl', 'dt', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'iframe', 'img', 'input', 'isindex', 'li', 'link', 'listing', 'main', 'marquee', 'menu', 'menuitem', 'meta', 'nav', 'noembed', 'noframes', 'noscript', 'object', 'ol', 'p', 'param', 'plaintext', 'pre', 'script', 'section', 'select', 'source', 'style', 'summary', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'track', 'ul', 'wbr', 'xmp']; // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope
  8180. var inScopeTags = ['applet', 'caption', 'html', 'table', 'td', 'th', 'marquee', 'object', 'template', // https://html.spec.whatwg.org/multipage/syntax.html#html-integration-point
  8181. // TODO: Distinguish by namespace here -- for <title>, including it here
  8182. // errs on the side of fewer warnings
  8183. 'foreignObject', 'desc', 'title']; // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-button-scope
  8184. var buttonScopeTags = inScopeTags.concat(['button']); // https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags
  8185. var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt'];
  8186. var emptyAncestorInfo = {
  8187. current: null,
  8188. formTag: null,
  8189. aTagInScope: null,
  8190. buttonTagInScope: null,
  8191. nobrTagInScope: null,
  8192. pTagInButtonScope: null,
  8193. listItemTagAutoclosing: null,
  8194. dlItemTagAutoclosing: null
  8195. };
  8196. updatedAncestorInfo = function (oldInfo, tag) {
  8197. var ancestorInfo = _assign({}, oldInfo || emptyAncestorInfo);
  8198. var info = {
  8199. tag: tag
  8200. };
  8201. if (inScopeTags.indexOf(tag) !== -1) {
  8202. ancestorInfo.aTagInScope = null;
  8203. ancestorInfo.buttonTagInScope = null;
  8204. ancestorInfo.nobrTagInScope = null;
  8205. }
  8206. if (buttonScopeTags.indexOf(tag) !== -1) {
  8207. ancestorInfo.pTagInButtonScope = null;
  8208. } // See rules for 'li', 'dd', 'dt' start tags in
  8209. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
  8210. if (specialTags.indexOf(tag) !== -1 && tag !== 'address' && tag !== 'div' && tag !== 'p') {
  8211. ancestorInfo.listItemTagAutoclosing = null;
  8212. ancestorInfo.dlItemTagAutoclosing = null;
  8213. }
  8214. ancestorInfo.current = info;
  8215. if (tag === 'form') {
  8216. ancestorInfo.formTag = info;
  8217. }
  8218. if (tag === 'a') {
  8219. ancestorInfo.aTagInScope = info;
  8220. }
  8221. if (tag === 'button') {
  8222. ancestorInfo.buttonTagInScope = info;
  8223. }
  8224. if (tag === 'nobr') {
  8225. ancestorInfo.nobrTagInScope = info;
  8226. }
  8227. if (tag === 'p') {
  8228. ancestorInfo.pTagInButtonScope = info;
  8229. }
  8230. if (tag === 'li') {
  8231. ancestorInfo.listItemTagAutoclosing = info;
  8232. }
  8233. if (tag === 'dd' || tag === 'dt') {
  8234. ancestorInfo.dlItemTagAutoclosing = info;
  8235. }
  8236. return ancestorInfo;
  8237. };
  8238. /**
  8239. * Returns whether
  8240. */
  8241. var isTagValidWithParent = function (tag, parentTag) {
  8242. // First, let's check if we're in an unusual parsing mode...
  8243. switch (parentTag) {
  8244. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect
  8245. case 'select':
  8246. return tag === 'option' || tag === 'optgroup' || tag === '#text';
  8247. case 'optgroup':
  8248. return tag === 'option' || tag === '#text';
  8249. // Strictly speaking, seeing an <option> doesn't mean we're in a <select>
  8250. // but
  8251. case 'option':
  8252. return tag === '#text';
  8253. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd
  8254. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption
  8255. // No special behavior since these rules fall back to "in body" mode for
  8256. // all except special table nodes which cause bad parsing behavior anyway.
  8257. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr
  8258. case 'tr':
  8259. return tag === 'th' || tag === 'td' || tag === 'style' || tag === 'script' || tag === 'template';
  8260. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody
  8261. case 'tbody':
  8262. case 'thead':
  8263. case 'tfoot':
  8264. return tag === 'tr' || tag === 'style' || tag === 'script' || tag === 'template';
  8265. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup
  8266. case 'colgroup':
  8267. return tag === 'col' || tag === 'template';
  8268. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable
  8269. case 'table':
  8270. return tag === 'caption' || tag === 'colgroup' || tag === 'tbody' || tag === 'tfoot' || tag === 'thead' || tag === 'style' || tag === 'script' || tag === 'template';
  8271. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead
  8272. case 'head':
  8273. return tag === 'base' || tag === 'basefont' || tag === 'bgsound' || tag === 'link' || tag === 'meta' || tag === 'title' || tag === 'noscript' || tag === 'noframes' || tag === 'style' || tag === 'script' || tag === 'template';
  8274. // https://html.spec.whatwg.org/multipage/semantics.html#the-html-element
  8275. case 'html':
  8276. return tag === 'head' || tag === 'body' || tag === 'frameset';
  8277. case 'frameset':
  8278. return tag === 'frame';
  8279. case '#document':
  8280. return tag === 'html';
  8281. } // Probably in the "in body" parsing mode, so we outlaw only tag combos
  8282. // where the parsing rules cause implicit opens or closes to be added.
  8283. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
  8284. switch (tag) {
  8285. case 'h1':
  8286. case 'h2':
  8287. case 'h3':
  8288. case 'h4':
  8289. case 'h5':
  8290. case 'h6':
  8291. return parentTag !== 'h1' && parentTag !== 'h2' && parentTag !== 'h3' && parentTag !== 'h4' && parentTag !== 'h5' && parentTag !== 'h6';
  8292. case 'rp':
  8293. case 'rt':
  8294. return impliedEndTags.indexOf(parentTag) === -1;
  8295. case 'body':
  8296. case 'caption':
  8297. case 'col':
  8298. case 'colgroup':
  8299. case 'frameset':
  8300. case 'frame':
  8301. case 'head':
  8302. case 'html':
  8303. case 'tbody':
  8304. case 'td':
  8305. case 'tfoot':
  8306. case 'th':
  8307. case 'thead':
  8308. case 'tr':
  8309. // These tags are only valid with a few parents that have special child
  8310. // parsing rules -- if we're down here, then none of those matched and
  8311. // so we allow it only if we don't know what the parent is, as all other
  8312. // cases are invalid.
  8313. return parentTag == null;
  8314. }
  8315. return true;
  8316. };
  8317. /**
  8318. * Returns whether
  8319. */
  8320. var findInvalidAncestorForTag = function (tag, ancestorInfo) {
  8321. switch (tag) {
  8322. case 'address':
  8323. case 'article':
  8324. case 'aside':
  8325. case 'blockquote':
  8326. case 'center':
  8327. case 'details':
  8328. case 'dialog':
  8329. case 'dir':
  8330. case 'div':
  8331. case 'dl':
  8332. case 'fieldset':
  8333. case 'figcaption':
  8334. case 'figure':
  8335. case 'footer':
  8336. case 'header':
  8337. case 'hgroup':
  8338. case 'main':
  8339. case 'menu':
  8340. case 'nav':
  8341. case 'ol':
  8342. case 'p':
  8343. case 'section':
  8344. case 'summary':
  8345. case 'ul':
  8346. case 'pre':
  8347. case 'listing':
  8348. case 'table':
  8349. case 'hr':
  8350. case 'xmp':
  8351. case 'h1':
  8352. case 'h2':
  8353. case 'h3':
  8354. case 'h4':
  8355. case 'h5':
  8356. case 'h6':
  8357. return ancestorInfo.pTagInButtonScope;
  8358. case 'form':
  8359. return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope;
  8360. case 'li':
  8361. return ancestorInfo.listItemTagAutoclosing;
  8362. case 'dd':
  8363. case 'dt':
  8364. return ancestorInfo.dlItemTagAutoclosing;
  8365. case 'button':
  8366. return ancestorInfo.buttonTagInScope;
  8367. case 'a':
  8368. // Spec says something about storing a list of markers, but it sounds
  8369. // equivalent to this check.
  8370. return ancestorInfo.aTagInScope;
  8371. case 'nobr':
  8372. return ancestorInfo.nobrTagInScope;
  8373. }
  8374. return null;
  8375. };
  8376. var didWarn$1 = {};
  8377. validateDOMNesting = function (childTag, childText, ancestorInfo) {
  8378. ancestorInfo = ancestorInfo || emptyAncestorInfo;
  8379. var parentInfo = ancestorInfo.current;
  8380. var parentTag = parentInfo && parentInfo.tag;
  8381. if (childText != null) {
  8382. if (childTag != null) {
  8383. error('validateDOMNesting: when childText is passed, childTag should be null');
  8384. }
  8385. childTag = '#text';
  8386. }
  8387. var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo;
  8388. var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo);
  8389. var invalidParentOrAncestor = invalidParent || invalidAncestor;
  8390. if (!invalidParentOrAncestor) {
  8391. return;
  8392. }
  8393. var ancestorTag = invalidParentOrAncestor.tag;
  8394. var warnKey = !!invalidParent + '|' + childTag + '|' + ancestorTag;
  8395. if (didWarn$1[warnKey]) {
  8396. return;
  8397. }
  8398. didWarn$1[warnKey] = true;
  8399. var tagDisplayName = childTag;
  8400. var whitespaceInfo = '';
  8401. if (childTag === '#text') {
  8402. if (/\S/.test(childText)) {
  8403. tagDisplayName = 'Text nodes';
  8404. } else {
  8405. tagDisplayName = 'Whitespace text nodes';
  8406. whitespaceInfo = " Make sure you don't have any extra whitespace between tags on " + 'each line of your source code.';
  8407. }
  8408. } else {
  8409. tagDisplayName = '<' + childTag + '>';
  8410. }
  8411. if (invalidParent) {
  8412. var info = '';
  8413. if (ancestorTag === 'table' && childTag === 'tr') {
  8414. info += ' Add a <tbody>, <thead> or <tfoot> to your code to match the DOM tree generated by ' + 'the browser.';
  8415. }
  8416. error('validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s', tagDisplayName, ancestorTag, whitespaceInfo, info);
  8417. } else {
  8418. error('validateDOMNesting(...): %s cannot appear as a descendant of ' + '<%s>.', tagDisplayName, ancestorTag);
  8419. }
  8420. };
  8421. }
  8422. var SUPPRESS_HYDRATION_WARNING$1;
  8423. {
  8424. SUPPRESS_HYDRATION_WARNING$1 = 'suppressHydrationWarning';
  8425. }
  8426. var SUSPENSE_START_DATA = '$';
  8427. var SUSPENSE_END_DATA = '/$';
  8428. var SUSPENSE_PENDING_START_DATA = '$?';
  8429. var SUSPENSE_FALLBACK_START_DATA = '$!';
  8430. var STYLE$1 = 'style';
  8431. var eventsEnabled = null;
  8432. var selectionInformation = null;
  8433. function shouldAutoFocusHostComponent(type, props) {
  8434. switch (type) {
  8435. case 'button':
  8436. case 'input':
  8437. case 'select':
  8438. case 'textarea':
  8439. return !!props.autoFocus;
  8440. }
  8441. return false;
  8442. }
  8443. function getRootHostContext(rootContainerInstance) {
  8444. var type;
  8445. var namespace;
  8446. var nodeType = rootContainerInstance.nodeType;
  8447. switch (nodeType) {
  8448. case DOCUMENT_NODE:
  8449. case DOCUMENT_FRAGMENT_NODE:
  8450. {
  8451. type = nodeType === DOCUMENT_NODE ? '#document' : '#fragment';
  8452. var root = rootContainerInstance.documentElement;
  8453. namespace = root ? root.namespaceURI : getChildNamespace(null, '');
  8454. break;
  8455. }
  8456. default:
  8457. {
  8458. var container = nodeType === COMMENT_NODE ? rootContainerInstance.parentNode : rootContainerInstance;
  8459. var ownNamespace = container.namespaceURI || null;
  8460. type = container.tagName;
  8461. namespace = getChildNamespace(ownNamespace, type);
  8462. break;
  8463. }
  8464. }
  8465. {
  8466. var validatedTag = type.toLowerCase();
  8467. var ancestorInfo = updatedAncestorInfo(null, validatedTag);
  8468. return {
  8469. namespace: namespace,
  8470. ancestorInfo: ancestorInfo
  8471. };
  8472. }
  8473. }
  8474. function getChildHostContext(parentHostContext, type, rootContainerInstance) {
  8475. {
  8476. var parentHostContextDev = parentHostContext;
  8477. var namespace = getChildNamespace(parentHostContextDev.namespace, type);
  8478. var ancestorInfo = updatedAncestorInfo(parentHostContextDev.ancestorInfo, type);
  8479. return {
  8480. namespace: namespace,
  8481. ancestorInfo: ancestorInfo
  8482. };
  8483. }
  8484. }
  8485. function getPublicInstance(instance) {
  8486. return instance;
  8487. }
  8488. function prepareForCommit(containerInfo) {
  8489. eventsEnabled = isEnabled();
  8490. selectionInformation = getSelectionInformation();
  8491. var activeInstance = null;
  8492. setEnabled(false);
  8493. return activeInstance;
  8494. }
  8495. function resetAfterCommit(containerInfo) {
  8496. restoreSelection(selectionInformation);
  8497. setEnabled(eventsEnabled);
  8498. eventsEnabled = null;
  8499. selectionInformation = null;
  8500. }
  8501. function createInstance(type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
  8502. var parentNamespace;
  8503. {
  8504. // TODO: take namespace into account when validating.
  8505. var hostContextDev = hostContext;
  8506. validateDOMNesting(type, null, hostContextDev.ancestorInfo);
  8507. if (typeof props.children === 'string' || typeof props.children === 'number') {
  8508. var string = '' + props.children;
  8509. var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type);
  8510. validateDOMNesting(null, string, ownAncestorInfo);
  8511. }
  8512. parentNamespace = hostContextDev.namespace;
  8513. }
  8514. var domElement = createElement(type, props, rootContainerInstance, parentNamespace);
  8515. precacheFiberNode(internalInstanceHandle, domElement);
  8516. updateFiberProps(domElement, props);
  8517. return domElement;
  8518. }
  8519. function appendInitialChild(parentInstance, child) {
  8520. parentInstance.appendChild(child);
  8521. }
  8522. function finalizeInitialChildren(domElement, type, props, rootContainerInstance, hostContext) {
  8523. setInitialProperties(domElement, type, props, rootContainerInstance);
  8524. return shouldAutoFocusHostComponent(type, props);
  8525. }
  8526. function prepareUpdate(domElement, type, oldProps, newProps, rootContainerInstance, hostContext) {
  8527. {
  8528. var hostContextDev = hostContext;
  8529. if (typeof newProps.children !== typeof oldProps.children && (typeof newProps.children === 'string' || typeof newProps.children === 'number')) {
  8530. var string = '' + newProps.children;
  8531. var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type);
  8532. validateDOMNesting(null, string, ownAncestorInfo);
  8533. }
  8534. }
  8535. return diffProperties(domElement, type, oldProps, newProps);
  8536. }
  8537. function shouldSetTextContent(type, props) {
  8538. 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;
  8539. }
  8540. function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) {
  8541. {
  8542. var hostContextDev = hostContext;
  8543. validateDOMNesting(null, text, hostContextDev.ancestorInfo);
  8544. }
  8545. var textNode = createTextNode(text, rootContainerInstance);
  8546. precacheFiberNode(internalInstanceHandle, textNode);
  8547. return textNode;
  8548. }
  8549. // if a component just imports ReactDOM (e.g. for findDOMNode).
  8550. // Some environments might not have setTimeout or clearTimeout.
  8551. var scheduleTimeout = typeof setTimeout === 'function' ? setTimeout : undefined;
  8552. var cancelTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined;
  8553. var noTimeout = -1; // -------------------
  8554. function commitMount(domElement, type, newProps, internalInstanceHandle) {
  8555. // Despite the naming that might imply otherwise, this method only
  8556. // fires if there is an `Update` effect scheduled during mounting.
  8557. // This happens if `finalizeInitialChildren` returns `true` (which it
  8558. // does to implement the `autoFocus` attribute on the client). But
  8559. // there are also other cases when this might happen (such as patching
  8560. // up text content during hydration mismatch). So we'll check this again.
  8561. if (shouldAutoFocusHostComponent(type, newProps)) {
  8562. domElement.focus();
  8563. }
  8564. }
  8565. function commitUpdate(domElement, updatePayload, type, oldProps, newProps, internalInstanceHandle) {
  8566. // Update the props handle so that we know which props are the ones with
  8567. // with current event handlers.
  8568. updateFiberProps(domElement, newProps); // Apply the diff to the DOM node.
  8569. updateProperties(domElement, updatePayload, type, oldProps, newProps);
  8570. }
  8571. function resetTextContent(domElement) {
  8572. setTextContent(domElement, '');
  8573. }
  8574. function commitTextUpdate(textInstance, oldText, newText) {
  8575. textInstance.nodeValue = newText;
  8576. }
  8577. function appendChild(parentInstance, child) {
  8578. parentInstance.appendChild(child);
  8579. }
  8580. function appendChildToContainer(container, child) {
  8581. var parentNode;
  8582. if (container.nodeType === COMMENT_NODE) {
  8583. parentNode = container.parentNode;
  8584. parentNode.insertBefore(child, container);
  8585. } else {
  8586. parentNode = container;
  8587. parentNode.appendChild(child);
  8588. } // This container might be used for a portal.
  8589. // If something inside a portal is clicked, that click should bubble
  8590. // through the React tree. However, on Mobile Safari the click would
  8591. // never bubble through the *DOM* tree unless an ancestor with onclick
  8592. // event exists. So we wouldn't see it and dispatch it.
  8593. // This is why we ensure that non React root containers have inline onclick
  8594. // defined.
  8595. // https://github.com/facebook/react/issues/11918
  8596. var reactRootContainer = container._reactRootContainer;
  8597. if ((reactRootContainer === null || reactRootContainer === undefined) && parentNode.onclick === null) {
  8598. // TODO: This cast may not be sound for SVG, MathML or custom elements.
  8599. trapClickOnNonInteractiveElement(parentNode);
  8600. }
  8601. }
  8602. function insertBefore(parentInstance, child, beforeChild) {
  8603. parentInstance.insertBefore(child, beforeChild);
  8604. }
  8605. function insertInContainerBefore(container, child, beforeChild) {
  8606. if (container.nodeType === COMMENT_NODE) {
  8607. container.parentNode.insertBefore(child, beforeChild);
  8608. } else {
  8609. container.insertBefore(child, beforeChild);
  8610. }
  8611. }
  8612. function removeChild(parentInstance, child) {
  8613. parentInstance.removeChild(child);
  8614. }
  8615. function removeChildFromContainer(container, child) {
  8616. if (container.nodeType === COMMENT_NODE) {
  8617. container.parentNode.removeChild(child);
  8618. } else {
  8619. container.removeChild(child);
  8620. }
  8621. }
  8622. function hideInstance(instance) {
  8623. // TODO: Does this work for all element types? What about MathML? Should we
  8624. // pass host context to this method?
  8625. instance = instance;
  8626. var style = instance.style;
  8627. if (typeof style.setProperty === 'function') {
  8628. style.setProperty('display', 'none', 'important');
  8629. } else {
  8630. style.display = 'none';
  8631. }
  8632. }
  8633. function hideTextInstance(textInstance) {
  8634. textInstance.nodeValue = '';
  8635. }
  8636. function unhideInstance(instance, props) {
  8637. instance = instance;
  8638. var styleProp = props[STYLE$1];
  8639. var display = styleProp !== undefined && styleProp !== null && styleProp.hasOwnProperty('display') ? styleProp.display : null;
  8640. instance.style.display = dangerousStyleValue('display', display);
  8641. }
  8642. function unhideTextInstance(textInstance, text) {
  8643. textInstance.nodeValue = text;
  8644. }
  8645. function clearContainer(container) {
  8646. if (container.nodeType === ELEMENT_NODE) {
  8647. container.textContent = '';
  8648. } else if (container.nodeType === DOCUMENT_NODE) {
  8649. var body = container.body;
  8650. if (body != null) {
  8651. body.textContent = '';
  8652. }
  8653. }
  8654. } // -------------------
  8655. function canHydrateInstance(instance, type, props) {
  8656. if (instance.nodeType !== ELEMENT_NODE || type.toLowerCase() !== instance.nodeName.toLowerCase()) {
  8657. return null;
  8658. } // This has now been refined to an element node.
  8659. return instance;
  8660. }
  8661. function canHydrateTextInstance(instance, text) {
  8662. if (text === '' || instance.nodeType !== TEXT_NODE) {
  8663. // Empty strings are not parsed by HTML so there won't be a correct match here.
  8664. return null;
  8665. } // This has now been refined to a text node.
  8666. return instance;
  8667. }
  8668. function isSuspenseInstancePending(instance) {
  8669. return instance.data === SUSPENSE_PENDING_START_DATA;
  8670. }
  8671. function isSuspenseInstanceFallback(instance) {
  8672. return instance.data === SUSPENSE_FALLBACK_START_DATA;
  8673. }
  8674. function getNextHydratable(node) {
  8675. // Skip non-hydratable nodes.
  8676. for (; node != null; node = node.nextSibling) {
  8677. var nodeType = node.nodeType;
  8678. if (nodeType === ELEMENT_NODE || nodeType === TEXT_NODE) {
  8679. break;
  8680. }
  8681. }
  8682. return node;
  8683. }
  8684. function getNextHydratableSibling(instance) {
  8685. return getNextHydratable(instance.nextSibling);
  8686. }
  8687. function getFirstHydratableChild(parentInstance) {
  8688. return getNextHydratable(parentInstance.firstChild);
  8689. }
  8690. function hydrateInstance(instance, type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
  8691. precacheFiberNode(internalInstanceHandle, instance); // TODO: Possibly defer this until the commit phase where all the events
  8692. // get attached.
  8693. updateFiberProps(instance, props);
  8694. var parentNamespace;
  8695. {
  8696. var hostContextDev = hostContext;
  8697. parentNamespace = hostContextDev.namespace;
  8698. }
  8699. return diffHydratedProperties(instance, type, props, parentNamespace);
  8700. }
  8701. function hydrateTextInstance(textInstance, text, internalInstanceHandle) {
  8702. precacheFiberNode(internalInstanceHandle, textInstance);
  8703. return diffHydratedText(textInstance, text);
  8704. }
  8705. function getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance) {
  8706. var node = suspenseInstance.nextSibling; // Skip past all nodes within this suspense boundary.
  8707. // There might be nested nodes so we need to keep track of how
  8708. // deep we are and only break out when we're back on top.
  8709. var depth = 0;
  8710. while (node) {
  8711. if (node.nodeType === COMMENT_NODE) {
  8712. var data = node.data;
  8713. if (data === SUSPENSE_END_DATA) {
  8714. if (depth === 0) {
  8715. return getNextHydratableSibling(node);
  8716. } else {
  8717. depth--;
  8718. }
  8719. } else if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) {
  8720. depth++;
  8721. }
  8722. }
  8723. node = node.nextSibling;
  8724. } // TODO: Warn, we didn't find the end comment boundary.
  8725. return null;
  8726. } // Returns the SuspenseInstance if this node is a direct child of a
  8727. // SuspenseInstance. I.e. if its previous sibling is a Comment with
  8728. // SUSPENSE_x_START_DATA. Otherwise, null.
  8729. function getParentSuspenseInstance(targetInstance) {
  8730. var node = targetInstance.previousSibling; // Skip past all nodes within this suspense boundary.
  8731. // There might be nested nodes so we need to keep track of how
  8732. // deep we are and only break out when we're back on top.
  8733. var depth = 0;
  8734. while (node) {
  8735. if (node.nodeType === COMMENT_NODE) {
  8736. var data = node.data;
  8737. if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) {
  8738. if (depth === 0) {
  8739. return node;
  8740. } else {
  8741. depth--;
  8742. }
  8743. } else if (data === SUSPENSE_END_DATA) {
  8744. depth++;
  8745. }
  8746. }
  8747. node = node.previousSibling;
  8748. }
  8749. return null;
  8750. }
  8751. function commitHydratedContainer(container) {
  8752. // Retry if any event replaying was blocked on this.
  8753. retryIfBlockedOn(container);
  8754. }
  8755. function commitHydratedSuspenseInstance(suspenseInstance) {
  8756. // Retry if any event replaying was blocked on this.
  8757. retryIfBlockedOn(suspenseInstance);
  8758. }
  8759. function didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, text) {
  8760. {
  8761. warnForUnmatchedText(textInstance, text);
  8762. }
  8763. }
  8764. function didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, text) {
  8765. if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) {
  8766. warnForUnmatchedText(textInstance, text);
  8767. }
  8768. }
  8769. function didNotHydrateContainerInstance(parentContainer, instance) {
  8770. {
  8771. if (instance.nodeType === ELEMENT_NODE) {
  8772. warnForDeletedHydratableElement(parentContainer, instance);
  8773. } else if (instance.nodeType === COMMENT_NODE) ; else {
  8774. warnForDeletedHydratableText(parentContainer, instance);
  8775. }
  8776. }
  8777. }
  8778. function didNotHydrateInstance(parentType, parentProps, parentInstance, instance) {
  8779. if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) {
  8780. if (instance.nodeType === ELEMENT_NODE) {
  8781. warnForDeletedHydratableElement(parentInstance, instance);
  8782. } else if (instance.nodeType === COMMENT_NODE) ; else {
  8783. warnForDeletedHydratableText(parentInstance, instance);
  8784. }
  8785. }
  8786. }
  8787. function didNotFindHydratableContainerInstance(parentContainer, type, props) {
  8788. {
  8789. warnForInsertedHydratedElement(parentContainer, type);
  8790. }
  8791. }
  8792. function didNotFindHydratableContainerTextInstance(parentContainer, text) {
  8793. {
  8794. warnForInsertedHydratedText(parentContainer, text);
  8795. }
  8796. }
  8797. function didNotFindHydratableInstance(parentType, parentProps, parentInstance, type, props) {
  8798. if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) {
  8799. warnForInsertedHydratedElement(parentInstance, type);
  8800. }
  8801. }
  8802. function didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, text) {
  8803. if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) {
  8804. warnForInsertedHydratedText(parentInstance, text);
  8805. }
  8806. }
  8807. function didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance) {
  8808. if ( parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) ;
  8809. }
  8810. var clientId = 0;
  8811. function makeClientIdInDEV(warnOnAccessInDEV) {
  8812. var id = 'r:' + (clientId++).toString(36);
  8813. return {
  8814. toString: function () {
  8815. warnOnAccessInDEV();
  8816. return id;
  8817. },
  8818. valueOf: function () {
  8819. warnOnAccessInDEV();
  8820. return id;
  8821. }
  8822. };
  8823. }
  8824. function isOpaqueHydratingObject(value) {
  8825. return value !== null && typeof value === 'object' && value.$$typeof === REACT_OPAQUE_ID_TYPE;
  8826. }
  8827. function makeOpaqueHydratingObject(attemptToReadValue) {
  8828. return {
  8829. $$typeof: REACT_OPAQUE_ID_TYPE,
  8830. toString: attemptToReadValue,
  8831. valueOf: attemptToReadValue
  8832. };
  8833. }
  8834. function preparePortalMount(portalInstance) {
  8835. {
  8836. listenToAllSupportedEvents(portalInstance);
  8837. }
  8838. }
  8839. var randomKey = Math.random().toString(36).slice(2);
  8840. var internalInstanceKey = '__reactFiber$' + randomKey;
  8841. var internalPropsKey = '__reactProps$' + randomKey;
  8842. var internalContainerInstanceKey = '__reactContainer$' + randomKey;
  8843. var internalEventHandlersKey = '__reactEvents$' + randomKey;
  8844. function precacheFiberNode(hostInst, node) {
  8845. node[internalInstanceKey] = hostInst;
  8846. }
  8847. function markContainerAsRoot(hostRoot, node) {
  8848. node[internalContainerInstanceKey] = hostRoot;
  8849. }
  8850. function unmarkContainerAsRoot(node) {
  8851. node[internalContainerInstanceKey] = null;
  8852. }
  8853. function isContainerMarkedAsRoot(node) {
  8854. return !!node[internalContainerInstanceKey];
  8855. } // Given a DOM node, return the closest HostComponent or HostText fiber ancestor.
  8856. // If the target node is part of a hydrated or not yet rendered subtree, then
  8857. // this may also return a SuspenseComponent or HostRoot to indicate that.
  8858. // Conceptually the HostRoot fiber is a child of the Container node. So if you
  8859. // pass the Container node as the targetNode, you will not actually get the
  8860. // HostRoot back. To get to the HostRoot, you need to pass a child of it.
  8861. // The same thing applies to Suspense boundaries.
  8862. function getClosestInstanceFromNode(targetNode) {
  8863. var targetInst = targetNode[internalInstanceKey];
  8864. if (targetInst) {
  8865. // Don't return HostRoot or SuspenseComponent here.
  8866. return targetInst;
  8867. } // If the direct event target isn't a React owned DOM node, we need to look
  8868. // to see if one of its parents is a React owned DOM node.
  8869. var parentNode = targetNode.parentNode;
  8870. while (parentNode) {
  8871. // We'll check if this is a container root that could include
  8872. // React nodes in the future. We need to check this first because
  8873. // if we're a child of a dehydrated container, we need to first
  8874. // find that inner container before moving on to finding the parent
  8875. // instance. Note that we don't check this field on the targetNode
  8876. // itself because the fibers are conceptually between the container
  8877. // node and the first child. It isn't surrounding the container node.
  8878. // If it's not a container, we check if it's an instance.
  8879. targetInst = parentNode[internalContainerInstanceKey] || parentNode[internalInstanceKey];
  8880. if (targetInst) {
  8881. // Since this wasn't the direct target of the event, we might have
  8882. // stepped past dehydrated DOM nodes to get here. However they could
  8883. // also have been non-React nodes. We need to answer which one.
  8884. // If we the instance doesn't have any children, then there can't be
  8885. // a nested suspense boundary within it. So we can use this as a fast
  8886. // bailout. Most of the time, when people add non-React children to
  8887. // the tree, it is using a ref to a child-less DOM node.
  8888. // Normally we'd only need to check one of the fibers because if it
  8889. // has ever gone from having children to deleting them or vice versa
  8890. // it would have deleted the dehydrated boundary nested inside already.
  8891. // However, since the HostRoot starts out with an alternate it might
  8892. // have one on the alternate so we need to check in case this was a
  8893. // root.
  8894. var alternate = targetInst.alternate;
  8895. if (targetInst.child !== null || alternate !== null && alternate.child !== null) {
  8896. // Next we need to figure out if the node that skipped past is
  8897. // nested within a dehydrated boundary and if so, which one.
  8898. var suspenseInstance = getParentSuspenseInstance(targetNode);
  8899. while (suspenseInstance !== null) {
  8900. // We found a suspense instance. That means that we haven't
  8901. // hydrated it yet. Even though we leave the comments in the
  8902. // DOM after hydrating, and there are boundaries in the DOM
  8903. // that could already be hydrated, we wouldn't have found them
  8904. // through this pass since if the target is hydrated it would
  8905. // have had an internalInstanceKey on it.
  8906. // Let's get the fiber associated with the SuspenseComponent
  8907. // as the deepest instance.
  8908. var targetSuspenseInst = suspenseInstance[internalInstanceKey];
  8909. if (targetSuspenseInst) {
  8910. return targetSuspenseInst;
  8911. } // If we don't find a Fiber on the comment, it might be because
  8912. // we haven't gotten to hydrate it yet. There might still be a
  8913. // parent boundary that hasn't above this one so we need to find
  8914. // the outer most that is known.
  8915. suspenseInstance = getParentSuspenseInstance(suspenseInstance); // If we don't find one, then that should mean that the parent
  8916. // host component also hasn't hydrated yet. We can return it
  8917. // below since it will bail out on the isMounted check later.
  8918. }
  8919. }
  8920. return targetInst;
  8921. }
  8922. targetNode = parentNode;
  8923. parentNode = targetNode.parentNode;
  8924. }
  8925. return null;
  8926. }
  8927. /**
  8928. * Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent
  8929. * instance, or null if the node was not rendered by this React.
  8930. */
  8931. function getInstanceFromNode(node) {
  8932. var inst = node[internalInstanceKey] || node[internalContainerInstanceKey];
  8933. if (inst) {
  8934. if (inst.tag === HostComponent || inst.tag === HostText || inst.tag === SuspenseComponent || inst.tag === HostRoot) {
  8935. return inst;
  8936. } else {
  8937. return null;
  8938. }
  8939. }
  8940. return null;
  8941. }
  8942. /**
  8943. * Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding
  8944. * DOM node.
  8945. */
  8946. function getNodeFromInstance(inst) {
  8947. if (inst.tag === HostComponent || inst.tag === HostText) {
  8948. // In Fiber this, is just the state node right now. We assume it will be
  8949. // a host component or host text.
  8950. return inst.stateNode;
  8951. } // Without this first invariant, passing a non-DOM-component triggers the next
  8952. // invariant for a missing parent, which is super confusing.
  8953. {
  8954. {
  8955. throw Error( "getNodeFromInstance: Invalid argument." );
  8956. }
  8957. }
  8958. }
  8959. function getFiberCurrentPropsFromNode(node) {
  8960. return node[internalPropsKey] || null;
  8961. }
  8962. function updateFiberProps(node, props) {
  8963. node[internalPropsKey] = props;
  8964. }
  8965. function getEventListenerSet(node) {
  8966. var elementListenerSet = node[internalEventHandlersKey];
  8967. if (elementListenerSet === undefined) {
  8968. elementListenerSet = node[internalEventHandlersKey] = new Set();
  8969. }
  8970. return elementListenerSet;
  8971. }
  8972. var loggedTypeFailures = {};
  8973. var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
  8974. function setCurrentlyValidatingElement(element) {
  8975. {
  8976. if (element) {
  8977. var owner = element._owner;
  8978. var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
  8979. ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
  8980. } else {
  8981. ReactDebugCurrentFrame$1.setExtraStackFrame(null);
  8982. }
  8983. }
  8984. }
  8985. function checkPropTypes(typeSpecs, values, location, componentName, element) {
  8986. {
  8987. // $FlowFixMe This is okay but Flow doesn't know it.
  8988. var has = Function.call.bind(Object.prototype.hasOwnProperty);
  8989. for (var typeSpecName in typeSpecs) {
  8990. if (has(typeSpecs, typeSpecName)) {
  8991. var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
  8992. // fail the render phase where it didn't fail before. So we log it.
  8993. // After these have been cleaned up, we'll let them throw.
  8994. try {
  8995. // This is intentionally an invariant that gets caught. It's the same
  8996. // behavior as without this statement except with a better message.
  8997. if (typeof typeSpecs[typeSpecName] !== 'function') {
  8998. var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
  8999. err.name = 'Invariant Violation';
  9000. throw err;
  9001. }
  9002. error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
  9003. } catch (ex) {
  9004. error$1 = ex;
  9005. }
  9006. if (error$1 && !(error$1 instanceof Error)) {
  9007. setCurrentlyValidatingElement(element);
  9008. error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
  9009. setCurrentlyValidatingElement(null);
  9010. }
  9011. if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
  9012. // Only monitor this failure once because there tends to be a lot of the
  9013. // same error.
  9014. loggedTypeFailures[error$1.message] = true;
  9015. setCurrentlyValidatingElement(element);
  9016. error('Failed %s type: %s', location, error$1.message);
  9017. setCurrentlyValidatingElement(null);
  9018. }
  9019. }
  9020. }
  9021. }
  9022. }
  9023. var valueStack = [];
  9024. var fiberStack;
  9025. {
  9026. fiberStack = [];
  9027. }
  9028. var index = -1;
  9029. function createCursor(defaultValue) {
  9030. return {
  9031. current: defaultValue
  9032. };
  9033. }
  9034. function pop(cursor, fiber) {
  9035. if (index < 0) {
  9036. {
  9037. error('Unexpected pop.');
  9038. }
  9039. return;
  9040. }
  9041. {
  9042. if (fiber !== fiberStack[index]) {
  9043. error('Unexpected Fiber popped.');
  9044. }
  9045. }
  9046. cursor.current = valueStack[index];
  9047. valueStack[index] = null;
  9048. {
  9049. fiberStack[index] = null;
  9050. }
  9051. index--;
  9052. }
  9053. function push(cursor, value, fiber) {
  9054. index++;
  9055. valueStack[index] = cursor.current;
  9056. {
  9057. fiberStack[index] = fiber;
  9058. }
  9059. cursor.current = value;
  9060. }
  9061. var warnedAboutMissingGetChildContext;
  9062. {
  9063. warnedAboutMissingGetChildContext = {};
  9064. }
  9065. var emptyContextObject = {};
  9066. {
  9067. Object.freeze(emptyContextObject);
  9068. } // A cursor to the current merged context object on the stack.
  9069. var contextStackCursor = createCursor(emptyContextObject); // A cursor to a boolean indicating whether the context has changed.
  9070. var didPerformWorkStackCursor = createCursor(false); // Keep track of the previous context object that was on the stack.
  9071. // We use this to get access to the parent context after we have already
  9072. // pushed the next context provider, and now need to merge their contexts.
  9073. var previousContext = emptyContextObject;
  9074. function getUnmaskedContext(workInProgress, Component, didPushOwnContextIfProvider) {
  9075. {
  9076. if (didPushOwnContextIfProvider && isContextProvider(Component)) {
  9077. // If the fiber is a context provider itself, when we read its context
  9078. // we may have already pushed its own child context on the stack. A context
  9079. // provider should not "see" its own child context. Therefore we read the
  9080. // previous (parent) context instead for a context provider.
  9081. return previousContext;
  9082. }
  9083. return contextStackCursor.current;
  9084. }
  9085. }
  9086. function cacheContext(workInProgress, unmaskedContext, maskedContext) {
  9087. {
  9088. var instance = workInProgress.stateNode;
  9089. instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
  9090. instance.__reactInternalMemoizedMaskedChildContext = maskedContext;
  9091. }
  9092. }
  9093. function getMaskedContext(workInProgress, unmaskedContext) {
  9094. {
  9095. var type = workInProgress.type;
  9096. var contextTypes = type.contextTypes;
  9097. if (!contextTypes) {
  9098. return emptyContextObject;
  9099. } // Avoid recreating masked context unless unmasked context has changed.
  9100. // Failing to do this will result in unnecessary calls to componentWillReceiveProps.
  9101. // This may trigger infinite loops if componentWillReceiveProps calls setState.
  9102. var instance = workInProgress.stateNode;
  9103. if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
  9104. return instance.__reactInternalMemoizedMaskedChildContext;
  9105. }
  9106. var context = {};
  9107. for (var key in contextTypes) {
  9108. context[key] = unmaskedContext[key];
  9109. }
  9110. {
  9111. var name = getComponentName(type) || 'Unknown';
  9112. checkPropTypes(contextTypes, context, 'context', name);
  9113. } // Cache unmasked context so we can avoid recreating masked context unless necessary.
  9114. // Context is created before the class component is instantiated so check for instance.
  9115. if (instance) {
  9116. cacheContext(workInProgress, unmaskedContext, context);
  9117. }
  9118. return context;
  9119. }
  9120. }
  9121. function hasContextChanged() {
  9122. {
  9123. return didPerformWorkStackCursor.current;
  9124. }
  9125. }
  9126. function isContextProvider(type) {
  9127. {
  9128. var childContextTypes = type.childContextTypes;
  9129. return childContextTypes !== null && childContextTypes !== undefined;
  9130. }
  9131. }
  9132. function popContext(fiber) {
  9133. {
  9134. pop(didPerformWorkStackCursor, fiber);
  9135. pop(contextStackCursor, fiber);
  9136. }
  9137. }
  9138. function popTopLevelContextObject(fiber) {
  9139. {
  9140. pop(didPerformWorkStackCursor, fiber);
  9141. pop(contextStackCursor, fiber);
  9142. }
  9143. }
  9144. function pushTopLevelContextObject(fiber, context, didChange) {
  9145. {
  9146. if (!(contextStackCursor.current === emptyContextObject)) {
  9147. {
  9148. throw Error( "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." );
  9149. }
  9150. }
  9151. push(contextStackCursor, context, fiber);
  9152. push(didPerformWorkStackCursor, didChange, fiber);
  9153. }
  9154. }
  9155. function processChildContext(fiber, type, parentContext) {
  9156. {
  9157. var instance = fiber.stateNode;
  9158. var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future.
  9159. // It has only been added in Fiber to match the (unintentional) behavior in Stack.
  9160. if (typeof instance.getChildContext !== 'function') {
  9161. {
  9162. var componentName = getComponentName(type) || 'Unknown';
  9163. if (!warnedAboutMissingGetChildContext[componentName]) {
  9164. warnedAboutMissingGetChildContext[componentName] = true;
  9165. error('%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);
  9166. }
  9167. }
  9168. return parentContext;
  9169. }
  9170. var childContext = instance.getChildContext();
  9171. for (var contextKey in childContext) {
  9172. if (!(contextKey in childContextTypes)) {
  9173. {
  9174. throw Error( (getComponentName(type) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes." );
  9175. }
  9176. }
  9177. }
  9178. {
  9179. var name = getComponentName(type) || 'Unknown';
  9180. checkPropTypes(childContextTypes, childContext, 'child context', name);
  9181. }
  9182. return _assign({}, parentContext, childContext);
  9183. }
  9184. }
  9185. function pushContextProvider(workInProgress) {
  9186. {
  9187. var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity.
  9188. // If the instance does not exist yet, we will push null at first,
  9189. // and replace it on the stack later when invalidating the context.
  9190. var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject; // Remember the parent context so we can merge with it later.
  9191. // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates.
  9192. previousContext = contextStackCursor.current;
  9193. push(contextStackCursor, memoizedMergedChildContext, workInProgress);
  9194. push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress);
  9195. return true;
  9196. }
  9197. }
  9198. function invalidateContextProvider(workInProgress, type, didChange) {
  9199. {
  9200. var instance = workInProgress.stateNode;
  9201. if (!instance) {
  9202. {
  9203. throw Error( "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." );
  9204. }
  9205. }
  9206. if (didChange) {
  9207. // Merge parent and own context.
  9208. // Skip this if we're not updating due to sCU.
  9209. // This avoids unnecessarily recomputing memoized values.
  9210. var mergedContext = processChildContext(workInProgress, type, previousContext);
  9211. instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one.
  9212. // It is important to unwind the context in the reverse order.
  9213. pop(didPerformWorkStackCursor, workInProgress);
  9214. pop(contextStackCursor, workInProgress); // Now push the new context and mark that it has changed.
  9215. push(contextStackCursor, mergedContext, workInProgress);
  9216. push(didPerformWorkStackCursor, didChange, workInProgress);
  9217. } else {
  9218. pop(didPerformWorkStackCursor, workInProgress);
  9219. push(didPerformWorkStackCursor, didChange, workInProgress);
  9220. }
  9221. }
  9222. }
  9223. function findCurrentUnmaskedContext(fiber) {
  9224. {
  9225. // Currently this is only used with renderSubtreeIntoContainer; not sure if it
  9226. // makes sense elsewhere
  9227. if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) {
  9228. {
  9229. throw Error( "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." );
  9230. }
  9231. }
  9232. var node = fiber;
  9233. do {
  9234. switch (node.tag) {
  9235. case HostRoot:
  9236. return node.stateNode.context;
  9237. case ClassComponent:
  9238. {
  9239. var Component = node.type;
  9240. if (isContextProvider(Component)) {
  9241. return node.stateNode.__reactInternalMemoizedMergedChildContext;
  9242. }
  9243. break;
  9244. }
  9245. }
  9246. node = node.return;
  9247. } while (node !== null);
  9248. {
  9249. {
  9250. throw Error( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." );
  9251. }
  9252. }
  9253. }
  9254. }
  9255. var LegacyRoot = 0;
  9256. var BlockingRoot = 1;
  9257. var ConcurrentRoot = 2;
  9258. var rendererID = null;
  9259. var injectedHook = null;
  9260. var hasLoggedError = false;
  9261. var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined';
  9262. function injectInternals(internals) {
  9263. if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
  9264. // No DevTools
  9265. return false;
  9266. }
  9267. var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
  9268. if (hook.isDisabled) {
  9269. // This isn't a real property on the hook, but it can be set to opt out
  9270. // of DevTools integration and associated warnings and logs.
  9271. // https://github.com/facebook/react/issues/3877
  9272. return true;
  9273. }
  9274. if (!hook.supportsFiber) {
  9275. {
  9276. error('The installed version of React DevTools is too old and will not work ' + 'with the current version of React. Please update React DevTools. ' + 'https://reactjs.org/link/react-devtools');
  9277. } // DevTools exists, even though it doesn't support Fiber.
  9278. return true;
  9279. }
  9280. try {
  9281. rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks.
  9282. injectedHook = hook;
  9283. } catch (err) {
  9284. // Catch all errors because it is unsafe to throw during initialization.
  9285. {
  9286. error('React instrumentation encountered an error: %s.', err);
  9287. }
  9288. } // DevTools exists
  9289. return true;
  9290. }
  9291. function onScheduleRoot(root, children) {
  9292. {
  9293. if (injectedHook && typeof injectedHook.onScheduleFiberRoot === 'function') {
  9294. try {
  9295. injectedHook.onScheduleFiberRoot(rendererID, root, children);
  9296. } catch (err) {
  9297. if ( !hasLoggedError) {
  9298. hasLoggedError = true;
  9299. error('React instrumentation encountered an error: %s', err);
  9300. }
  9301. }
  9302. }
  9303. }
  9304. }
  9305. function onCommitRoot(root, priorityLevel) {
  9306. if (injectedHook && typeof injectedHook.onCommitFiberRoot === 'function') {
  9307. try {
  9308. var didError = (root.current.flags & DidCapture) === DidCapture;
  9309. if (enableProfilerTimer) {
  9310. injectedHook.onCommitFiberRoot(rendererID, root, priorityLevel, didError);
  9311. } else {
  9312. injectedHook.onCommitFiberRoot(rendererID, root, undefined, didError);
  9313. }
  9314. } catch (err) {
  9315. {
  9316. if (!hasLoggedError) {
  9317. hasLoggedError = true;
  9318. error('React instrumentation encountered an error: %s', err);
  9319. }
  9320. }
  9321. }
  9322. }
  9323. }
  9324. function onCommitUnmount(fiber) {
  9325. if (injectedHook && typeof injectedHook.onCommitFiberUnmount === 'function') {
  9326. try {
  9327. injectedHook.onCommitFiberUnmount(rendererID, fiber);
  9328. } catch (err) {
  9329. {
  9330. if (!hasLoggedError) {
  9331. hasLoggedError = true;
  9332. error('React instrumentation encountered an error: %s', err);
  9333. }
  9334. }
  9335. }
  9336. }
  9337. }
  9338. var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority,
  9339. Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback,
  9340. Scheduler_cancelCallback = Scheduler.unstable_cancelCallback,
  9341. Scheduler_shouldYield = Scheduler.unstable_shouldYield,
  9342. Scheduler_requestPaint = Scheduler.unstable_requestPaint,
  9343. Scheduler_now$1 = Scheduler.unstable_now,
  9344. Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel,
  9345. Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority,
  9346. Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority,
  9347. Scheduler_NormalPriority = Scheduler.unstable_NormalPriority,
  9348. Scheduler_LowPriority = Scheduler.unstable_LowPriority,
  9349. Scheduler_IdlePriority = Scheduler.unstable_IdlePriority;
  9350. {
  9351. // Provide explicit error message when production+profiling bundle of e.g.
  9352. // react-dom is used with production (non-profiling) bundle of
  9353. // scheduler/tracing
  9354. if (!(tracing.__interactionsRef != null && tracing.__interactionsRef.current != null)) {
  9355. {
  9356. throw Error( "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at https://reactjs.org/link/profiling" );
  9357. }
  9358. }
  9359. }
  9360. var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Scheduler priorities. We use
  9361. // ascending numbers so we can compare them like numbers. They start at 90 to
  9362. // avoid clashing with Scheduler's priorities.
  9363. var ImmediatePriority$1 = 99;
  9364. var UserBlockingPriority$2 = 98;
  9365. var NormalPriority$1 = 97;
  9366. var LowPriority$1 = 96;
  9367. var IdlePriority$1 = 95; // NoPriority is the absence of priority. Also React-only.
  9368. var NoPriority$1 = 90;
  9369. var shouldYield = Scheduler_shouldYield;
  9370. var requestPaint = // Fall back gracefully if we're running an older version of Scheduler.
  9371. Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function () {};
  9372. var syncQueue = null;
  9373. var immediateQueueCallbackNode = null;
  9374. var isFlushingSyncQueue = false;
  9375. var initialTimeMs$1 = Scheduler_now$1(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly.
  9376. // This will be the case for modern browsers that support `performance.now`. In
  9377. // older browsers, Scheduler falls back to `Date.now`, which returns a Unix
  9378. // timestamp. In that case, subtract the module initialization time to simulate
  9379. // the behavior of performance.now and keep our times small enough to fit
  9380. // within 32 bits.
  9381. // TODO: Consider lifting this into Scheduler.
  9382. var now = initialTimeMs$1 < 10000 ? Scheduler_now$1 : function () {
  9383. return Scheduler_now$1() - initialTimeMs$1;
  9384. };
  9385. function getCurrentPriorityLevel() {
  9386. switch (Scheduler_getCurrentPriorityLevel()) {
  9387. case Scheduler_ImmediatePriority:
  9388. return ImmediatePriority$1;
  9389. case Scheduler_UserBlockingPriority:
  9390. return UserBlockingPriority$2;
  9391. case Scheduler_NormalPriority:
  9392. return NormalPriority$1;
  9393. case Scheduler_LowPriority:
  9394. return LowPriority$1;
  9395. case Scheduler_IdlePriority:
  9396. return IdlePriority$1;
  9397. default:
  9398. {
  9399. {
  9400. throw Error( "Unknown priority level." );
  9401. }
  9402. }
  9403. }
  9404. }
  9405. function reactPriorityToSchedulerPriority(reactPriorityLevel) {
  9406. switch (reactPriorityLevel) {
  9407. case ImmediatePriority$1:
  9408. return Scheduler_ImmediatePriority;
  9409. case UserBlockingPriority$2:
  9410. return Scheduler_UserBlockingPriority;
  9411. case NormalPriority$1:
  9412. return Scheduler_NormalPriority;
  9413. case LowPriority$1:
  9414. return Scheduler_LowPriority;
  9415. case IdlePriority$1:
  9416. return Scheduler_IdlePriority;
  9417. default:
  9418. {
  9419. {
  9420. throw Error( "Unknown priority level." );
  9421. }
  9422. }
  9423. }
  9424. }
  9425. function runWithPriority$1(reactPriorityLevel, fn) {
  9426. var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
  9427. return Scheduler_runWithPriority(priorityLevel, fn);
  9428. }
  9429. function scheduleCallback(reactPriorityLevel, callback, options) {
  9430. var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
  9431. return Scheduler_scheduleCallback(priorityLevel, callback, options);
  9432. }
  9433. function scheduleSyncCallback(callback) {
  9434. // Push this callback into an internal queue. We'll flush these either in
  9435. // the next tick, or earlier if something calls `flushSyncCallbackQueue`.
  9436. if (syncQueue === null) {
  9437. syncQueue = [callback]; // Flush the queue in the next tick, at the earliest.
  9438. immediateQueueCallbackNode = Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueueImpl);
  9439. } else {
  9440. // Push onto existing queue. Don't need to schedule a callback because
  9441. // we already scheduled one when we created the queue.
  9442. syncQueue.push(callback);
  9443. }
  9444. return fakeCallbackNode;
  9445. }
  9446. function cancelCallback(callbackNode) {
  9447. if (callbackNode !== fakeCallbackNode) {
  9448. Scheduler_cancelCallback(callbackNode);
  9449. }
  9450. }
  9451. function flushSyncCallbackQueue() {
  9452. if (immediateQueueCallbackNode !== null) {
  9453. var node = immediateQueueCallbackNode;
  9454. immediateQueueCallbackNode = null;
  9455. Scheduler_cancelCallback(node);
  9456. }
  9457. flushSyncCallbackQueueImpl();
  9458. }
  9459. function flushSyncCallbackQueueImpl() {
  9460. if (!isFlushingSyncQueue && syncQueue !== null) {
  9461. // Prevent re-entrancy.
  9462. isFlushingSyncQueue = true;
  9463. var i = 0;
  9464. {
  9465. try {
  9466. var _isSync2 = true;
  9467. var _queue = syncQueue;
  9468. runWithPriority$1(ImmediatePriority$1, function () {
  9469. for (; i < _queue.length; i++) {
  9470. var callback = _queue[i];
  9471. do {
  9472. callback = callback(_isSync2);
  9473. } while (callback !== null);
  9474. }
  9475. });
  9476. syncQueue = null;
  9477. } catch (error) {
  9478. // If something throws, leave the remaining callbacks on the queue.
  9479. if (syncQueue !== null) {
  9480. syncQueue = syncQueue.slice(i + 1);
  9481. } // Resume flushing in the next tick
  9482. Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueue);
  9483. throw error;
  9484. } finally {
  9485. isFlushingSyncQueue = false;
  9486. }
  9487. }
  9488. }
  9489. }
  9490. // TODO: this is special because it gets imported during build.
  9491. var ReactVersion = '17.0.2';
  9492. var NoMode = 0;
  9493. var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root
  9494. // tag instead
  9495. var BlockingMode = 2;
  9496. var ConcurrentMode = 4;
  9497. var ProfileMode = 8;
  9498. var DebugTracingMode = 16;
  9499. var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
  9500. var NoTransition = 0;
  9501. function requestCurrentTransition() {
  9502. return ReactCurrentBatchConfig.transition;
  9503. }
  9504. var ReactStrictModeWarnings = {
  9505. recordUnsafeLifecycleWarnings: function (fiber, instance) {},
  9506. flushPendingUnsafeLifecycleWarnings: function () {},
  9507. recordLegacyContextWarning: function (fiber, instance) {},
  9508. flushLegacyContextWarning: function () {},
  9509. discardPendingWarnings: function () {}
  9510. };
  9511. {
  9512. var findStrictRoot = function (fiber) {
  9513. var maybeStrictRoot = null;
  9514. var node = fiber;
  9515. while (node !== null) {
  9516. if (node.mode & StrictMode) {
  9517. maybeStrictRoot = node;
  9518. }
  9519. node = node.return;
  9520. }
  9521. return maybeStrictRoot;
  9522. };
  9523. var setToSortedString = function (set) {
  9524. var array = [];
  9525. set.forEach(function (value) {
  9526. array.push(value);
  9527. });
  9528. return array.sort().join(', ');
  9529. };
  9530. var pendingComponentWillMountWarnings = [];
  9531. var pendingUNSAFE_ComponentWillMountWarnings = [];
  9532. var pendingComponentWillReceivePropsWarnings = [];
  9533. var pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
  9534. var pendingComponentWillUpdateWarnings = [];
  9535. var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about.
  9536. var didWarnAboutUnsafeLifecycles = new Set();
  9537. ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) {
  9538. // Dedup strategy: Warn once per component.
  9539. if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
  9540. return;
  9541. }
  9542. if (typeof instance.componentWillMount === 'function' && // Don't warn about react-lifecycles-compat polyfilled components.
  9543. instance.componentWillMount.__suppressDeprecationWarning !== true) {
  9544. pendingComponentWillMountWarnings.push(fiber);
  9545. }
  9546. if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillMount === 'function') {
  9547. pendingUNSAFE_ComponentWillMountWarnings.push(fiber);
  9548. }
  9549. if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
  9550. pendingComponentWillReceivePropsWarnings.push(fiber);
  9551. }
  9552. if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  9553. pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber);
  9554. }
  9555. if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
  9556. pendingComponentWillUpdateWarnings.push(fiber);
  9557. }
  9558. if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillUpdate === 'function') {
  9559. pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber);
  9560. }
  9561. };
  9562. ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () {
  9563. // We do an initial pass to gather component names
  9564. var componentWillMountUniqueNames = new Set();
  9565. if (pendingComponentWillMountWarnings.length > 0) {
  9566. pendingComponentWillMountWarnings.forEach(function (fiber) {
  9567. componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component');
  9568. didWarnAboutUnsafeLifecycles.add(fiber.type);
  9569. });
  9570. pendingComponentWillMountWarnings = [];
  9571. }
  9572. var UNSAFE_componentWillMountUniqueNames = new Set();
  9573. if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) {
  9574. pendingUNSAFE_ComponentWillMountWarnings.forEach(function (fiber) {
  9575. UNSAFE_componentWillMountUniqueNames.add(getComponentName(fiber.type) || 'Component');
  9576. didWarnAboutUnsafeLifecycles.add(fiber.type);
  9577. });
  9578. pendingUNSAFE_ComponentWillMountWarnings = [];
  9579. }
  9580. var componentWillReceivePropsUniqueNames = new Set();
  9581. if (pendingComponentWillReceivePropsWarnings.length > 0) {
  9582. pendingComponentWillReceivePropsWarnings.forEach(function (fiber) {
  9583. componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component');
  9584. didWarnAboutUnsafeLifecycles.add(fiber.type);
  9585. });
  9586. pendingComponentWillReceivePropsWarnings = [];
  9587. }
  9588. var UNSAFE_componentWillReceivePropsUniqueNames = new Set();
  9589. if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) {
  9590. pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function (fiber) {
  9591. UNSAFE_componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || 'Component');
  9592. didWarnAboutUnsafeLifecycles.add(fiber.type);
  9593. });
  9594. pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
  9595. }
  9596. var componentWillUpdateUniqueNames = new Set();
  9597. if (pendingComponentWillUpdateWarnings.length > 0) {
  9598. pendingComponentWillUpdateWarnings.forEach(function (fiber) {
  9599. componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component');
  9600. didWarnAboutUnsafeLifecycles.add(fiber.type);
  9601. });
  9602. pendingComponentWillUpdateWarnings = [];
  9603. }
  9604. var UNSAFE_componentWillUpdateUniqueNames = new Set();
  9605. if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) {
  9606. pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function (fiber) {
  9607. UNSAFE_componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || 'Component');
  9608. didWarnAboutUnsafeLifecycles.add(fiber.type);
  9609. });
  9610. pendingUNSAFE_ComponentWillUpdateWarnings = [];
  9611. } // Finally, we flush all the warnings
  9612. // UNSAFE_ ones before the deprecated ones, since they'll be 'louder'
  9613. if (UNSAFE_componentWillMountUniqueNames.size > 0) {
  9614. var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames);
  9615. error('Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '\nPlease update the following components: %s', sortedNames);
  9616. }
  9617. if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) {
  9618. var _sortedNames = setToSortedString(UNSAFE_componentWillReceivePropsUniqueNames);
  9619. error('Using UNSAFE_componentWillReceiveProps in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, " + 'refactor your code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state\n' + '\nPlease update the following components: %s', _sortedNames);
  9620. }
  9621. if (UNSAFE_componentWillUpdateUniqueNames.size > 0) {
  9622. var _sortedNames2 = setToSortedString(UNSAFE_componentWillUpdateUniqueNames);
  9623. error('Using UNSAFE_componentWillUpdate in strict mode is not recommended ' + 'and may indicate bugs in your code. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '\nPlease update the following components: %s', _sortedNames2);
  9624. }
  9625. if (componentWillMountUniqueNames.size > 0) {
  9626. var _sortedNames3 = setToSortedString(componentWillMountUniqueNames);
  9627. warn('componentWillMount has been renamed, and is not recommended for use. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move code with side effects to componentDidMount, and set initial state in the constructor.\n' + '* Rename componentWillMount to UNSAFE_componentWillMount to suppress ' + 'this warning in non-strict mode. In React 18.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);
  9628. }
  9629. if (componentWillReceivePropsUniqueNames.size > 0) {
  9630. var _sortedNames4 = setToSortedString(componentWillReceivePropsUniqueNames);
  9631. warn('componentWillReceiveProps has been renamed, and is not recommended for use. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + "* If you're updating state whenever props change, refactor your " + 'code to use memoization techniques or move it to ' + 'static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state\n' + '* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress ' + 'this warning in non-strict mode. In React 18.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);
  9632. }
  9633. if (componentWillUpdateUniqueNames.size > 0) {
  9634. var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames);
  9635. warn('componentWillUpdate has been renamed, and is not recommended for use. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move data fetching code or side effects to componentDidUpdate.\n' + '* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress ' + 'this warning in non-strict mode. In React 18.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);
  9636. }
  9637. };
  9638. var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about.
  9639. var didWarnAboutLegacyContext = new Set();
  9640. ReactStrictModeWarnings.recordLegacyContextWarning = function (fiber, instance) {
  9641. var strictRoot = findStrictRoot(fiber);
  9642. if (strictRoot === null) {
  9643. error('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.');
  9644. return;
  9645. } // Dedup strategy: Warn once per component.
  9646. if (didWarnAboutLegacyContext.has(fiber.type)) {
  9647. return;
  9648. }
  9649. var warningsForRoot = pendingLegacyContextWarning.get(strictRoot);
  9650. if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === 'function') {
  9651. if (warningsForRoot === undefined) {
  9652. warningsForRoot = [];
  9653. pendingLegacyContextWarning.set(strictRoot, warningsForRoot);
  9654. }
  9655. warningsForRoot.push(fiber);
  9656. }
  9657. };
  9658. ReactStrictModeWarnings.flushLegacyContextWarning = function () {
  9659. pendingLegacyContextWarning.forEach(function (fiberArray, strictRoot) {
  9660. if (fiberArray.length === 0) {
  9661. return;
  9662. }
  9663. var firstFiber = fiberArray[0];
  9664. var uniqueNames = new Set();
  9665. fiberArray.forEach(function (fiber) {
  9666. uniqueNames.add(getComponentName(fiber.type) || 'Component');
  9667. didWarnAboutLegacyContext.add(fiber.type);
  9668. });
  9669. var sortedNames = setToSortedString(uniqueNames);
  9670. try {
  9671. setCurrentFiber(firstFiber);
  9672. error('Legacy context API has been detected within a strict-mode tree.' + '\n\nThe old API will be supported in all 16.x releases, but applications ' + 'using it should migrate to the new version.' + '\n\nPlease update the following components: %s' + '\n\nLearn more about this warning here: https://reactjs.org/link/legacy-context', sortedNames);
  9673. } finally {
  9674. resetCurrentFiber();
  9675. }
  9676. });
  9677. };
  9678. ReactStrictModeWarnings.discardPendingWarnings = function () {
  9679. pendingComponentWillMountWarnings = [];
  9680. pendingUNSAFE_ComponentWillMountWarnings = [];
  9681. pendingComponentWillReceivePropsWarnings = [];
  9682. pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
  9683. pendingComponentWillUpdateWarnings = [];
  9684. pendingUNSAFE_ComponentWillUpdateWarnings = [];
  9685. pendingLegacyContextWarning = new Map();
  9686. };
  9687. }
  9688. function resolveDefaultProps(Component, baseProps) {
  9689. if (Component && Component.defaultProps) {
  9690. // Resolve default props. Taken from ReactElement
  9691. var props = _assign({}, baseProps);
  9692. var defaultProps = Component.defaultProps;
  9693. for (var propName in defaultProps) {
  9694. if (props[propName] === undefined) {
  9695. props[propName] = defaultProps[propName];
  9696. }
  9697. }
  9698. return props;
  9699. }
  9700. return baseProps;
  9701. }
  9702. // Max 31 bit integer. The max integer size in V8 for 32-bit systems.
  9703. // Math.pow(2, 30) - 1
  9704. // 0b111111111111111111111111111111
  9705. var MAX_SIGNED_31_BIT_INT = 1073741823;
  9706. var valueCursor = createCursor(null);
  9707. var rendererSigil;
  9708. {
  9709. // Use this to detect multiple renderers using the same context
  9710. rendererSigil = {};
  9711. }
  9712. var currentlyRenderingFiber = null;
  9713. var lastContextDependency = null;
  9714. var lastContextWithAllBitsObserved = null;
  9715. var isDisallowedContextReadInDEV = false;
  9716. function resetContextDependencies() {
  9717. // This is called right before React yields execution, to ensure `readContext`
  9718. // cannot be called outside the render phase.
  9719. currentlyRenderingFiber = null;
  9720. lastContextDependency = null;
  9721. lastContextWithAllBitsObserved = null;
  9722. {
  9723. isDisallowedContextReadInDEV = false;
  9724. }
  9725. }
  9726. function enterDisallowedContextReadInDEV() {
  9727. {
  9728. isDisallowedContextReadInDEV = true;
  9729. }
  9730. }
  9731. function exitDisallowedContextReadInDEV() {
  9732. {
  9733. isDisallowedContextReadInDEV = false;
  9734. }
  9735. }
  9736. function pushProvider(providerFiber, nextValue) {
  9737. var context = providerFiber.type._context;
  9738. {
  9739. push(valueCursor, context._currentValue, providerFiber);
  9740. context._currentValue = nextValue;
  9741. {
  9742. if (context._currentRenderer !== undefined && context._currentRenderer !== null && context._currentRenderer !== rendererSigil) {
  9743. error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.');
  9744. }
  9745. context._currentRenderer = rendererSigil;
  9746. }
  9747. }
  9748. }
  9749. function popProvider(providerFiber) {
  9750. var currentValue = valueCursor.current;
  9751. pop(valueCursor, providerFiber);
  9752. var context = providerFiber.type._context;
  9753. {
  9754. context._currentValue = currentValue;
  9755. }
  9756. }
  9757. function calculateChangedBits(context, newValue, oldValue) {
  9758. if (objectIs(oldValue, newValue)) {
  9759. // No change
  9760. return 0;
  9761. } else {
  9762. var changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
  9763. {
  9764. if ((changedBits & MAX_SIGNED_31_BIT_INT) !== changedBits) {
  9765. error('calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits);
  9766. }
  9767. }
  9768. return changedBits | 0;
  9769. }
  9770. }
  9771. function scheduleWorkOnParentPath(parent, renderLanes) {
  9772. // Update the child lanes of all the ancestors, including the alternates.
  9773. var node = parent;
  9774. while (node !== null) {
  9775. var alternate = node.alternate;
  9776. if (!isSubsetOfLanes(node.childLanes, renderLanes)) {
  9777. node.childLanes = mergeLanes(node.childLanes, renderLanes);
  9778. if (alternate !== null) {
  9779. alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes);
  9780. }
  9781. } else if (alternate !== null && !isSubsetOfLanes(alternate.childLanes, renderLanes)) {
  9782. alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes);
  9783. } else {
  9784. // Neither alternate was updated, which means the rest of the
  9785. // ancestor path already has sufficient priority.
  9786. break;
  9787. }
  9788. node = node.return;
  9789. }
  9790. }
  9791. function propagateContextChange(workInProgress, context, changedBits, renderLanes) {
  9792. var fiber = workInProgress.child;
  9793. if (fiber !== null) {
  9794. // Set the return pointer of the child to the work-in-progress fiber.
  9795. fiber.return = workInProgress;
  9796. }
  9797. while (fiber !== null) {
  9798. var nextFiber = void 0; // Visit this fiber.
  9799. var list = fiber.dependencies;
  9800. if (list !== null) {
  9801. nextFiber = fiber.child;
  9802. var dependency = list.firstContext;
  9803. while (dependency !== null) {
  9804. // Check if the context matches.
  9805. if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) {
  9806. // Match! Schedule an update on this fiber.
  9807. if (fiber.tag === ClassComponent) {
  9808. // Schedule a force update on the work-in-progress.
  9809. var update = createUpdate(NoTimestamp, pickArbitraryLane(renderLanes));
  9810. update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the
  9811. // update to the current fiber, too, which means it will persist even if
  9812. // this render is thrown away. Since it's a race condition, not sure it's
  9813. // worth fixing.
  9814. enqueueUpdate(fiber, update);
  9815. }
  9816. fiber.lanes = mergeLanes(fiber.lanes, renderLanes);
  9817. var alternate = fiber.alternate;
  9818. if (alternate !== null) {
  9819. alternate.lanes = mergeLanes(alternate.lanes, renderLanes);
  9820. }
  9821. scheduleWorkOnParentPath(fiber.return, renderLanes); // Mark the updated lanes on the list, too.
  9822. list.lanes = mergeLanes(list.lanes, renderLanes); // Since we already found a match, we can stop traversing the
  9823. // dependency list.
  9824. break;
  9825. }
  9826. dependency = dependency.next;
  9827. }
  9828. } else if (fiber.tag === ContextProvider) {
  9829. // Don't scan deeper if this is a matching provider
  9830. nextFiber = fiber.type === workInProgress.type ? null : fiber.child;
  9831. } else {
  9832. // Traverse down.
  9833. nextFiber = fiber.child;
  9834. }
  9835. if (nextFiber !== null) {
  9836. // Set the return pointer of the child to the work-in-progress fiber.
  9837. nextFiber.return = fiber;
  9838. } else {
  9839. // No child. Traverse to next sibling.
  9840. nextFiber = fiber;
  9841. while (nextFiber !== null) {
  9842. if (nextFiber === workInProgress) {
  9843. // We're back to the root of this subtree. Exit.
  9844. nextFiber = null;
  9845. break;
  9846. }
  9847. var sibling = nextFiber.sibling;
  9848. if (sibling !== null) {
  9849. // Set the return pointer of the sibling to the work-in-progress fiber.
  9850. sibling.return = nextFiber.return;
  9851. nextFiber = sibling;
  9852. break;
  9853. } // No more siblings. Traverse up.
  9854. nextFiber = nextFiber.return;
  9855. }
  9856. }
  9857. fiber = nextFiber;
  9858. }
  9859. }
  9860. function prepareToReadContext(workInProgress, renderLanes) {
  9861. currentlyRenderingFiber = workInProgress;
  9862. lastContextDependency = null;
  9863. lastContextWithAllBitsObserved = null;
  9864. var dependencies = workInProgress.dependencies;
  9865. if (dependencies !== null) {
  9866. var firstContext = dependencies.firstContext;
  9867. if (firstContext !== null) {
  9868. if (includesSomeLane(dependencies.lanes, renderLanes)) {
  9869. // Context list has a pending update. Mark that this fiber performed work.
  9870. markWorkInProgressReceivedUpdate();
  9871. } // Reset the work-in-progress list
  9872. dependencies.firstContext = null;
  9873. }
  9874. }
  9875. }
  9876. function readContext(context, observedBits) {
  9877. {
  9878. // This warning would fire if you read context inside a Hook like useMemo.
  9879. // Unlike the class check below, it's not enforced in production for perf.
  9880. if (isDisallowedContextReadInDEV) {
  9881. 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().');
  9882. }
  9883. }
  9884. if (lastContextWithAllBitsObserved === context) ; else if (observedBits === false || observedBits === 0) ; else {
  9885. var resolvedObservedBits; // Avoid deopting on observable arguments or heterogeneous types.
  9886. if (typeof observedBits !== 'number' || observedBits === MAX_SIGNED_31_BIT_INT) {
  9887. // Observe all updates.
  9888. lastContextWithAllBitsObserved = context;
  9889. resolvedObservedBits = MAX_SIGNED_31_BIT_INT;
  9890. } else {
  9891. resolvedObservedBits = observedBits;
  9892. }
  9893. var contextItem = {
  9894. context: context,
  9895. observedBits: resolvedObservedBits,
  9896. next: null
  9897. };
  9898. if (lastContextDependency === null) {
  9899. if (!(currentlyRenderingFiber !== null)) {
  9900. {
  9901. throw Error( "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()." );
  9902. }
  9903. } // This is the first dependency for this component. Create a new list.
  9904. lastContextDependency = contextItem;
  9905. currentlyRenderingFiber.dependencies = {
  9906. lanes: NoLanes,
  9907. firstContext: contextItem,
  9908. responders: null
  9909. };
  9910. } else {
  9911. // Append a new context item.
  9912. lastContextDependency = lastContextDependency.next = contextItem;
  9913. }
  9914. }
  9915. return context._currentValue ;
  9916. }
  9917. var UpdateState = 0;
  9918. var ReplaceState = 1;
  9919. var ForceUpdate = 2;
  9920. var CaptureUpdate = 3; // Global state that is reset at the beginning of calling `processUpdateQueue`.
  9921. // It should only be read right after calling `processUpdateQueue`, via
  9922. // `checkHasForceUpdateAfterProcessing`.
  9923. var hasForceUpdate = false;
  9924. var didWarnUpdateInsideUpdate;
  9925. var currentlyProcessingQueue;
  9926. {
  9927. didWarnUpdateInsideUpdate = false;
  9928. currentlyProcessingQueue = null;
  9929. }
  9930. function initializeUpdateQueue(fiber) {
  9931. var queue = {
  9932. baseState: fiber.memoizedState,
  9933. firstBaseUpdate: null,
  9934. lastBaseUpdate: null,
  9935. shared: {
  9936. pending: null
  9937. },
  9938. effects: null
  9939. };
  9940. fiber.updateQueue = queue;
  9941. }
  9942. function cloneUpdateQueue(current, workInProgress) {
  9943. // Clone the update queue from current. Unless it's already a clone.
  9944. var queue = workInProgress.updateQueue;
  9945. var currentQueue = current.updateQueue;
  9946. if (queue === currentQueue) {
  9947. var clone = {
  9948. baseState: currentQueue.baseState,
  9949. firstBaseUpdate: currentQueue.firstBaseUpdate,
  9950. lastBaseUpdate: currentQueue.lastBaseUpdate,
  9951. shared: currentQueue.shared,
  9952. effects: currentQueue.effects
  9953. };
  9954. workInProgress.updateQueue = clone;
  9955. }
  9956. }
  9957. function createUpdate(eventTime, lane) {
  9958. var update = {
  9959. eventTime: eventTime,
  9960. lane: lane,
  9961. tag: UpdateState,
  9962. payload: null,
  9963. callback: null,
  9964. next: null
  9965. };
  9966. return update;
  9967. }
  9968. function enqueueUpdate(fiber, update) {
  9969. var updateQueue = fiber.updateQueue;
  9970. if (updateQueue === null) {
  9971. // Only occurs if the fiber has been unmounted.
  9972. return;
  9973. }
  9974. var sharedQueue = updateQueue.shared;
  9975. var pending = sharedQueue.pending;
  9976. if (pending === null) {
  9977. // This is the first update. Create a circular list.
  9978. update.next = update;
  9979. } else {
  9980. update.next = pending.next;
  9981. pending.next = update;
  9982. }
  9983. sharedQueue.pending = update;
  9984. {
  9985. if (currentlyProcessingQueue === sharedQueue && !didWarnUpdateInsideUpdate) {
  9986. error('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.');
  9987. didWarnUpdateInsideUpdate = true;
  9988. }
  9989. }
  9990. }
  9991. function enqueueCapturedUpdate(workInProgress, capturedUpdate) {
  9992. // Captured updates are updates that are thrown by a child during the render
  9993. // phase. They should be discarded if the render is aborted. Therefore,
  9994. // we should only put them on the work-in-progress queue, not the current one.
  9995. var queue = workInProgress.updateQueue; // Check if the work-in-progress queue is a clone.
  9996. var current = workInProgress.alternate;
  9997. if (current !== null) {
  9998. var currentQueue = current.updateQueue;
  9999. if (queue === currentQueue) {
  10000. // The work-in-progress queue is the same as current. This happens when
  10001. // we bail out on a parent fiber that then captures an error thrown by
  10002. // a child. Since we want to append the update only to the work-in
  10003. // -progress queue, we need to clone the updates. We usually clone during
  10004. // processUpdateQueue, but that didn't happen in this case because we
  10005. // skipped over the parent when we bailed out.
  10006. var newFirst = null;
  10007. var newLast = null;
  10008. var firstBaseUpdate = queue.firstBaseUpdate;
  10009. if (firstBaseUpdate !== null) {
  10010. // Loop through the updates and clone them.
  10011. var update = firstBaseUpdate;
  10012. do {
  10013. var clone = {
  10014. eventTime: update.eventTime,
  10015. lane: update.lane,
  10016. tag: update.tag,
  10017. payload: update.payload,
  10018. callback: update.callback,
  10019. next: null
  10020. };
  10021. if (newLast === null) {
  10022. newFirst = newLast = clone;
  10023. } else {
  10024. newLast.next = clone;
  10025. newLast = clone;
  10026. }
  10027. update = update.next;
  10028. } while (update !== null); // Append the captured update the end of the cloned list.
  10029. if (newLast === null) {
  10030. newFirst = newLast = capturedUpdate;
  10031. } else {
  10032. newLast.next = capturedUpdate;
  10033. newLast = capturedUpdate;
  10034. }
  10035. } else {
  10036. // There are no base updates.
  10037. newFirst = newLast = capturedUpdate;
  10038. }
  10039. queue = {
  10040. baseState: currentQueue.baseState,
  10041. firstBaseUpdate: newFirst,
  10042. lastBaseUpdate: newLast,
  10043. shared: currentQueue.shared,
  10044. effects: currentQueue.effects
  10045. };
  10046. workInProgress.updateQueue = queue;
  10047. return;
  10048. }
  10049. } // Append the update to the end of the list.
  10050. var lastBaseUpdate = queue.lastBaseUpdate;
  10051. if (lastBaseUpdate === null) {
  10052. queue.firstBaseUpdate = capturedUpdate;
  10053. } else {
  10054. lastBaseUpdate.next = capturedUpdate;
  10055. }
  10056. queue.lastBaseUpdate = capturedUpdate;
  10057. }
  10058. function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) {
  10059. switch (update.tag) {
  10060. case ReplaceState:
  10061. {
  10062. var payload = update.payload;
  10063. if (typeof payload === 'function') {
  10064. // Updater function
  10065. {
  10066. enterDisallowedContextReadInDEV();
  10067. }
  10068. var nextState = payload.call(instance, prevState, nextProps);
  10069. {
  10070. if ( workInProgress.mode & StrictMode) {
  10071. disableLogs();
  10072. try {
  10073. payload.call(instance, prevState, nextProps);
  10074. } finally {
  10075. reenableLogs();
  10076. }
  10077. }
  10078. exitDisallowedContextReadInDEV();
  10079. }
  10080. return nextState;
  10081. } // State object
  10082. return payload;
  10083. }
  10084. case CaptureUpdate:
  10085. {
  10086. workInProgress.flags = workInProgress.flags & ~ShouldCapture | DidCapture;
  10087. }
  10088. // Intentional fallthrough
  10089. case UpdateState:
  10090. {
  10091. var _payload = update.payload;
  10092. var partialState;
  10093. if (typeof _payload === 'function') {
  10094. // Updater function
  10095. {
  10096. enterDisallowedContextReadInDEV();
  10097. }
  10098. partialState = _payload.call(instance, prevState, nextProps);
  10099. {
  10100. if ( workInProgress.mode & StrictMode) {
  10101. disableLogs();
  10102. try {
  10103. _payload.call(instance, prevState, nextProps);
  10104. } finally {
  10105. reenableLogs();
  10106. }
  10107. }
  10108. exitDisallowedContextReadInDEV();
  10109. }
  10110. } else {
  10111. // Partial state object
  10112. partialState = _payload;
  10113. }
  10114. if (partialState === null || partialState === undefined) {
  10115. // Null and undefined are treated as no-ops.
  10116. return prevState;
  10117. } // Merge the partial state and the previous state.
  10118. return _assign({}, prevState, partialState);
  10119. }
  10120. case ForceUpdate:
  10121. {
  10122. hasForceUpdate = true;
  10123. return prevState;
  10124. }
  10125. }
  10126. return prevState;
  10127. }
  10128. function processUpdateQueue(workInProgress, props, instance, renderLanes) {
  10129. // This is always non-null on a ClassComponent or HostRoot
  10130. var queue = workInProgress.updateQueue;
  10131. hasForceUpdate = false;
  10132. {
  10133. currentlyProcessingQueue = queue.shared;
  10134. }
  10135. var firstBaseUpdate = queue.firstBaseUpdate;
  10136. var lastBaseUpdate = queue.lastBaseUpdate; // Check if there are pending updates. If so, transfer them to the base queue.
  10137. var pendingQueue = queue.shared.pending;
  10138. if (pendingQueue !== null) {
  10139. queue.shared.pending = null; // The pending queue is circular. Disconnect the pointer between first
  10140. // and last so that it's non-circular.
  10141. var lastPendingUpdate = pendingQueue;
  10142. var firstPendingUpdate = lastPendingUpdate.next;
  10143. lastPendingUpdate.next = null; // Append pending updates to base queue
  10144. if (lastBaseUpdate === null) {
  10145. firstBaseUpdate = firstPendingUpdate;
  10146. } else {
  10147. lastBaseUpdate.next = firstPendingUpdate;
  10148. }
  10149. lastBaseUpdate = lastPendingUpdate; // If there's a current queue, and it's different from the base queue, then
  10150. // we need to transfer the updates to that queue, too. Because the base
  10151. // queue is a singly-linked list with no cycles, we can append to both
  10152. // lists and take advantage of structural sharing.
  10153. // TODO: Pass `current` as argument
  10154. var current = workInProgress.alternate;
  10155. if (current !== null) {
  10156. // This is always non-null on a ClassComponent or HostRoot
  10157. var currentQueue = current.updateQueue;
  10158. var currentLastBaseUpdate = currentQueue.lastBaseUpdate;
  10159. if (currentLastBaseUpdate !== lastBaseUpdate) {
  10160. if (currentLastBaseUpdate === null) {
  10161. currentQueue.firstBaseUpdate = firstPendingUpdate;
  10162. } else {
  10163. currentLastBaseUpdate.next = firstPendingUpdate;
  10164. }
  10165. currentQueue.lastBaseUpdate = lastPendingUpdate;
  10166. }
  10167. }
  10168. } // These values may change as we process the queue.
  10169. if (firstBaseUpdate !== null) {
  10170. // Iterate through the list of updates to compute the result.
  10171. var newState = queue.baseState; // TODO: Don't need to accumulate this. Instead, we can remove renderLanes
  10172. // from the original lanes.
  10173. var newLanes = NoLanes;
  10174. var newBaseState = null;
  10175. var newFirstBaseUpdate = null;
  10176. var newLastBaseUpdate = null;
  10177. var update = firstBaseUpdate;
  10178. do {
  10179. var updateLane = update.lane;
  10180. var updateEventTime = update.eventTime;
  10181. if (!isSubsetOfLanes(renderLanes, updateLane)) {
  10182. // Priority is insufficient. Skip this update. If this is the first
  10183. // skipped update, the previous update/state is the new base
  10184. // update/state.
  10185. var clone = {
  10186. eventTime: updateEventTime,
  10187. lane: updateLane,
  10188. tag: update.tag,
  10189. payload: update.payload,
  10190. callback: update.callback,
  10191. next: null
  10192. };
  10193. if (newLastBaseUpdate === null) {
  10194. newFirstBaseUpdate = newLastBaseUpdate = clone;
  10195. newBaseState = newState;
  10196. } else {
  10197. newLastBaseUpdate = newLastBaseUpdate.next = clone;
  10198. } // Update the remaining priority in the queue.
  10199. newLanes = mergeLanes(newLanes, updateLane);
  10200. } else {
  10201. // This update does have sufficient priority.
  10202. if (newLastBaseUpdate !== null) {
  10203. var _clone = {
  10204. eventTime: updateEventTime,
  10205. // This update is going to be committed so we never want uncommit
  10206. // it. Using NoLane works because 0 is a subset of all bitmasks, so
  10207. // this will never be skipped by the check above.
  10208. lane: NoLane,
  10209. tag: update.tag,
  10210. payload: update.payload,
  10211. callback: update.callback,
  10212. next: null
  10213. };
  10214. newLastBaseUpdate = newLastBaseUpdate.next = _clone;
  10215. } // Process this update.
  10216. newState = getStateFromUpdate(workInProgress, queue, update, newState, props, instance);
  10217. var callback = update.callback;
  10218. if (callback !== null) {
  10219. workInProgress.flags |= Callback;
  10220. var effects = queue.effects;
  10221. if (effects === null) {
  10222. queue.effects = [update];
  10223. } else {
  10224. effects.push(update);
  10225. }
  10226. }
  10227. }
  10228. update = update.next;
  10229. if (update === null) {
  10230. pendingQueue = queue.shared.pending;
  10231. if (pendingQueue === null) {
  10232. break;
  10233. } else {
  10234. // An update was scheduled from inside a reducer. Add the new
  10235. // pending updates to the end of the list and keep processing.
  10236. var _lastPendingUpdate = pendingQueue; // Intentionally unsound. Pending updates form a circular list, but we
  10237. // unravel them when transferring them to the base queue.
  10238. var _firstPendingUpdate = _lastPendingUpdate.next;
  10239. _lastPendingUpdate.next = null;
  10240. update = _firstPendingUpdate;
  10241. queue.lastBaseUpdate = _lastPendingUpdate;
  10242. queue.shared.pending = null;
  10243. }
  10244. }
  10245. } while (true);
  10246. if (newLastBaseUpdate === null) {
  10247. newBaseState = newState;
  10248. }
  10249. queue.baseState = newBaseState;
  10250. queue.firstBaseUpdate = newFirstBaseUpdate;
  10251. queue.lastBaseUpdate = newLastBaseUpdate; // Set the remaining expiration time to be whatever is remaining in the queue.
  10252. // This should be fine because the only two other things that contribute to
  10253. // expiration time are props and context. We're already in the middle of the
  10254. // begin phase by the time we start processing the queue, so we've already
  10255. // dealt with the props. Context in components that specify
  10256. // shouldComponentUpdate is tricky; but we'll have to account for
  10257. // that regardless.
  10258. markSkippedUpdateLanes(newLanes);
  10259. workInProgress.lanes = newLanes;
  10260. workInProgress.memoizedState = newState;
  10261. }
  10262. {
  10263. currentlyProcessingQueue = null;
  10264. }
  10265. }
  10266. function callCallback(callback, context) {
  10267. if (!(typeof callback === 'function')) {
  10268. {
  10269. throw Error( "Invalid argument passed as callback. Expected a function. Instead received: " + callback );
  10270. }
  10271. }
  10272. callback.call(context);
  10273. }
  10274. function resetHasForceUpdateBeforeProcessing() {
  10275. hasForceUpdate = false;
  10276. }
  10277. function checkHasForceUpdateAfterProcessing() {
  10278. return hasForceUpdate;
  10279. }
  10280. function commitUpdateQueue(finishedWork, finishedQueue, instance) {
  10281. // Commit the effects
  10282. var effects = finishedQueue.effects;
  10283. finishedQueue.effects = null;
  10284. if (effects !== null) {
  10285. for (var i = 0; i < effects.length; i++) {
  10286. var effect = effects[i];
  10287. var callback = effect.callback;
  10288. if (callback !== null) {
  10289. effect.callback = null;
  10290. callCallback(callback, instance);
  10291. }
  10292. }
  10293. }
  10294. }
  10295. var fakeInternalInstance = {};
  10296. var isArray = Array.isArray; // React.Component uses a shared frozen object by default.
  10297. // We'll use it to determine whether we need to initialize legacy refs.
  10298. var emptyRefsObject = new React.Component().refs;
  10299. var didWarnAboutStateAssignmentForComponent;
  10300. var didWarnAboutUninitializedState;
  10301. var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate;
  10302. var didWarnAboutLegacyLifecyclesAndDerivedState;
  10303. var didWarnAboutUndefinedDerivedState;
  10304. var warnOnUndefinedDerivedState;
  10305. var warnOnInvalidCallback;
  10306. var didWarnAboutDirectlyAssigningPropsToState;
  10307. var didWarnAboutContextTypeAndContextTypes;
  10308. var didWarnAboutInvalidateContextType;
  10309. {
  10310. didWarnAboutStateAssignmentForComponent = new Set();
  10311. didWarnAboutUninitializedState = new Set();
  10312. didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set();
  10313. didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
  10314. didWarnAboutDirectlyAssigningPropsToState = new Set();
  10315. didWarnAboutUndefinedDerivedState = new Set();
  10316. didWarnAboutContextTypeAndContextTypes = new Set();
  10317. didWarnAboutInvalidateContextType = new Set();
  10318. var didWarnOnInvalidCallback = new Set();
  10319. warnOnInvalidCallback = function (callback, callerName) {
  10320. if (callback === null || typeof callback === 'function') {
  10321. return;
  10322. }
  10323. var key = callerName + '_' + callback;
  10324. if (!didWarnOnInvalidCallback.has(key)) {
  10325. didWarnOnInvalidCallback.add(key);
  10326. error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
  10327. }
  10328. };
  10329. warnOnUndefinedDerivedState = function (type, partialState) {
  10330. if (partialState === undefined) {
  10331. var componentName = getComponentName(type) || 'Component';
  10332. if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
  10333. didWarnAboutUndefinedDerivedState.add(componentName);
  10334. error('%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
  10335. }
  10336. }
  10337. }; // This is so gross but it's at least non-critical and can be removed if
  10338. // it causes problems. This is meant to give a nicer error message for
  10339. // ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component,
  10340. // ...)) which otherwise throws a "_processChildContext is not a function"
  10341. // exception.
  10342. Object.defineProperty(fakeInternalInstance, '_processChildContext', {
  10343. enumerable: false,
  10344. value: function () {
  10345. {
  10346. {
  10347. throw Error( "_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn't supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal)." );
  10348. }
  10349. }
  10350. }
  10351. });
  10352. Object.freeze(fakeInternalInstance);
  10353. }
  10354. function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) {
  10355. var prevState = workInProgress.memoizedState;
  10356. {
  10357. if ( workInProgress.mode & StrictMode) {
  10358. disableLogs();
  10359. try {
  10360. // Invoke the function an extra time to help detect side-effects.
  10361. getDerivedStateFromProps(nextProps, prevState);
  10362. } finally {
  10363. reenableLogs();
  10364. }
  10365. }
  10366. }
  10367. var partialState = getDerivedStateFromProps(nextProps, prevState);
  10368. {
  10369. warnOnUndefinedDerivedState(ctor, partialState);
  10370. } // Merge the partial state and the previous state.
  10371. var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState);
  10372. workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the
  10373. // base state.
  10374. if (workInProgress.lanes === NoLanes) {
  10375. // Queue is always non-null for classes
  10376. var updateQueue = workInProgress.updateQueue;
  10377. updateQueue.baseState = memoizedState;
  10378. }
  10379. }
  10380. var classComponentUpdater = {
  10381. isMounted: isMounted,
  10382. enqueueSetState: function (inst, payload, callback) {
  10383. var fiber = get(inst);
  10384. var eventTime = requestEventTime();
  10385. var lane = requestUpdateLane(fiber);
  10386. var update = createUpdate(eventTime, lane);
  10387. update.payload = payload;
  10388. if (callback !== undefined && callback !== null) {
  10389. {
  10390. warnOnInvalidCallback(callback, 'setState');
  10391. }
  10392. update.callback = callback;
  10393. }
  10394. enqueueUpdate(fiber, update);
  10395. scheduleUpdateOnFiber(fiber, lane, eventTime);
  10396. },
  10397. enqueueReplaceState: function (inst, payload, callback) {
  10398. var fiber = get(inst);
  10399. var eventTime = requestEventTime();
  10400. var lane = requestUpdateLane(fiber);
  10401. var update = createUpdate(eventTime, lane);
  10402. update.tag = ReplaceState;
  10403. update.payload = payload;
  10404. if (callback !== undefined && callback !== null) {
  10405. {
  10406. warnOnInvalidCallback(callback, 'replaceState');
  10407. }
  10408. update.callback = callback;
  10409. }
  10410. enqueueUpdate(fiber, update);
  10411. scheduleUpdateOnFiber(fiber, lane, eventTime);
  10412. },
  10413. enqueueForceUpdate: function (inst, callback) {
  10414. var fiber = get(inst);
  10415. var eventTime = requestEventTime();
  10416. var lane = requestUpdateLane(fiber);
  10417. var update = createUpdate(eventTime, lane);
  10418. update.tag = ForceUpdate;
  10419. if (callback !== undefined && callback !== null) {
  10420. {
  10421. warnOnInvalidCallback(callback, 'forceUpdate');
  10422. }
  10423. update.callback = callback;
  10424. }
  10425. enqueueUpdate(fiber, update);
  10426. scheduleUpdateOnFiber(fiber, lane, eventTime);
  10427. }
  10428. };
  10429. function checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext) {
  10430. var instance = workInProgress.stateNode;
  10431. if (typeof instance.shouldComponentUpdate === 'function') {
  10432. {
  10433. if ( workInProgress.mode & StrictMode) {
  10434. disableLogs();
  10435. try {
  10436. // Invoke the function an extra time to help detect side-effects.
  10437. instance.shouldComponentUpdate(newProps, newState, nextContext);
  10438. } finally {
  10439. reenableLogs();
  10440. }
  10441. }
  10442. }
  10443. var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext);
  10444. {
  10445. if (shouldUpdate === undefined) {
  10446. error('%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(ctor) || 'Component');
  10447. }
  10448. }
  10449. return shouldUpdate;
  10450. }
  10451. if (ctor.prototype && ctor.prototype.isPureReactComponent) {
  10452. return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
  10453. }
  10454. return true;
  10455. }
  10456. function checkClassInstance(workInProgress, ctor, newProps) {
  10457. var instance = workInProgress.stateNode;
  10458. {
  10459. var name = getComponentName(ctor) || 'Component';
  10460. var renderPresent = instance.render;
  10461. if (!renderPresent) {
  10462. if (ctor.prototype && typeof ctor.prototype.render === 'function') {
  10463. error('%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
  10464. } else {
  10465. error('%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
  10466. }
  10467. }
  10468. if (instance.getInitialState && !instance.getInitialState.isReactClassApproved && !instance.state) {
  10469. error('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);
  10470. }
  10471. if (instance.getDefaultProps && !instance.getDefaultProps.isReactClassApproved) {
  10472. error('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);
  10473. }
  10474. if (instance.propTypes) {
  10475. error('propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name);
  10476. }
  10477. if (instance.contextType) {
  10478. error('contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name);
  10479. }
  10480. {
  10481. if (instance.contextTypes) {
  10482. error('contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name);
  10483. }
  10484. if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
  10485. didWarnAboutContextTypeAndContextTypes.add(ctor);
  10486. error('%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
  10487. }
  10488. }
  10489. if (typeof instance.componentShouldUpdate === 'function') {
  10490. error('%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);
  10491. }
  10492. if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
  10493. error('%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');
  10494. }
  10495. if (typeof instance.componentDidUnmount === 'function') {
  10496. error('%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name);
  10497. }
  10498. if (typeof instance.componentDidReceiveProps === 'function') {
  10499. error('%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);
  10500. }
  10501. if (typeof instance.componentWillRecieveProps === 'function') {
  10502. error('%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name);
  10503. }
  10504. if (typeof instance.UNSAFE_componentWillRecieveProps === 'function') {
  10505. error('%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name);
  10506. }
  10507. var hasMutatedProps = instance.props !== newProps;
  10508. if (instance.props !== undefined && hasMutatedProps) {
  10509. error('%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name);
  10510. }
  10511. if (instance.defaultProps) {
  10512. error('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);
  10513. }
  10514. if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) {
  10515. didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor);
  10516. error('%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentName(ctor));
  10517. }
  10518. if (typeof instance.getDerivedStateFromProps === 'function') {
  10519. error('%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name);
  10520. }
  10521. if (typeof instance.getDerivedStateFromError === 'function') {
  10522. error('%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name);
  10523. }
  10524. if (typeof ctor.getSnapshotBeforeUpdate === 'function') {
  10525. error('%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name);
  10526. }
  10527. var _state = instance.state;
  10528. if (_state && (typeof _state !== 'object' || isArray(_state))) {
  10529. error('%s.state: must be set to an object or null', name);
  10530. }
  10531. if (typeof instance.getChildContext === 'function' && typeof ctor.childContextTypes !== 'object') {
  10532. error('%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name);
  10533. }
  10534. }
  10535. }
  10536. function adoptClassInstance(workInProgress, instance) {
  10537. instance.updater = classComponentUpdater;
  10538. workInProgress.stateNode = instance; // The instance needs access to the fiber so that it can schedule updates
  10539. set(instance, workInProgress);
  10540. {
  10541. instance._reactInternalInstance = fakeInternalInstance;
  10542. }
  10543. }
  10544. function constructClassInstance(workInProgress, ctor, props) {
  10545. var isLegacyContextConsumer = false;
  10546. var unmaskedContext = emptyContextObject;
  10547. var context = emptyContextObject;
  10548. var contextType = ctor.contextType;
  10549. {
  10550. if ('contextType' in ctor) {
  10551. var isValid = // Allow null for conditional declaration
  10552. contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer>
  10553. if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
  10554. didWarnAboutInvalidateContextType.add(ctor);
  10555. var addendum = '';
  10556. if (contextType === undefined) {
  10557. 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.';
  10558. } else if (typeof contextType !== 'object') {
  10559. addendum = ' However, it is set to a ' + typeof contextType + '.';
  10560. } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
  10561. addendum = ' Did you accidentally pass the Context.Provider instead?';
  10562. } else if (contextType._context !== undefined) {
  10563. // <Context.Consumer>
  10564. addendum = ' Did you accidentally pass the Context.Consumer instead?';
  10565. } else {
  10566. addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.';
  10567. }
  10568. error('%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum);
  10569. }
  10570. }
  10571. }
  10572. if (typeof contextType === 'object' && contextType !== null) {
  10573. context = readContext(contextType);
  10574. } else {
  10575. unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  10576. var contextTypes = ctor.contextTypes;
  10577. isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined;
  10578. context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject;
  10579. } // Instantiate twice to help detect side-effects.
  10580. {
  10581. if ( workInProgress.mode & StrictMode) {
  10582. disableLogs();
  10583. try {
  10584. new ctor(props, context); // eslint-disable-line no-new
  10585. } finally {
  10586. reenableLogs();
  10587. }
  10588. }
  10589. }
  10590. var instance = new ctor(props, context);
  10591. var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null;
  10592. adoptClassInstance(workInProgress, instance);
  10593. {
  10594. if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) {
  10595. var componentName = getComponentName(ctor) || 'Component';
  10596. if (!didWarnAboutUninitializedState.has(componentName)) {
  10597. didWarnAboutUninitializedState.add(componentName);
  10598. error('`%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);
  10599. }
  10600. } // If new component APIs are defined, "unsafe" lifecycles won't be called.
  10601. // Warn about these lifecycles if they are present.
  10602. // Don't warn about react-lifecycles-compat polyfilled methods though.
  10603. if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') {
  10604. var foundWillMountName = null;
  10605. var foundWillReceivePropsName = null;
  10606. var foundWillUpdateName = null;
  10607. if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
  10608. foundWillMountName = 'componentWillMount';
  10609. } else if (typeof instance.UNSAFE_componentWillMount === 'function') {
  10610. foundWillMountName = 'UNSAFE_componentWillMount';
  10611. }
  10612. if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
  10613. foundWillReceivePropsName = 'componentWillReceiveProps';
  10614. } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  10615. foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
  10616. }
  10617. if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
  10618. foundWillUpdateName = 'componentWillUpdate';
  10619. } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
  10620. foundWillUpdateName = 'UNSAFE_componentWillUpdate';
  10621. }
  10622. if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
  10623. var _componentName = getComponentName(ctor) || 'Component';
  10624. var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()';
  10625. if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) {
  10626. didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName);
  10627. error('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://reactjs.org/link/unsafe-component-lifecycles', _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : '', foundWillReceivePropsName !== null ? "\n " + foundWillReceivePropsName : '', foundWillUpdateName !== null ? "\n " + foundWillUpdateName : '');
  10628. }
  10629. }
  10630. }
  10631. } // Cache unmasked context so we can avoid recreating masked context unless necessary.
  10632. // ReactFiberContext usually updates this cache but can't for newly-created instances.
  10633. if (isLegacyContextConsumer) {
  10634. cacheContext(workInProgress, unmaskedContext, context);
  10635. }
  10636. return instance;
  10637. }
  10638. function callComponentWillMount(workInProgress, instance) {
  10639. var oldState = instance.state;
  10640. if (typeof instance.componentWillMount === 'function') {
  10641. instance.componentWillMount();
  10642. }
  10643. if (typeof instance.UNSAFE_componentWillMount === 'function') {
  10644. instance.UNSAFE_componentWillMount();
  10645. }
  10646. if (oldState !== instance.state) {
  10647. {
  10648. error('%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress.type) || 'Component');
  10649. }
  10650. classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
  10651. }
  10652. }
  10653. function callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext) {
  10654. var oldState = instance.state;
  10655. if (typeof instance.componentWillReceiveProps === 'function') {
  10656. instance.componentWillReceiveProps(newProps, nextContext);
  10657. }
  10658. if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  10659. instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
  10660. }
  10661. if (instance.state !== oldState) {
  10662. {
  10663. var componentName = getComponentName(workInProgress.type) || 'Component';
  10664. if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
  10665. didWarnAboutStateAssignmentForComponent.add(componentName);
  10666. error('%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', componentName);
  10667. }
  10668. }
  10669. classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
  10670. }
  10671. } // Invokes the mount life-cycles on a previously never rendered instance.
  10672. function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
  10673. {
  10674. checkClassInstance(workInProgress, ctor, newProps);
  10675. }
  10676. var instance = workInProgress.stateNode;
  10677. instance.props = newProps;
  10678. instance.state = workInProgress.memoizedState;
  10679. instance.refs = emptyRefsObject;
  10680. initializeUpdateQueue(workInProgress);
  10681. var contextType = ctor.contextType;
  10682. if (typeof contextType === 'object' && contextType !== null) {
  10683. instance.context = readContext(contextType);
  10684. } else {
  10685. var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  10686. instance.context = getMaskedContext(workInProgress, unmaskedContext);
  10687. }
  10688. {
  10689. if (instance.state === newProps) {
  10690. var componentName = getComponentName(ctor) || 'Component';
  10691. if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) {
  10692. didWarnAboutDirectlyAssigningPropsToState.add(componentName);
  10693. error('%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);
  10694. }
  10695. }
  10696. if (workInProgress.mode & StrictMode) {
  10697. ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance);
  10698. }
  10699. {
  10700. ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance);
  10701. }
  10702. }
  10703. processUpdateQueue(workInProgress, newProps, instance, renderLanes);
  10704. instance.state = workInProgress.memoizedState;
  10705. var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
  10706. if (typeof getDerivedStateFromProps === 'function') {
  10707. applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
  10708. instance.state = workInProgress.memoizedState;
  10709. } // In order to support react-lifecycles-compat polyfilled components,
  10710. // Unsafe lifecycles should not be invoked for components using the new APIs.
  10711. if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
  10712. callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's
  10713. // process them now.
  10714. processUpdateQueue(workInProgress, newProps, instance, renderLanes);
  10715. instance.state = workInProgress.memoizedState;
  10716. }
  10717. if (typeof instance.componentDidMount === 'function') {
  10718. workInProgress.flags |= Update;
  10719. }
  10720. }
  10721. function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) {
  10722. var instance = workInProgress.stateNode;
  10723. var oldProps = workInProgress.memoizedProps;
  10724. instance.props = oldProps;
  10725. var oldContext = instance.context;
  10726. var contextType = ctor.contextType;
  10727. var nextContext = emptyContextObject;
  10728. if (typeof contextType === 'object' && contextType !== null) {
  10729. nextContext = readContext(contextType);
  10730. } else {
  10731. var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  10732. nextContext = getMaskedContext(workInProgress, nextLegacyUnmaskedContext);
  10733. }
  10734. var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
  10735. var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what
  10736. // ever the previously attempted to render - not the "current". However,
  10737. // during componentDidUpdate we pass the "current" props.
  10738. // In order to support react-lifecycles-compat polyfilled components,
  10739. // Unsafe lifecycles should not be invoked for components using the new APIs.
  10740. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
  10741. if (oldProps !== newProps || oldContext !== nextContext) {
  10742. callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
  10743. }
  10744. }
  10745. resetHasForceUpdateBeforeProcessing();
  10746. var oldState = workInProgress.memoizedState;
  10747. var newState = instance.state = oldState;
  10748. processUpdateQueue(workInProgress, newProps, instance, renderLanes);
  10749. newState = workInProgress.memoizedState;
  10750. if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
  10751. // If an update was already in progress, we should schedule an Update
  10752. // effect even though we're bailing out, so that cWU/cDU are called.
  10753. if (typeof instance.componentDidMount === 'function') {
  10754. workInProgress.flags |= Update;
  10755. }
  10756. return false;
  10757. }
  10758. if (typeof getDerivedStateFromProps === 'function') {
  10759. applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
  10760. newState = workInProgress.memoizedState;
  10761. }
  10762. var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
  10763. if (shouldUpdate) {
  10764. // In order to support react-lifecycles-compat polyfilled components,
  10765. // Unsafe lifecycles should not be invoked for components using the new APIs.
  10766. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
  10767. if (typeof instance.componentWillMount === 'function') {
  10768. instance.componentWillMount();
  10769. }
  10770. if (typeof instance.UNSAFE_componentWillMount === 'function') {
  10771. instance.UNSAFE_componentWillMount();
  10772. }
  10773. }
  10774. if (typeof instance.componentDidMount === 'function') {
  10775. workInProgress.flags |= Update;
  10776. }
  10777. } else {
  10778. // If an update was already in progress, we should schedule an Update
  10779. // effect even though we're bailing out, so that cWU/cDU are called.
  10780. if (typeof instance.componentDidMount === 'function') {
  10781. workInProgress.flags |= Update;
  10782. } // If shouldComponentUpdate returned false, we should still update the
  10783. // memoized state to indicate that this work can be reused.
  10784. workInProgress.memoizedProps = newProps;
  10785. workInProgress.memoizedState = newState;
  10786. } // Update the existing instance's state, props, and context pointers even
  10787. // if shouldComponentUpdate returns false.
  10788. instance.props = newProps;
  10789. instance.state = newState;
  10790. instance.context = nextContext;
  10791. return shouldUpdate;
  10792. } // Invokes the update life-cycles and returns false if it shouldn't rerender.
  10793. function updateClassInstance(current, workInProgress, ctor, newProps, renderLanes) {
  10794. var instance = workInProgress.stateNode;
  10795. cloneUpdateQueue(current, workInProgress);
  10796. var unresolvedOldProps = workInProgress.memoizedProps;
  10797. var oldProps = workInProgress.type === workInProgress.elementType ? unresolvedOldProps : resolveDefaultProps(workInProgress.type, unresolvedOldProps);
  10798. instance.props = oldProps;
  10799. var unresolvedNewProps = workInProgress.pendingProps;
  10800. var oldContext = instance.context;
  10801. var contextType = ctor.contextType;
  10802. var nextContext = emptyContextObject;
  10803. if (typeof contextType === 'object' && contextType !== null) {
  10804. nextContext = readContext(contextType);
  10805. } else {
  10806. var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
  10807. nextContext = getMaskedContext(workInProgress, nextUnmaskedContext);
  10808. }
  10809. var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
  10810. var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what
  10811. // ever the previously attempted to render - not the "current". However,
  10812. // during componentDidUpdate we pass the "current" props.
  10813. // In order to support react-lifecycles-compat polyfilled components,
  10814. // Unsafe lifecycles should not be invoked for components using the new APIs.
  10815. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
  10816. if (unresolvedOldProps !== unresolvedNewProps || oldContext !== nextContext) {
  10817. callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
  10818. }
  10819. }
  10820. resetHasForceUpdateBeforeProcessing();
  10821. var oldState = workInProgress.memoizedState;
  10822. var newState = instance.state = oldState;
  10823. processUpdateQueue(workInProgress, newProps, instance, renderLanes);
  10824. newState = workInProgress.memoizedState;
  10825. if (unresolvedOldProps === unresolvedNewProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
  10826. // If an update was already in progress, we should schedule an Update
  10827. // effect even though we're bailing out, so that cWU/cDU are called.
  10828. if (typeof instance.componentDidUpdate === 'function') {
  10829. if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  10830. workInProgress.flags |= Update;
  10831. }
  10832. }
  10833. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  10834. if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  10835. workInProgress.flags |= Snapshot;
  10836. }
  10837. }
  10838. return false;
  10839. }
  10840. if (typeof getDerivedStateFromProps === 'function') {
  10841. applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
  10842. newState = workInProgress.memoizedState;
  10843. }
  10844. var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, ctor, oldProps, newProps, oldState, newState, nextContext);
  10845. if (shouldUpdate) {
  10846. // In order to support react-lifecycles-compat polyfilled components,
  10847. // Unsafe lifecycles should not be invoked for components using the new APIs.
  10848. if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) {
  10849. if (typeof instance.componentWillUpdate === 'function') {
  10850. instance.componentWillUpdate(newProps, newState, nextContext);
  10851. }
  10852. if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
  10853. instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext);
  10854. }
  10855. }
  10856. if (typeof instance.componentDidUpdate === 'function') {
  10857. workInProgress.flags |= Update;
  10858. }
  10859. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  10860. workInProgress.flags |= Snapshot;
  10861. }
  10862. } else {
  10863. // If an update was already in progress, we should schedule an Update
  10864. // effect even though we're bailing out, so that cWU/cDU are called.
  10865. if (typeof instance.componentDidUpdate === 'function') {
  10866. if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  10867. workInProgress.flags |= Update;
  10868. }
  10869. }
  10870. if (typeof instance.getSnapshotBeforeUpdate === 'function') {
  10871. if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) {
  10872. workInProgress.flags |= Snapshot;
  10873. }
  10874. } // If shouldComponentUpdate returned false, we should still update the
  10875. // memoized props/state to indicate that this work can be reused.
  10876. workInProgress.memoizedProps = newProps;
  10877. workInProgress.memoizedState = newState;
  10878. } // Update the existing instance's state, props, and context pointers even
  10879. // if shouldComponentUpdate returns false.
  10880. instance.props = newProps;
  10881. instance.state = newState;
  10882. instance.context = nextContext;
  10883. return shouldUpdate;
  10884. }
  10885. var didWarnAboutMaps;
  10886. var didWarnAboutGenerators;
  10887. var didWarnAboutStringRefs;
  10888. var ownerHasKeyUseWarning;
  10889. var ownerHasFunctionTypeWarning;
  10890. var warnForMissingKey = function (child, returnFiber) {};
  10891. {
  10892. didWarnAboutMaps = false;
  10893. didWarnAboutGenerators = false;
  10894. didWarnAboutStringRefs = {};
  10895. /**
  10896. * Warn if there's no key explicitly set on dynamic arrays of children or
  10897. * object keys are not valid. This allows us to keep track of children between
  10898. * updates.
  10899. */
  10900. ownerHasKeyUseWarning = {};
  10901. ownerHasFunctionTypeWarning = {};
  10902. warnForMissingKey = function (child, returnFiber) {
  10903. if (child === null || typeof child !== 'object') {
  10904. return;
  10905. }
  10906. if (!child._store || child._store.validated || child.key != null) {
  10907. return;
  10908. }
  10909. if (!(typeof child._store === 'object')) {
  10910. {
  10911. throw Error( "React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue." );
  10912. }
  10913. }
  10914. child._store.validated = true;
  10915. var componentName = getComponentName(returnFiber.type) || 'Component';
  10916. if (ownerHasKeyUseWarning[componentName]) {
  10917. return;
  10918. }
  10919. ownerHasKeyUseWarning[componentName] = true;
  10920. error('Each child in a list should have a unique ' + '"key" prop. See https://reactjs.org/link/warning-keys for ' + 'more information.');
  10921. };
  10922. }
  10923. var isArray$1 = Array.isArray;
  10924. function coerceRef(returnFiber, current, element) {
  10925. var mixedRef = element.ref;
  10926. if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') {
  10927. {
  10928. // TODO: Clean this up once we turn on the string ref warning for
  10929. // everyone, because the strict mode case will no longer be relevant
  10930. if ((returnFiber.mode & StrictMode || warnAboutStringRefs) && // We warn in ReactElement.js if owner and self are equal for string refs
  10931. // because these cannot be automatically converted to an arrow function
  10932. // using a codemod. Therefore, we don't have to warn about string refs again.
  10933. !(element._owner && element._self && element._owner.stateNode !== element._self)) {
  10934. var componentName = getComponentName(returnFiber.type) || 'Component';
  10935. if (!didWarnAboutStringRefs[componentName]) {
  10936. {
  10937. error('A string ref, "%s", has been found within a strict mode tree. ' + 'String refs are a source of potential bugs and should be avoided. ' + 'We recommend using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', mixedRef);
  10938. }
  10939. didWarnAboutStringRefs[componentName] = true;
  10940. }
  10941. }
  10942. }
  10943. if (element._owner) {
  10944. var owner = element._owner;
  10945. var inst;
  10946. if (owner) {
  10947. var ownerFiber = owner;
  10948. if (!(ownerFiber.tag === ClassComponent)) {
  10949. {
  10950. throw Error( "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref" );
  10951. }
  10952. }
  10953. inst = ownerFiber.stateNode;
  10954. }
  10955. if (!inst) {
  10956. {
  10957. throw Error( "Missing owner for string ref " + mixedRef + ". This error is likely caused by a bug in React. Please file an issue." );
  10958. }
  10959. }
  10960. var stringRef = '' + mixedRef; // Check if previous string ref matches new string ref
  10961. if (current !== null && current.ref !== null && typeof current.ref === 'function' && current.ref._stringRef === stringRef) {
  10962. return current.ref;
  10963. }
  10964. var ref = function (value) {
  10965. var refs = inst.refs;
  10966. if (refs === emptyRefsObject) {
  10967. // This is a lazy pooled frozen object, so we need to initialize.
  10968. refs = inst.refs = {};
  10969. }
  10970. if (value === null) {
  10971. delete refs[stringRef];
  10972. } else {
  10973. refs[stringRef] = value;
  10974. }
  10975. };
  10976. ref._stringRef = stringRef;
  10977. return ref;
  10978. } else {
  10979. if (!(typeof mixedRef === 'string')) {
  10980. {
  10981. throw Error( "Expected ref to be a function, a string, an object returned by React.createRef(), or null." );
  10982. }
  10983. }
  10984. if (!element._owner) {
  10985. {
  10986. throw Error( "Element ref was specified as a string (" + mixedRef + ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://reactjs.org/link/refs-must-have-owner for more information." );
  10987. }
  10988. }
  10989. }
  10990. }
  10991. return mixedRef;
  10992. }
  10993. function throwOnInvalidObjectType(returnFiber, newChild) {
  10994. if (returnFiber.type !== 'textarea') {
  10995. {
  10996. {
  10997. throw Error( "Objects are not valid as a React child (found: " + (Object.prototype.toString.call(newChild) === '[object Object]' ? 'object with keys {' + Object.keys(newChild).join(', ') + '}' : newChild) + "). If you meant to render a collection of children, use an array instead." );
  10998. }
  10999. }
  11000. }
  11001. }
  11002. function warnOnFunctionType(returnFiber) {
  11003. {
  11004. var componentName = getComponentName(returnFiber.type) || 'Component';
  11005. if (ownerHasFunctionTypeWarning[componentName]) {
  11006. return;
  11007. }
  11008. ownerHasFunctionTypeWarning[componentName] = true;
  11009. error('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.');
  11010. }
  11011. } // We avoid inlining this to avoid potential deopts from using try/catch.
  11012. // to be able to optimize each path individually by branching early. This needs
  11013. // a compiler or we can do it manually. Helpers that don't need this branching
  11014. // live outside of this function.
  11015. function ChildReconciler(shouldTrackSideEffects) {
  11016. function deleteChild(returnFiber, childToDelete) {
  11017. if (!shouldTrackSideEffects) {
  11018. // Noop.
  11019. return;
  11020. } // Deletions are added in reversed order so we add it to the front.
  11021. // At this point, the return fiber's effect list is empty except for
  11022. // deletions, so we can just append the deletion to the list. The remaining
  11023. // effects aren't added until the complete phase. Once we implement
  11024. // resuming, this may not be true.
  11025. var last = returnFiber.lastEffect;
  11026. if (last !== null) {
  11027. last.nextEffect = childToDelete;
  11028. returnFiber.lastEffect = childToDelete;
  11029. } else {
  11030. returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
  11031. }
  11032. childToDelete.nextEffect = null;
  11033. childToDelete.flags = Deletion;
  11034. }
  11035. function deleteRemainingChildren(returnFiber, currentFirstChild) {
  11036. if (!shouldTrackSideEffects) {
  11037. // Noop.
  11038. return null;
  11039. } // TODO: For the shouldClone case, this could be micro-optimized a bit by
  11040. // assuming that after the first child we've already added everything.
  11041. var childToDelete = currentFirstChild;
  11042. while (childToDelete !== null) {
  11043. deleteChild(returnFiber, childToDelete);
  11044. childToDelete = childToDelete.sibling;
  11045. }
  11046. return null;
  11047. }
  11048. function mapRemainingChildren(returnFiber, currentFirstChild) {
  11049. // Add the remaining children to a temporary map so that we can find them by
  11050. // keys quickly. Implicit (null) keys get added to this set with their index
  11051. // instead.
  11052. var existingChildren = new Map();
  11053. var existingChild = currentFirstChild;
  11054. while (existingChild !== null) {
  11055. if (existingChild.key !== null) {
  11056. existingChildren.set(existingChild.key, existingChild);
  11057. } else {
  11058. existingChildren.set(existingChild.index, existingChild);
  11059. }
  11060. existingChild = existingChild.sibling;
  11061. }
  11062. return existingChildren;
  11063. }
  11064. function useFiber(fiber, pendingProps) {
  11065. // We currently set sibling to null and index to 0 here because it is easy
  11066. // to forget to do before returning it. E.g. for the single child case.
  11067. var clone = createWorkInProgress(fiber, pendingProps);
  11068. clone.index = 0;
  11069. clone.sibling = null;
  11070. return clone;
  11071. }
  11072. function placeChild(newFiber, lastPlacedIndex, newIndex) {
  11073. newFiber.index = newIndex;
  11074. if (!shouldTrackSideEffects) {
  11075. // Noop.
  11076. return lastPlacedIndex;
  11077. }
  11078. var current = newFiber.alternate;
  11079. if (current !== null) {
  11080. var oldIndex = current.index;
  11081. if (oldIndex < lastPlacedIndex) {
  11082. // This is a move.
  11083. newFiber.flags = Placement;
  11084. return lastPlacedIndex;
  11085. } else {
  11086. // This item can stay in place.
  11087. return oldIndex;
  11088. }
  11089. } else {
  11090. // This is an insertion.
  11091. newFiber.flags = Placement;
  11092. return lastPlacedIndex;
  11093. }
  11094. }
  11095. function placeSingleChild(newFiber) {
  11096. // This is simpler for the single child case. We only need to do a
  11097. // placement for inserting new children.
  11098. if (shouldTrackSideEffects && newFiber.alternate === null) {
  11099. newFiber.flags = Placement;
  11100. }
  11101. return newFiber;
  11102. }
  11103. function updateTextNode(returnFiber, current, textContent, lanes) {
  11104. if (current === null || current.tag !== HostText) {
  11105. // Insert
  11106. var created = createFiberFromText(textContent, returnFiber.mode, lanes);
  11107. created.return = returnFiber;
  11108. return created;
  11109. } else {
  11110. // Update
  11111. var existing = useFiber(current, textContent);
  11112. existing.return = returnFiber;
  11113. return existing;
  11114. }
  11115. }
  11116. function updateElement(returnFiber, current, element, lanes) {
  11117. if (current !== null) {
  11118. if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path:
  11119. isCompatibleFamilyForHotReloading(current, element) )) {
  11120. // Move based on index
  11121. var existing = useFiber(current, element.props);
  11122. existing.ref = coerceRef(returnFiber, current, element);
  11123. existing.return = returnFiber;
  11124. {
  11125. existing._debugSource = element._source;
  11126. existing._debugOwner = element._owner;
  11127. }
  11128. return existing;
  11129. }
  11130. } // Insert
  11131. var created = createFiberFromElement(element, returnFiber.mode, lanes);
  11132. created.ref = coerceRef(returnFiber, current, element);
  11133. created.return = returnFiber;
  11134. return created;
  11135. }
  11136. function updatePortal(returnFiber, current, portal, lanes) {
  11137. if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) {
  11138. // Insert
  11139. var created = createFiberFromPortal(portal, returnFiber.mode, lanes);
  11140. created.return = returnFiber;
  11141. return created;
  11142. } else {
  11143. // Update
  11144. var existing = useFiber(current, portal.children || []);
  11145. existing.return = returnFiber;
  11146. return existing;
  11147. }
  11148. }
  11149. function updateFragment(returnFiber, current, fragment, lanes, key) {
  11150. if (current === null || current.tag !== Fragment) {
  11151. // Insert
  11152. var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);
  11153. created.return = returnFiber;
  11154. return created;
  11155. } else {
  11156. // Update
  11157. var existing = useFiber(current, fragment);
  11158. existing.return = returnFiber;
  11159. return existing;
  11160. }
  11161. }
  11162. function createChild(returnFiber, newChild, lanes) {
  11163. if (typeof newChild === 'string' || typeof newChild === 'number') {
  11164. // Text nodes don't have keys. If the previous node is implicitly keyed
  11165. // we can continue to replace it without aborting even if it is not a text
  11166. // node.
  11167. var created = createFiberFromText('' + newChild, returnFiber.mode, lanes);
  11168. created.return = returnFiber;
  11169. return created;
  11170. }
  11171. if (typeof newChild === 'object' && newChild !== null) {
  11172. switch (newChild.$$typeof) {
  11173. case REACT_ELEMENT_TYPE:
  11174. {
  11175. var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);
  11176. _created.ref = coerceRef(returnFiber, null, newChild);
  11177. _created.return = returnFiber;
  11178. return _created;
  11179. }
  11180. case REACT_PORTAL_TYPE:
  11181. {
  11182. var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);
  11183. _created2.return = returnFiber;
  11184. return _created2;
  11185. }
  11186. }
  11187. if (isArray$1(newChild) || getIteratorFn(newChild)) {
  11188. var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);
  11189. _created3.return = returnFiber;
  11190. return _created3;
  11191. }
  11192. throwOnInvalidObjectType(returnFiber, newChild);
  11193. }
  11194. {
  11195. if (typeof newChild === 'function') {
  11196. warnOnFunctionType(returnFiber);
  11197. }
  11198. }
  11199. return null;
  11200. }
  11201. function updateSlot(returnFiber, oldFiber, newChild, lanes) {
  11202. // Update the fiber if the keys match, otherwise return null.
  11203. var key = oldFiber !== null ? oldFiber.key : null;
  11204. if (typeof newChild === 'string' || typeof newChild === 'number') {
  11205. // Text nodes don't have keys. If the previous node is implicitly keyed
  11206. // we can continue to replace it without aborting even if it is not a text
  11207. // node.
  11208. if (key !== null) {
  11209. return null;
  11210. }
  11211. return updateTextNode(returnFiber, oldFiber, '' + newChild, lanes);
  11212. }
  11213. if (typeof newChild === 'object' && newChild !== null) {
  11214. switch (newChild.$$typeof) {
  11215. case REACT_ELEMENT_TYPE:
  11216. {
  11217. if (newChild.key === key) {
  11218. if (newChild.type === REACT_FRAGMENT_TYPE) {
  11219. return updateFragment(returnFiber, oldFiber, newChild.props.children, lanes, key);
  11220. }
  11221. return updateElement(returnFiber, oldFiber, newChild, lanes);
  11222. } else {
  11223. return null;
  11224. }
  11225. }
  11226. case REACT_PORTAL_TYPE:
  11227. {
  11228. if (newChild.key === key) {
  11229. return updatePortal(returnFiber, oldFiber, newChild, lanes);
  11230. } else {
  11231. return null;
  11232. }
  11233. }
  11234. }
  11235. if (isArray$1(newChild) || getIteratorFn(newChild)) {
  11236. if (key !== null) {
  11237. return null;
  11238. }
  11239. return updateFragment(returnFiber, oldFiber, newChild, lanes, null);
  11240. }
  11241. throwOnInvalidObjectType(returnFiber, newChild);
  11242. }
  11243. {
  11244. if (typeof newChild === 'function') {
  11245. warnOnFunctionType(returnFiber);
  11246. }
  11247. }
  11248. return null;
  11249. }
  11250. function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {
  11251. if (typeof newChild === 'string' || typeof newChild === 'number') {
  11252. // Text nodes don't have keys, so we neither have to check the old nor
  11253. // new node for the key. If both are text nodes, they match.
  11254. var matchedFiber = existingChildren.get(newIdx) || null;
  11255. return updateTextNode(returnFiber, matchedFiber, '' + newChild, lanes);
  11256. }
  11257. if (typeof newChild === 'object' && newChild !== null) {
  11258. switch (newChild.$$typeof) {
  11259. case REACT_ELEMENT_TYPE:
  11260. {
  11261. var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
  11262. if (newChild.type === REACT_FRAGMENT_TYPE) {
  11263. return updateFragment(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);
  11264. }
  11265. return updateElement(returnFiber, _matchedFiber, newChild, lanes);
  11266. }
  11267. case REACT_PORTAL_TYPE:
  11268. {
  11269. var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
  11270. return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);
  11271. }
  11272. }
  11273. if (isArray$1(newChild) || getIteratorFn(newChild)) {
  11274. var _matchedFiber3 = existingChildren.get(newIdx) || null;
  11275. return updateFragment(returnFiber, _matchedFiber3, newChild, lanes, null);
  11276. }
  11277. throwOnInvalidObjectType(returnFiber, newChild);
  11278. }
  11279. {
  11280. if (typeof newChild === 'function') {
  11281. warnOnFunctionType(returnFiber);
  11282. }
  11283. }
  11284. return null;
  11285. }
  11286. /**
  11287. * Warns if there is a duplicate or missing key
  11288. */
  11289. function warnOnInvalidKey(child, knownKeys, returnFiber) {
  11290. {
  11291. if (typeof child !== 'object' || child === null) {
  11292. return knownKeys;
  11293. }
  11294. switch (child.$$typeof) {
  11295. case REACT_ELEMENT_TYPE:
  11296. case REACT_PORTAL_TYPE:
  11297. warnForMissingKey(child, returnFiber);
  11298. var key = child.key;
  11299. if (typeof key !== 'string') {
  11300. break;
  11301. }
  11302. if (knownKeys === null) {
  11303. knownKeys = new Set();
  11304. knownKeys.add(key);
  11305. break;
  11306. }
  11307. if (!knownKeys.has(key)) {
  11308. knownKeys.add(key);
  11309. break;
  11310. }
  11311. error('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);
  11312. break;
  11313. }
  11314. }
  11315. return knownKeys;
  11316. }
  11317. function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {
  11318. // This algorithm can't optimize by searching from both ends since we
  11319. // don't have backpointers on fibers. I'm trying to see how far we can get
  11320. // with that model. If it ends up not being worth the tradeoffs, we can
  11321. // add it later.
  11322. // Even with a two ended optimization, we'd want to optimize for the case
  11323. // where there are few changes and brute force the comparison instead of
  11324. // going for the Map. It'd like to explore hitting that path first in
  11325. // forward-only mode and only go for the Map once we notice that we need
  11326. // lots of look ahead. This doesn't handle reversal as well as two ended
  11327. // search but that's unusual. Besides, for the two ended optimization to
  11328. // work on Iterables, we'd need to copy the whole set.
  11329. // In this first iteration, we'll just live with hitting the bad case
  11330. // (adding everything to a Map) in for every insert/move.
  11331. // If you change this code, also update reconcileChildrenIterator() which
  11332. // uses the same algorithm.
  11333. {
  11334. // First, validate keys.
  11335. var knownKeys = null;
  11336. for (var i = 0; i < newChildren.length; i++) {
  11337. var child = newChildren[i];
  11338. knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);
  11339. }
  11340. }
  11341. var resultingFirstChild = null;
  11342. var previousNewFiber = null;
  11343. var oldFiber = currentFirstChild;
  11344. var lastPlacedIndex = 0;
  11345. var newIdx = 0;
  11346. var nextOldFiber = null;
  11347. for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {
  11348. if (oldFiber.index > newIdx) {
  11349. nextOldFiber = oldFiber;
  11350. oldFiber = null;
  11351. } else {
  11352. nextOldFiber = oldFiber.sibling;
  11353. }
  11354. var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);
  11355. if (newFiber === null) {
  11356. // TODO: This breaks on empty slots like null children. That's
  11357. // unfortunate because it triggers the slow path all the time. We need
  11358. // a better way to communicate whether this was a miss or null,
  11359. // boolean, undefined, etc.
  11360. if (oldFiber === null) {
  11361. oldFiber = nextOldFiber;
  11362. }
  11363. break;
  11364. }
  11365. if (shouldTrackSideEffects) {
  11366. if (oldFiber && newFiber.alternate === null) {
  11367. // We matched the slot, but we didn't reuse the existing fiber, so we
  11368. // need to delete the existing child.
  11369. deleteChild(returnFiber, oldFiber);
  11370. }
  11371. }
  11372. lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
  11373. if (previousNewFiber === null) {
  11374. // TODO: Move out of the loop. This only happens for the first run.
  11375. resultingFirstChild = newFiber;
  11376. } else {
  11377. // TODO: Defer siblings if we're not at the right index for this slot.
  11378. // I.e. if we had null values before, then we want to defer this
  11379. // for each null value. However, we also don't want to call updateSlot
  11380. // with the previous one.
  11381. previousNewFiber.sibling = newFiber;
  11382. }
  11383. previousNewFiber = newFiber;
  11384. oldFiber = nextOldFiber;
  11385. }
  11386. if (newIdx === newChildren.length) {
  11387. // We've reached the end of the new children. We can delete the rest.
  11388. deleteRemainingChildren(returnFiber, oldFiber);
  11389. return resultingFirstChild;
  11390. }
  11391. if (oldFiber === null) {
  11392. // If we don't have any more existing children we can choose a fast path
  11393. // since the rest will all be insertions.
  11394. for (; newIdx < newChildren.length; newIdx++) {
  11395. var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);
  11396. if (_newFiber === null) {
  11397. continue;
  11398. }
  11399. lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);
  11400. if (previousNewFiber === null) {
  11401. // TODO: Move out of the loop. This only happens for the first run.
  11402. resultingFirstChild = _newFiber;
  11403. } else {
  11404. previousNewFiber.sibling = _newFiber;
  11405. }
  11406. previousNewFiber = _newFiber;
  11407. }
  11408. return resultingFirstChild;
  11409. } // Add all children to a key map for quick lookups.
  11410. var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.
  11411. for (; newIdx < newChildren.length; newIdx++) {
  11412. var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);
  11413. if (_newFiber2 !== null) {
  11414. if (shouldTrackSideEffects) {
  11415. if (_newFiber2.alternate !== null) {
  11416. // The new fiber is a work in progress, but if there exists a
  11417. // current, that means that we reused the fiber. We need to delete
  11418. // it from the child list so that we don't add it to the deletion
  11419. // list.
  11420. existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);
  11421. }
  11422. }
  11423. lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);
  11424. if (previousNewFiber === null) {
  11425. resultingFirstChild = _newFiber2;
  11426. } else {
  11427. previousNewFiber.sibling = _newFiber2;
  11428. }
  11429. previousNewFiber = _newFiber2;
  11430. }
  11431. }
  11432. if (shouldTrackSideEffects) {
  11433. // Any existing children that weren't consumed above were deleted. We need
  11434. // to add them to the deletion list.
  11435. existingChildren.forEach(function (child) {
  11436. return deleteChild(returnFiber, child);
  11437. });
  11438. }
  11439. return resultingFirstChild;
  11440. }
  11441. function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {
  11442. // This is the same implementation as reconcileChildrenArray(),
  11443. // but using the iterator instead.
  11444. var iteratorFn = getIteratorFn(newChildrenIterable);
  11445. if (!(typeof iteratorFn === 'function')) {
  11446. {
  11447. throw Error( "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." );
  11448. }
  11449. }
  11450. {
  11451. // We don't support rendering Generators because it's a mutation.
  11452. // See https://github.com/facebook/react/issues/12995
  11453. if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag
  11454. newChildrenIterable[Symbol.toStringTag] === 'Generator') {
  11455. if (!didWarnAboutGenerators) {
  11456. error('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.');
  11457. }
  11458. didWarnAboutGenerators = true;
  11459. } // Warn about using Maps as children
  11460. if (newChildrenIterable.entries === iteratorFn) {
  11461. if (!didWarnAboutMaps) {
  11462. error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');
  11463. }
  11464. didWarnAboutMaps = true;
  11465. } // First, validate keys.
  11466. // We'll get a different iterator later for the main pass.
  11467. var _newChildren = iteratorFn.call(newChildrenIterable);
  11468. if (_newChildren) {
  11469. var knownKeys = null;
  11470. var _step = _newChildren.next();
  11471. for (; !_step.done; _step = _newChildren.next()) {
  11472. var child = _step.value;
  11473. knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);
  11474. }
  11475. }
  11476. }
  11477. var newChildren = iteratorFn.call(newChildrenIterable);
  11478. if (!(newChildren != null)) {
  11479. {
  11480. throw Error( "An iterable object provided no iterator." );
  11481. }
  11482. }
  11483. var resultingFirstChild = null;
  11484. var previousNewFiber = null;
  11485. var oldFiber = currentFirstChild;
  11486. var lastPlacedIndex = 0;
  11487. var newIdx = 0;
  11488. var nextOldFiber = null;
  11489. var step = newChildren.next();
  11490. for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {
  11491. if (oldFiber.index > newIdx) {
  11492. nextOldFiber = oldFiber;
  11493. oldFiber = null;
  11494. } else {
  11495. nextOldFiber = oldFiber.sibling;
  11496. }
  11497. var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);
  11498. if (newFiber === null) {
  11499. // TODO: This breaks on empty slots like null children. That's
  11500. // unfortunate because it triggers the slow path all the time. We need
  11501. // a better way to communicate whether this was a miss or null,
  11502. // boolean, undefined, etc.
  11503. if (oldFiber === null) {
  11504. oldFiber = nextOldFiber;
  11505. }
  11506. break;
  11507. }
  11508. if (shouldTrackSideEffects) {
  11509. if (oldFiber && newFiber.alternate === null) {
  11510. // We matched the slot, but we didn't reuse the existing fiber, so we
  11511. // need to delete the existing child.
  11512. deleteChild(returnFiber, oldFiber);
  11513. }
  11514. }
  11515. lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
  11516. if (previousNewFiber === null) {
  11517. // TODO: Move out of the loop. This only happens for the first run.
  11518. resultingFirstChild = newFiber;
  11519. } else {
  11520. // TODO: Defer siblings if we're not at the right index for this slot.
  11521. // I.e. if we had null values before, then we want to defer this
  11522. // for each null value. However, we also don't want to call updateSlot
  11523. // with the previous one.
  11524. previousNewFiber.sibling = newFiber;
  11525. }
  11526. previousNewFiber = newFiber;
  11527. oldFiber = nextOldFiber;
  11528. }
  11529. if (step.done) {
  11530. // We've reached the end of the new children. We can delete the rest.
  11531. deleteRemainingChildren(returnFiber, oldFiber);
  11532. return resultingFirstChild;
  11533. }
  11534. if (oldFiber === null) {
  11535. // If we don't have any more existing children we can choose a fast path
  11536. // since the rest will all be insertions.
  11537. for (; !step.done; newIdx++, step = newChildren.next()) {
  11538. var _newFiber3 = createChild(returnFiber, step.value, lanes);
  11539. if (_newFiber3 === null) {
  11540. continue;
  11541. }
  11542. lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);
  11543. if (previousNewFiber === null) {
  11544. // TODO: Move out of the loop. This only happens for the first run.
  11545. resultingFirstChild = _newFiber3;
  11546. } else {
  11547. previousNewFiber.sibling = _newFiber3;
  11548. }
  11549. previousNewFiber = _newFiber3;
  11550. }
  11551. return resultingFirstChild;
  11552. } // Add all children to a key map for quick lookups.
  11553. var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves.
  11554. for (; !step.done; newIdx++, step = newChildren.next()) {
  11555. var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);
  11556. if (_newFiber4 !== null) {
  11557. if (shouldTrackSideEffects) {
  11558. if (_newFiber4.alternate !== null) {
  11559. // The new fiber is a work in progress, but if there exists a
  11560. // current, that means that we reused the fiber. We need to delete
  11561. // it from the child list so that we don't add it to the deletion
  11562. // list.
  11563. existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);
  11564. }
  11565. }
  11566. lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);
  11567. if (previousNewFiber === null) {
  11568. resultingFirstChild = _newFiber4;
  11569. } else {
  11570. previousNewFiber.sibling = _newFiber4;
  11571. }
  11572. previousNewFiber = _newFiber4;
  11573. }
  11574. }
  11575. if (shouldTrackSideEffects) {
  11576. // Any existing children that weren't consumed above were deleted. We need
  11577. // to add them to the deletion list.
  11578. existingChildren.forEach(function (child) {
  11579. return deleteChild(returnFiber, child);
  11580. });
  11581. }
  11582. return resultingFirstChild;
  11583. }
  11584. function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {
  11585. // There's no need to check for keys on text nodes since we don't have a
  11586. // way to define them.
  11587. if (currentFirstChild !== null && currentFirstChild.tag === HostText) {
  11588. // We already have an existing node so let's just update it and delete
  11589. // the rest.
  11590. deleteRemainingChildren(returnFiber, currentFirstChild.sibling);
  11591. var existing = useFiber(currentFirstChild, textContent);
  11592. existing.return = returnFiber;
  11593. return existing;
  11594. } // The existing first child is not a text node so we need to create one
  11595. // and delete the existing ones.
  11596. deleteRemainingChildren(returnFiber, currentFirstChild);
  11597. var created = createFiberFromText(textContent, returnFiber.mode, lanes);
  11598. created.return = returnFiber;
  11599. return created;
  11600. }
  11601. function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {
  11602. var key = element.key;
  11603. var child = currentFirstChild;
  11604. while (child !== null) {
  11605. // TODO: If key === null and child.key === null, then this only applies to
  11606. // the first item in the list.
  11607. if (child.key === key) {
  11608. switch (child.tag) {
  11609. case Fragment:
  11610. {
  11611. if (element.type === REACT_FRAGMENT_TYPE) {
  11612. deleteRemainingChildren(returnFiber, child.sibling);
  11613. var existing = useFiber(child, element.props.children);
  11614. existing.return = returnFiber;
  11615. {
  11616. existing._debugSource = element._source;
  11617. existing._debugOwner = element._owner;
  11618. }
  11619. return existing;
  11620. }
  11621. break;
  11622. }
  11623. case Block:
  11624. // We intentionally fallthrough here if enableBlocksAPI is not on.
  11625. // eslint-disable-next-lined no-fallthrough
  11626. default:
  11627. {
  11628. if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path:
  11629. isCompatibleFamilyForHotReloading(child, element) )) {
  11630. deleteRemainingChildren(returnFiber, child.sibling);
  11631. var _existing3 = useFiber(child, element.props);
  11632. _existing3.ref = coerceRef(returnFiber, child, element);
  11633. _existing3.return = returnFiber;
  11634. {
  11635. _existing3._debugSource = element._source;
  11636. _existing3._debugOwner = element._owner;
  11637. }
  11638. return _existing3;
  11639. }
  11640. break;
  11641. }
  11642. } // Didn't match.
  11643. deleteRemainingChildren(returnFiber, child);
  11644. break;
  11645. } else {
  11646. deleteChild(returnFiber, child);
  11647. }
  11648. child = child.sibling;
  11649. }
  11650. if (element.type === REACT_FRAGMENT_TYPE) {
  11651. var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);
  11652. created.return = returnFiber;
  11653. return created;
  11654. } else {
  11655. var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);
  11656. _created4.ref = coerceRef(returnFiber, currentFirstChild, element);
  11657. _created4.return = returnFiber;
  11658. return _created4;
  11659. }
  11660. }
  11661. function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {
  11662. var key = portal.key;
  11663. var child = currentFirstChild;
  11664. while (child !== null) {
  11665. // TODO: If key === null and child.key === null, then this only applies to
  11666. // the first item in the list.
  11667. if (child.key === key) {
  11668. if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {
  11669. deleteRemainingChildren(returnFiber, child.sibling);
  11670. var existing = useFiber(child, portal.children || []);
  11671. existing.return = returnFiber;
  11672. return existing;
  11673. } else {
  11674. deleteRemainingChildren(returnFiber, child);
  11675. break;
  11676. }
  11677. } else {
  11678. deleteChild(returnFiber, child);
  11679. }
  11680. child = child.sibling;
  11681. }
  11682. var created = createFiberFromPortal(portal, returnFiber.mode, lanes);
  11683. created.return = returnFiber;
  11684. return created;
  11685. } // This API will tag the children with the side-effect of the reconciliation
  11686. // itself. They will be added to the side-effect list as we pass through the
  11687. // children and the parent.
  11688. function reconcileChildFibers(returnFiber, currentFirstChild, newChild, lanes) {
  11689. // This function is not recursive.
  11690. // If the top level item is an array, we treat it as a set of children,
  11691. // not as a fragment. Nested arrays on the other hand will be treated as
  11692. // fragment nodes. Recursion happens at the normal flow.
  11693. // Handle top level unkeyed fragments as if they were arrays.
  11694. // This leads to an ambiguity between <>{[...]}</> and <>...</>.
  11695. // We treat the ambiguous cases above the same.
  11696. var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;
  11697. if (isUnkeyedTopLevelFragment) {
  11698. newChild = newChild.props.children;
  11699. } // Handle object types
  11700. var isObject = typeof newChild === 'object' && newChild !== null;
  11701. if (isObject) {
  11702. switch (newChild.$$typeof) {
  11703. case REACT_ELEMENT_TYPE:
  11704. return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));
  11705. case REACT_PORTAL_TYPE:
  11706. return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));
  11707. }
  11708. }
  11709. if (typeof newChild === 'string' || typeof newChild === 'number') {
  11710. return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, lanes));
  11711. }
  11712. if (isArray$1(newChild)) {
  11713. return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);
  11714. }
  11715. if (getIteratorFn(newChild)) {
  11716. return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);
  11717. }
  11718. if (isObject) {
  11719. throwOnInvalidObjectType(returnFiber, newChild);
  11720. }
  11721. {
  11722. if (typeof newChild === 'function') {
  11723. warnOnFunctionType(returnFiber);
  11724. }
  11725. }
  11726. if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {
  11727. // If the new child is undefined, and the return fiber is a composite
  11728. // component, throw an error. If Fiber return types are disabled,
  11729. // we already threw above.
  11730. switch (returnFiber.tag) {
  11731. case ClassComponent:
  11732. {
  11733. {
  11734. var instance = returnFiber.stateNode;
  11735. if (instance.render._isMockFunction) {
  11736. // We allow auto-mocks to proceed as if they're returning null.
  11737. break;
  11738. }
  11739. }
  11740. }
  11741. // Intentionally fall through to the next case, which handles both
  11742. // functions and classes
  11743. // eslint-disable-next-lined no-fallthrough
  11744. case Block:
  11745. case FunctionComponent:
  11746. case ForwardRef:
  11747. case SimpleMemoComponent:
  11748. {
  11749. {
  11750. {
  11751. throw Error( (getComponentName(returnFiber.type) || 'Component') + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." );
  11752. }
  11753. }
  11754. }
  11755. }
  11756. } // Remaining cases are all treated as empty.
  11757. return deleteRemainingChildren(returnFiber, currentFirstChild);
  11758. }
  11759. return reconcileChildFibers;
  11760. }
  11761. var reconcileChildFibers = ChildReconciler(true);
  11762. var mountChildFibers = ChildReconciler(false);
  11763. function cloneChildFibers(current, workInProgress) {
  11764. if (!(current === null || workInProgress.child === current.child)) {
  11765. {
  11766. throw Error( "Resuming work not yet implemented." );
  11767. }
  11768. }
  11769. if (workInProgress.child === null) {
  11770. return;
  11771. }
  11772. var currentChild = workInProgress.child;
  11773. var newChild = createWorkInProgress(currentChild, currentChild.pendingProps);
  11774. workInProgress.child = newChild;
  11775. newChild.return = workInProgress;
  11776. while (currentChild.sibling !== null) {
  11777. currentChild = currentChild.sibling;
  11778. newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps);
  11779. newChild.return = workInProgress;
  11780. }
  11781. newChild.sibling = null;
  11782. } // Reset a workInProgress child set to prepare it for a second pass.
  11783. function resetChildFibers(workInProgress, lanes) {
  11784. var child = workInProgress.child;
  11785. while (child !== null) {
  11786. resetWorkInProgress(child, lanes);
  11787. child = child.sibling;
  11788. }
  11789. }
  11790. var NO_CONTEXT = {};
  11791. var contextStackCursor$1 = createCursor(NO_CONTEXT);
  11792. var contextFiberStackCursor = createCursor(NO_CONTEXT);
  11793. var rootInstanceStackCursor = createCursor(NO_CONTEXT);
  11794. function requiredContext(c) {
  11795. if (!(c !== NO_CONTEXT)) {
  11796. {
  11797. throw Error( "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." );
  11798. }
  11799. }
  11800. return c;
  11801. }
  11802. function getRootHostContainer() {
  11803. var rootInstance = requiredContext(rootInstanceStackCursor.current);
  11804. return rootInstance;
  11805. }
  11806. function pushHostContainer(fiber, nextRootInstance) {
  11807. // Push current root instance onto the stack;
  11808. // This allows us to reset root when portals are popped.
  11809. push(rootInstanceStackCursor, nextRootInstance, fiber); // Track the context and the Fiber that provided it.
  11810. // This enables us to pop only Fibers that provide unique contexts.
  11811. push(contextFiberStackCursor, fiber, fiber); // Finally, we need to push the host context to the stack.
  11812. // However, we can't just call getRootHostContext() and push it because
  11813. // we'd have a different number of entries on the stack depending on
  11814. // whether getRootHostContext() throws somewhere in renderer code or not.
  11815. // So we push an empty value first. This lets us safely unwind on errors.
  11816. push(contextStackCursor$1, NO_CONTEXT, fiber);
  11817. var nextRootContext = getRootHostContext(nextRootInstance); // Now that we know this function doesn't throw, replace it.
  11818. pop(contextStackCursor$1, fiber);
  11819. push(contextStackCursor$1, nextRootContext, fiber);
  11820. }
  11821. function popHostContainer(fiber) {
  11822. pop(contextStackCursor$1, fiber);
  11823. pop(contextFiberStackCursor, fiber);
  11824. pop(rootInstanceStackCursor, fiber);
  11825. }
  11826. function getHostContext() {
  11827. var context = requiredContext(contextStackCursor$1.current);
  11828. return context;
  11829. }
  11830. function pushHostContext(fiber) {
  11831. var rootInstance = requiredContext(rootInstanceStackCursor.current);
  11832. var context = requiredContext(contextStackCursor$1.current);
  11833. var nextContext = getChildHostContext(context, fiber.type); // Don't push this Fiber's context unless it's unique.
  11834. if (context === nextContext) {
  11835. return;
  11836. } // Track the context and the Fiber that provided it.
  11837. // This enables us to pop only Fibers that provide unique contexts.
  11838. push(contextFiberStackCursor, fiber, fiber);
  11839. push(contextStackCursor$1, nextContext, fiber);
  11840. }
  11841. function popHostContext(fiber) {
  11842. // Do not pop unless this Fiber provided the current context.
  11843. // pushHostContext() only pushes Fibers that provide unique contexts.
  11844. if (contextFiberStackCursor.current !== fiber) {
  11845. return;
  11846. }
  11847. pop(contextStackCursor$1, fiber);
  11848. pop(contextFiberStackCursor, fiber);
  11849. }
  11850. var DefaultSuspenseContext = 0; // The Suspense Context is split into two parts. The lower bits is
  11851. // inherited deeply down the subtree. The upper bits only affect
  11852. // this immediate suspense boundary and gets reset each new
  11853. // boundary or suspense list.
  11854. var SubtreeSuspenseContextMask = 1; // Subtree Flags:
  11855. // InvisibleParentSuspenseContext indicates that one of our parent Suspense
  11856. // boundaries is not currently showing visible main content.
  11857. // Either because it is already showing a fallback or is not mounted at all.
  11858. // We can use this to determine if it is desirable to trigger a fallback at
  11859. // the parent. If not, then we might need to trigger undesirable boundaries
  11860. // and/or suspend the commit to avoid hiding the parent content.
  11861. var InvisibleParentSuspenseContext = 1; // Shallow Flags:
  11862. // ForceSuspenseFallback can be used by SuspenseList to force newly added
  11863. // items into their fallback state during one of the render passes.
  11864. var ForceSuspenseFallback = 2;
  11865. var suspenseStackCursor = createCursor(DefaultSuspenseContext);
  11866. function hasSuspenseContext(parentContext, flag) {
  11867. return (parentContext & flag) !== 0;
  11868. }
  11869. function setDefaultShallowSuspenseContext(parentContext) {
  11870. return parentContext & SubtreeSuspenseContextMask;
  11871. }
  11872. function setShallowSuspenseContext(parentContext, shallowContext) {
  11873. return parentContext & SubtreeSuspenseContextMask | shallowContext;
  11874. }
  11875. function addSubtreeSuspenseContext(parentContext, subtreeContext) {
  11876. return parentContext | subtreeContext;
  11877. }
  11878. function pushSuspenseContext(fiber, newContext) {
  11879. push(suspenseStackCursor, newContext, fiber);
  11880. }
  11881. function popSuspenseContext(fiber) {
  11882. pop(suspenseStackCursor, fiber);
  11883. }
  11884. function shouldCaptureSuspense(workInProgress, hasInvisibleParent) {
  11885. // If it was the primary children that just suspended, capture and render the
  11886. // fallback. Otherwise, don't capture and bubble to the next boundary.
  11887. var nextState = workInProgress.memoizedState;
  11888. if (nextState !== null) {
  11889. if (nextState.dehydrated !== null) {
  11890. // A dehydrated boundary always captures.
  11891. return true;
  11892. }
  11893. return false;
  11894. }
  11895. var props = workInProgress.memoizedProps; // In order to capture, the Suspense component must have a fallback prop.
  11896. if (props.fallback === undefined) {
  11897. return false;
  11898. } // Regular boundaries always capture.
  11899. if (props.unstable_avoidThisFallback !== true) {
  11900. return true;
  11901. } // If it's a boundary we should avoid, then we prefer to bubble up to the
  11902. // parent boundary if it is currently invisible.
  11903. if (hasInvisibleParent) {
  11904. return false;
  11905. } // If the parent is not able to handle it, we must handle it.
  11906. return true;
  11907. }
  11908. function findFirstSuspended(row) {
  11909. var node = row;
  11910. while (node !== null) {
  11911. if (node.tag === SuspenseComponent) {
  11912. var state = node.memoizedState;
  11913. if (state !== null) {
  11914. var dehydrated = state.dehydrated;
  11915. if (dehydrated === null || isSuspenseInstancePending(dehydrated) || isSuspenseInstanceFallback(dehydrated)) {
  11916. return node;
  11917. }
  11918. }
  11919. } else if (node.tag === SuspenseListComponent && // revealOrder undefined can't be trusted because it don't
  11920. // keep track of whether it suspended or not.
  11921. node.memoizedProps.revealOrder !== undefined) {
  11922. var didSuspend = (node.flags & DidCapture) !== NoFlags;
  11923. if (didSuspend) {
  11924. return node;
  11925. }
  11926. } else if (node.child !== null) {
  11927. node.child.return = node;
  11928. node = node.child;
  11929. continue;
  11930. }
  11931. if (node === row) {
  11932. return null;
  11933. }
  11934. while (node.sibling === null) {
  11935. if (node.return === null || node.return === row) {
  11936. return null;
  11937. }
  11938. node = node.return;
  11939. }
  11940. node.sibling.return = node.return;
  11941. node = node.sibling;
  11942. }
  11943. return null;
  11944. }
  11945. var NoFlags$1 =
  11946. /* */
  11947. 0; // Represents whether effect should fire.
  11948. var HasEffect =
  11949. /* */
  11950. 1; // Represents the phase in which the effect (not the clean-up) fires.
  11951. var Layout =
  11952. /* */
  11953. 2;
  11954. var Passive$1 =
  11955. /* */
  11956. 4;
  11957. // This may have been an insertion or a hydration.
  11958. var hydrationParentFiber = null;
  11959. var nextHydratableInstance = null;
  11960. var isHydrating = false;
  11961. function enterHydrationState(fiber) {
  11962. var parentInstance = fiber.stateNode.containerInfo;
  11963. nextHydratableInstance = getFirstHydratableChild(parentInstance);
  11964. hydrationParentFiber = fiber;
  11965. isHydrating = true;
  11966. return true;
  11967. }
  11968. function deleteHydratableInstance(returnFiber, instance) {
  11969. {
  11970. switch (returnFiber.tag) {
  11971. case HostRoot:
  11972. didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance);
  11973. break;
  11974. case HostComponent:
  11975. didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance);
  11976. break;
  11977. }
  11978. }
  11979. var childToDelete = createFiberFromHostInstanceForDeletion();
  11980. childToDelete.stateNode = instance;
  11981. childToDelete.return = returnFiber;
  11982. childToDelete.flags = Deletion; // This might seem like it belongs on progressedFirstDeletion. However,
  11983. // these children are not part of the reconciliation list of children.
  11984. // Even if we abort and rereconcile the children, that will try to hydrate
  11985. // again and the nodes are still in the host tree so these will be
  11986. // recreated.
  11987. if (returnFiber.lastEffect !== null) {
  11988. returnFiber.lastEffect.nextEffect = childToDelete;
  11989. returnFiber.lastEffect = childToDelete;
  11990. } else {
  11991. returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
  11992. }
  11993. }
  11994. function insertNonHydratedInstance(returnFiber, fiber) {
  11995. fiber.flags = fiber.flags & ~Hydrating | Placement;
  11996. {
  11997. switch (returnFiber.tag) {
  11998. case HostRoot:
  11999. {
  12000. var parentContainer = returnFiber.stateNode.containerInfo;
  12001. switch (fiber.tag) {
  12002. case HostComponent:
  12003. var type = fiber.type;
  12004. var props = fiber.pendingProps;
  12005. didNotFindHydratableContainerInstance(parentContainer, type);
  12006. break;
  12007. case HostText:
  12008. var text = fiber.pendingProps;
  12009. didNotFindHydratableContainerTextInstance(parentContainer, text);
  12010. break;
  12011. }
  12012. break;
  12013. }
  12014. case HostComponent:
  12015. {
  12016. var parentType = returnFiber.type;
  12017. var parentProps = returnFiber.memoizedProps;
  12018. var parentInstance = returnFiber.stateNode;
  12019. switch (fiber.tag) {
  12020. case HostComponent:
  12021. var _type = fiber.type;
  12022. var _props = fiber.pendingProps;
  12023. didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type);
  12024. break;
  12025. case HostText:
  12026. var _text = fiber.pendingProps;
  12027. didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text);
  12028. break;
  12029. case SuspenseComponent:
  12030. didNotFindHydratableSuspenseInstance(parentType, parentProps);
  12031. break;
  12032. }
  12033. break;
  12034. }
  12035. default:
  12036. return;
  12037. }
  12038. }
  12039. }
  12040. function tryHydrate(fiber, nextInstance) {
  12041. switch (fiber.tag) {
  12042. case HostComponent:
  12043. {
  12044. var type = fiber.type;
  12045. var props = fiber.pendingProps;
  12046. var instance = canHydrateInstance(nextInstance, type);
  12047. if (instance !== null) {
  12048. fiber.stateNode = instance;
  12049. return true;
  12050. }
  12051. return false;
  12052. }
  12053. case HostText:
  12054. {
  12055. var text = fiber.pendingProps;
  12056. var textInstance = canHydrateTextInstance(nextInstance, text);
  12057. if (textInstance !== null) {
  12058. fiber.stateNode = textInstance;
  12059. return true;
  12060. }
  12061. return false;
  12062. }
  12063. case SuspenseComponent:
  12064. {
  12065. return false;
  12066. }
  12067. default:
  12068. return false;
  12069. }
  12070. }
  12071. function tryToClaimNextHydratableInstance(fiber) {
  12072. if (!isHydrating) {
  12073. return;
  12074. }
  12075. var nextInstance = nextHydratableInstance;
  12076. if (!nextInstance) {
  12077. // Nothing to hydrate. Make it an insertion.
  12078. insertNonHydratedInstance(hydrationParentFiber, fiber);
  12079. isHydrating = false;
  12080. hydrationParentFiber = fiber;
  12081. return;
  12082. }
  12083. var firstAttemptedInstance = nextInstance;
  12084. if (!tryHydrate(fiber, nextInstance)) {
  12085. // If we can't hydrate this instance let's try the next one.
  12086. // We use this as a heuristic. It's based on intuition and not data so it
  12087. // might be flawed or unnecessary.
  12088. nextInstance = getNextHydratableSibling(firstAttemptedInstance);
  12089. if (!nextInstance || !tryHydrate(fiber, nextInstance)) {
  12090. // Nothing to hydrate. Make it an insertion.
  12091. insertNonHydratedInstance(hydrationParentFiber, fiber);
  12092. isHydrating = false;
  12093. hydrationParentFiber = fiber;
  12094. return;
  12095. } // We matched the next one, we'll now assume that the first one was
  12096. // superfluous and we'll delete it. Since we can't eagerly delete it
  12097. // we'll have to schedule a deletion. To do that, this node needs a dummy
  12098. // fiber associated with it.
  12099. deleteHydratableInstance(hydrationParentFiber, firstAttemptedInstance);
  12100. }
  12101. hydrationParentFiber = fiber;
  12102. nextHydratableInstance = getFirstHydratableChild(nextInstance);
  12103. }
  12104. function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) {
  12105. var instance = fiber.stateNode;
  12106. var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber); // TODO: Type this specific to this type of component.
  12107. fiber.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there
  12108. // is a new ref we mark this as an update.
  12109. if (updatePayload !== null) {
  12110. return true;
  12111. }
  12112. return false;
  12113. }
  12114. function prepareToHydrateHostTextInstance(fiber) {
  12115. var textInstance = fiber.stateNode;
  12116. var textContent = fiber.memoizedProps;
  12117. var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber);
  12118. {
  12119. if (shouldUpdate) {
  12120. // We assume that prepareToHydrateHostTextInstance is called in a context where the
  12121. // hydration parent is the parent host component of this host text.
  12122. var returnFiber = hydrationParentFiber;
  12123. if (returnFiber !== null) {
  12124. switch (returnFiber.tag) {
  12125. case HostRoot:
  12126. {
  12127. var parentContainer = returnFiber.stateNode.containerInfo;
  12128. didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent);
  12129. break;
  12130. }
  12131. case HostComponent:
  12132. {
  12133. var parentType = returnFiber.type;
  12134. var parentProps = returnFiber.memoizedProps;
  12135. var parentInstance = returnFiber.stateNode;
  12136. didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent);
  12137. break;
  12138. }
  12139. }
  12140. }
  12141. }
  12142. }
  12143. return shouldUpdate;
  12144. }
  12145. function skipPastDehydratedSuspenseInstance(fiber) {
  12146. var suspenseState = fiber.memoizedState;
  12147. var suspenseInstance = suspenseState !== null ? suspenseState.dehydrated : null;
  12148. if (!suspenseInstance) {
  12149. {
  12150. throw Error( "Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue." );
  12151. }
  12152. }
  12153. return getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
  12154. }
  12155. function popToNextHostParent(fiber) {
  12156. var parent = fiber.return;
  12157. while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== SuspenseComponent) {
  12158. parent = parent.return;
  12159. }
  12160. hydrationParentFiber = parent;
  12161. }
  12162. function popHydrationState(fiber) {
  12163. if (fiber !== hydrationParentFiber) {
  12164. // We're deeper than the current hydration context, inside an inserted
  12165. // tree.
  12166. return false;
  12167. }
  12168. if (!isHydrating) {
  12169. // If we're not currently hydrating but we're in a hydration context, then
  12170. // we were an insertion and now need to pop up reenter hydration of our
  12171. // siblings.
  12172. popToNextHostParent(fiber);
  12173. isHydrating = true;
  12174. return false;
  12175. }
  12176. var type = fiber.type; // If we have any remaining hydratable nodes, we need to delete them now.
  12177. // We only do this deeper than head and body since they tend to have random
  12178. // other nodes in them. We also ignore components with pure text content in
  12179. // side of them.
  12180. // TODO: Better heuristic.
  12181. if (fiber.tag !== HostComponent || type !== 'head' && type !== 'body' && !shouldSetTextContent(type, fiber.memoizedProps)) {
  12182. var nextInstance = nextHydratableInstance;
  12183. while (nextInstance) {
  12184. deleteHydratableInstance(fiber, nextInstance);
  12185. nextInstance = getNextHydratableSibling(nextInstance);
  12186. }
  12187. }
  12188. popToNextHostParent(fiber);
  12189. if (fiber.tag === SuspenseComponent) {
  12190. nextHydratableInstance = skipPastDehydratedSuspenseInstance(fiber);
  12191. } else {
  12192. nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null;
  12193. }
  12194. return true;
  12195. }
  12196. function resetHydrationState() {
  12197. hydrationParentFiber = null;
  12198. nextHydratableInstance = null;
  12199. isHydrating = false;
  12200. }
  12201. function getIsHydrating() {
  12202. return isHydrating;
  12203. }
  12204. // and should be reset before starting a new render.
  12205. // This tracks which mutable sources need to be reset after a render.
  12206. var workInProgressSources = [];
  12207. var rendererSigil$1;
  12208. {
  12209. // Used to detect multiple renderers using the same mutable source.
  12210. rendererSigil$1 = {};
  12211. }
  12212. function markSourceAsDirty(mutableSource) {
  12213. workInProgressSources.push(mutableSource);
  12214. }
  12215. function resetWorkInProgressVersions() {
  12216. for (var i = 0; i < workInProgressSources.length; i++) {
  12217. var mutableSource = workInProgressSources[i];
  12218. {
  12219. mutableSource._workInProgressVersionPrimary = null;
  12220. }
  12221. }
  12222. workInProgressSources.length = 0;
  12223. }
  12224. function getWorkInProgressVersion(mutableSource) {
  12225. {
  12226. return mutableSource._workInProgressVersionPrimary;
  12227. }
  12228. }
  12229. function setWorkInProgressVersion(mutableSource, version) {
  12230. {
  12231. mutableSource._workInProgressVersionPrimary = version;
  12232. }
  12233. workInProgressSources.push(mutableSource);
  12234. }
  12235. function warnAboutMultipleRenderersDEV(mutableSource) {
  12236. {
  12237. {
  12238. if (mutableSource._currentPrimaryRenderer == null) {
  12239. mutableSource._currentPrimaryRenderer = rendererSigil$1;
  12240. } else if (mutableSource._currentPrimaryRenderer !== rendererSigil$1) {
  12241. error('Detected multiple renderers concurrently rendering the ' + 'same mutable source. This is currently unsupported.');
  12242. }
  12243. }
  12244. }
  12245. } // Eager reads the version of a mutable source and stores it on the root.
  12246. var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
  12247. ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig;
  12248. var didWarnAboutMismatchedHooksForComponent;
  12249. var didWarnAboutUseOpaqueIdentifier;
  12250. {
  12251. didWarnAboutUseOpaqueIdentifier = {};
  12252. didWarnAboutMismatchedHooksForComponent = new Set();
  12253. }
  12254. // These are set right before calling the component.
  12255. var renderLanes = NoLanes; // The work-in-progress fiber. I've named it differently to distinguish it from
  12256. // the work-in-progress hook.
  12257. var currentlyRenderingFiber$1 = null; // Hooks are stored as a linked list on the fiber's memoizedState field. The
  12258. // current hook list is the list that belongs to the current fiber. The
  12259. // work-in-progress hook list is a new list that will be added to the
  12260. // work-in-progress fiber.
  12261. var currentHook = null;
  12262. var workInProgressHook = null; // Whether an update was scheduled at any point during the render phase. This
  12263. // does not get reset if we do another render pass; only when we're completely
  12264. // finished evaluating this component. This is an optimization so we know
  12265. // whether we need to clear render phase updates after a throw.
  12266. var didScheduleRenderPhaseUpdate = false; // Where an update was scheduled only during the current render pass. This
  12267. // gets reset after each attempt.
  12268. // TODO: Maybe there's some way to consolidate this with
  12269. // `didScheduleRenderPhaseUpdate`. Or with `numberOfReRenders`.
  12270. var didScheduleRenderPhaseUpdateDuringThisPass = false;
  12271. var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook
  12272. var currentHookNameInDev = null; // In DEV, this list ensures that hooks are called in the same order between renders.
  12273. // The list stores the order of hooks used during the initial render (mount).
  12274. // Subsequent renders (updates) reference this list.
  12275. var hookTypesDev = null;
  12276. var hookTypesUpdateIndexDev = -1; // In DEV, this tracks whether currently rendering component needs to ignore
  12277. // the dependencies for Hooks that need them (e.g. useEffect or useMemo).
  12278. // When true, such Hooks will always be "remounted". Only used during hot reload.
  12279. var ignorePreviousDependencies = false;
  12280. function mountHookTypesDev() {
  12281. {
  12282. var hookName = currentHookNameInDev;
  12283. if (hookTypesDev === null) {
  12284. hookTypesDev = [hookName];
  12285. } else {
  12286. hookTypesDev.push(hookName);
  12287. }
  12288. }
  12289. }
  12290. function updateHookTypesDev() {
  12291. {
  12292. var hookName = currentHookNameInDev;
  12293. if (hookTypesDev !== null) {
  12294. hookTypesUpdateIndexDev++;
  12295. if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
  12296. warnOnHookMismatchInDev(hookName);
  12297. }
  12298. }
  12299. }
  12300. }
  12301. function checkDepsAreArrayDev(deps) {
  12302. {
  12303. if (deps !== undefined && deps !== null && !Array.isArray(deps)) {
  12304. // Verify deps, but only on mount to avoid extra checks.
  12305. // It's unlikely their type would change as usually you define them inline.
  12306. error('%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);
  12307. }
  12308. }
  12309. }
  12310. function warnOnHookMismatchInDev(currentHookName) {
  12311. {
  12312. var componentName = getComponentName(currentlyRenderingFiber$1.type);
  12313. if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
  12314. didWarnAboutMismatchedHooksForComponent.add(componentName);
  12315. if (hookTypesDev !== null) {
  12316. var table = '';
  12317. var secondColumnStart = 30;
  12318. for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
  12319. var oldHookName = hookTypesDev[i];
  12320. var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
  12321. var row = i + 1 + ". " + oldHookName; // Extra space so second column lines up
  12322. // lol @ IE not supporting String#repeat
  12323. while (row.length < secondColumnStart) {
  12324. row += ' ';
  12325. }
  12326. row += newHookName + '\n';
  12327. table += row;
  12328. }
  12329. error('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://reactjs.org/link/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' ------------------------------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table);
  12330. }
  12331. }
  12332. }
  12333. }
  12334. function throwInvalidHookError() {
  12335. {
  12336. {
  12337. throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." );
  12338. }
  12339. }
  12340. }
  12341. function areHookInputsEqual(nextDeps, prevDeps) {
  12342. {
  12343. if (ignorePreviousDependencies) {
  12344. // Only true when this component is being hot reloaded.
  12345. return false;
  12346. }
  12347. }
  12348. if (prevDeps === null) {
  12349. {
  12350. error('%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);
  12351. }
  12352. return false;
  12353. }
  12354. {
  12355. // Don't bother comparing lengths in prod because these arrays should be
  12356. // passed inline.
  12357. if (nextDeps.length !== prevDeps.length) {
  12358. error('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(', ') + "]");
  12359. }
  12360. }
  12361. for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
  12362. if (objectIs(nextDeps[i], prevDeps[i])) {
  12363. continue;
  12364. }
  12365. return false;
  12366. }
  12367. return true;
  12368. }
  12369. function renderWithHooks(current, workInProgress, Component, props, secondArg, nextRenderLanes) {
  12370. renderLanes = nextRenderLanes;
  12371. currentlyRenderingFiber$1 = workInProgress;
  12372. {
  12373. hookTypesDev = current !== null ? current._debugHookTypes : null;
  12374. hookTypesUpdateIndexDev = -1; // Used for hot reloading:
  12375. ignorePreviousDependencies = current !== null && current.type !== workInProgress.type;
  12376. }
  12377. workInProgress.memoizedState = null;
  12378. workInProgress.updateQueue = null;
  12379. workInProgress.lanes = NoLanes; // The following should have already been reset
  12380. // currentHook = null;
  12381. // workInProgressHook = null;
  12382. // didScheduleRenderPhaseUpdate = false;
  12383. // TODO Warn if no hooks are used at all during mount, then some are used during update.
  12384. // Currently we will identify the update render as a mount because memoizedState === null.
  12385. // This is tricky because it's valid for certain types of components (e.g. React.lazy)
  12386. // Using memoizedState to differentiate between mount/update only works if at least one stateful hook is used.
  12387. // Non-stateful hooks (e.g. context) don't get added to memoizedState,
  12388. // so memoizedState would be null during updates and mounts.
  12389. {
  12390. if (current !== null && current.memoizedState !== null) {
  12391. ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
  12392. } else if (hookTypesDev !== null) {
  12393. // This dispatcher handles an edge case where a component is updating,
  12394. // but no stateful hooks have been used.
  12395. // We want to match the production code behavior (which will use HooksDispatcherOnMount),
  12396. // but with the extra DEV validation to ensure hooks ordering hasn't changed.
  12397. // This dispatcher does that.
  12398. ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
  12399. } else {
  12400. ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
  12401. }
  12402. }
  12403. var children = Component(props, secondArg); // Check if there was a render phase update
  12404. if (didScheduleRenderPhaseUpdateDuringThisPass) {
  12405. // Keep rendering in a loop for as long as render phase updates continue to
  12406. // be scheduled. Use a counter to prevent infinite loops.
  12407. var numberOfReRenders = 0;
  12408. do {
  12409. didScheduleRenderPhaseUpdateDuringThisPass = false;
  12410. if (!(numberOfReRenders < RE_RENDER_LIMIT)) {
  12411. {
  12412. throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." );
  12413. }
  12414. }
  12415. numberOfReRenders += 1;
  12416. {
  12417. // Even when hot reloading, allow dependencies to stabilize
  12418. // after first render to prevent infinite render phase updates.
  12419. ignorePreviousDependencies = false;
  12420. } // Start over from the beginning of the list
  12421. currentHook = null;
  12422. workInProgressHook = null;
  12423. workInProgress.updateQueue = null;
  12424. {
  12425. // Also validate hook order for cascading updates.
  12426. hookTypesUpdateIndexDev = -1;
  12427. }
  12428. ReactCurrentDispatcher$1.current = HooksDispatcherOnRerenderInDEV ;
  12429. children = Component(props, secondArg);
  12430. } while (didScheduleRenderPhaseUpdateDuringThisPass);
  12431. } // We can assume the previous dispatcher is always this one, since we set it
  12432. // at the beginning of the render phase and there's no re-entrancy.
  12433. ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
  12434. {
  12435. workInProgress._debugHookTypes = hookTypesDev;
  12436. } // This check uses currentHook so that it works the same in DEV and prod bundles.
  12437. // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles.
  12438. var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
  12439. renderLanes = NoLanes;
  12440. currentlyRenderingFiber$1 = null;
  12441. currentHook = null;
  12442. workInProgressHook = null;
  12443. {
  12444. currentHookNameInDev = null;
  12445. hookTypesDev = null;
  12446. hookTypesUpdateIndexDev = -1;
  12447. }
  12448. didScheduleRenderPhaseUpdate = false;
  12449. if (!!didRenderTooFewHooks) {
  12450. {
  12451. throw Error( "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." );
  12452. }
  12453. }
  12454. return children;
  12455. }
  12456. function bailoutHooks(current, workInProgress, lanes) {
  12457. workInProgress.updateQueue = current.updateQueue;
  12458. workInProgress.flags &= ~(Passive | Update);
  12459. current.lanes = removeLanes(current.lanes, lanes);
  12460. }
  12461. function resetHooksAfterThrow() {
  12462. // We can assume the previous dispatcher is always this one, since we set it
  12463. // at the beginning of the render phase and there's no re-entrancy.
  12464. ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
  12465. if (didScheduleRenderPhaseUpdate) {
  12466. // There were render phase updates. These are only valid for this render
  12467. // phase, which we are now aborting. Remove the updates from the queues so
  12468. // they do not persist to the next render. Do not remove updates from hooks
  12469. // that weren't processed.
  12470. //
  12471. // Only reset the updates from the queue if it has a clone. If it does
  12472. // not have a clone, that means it wasn't processed, and the updates were
  12473. // scheduled before we entered the render phase.
  12474. var hook = currentlyRenderingFiber$1.memoizedState;
  12475. while (hook !== null) {
  12476. var queue = hook.queue;
  12477. if (queue !== null) {
  12478. queue.pending = null;
  12479. }
  12480. hook = hook.next;
  12481. }
  12482. didScheduleRenderPhaseUpdate = false;
  12483. }
  12484. renderLanes = NoLanes;
  12485. currentlyRenderingFiber$1 = null;
  12486. currentHook = null;
  12487. workInProgressHook = null;
  12488. {
  12489. hookTypesDev = null;
  12490. hookTypesUpdateIndexDev = -1;
  12491. currentHookNameInDev = null;
  12492. isUpdatingOpaqueValueInRenderPhase = false;
  12493. }
  12494. didScheduleRenderPhaseUpdateDuringThisPass = false;
  12495. }
  12496. function mountWorkInProgressHook() {
  12497. var hook = {
  12498. memoizedState: null,
  12499. baseState: null,
  12500. baseQueue: null,
  12501. queue: null,
  12502. next: null
  12503. };
  12504. if (workInProgressHook === null) {
  12505. // This is the first hook in the list
  12506. currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook;
  12507. } else {
  12508. // Append to the end of the list
  12509. workInProgressHook = workInProgressHook.next = hook;
  12510. }
  12511. return workInProgressHook;
  12512. }
  12513. function updateWorkInProgressHook() {
  12514. // This function is used both for updates and for re-renders triggered by a
  12515. // render phase update. It assumes there is either a current hook we can
  12516. // clone, or a work-in-progress hook from a previous render pass that we can
  12517. // use as a base. When we reach the end of the base list, we must switch to
  12518. // the dispatcher used for mounts.
  12519. var nextCurrentHook;
  12520. if (currentHook === null) {
  12521. var current = currentlyRenderingFiber$1.alternate;
  12522. if (current !== null) {
  12523. nextCurrentHook = current.memoizedState;
  12524. } else {
  12525. nextCurrentHook = null;
  12526. }
  12527. } else {
  12528. nextCurrentHook = currentHook.next;
  12529. }
  12530. var nextWorkInProgressHook;
  12531. if (workInProgressHook === null) {
  12532. nextWorkInProgressHook = currentlyRenderingFiber$1.memoizedState;
  12533. } else {
  12534. nextWorkInProgressHook = workInProgressHook.next;
  12535. }
  12536. if (nextWorkInProgressHook !== null) {
  12537. // There's already a work-in-progress. Reuse it.
  12538. workInProgressHook = nextWorkInProgressHook;
  12539. nextWorkInProgressHook = workInProgressHook.next;
  12540. currentHook = nextCurrentHook;
  12541. } else {
  12542. // Clone from the current hook.
  12543. if (!(nextCurrentHook !== null)) {
  12544. {
  12545. throw Error( "Rendered more hooks than during the previous render." );
  12546. }
  12547. }
  12548. currentHook = nextCurrentHook;
  12549. var newHook = {
  12550. memoizedState: currentHook.memoizedState,
  12551. baseState: currentHook.baseState,
  12552. baseQueue: currentHook.baseQueue,
  12553. queue: currentHook.queue,
  12554. next: null
  12555. };
  12556. if (workInProgressHook === null) {
  12557. // This is the first hook in the list.
  12558. currentlyRenderingFiber$1.memoizedState = workInProgressHook = newHook;
  12559. } else {
  12560. // Append to the end of the list.
  12561. workInProgressHook = workInProgressHook.next = newHook;
  12562. }
  12563. }
  12564. return workInProgressHook;
  12565. }
  12566. function createFunctionComponentUpdateQueue() {
  12567. return {
  12568. lastEffect: null
  12569. };
  12570. }
  12571. function basicStateReducer(state, action) {
  12572. // $FlowFixMe: Flow doesn't like mixed types
  12573. return typeof action === 'function' ? action(state) : action;
  12574. }
  12575. function mountReducer(reducer, initialArg, init) {
  12576. var hook = mountWorkInProgressHook();
  12577. var initialState;
  12578. if (init !== undefined) {
  12579. initialState = init(initialArg);
  12580. } else {
  12581. initialState = initialArg;
  12582. }
  12583. hook.memoizedState = hook.baseState = initialState;
  12584. var queue = hook.queue = {
  12585. pending: null,
  12586. dispatch: null,
  12587. lastRenderedReducer: reducer,
  12588. lastRenderedState: initialState
  12589. };
  12590. var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue);
  12591. return [hook.memoizedState, dispatch];
  12592. }
  12593. function updateReducer(reducer, initialArg, init) {
  12594. var hook = updateWorkInProgressHook();
  12595. var queue = hook.queue;
  12596. if (!(queue !== null)) {
  12597. {
  12598. throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." );
  12599. }
  12600. }
  12601. queue.lastRenderedReducer = reducer;
  12602. var current = currentHook; // The last rebase update that is NOT part of the base state.
  12603. var baseQueue = current.baseQueue; // The last pending update that hasn't been processed yet.
  12604. var pendingQueue = queue.pending;
  12605. if (pendingQueue !== null) {
  12606. // We have new updates that haven't been processed yet.
  12607. // We'll add them to the base queue.
  12608. if (baseQueue !== null) {
  12609. // Merge the pending queue and the base queue.
  12610. var baseFirst = baseQueue.next;
  12611. var pendingFirst = pendingQueue.next;
  12612. baseQueue.next = pendingFirst;
  12613. pendingQueue.next = baseFirst;
  12614. }
  12615. {
  12616. if (current.baseQueue !== baseQueue) {
  12617. // Internal invariant that should never happen, but feasibly could in
  12618. // the future if we implement resuming, or some form of that.
  12619. error('Internal error: Expected work-in-progress queue to be a clone. ' + 'This is a bug in React.');
  12620. }
  12621. }
  12622. current.baseQueue = baseQueue = pendingQueue;
  12623. queue.pending = null;
  12624. }
  12625. if (baseQueue !== null) {
  12626. // We have a queue to process.
  12627. var first = baseQueue.next;
  12628. var newState = current.baseState;
  12629. var newBaseState = null;
  12630. var newBaseQueueFirst = null;
  12631. var newBaseQueueLast = null;
  12632. var update = first;
  12633. do {
  12634. var updateLane = update.lane;
  12635. if (!isSubsetOfLanes(renderLanes, updateLane)) {
  12636. // Priority is insufficient. Skip this update. If this is the first
  12637. // skipped update, the previous update/state is the new base
  12638. // update/state.
  12639. var clone = {
  12640. lane: updateLane,
  12641. action: update.action,
  12642. eagerReducer: update.eagerReducer,
  12643. eagerState: update.eagerState,
  12644. next: null
  12645. };
  12646. if (newBaseQueueLast === null) {
  12647. newBaseQueueFirst = newBaseQueueLast = clone;
  12648. newBaseState = newState;
  12649. } else {
  12650. newBaseQueueLast = newBaseQueueLast.next = clone;
  12651. } // Update the remaining priority in the queue.
  12652. // TODO: Don't need to accumulate this. Instead, we can remove
  12653. // renderLanes from the original lanes.
  12654. currentlyRenderingFiber$1.lanes = mergeLanes(currentlyRenderingFiber$1.lanes, updateLane);
  12655. markSkippedUpdateLanes(updateLane);
  12656. } else {
  12657. // This update does have sufficient priority.
  12658. if (newBaseQueueLast !== null) {
  12659. var _clone = {
  12660. // This update is going to be committed so we never want uncommit
  12661. // it. Using NoLane works because 0 is a subset of all bitmasks, so
  12662. // this will never be skipped by the check above.
  12663. lane: NoLane,
  12664. action: update.action,
  12665. eagerReducer: update.eagerReducer,
  12666. eagerState: update.eagerState,
  12667. next: null
  12668. };
  12669. newBaseQueueLast = newBaseQueueLast.next = _clone;
  12670. } // Process this update.
  12671. if (update.eagerReducer === reducer) {
  12672. // If this update was processed eagerly, and its reducer matches the
  12673. // current reducer, we can use the eagerly computed state.
  12674. newState = update.eagerState;
  12675. } else {
  12676. var action = update.action;
  12677. newState = reducer(newState, action);
  12678. }
  12679. }
  12680. update = update.next;
  12681. } while (update !== null && update !== first);
  12682. if (newBaseQueueLast === null) {
  12683. newBaseState = newState;
  12684. } else {
  12685. newBaseQueueLast.next = newBaseQueueFirst;
  12686. } // Mark that the fiber performed work, but only if the new state is
  12687. // different from the current state.
  12688. if (!objectIs(newState, hook.memoizedState)) {
  12689. markWorkInProgressReceivedUpdate();
  12690. }
  12691. hook.memoizedState = newState;
  12692. hook.baseState = newBaseState;
  12693. hook.baseQueue = newBaseQueueLast;
  12694. queue.lastRenderedState = newState;
  12695. }
  12696. var dispatch = queue.dispatch;
  12697. return [hook.memoizedState, dispatch];
  12698. }
  12699. function rerenderReducer(reducer, initialArg, init) {
  12700. var hook = updateWorkInProgressHook();
  12701. var queue = hook.queue;
  12702. if (!(queue !== null)) {
  12703. {
  12704. throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." );
  12705. }
  12706. }
  12707. queue.lastRenderedReducer = reducer; // This is a re-render. Apply the new render phase updates to the previous
  12708. // work-in-progress hook.
  12709. var dispatch = queue.dispatch;
  12710. var lastRenderPhaseUpdate = queue.pending;
  12711. var newState = hook.memoizedState;
  12712. if (lastRenderPhaseUpdate !== null) {
  12713. // The queue doesn't persist past this render pass.
  12714. queue.pending = null;
  12715. var firstRenderPhaseUpdate = lastRenderPhaseUpdate.next;
  12716. var update = firstRenderPhaseUpdate;
  12717. do {
  12718. // Process this render phase update. We don't have to check the
  12719. // priority because it will always be the same as the current
  12720. // render's.
  12721. var action = update.action;
  12722. newState = reducer(newState, action);
  12723. update = update.next;
  12724. } while (update !== firstRenderPhaseUpdate); // Mark that the fiber performed work, but only if the new state is
  12725. // different from the current state.
  12726. if (!objectIs(newState, hook.memoizedState)) {
  12727. markWorkInProgressReceivedUpdate();
  12728. }
  12729. hook.memoizedState = newState; // Don't persist the state accumulated from the render phase updates to
  12730. // the base state unless the queue is empty.
  12731. // TODO: Not sure if this is the desired semantics, but it's what we
  12732. // do for gDSFP. I can't remember why.
  12733. if (hook.baseQueue === null) {
  12734. hook.baseState = newState;
  12735. }
  12736. queue.lastRenderedState = newState;
  12737. }
  12738. return [newState, dispatch];
  12739. }
  12740. function readFromUnsubcribedMutableSource(root, source, getSnapshot) {
  12741. {
  12742. warnAboutMultipleRenderersDEV(source);
  12743. }
  12744. var getVersion = source._getVersion;
  12745. var version = getVersion(source._source); // Is it safe for this component to read from this source during the current render?
  12746. var isSafeToReadFromSource = false; // Check the version first.
  12747. // If this render has already been started with a specific version,
  12748. // we can use it alone to determine if we can safely read from the source.
  12749. var currentRenderVersion = getWorkInProgressVersion(source);
  12750. if (currentRenderVersion !== null) {
  12751. // It's safe to read if the store hasn't been mutated since the last time
  12752. // we read something.
  12753. isSafeToReadFromSource = currentRenderVersion === version;
  12754. } else {
  12755. // If there's no version, then this is the first time we've read from the
  12756. // source during the current render pass, so we need to do a bit more work.
  12757. // What we need to determine is if there are any hooks that already
  12758. // subscribed to the source, and if so, whether there are any pending
  12759. // mutations that haven't been synchronized yet.
  12760. //
  12761. // If there are no pending mutations, then `root.mutableReadLanes` will be
  12762. // empty, and we know we can safely read.
  12763. //
  12764. // If there *are* pending mutations, we may still be able to safely read
  12765. // if the currently rendering lanes are inclusive of the pending mutation
  12766. // lanes, since that guarantees that the value we're about to read from
  12767. // the source is consistent with the values that we read during the most
  12768. // recent mutation.
  12769. isSafeToReadFromSource = isSubsetOfLanes(renderLanes, root.mutableReadLanes);
  12770. if (isSafeToReadFromSource) {
  12771. // If it's safe to read from this source during the current render,
  12772. // store the version in case other components read from it.
  12773. // A changed version number will let those components know to throw and restart the render.
  12774. setWorkInProgressVersion(source, version);
  12775. }
  12776. }
  12777. if (isSafeToReadFromSource) {
  12778. var snapshot = getSnapshot(source._source);
  12779. {
  12780. if (typeof snapshot === 'function') {
  12781. error('Mutable source should not return a function as the snapshot value. ' + 'Functions may close over mutable values and cause tearing.');
  12782. }
  12783. }
  12784. return snapshot;
  12785. } else {
  12786. // This handles the special case of a mutable source being shared between renderers.
  12787. // In that case, if the source is mutated between the first and second renderer,
  12788. // The second renderer don't know that it needs to reset the WIP version during unwind,
  12789. // (because the hook only marks sources as dirty if it's written to their WIP version).
  12790. // That would cause this tear check to throw again and eventually be visible to the user.
  12791. // We can avoid this infinite loop by explicitly marking the source as dirty.
  12792. //
  12793. // This can lead to tearing in the first renderer when it resumes,
  12794. // but there's nothing we can do about that (short of throwing here and refusing to continue the render).
  12795. markSourceAsDirty(source);
  12796. {
  12797. {
  12798. throw Error( "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue." );
  12799. }
  12800. }
  12801. }
  12802. }
  12803. function useMutableSource(hook, source, getSnapshot, subscribe) {
  12804. var root = getWorkInProgressRoot();
  12805. if (!(root !== null)) {
  12806. {
  12807. throw Error( "Expected a work-in-progress root. This is a bug in React. Please file an issue." );
  12808. }
  12809. }
  12810. var getVersion = source._getVersion;
  12811. var version = getVersion(source._source);
  12812. var dispatcher = ReactCurrentDispatcher$1.current; // eslint-disable-next-line prefer-const
  12813. var _dispatcher$useState = dispatcher.useState(function () {
  12814. return readFromUnsubcribedMutableSource(root, source, getSnapshot);
  12815. }),
  12816. currentSnapshot = _dispatcher$useState[0],
  12817. setSnapshot = _dispatcher$useState[1];
  12818. var snapshot = currentSnapshot; // Grab a handle to the state hook as well.
  12819. // We use it to clear the pending update queue if we have a new source.
  12820. var stateHook = workInProgressHook;
  12821. var memoizedState = hook.memoizedState;
  12822. var refs = memoizedState.refs;
  12823. var prevGetSnapshot = refs.getSnapshot;
  12824. var prevSource = memoizedState.source;
  12825. var prevSubscribe = memoizedState.subscribe;
  12826. var fiber = currentlyRenderingFiber$1;
  12827. hook.memoizedState = {
  12828. refs: refs,
  12829. source: source,
  12830. subscribe: subscribe
  12831. }; // Sync the values needed by our subscription handler after each commit.
  12832. dispatcher.useEffect(function () {
  12833. refs.getSnapshot = getSnapshot; // Normally the dispatch function for a state hook never changes,
  12834. // but this hook recreates the queue in certain cases to avoid updates from stale sources.
  12835. // handleChange() below needs to reference the dispatch function without re-subscribing,
  12836. // so we use a ref to ensure that it always has the latest version.
  12837. refs.setSnapshot = setSnapshot; // Check for a possible change between when we last rendered now.
  12838. var maybeNewVersion = getVersion(source._source);
  12839. if (!objectIs(version, maybeNewVersion)) {
  12840. var maybeNewSnapshot = getSnapshot(source._source);
  12841. {
  12842. if (typeof maybeNewSnapshot === 'function') {
  12843. error('Mutable source should not return a function as the snapshot value. ' + 'Functions may close over mutable values and cause tearing.');
  12844. }
  12845. }
  12846. if (!objectIs(snapshot, maybeNewSnapshot)) {
  12847. setSnapshot(maybeNewSnapshot);
  12848. var lane = requestUpdateLane(fiber);
  12849. markRootMutableRead(root, lane);
  12850. } // If the source mutated between render and now,
  12851. // there may be state updates already scheduled from the old source.
  12852. // Entangle the updates so that they render in the same batch.
  12853. markRootEntangled(root, root.mutableReadLanes);
  12854. }
  12855. }, [getSnapshot, source, subscribe]); // If we got a new source or subscribe function, re-subscribe in a passive effect.
  12856. dispatcher.useEffect(function () {
  12857. var handleChange = function () {
  12858. var latestGetSnapshot = refs.getSnapshot;
  12859. var latestSetSnapshot = refs.setSnapshot;
  12860. try {
  12861. latestSetSnapshot(latestGetSnapshot(source._source)); // Record a pending mutable source update with the same expiration time.
  12862. var lane = requestUpdateLane(fiber);
  12863. markRootMutableRead(root, lane);
  12864. } catch (error) {
  12865. // A selector might throw after a source mutation.
  12866. // e.g. it might try to read from a part of the store that no longer exists.
  12867. // In this case we should still schedule an update with React.
  12868. // Worst case the selector will throw again and then an error boundary will handle it.
  12869. latestSetSnapshot(function () {
  12870. throw error;
  12871. });
  12872. }
  12873. };
  12874. var unsubscribe = subscribe(source._source, handleChange);
  12875. {
  12876. if (typeof unsubscribe !== 'function') {
  12877. error('Mutable source subscribe function must return an unsubscribe function.');
  12878. }
  12879. }
  12880. return unsubscribe;
  12881. }, [source, subscribe]); // If any of the inputs to useMutableSource change, reading is potentially unsafe.
  12882. //
  12883. // If either the source or the subscription have changed we can't can't trust the update queue.
  12884. // Maybe the source changed in a way that the old subscription ignored but the new one depends on.
  12885. //
  12886. // If the getSnapshot function changed, we also shouldn't rely on the update queue.
  12887. // It's possible that the underlying source was mutated between the when the last "change" event fired,
  12888. // and when the current render (with the new getSnapshot function) is processed.
  12889. //
  12890. // In both cases, we need to throw away pending updates (since they are no longer relevant)
  12891. // and treat reading from the source as we do in the mount case.
  12892. if (!objectIs(prevGetSnapshot, getSnapshot) || !objectIs(prevSource, source) || !objectIs(prevSubscribe, subscribe)) {
  12893. // Create a new queue and setState method,
  12894. // So if there are interleaved updates, they get pushed to the older queue.
  12895. // When this becomes current, the previous queue and dispatch method will be discarded,
  12896. // including any interleaving updates that occur.
  12897. var newQueue = {
  12898. pending: null,
  12899. dispatch: null,
  12900. lastRenderedReducer: basicStateReducer,
  12901. lastRenderedState: snapshot
  12902. };
  12903. newQueue.dispatch = setSnapshot = dispatchAction.bind(null, currentlyRenderingFiber$1, newQueue);
  12904. stateHook.queue = newQueue;
  12905. stateHook.baseQueue = null;
  12906. snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot);
  12907. stateHook.memoizedState = stateHook.baseState = snapshot;
  12908. }
  12909. return snapshot;
  12910. }
  12911. function mountMutableSource(source, getSnapshot, subscribe) {
  12912. var hook = mountWorkInProgressHook();
  12913. hook.memoizedState = {
  12914. refs: {
  12915. getSnapshot: getSnapshot,
  12916. setSnapshot: null
  12917. },
  12918. source: source,
  12919. subscribe: subscribe
  12920. };
  12921. return useMutableSource(hook, source, getSnapshot, subscribe);
  12922. }
  12923. function updateMutableSource(source, getSnapshot, subscribe) {
  12924. var hook = updateWorkInProgressHook();
  12925. return useMutableSource(hook, source, getSnapshot, subscribe);
  12926. }
  12927. function mountState(initialState) {
  12928. var hook = mountWorkInProgressHook();
  12929. if (typeof initialState === 'function') {
  12930. // $FlowFixMe: Flow doesn't like mixed types
  12931. initialState = initialState();
  12932. }
  12933. hook.memoizedState = hook.baseState = initialState;
  12934. var queue = hook.queue = {
  12935. pending: null,
  12936. dispatch: null,
  12937. lastRenderedReducer: basicStateReducer,
  12938. lastRenderedState: initialState
  12939. };
  12940. var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue);
  12941. return [hook.memoizedState, dispatch];
  12942. }
  12943. function updateState(initialState) {
  12944. return updateReducer(basicStateReducer);
  12945. }
  12946. function rerenderState(initialState) {
  12947. return rerenderReducer(basicStateReducer);
  12948. }
  12949. function pushEffect(tag, create, destroy, deps) {
  12950. var effect = {
  12951. tag: tag,
  12952. create: create,
  12953. destroy: destroy,
  12954. deps: deps,
  12955. // Circular
  12956. next: null
  12957. };
  12958. var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue;
  12959. if (componentUpdateQueue === null) {
  12960. componentUpdateQueue = createFunctionComponentUpdateQueue();
  12961. currentlyRenderingFiber$1.updateQueue = componentUpdateQueue;
  12962. componentUpdateQueue.lastEffect = effect.next = effect;
  12963. } else {
  12964. var lastEffect = componentUpdateQueue.lastEffect;
  12965. if (lastEffect === null) {
  12966. componentUpdateQueue.lastEffect = effect.next = effect;
  12967. } else {
  12968. var firstEffect = lastEffect.next;
  12969. lastEffect.next = effect;
  12970. effect.next = firstEffect;
  12971. componentUpdateQueue.lastEffect = effect;
  12972. }
  12973. }
  12974. return effect;
  12975. }
  12976. function mountRef(initialValue) {
  12977. var hook = mountWorkInProgressHook();
  12978. var ref = {
  12979. current: initialValue
  12980. };
  12981. {
  12982. Object.seal(ref);
  12983. }
  12984. hook.memoizedState = ref;
  12985. return ref;
  12986. }
  12987. function updateRef(initialValue) {
  12988. var hook = updateWorkInProgressHook();
  12989. return hook.memoizedState;
  12990. }
  12991. function mountEffectImpl(fiberFlags, hookFlags, create, deps) {
  12992. var hook = mountWorkInProgressHook();
  12993. var nextDeps = deps === undefined ? null : deps;
  12994. currentlyRenderingFiber$1.flags |= fiberFlags;
  12995. hook.memoizedState = pushEffect(HasEffect | hookFlags, create, undefined, nextDeps);
  12996. }
  12997. function updateEffectImpl(fiberFlags, hookFlags, create, deps) {
  12998. var hook = updateWorkInProgressHook();
  12999. var nextDeps = deps === undefined ? null : deps;
  13000. var destroy = undefined;
  13001. if (currentHook !== null) {
  13002. var prevEffect = currentHook.memoizedState;
  13003. destroy = prevEffect.destroy;
  13004. if (nextDeps !== null) {
  13005. var prevDeps = prevEffect.deps;
  13006. if (areHookInputsEqual(nextDeps, prevDeps)) {
  13007. pushEffect(hookFlags, create, destroy, nextDeps);
  13008. return;
  13009. }
  13010. }
  13011. }
  13012. currentlyRenderingFiber$1.flags |= fiberFlags;
  13013. hook.memoizedState = pushEffect(HasEffect | hookFlags, create, destroy, nextDeps);
  13014. }
  13015. function mountEffect(create, deps) {
  13016. {
  13017. // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
  13018. if ('undefined' !== typeof jest) {
  13019. warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
  13020. }
  13021. }
  13022. return mountEffectImpl(Update | Passive, Passive$1, create, deps);
  13023. }
  13024. function updateEffect(create, deps) {
  13025. {
  13026. // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
  13027. if ('undefined' !== typeof jest) {
  13028. warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
  13029. }
  13030. }
  13031. return updateEffectImpl(Update | Passive, Passive$1, create, deps);
  13032. }
  13033. function mountLayoutEffect(create, deps) {
  13034. return mountEffectImpl(Update, Layout, create, deps);
  13035. }
  13036. function updateLayoutEffect(create, deps) {
  13037. return updateEffectImpl(Update, Layout, create, deps);
  13038. }
  13039. function imperativeHandleEffect(create, ref) {
  13040. if (typeof ref === 'function') {
  13041. var refCallback = ref;
  13042. var _inst = create();
  13043. refCallback(_inst);
  13044. return function () {
  13045. refCallback(null);
  13046. };
  13047. } else if (ref !== null && ref !== undefined) {
  13048. var refObject = ref;
  13049. {
  13050. if (!refObject.hasOwnProperty('current')) {
  13051. error('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(', ') + '}');
  13052. }
  13053. }
  13054. var _inst2 = create();
  13055. refObject.current = _inst2;
  13056. return function () {
  13057. refObject.current = null;
  13058. };
  13059. }
  13060. }
  13061. function mountImperativeHandle(ref, create, deps) {
  13062. {
  13063. if (typeof create !== 'function') {
  13064. error('Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null');
  13065. }
  13066. } // TODO: If deps are provided, should we skip comparing the ref itself?
  13067. var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
  13068. return mountEffectImpl(Update, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
  13069. }
  13070. function updateImperativeHandle(ref, create, deps) {
  13071. {
  13072. if (typeof create !== 'function') {
  13073. error('Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null');
  13074. }
  13075. } // TODO: If deps are provided, should we skip comparing the ref itself?
  13076. var effectDeps = deps !== null && deps !== undefined ? deps.concat([ref]) : null;
  13077. return updateEffectImpl(Update, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
  13078. }
  13079. function mountDebugValue(value, formatterFn) {// This hook is normally a no-op.
  13080. // The react-debug-hooks package injects its own implementation
  13081. // so that e.g. DevTools can display custom hook values.
  13082. }
  13083. var updateDebugValue = mountDebugValue;
  13084. function mountCallback(callback, deps) {
  13085. var hook = mountWorkInProgressHook();
  13086. var nextDeps = deps === undefined ? null : deps;
  13087. hook.memoizedState = [callback, nextDeps];
  13088. return callback;
  13089. }
  13090. function updateCallback(callback, deps) {
  13091. var hook = updateWorkInProgressHook();
  13092. var nextDeps = deps === undefined ? null : deps;
  13093. var prevState = hook.memoizedState;
  13094. if (prevState !== null) {
  13095. if (nextDeps !== null) {
  13096. var prevDeps = prevState[1];
  13097. if (areHookInputsEqual(nextDeps, prevDeps)) {
  13098. return prevState[0];
  13099. }
  13100. }
  13101. }
  13102. hook.memoizedState = [callback, nextDeps];
  13103. return callback;
  13104. }
  13105. function mountMemo(nextCreate, deps) {
  13106. var hook = mountWorkInProgressHook();
  13107. var nextDeps = deps === undefined ? null : deps;
  13108. var nextValue = nextCreate();
  13109. hook.memoizedState = [nextValue, nextDeps];
  13110. return nextValue;
  13111. }
  13112. function updateMemo(nextCreate, deps) {
  13113. var hook = updateWorkInProgressHook();
  13114. var nextDeps = deps === undefined ? null : deps;
  13115. var prevState = hook.memoizedState;
  13116. if (prevState !== null) {
  13117. // Assume these are defined. If they're not, areHookInputsEqual will warn.
  13118. if (nextDeps !== null) {
  13119. var prevDeps = prevState[1];
  13120. if (areHookInputsEqual(nextDeps, prevDeps)) {
  13121. return prevState[0];
  13122. }
  13123. }
  13124. }
  13125. var nextValue = nextCreate();
  13126. hook.memoizedState = [nextValue, nextDeps];
  13127. return nextValue;
  13128. }
  13129. function mountDeferredValue(value) {
  13130. var _mountState = mountState(value),
  13131. prevValue = _mountState[0],
  13132. setValue = _mountState[1];
  13133. mountEffect(function () {
  13134. var prevTransition = ReactCurrentBatchConfig$1.transition;
  13135. ReactCurrentBatchConfig$1.transition = 1;
  13136. try {
  13137. setValue(value);
  13138. } finally {
  13139. ReactCurrentBatchConfig$1.transition = prevTransition;
  13140. }
  13141. }, [value]);
  13142. return prevValue;
  13143. }
  13144. function updateDeferredValue(value) {
  13145. var _updateState = updateState(),
  13146. prevValue = _updateState[0],
  13147. setValue = _updateState[1];
  13148. updateEffect(function () {
  13149. var prevTransition = ReactCurrentBatchConfig$1.transition;
  13150. ReactCurrentBatchConfig$1.transition = 1;
  13151. try {
  13152. setValue(value);
  13153. } finally {
  13154. ReactCurrentBatchConfig$1.transition = prevTransition;
  13155. }
  13156. }, [value]);
  13157. return prevValue;
  13158. }
  13159. function rerenderDeferredValue(value) {
  13160. var _rerenderState = rerenderState(),
  13161. prevValue = _rerenderState[0],
  13162. setValue = _rerenderState[1];
  13163. updateEffect(function () {
  13164. var prevTransition = ReactCurrentBatchConfig$1.transition;
  13165. ReactCurrentBatchConfig$1.transition = 1;
  13166. try {
  13167. setValue(value);
  13168. } finally {
  13169. ReactCurrentBatchConfig$1.transition = prevTransition;
  13170. }
  13171. }, [value]);
  13172. return prevValue;
  13173. }
  13174. function startTransition(setPending, callback) {
  13175. var priorityLevel = getCurrentPriorityLevel();
  13176. {
  13177. runWithPriority$1(priorityLevel < UserBlockingPriority$2 ? UserBlockingPriority$2 : priorityLevel, function () {
  13178. setPending(true);
  13179. });
  13180. runWithPriority$1(priorityLevel > NormalPriority$1 ? NormalPriority$1 : priorityLevel, function () {
  13181. var prevTransition = ReactCurrentBatchConfig$1.transition;
  13182. ReactCurrentBatchConfig$1.transition = 1;
  13183. try {
  13184. setPending(false);
  13185. callback();
  13186. } finally {
  13187. ReactCurrentBatchConfig$1.transition = prevTransition;
  13188. }
  13189. });
  13190. }
  13191. }
  13192. function mountTransition() {
  13193. var _mountState2 = mountState(false),
  13194. isPending = _mountState2[0],
  13195. setPending = _mountState2[1]; // The `start` method can be stored on a ref, since `setPending`
  13196. // never changes.
  13197. var start = startTransition.bind(null, setPending);
  13198. mountRef(start);
  13199. return [start, isPending];
  13200. }
  13201. function updateTransition() {
  13202. var _updateState2 = updateState(),
  13203. isPending = _updateState2[0];
  13204. var startRef = updateRef();
  13205. var start = startRef.current;
  13206. return [start, isPending];
  13207. }
  13208. function rerenderTransition() {
  13209. var _rerenderState2 = rerenderState(),
  13210. isPending = _rerenderState2[0];
  13211. var startRef = updateRef();
  13212. var start = startRef.current;
  13213. return [start, isPending];
  13214. }
  13215. var isUpdatingOpaqueValueInRenderPhase = false;
  13216. function getIsUpdatingOpaqueValueInRenderPhaseInDEV() {
  13217. {
  13218. return isUpdatingOpaqueValueInRenderPhase;
  13219. }
  13220. }
  13221. function warnOnOpaqueIdentifierAccessInDEV(fiber) {
  13222. {
  13223. // TODO: Should warn in effects and callbacks, too
  13224. var name = getComponentName(fiber.type) || 'Unknown';
  13225. if (getIsRendering() && !didWarnAboutUseOpaqueIdentifier[name]) {
  13226. error('The object passed back from useOpaqueIdentifier is meant to be ' + 'passed through to attributes only. Do not read the ' + 'value directly.');
  13227. didWarnAboutUseOpaqueIdentifier[name] = true;
  13228. }
  13229. }
  13230. }
  13231. function mountOpaqueIdentifier() {
  13232. var makeId = makeClientIdInDEV.bind(null, warnOnOpaqueIdentifierAccessInDEV.bind(null, currentlyRenderingFiber$1)) ;
  13233. if (getIsHydrating()) {
  13234. var didUpgrade = false;
  13235. var fiber = currentlyRenderingFiber$1;
  13236. var readValue = function () {
  13237. if (!didUpgrade) {
  13238. // Only upgrade once. This works even inside the render phase because
  13239. // the update is added to a shared queue, which outlasts the
  13240. // in-progress render.
  13241. didUpgrade = true;
  13242. {
  13243. isUpdatingOpaqueValueInRenderPhase = true;
  13244. setId(makeId());
  13245. isUpdatingOpaqueValueInRenderPhase = false;
  13246. warnOnOpaqueIdentifierAccessInDEV(fiber);
  13247. }
  13248. }
  13249. {
  13250. {
  13251. throw Error( "The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. Do not read the value directly." );
  13252. }
  13253. }
  13254. };
  13255. var id = makeOpaqueHydratingObject(readValue);
  13256. var setId = mountState(id)[1];
  13257. if ((currentlyRenderingFiber$1.mode & BlockingMode) === NoMode) {
  13258. currentlyRenderingFiber$1.flags |= Update | Passive;
  13259. pushEffect(HasEffect | Passive$1, function () {
  13260. setId(makeId());
  13261. }, undefined, null);
  13262. }
  13263. return id;
  13264. } else {
  13265. var _id = makeId();
  13266. mountState(_id);
  13267. return _id;
  13268. }
  13269. }
  13270. function updateOpaqueIdentifier() {
  13271. var id = updateState()[0];
  13272. return id;
  13273. }
  13274. function rerenderOpaqueIdentifier() {
  13275. var id = rerenderState()[0];
  13276. return id;
  13277. }
  13278. function dispatchAction(fiber, queue, action) {
  13279. {
  13280. if (typeof arguments[3] === 'function') {
  13281. error("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().');
  13282. }
  13283. }
  13284. var eventTime = requestEventTime();
  13285. var lane = requestUpdateLane(fiber);
  13286. var update = {
  13287. lane: lane,
  13288. action: action,
  13289. eagerReducer: null,
  13290. eagerState: null,
  13291. next: null
  13292. }; // Append the update to the end of the list.
  13293. var pending = queue.pending;
  13294. if (pending === null) {
  13295. // This is the first update. Create a circular list.
  13296. update.next = update;
  13297. } else {
  13298. update.next = pending.next;
  13299. pending.next = update;
  13300. }
  13301. queue.pending = update;
  13302. var alternate = fiber.alternate;
  13303. if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) {
  13304. // This is a render phase update. Stash it in a lazily-created map of
  13305. // queue -> linked list of updates. After this render pass, we'll restart
  13306. // and apply the stashed updates on top of the work-in-progress hook.
  13307. didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true;
  13308. } else {
  13309. if (fiber.lanes === NoLanes && (alternate === null || alternate.lanes === NoLanes)) {
  13310. // The queue is currently empty, which means we can eagerly compute the
  13311. // next state before entering the render phase. If the new state is the
  13312. // same as the current state, we may be able to bail out entirely.
  13313. var lastRenderedReducer = queue.lastRenderedReducer;
  13314. if (lastRenderedReducer !== null) {
  13315. var prevDispatcher;
  13316. {
  13317. prevDispatcher = ReactCurrentDispatcher$1.current;
  13318. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  13319. }
  13320. try {
  13321. var currentState = queue.lastRenderedState;
  13322. var eagerState = lastRenderedReducer(currentState, action); // Stash the eagerly computed state, and the reducer used to compute
  13323. // it, on the update object. If the reducer hasn't changed by the
  13324. // time we enter the render phase, then the eager state can be used
  13325. // without calling the reducer again.
  13326. update.eagerReducer = lastRenderedReducer;
  13327. update.eagerState = eagerState;
  13328. if (objectIs(eagerState, currentState)) {
  13329. // Fast path. We can bail out without scheduling React to re-render.
  13330. // It's still possible that we'll need to rebase this update later,
  13331. // if the component re-renders for a different reason and by that
  13332. // time the reducer has changed.
  13333. return;
  13334. }
  13335. } catch (error) {// Suppress the error. It will throw again in the render phase.
  13336. } finally {
  13337. {
  13338. ReactCurrentDispatcher$1.current = prevDispatcher;
  13339. }
  13340. }
  13341. }
  13342. }
  13343. {
  13344. // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
  13345. if ('undefined' !== typeof jest) {
  13346. warnIfNotScopedWithMatchingAct(fiber);
  13347. warnIfNotCurrentlyActingUpdatesInDev(fiber);
  13348. }
  13349. }
  13350. scheduleUpdateOnFiber(fiber, lane, eventTime);
  13351. }
  13352. }
  13353. var ContextOnlyDispatcher = {
  13354. readContext: readContext,
  13355. useCallback: throwInvalidHookError,
  13356. useContext: throwInvalidHookError,
  13357. useEffect: throwInvalidHookError,
  13358. useImperativeHandle: throwInvalidHookError,
  13359. useLayoutEffect: throwInvalidHookError,
  13360. useMemo: throwInvalidHookError,
  13361. useReducer: throwInvalidHookError,
  13362. useRef: throwInvalidHookError,
  13363. useState: throwInvalidHookError,
  13364. useDebugValue: throwInvalidHookError,
  13365. useDeferredValue: throwInvalidHookError,
  13366. useTransition: throwInvalidHookError,
  13367. useMutableSource: throwInvalidHookError,
  13368. useOpaqueIdentifier: throwInvalidHookError,
  13369. unstable_isNewReconciler: enableNewReconciler
  13370. };
  13371. var HooksDispatcherOnMountInDEV = null;
  13372. var HooksDispatcherOnMountWithHookTypesInDEV = null;
  13373. var HooksDispatcherOnUpdateInDEV = null;
  13374. var HooksDispatcherOnRerenderInDEV = null;
  13375. var InvalidNestedHooksDispatcherOnMountInDEV = null;
  13376. var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
  13377. var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
  13378. {
  13379. var warnInvalidContextAccess = function () {
  13380. 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().');
  13381. };
  13382. var warnInvalidHookAccess = function () {
  13383. error('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://reactjs.org/link/rules-of-hooks');
  13384. };
  13385. HooksDispatcherOnMountInDEV = {
  13386. readContext: function (context, observedBits) {
  13387. return readContext(context, observedBits);
  13388. },
  13389. useCallback: function (callback, deps) {
  13390. currentHookNameInDev = 'useCallback';
  13391. mountHookTypesDev();
  13392. checkDepsAreArrayDev(deps);
  13393. return mountCallback(callback, deps);
  13394. },
  13395. useContext: function (context, observedBits) {
  13396. currentHookNameInDev = 'useContext';
  13397. mountHookTypesDev();
  13398. return readContext(context, observedBits);
  13399. },
  13400. useEffect: function (create, deps) {
  13401. currentHookNameInDev = 'useEffect';
  13402. mountHookTypesDev();
  13403. checkDepsAreArrayDev(deps);
  13404. return mountEffect(create, deps);
  13405. },
  13406. useImperativeHandle: function (ref, create, deps) {
  13407. currentHookNameInDev = 'useImperativeHandle';
  13408. mountHookTypesDev();
  13409. checkDepsAreArrayDev(deps);
  13410. return mountImperativeHandle(ref, create, deps);
  13411. },
  13412. useLayoutEffect: function (create, deps) {
  13413. currentHookNameInDev = 'useLayoutEffect';
  13414. mountHookTypesDev();
  13415. checkDepsAreArrayDev(deps);
  13416. return mountLayoutEffect(create, deps);
  13417. },
  13418. useMemo: function (create, deps) {
  13419. currentHookNameInDev = 'useMemo';
  13420. mountHookTypesDev();
  13421. checkDepsAreArrayDev(deps);
  13422. var prevDispatcher = ReactCurrentDispatcher$1.current;
  13423. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  13424. try {
  13425. return mountMemo(create, deps);
  13426. } finally {
  13427. ReactCurrentDispatcher$1.current = prevDispatcher;
  13428. }
  13429. },
  13430. useReducer: function (reducer, initialArg, init) {
  13431. currentHookNameInDev = 'useReducer';
  13432. mountHookTypesDev();
  13433. var prevDispatcher = ReactCurrentDispatcher$1.current;
  13434. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  13435. try {
  13436. return mountReducer(reducer, initialArg, init);
  13437. } finally {
  13438. ReactCurrentDispatcher$1.current = prevDispatcher;
  13439. }
  13440. },
  13441. useRef: function (initialValue) {
  13442. currentHookNameInDev = 'useRef';
  13443. mountHookTypesDev();
  13444. return mountRef(initialValue);
  13445. },
  13446. useState: function (initialState) {
  13447. currentHookNameInDev = 'useState';
  13448. mountHookTypesDev();
  13449. var prevDispatcher = ReactCurrentDispatcher$1.current;
  13450. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  13451. try {
  13452. return mountState(initialState);
  13453. } finally {
  13454. ReactCurrentDispatcher$1.current = prevDispatcher;
  13455. }
  13456. },
  13457. useDebugValue: function (value, formatterFn) {
  13458. currentHookNameInDev = 'useDebugValue';
  13459. mountHookTypesDev();
  13460. return mountDebugValue();
  13461. },
  13462. useDeferredValue: function (value) {
  13463. currentHookNameInDev = 'useDeferredValue';
  13464. mountHookTypesDev();
  13465. return mountDeferredValue(value);
  13466. },
  13467. useTransition: function () {
  13468. currentHookNameInDev = 'useTransition';
  13469. mountHookTypesDev();
  13470. return mountTransition();
  13471. },
  13472. useMutableSource: function (source, getSnapshot, subscribe) {
  13473. currentHookNameInDev = 'useMutableSource';
  13474. mountHookTypesDev();
  13475. return mountMutableSource(source, getSnapshot, subscribe);
  13476. },
  13477. useOpaqueIdentifier: function () {
  13478. currentHookNameInDev = 'useOpaqueIdentifier';
  13479. mountHookTypesDev();
  13480. return mountOpaqueIdentifier();
  13481. },
  13482. unstable_isNewReconciler: enableNewReconciler
  13483. };
  13484. HooksDispatcherOnMountWithHookTypesInDEV = {
  13485. readContext: function (context, observedBits) {
  13486. return readContext(context, observedBits);
  13487. },
  13488. useCallback: function (callback, deps) {
  13489. currentHookNameInDev = 'useCallback';
  13490. updateHookTypesDev();
  13491. return mountCallback(callback, deps);
  13492. },
  13493. useContext: function (context, observedBits) {
  13494. currentHookNameInDev = 'useContext';
  13495. updateHookTypesDev();
  13496. return readContext(context, observedBits);
  13497. },
  13498. useEffect: function (create, deps) {
  13499. currentHookNameInDev = 'useEffect';
  13500. updateHookTypesDev();
  13501. return mountEffect(create, deps);
  13502. },
  13503. useImperativeHandle: function (ref, create, deps) {
  13504. currentHookNameInDev = 'useImperativeHandle';
  13505. updateHookTypesDev();
  13506. return mountImperativeHandle(ref, create, deps);
  13507. },
  13508. useLayoutEffect: function (create, deps) {
  13509. currentHookNameInDev = 'useLayoutEffect';
  13510. updateHookTypesDev();
  13511. return mountLayoutEffect(create, deps);
  13512. },
  13513. useMemo: function (create, deps) {
  13514. currentHookNameInDev = 'useMemo';
  13515. updateHookTypesDev();
  13516. var prevDispatcher = ReactCurrentDispatcher$1.current;
  13517. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  13518. try {
  13519. return mountMemo(create, deps);
  13520. } finally {
  13521. ReactCurrentDispatcher$1.current = prevDispatcher;
  13522. }
  13523. },
  13524. useReducer: function (reducer, initialArg, init) {
  13525. currentHookNameInDev = 'useReducer';
  13526. updateHookTypesDev();
  13527. var prevDispatcher = ReactCurrentDispatcher$1.current;
  13528. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  13529. try {
  13530. return mountReducer(reducer, initialArg, init);
  13531. } finally {
  13532. ReactCurrentDispatcher$1.current = prevDispatcher;
  13533. }
  13534. },
  13535. useRef: function (initialValue) {
  13536. currentHookNameInDev = 'useRef';
  13537. updateHookTypesDev();
  13538. return mountRef(initialValue);
  13539. },
  13540. useState: function (initialState) {
  13541. currentHookNameInDev = 'useState';
  13542. updateHookTypesDev();
  13543. var prevDispatcher = ReactCurrentDispatcher$1.current;
  13544. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  13545. try {
  13546. return mountState(initialState);
  13547. } finally {
  13548. ReactCurrentDispatcher$1.current = prevDispatcher;
  13549. }
  13550. },
  13551. useDebugValue: function (value, formatterFn) {
  13552. currentHookNameInDev = 'useDebugValue';
  13553. updateHookTypesDev();
  13554. return mountDebugValue();
  13555. },
  13556. useDeferredValue: function (value) {
  13557. currentHookNameInDev = 'useDeferredValue';
  13558. updateHookTypesDev();
  13559. return mountDeferredValue(value);
  13560. },
  13561. useTransition: function () {
  13562. currentHookNameInDev = 'useTransition';
  13563. updateHookTypesDev();
  13564. return mountTransition();
  13565. },
  13566. useMutableSource: function (source, getSnapshot, subscribe) {
  13567. currentHookNameInDev = 'useMutableSource';
  13568. updateHookTypesDev();
  13569. return mountMutableSource(source, getSnapshot, subscribe);
  13570. },
  13571. useOpaqueIdentifier: function () {
  13572. currentHookNameInDev = 'useOpaqueIdentifier';
  13573. updateHookTypesDev();
  13574. return mountOpaqueIdentifier();
  13575. },
  13576. unstable_isNewReconciler: enableNewReconciler
  13577. };
  13578. HooksDispatcherOnUpdateInDEV = {
  13579. readContext: function (context, observedBits) {
  13580. return readContext(context, observedBits);
  13581. },
  13582. useCallback: function (callback, deps) {
  13583. currentHookNameInDev = 'useCallback';
  13584. updateHookTypesDev();
  13585. return updateCallback(callback, deps);
  13586. },
  13587. useContext: function (context, observedBits) {
  13588. currentHookNameInDev = 'useContext';
  13589. updateHookTypesDev();
  13590. return readContext(context, observedBits);
  13591. },
  13592. useEffect: function (create, deps) {
  13593. currentHookNameInDev = 'useEffect';
  13594. updateHookTypesDev();
  13595. return updateEffect(create, deps);
  13596. },
  13597. useImperativeHandle: function (ref, create, deps) {
  13598. currentHookNameInDev = 'useImperativeHandle';
  13599. updateHookTypesDev();
  13600. return updateImperativeHandle(ref, create, deps);
  13601. },
  13602. useLayoutEffect: function (create, deps) {
  13603. currentHookNameInDev = 'useLayoutEffect';
  13604. updateHookTypesDev();
  13605. return updateLayoutEffect(create, deps);
  13606. },
  13607. useMemo: function (create, deps) {
  13608. currentHookNameInDev = 'useMemo';
  13609. updateHookTypesDev();
  13610. var prevDispatcher = ReactCurrentDispatcher$1.current;
  13611. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  13612. try {
  13613. return updateMemo(create, deps);
  13614. } finally {
  13615. ReactCurrentDispatcher$1.current = prevDispatcher;
  13616. }
  13617. },
  13618. useReducer: function (reducer, initialArg, init) {
  13619. currentHookNameInDev = 'useReducer';
  13620. updateHookTypesDev();
  13621. var prevDispatcher = ReactCurrentDispatcher$1.current;
  13622. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  13623. try {
  13624. return updateReducer(reducer, initialArg, init);
  13625. } finally {
  13626. ReactCurrentDispatcher$1.current = prevDispatcher;
  13627. }
  13628. },
  13629. useRef: function (initialValue) {
  13630. currentHookNameInDev = 'useRef';
  13631. updateHookTypesDev();
  13632. return updateRef();
  13633. },
  13634. useState: function (initialState) {
  13635. currentHookNameInDev = 'useState';
  13636. updateHookTypesDev();
  13637. var prevDispatcher = ReactCurrentDispatcher$1.current;
  13638. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  13639. try {
  13640. return updateState(initialState);
  13641. } finally {
  13642. ReactCurrentDispatcher$1.current = prevDispatcher;
  13643. }
  13644. },
  13645. useDebugValue: function (value, formatterFn) {
  13646. currentHookNameInDev = 'useDebugValue';
  13647. updateHookTypesDev();
  13648. return updateDebugValue();
  13649. },
  13650. useDeferredValue: function (value) {
  13651. currentHookNameInDev = 'useDeferredValue';
  13652. updateHookTypesDev();
  13653. return updateDeferredValue(value);
  13654. },
  13655. useTransition: function () {
  13656. currentHookNameInDev = 'useTransition';
  13657. updateHookTypesDev();
  13658. return updateTransition();
  13659. },
  13660. useMutableSource: function (source, getSnapshot, subscribe) {
  13661. currentHookNameInDev = 'useMutableSource';
  13662. updateHookTypesDev();
  13663. return updateMutableSource(source, getSnapshot, subscribe);
  13664. },
  13665. useOpaqueIdentifier: function () {
  13666. currentHookNameInDev = 'useOpaqueIdentifier';
  13667. updateHookTypesDev();
  13668. return updateOpaqueIdentifier();
  13669. },
  13670. unstable_isNewReconciler: enableNewReconciler
  13671. };
  13672. HooksDispatcherOnRerenderInDEV = {
  13673. readContext: function (context, observedBits) {
  13674. return readContext(context, observedBits);
  13675. },
  13676. useCallback: function (callback, deps) {
  13677. currentHookNameInDev = 'useCallback';
  13678. updateHookTypesDev();
  13679. return updateCallback(callback, deps);
  13680. },
  13681. useContext: function (context, observedBits) {
  13682. currentHookNameInDev = 'useContext';
  13683. updateHookTypesDev();
  13684. return readContext(context, observedBits);
  13685. },
  13686. useEffect: function (create, deps) {
  13687. currentHookNameInDev = 'useEffect';
  13688. updateHookTypesDev();
  13689. return updateEffect(create, deps);
  13690. },
  13691. useImperativeHandle: function (ref, create, deps) {
  13692. currentHookNameInDev = 'useImperativeHandle';
  13693. updateHookTypesDev();
  13694. return updateImperativeHandle(ref, create, deps);
  13695. },
  13696. useLayoutEffect: function (create, deps) {
  13697. currentHookNameInDev = 'useLayoutEffect';
  13698. updateHookTypesDev();
  13699. return updateLayoutEffect(create, deps);
  13700. },
  13701. useMemo: function (create, deps) {
  13702. currentHookNameInDev = 'useMemo';
  13703. updateHookTypesDev();
  13704. var prevDispatcher = ReactCurrentDispatcher$1.current;
  13705. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
  13706. try {
  13707. return updateMemo(create, deps);
  13708. } finally {
  13709. ReactCurrentDispatcher$1.current = prevDispatcher;
  13710. }
  13711. },
  13712. useReducer: function (reducer, initialArg, init) {
  13713. currentHookNameInDev = 'useReducer';
  13714. updateHookTypesDev();
  13715. var prevDispatcher = ReactCurrentDispatcher$1.current;
  13716. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
  13717. try {
  13718. return rerenderReducer(reducer, initialArg, init);
  13719. } finally {
  13720. ReactCurrentDispatcher$1.current = prevDispatcher;
  13721. }
  13722. },
  13723. useRef: function (initialValue) {
  13724. currentHookNameInDev = 'useRef';
  13725. updateHookTypesDev();
  13726. return updateRef();
  13727. },
  13728. useState: function (initialState) {
  13729. currentHookNameInDev = 'useState';
  13730. updateHookTypesDev();
  13731. var prevDispatcher = ReactCurrentDispatcher$1.current;
  13732. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
  13733. try {
  13734. return rerenderState(initialState);
  13735. } finally {
  13736. ReactCurrentDispatcher$1.current = prevDispatcher;
  13737. }
  13738. },
  13739. useDebugValue: function (value, formatterFn) {
  13740. currentHookNameInDev = 'useDebugValue';
  13741. updateHookTypesDev();
  13742. return updateDebugValue();
  13743. },
  13744. useDeferredValue: function (value) {
  13745. currentHookNameInDev = 'useDeferredValue';
  13746. updateHookTypesDev();
  13747. return rerenderDeferredValue(value);
  13748. },
  13749. useTransition: function () {
  13750. currentHookNameInDev = 'useTransition';
  13751. updateHookTypesDev();
  13752. return rerenderTransition();
  13753. },
  13754. useMutableSource: function (source, getSnapshot, subscribe) {
  13755. currentHookNameInDev = 'useMutableSource';
  13756. updateHookTypesDev();
  13757. return updateMutableSource(source, getSnapshot, subscribe);
  13758. },
  13759. useOpaqueIdentifier: function () {
  13760. currentHookNameInDev = 'useOpaqueIdentifier';
  13761. updateHookTypesDev();
  13762. return rerenderOpaqueIdentifier();
  13763. },
  13764. unstable_isNewReconciler: enableNewReconciler
  13765. };
  13766. InvalidNestedHooksDispatcherOnMountInDEV = {
  13767. readContext: function (context, observedBits) {
  13768. warnInvalidContextAccess();
  13769. return readContext(context, observedBits);
  13770. },
  13771. useCallback: function (callback, deps) {
  13772. currentHookNameInDev = 'useCallback';
  13773. warnInvalidHookAccess();
  13774. mountHookTypesDev();
  13775. return mountCallback(callback, deps);
  13776. },
  13777. useContext: function (context, observedBits) {
  13778. currentHookNameInDev = 'useContext';
  13779. warnInvalidHookAccess();
  13780. mountHookTypesDev();
  13781. return readContext(context, observedBits);
  13782. },
  13783. useEffect: function (create, deps) {
  13784. currentHookNameInDev = 'useEffect';
  13785. warnInvalidHookAccess();
  13786. mountHookTypesDev();
  13787. return mountEffect(create, deps);
  13788. },
  13789. useImperativeHandle: function (ref, create, deps) {
  13790. currentHookNameInDev = 'useImperativeHandle';
  13791. warnInvalidHookAccess();
  13792. mountHookTypesDev();
  13793. return mountImperativeHandle(ref, create, deps);
  13794. },
  13795. useLayoutEffect: function (create, deps) {
  13796. currentHookNameInDev = 'useLayoutEffect';
  13797. warnInvalidHookAccess();
  13798. mountHookTypesDev();
  13799. return mountLayoutEffect(create, deps);
  13800. },
  13801. useMemo: function (create, deps) {
  13802. currentHookNameInDev = 'useMemo';
  13803. warnInvalidHookAccess();
  13804. mountHookTypesDev();
  13805. var prevDispatcher = ReactCurrentDispatcher$1.current;
  13806. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  13807. try {
  13808. return mountMemo(create, deps);
  13809. } finally {
  13810. ReactCurrentDispatcher$1.current = prevDispatcher;
  13811. }
  13812. },
  13813. useReducer: function (reducer, initialArg, init) {
  13814. currentHookNameInDev = 'useReducer';
  13815. warnInvalidHookAccess();
  13816. mountHookTypesDev();
  13817. var prevDispatcher = ReactCurrentDispatcher$1.current;
  13818. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  13819. try {
  13820. return mountReducer(reducer, initialArg, init);
  13821. } finally {
  13822. ReactCurrentDispatcher$1.current = prevDispatcher;
  13823. }
  13824. },
  13825. useRef: function (initialValue) {
  13826. currentHookNameInDev = 'useRef';
  13827. warnInvalidHookAccess();
  13828. mountHookTypesDev();
  13829. return mountRef(initialValue);
  13830. },
  13831. useState: function (initialState) {
  13832. currentHookNameInDev = 'useState';
  13833. warnInvalidHookAccess();
  13834. mountHookTypesDev();
  13835. var prevDispatcher = ReactCurrentDispatcher$1.current;
  13836. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
  13837. try {
  13838. return mountState(initialState);
  13839. } finally {
  13840. ReactCurrentDispatcher$1.current = prevDispatcher;
  13841. }
  13842. },
  13843. useDebugValue: function (value, formatterFn) {
  13844. currentHookNameInDev = 'useDebugValue';
  13845. warnInvalidHookAccess();
  13846. mountHookTypesDev();
  13847. return mountDebugValue();
  13848. },
  13849. useDeferredValue: function (value) {
  13850. currentHookNameInDev = 'useDeferredValue';
  13851. warnInvalidHookAccess();
  13852. mountHookTypesDev();
  13853. return mountDeferredValue(value);
  13854. },
  13855. useTransition: function () {
  13856. currentHookNameInDev = 'useTransition';
  13857. warnInvalidHookAccess();
  13858. mountHookTypesDev();
  13859. return mountTransition();
  13860. },
  13861. useMutableSource: function (source, getSnapshot, subscribe) {
  13862. currentHookNameInDev = 'useMutableSource';
  13863. warnInvalidHookAccess();
  13864. mountHookTypesDev();
  13865. return mountMutableSource(source, getSnapshot, subscribe);
  13866. },
  13867. useOpaqueIdentifier: function () {
  13868. currentHookNameInDev = 'useOpaqueIdentifier';
  13869. warnInvalidHookAccess();
  13870. mountHookTypesDev();
  13871. return mountOpaqueIdentifier();
  13872. },
  13873. unstable_isNewReconciler: enableNewReconciler
  13874. };
  13875. InvalidNestedHooksDispatcherOnUpdateInDEV = {
  13876. readContext: function (context, observedBits) {
  13877. warnInvalidContextAccess();
  13878. return readContext(context, observedBits);
  13879. },
  13880. useCallback: function (callback, deps) {
  13881. currentHookNameInDev = 'useCallback';
  13882. warnInvalidHookAccess();
  13883. updateHookTypesDev();
  13884. return updateCallback(callback, deps);
  13885. },
  13886. useContext: function (context, observedBits) {
  13887. currentHookNameInDev = 'useContext';
  13888. warnInvalidHookAccess();
  13889. updateHookTypesDev();
  13890. return readContext(context, observedBits);
  13891. },
  13892. useEffect: function (create, deps) {
  13893. currentHookNameInDev = 'useEffect';
  13894. warnInvalidHookAccess();
  13895. updateHookTypesDev();
  13896. return updateEffect(create, deps);
  13897. },
  13898. useImperativeHandle: function (ref, create, deps) {
  13899. currentHookNameInDev = 'useImperativeHandle';
  13900. warnInvalidHookAccess();
  13901. updateHookTypesDev();
  13902. return updateImperativeHandle(ref, create, deps);
  13903. },
  13904. useLayoutEffect: function (create, deps) {
  13905. currentHookNameInDev = 'useLayoutEffect';
  13906. warnInvalidHookAccess();
  13907. updateHookTypesDev();
  13908. return updateLayoutEffect(create, deps);
  13909. },
  13910. useMemo: function (create, deps) {
  13911. currentHookNameInDev = 'useMemo';
  13912. warnInvalidHookAccess();
  13913. updateHookTypesDev();
  13914. var prevDispatcher = ReactCurrentDispatcher$1.current;
  13915. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  13916. try {
  13917. return updateMemo(create, deps);
  13918. } finally {
  13919. ReactCurrentDispatcher$1.current = prevDispatcher;
  13920. }
  13921. },
  13922. useReducer: function (reducer, initialArg, init) {
  13923. currentHookNameInDev = 'useReducer';
  13924. warnInvalidHookAccess();
  13925. updateHookTypesDev();
  13926. var prevDispatcher = ReactCurrentDispatcher$1.current;
  13927. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  13928. try {
  13929. return updateReducer(reducer, initialArg, init);
  13930. } finally {
  13931. ReactCurrentDispatcher$1.current = prevDispatcher;
  13932. }
  13933. },
  13934. useRef: function (initialValue) {
  13935. currentHookNameInDev = 'useRef';
  13936. warnInvalidHookAccess();
  13937. updateHookTypesDev();
  13938. return updateRef();
  13939. },
  13940. useState: function (initialState) {
  13941. currentHookNameInDev = 'useState';
  13942. warnInvalidHookAccess();
  13943. updateHookTypesDev();
  13944. var prevDispatcher = ReactCurrentDispatcher$1.current;
  13945. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  13946. try {
  13947. return updateState(initialState);
  13948. } finally {
  13949. ReactCurrentDispatcher$1.current = prevDispatcher;
  13950. }
  13951. },
  13952. useDebugValue: function (value, formatterFn) {
  13953. currentHookNameInDev = 'useDebugValue';
  13954. warnInvalidHookAccess();
  13955. updateHookTypesDev();
  13956. return updateDebugValue();
  13957. },
  13958. useDeferredValue: function (value) {
  13959. currentHookNameInDev = 'useDeferredValue';
  13960. warnInvalidHookAccess();
  13961. updateHookTypesDev();
  13962. return updateDeferredValue(value);
  13963. },
  13964. useTransition: function () {
  13965. currentHookNameInDev = 'useTransition';
  13966. warnInvalidHookAccess();
  13967. updateHookTypesDev();
  13968. return updateTransition();
  13969. },
  13970. useMutableSource: function (source, getSnapshot, subscribe) {
  13971. currentHookNameInDev = 'useMutableSource';
  13972. warnInvalidHookAccess();
  13973. updateHookTypesDev();
  13974. return updateMutableSource(source, getSnapshot, subscribe);
  13975. },
  13976. useOpaqueIdentifier: function () {
  13977. currentHookNameInDev = 'useOpaqueIdentifier';
  13978. warnInvalidHookAccess();
  13979. updateHookTypesDev();
  13980. return updateOpaqueIdentifier();
  13981. },
  13982. unstable_isNewReconciler: enableNewReconciler
  13983. };
  13984. InvalidNestedHooksDispatcherOnRerenderInDEV = {
  13985. readContext: function (context, observedBits) {
  13986. warnInvalidContextAccess();
  13987. return readContext(context, observedBits);
  13988. },
  13989. useCallback: function (callback, deps) {
  13990. currentHookNameInDev = 'useCallback';
  13991. warnInvalidHookAccess();
  13992. updateHookTypesDev();
  13993. return updateCallback(callback, deps);
  13994. },
  13995. useContext: function (context, observedBits) {
  13996. currentHookNameInDev = 'useContext';
  13997. warnInvalidHookAccess();
  13998. updateHookTypesDev();
  13999. return readContext(context, observedBits);
  14000. },
  14001. useEffect: function (create, deps) {
  14002. currentHookNameInDev = 'useEffect';
  14003. warnInvalidHookAccess();
  14004. updateHookTypesDev();
  14005. return updateEffect(create, deps);
  14006. },
  14007. useImperativeHandle: function (ref, create, deps) {
  14008. currentHookNameInDev = 'useImperativeHandle';
  14009. warnInvalidHookAccess();
  14010. updateHookTypesDev();
  14011. return updateImperativeHandle(ref, create, deps);
  14012. },
  14013. useLayoutEffect: function (create, deps) {
  14014. currentHookNameInDev = 'useLayoutEffect';
  14015. warnInvalidHookAccess();
  14016. updateHookTypesDev();
  14017. return updateLayoutEffect(create, deps);
  14018. },
  14019. useMemo: function (create, deps) {
  14020. currentHookNameInDev = 'useMemo';
  14021. warnInvalidHookAccess();
  14022. updateHookTypesDev();
  14023. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14024. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  14025. try {
  14026. return updateMemo(create, deps);
  14027. } finally {
  14028. ReactCurrentDispatcher$1.current = prevDispatcher;
  14029. }
  14030. },
  14031. useReducer: function (reducer, initialArg, init) {
  14032. currentHookNameInDev = 'useReducer';
  14033. warnInvalidHookAccess();
  14034. updateHookTypesDev();
  14035. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14036. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  14037. try {
  14038. return rerenderReducer(reducer, initialArg, init);
  14039. } finally {
  14040. ReactCurrentDispatcher$1.current = prevDispatcher;
  14041. }
  14042. },
  14043. useRef: function (initialValue) {
  14044. currentHookNameInDev = 'useRef';
  14045. warnInvalidHookAccess();
  14046. updateHookTypesDev();
  14047. return updateRef();
  14048. },
  14049. useState: function (initialState) {
  14050. currentHookNameInDev = 'useState';
  14051. warnInvalidHookAccess();
  14052. updateHookTypesDev();
  14053. var prevDispatcher = ReactCurrentDispatcher$1.current;
  14054. ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
  14055. try {
  14056. return rerenderState(initialState);
  14057. } finally {
  14058. ReactCurrentDispatcher$1.current = prevDispatcher;
  14059. }
  14060. },
  14061. useDebugValue: function (value, formatterFn) {
  14062. currentHookNameInDev = 'useDebugValue';
  14063. warnInvalidHookAccess();
  14064. updateHookTypesDev();
  14065. return updateDebugValue();
  14066. },
  14067. useDeferredValue: function (value) {
  14068. currentHookNameInDev = 'useDeferredValue';
  14069. warnInvalidHookAccess();
  14070. updateHookTypesDev();
  14071. return rerenderDeferredValue(value);
  14072. },
  14073. useTransition: function () {
  14074. currentHookNameInDev = 'useTransition';
  14075. warnInvalidHookAccess();
  14076. updateHookTypesDev();
  14077. return rerenderTransition();
  14078. },
  14079. useMutableSource: function (source, getSnapshot, subscribe) {
  14080. currentHookNameInDev = 'useMutableSource';
  14081. warnInvalidHookAccess();
  14082. updateHookTypesDev();
  14083. return updateMutableSource(source, getSnapshot, subscribe);
  14084. },
  14085. useOpaqueIdentifier: function () {
  14086. currentHookNameInDev = 'useOpaqueIdentifier';
  14087. warnInvalidHookAccess();
  14088. updateHookTypesDev();
  14089. return rerenderOpaqueIdentifier();
  14090. },
  14091. unstable_isNewReconciler: enableNewReconciler
  14092. };
  14093. }
  14094. var now$1 = Scheduler.unstable_now;
  14095. var commitTime = 0;
  14096. var profilerStartTime = -1;
  14097. function getCommitTime() {
  14098. return commitTime;
  14099. }
  14100. function recordCommitTime() {
  14101. commitTime = now$1();
  14102. }
  14103. function startProfilerTimer(fiber) {
  14104. profilerStartTime = now$1();
  14105. if (fiber.actualStartTime < 0) {
  14106. fiber.actualStartTime = now$1();
  14107. }
  14108. }
  14109. function stopProfilerTimerIfRunning(fiber) {
  14110. profilerStartTime = -1;
  14111. }
  14112. function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
  14113. if (profilerStartTime >= 0) {
  14114. var elapsedTime = now$1() - profilerStartTime;
  14115. fiber.actualDuration += elapsedTime;
  14116. if (overrideBaseTime) {
  14117. fiber.selfBaseDuration = elapsedTime;
  14118. }
  14119. profilerStartTime = -1;
  14120. }
  14121. }
  14122. function transferActualDuration(fiber) {
  14123. // Transfer time spent rendering these children so we don't lose it
  14124. // after we rerender. This is used as a helper in special cases
  14125. // where we should count the work of multiple passes.
  14126. var child = fiber.child;
  14127. while (child) {
  14128. fiber.actualDuration += child.actualDuration;
  14129. child = child.sibling;
  14130. }
  14131. }
  14132. var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
  14133. var didReceiveUpdate = false;
  14134. var didWarnAboutBadClass;
  14135. var didWarnAboutModulePatternComponent;
  14136. var didWarnAboutContextTypeOnFunctionComponent;
  14137. var didWarnAboutGetDerivedStateOnFunctionComponent;
  14138. var didWarnAboutFunctionRefs;
  14139. var didWarnAboutReassigningProps;
  14140. var didWarnAboutRevealOrder;
  14141. var didWarnAboutTailOptions;
  14142. {
  14143. didWarnAboutBadClass = {};
  14144. didWarnAboutModulePatternComponent = {};
  14145. didWarnAboutContextTypeOnFunctionComponent = {};
  14146. didWarnAboutGetDerivedStateOnFunctionComponent = {};
  14147. didWarnAboutFunctionRefs = {};
  14148. didWarnAboutReassigningProps = false;
  14149. didWarnAboutRevealOrder = {};
  14150. didWarnAboutTailOptions = {};
  14151. }
  14152. function reconcileChildren(current, workInProgress, nextChildren, renderLanes) {
  14153. if (current === null) {
  14154. // If this is a fresh new component that hasn't been rendered yet, we
  14155. // won't update its child set by applying minimal side-effects. Instead,
  14156. // we will add them all to the child before it gets rendered. That means
  14157. // we can optimize this reconciliation pass by not tracking side-effects.
  14158. workInProgress.child = mountChildFibers(workInProgress, null, nextChildren, renderLanes);
  14159. } else {
  14160. // If the current child is the same as the work in progress, it means that
  14161. // we haven't yet started any work on these children. Therefore, we use
  14162. // the clone algorithm to create a copy of all the current children.
  14163. // If we had any progressed work already, that is invalid at this point so
  14164. // let's throw it out.
  14165. workInProgress.child = reconcileChildFibers(workInProgress, current.child, nextChildren, renderLanes);
  14166. }
  14167. }
  14168. function forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderLanes) {
  14169. // This function is fork of reconcileChildren. It's used in cases where we
  14170. // want to reconcile without matching against the existing set. This has the
  14171. // effect of all current children being unmounted; even if the type and key
  14172. // are the same, the old child is unmounted and a new child is created.
  14173. //
  14174. // To do this, we're going to go through the reconcile algorithm twice. In
  14175. // the first pass, we schedule a deletion for all the current children by
  14176. // passing null.
  14177. workInProgress.child = reconcileChildFibers(workInProgress, current.child, null, renderLanes); // In the second pass, we mount the new children. The trick here is that we
  14178. // pass null in place of where we usually pass the current child set. This has
  14179. // the effect of remounting all children regardless of whether their
  14180. // identities match.
  14181. workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderLanes);
  14182. }
  14183. function updateForwardRef(current, workInProgress, Component, nextProps, renderLanes) {
  14184. // TODO: current can be non-null here even if the component
  14185. // hasn't yet mounted. This happens after the first render suspends.
  14186. // We'll need to figure out if this is fine or can cause issues.
  14187. {
  14188. if (workInProgress.type !== workInProgress.elementType) {
  14189. // Lazy component props can't be validated in createElement
  14190. // because they're only guaranteed to be resolved here.
  14191. var innerPropTypes = Component.propTypes;
  14192. if (innerPropTypes) {
  14193. checkPropTypes(innerPropTypes, nextProps, // Resolved props
  14194. 'prop', getComponentName(Component));
  14195. }
  14196. }
  14197. }
  14198. var render = Component.render;
  14199. var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent
  14200. var nextChildren;
  14201. prepareToReadContext(workInProgress, renderLanes);
  14202. {
  14203. ReactCurrentOwner$1.current = workInProgress;
  14204. setIsRendering(true);
  14205. nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderLanes);
  14206. if ( workInProgress.mode & StrictMode) {
  14207. disableLogs();
  14208. try {
  14209. nextChildren = renderWithHooks(current, workInProgress, render, nextProps, ref, renderLanes);
  14210. } finally {
  14211. reenableLogs();
  14212. }
  14213. }
  14214. setIsRendering(false);
  14215. }
  14216. if (current !== null && !didReceiveUpdate) {
  14217. bailoutHooks(current, workInProgress, renderLanes);
  14218. return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
  14219. } // React DevTools reads this flag.
  14220. workInProgress.flags |= PerformedWork;
  14221. reconcileChildren(current, workInProgress, nextChildren, renderLanes);
  14222. return workInProgress.child;
  14223. }
  14224. function updateMemoComponent(current, workInProgress, Component, nextProps, updateLanes, renderLanes) {
  14225. if (current === null) {
  14226. var type = Component.type;
  14227. if (isSimpleFunctionComponent(type) && Component.compare === null && // SimpleMemoComponent codepath doesn't resolve outer props either.
  14228. Component.defaultProps === undefined) {
  14229. var resolvedType = type;
  14230. {
  14231. resolvedType = resolveFunctionForHotReloading(type);
  14232. } // If this is a plain function component without default props,
  14233. // and with only the default shallow comparison, we upgrade it
  14234. // to a SimpleMemoComponent to allow fast path updates.
  14235. workInProgress.tag = SimpleMemoComponent;
  14236. workInProgress.type = resolvedType;
  14237. {
  14238. validateFunctionComponentInDev(workInProgress, type);
  14239. }
  14240. return updateSimpleMemoComponent(current, workInProgress, resolvedType, nextProps, updateLanes, renderLanes);
  14241. }
  14242. {
  14243. var innerPropTypes = type.propTypes;
  14244. if (innerPropTypes) {
  14245. // Inner memo component props aren't currently validated in createElement.
  14246. // We could move it there, but we'd still need this for lazy code path.
  14247. checkPropTypes(innerPropTypes, nextProps, // Resolved props
  14248. 'prop', getComponentName(type));
  14249. }
  14250. }
  14251. var child = createFiberFromTypeAndProps(Component.type, null, nextProps, workInProgress, workInProgress.mode, renderLanes);
  14252. child.ref = workInProgress.ref;
  14253. child.return = workInProgress;
  14254. workInProgress.child = child;
  14255. return child;
  14256. }
  14257. {
  14258. var _type = Component.type;
  14259. var _innerPropTypes = _type.propTypes;
  14260. if (_innerPropTypes) {
  14261. // Inner memo component props aren't currently validated in createElement.
  14262. // We could move it there, but we'd still need this for lazy code path.
  14263. checkPropTypes(_innerPropTypes, nextProps, // Resolved props
  14264. 'prop', getComponentName(_type));
  14265. }
  14266. }
  14267. var currentChild = current.child; // This is always exactly one child
  14268. if (!includesSomeLane(updateLanes, renderLanes)) {
  14269. // This will be the props with resolved defaultProps,
  14270. // unlike current.memoizedProps which will be the unresolved ones.
  14271. var prevProps = currentChild.memoizedProps; // Default to shallow comparison
  14272. var compare = Component.compare;
  14273. compare = compare !== null ? compare : shallowEqual;
  14274. if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) {
  14275. return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
  14276. }
  14277. } // React DevTools reads this flag.
  14278. workInProgress.flags |= PerformedWork;
  14279. var newChild = createWorkInProgress(currentChild, nextProps);
  14280. newChild.ref = workInProgress.ref;
  14281. newChild.return = workInProgress;
  14282. workInProgress.child = newChild;
  14283. return newChild;
  14284. }
  14285. function updateSimpleMemoComponent(current, workInProgress, Component, nextProps, updateLanes, renderLanes) {
  14286. // TODO: current can be non-null here even if the component
  14287. // hasn't yet mounted. This happens when the inner render suspends.
  14288. // We'll need to figure out if this is fine or can cause issues.
  14289. {
  14290. if (workInProgress.type !== workInProgress.elementType) {
  14291. // Lazy component props can't be validated in createElement
  14292. // because they're only guaranteed to be resolved here.
  14293. var outerMemoType = workInProgress.elementType;
  14294. if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
  14295. // We warn when you define propTypes on lazy()
  14296. // so let's just skip over it to find memo() outer wrapper.
  14297. // Inner props for memo are validated later.
  14298. var lazyComponent = outerMemoType;
  14299. var payload = lazyComponent._payload;
  14300. var init = lazyComponent._init;
  14301. try {
  14302. outerMemoType = init(payload);
  14303. } catch (x) {
  14304. outerMemoType = null;
  14305. } // Inner propTypes will be validated in the function component path.
  14306. var outerPropTypes = outerMemoType && outerMemoType.propTypes;
  14307. if (outerPropTypes) {
  14308. checkPropTypes(outerPropTypes, nextProps, // Resolved (SimpleMemoComponent has no defaultProps)
  14309. 'prop', getComponentName(outerMemoType));
  14310. }
  14311. }
  14312. }
  14313. }
  14314. if (current !== null) {
  14315. var prevProps = current.memoizedProps;
  14316. if (shallowEqual(prevProps, nextProps) && current.ref === workInProgress.ref && ( // Prevent bailout if the implementation changed due to hot reload.
  14317. workInProgress.type === current.type )) {
  14318. didReceiveUpdate = false;
  14319. if (!includesSomeLane(renderLanes, updateLanes)) {
  14320. // The pending lanes were cleared at the beginning of beginWork. We're
  14321. // about to bail out, but there might be other lanes that weren't
  14322. // included in the current render. Usually, the priority level of the
  14323. // remaining updates is accumlated during the evaluation of the
  14324. // component (i.e. when processing the update queue). But since since
  14325. // we're bailing out early *without* evaluating the component, we need
  14326. // to account for it here, too. Reset to the value of the current fiber.
  14327. // NOTE: This only applies to SimpleMemoComponent, not MemoComponent,
  14328. // because a MemoComponent fiber does not have hooks or an update queue;
  14329. // rather, it wraps around an inner component, which may or may not
  14330. // contains hooks.
  14331. // TODO: Move the reset at in beginWork out of the common path so that
  14332. // this is no longer necessary.
  14333. workInProgress.lanes = current.lanes;
  14334. return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
  14335. } else if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) {
  14336. // This is a special case that only exists for legacy mode.
  14337. // See https://github.com/facebook/react/pull/19216.
  14338. didReceiveUpdate = true;
  14339. }
  14340. }
  14341. }
  14342. return updateFunctionComponent(current, workInProgress, Component, nextProps, renderLanes);
  14343. }
  14344. function updateOffscreenComponent(current, workInProgress, renderLanes) {
  14345. var nextProps = workInProgress.pendingProps;
  14346. var nextChildren = nextProps.children;
  14347. var prevState = current !== null ? current.memoizedState : null;
  14348. if (nextProps.mode === 'hidden' || nextProps.mode === 'unstable-defer-without-hiding') {
  14349. if ((workInProgress.mode & ConcurrentMode) === NoMode) {
  14350. // In legacy sync mode, don't defer the subtree. Render it now.
  14351. // TODO: Figure out what we should do in Blocking mode.
  14352. var nextState = {
  14353. baseLanes: NoLanes
  14354. };
  14355. workInProgress.memoizedState = nextState;
  14356. pushRenderLanes(workInProgress, renderLanes);
  14357. } else if (!includesSomeLane(renderLanes, OffscreenLane)) {
  14358. var nextBaseLanes;
  14359. if (prevState !== null) {
  14360. var prevBaseLanes = prevState.baseLanes;
  14361. nextBaseLanes = mergeLanes(prevBaseLanes, renderLanes);
  14362. } else {
  14363. nextBaseLanes = renderLanes;
  14364. } // Schedule this fiber to re-render at offscreen priority. Then bailout.
  14365. {
  14366. markSpawnedWork(OffscreenLane);
  14367. }
  14368. workInProgress.lanes = workInProgress.childLanes = laneToLanes(OffscreenLane);
  14369. var _nextState = {
  14370. baseLanes: nextBaseLanes
  14371. };
  14372. workInProgress.memoizedState = _nextState; // We're about to bail out, but we need to push this to the stack anyway
  14373. // to avoid a push/pop misalignment.
  14374. pushRenderLanes(workInProgress, nextBaseLanes);
  14375. return null;
  14376. } else {
  14377. // Rendering at offscreen, so we can clear the base lanes.
  14378. var _nextState2 = {
  14379. baseLanes: NoLanes
  14380. };
  14381. workInProgress.memoizedState = _nextState2; // Push the lanes that were skipped when we bailed out.
  14382. var subtreeRenderLanes = prevState !== null ? prevState.baseLanes : renderLanes;
  14383. pushRenderLanes(workInProgress, subtreeRenderLanes);
  14384. }
  14385. } else {
  14386. var _subtreeRenderLanes;
  14387. if (prevState !== null) {
  14388. _subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes); // Since we're not hidden anymore, reset the state
  14389. workInProgress.memoizedState = null;
  14390. } else {
  14391. // We weren't previously hidden, and we still aren't, so there's nothing
  14392. // special to do. Need to push to the stack regardless, though, to avoid
  14393. // a push/pop misalignment.
  14394. _subtreeRenderLanes = renderLanes;
  14395. }
  14396. pushRenderLanes(workInProgress, _subtreeRenderLanes);
  14397. }
  14398. reconcileChildren(current, workInProgress, nextChildren, renderLanes);
  14399. return workInProgress.child;
  14400. } // Note: These happen to have identical begin phases, for now. We shouldn't hold
  14401. // ourselves to this constraint, though. If the behavior diverges, we should
  14402. // fork the function.
  14403. var updateLegacyHiddenComponent = updateOffscreenComponent;
  14404. function updateFragment(current, workInProgress, renderLanes) {
  14405. var nextChildren = workInProgress.pendingProps;
  14406. reconcileChildren(current, workInProgress, nextChildren, renderLanes);
  14407. return workInProgress.child;
  14408. }
  14409. function updateMode(current, workInProgress, renderLanes) {
  14410. var nextChildren = workInProgress.pendingProps.children;
  14411. reconcileChildren(current, workInProgress, nextChildren, renderLanes);
  14412. return workInProgress.child;
  14413. }
  14414. function updateProfiler(current, workInProgress, renderLanes) {
  14415. {
  14416. workInProgress.flags |= Update; // Reset effect durations for the next eventual effect phase.
  14417. // These are reset during render to allow the DevTools commit hook a chance to read them,
  14418. var stateNode = workInProgress.stateNode;
  14419. stateNode.effectDuration = 0;
  14420. stateNode.passiveEffectDuration = 0;
  14421. }
  14422. var nextProps = workInProgress.pendingProps;
  14423. var nextChildren = nextProps.children;
  14424. reconcileChildren(current, workInProgress, nextChildren, renderLanes);
  14425. return workInProgress.child;
  14426. }
  14427. function markRef(current, workInProgress) {
  14428. var ref = workInProgress.ref;
  14429. if (current === null && ref !== null || current !== null && current.ref !== ref) {
  14430. // Schedule a Ref effect
  14431. workInProgress.flags |= Ref;
  14432. }
  14433. }
  14434. function updateFunctionComponent(current, workInProgress, Component, nextProps, renderLanes) {
  14435. {
  14436. if (workInProgress.type !== workInProgress.elementType) {
  14437. // Lazy component props can't be validated in createElement
  14438. // because they're only guaranteed to be resolved here.
  14439. var innerPropTypes = Component.propTypes;
  14440. if (innerPropTypes) {
  14441. checkPropTypes(innerPropTypes, nextProps, // Resolved props
  14442. 'prop', getComponentName(Component));
  14443. }
  14444. }
  14445. }
  14446. var context;
  14447. {
  14448. var unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
  14449. context = getMaskedContext(workInProgress, unmaskedContext);
  14450. }
  14451. var nextChildren;
  14452. prepareToReadContext(workInProgress, renderLanes);
  14453. {
  14454. ReactCurrentOwner$1.current = workInProgress;
  14455. setIsRendering(true);
  14456. nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderLanes);
  14457. if ( workInProgress.mode & StrictMode) {
  14458. disableLogs();
  14459. try {
  14460. nextChildren = renderWithHooks(current, workInProgress, Component, nextProps, context, renderLanes);
  14461. } finally {
  14462. reenableLogs();
  14463. }
  14464. }
  14465. setIsRendering(false);
  14466. }
  14467. if (current !== null && !didReceiveUpdate) {
  14468. bailoutHooks(current, workInProgress, renderLanes);
  14469. return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
  14470. } // React DevTools reads this flag.
  14471. workInProgress.flags |= PerformedWork;
  14472. reconcileChildren(current, workInProgress, nextChildren, renderLanes);
  14473. return workInProgress.child;
  14474. }
  14475. function updateClassComponent(current, workInProgress, Component, nextProps, renderLanes) {
  14476. {
  14477. if (workInProgress.type !== workInProgress.elementType) {
  14478. // Lazy component props can't be validated in createElement
  14479. // because they're only guaranteed to be resolved here.
  14480. var innerPropTypes = Component.propTypes;
  14481. if (innerPropTypes) {
  14482. checkPropTypes(innerPropTypes, nextProps, // Resolved props
  14483. 'prop', getComponentName(Component));
  14484. }
  14485. }
  14486. } // Push context providers early to prevent context stack mismatches.
  14487. // During mounting we don't know the child context yet as the instance doesn't exist.
  14488. // We will invalidate the child context in finishClassComponent() right after rendering.
  14489. var hasContext;
  14490. if (isContextProvider(Component)) {
  14491. hasContext = true;
  14492. pushContextProvider(workInProgress);
  14493. } else {
  14494. hasContext = false;
  14495. }
  14496. prepareToReadContext(workInProgress, renderLanes);
  14497. var instance = workInProgress.stateNode;
  14498. var shouldUpdate;
  14499. if (instance === null) {
  14500. if (current !== null) {
  14501. // A class component without an instance only mounts if it suspended
  14502. // inside a non-concurrent tree, in an inconsistent state. We want to
  14503. // treat it like a new mount, even though an empty version of it already
  14504. // committed. Disconnect the alternate pointers.
  14505. current.alternate = null;
  14506. workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
  14507. workInProgress.flags |= Placement;
  14508. } // In the initial pass we might need to construct the instance.
  14509. constructClassInstance(workInProgress, Component, nextProps);
  14510. mountClassInstance(workInProgress, Component, nextProps, renderLanes);
  14511. shouldUpdate = true;
  14512. } else if (current === null) {
  14513. // In a resume, we'll already have an instance we can reuse.
  14514. shouldUpdate = resumeMountClassInstance(workInProgress, Component, nextProps, renderLanes);
  14515. } else {
  14516. shouldUpdate = updateClassInstance(current, workInProgress, Component, nextProps, renderLanes);
  14517. }
  14518. var nextUnitOfWork = finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderLanes);
  14519. {
  14520. var inst = workInProgress.stateNode;
  14521. if (shouldUpdate && inst.props !== nextProps) {
  14522. if (!didWarnAboutReassigningProps) {
  14523. error('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');
  14524. }
  14525. didWarnAboutReassigningProps = true;
  14526. }
  14527. }
  14528. return nextUnitOfWork;
  14529. }
  14530. function finishClassComponent(current, workInProgress, Component, shouldUpdate, hasContext, renderLanes) {
  14531. // Refs should update even if shouldComponentUpdate returns false
  14532. markRef(current, workInProgress);
  14533. var didCaptureError = (workInProgress.flags & DidCapture) !== NoFlags;
  14534. if (!shouldUpdate && !didCaptureError) {
  14535. // Context providers should defer to sCU for rendering
  14536. if (hasContext) {
  14537. invalidateContextProvider(workInProgress, Component, false);
  14538. }
  14539. return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
  14540. }
  14541. var instance = workInProgress.stateNode; // Rerender
  14542. ReactCurrentOwner$1.current = workInProgress;
  14543. var nextChildren;
  14544. if (didCaptureError && typeof Component.getDerivedStateFromError !== 'function') {
  14545. // If we captured an error, but getDerivedStateFromError is not defined,
  14546. // unmount all the children. componentDidCatch will schedule an update to
  14547. // re-render a fallback. This is temporary until we migrate everyone to
  14548. // the new API.
  14549. // TODO: Warn in a future release.
  14550. nextChildren = null;
  14551. {
  14552. stopProfilerTimerIfRunning();
  14553. }
  14554. } else {
  14555. {
  14556. setIsRendering(true);
  14557. nextChildren = instance.render();
  14558. if ( workInProgress.mode & StrictMode) {
  14559. disableLogs();
  14560. try {
  14561. instance.render();
  14562. } finally {
  14563. reenableLogs();
  14564. }
  14565. }
  14566. setIsRendering(false);
  14567. }
  14568. } // React DevTools reads this flag.
  14569. workInProgress.flags |= PerformedWork;
  14570. if (current !== null && didCaptureError) {
  14571. // If we're recovering from an error, reconcile without reusing any of
  14572. // the existing children. Conceptually, the normal children and the children
  14573. // that are shown on error are two different sets, so we shouldn't reuse
  14574. // normal children even if their identities match.
  14575. forceUnmountCurrentAndReconcile(current, workInProgress, nextChildren, renderLanes);
  14576. } else {
  14577. reconcileChildren(current, workInProgress, nextChildren, renderLanes);
  14578. } // Memoize state using the values we just used to render.
  14579. // TODO: Restructure so we never read values from the instance.
  14580. workInProgress.memoizedState = instance.state; // The context might have changed so we need to recalculate it.
  14581. if (hasContext) {
  14582. invalidateContextProvider(workInProgress, Component, true);
  14583. }
  14584. return workInProgress.child;
  14585. }
  14586. function pushHostRootContext(workInProgress) {
  14587. var root = workInProgress.stateNode;
  14588. if (root.pendingContext) {
  14589. pushTopLevelContextObject(workInProgress, root.pendingContext, root.pendingContext !== root.context);
  14590. } else if (root.context) {
  14591. // Should always be set
  14592. pushTopLevelContextObject(workInProgress, root.context, false);
  14593. }
  14594. pushHostContainer(workInProgress, root.containerInfo);
  14595. }
  14596. function updateHostRoot(current, workInProgress, renderLanes) {
  14597. pushHostRootContext(workInProgress);
  14598. var updateQueue = workInProgress.updateQueue;
  14599. if (!(current !== null && updateQueue !== null)) {
  14600. {
  14601. throw Error( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." );
  14602. }
  14603. }
  14604. var nextProps = workInProgress.pendingProps;
  14605. var prevState = workInProgress.memoizedState;
  14606. var prevChildren = prevState !== null ? prevState.element : null;
  14607. cloneUpdateQueue(current, workInProgress);
  14608. processUpdateQueue(workInProgress, nextProps, null, renderLanes);
  14609. var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property
  14610. // being called "element".
  14611. var nextChildren = nextState.element;
  14612. if (nextChildren === prevChildren) {
  14613. resetHydrationState();
  14614. return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
  14615. }
  14616. var root = workInProgress.stateNode;
  14617. if (root.hydrate && enterHydrationState(workInProgress)) {
  14618. // If we don't have any current children this might be the first pass.
  14619. // We always try to hydrate. If this isn't a hydration pass there won't
  14620. // be any children to hydrate which is effectively the same thing as
  14621. // not hydrating.
  14622. {
  14623. var mutableSourceEagerHydrationData = root.mutableSourceEagerHydrationData;
  14624. if (mutableSourceEagerHydrationData != null) {
  14625. for (var i = 0; i < mutableSourceEagerHydrationData.length; i += 2) {
  14626. var mutableSource = mutableSourceEagerHydrationData[i];
  14627. var version = mutableSourceEagerHydrationData[i + 1];
  14628. setWorkInProgressVersion(mutableSource, version);
  14629. }
  14630. }
  14631. }
  14632. var child = mountChildFibers(workInProgress, null, nextChildren, renderLanes);
  14633. workInProgress.child = child;
  14634. var node = child;
  14635. while (node) {
  14636. // Mark each child as hydrating. This is a fast path to know whether this
  14637. // tree is part of a hydrating tree. This is used to determine if a child
  14638. // node has fully mounted yet, and for scheduling event replaying.
  14639. // Conceptually this is similar to Placement in that a new subtree is
  14640. // inserted into the React tree here. It just happens to not need DOM
  14641. // mutations because it already exists.
  14642. node.flags = node.flags & ~Placement | Hydrating;
  14643. node = node.sibling;
  14644. }
  14645. } else {
  14646. // Otherwise reset hydration state in case we aborted and resumed another
  14647. // root.
  14648. reconcileChildren(current, workInProgress, nextChildren, renderLanes);
  14649. resetHydrationState();
  14650. }
  14651. return workInProgress.child;
  14652. }
  14653. function updateHostComponent(current, workInProgress, renderLanes) {
  14654. pushHostContext(workInProgress);
  14655. if (current === null) {
  14656. tryToClaimNextHydratableInstance(workInProgress);
  14657. }
  14658. var type = workInProgress.type;
  14659. var nextProps = workInProgress.pendingProps;
  14660. var prevProps = current !== null ? current.memoizedProps : null;
  14661. var nextChildren = nextProps.children;
  14662. var isDirectTextChild = shouldSetTextContent(type, nextProps);
  14663. if (isDirectTextChild) {
  14664. // We special case a direct text child of a host node. This is a common
  14665. // case. We won't handle it as a reified child. We will instead handle
  14666. // this in the host environment that also has access to this prop. That
  14667. // avoids allocating another HostText fiber and traversing it.
  14668. nextChildren = null;
  14669. } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) {
  14670. // If we're switching from a direct text child to a normal child, or to
  14671. // empty, we need to schedule the text content to be reset.
  14672. workInProgress.flags |= ContentReset;
  14673. }
  14674. markRef(current, workInProgress);
  14675. reconcileChildren(current, workInProgress, nextChildren, renderLanes);
  14676. return workInProgress.child;
  14677. }
  14678. function updateHostText(current, workInProgress) {
  14679. if (current === null) {
  14680. tryToClaimNextHydratableInstance(workInProgress);
  14681. } // Nothing to do here. This is terminal. We'll do the completion step
  14682. // immediately after.
  14683. return null;
  14684. }
  14685. function mountLazyComponent(_current, workInProgress, elementType, updateLanes, renderLanes) {
  14686. if (_current !== null) {
  14687. // A lazy component only mounts if it suspended inside a non-
  14688. // concurrent tree, in an inconsistent state. We want to treat it like
  14689. // a new mount, even though an empty version of it already committed.
  14690. // Disconnect the alternate pointers.
  14691. _current.alternate = null;
  14692. workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
  14693. workInProgress.flags |= Placement;
  14694. }
  14695. var props = workInProgress.pendingProps;
  14696. var lazyComponent = elementType;
  14697. var payload = lazyComponent._payload;
  14698. var init = lazyComponent._init;
  14699. var Component = init(payload); // Store the unwrapped component in the type.
  14700. workInProgress.type = Component;
  14701. var resolvedTag = workInProgress.tag = resolveLazyComponentTag(Component);
  14702. var resolvedProps = resolveDefaultProps(Component, props);
  14703. var child;
  14704. switch (resolvedTag) {
  14705. case FunctionComponent:
  14706. {
  14707. {
  14708. validateFunctionComponentInDev(workInProgress, Component);
  14709. workInProgress.type = Component = resolveFunctionForHotReloading(Component);
  14710. }
  14711. child = updateFunctionComponent(null, workInProgress, Component, resolvedProps, renderLanes);
  14712. return child;
  14713. }
  14714. case ClassComponent:
  14715. {
  14716. {
  14717. workInProgress.type = Component = resolveClassForHotReloading(Component);
  14718. }
  14719. child = updateClassComponent(null, workInProgress, Component, resolvedProps, renderLanes);
  14720. return child;
  14721. }
  14722. case ForwardRef:
  14723. {
  14724. {
  14725. workInProgress.type = Component = resolveForwardRefForHotReloading(Component);
  14726. }
  14727. child = updateForwardRef(null, workInProgress, Component, resolvedProps, renderLanes);
  14728. return child;
  14729. }
  14730. case MemoComponent:
  14731. {
  14732. {
  14733. if (workInProgress.type !== workInProgress.elementType) {
  14734. var outerPropTypes = Component.propTypes;
  14735. if (outerPropTypes) {
  14736. checkPropTypes(outerPropTypes, resolvedProps, // Resolved for outer only
  14737. 'prop', getComponentName(Component));
  14738. }
  14739. }
  14740. }
  14741. child = updateMemoComponent(null, workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too
  14742. updateLanes, renderLanes);
  14743. return child;
  14744. }
  14745. }
  14746. var hint = '';
  14747. {
  14748. if (Component !== null && typeof Component === 'object' && Component.$$typeof === REACT_LAZY_TYPE) {
  14749. hint = ' Did you wrap a component in React.lazy() more than once?';
  14750. }
  14751. } // This message intentionally doesn't mention ForwardRef or MemoComponent
  14752. // because the fact that it's a separate type of work is an
  14753. // implementation detail.
  14754. {
  14755. {
  14756. throw Error( "Element type is invalid. Received a promise that resolves to: " + Component + ". Lazy element type must resolve to a class or function." + hint );
  14757. }
  14758. }
  14759. }
  14760. function mountIncompleteClassComponent(_current, workInProgress, Component, nextProps, renderLanes) {
  14761. if (_current !== null) {
  14762. // An incomplete component only mounts if it suspended inside a non-
  14763. // concurrent tree, in an inconsistent state. We want to treat it like
  14764. // a new mount, even though an empty version of it already committed.
  14765. // Disconnect the alternate pointers.
  14766. _current.alternate = null;
  14767. workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
  14768. workInProgress.flags |= Placement;
  14769. } // Promote the fiber to a class and try rendering again.
  14770. workInProgress.tag = ClassComponent; // The rest of this function is a fork of `updateClassComponent`
  14771. // Push context providers early to prevent context stack mismatches.
  14772. // During mounting we don't know the child context yet as the instance doesn't exist.
  14773. // We will invalidate the child context in finishClassComponent() right after rendering.
  14774. var hasContext;
  14775. if (isContextProvider(Component)) {
  14776. hasContext = true;
  14777. pushContextProvider(workInProgress);
  14778. } else {
  14779. hasContext = false;
  14780. }
  14781. prepareToReadContext(workInProgress, renderLanes);
  14782. constructClassInstance(workInProgress, Component, nextProps);
  14783. mountClassInstance(workInProgress, Component, nextProps, renderLanes);
  14784. return finishClassComponent(null, workInProgress, Component, true, hasContext, renderLanes);
  14785. }
  14786. function mountIndeterminateComponent(_current, workInProgress, Component, renderLanes) {
  14787. if (_current !== null) {
  14788. // An indeterminate component only mounts if it suspended inside a non-
  14789. // concurrent tree, in an inconsistent state. We want to treat it like
  14790. // a new mount, even though an empty version of it already committed.
  14791. // Disconnect the alternate pointers.
  14792. _current.alternate = null;
  14793. workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect
  14794. workInProgress.flags |= Placement;
  14795. }
  14796. var props = workInProgress.pendingProps;
  14797. var context;
  14798. {
  14799. var unmaskedContext = getUnmaskedContext(workInProgress, Component, false);
  14800. context = getMaskedContext(workInProgress, unmaskedContext);
  14801. }
  14802. prepareToReadContext(workInProgress, renderLanes);
  14803. var value;
  14804. {
  14805. if (Component.prototype && typeof Component.prototype.render === 'function') {
  14806. var componentName = getComponentName(Component) || 'Unknown';
  14807. if (!didWarnAboutBadClass[componentName]) {
  14808. error("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);
  14809. didWarnAboutBadClass[componentName] = true;
  14810. }
  14811. }
  14812. if (workInProgress.mode & StrictMode) {
  14813. ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null);
  14814. }
  14815. setIsRendering(true);
  14816. ReactCurrentOwner$1.current = workInProgress;
  14817. value = renderWithHooks(null, workInProgress, Component, props, context, renderLanes);
  14818. setIsRendering(false);
  14819. } // React DevTools reads this flag.
  14820. workInProgress.flags |= PerformedWork;
  14821. {
  14822. // Support for module components is deprecated and is removed behind a flag.
  14823. // Whether or not it would crash later, we want to show a good message in DEV first.
  14824. if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
  14825. var _componentName = getComponentName(Component) || 'Unknown';
  14826. if (!didWarnAboutModulePatternComponent[_componentName]) {
  14827. error('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);
  14828. didWarnAboutModulePatternComponent[_componentName] = true;
  14829. }
  14830. }
  14831. }
  14832. if ( // Run these checks in production only if the flag is off.
  14833. // Eventually we'll delete this branch altogether.
  14834. typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
  14835. {
  14836. var _componentName2 = getComponentName(Component) || 'Unknown';
  14837. if (!didWarnAboutModulePatternComponent[_componentName2]) {
  14838. error('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.', _componentName2, _componentName2, _componentName2);
  14839. didWarnAboutModulePatternComponent[_componentName2] = true;
  14840. }
  14841. } // Proceed under the assumption that this is a class instance
  14842. workInProgress.tag = ClassComponent; // Throw out any hooks that were used.
  14843. workInProgress.memoizedState = null;
  14844. workInProgress.updateQueue = null; // Push context providers early to prevent context stack mismatches.
  14845. // During mounting we don't know the child context yet as the instance doesn't exist.
  14846. // We will invalidate the child context in finishClassComponent() right after rendering.
  14847. var hasContext = false;
  14848. if (isContextProvider(Component)) {
  14849. hasContext = true;
  14850. pushContextProvider(workInProgress);
  14851. } else {
  14852. hasContext = false;
  14853. }
  14854. workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null;
  14855. initializeUpdateQueue(workInProgress);
  14856. var getDerivedStateFromProps = Component.getDerivedStateFromProps;
  14857. if (typeof getDerivedStateFromProps === 'function') {
  14858. applyDerivedStateFromProps(workInProgress, Component, getDerivedStateFromProps, props);
  14859. }
  14860. adoptClassInstance(workInProgress, value);
  14861. mountClassInstance(workInProgress, Component, props, renderLanes);
  14862. return finishClassComponent(null, workInProgress, Component, true, hasContext, renderLanes);
  14863. } else {
  14864. // Proceed under the assumption that this is a function component
  14865. workInProgress.tag = FunctionComponent;
  14866. {
  14867. if ( workInProgress.mode & StrictMode) {
  14868. disableLogs();
  14869. try {
  14870. value = renderWithHooks(null, workInProgress, Component, props, context, renderLanes);
  14871. } finally {
  14872. reenableLogs();
  14873. }
  14874. }
  14875. }
  14876. reconcileChildren(null, workInProgress, value, renderLanes);
  14877. {
  14878. validateFunctionComponentInDev(workInProgress, Component);
  14879. }
  14880. return workInProgress.child;
  14881. }
  14882. }
  14883. function validateFunctionComponentInDev(workInProgress, Component) {
  14884. {
  14885. if (Component) {
  14886. if (Component.childContextTypes) {
  14887. error('%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component');
  14888. }
  14889. }
  14890. if (workInProgress.ref !== null) {
  14891. var info = '';
  14892. var ownerName = getCurrentFiberOwnerNameInDevOrNull();
  14893. if (ownerName) {
  14894. info += '\n\nCheck the render method of `' + ownerName + '`.';
  14895. }
  14896. var warningKey = ownerName || workInProgress._debugID || '';
  14897. var debugSource = workInProgress._debugSource;
  14898. if (debugSource) {
  14899. warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
  14900. }
  14901. if (!didWarnAboutFunctionRefs[warningKey]) {
  14902. didWarnAboutFunctionRefs[warningKey] = true;
  14903. error('Function components cannot be given refs. ' + 'Attempts to access this ref will fail. ' + 'Did you mean to use React.forwardRef()?%s', info);
  14904. }
  14905. }
  14906. if (typeof Component.getDerivedStateFromProps === 'function') {
  14907. var _componentName3 = getComponentName(Component) || 'Unknown';
  14908. if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]) {
  14909. error('%s: Function components do not support getDerivedStateFromProps.', _componentName3);
  14910. didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] = true;
  14911. }
  14912. }
  14913. if (typeof Component.contextType === 'object' && Component.contextType !== null) {
  14914. var _componentName4 = getComponentName(Component) || 'Unknown';
  14915. if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) {
  14916. error('%s: Function components do not support contextType.', _componentName4);
  14917. didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true;
  14918. }
  14919. }
  14920. }
  14921. }
  14922. var SUSPENDED_MARKER = {
  14923. dehydrated: null,
  14924. retryLane: NoLane
  14925. };
  14926. function mountSuspenseOffscreenState(renderLanes) {
  14927. return {
  14928. baseLanes: renderLanes
  14929. };
  14930. }
  14931. function updateSuspenseOffscreenState(prevOffscreenState, renderLanes) {
  14932. return {
  14933. baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes)
  14934. };
  14935. } // TODO: Probably should inline this back
  14936. function shouldRemainOnFallback(suspenseContext, current, workInProgress, renderLanes) {
  14937. // If we're already showing a fallback, there are cases where we need to
  14938. // remain on that fallback regardless of whether the content has resolved.
  14939. // For example, SuspenseList coordinates when nested content appears.
  14940. if (current !== null) {
  14941. var suspenseState = current.memoizedState;
  14942. if (suspenseState === null) {
  14943. // Currently showing content. Don't hide it, even if ForceSuspenseFallack
  14944. // is true. More precise name might be "ForceRemainSuspenseFallback".
  14945. // Note: This is a factoring smell. Can't remain on a fallback if there's
  14946. // no fallback to remain on.
  14947. return false;
  14948. }
  14949. } // Not currently showing content. Consult the Suspense context.
  14950. return hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
  14951. }
  14952. function getRemainingWorkInPrimaryTree(current, renderLanes) {
  14953. // TODO: Should not remove render lanes that were pinged during this render
  14954. return removeLanes(current.childLanes, renderLanes);
  14955. }
  14956. function updateSuspenseComponent(current, workInProgress, renderLanes) {
  14957. var nextProps = workInProgress.pendingProps; // This is used by DevTools to force a boundary to suspend.
  14958. {
  14959. if (shouldSuspend(workInProgress)) {
  14960. workInProgress.flags |= DidCapture;
  14961. }
  14962. }
  14963. var suspenseContext = suspenseStackCursor.current;
  14964. var showFallback = false;
  14965. var didSuspend = (workInProgress.flags & DidCapture) !== NoFlags;
  14966. if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) {
  14967. // Something in this boundary's subtree already suspended. Switch to
  14968. // rendering the fallback children.
  14969. showFallback = true;
  14970. workInProgress.flags &= ~DidCapture;
  14971. } else {
  14972. // Attempting the main content
  14973. if (current === null || current.memoizedState !== null) {
  14974. // This is a new mount or this boundary is already showing a fallback state.
  14975. // Mark this subtree context as having at least one invisible parent that could
  14976. // handle the fallback state.
  14977. // Boundaries without fallbacks or should be avoided are not considered since
  14978. // they cannot handle preferred fallback states.
  14979. if (nextProps.fallback !== undefined && nextProps.unstable_avoidThisFallback !== true) {
  14980. suspenseContext = addSubtreeSuspenseContext(suspenseContext, InvisibleParentSuspenseContext);
  14981. }
  14982. }
  14983. }
  14984. suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
  14985. pushSuspenseContext(workInProgress, suspenseContext); // OK, the next part is confusing. We're about to reconcile the Suspense
  14986. // boundary's children. This involves some custom reconcilation logic. Two
  14987. // main reasons this is so complicated.
  14988. //
  14989. // First, Legacy Mode has different semantics for backwards compatibility. The
  14990. // primary tree will commit in an inconsistent state, so when we do the
  14991. // second pass to render the fallback, we do some exceedingly, uh, clever
  14992. // hacks to make that not totally break. Like transferring effects and
  14993. // deletions from hidden tree. In Concurrent Mode, it's much simpler,
  14994. // because we bailout on the primary tree completely and leave it in its old
  14995. // state, no effects. Same as what we do for Offscreen (except that
  14996. // Offscreen doesn't have the first render pass).
  14997. //
  14998. // Second is hydration. During hydration, the Suspense fiber has a slightly
  14999. // different layout, where the child points to a dehydrated fragment, which
  15000. // contains the DOM rendered by the server.
  15001. //
  15002. // Third, even if you set all that aside, Suspense is like error boundaries in
  15003. // that we first we try to render one tree, and if that fails, we render again
  15004. // and switch to a different tree. Like a try/catch block. So we have to track
  15005. // which branch we're currently rendering. Ideally we would model this using
  15006. // a stack.
  15007. if (current === null) {
  15008. // Initial mount
  15009. // If we're currently hydrating, try to hydrate this boundary.
  15010. // But only if this has a fallback.
  15011. if (nextProps.fallback !== undefined) {
  15012. tryToClaimNextHydratableInstance(workInProgress); // This could've been a dehydrated suspense component.
  15013. }
  15014. var nextPrimaryChildren = nextProps.children;
  15015. var nextFallbackChildren = nextProps.fallback;
  15016. if (showFallback) {
  15017. var fallbackFragment = mountSuspenseFallbackChildren(workInProgress, nextPrimaryChildren, nextFallbackChildren, renderLanes);
  15018. var primaryChildFragment = workInProgress.child;
  15019. primaryChildFragment.memoizedState = mountSuspenseOffscreenState(renderLanes);
  15020. workInProgress.memoizedState = SUSPENDED_MARKER;
  15021. return fallbackFragment;
  15022. } else if (typeof nextProps.unstable_expectedLoadTime === 'number') {
  15023. // This is a CPU-bound tree. Skip this tree and show a placeholder to
  15024. // unblock the surrounding content. Then immediately retry after the
  15025. // initial commit.
  15026. var _fallbackFragment = mountSuspenseFallbackChildren(workInProgress, nextPrimaryChildren, nextFallbackChildren, renderLanes);
  15027. var _primaryChildFragment = workInProgress.child;
  15028. _primaryChildFragment.memoizedState = mountSuspenseOffscreenState(renderLanes);
  15029. workInProgress.memoizedState = SUSPENDED_MARKER; // Since nothing actually suspended, there will nothing to ping this to
  15030. // get it started back up to attempt the next item. While in terms of
  15031. // priority this work has the same priority as this current render, it's
  15032. // not part of the same transition once the transition has committed. If
  15033. // it's sync, we still want to yield so that it can be painted.
  15034. // Conceptually, this is really the same as pinging. We can use any
  15035. // RetryLane even if it's the one currently rendering since we're leaving
  15036. // it behind on this node.
  15037. workInProgress.lanes = SomeRetryLane;
  15038. {
  15039. markSpawnedWork(SomeRetryLane);
  15040. }
  15041. return _fallbackFragment;
  15042. } else {
  15043. return mountSuspensePrimaryChildren(workInProgress, nextPrimaryChildren, renderLanes);
  15044. }
  15045. } else {
  15046. // This is an update.
  15047. // If the current fiber has a SuspenseState, that means it's already showing
  15048. // a fallback.
  15049. var prevState = current.memoizedState;
  15050. if (prevState !== null) {
  15051. if (showFallback) {
  15052. var _nextFallbackChildren2 = nextProps.fallback;
  15053. var _nextPrimaryChildren2 = nextProps.children;
  15054. var _fallbackChildFragment = updateSuspenseFallbackChildren(current, workInProgress, _nextPrimaryChildren2, _nextFallbackChildren2, renderLanes);
  15055. var _primaryChildFragment3 = workInProgress.child;
  15056. var prevOffscreenState = current.child.memoizedState;
  15057. _primaryChildFragment3.memoizedState = prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes) : updateSuspenseOffscreenState(prevOffscreenState, renderLanes);
  15058. _primaryChildFragment3.childLanes = getRemainingWorkInPrimaryTree(current, renderLanes);
  15059. workInProgress.memoizedState = SUSPENDED_MARKER;
  15060. return _fallbackChildFragment;
  15061. } else {
  15062. var _nextPrimaryChildren3 = nextProps.children;
  15063. var _primaryChildFragment4 = updateSuspensePrimaryChildren(current, workInProgress, _nextPrimaryChildren3, renderLanes);
  15064. workInProgress.memoizedState = null;
  15065. return _primaryChildFragment4;
  15066. }
  15067. } else {
  15068. // The current tree is not already showing a fallback.
  15069. if (showFallback) {
  15070. // Timed out.
  15071. var _nextFallbackChildren3 = nextProps.fallback;
  15072. var _nextPrimaryChildren4 = nextProps.children;
  15073. var _fallbackChildFragment2 = updateSuspenseFallbackChildren(current, workInProgress, _nextPrimaryChildren4, _nextFallbackChildren3, renderLanes);
  15074. var _primaryChildFragment5 = workInProgress.child;
  15075. var _prevOffscreenState = current.child.memoizedState;
  15076. _primaryChildFragment5.memoizedState = _prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes) : updateSuspenseOffscreenState(_prevOffscreenState, renderLanes);
  15077. _primaryChildFragment5.childLanes = getRemainingWorkInPrimaryTree(current, renderLanes); // Skip the primary children, and continue working on the
  15078. // fallback children.
  15079. workInProgress.memoizedState = SUSPENDED_MARKER;
  15080. return _fallbackChildFragment2;
  15081. } else {
  15082. // Still haven't timed out. Continue rendering the children, like we
  15083. // normally do.
  15084. var _nextPrimaryChildren5 = nextProps.children;
  15085. var _primaryChildFragment6 = updateSuspensePrimaryChildren(current, workInProgress, _nextPrimaryChildren5, renderLanes);
  15086. workInProgress.memoizedState = null;
  15087. return _primaryChildFragment6;
  15088. }
  15089. }
  15090. }
  15091. }
  15092. function mountSuspensePrimaryChildren(workInProgress, primaryChildren, renderLanes) {
  15093. var mode = workInProgress.mode;
  15094. var primaryChildProps = {
  15095. mode: 'visible',
  15096. children: primaryChildren
  15097. };
  15098. var primaryChildFragment = createFiberFromOffscreen(primaryChildProps, mode, renderLanes, null);
  15099. primaryChildFragment.return = workInProgress;
  15100. workInProgress.child = primaryChildFragment;
  15101. return primaryChildFragment;
  15102. }
  15103. function mountSuspenseFallbackChildren(workInProgress, primaryChildren, fallbackChildren, renderLanes) {
  15104. var mode = workInProgress.mode;
  15105. var progressedPrimaryFragment = workInProgress.child;
  15106. var primaryChildProps = {
  15107. mode: 'hidden',
  15108. children: primaryChildren
  15109. };
  15110. var primaryChildFragment;
  15111. var fallbackChildFragment;
  15112. if ((mode & BlockingMode) === NoMode && progressedPrimaryFragment !== null) {
  15113. // In legacy mode, we commit the primary tree as if it successfully
  15114. // completed, even though it's in an inconsistent state.
  15115. primaryChildFragment = progressedPrimaryFragment;
  15116. primaryChildFragment.childLanes = NoLanes;
  15117. primaryChildFragment.pendingProps = primaryChildProps;
  15118. if ( workInProgress.mode & ProfileMode) {
  15119. // Reset the durations from the first pass so they aren't included in the
  15120. // final amounts. This seems counterintuitive, since we're intentionally
  15121. // not measuring part of the render phase, but this makes it match what we
  15122. // do in Concurrent Mode.
  15123. primaryChildFragment.actualDuration = 0;
  15124. primaryChildFragment.actualStartTime = -1;
  15125. primaryChildFragment.selfBaseDuration = 0;
  15126. primaryChildFragment.treeBaseDuration = 0;
  15127. }
  15128. fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes, null);
  15129. } else {
  15130. primaryChildFragment = createFiberFromOffscreen(primaryChildProps, mode, NoLanes, null);
  15131. fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes, null);
  15132. }
  15133. primaryChildFragment.return = workInProgress;
  15134. fallbackChildFragment.return = workInProgress;
  15135. primaryChildFragment.sibling = fallbackChildFragment;
  15136. workInProgress.child = primaryChildFragment;
  15137. return fallbackChildFragment;
  15138. }
  15139. function createWorkInProgressOffscreenFiber(current, offscreenProps) {
  15140. // The props argument to `createWorkInProgress` is `any` typed, so we use this
  15141. // wrapper function to constrain it.
  15142. return createWorkInProgress(current, offscreenProps);
  15143. }
  15144. function updateSuspensePrimaryChildren(current, workInProgress, primaryChildren, renderLanes) {
  15145. var currentPrimaryChildFragment = current.child;
  15146. var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
  15147. var primaryChildFragment = createWorkInProgressOffscreenFiber(currentPrimaryChildFragment, {
  15148. mode: 'visible',
  15149. children: primaryChildren
  15150. });
  15151. if ((workInProgress.mode & BlockingMode) === NoMode) {
  15152. primaryChildFragment.lanes = renderLanes;
  15153. }
  15154. primaryChildFragment.return = workInProgress;
  15155. primaryChildFragment.sibling = null;
  15156. if (currentFallbackChildFragment !== null) {
  15157. // Delete the fallback child fragment
  15158. currentFallbackChildFragment.nextEffect = null;
  15159. currentFallbackChildFragment.flags = Deletion;
  15160. workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChildFragment;
  15161. }
  15162. workInProgress.child = primaryChildFragment;
  15163. return primaryChildFragment;
  15164. }
  15165. function updateSuspenseFallbackChildren(current, workInProgress, primaryChildren, fallbackChildren, renderLanes) {
  15166. var mode = workInProgress.mode;
  15167. var currentPrimaryChildFragment = current.child;
  15168. var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
  15169. var primaryChildProps = {
  15170. mode: 'hidden',
  15171. children: primaryChildren
  15172. };
  15173. var primaryChildFragment;
  15174. if ( // In legacy mode, we commit the primary tree as if it successfully
  15175. // completed, even though it's in an inconsistent state.
  15176. (mode & BlockingMode) === NoMode && // Make sure we're on the second pass, i.e. the primary child fragment was
  15177. // already cloned. In legacy mode, the only case where this isn't true is
  15178. // when DevTools forces us to display a fallback; we skip the first render
  15179. // pass entirely and go straight to rendering the fallback. (In Concurrent
  15180. // Mode, SuspenseList can also trigger this scenario, but this is a legacy-
  15181. // only codepath.)
  15182. workInProgress.child !== currentPrimaryChildFragment) {
  15183. var progressedPrimaryFragment = workInProgress.child;
  15184. primaryChildFragment = progressedPrimaryFragment;
  15185. primaryChildFragment.childLanes = NoLanes;
  15186. primaryChildFragment.pendingProps = primaryChildProps;
  15187. if ( workInProgress.mode & ProfileMode) {
  15188. // Reset the durations from the first pass so they aren't included in the
  15189. // final amounts. This seems counterintuitive, since we're intentionally
  15190. // not measuring part of the render phase, but this makes it match what we
  15191. // do in Concurrent Mode.
  15192. primaryChildFragment.actualDuration = 0;
  15193. primaryChildFragment.actualStartTime = -1;
  15194. primaryChildFragment.selfBaseDuration = currentPrimaryChildFragment.selfBaseDuration;
  15195. primaryChildFragment.treeBaseDuration = currentPrimaryChildFragment.treeBaseDuration;
  15196. } // The fallback fiber was added as a deletion effect during the first pass.
  15197. // However, since we're going to remain on the fallback, we no longer want
  15198. // to delete it. So we need to remove it from the list. Deletions are stored
  15199. // on the same list as effects. We want to keep the effects from the primary
  15200. // tree. So we copy the primary child fragment's effect list, which does not
  15201. // include the fallback deletion effect.
  15202. var progressedLastEffect = primaryChildFragment.lastEffect;
  15203. if (progressedLastEffect !== null) {
  15204. workInProgress.firstEffect = primaryChildFragment.firstEffect;
  15205. workInProgress.lastEffect = progressedLastEffect;
  15206. progressedLastEffect.nextEffect = null;
  15207. } else {
  15208. // TODO: Reset this somewhere else? Lol legacy mode is so weird.
  15209. workInProgress.firstEffect = workInProgress.lastEffect = null;
  15210. }
  15211. } else {
  15212. primaryChildFragment = createWorkInProgressOffscreenFiber(currentPrimaryChildFragment, primaryChildProps);
  15213. }
  15214. var fallbackChildFragment;
  15215. if (currentFallbackChildFragment !== null) {
  15216. fallbackChildFragment = createWorkInProgress(currentFallbackChildFragment, fallbackChildren);
  15217. } else {
  15218. fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes, null); // Needs a placement effect because the parent (the Suspense boundary) already
  15219. // mounted but this is a new fiber.
  15220. fallbackChildFragment.flags |= Placement;
  15221. }
  15222. fallbackChildFragment.return = workInProgress;
  15223. primaryChildFragment.return = workInProgress;
  15224. primaryChildFragment.sibling = fallbackChildFragment;
  15225. workInProgress.child = primaryChildFragment;
  15226. return fallbackChildFragment;
  15227. }
  15228. function scheduleWorkOnFiber(fiber, renderLanes) {
  15229. fiber.lanes = mergeLanes(fiber.lanes, renderLanes);
  15230. var alternate = fiber.alternate;
  15231. if (alternate !== null) {
  15232. alternate.lanes = mergeLanes(alternate.lanes, renderLanes);
  15233. }
  15234. scheduleWorkOnParentPath(fiber.return, renderLanes);
  15235. }
  15236. function propagateSuspenseContextChange(workInProgress, firstChild, renderLanes) {
  15237. // Mark any Suspense boundaries with fallbacks as having work to do.
  15238. // If they were previously forced into fallbacks, they may now be able
  15239. // to unblock.
  15240. var node = firstChild;
  15241. while (node !== null) {
  15242. if (node.tag === SuspenseComponent) {
  15243. var state = node.memoizedState;
  15244. if (state !== null) {
  15245. scheduleWorkOnFiber(node, renderLanes);
  15246. }
  15247. } else if (node.tag === SuspenseListComponent) {
  15248. // If the tail is hidden there might not be an Suspense boundaries
  15249. // to schedule work on. In this case we have to schedule it on the
  15250. // list itself.
  15251. // We don't have to traverse to the children of the list since
  15252. // the list will propagate the change when it rerenders.
  15253. scheduleWorkOnFiber(node, renderLanes);
  15254. } else if (node.child !== null) {
  15255. node.child.return = node;
  15256. node = node.child;
  15257. continue;
  15258. }
  15259. if (node === workInProgress) {
  15260. return;
  15261. }
  15262. while (node.sibling === null) {
  15263. if (node.return === null || node.return === workInProgress) {
  15264. return;
  15265. }
  15266. node = node.return;
  15267. }
  15268. node.sibling.return = node.return;
  15269. node = node.sibling;
  15270. }
  15271. }
  15272. function findLastContentRow(firstChild) {
  15273. // This is going to find the last row among these children that is already
  15274. // showing content on the screen, as opposed to being in fallback state or
  15275. // new. If a row has multiple Suspense boundaries, any of them being in the
  15276. // fallback state, counts as the whole row being in a fallback state.
  15277. // Note that the "rows" will be workInProgress, but any nested children
  15278. // will still be current since we haven't rendered them yet. The mounted
  15279. // order may not be the same as the new order. We use the new order.
  15280. var row = firstChild;
  15281. var lastContentRow = null;
  15282. while (row !== null) {
  15283. var currentRow = row.alternate; // New rows can't be content rows.
  15284. if (currentRow !== null && findFirstSuspended(currentRow) === null) {
  15285. lastContentRow = row;
  15286. }
  15287. row = row.sibling;
  15288. }
  15289. return lastContentRow;
  15290. }
  15291. function validateRevealOrder(revealOrder) {
  15292. {
  15293. if (revealOrder !== undefined && revealOrder !== 'forwards' && revealOrder !== 'backwards' && revealOrder !== 'together' && !didWarnAboutRevealOrder[revealOrder]) {
  15294. didWarnAboutRevealOrder[revealOrder] = true;
  15295. if (typeof revealOrder === 'string') {
  15296. switch (revealOrder.toLowerCase()) {
  15297. case 'together':
  15298. case 'forwards':
  15299. case 'backwards':
  15300. {
  15301. error('"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase());
  15302. break;
  15303. }
  15304. case 'forward':
  15305. case 'backward':
  15306. {
  15307. error('"%s" is not a valid value for revealOrder on <SuspenseList />. ' + 'React uses the -s suffix in the spelling. Use "%ss" instead.', revealOrder, revealOrder.toLowerCase());
  15308. break;
  15309. }
  15310. default:
  15311. error('"%s" is not a supported revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
  15312. break;
  15313. }
  15314. } else {
  15315. error('%s is not a supported value for revealOrder on <SuspenseList />. ' + 'Did you mean "together", "forwards" or "backwards"?', revealOrder);
  15316. }
  15317. }
  15318. }
  15319. }
  15320. function validateTailOptions(tailMode, revealOrder) {
  15321. {
  15322. if (tailMode !== undefined && !didWarnAboutTailOptions[tailMode]) {
  15323. if (tailMode !== 'collapsed' && tailMode !== 'hidden') {
  15324. didWarnAboutTailOptions[tailMode] = true;
  15325. error('"%s" is not a supported value for tail on <SuspenseList />. ' + 'Did you mean "collapsed" or "hidden"?', tailMode);
  15326. } else if (revealOrder !== 'forwards' && revealOrder !== 'backwards') {
  15327. didWarnAboutTailOptions[tailMode] = true;
  15328. error('<SuspenseList tail="%s" /> is only valid if revealOrder is ' + '"forwards" or "backwards". ' + 'Did you mean to specify revealOrder="forwards"?', tailMode);
  15329. }
  15330. }
  15331. }
  15332. }
  15333. function validateSuspenseListNestedChild(childSlot, index) {
  15334. {
  15335. var isArray = Array.isArray(childSlot);
  15336. var isIterable = !isArray && typeof getIteratorFn(childSlot) === 'function';
  15337. if (isArray || isIterable) {
  15338. var type = isArray ? 'array' : 'iterable';
  15339. error('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);
  15340. return false;
  15341. }
  15342. }
  15343. return true;
  15344. }
  15345. function validateSuspenseListChildren(children, revealOrder) {
  15346. {
  15347. if ((revealOrder === 'forwards' || revealOrder === 'backwards') && children !== undefined && children !== null && children !== false) {
  15348. if (Array.isArray(children)) {
  15349. for (var i = 0; i < children.length; i++) {
  15350. if (!validateSuspenseListNestedChild(children[i], i)) {
  15351. return;
  15352. }
  15353. }
  15354. } else {
  15355. var iteratorFn = getIteratorFn(children);
  15356. if (typeof iteratorFn === 'function') {
  15357. var childrenIterator = iteratorFn.call(children);
  15358. if (childrenIterator) {
  15359. var step = childrenIterator.next();
  15360. var _i = 0;
  15361. for (; !step.done; step = childrenIterator.next()) {
  15362. if (!validateSuspenseListNestedChild(step.value, _i)) {
  15363. return;
  15364. }
  15365. _i++;
  15366. }
  15367. }
  15368. } else {
  15369. error('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);
  15370. }
  15371. }
  15372. }
  15373. }
  15374. }
  15375. function initSuspenseListRenderState(workInProgress, isBackwards, tail, lastContentRow, tailMode, lastEffectBeforeRendering) {
  15376. var renderState = workInProgress.memoizedState;
  15377. if (renderState === null) {
  15378. workInProgress.memoizedState = {
  15379. isBackwards: isBackwards,
  15380. rendering: null,
  15381. renderingStartTime: 0,
  15382. last: lastContentRow,
  15383. tail: tail,
  15384. tailMode: tailMode,
  15385. lastEffect: lastEffectBeforeRendering
  15386. };
  15387. } else {
  15388. // We can reuse the existing object from previous renders.
  15389. renderState.isBackwards = isBackwards;
  15390. renderState.rendering = null;
  15391. renderState.renderingStartTime = 0;
  15392. renderState.last = lastContentRow;
  15393. renderState.tail = tail;
  15394. renderState.tailMode = tailMode;
  15395. renderState.lastEffect = lastEffectBeforeRendering;
  15396. }
  15397. } // This can end up rendering this component multiple passes.
  15398. // The first pass splits the children fibers into two sets. A head and tail.
  15399. // We first render the head. If anything is in fallback state, we do another
  15400. // pass through beginWork to rerender all children (including the tail) with
  15401. // the force suspend context. If the first render didn't have anything in
  15402. // in fallback state. Then we render each row in the tail one-by-one.
  15403. // That happens in the completeWork phase without going back to beginWork.
  15404. function updateSuspenseListComponent(current, workInProgress, renderLanes) {
  15405. var nextProps = workInProgress.pendingProps;
  15406. var revealOrder = nextProps.revealOrder;
  15407. var tailMode = nextProps.tail;
  15408. var newChildren = nextProps.children;
  15409. validateRevealOrder(revealOrder);
  15410. validateTailOptions(tailMode, revealOrder);
  15411. validateSuspenseListChildren(newChildren, revealOrder);
  15412. reconcileChildren(current, workInProgress, newChildren, renderLanes);
  15413. var suspenseContext = suspenseStackCursor.current;
  15414. var shouldForceFallback = hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
  15415. if (shouldForceFallback) {
  15416. suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
  15417. workInProgress.flags |= DidCapture;
  15418. } else {
  15419. var didSuspendBefore = current !== null && (current.flags & DidCapture) !== NoFlags;
  15420. if (didSuspendBefore) {
  15421. // If we previously forced a fallback, we need to schedule work
  15422. // on any nested boundaries to let them know to try to render
  15423. // again. This is the same as context updating.
  15424. propagateSuspenseContextChange(workInProgress, workInProgress.child, renderLanes);
  15425. }
  15426. suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
  15427. }
  15428. pushSuspenseContext(workInProgress, suspenseContext);
  15429. if ((workInProgress.mode & BlockingMode) === NoMode) {
  15430. // In legacy mode, SuspenseList doesn't work so we just
  15431. // use make it a noop by treating it as the default revealOrder.
  15432. workInProgress.memoizedState = null;
  15433. } else {
  15434. switch (revealOrder) {
  15435. case 'forwards':
  15436. {
  15437. var lastContentRow = findLastContentRow(workInProgress.child);
  15438. var tail;
  15439. if (lastContentRow === null) {
  15440. // The whole list is part of the tail.
  15441. // TODO: We could fast path by just rendering the tail now.
  15442. tail = workInProgress.child;
  15443. workInProgress.child = null;
  15444. } else {
  15445. // Disconnect the tail rows after the content row.
  15446. // We're going to render them separately later.
  15447. tail = lastContentRow.sibling;
  15448. lastContentRow.sibling = null;
  15449. }
  15450. initSuspenseListRenderState(workInProgress, false, // isBackwards
  15451. tail, lastContentRow, tailMode, workInProgress.lastEffect);
  15452. break;
  15453. }
  15454. case 'backwards':
  15455. {
  15456. // We're going to find the first row that has existing content.
  15457. // At the same time we're going to reverse the list of everything
  15458. // we pass in the meantime. That's going to be our tail in reverse
  15459. // order.
  15460. var _tail = null;
  15461. var row = workInProgress.child;
  15462. workInProgress.child = null;
  15463. while (row !== null) {
  15464. var currentRow = row.alternate; // New rows can't be content rows.
  15465. if (currentRow !== null && findFirstSuspended(currentRow) === null) {
  15466. // This is the beginning of the main content.
  15467. workInProgress.child = row;
  15468. break;
  15469. }
  15470. var nextRow = row.sibling;
  15471. row.sibling = _tail;
  15472. _tail = row;
  15473. row = nextRow;
  15474. } // TODO: If workInProgress.child is null, we can continue on the tail immediately.
  15475. initSuspenseListRenderState(workInProgress, true, // isBackwards
  15476. _tail, null, // last
  15477. tailMode, workInProgress.lastEffect);
  15478. break;
  15479. }
  15480. case 'together':
  15481. {
  15482. initSuspenseListRenderState(workInProgress, false, // isBackwards
  15483. null, // tail
  15484. null, // last
  15485. undefined, workInProgress.lastEffect);
  15486. break;
  15487. }
  15488. default:
  15489. {
  15490. // The default reveal order is the same as not having
  15491. // a boundary.
  15492. workInProgress.memoizedState = null;
  15493. }
  15494. }
  15495. }
  15496. return workInProgress.child;
  15497. }
  15498. function updatePortalComponent(current, workInProgress, renderLanes) {
  15499. pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
  15500. var nextChildren = workInProgress.pendingProps;
  15501. if (current === null) {
  15502. // Portals are special because we don't append the children during mount
  15503. // but at commit. Therefore we need to track insertions which the normal
  15504. // flow doesn't do during mount. This doesn't happen at the root because
  15505. // the root always starts with a "current" with a null child.
  15506. // TODO: Consider unifying this with how the root works.
  15507. workInProgress.child = reconcileChildFibers(workInProgress, null, nextChildren, renderLanes);
  15508. } else {
  15509. reconcileChildren(current, workInProgress, nextChildren, renderLanes);
  15510. }
  15511. return workInProgress.child;
  15512. }
  15513. var hasWarnedAboutUsingNoValuePropOnContextProvider = false;
  15514. function updateContextProvider(current, workInProgress, renderLanes) {
  15515. var providerType = workInProgress.type;
  15516. var context = providerType._context;
  15517. var newProps = workInProgress.pendingProps;
  15518. var oldProps = workInProgress.memoizedProps;
  15519. var newValue = newProps.value;
  15520. {
  15521. if (!('value' in newProps)) {
  15522. if (!hasWarnedAboutUsingNoValuePropOnContextProvider) {
  15523. hasWarnedAboutUsingNoValuePropOnContextProvider = true;
  15524. error('The `value` prop is required for the `<Context.Provider>`. Did you misspell it or forget to pass it?');
  15525. }
  15526. }
  15527. var providerPropTypes = workInProgress.type.propTypes;
  15528. if (providerPropTypes) {
  15529. checkPropTypes(providerPropTypes, newProps, 'prop', 'Context.Provider');
  15530. }
  15531. }
  15532. pushProvider(workInProgress, newValue);
  15533. if (oldProps !== null) {
  15534. var oldValue = oldProps.value;
  15535. var changedBits = calculateChangedBits(context, newValue, oldValue);
  15536. if (changedBits === 0) {
  15537. // No change. Bailout early if children are the same.
  15538. if (oldProps.children === newProps.children && !hasContextChanged()) {
  15539. return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
  15540. }
  15541. } else {
  15542. // The context value changed. Search for matching consumers and schedule
  15543. // them to update.
  15544. propagateContextChange(workInProgress, context, changedBits, renderLanes);
  15545. }
  15546. }
  15547. var newChildren = newProps.children;
  15548. reconcileChildren(current, workInProgress, newChildren, renderLanes);
  15549. return workInProgress.child;
  15550. }
  15551. var hasWarnedAboutUsingContextAsConsumer = false;
  15552. function updateContextConsumer(current, workInProgress, renderLanes) {
  15553. var context = workInProgress.type; // The logic below for Context differs depending on PROD or DEV mode. In
  15554. // DEV mode, we create a separate object for Context.Consumer that acts
  15555. // like a proxy to Context. This proxy object adds unnecessary code in PROD
  15556. // so we use the old behaviour (Context.Consumer references Context) to
  15557. // reduce size and overhead. The separate object references context via
  15558. // a property called "_context", which also gives us the ability to check
  15559. // in DEV mode if this property exists or not and warn if it does not.
  15560. {
  15561. if (context._context === undefined) {
  15562. // This may be because it's a Context (rather than a Consumer).
  15563. // Or it may be because it's older React where they're the same thing.
  15564. // We only want to warn if we're sure it's a new React.
  15565. if (context !== context.Consumer) {
  15566. if (!hasWarnedAboutUsingContextAsConsumer) {
  15567. hasWarnedAboutUsingContextAsConsumer = true;
  15568. error('Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
  15569. }
  15570. }
  15571. } else {
  15572. context = context._context;
  15573. }
  15574. }
  15575. var newProps = workInProgress.pendingProps;
  15576. var render = newProps.children;
  15577. {
  15578. if (typeof render !== 'function') {
  15579. error('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.');
  15580. }
  15581. }
  15582. prepareToReadContext(workInProgress, renderLanes);
  15583. var newValue = readContext(context, newProps.unstable_observedBits);
  15584. var newChildren;
  15585. {
  15586. ReactCurrentOwner$1.current = workInProgress;
  15587. setIsRendering(true);
  15588. newChildren = render(newValue);
  15589. setIsRendering(false);
  15590. } // React DevTools reads this flag.
  15591. workInProgress.flags |= PerformedWork;
  15592. reconcileChildren(current, workInProgress, newChildren, renderLanes);
  15593. return workInProgress.child;
  15594. }
  15595. function markWorkInProgressReceivedUpdate() {
  15596. didReceiveUpdate = true;
  15597. }
  15598. function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) {
  15599. if (current !== null) {
  15600. // Reuse previous dependencies
  15601. workInProgress.dependencies = current.dependencies;
  15602. }
  15603. {
  15604. // Don't update "base" render times for bailouts.
  15605. stopProfilerTimerIfRunning();
  15606. }
  15607. markSkippedUpdateLanes(workInProgress.lanes); // Check if the children have any pending work.
  15608. if (!includesSomeLane(renderLanes, workInProgress.childLanes)) {
  15609. // The children don't have any work either. We can skip them.
  15610. // TODO: Once we add back resuming, we should check if the children are
  15611. // a work-in-progress set. If so, we need to transfer their effects.
  15612. return null;
  15613. } else {
  15614. // This fiber doesn't have work, but its subtree does. Clone the child
  15615. // fibers and continue.
  15616. cloneChildFibers(current, workInProgress);
  15617. return workInProgress.child;
  15618. }
  15619. }
  15620. function remountFiber(current, oldWorkInProgress, newWorkInProgress) {
  15621. {
  15622. var returnFiber = oldWorkInProgress.return;
  15623. if (returnFiber === null) {
  15624. throw new Error('Cannot swap the root fiber.');
  15625. } // Disconnect from the old current.
  15626. // It will get deleted.
  15627. current.alternate = null;
  15628. oldWorkInProgress.alternate = null; // Connect to the new tree.
  15629. newWorkInProgress.index = oldWorkInProgress.index;
  15630. newWorkInProgress.sibling = oldWorkInProgress.sibling;
  15631. newWorkInProgress.return = oldWorkInProgress.return;
  15632. newWorkInProgress.ref = oldWorkInProgress.ref; // Replace the child/sibling pointers above it.
  15633. if (oldWorkInProgress === returnFiber.child) {
  15634. returnFiber.child = newWorkInProgress;
  15635. } else {
  15636. var prevSibling = returnFiber.child;
  15637. if (prevSibling === null) {
  15638. throw new Error('Expected parent to have a child.');
  15639. }
  15640. while (prevSibling.sibling !== oldWorkInProgress) {
  15641. prevSibling = prevSibling.sibling;
  15642. if (prevSibling === null) {
  15643. throw new Error('Expected to find the previous sibling.');
  15644. }
  15645. }
  15646. prevSibling.sibling = newWorkInProgress;
  15647. } // Delete the old fiber and place the new one.
  15648. // Since the old fiber is disconnected, we have to schedule it manually.
  15649. var last = returnFiber.lastEffect;
  15650. if (last !== null) {
  15651. last.nextEffect = current;
  15652. returnFiber.lastEffect = current;
  15653. } else {
  15654. returnFiber.firstEffect = returnFiber.lastEffect = current;
  15655. }
  15656. current.nextEffect = null;
  15657. current.flags = Deletion;
  15658. newWorkInProgress.flags |= Placement; // Restart work from the new fiber.
  15659. return newWorkInProgress;
  15660. }
  15661. }
  15662. function beginWork(current, workInProgress, renderLanes) {
  15663. var updateLanes = workInProgress.lanes;
  15664. {
  15665. if (workInProgress._debugNeedsRemount && current !== null) {
  15666. // This will restart the begin phase with a new fiber.
  15667. return remountFiber(current, workInProgress, createFiberFromTypeAndProps(workInProgress.type, workInProgress.key, workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, workInProgress.lanes));
  15668. }
  15669. }
  15670. if (current !== null) {
  15671. var oldProps = current.memoizedProps;
  15672. var newProps = workInProgress.pendingProps;
  15673. if (oldProps !== newProps || hasContextChanged() || ( // Force a re-render if the implementation changed due to hot reload:
  15674. workInProgress.type !== current.type )) {
  15675. // If props or context changed, mark the fiber as having performed work.
  15676. // This may be unset if the props are determined to be equal later (memo).
  15677. didReceiveUpdate = true;
  15678. } else if (!includesSomeLane(renderLanes, updateLanes)) {
  15679. didReceiveUpdate = false; // This fiber does not have any pending work. Bailout without entering
  15680. // the begin phase. There's still some bookkeeping we that needs to be done
  15681. // in this optimized path, mostly pushing stuff onto the stack.
  15682. switch (workInProgress.tag) {
  15683. case HostRoot:
  15684. pushHostRootContext(workInProgress);
  15685. resetHydrationState();
  15686. break;
  15687. case HostComponent:
  15688. pushHostContext(workInProgress);
  15689. break;
  15690. case ClassComponent:
  15691. {
  15692. var Component = workInProgress.type;
  15693. if (isContextProvider(Component)) {
  15694. pushContextProvider(workInProgress);
  15695. }
  15696. break;
  15697. }
  15698. case HostPortal:
  15699. pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo);
  15700. break;
  15701. case ContextProvider:
  15702. {
  15703. var newValue = workInProgress.memoizedProps.value;
  15704. pushProvider(workInProgress, newValue);
  15705. break;
  15706. }
  15707. case Profiler:
  15708. {
  15709. // Profiler should only call onRender when one of its descendants actually rendered.
  15710. var hasChildWork = includesSomeLane(renderLanes, workInProgress.childLanes);
  15711. if (hasChildWork) {
  15712. workInProgress.flags |= Update;
  15713. } // Reset effect durations for the next eventual effect phase.
  15714. // These are reset during render to allow the DevTools commit hook a chance to read them,
  15715. var stateNode = workInProgress.stateNode;
  15716. stateNode.effectDuration = 0;
  15717. stateNode.passiveEffectDuration = 0;
  15718. }
  15719. break;
  15720. case SuspenseComponent:
  15721. {
  15722. var state = workInProgress.memoizedState;
  15723. if (state !== null) {
  15724. // whether to retry the primary children, or to skip over it and
  15725. // go straight to the fallback. Check the priority of the primary
  15726. // child fragment.
  15727. var primaryChildFragment = workInProgress.child;
  15728. var primaryChildLanes = primaryChildFragment.childLanes;
  15729. if (includesSomeLane(renderLanes, primaryChildLanes)) {
  15730. // The primary children have pending work. Use the normal path
  15731. // to attempt to render the primary children again.
  15732. return updateSuspenseComponent(current, workInProgress, renderLanes);
  15733. } else {
  15734. // The primary child fragment does not have pending work marked
  15735. // on it
  15736. pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current)); // The primary children do not have pending work with sufficient
  15737. // priority. Bailout.
  15738. var child = bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
  15739. if (child !== null) {
  15740. // The fallback children have pending work. Skip over the
  15741. // primary children and work on the fallback.
  15742. return child.sibling;
  15743. } else {
  15744. return null;
  15745. }
  15746. }
  15747. } else {
  15748. pushSuspenseContext(workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
  15749. }
  15750. break;
  15751. }
  15752. case SuspenseListComponent:
  15753. {
  15754. var didSuspendBefore = (current.flags & DidCapture) !== NoFlags;
  15755. var _hasChildWork = includesSomeLane(renderLanes, workInProgress.childLanes);
  15756. if (didSuspendBefore) {
  15757. if (_hasChildWork) {
  15758. // If something was in fallback state last time, and we have all the
  15759. // same children then we're still in progressive loading state.
  15760. // Something might get unblocked by state updates or retries in the
  15761. // tree which will affect the tail. So we need to use the normal
  15762. // path to compute the correct tail.
  15763. return updateSuspenseListComponent(current, workInProgress, renderLanes);
  15764. } // If none of the children had any work, that means that none of
  15765. // them got retried so they'll still be blocked in the same way
  15766. // as before. We can fast bail out.
  15767. workInProgress.flags |= DidCapture;
  15768. } // If nothing suspended before and we're rendering the same children,
  15769. // then the tail doesn't matter. Anything new that suspends will work
  15770. // in the "together" mode, so we can continue from the state we had.
  15771. var renderState = workInProgress.memoizedState;
  15772. if (renderState !== null) {
  15773. // Reset to the "together" mode in case we've started a different
  15774. // update in the past but didn't complete it.
  15775. renderState.rendering = null;
  15776. renderState.tail = null;
  15777. renderState.lastEffect = null;
  15778. }
  15779. pushSuspenseContext(workInProgress, suspenseStackCursor.current);
  15780. if (_hasChildWork) {
  15781. break;
  15782. } else {
  15783. // If none of the children had any work, that means that none of
  15784. // them got retried so they'll still be blocked in the same way
  15785. // as before. We can fast bail out.
  15786. return null;
  15787. }
  15788. }
  15789. case OffscreenComponent:
  15790. case LegacyHiddenComponent:
  15791. {
  15792. // Need to check if the tree still needs to be deferred. This is
  15793. // almost identical to the logic used in the normal update path,
  15794. // so we'll just enter that. The only difference is we'll bail out
  15795. // at the next level instead of this one, because the child props
  15796. // have not changed. Which is fine.
  15797. // TODO: Probably should refactor `beginWork` to split the bailout
  15798. // path from the normal path. I'm tempted to do a labeled break here
  15799. // but I won't :)
  15800. workInProgress.lanes = NoLanes;
  15801. return updateOffscreenComponent(current, workInProgress, renderLanes);
  15802. }
  15803. }
  15804. return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
  15805. } else {
  15806. if ((current.flags & ForceUpdateForLegacySuspense) !== NoFlags) {
  15807. // This is a special case that only exists for legacy mode.
  15808. // See https://github.com/facebook/react/pull/19216.
  15809. didReceiveUpdate = true;
  15810. } else {
  15811. // An update was scheduled on this fiber, but there are no new props
  15812. // nor legacy context. Set this to false. If an update queue or context
  15813. // consumer produces a changed value, it will set this to true. Otherwise,
  15814. // the component will assume the children have not changed and bail out.
  15815. didReceiveUpdate = false;
  15816. }
  15817. }
  15818. } else {
  15819. didReceiveUpdate = false;
  15820. } // Before entering the begin phase, clear pending update priority.
  15821. // TODO: This assumes that we're about to evaluate the component and process
  15822. // the update queue. However, there's an exception: SimpleMemoComponent
  15823. // sometimes bails out later in the begin phase. This indicates that we should
  15824. // move this assignment out of the common path and into each branch.
  15825. workInProgress.lanes = NoLanes;
  15826. switch (workInProgress.tag) {
  15827. case IndeterminateComponent:
  15828. {
  15829. return mountIndeterminateComponent(current, workInProgress, workInProgress.type, renderLanes);
  15830. }
  15831. case LazyComponent:
  15832. {
  15833. var elementType = workInProgress.elementType;
  15834. return mountLazyComponent(current, workInProgress, elementType, updateLanes, renderLanes);
  15835. }
  15836. case FunctionComponent:
  15837. {
  15838. var _Component = workInProgress.type;
  15839. var unresolvedProps = workInProgress.pendingProps;
  15840. var resolvedProps = workInProgress.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps);
  15841. return updateFunctionComponent(current, workInProgress, _Component, resolvedProps, renderLanes);
  15842. }
  15843. case ClassComponent:
  15844. {
  15845. var _Component2 = workInProgress.type;
  15846. var _unresolvedProps = workInProgress.pendingProps;
  15847. var _resolvedProps = workInProgress.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps);
  15848. return updateClassComponent(current, workInProgress, _Component2, _resolvedProps, renderLanes);
  15849. }
  15850. case HostRoot:
  15851. return updateHostRoot(current, workInProgress, renderLanes);
  15852. case HostComponent:
  15853. return updateHostComponent(current, workInProgress, renderLanes);
  15854. case HostText:
  15855. return updateHostText(current, workInProgress);
  15856. case SuspenseComponent:
  15857. return updateSuspenseComponent(current, workInProgress, renderLanes);
  15858. case HostPortal:
  15859. return updatePortalComponent(current, workInProgress, renderLanes);
  15860. case ForwardRef:
  15861. {
  15862. var type = workInProgress.type;
  15863. var _unresolvedProps2 = workInProgress.pendingProps;
  15864. var _resolvedProps2 = workInProgress.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
  15865. return updateForwardRef(current, workInProgress, type, _resolvedProps2, renderLanes);
  15866. }
  15867. case Fragment:
  15868. return updateFragment(current, workInProgress, renderLanes);
  15869. case Mode:
  15870. return updateMode(current, workInProgress, renderLanes);
  15871. case Profiler:
  15872. return updateProfiler(current, workInProgress, renderLanes);
  15873. case ContextProvider:
  15874. return updateContextProvider(current, workInProgress, renderLanes);
  15875. case ContextConsumer:
  15876. return updateContextConsumer(current, workInProgress, renderLanes);
  15877. case MemoComponent:
  15878. {
  15879. var _type2 = workInProgress.type;
  15880. var _unresolvedProps3 = workInProgress.pendingProps; // Resolve outer props first, then resolve inner props.
  15881. var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);
  15882. {
  15883. if (workInProgress.type !== workInProgress.elementType) {
  15884. var outerPropTypes = _type2.propTypes;
  15885. if (outerPropTypes) {
  15886. checkPropTypes(outerPropTypes, _resolvedProps3, // Resolved for outer only
  15887. 'prop', getComponentName(_type2));
  15888. }
  15889. }
  15890. }
  15891. _resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);
  15892. return updateMemoComponent(current, workInProgress, _type2, _resolvedProps3, updateLanes, renderLanes);
  15893. }
  15894. case SimpleMemoComponent:
  15895. {
  15896. return updateSimpleMemoComponent(current, workInProgress, workInProgress.type, workInProgress.pendingProps, updateLanes, renderLanes);
  15897. }
  15898. case IncompleteClassComponent:
  15899. {
  15900. var _Component3 = workInProgress.type;
  15901. var _unresolvedProps4 = workInProgress.pendingProps;
  15902. var _resolvedProps4 = workInProgress.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
  15903. return mountIncompleteClassComponent(current, workInProgress, _Component3, _resolvedProps4, renderLanes);
  15904. }
  15905. case SuspenseListComponent:
  15906. {
  15907. return updateSuspenseListComponent(current, workInProgress, renderLanes);
  15908. }
  15909. case FundamentalComponent:
  15910. {
  15911. break;
  15912. }
  15913. case ScopeComponent:
  15914. {
  15915. break;
  15916. }
  15917. case Block:
  15918. {
  15919. break;
  15920. }
  15921. case OffscreenComponent:
  15922. {
  15923. return updateOffscreenComponent(current, workInProgress, renderLanes);
  15924. }
  15925. case LegacyHiddenComponent:
  15926. {
  15927. return updateLegacyHiddenComponent(current, workInProgress, renderLanes);
  15928. }
  15929. }
  15930. {
  15931. {
  15932. throw Error( "Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue." );
  15933. }
  15934. }
  15935. }
  15936. function markUpdate(workInProgress) {
  15937. // Tag the fiber with an update effect. This turns a Placement into
  15938. // a PlacementAndUpdate.
  15939. workInProgress.flags |= Update;
  15940. }
  15941. function markRef$1(workInProgress) {
  15942. workInProgress.flags |= Ref;
  15943. }
  15944. var appendAllChildren;
  15945. var updateHostContainer;
  15946. var updateHostComponent$1;
  15947. var updateHostText$1;
  15948. {
  15949. // Mutation mode
  15950. appendAllChildren = function (parent, workInProgress, needsVisibilityToggle, isHidden) {
  15951. // We only have the top Fiber that was created but we need recurse down its
  15952. // children to find all the terminal nodes.
  15953. var node = workInProgress.child;
  15954. while (node !== null) {
  15955. if (node.tag === HostComponent || node.tag === HostText) {
  15956. appendInitialChild(parent, node.stateNode);
  15957. } else if (node.tag === HostPortal) ; else if (node.child !== null) {
  15958. node.child.return = node;
  15959. node = node.child;
  15960. continue;
  15961. }
  15962. if (node === workInProgress) {
  15963. return;
  15964. }
  15965. while (node.sibling === null) {
  15966. if (node.return === null || node.return === workInProgress) {
  15967. return;
  15968. }
  15969. node = node.return;
  15970. }
  15971. node.sibling.return = node.return;
  15972. node = node.sibling;
  15973. }
  15974. };
  15975. updateHostContainer = function (workInProgress) {// Noop
  15976. };
  15977. updateHostComponent$1 = function (current, workInProgress, type, newProps, rootContainerInstance) {
  15978. // If we have an alternate, that means this is an update and we need to
  15979. // schedule a side-effect to do the updates.
  15980. var oldProps = current.memoizedProps;
  15981. if (oldProps === newProps) {
  15982. // In mutation mode, this is sufficient for a bailout because
  15983. // we won't touch this node even if children changed.
  15984. return;
  15985. } // If we get updated because one of our children updated, we don't
  15986. // have newProps so we'll have to reuse them.
  15987. // TODO: Split the update API as separate for the props vs. children.
  15988. // Even better would be if children weren't special cased at all tho.
  15989. var instance = workInProgress.stateNode;
  15990. var currentHostContext = getHostContext(); // TODO: Experiencing an error where oldProps is null. Suggests a host
  15991. // component is hitting the resume path. Figure out why. Possibly
  15992. // related to `hidden`.
  15993. var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext); // TODO: Type this specific to this type of component.
  15994. workInProgress.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there
  15995. // is a new ref we mark this as an update. All the work is done in commitWork.
  15996. if (updatePayload) {
  15997. markUpdate(workInProgress);
  15998. }
  15999. };
  16000. updateHostText$1 = function (current, workInProgress, oldText, newText) {
  16001. // If the text differs, mark it as an update. All the work in done in commitWork.
  16002. if (oldText !== newText) {
  16003. markUpdate(workInProgress);
  16004. }
  16005. };
  16006. }
  16007. function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
  16008. if (getIsHydrating()) {
  16009. // If we're hydrating, we should consume as many items as we can
  16010. // so we don't leave any behind.
  16011. return;
  16012. }
  16013. switch (renderState.tailMode) {
  16014. case 'hidden':
  16015. {
  16016. // Any insertions at the end of the tail list after this point
  16017. // should be invisible. If there are already mounted boundaries
  16018. // anything before them are not considered for collapsing.
  16019. // Therefore we need to go through the whole tail to find if
  16020. // there are any.
  16021. var tailNode = renderState.tail;
  16022. var lastTailNode = null;
  16023. while (tailNode !== null) {
  16024. if (tailNode.alternate !== null) {
  16025. lastTailNode = tailNode;
  16026. }
  16027. tailNode = tailNode.sibling;
  16028. } // Next we're simply going to delete all insertions after the
  16029. // last rendered item.
  16030. if (lastTailNode === null) {
  16031. // All remaining items in the tail are insertions.
  16032. renderState.tail = null;
  16033. } else {
  16034. // Detach the insertion after the last node that was already
  16035. // inserted.
  16036. lastTailNode.sibling = null;
  16037. }
  16038. break;
  16039. }
  16040. case 'collapsed':
  16041. {
  16042. // Any insertions at the end of the tail list after this point
  16043. // should be invisible. If there are already mounted boundaries
  16044. // anything before them are not considered for collapsing.
  16045. // Therefore we need to go through the whole tail to find if
  16046. // there are any.
  16047. var _tailNode = renderState.tail;
  16048. var _lastTailNode = null;
  16049. while (_tailNode !== null) {
  16050. if (_tailNode.alternate !== null) {
  16051. _lastTailNode = _tailNode;
  16052. }
  16053. _tailNode = _tailNode.sibling;
  16054. } // Next we're simply going to delete all insertions after the
  16055. // last rendered item.
  16056. if (_lastTailNode === null) {
  16057. // All remaining items in the tail are insertions.
  16058. if (!hasRenderedATailFallback && renderState.tail !== null) {
  16059. // We suspended during the head. We want to show at least one
  16060. // row at the tail. So we'll keep on and cut off the rest.
  16061. renderState.tail.sibling = null;
  16062. } else {
  16063. renderState.tail = null;
  16064. }
  16065. } else {
  16066. // Detach the insertion after the last node that was already
  16067. // inserted.
  16068. _lastTailNode.sibling = null;
  16069. }
  16070. break;
  16071. }
  16072. }
  16073. }
  16074. function completeWork(current, workInProgress, renderLanes) {
  16075. var newProps = workInProgress.pendingProps;
  16076. switch (workInProgress.tag) {
  16077. case IndeterminateComponent:
  16078. case LazyComponent:
  16079. case SimpleMemoComponent:
  16080. case FunctionComponent:
  16081. case ForwardRef:
  16082. case Fragment:
  16083. case Mode:
  16084. case Profiler:
  16085. case ContextConsumer:
  16086. case MemoComponent:
  16087. return null;
  16088. case ClassComponent:
  16089. {
  16090. var Component = workInProgress.type;
  16091. if (isContextProvider(Component)) {
  16092. popContext(workInProgress);
  16093. }
  16094. return null;
  16095. }
  16096. case HostRoot:
  16097. {
  16098. popHostContainer(workInProgress);
  16099. popTopLevelContextObject(workInProgress);
  16100. resetWorkInProgressVersions();
  16101. var fiberRoot = workInProgress.stateNode;
  16102. if (fiberRoot.pendingContext) {
  16103. fiberRoot.context = fiberRoot.pendingContext;
  16104. fiberRoot.pendingContext = null;
  16105. }
  16106. if (current === null || current.child === null) {
  16107. // If we hydrated, pop so that we can delete any remaining children
  16108. // that weren't hydrated.
  16109. var wasHydrated = popHydrationState(workInProgress);
  16110. if (wasHydrated) {
  16111. // If we hydrated, then we'll need to schedule an update for
  16112. // the commit side-effects on the root.
  16113. markUpdate(workInProgress);
  16114. } else if (!fiberRoot.hydrate) {
  16115. // Schedule an effect to clear this container at the start of the next commit.
  16116. // This handles the case of React rendering into a container with previous children.
  16117. // It's also safe to do for updates too, because current.child would only be null
  16118. // if the previous render was null (so the the container would already be empty).
  16119. workInProgress.flags |= Snapshot;
  16120. }
  16121. }
  16122. updateHostContainer(workInProgress);
  16123. return null;
  16124. }
  16125. case HostComponent:
  16126. {
  16127. popHostContext(workInProgress);
  16128. var rootContainerInstance = getRootHostContainer();
  16129. var type = workInProgress.type;
  16130. if (current !== null && workInProgress.stateNode != null) {
  16131. updateHostComponent$1(current, workInProgress, type, newProps, rootContainerInstance);
  16132. if (current.ref !== workInProgress.ref) {
  16133. markRef$1(workInProgress);
  16134. }
  16135. } else {
  16136. if (!newProps) {
  16137. if (!(workInProgress.stateNode !== null)) {
  16138. {
  16139. throw Error( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." );
  16140. }
  16141. } // This can happen when we abort work.
  16142. return null;
  16143. }
  16144. var currentHostContext = getHostContext(); // TODO: Move createInstance to beginWork and keep it on a context
  16145. // "stack" as the parent. Then append children as we go in beginWork
  16146. // or completeWork depending on whether we want to add them top->down or
  16147. // bottom->up. Top->down is faster in IE11.
  16148. var _wasHydrated = popHydrationState(workInProgress);
  16149. if (_wasHydrated) {
  16150. // TODO: Move this and createInstance step into the beginPhase
  16151. // to consolidate.
  16152. if (prepareToHydrateHostInstance(workInProgress, rootContainerInstance, currentHostContext)) {
  16153. // If changes to the hydrated node need to be applied at the
  16154. // commit-phase we mark this as such.
  16155. markUpdate(workInProgress);
  16156. }
  16157. } else {
  16158. var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress);
  16159. appendAllChildren(instance, workInProgress, false, false);
  16160. workInProgress.stateNode = instance; // Certain renderers require commit-time effects for initial mount.
  16161. // (eg DOM renderer supports auto-focus for certain elements).
  16162. // Make sure such renderers get scheduled for later work.
  16163. if (finalizeInitialChildren(instance, type, newProps, rootContainerInstance)) {
  16164. markUpdate(workInProgress);
  16165. }
  16166. }
  16167. if (workInProgress.ref !== null) {
  16168. // If there is a ref on a host node we need to schedule a callback
  16169. markRef$1(workInProgress);
  16170. }
  16171. }
  16172. return null;
  16173. }
  16174. case HostText:
  16175. {
  16176. var newText = newProps;
  16177. if (current && workInProgress.stateNode != null) {
  16178. var oldText = current.memoizedProps; // If we have an alternate, that means this is an update and we need
  16179. // to schedule a side-effect to do the updates.
  16180. updateHostText$1(current, workInProgress, oldText, newText);
  16181. } else {
  16182. if (typeof newText !== 'string') {
  16183. if (!(workInProgress.stateNode !== null)) {
  16184. {
  16185. throw Error( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." );
  16186. }
  16187. } // This can happen when we abort work.
  16188. }
  16189. var _rootContainerInstance = getRootHostContainer();
  16190. var _currentHostContext = getHostContext();
  16191. var _wasHydrated2 = popHydrationState(workInProgress);
  16192. if (_wasHydrated2) {
  16193. if (prepareToHydrateHostTextInstance(workInProgress)) {
  16194. markUpdate(workInProgress);
  16195. }
  16196. } else {
  16197. workInProgress.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext, workInProgress);
  16198. }
  16199. }
  16200. return null;
  16201. }
  16202. case SuspenseComponent:
  16203. {
  16204. popSuspenseContext(workInProgress);
  16205. var nextState = workInProgress.memoizedState;
  16206. if ((workInProgress.flags & DidCapture) !== NoFlags) {
  16207. // Something suspended. Re-render with the fallback children.
  16208. workInProgress.lanes = renderLanes; // Do not reset the effect list.
  16209. if ( (workInProgress.mode & ProfileMode) !== NoMode) {
  16210. transferActualDuration(workInProgress);
  16211. }
  16212. return workInProgress;
  16213. }
  16214. var nextDidTimeout = nextState !== null;
  16215. var prevDidTimeout = false;
  16216. if (current === null) {
  16217. if (workInProgress.memoizedProps.fallback !== undefined) {
  16218. popHydrationState(workInProgress);
  16219. }
  16220. } else {
  16221. var prevState = current.memoizedState;
  16222. prevDidTimeout = prevState !== null;
  16223. }
  16224. if (nextDidTimeout && !prevDidTimeout) {
  16225. // If this subtreee is running in blocking mode we can suspend,
  16226. // otherwise we won't suspend.
  16227. // TODO: This will still suspend a synchronous tree if anything
  16228. // in the concurrent tree already suspended during this render.
  16229. // This is a known bug.
  16230. if ((workInProgress.mode & BlockingMode) !== NoMode) {
  16231. // TODO: Move this back to throwException because this is too late
  16232. // if this is a large tree which is common for initial loads. We
  16233. // don't know if we should restart a render or not until we get
  16234. // this marker, and this is too late.
  16235. // If this render already had a ping or lower pri updates,
  16236. // and this is the first time we know we're going to suspend we
  16237. // should be able to immediately restart from within throwException.
  16238. var hasInvisibleChildContext = current === null && workInProgress.memoizedProps.unstable_avoidThisFallback !== true;
  16239. if (hasInvisibleChildContext || hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext)) {
  16240. // If this was in an invisible tree or a new render, then showing
  16241. // this boundary is ok.
  16242. renderDidSuspend();
  16243. } else {
  16244. // Otherwise, we're going to have to hide content so we should
  16245. // suspend for longer if possible.
  16246. renderDidSuspendDelayIfPossible();
  16247. }
  16248. }
  16249. }
  16250. {
  16251. // TODO: Only schedule updates if these values are non equal, i.e. it changed.
  16252. if (nextDidTimeout || prevDidTimeout) {
  16253. // If this boundary just timed out, schedule an effect to attach a
  16254. // retry listener to the promise. This flag is also used to hide the
  16255. // primary children. In mutation mode, we also need the flag to
  16256. // *unhide* children that were previously hidden, so check if this
  16257. // is currently timed out, too.
  16258. workInProgress.flags |= Update;
  16259. }
  16260. }
  16261. return null;
  16262. }
  16263. case HostPortal:
  16264. popHostContainer(workInProgress);
  16265. updateHostContainer(workInProgress);
  16266. if (current === null) {
  16267. preparePortalMount(workInProgress.stateNode.containerInfo);
  16268. }
  16269. return null;
  16270. case ContextProvider:
  16271. // Pop provider fiber
  16272. popProvider(workInProgress);
  16273. return null;
  16274. case IncompleteClassComponent:
  16275. {
  16276. // Same as class component case. I put it down here so that the tags are
  16277. // sequential to ensure this switch is compiled to a jump table.
  16278. var _Component = workInProgress.type;
  16279. if (isContextProvider(_Component)) {
  16280. popContext(workInProgress);
  16281. }
  16282. return null;
  16283. }
  16284. case SuspenseListComponent:
  16285. {
  16286. popSuspenseContext(workInProgress);
  16287. var renderState = workInProgress.memoizedState;
  16288. if (renderState === null) {
  16289. // We're running in the default, "independent" mode.
  16290. // We don't do anything in this mode.
  16291. return null;
  16292. }
  16293. var didSuspendAlready = (workInProgress.flags & DidCapture) !== NoFlags;
  16294. var renderedTail = renderState.rendering;
  16295. if (renderedTail === null) {
  16296. // We just rendered the head.
  16297. if (!didSuspendAlready) {
  16298. // This is the first pass. We need to figure out if anything is still
  16299. // suspended in the rendered set.
  16300. // If new content unsuspended, but there's still some content that
  16301. // didn't. Then we need to do a second pass that forces everything
  16302. // to keep showing their fallbacks.
  16303. // We might be suspended if something in this render pass suspended, or
  16304. // something in the previous committed pass suspended. Otherwise,
  16305. // there's no chance so we can skip the expensive call to
  16306. // findFirstSuspended.
  16307. var cannotBeSuspended = renderHasNotSuspendedYet() && (current === null || (current.flags & DidCapture) === NoFlags);
  16308. if (!cannotBeSuspended) {
  16309. var row = workInProgress.child;
  16310. while (row !== null) {
  16311. var suspended = findFirstSuspended(row);
  16312. if (suspended !== null) {
  16313. didSuspendAlready = true;
  16314. workInProgress.flags |= DidCapture;
  16315. cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as
  16316. // part of the second pass. In that case nothing will subscribe to
  16317. // its thennables. Instead, we'll transfer its thennables to the
  16318. // SuspenseList so that it can retry if they resolve.
  16319. // There might be multiple of these in the list but since we're
  16320. // going to wait for all of them anyway, it doesn't really matter
  16321. // which ones gets to ping. In theory we could get clever and keep
  16322. // track of how many dependencies remain but it gets tricky because
  16323. // in the meantime, we can add/remove/change items and dependencies.
  16324. // We might bail out of the loop before finding any but that
  16325. // doesn't matter since that means that the other boundaries that
  16326. // we did find already has their listeners attached.
  16327. var newThennables = suspended.updateQueue;
  16328. if (newThennables !== null) {
  16329. workInProgress.updateQueue = newThennables;
  16330. workInProgress.flags |= Update;
  16331. } // Rerender the whole list, but this time, we'll force fallbacks
  16332. // to stay in place.
  16333. // Reset the effect list before doing the second pass since that's now invalid.
  16334. if (renderState.lastEffect === null) {
  16335. workInProgress.firstEffect = null;
  16336. }
  16337. workInProgress.lastEffect = renderState.lastEffect; // Reset the child fibers to their original state.
  16338. resetChildFibers(workInProgress, renderLanes); // Set up the Suspense Context to force suspense and immediately
  16339. // rerender the children.
  16340. pushSuspenseContext(workInProgress, setShallowSuspenseContext(suspenseStackCursor.current, ForceSuspenseFallback));
  16341. return workInProgress.child;
  16342. }
  16343. row = row.sibling;
  16344. }
  16345. }
  16346. if (renderState.tail !== null && now() > getRenderTargetTime()) {
  16347. // We have already passed our CPU deadline but we still have rows
  16348. // left in the tail. We'll just give up further attempts to render
  16349. // the main content and only render fallbacks.
  16350. workInProgress.flags |= DidCapture;
  16351. didSuspendAlready = true;
  16352. cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this
  16353. // to get it started back up to attempt the next item. While in terms
  16354. // of priority this work has the same priority as this current render,
  16355. // it's not part of the same transition once the transition has
  16356. // committed. If it's sync, we still want to yield so that it can be
  16357. // painted. Conceptually, this is really the same as pinging.
  16358. // We can use any RetryLane even if it's the one currently rendering
  16359. // since we're leaving it behind on this node.
  16360. workInProgress.lanes = SomeRetryLane;
  16361. {
  16362. markSpawnedWork(SomeRetryLane);
  16363. }
  16364. }
  16365. } else {
  16366. cutOffTailIfNeeded(renderState, false);
  16367. } // Next we're going to render the tail.
  16368. } else {
  16369. // Append the rendered row to the child list.
  16370. if (!didSuspendAlready) {
  16371. var _suspended = findFirstSuspended(renderedTail);
  16372. if (_suspended !== null) {
  16373. workInProgress.flags |= DidCapture;
  16374. didSuspendAlready = true; // Ensure we transfer the update queue to the parent so that it doesn't
  16375. // get lost if this row ends up dropped during a second pass.
  16376. var _newThennables = _suspended.updateQueue;
  16377. if (_newThennables !== null) {
  16378. workInProgress.updateQueue = _newThennables;
  16379. workInProgress.flags |= Update;
  16380. }
  16381. cutOffTailIfNeeded(renderState, true); // This might have been modified.
  16382. if (renderState.tail === null && renderState.tailMode === 'hidden' && !renderedTail.alternate && !getIsHydrating() // We don't cut it if we're hydrating.
  16383. ) {
  16384. // We need to delete the row we just rendered.
  16385. // Reset the effect list to what it was before we rendered this
  16386. // child. The nested children have already appended themselves.
  16387. var lastEffect = workInProgress.lastEffect = renderState.lastEffect; // Remove any effects that were appended after this point.
  16388. if (lastEffect !== null) {
  16389. lastEffect.nextEffect = null;
  16390. } // We're done.
  16391. return null;
  16392. }
  16393. } else if ( // The time it took to render last row is greater than the remaining
  16394. // time we have to render. So rendering one more row would likely
  16395. // exceed it.
  16396. now() * 2 - renderState.renderingStartTime > getRenderTargetTime() && renderLanes !== OffscreenLane) {
  16397. // We have now passed our CPU deadline and we'll just give up further
  16398. // attempts to render the main content and only render fallbacks.
  16399. // The assumption is that this is usually faster.
  16400. workInProgress.flags |= DidCapture;
  16401. didSuspendAlready = true;
  16402. cutOffTailIfNeeded(renderState, false); // Since nothing actually suspended, there will nothing to ping this
  16403. // to get it started back up to attempt the next item. While in terms
  16404. // of priority this work has the same priority as this current render,
  16405. // it's not part of the same transition once the transition has
  16406. // committed. If it's sync, we still want to yield so that it can be
  16407. // painted. Conceptually, this is really the same as pinging.
  16408. // We can use any RetryLane even if it's the one currently rendering
  16409. // since we're leaving it behind on this node.
  16410. workInProgress.lanes = SomeRetryLane;
  16411. {
  16412. markSpawnedWork(SomeRetryLane);
  16413. }
  16414. }
  16415. }
  16416. if (renderState.isBackwards) {
  16417. // The effect list of the backwards tail will have been added
  16418. // to the end. This breaks the guarantee that life-cycles fire in
  16419. // sibling order but that isn't a strong guarantee promised by React.
  16420. // Especially since these might also just pop in during future commits.
  16421. // Append to the beginning of the list.
  16422. renderedTail.sibling = workInProgress.child;
  16423. workInProgress.child = renderedTail;
  16424. } else {
  16425. var previousSibling = renderState.last;
  16426. if (previousSibling !== null) {
  16427. previousSibling.sibling = renderedTail;
  16428. } else {
  16429. workInProgress.child = renderedTail;
  16430. }
  16431. renderState.last = renderedTail;
  16432. }
  16433. }
  16434. if (renderState.tail !== null) {
  16435. // We still have tail rows to render.
  16436. // Pop a row.
  16437. var next = renderState.tail;
  16438. renderState.rendering = next;
  16439. renderState.tail = next.sibling;
  16440. renderState.lastEffect = workInProgress.lastEffect;
  16441. renderState.renderingStartTime = now();
  16442. next.sibling = null; // Restore the context.
  16443. // TODO: We can probably just avoid popping it instead and only
  16444. // setting it the first time we go from not suspended to suspended.
  16445. var suspenseContext = suspenseStackCursor.current;
  16446. if (didSuspendAlready) {
  16447. suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
  16448. } else {
  16449. suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
  16450. }
  16451. pushSuspenseContext(workInProgress, suspenseContext); // Do a pass over the next row.
  16452. return next;
  16453. }
  16454. return null;
  16455. }
  16456. case FundamentalComponent:
  16457. {
  16458. break;
  16459. }
  16460. case ScopeComponent:
  16461. {
  16462. break;
  16463. }
  16464. case Block:
  16465. break;
  16466. case OffscreenComponent:
  16467. case LegacyHiddenComponent:
  16468. {
  16469. popRenderLanes(workInProgress);
  16470. if (current !== null) {
  16471. var _nextState = workInProgress.memoizedState;
  16472. var _prevState = current.memoizedState;
  16473. var prevIsHidden = _prevState !== null;
  16474. var nextIsHidden = _nextState !== null;
  16475. if (prevIsHidden !== nextIsHidden && newProps.mode !== 'unstable-defer-without-hiding') {
  16476. workInProgress.flags |= Update;
  16477. }
  16478. }
  16479. return null;
  16480. }
  16481. }
  16482. {
  16483. {
  16484. throw Error( "Unknown unit of work tag (" + workInProgress.tag + "). This error is likely caused by a bug in React. Please file an issue." );
  16485. }
  16486. }
  16487. }
  16488. function unwindWork(workInProgress, renderLanes) {
  16489. switch (workInProgress.tag) {
  16490. case ClassComponent:
  16491. {
  16492. var Component = workInProgress.type;
  16493. if (isContextProvider(Component)) {
  16494. popContext(workInProgress);
  16495. }
  16496. var flags = workInProgress.flags;
  16497. if (flags & ShouldCapture) {
  16498. workInProgress.flags = flags & ~ShouldCapture | DidCapture;
  16499. if ( (workInProgress.mode & ProfileMode) !== NoMode) {
  16500. transferActualDuration(workInProgress);
  16501. }
  16502. return workInProgress;
  16503. }
  16504. return null;
  16505. }
  16506. case HostRoot:
  16507. {
  16508. popHostContainer(workInProgress);
  16509. popTopLevelContextObject(workInProgress);
  16510. resetWorkInProgressVersions();
  16511. var _flags = workInProgress.flags;
  16512. if (!((_flags & DidCapture) === NoFlags)) {
  16513. {
  16514. throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." );
  16515. }
  16516. }
  16517. workInProgress.flags = _flags & ~ShouldCapture | DidCapture;
  16518. return workInProgress;
  16519. }
  16520. case HostComponent:
  16521. {
  16522. // TODO: popHydrationState
  16523. popHostContext(workInProgress);
  16524. return null;
  16525. }
  16526. case SuspenseComponent:
  16527. {
  16528. popSuspenseContext(workInProgress);
  16529. var _flags2 = workInProgress.flags;
  16530. if (_flags2 & ShouldCapture) {
  16531. workInProgress.flags = _flags2 & ~ShouldCapture | DidCapture; // Captured a suspense effect. Re-render the boundary.
  16532. if ( (workInProgress.mode & ProfileMode) !== NoMode) {
  16533. transferActualDuration(workInProgress);
  16534. }
  16535. return workInProgress;
  16536. }
  16537. return null;
  16538. }
  16539. case SuspenseListComponent:
  16540. {
  16541. popSuspenseContext(workInProgress); // SuspenseList doesn't actually catch anything. It should've been
  16542. // caught by a nested boundary. If not, it should bubble through.
  16543. return null;
  16544. }
  16545. case HostPortal:
  16546. popHostContainer(workInProgress);
  16547. return null;
  16548. case ContextProvider:
  16549. popProvider(workInProgress);
  16550. return null;
  16551. case OffscreenComponent:
  16552. case LegacyHiddenComponent:
  16553. popRenderLanes(workInProgress);
  16554. return null;
  16555. default:
  16556. return null;
  16557. }
  16558. }
  16559. function unwindInterruptedWork(interruptedWork) {
  16560. switch (interruptedWork.tag) {
  16561. case ClassComponent:
  16562. {
  16563. var childContextTypes = interruptedWork.type.childContextTypes;
  16564. if (childContextTypes !== null && childContextTypes !== undefined) {
  16565. popContext(interruptedWork);
  16566. }
  16567. break;
  16568. }
  16569. case HostRoot:
  16570. {
  16571. popHostContainer(interruptedWork);
  16572. popTopLevelContextObject(interruptedWork);
  16573. resetWorkInProgressVersions();
  16574. break;
  16575. }
  16576. case HostComponent:
  16577. {
  16578. popHostContext(interruptedWork);
  16579. break;
  16580. }
  16581. case HostPortal:
  16582. popHostContainer(interruptedWork);
  16583. break;
  16584. case SuspenseComponent:
  16585. popSuspenseContext(interruptedWork);
  16586. break;
  16587. case SuspenseListComponent:
  16588. popSuspenseContext(interruptedWork);
  16589. break;
  16590. case ContextProvider:
  16591. popProvider(interruptedWork);
  16592. break;
  16593. case OffscreenComponent:
  16594. case LegacyHiddenComponent:
  16595. popRenderLanes(interruptedWork);
  16596. break;
  16597. }
  16598. }
  16599. function createCapturedValue(value, source) {
  16600. // If the value is an error, call this function immediately after it is thrown
  16601. // so the stack is accurate.
  16602. return {
  16603. value: value,
  16604. source: source,
  16605. stack: getStackByFiberInDevAndProd(source)
  16606. };
  16607. }
  16608. // This module is forked in different environments.
  16609. // By default, return `true` to log errors to the console.
  16610. // Forks can return `false` if this isn't desirable.
  16611. function showErrorDialog(boundary, errorInfo) {
  16612. return true;
  16613. }
  16614. function logCapturedError(boundary, errorInfo) {
  16615. try {
  16616. var logError = showErrorDialog(boundary, errorInfo); // Allow injected showErrorDialog() to prevent default console.error logging.
  16617. // This enables renderers like ReactNative to better manage redbox behavior.
  16618. if (logError === false) {
  16619. return;
  16620. }
  16621. var error = errorInfo.value;
  16622. if (true) {
  16623. var source = errorInfo.source;
  16624. var stack = errorInfo.stack;
  16625. var componentStack = stack !== null ? stack : ''; // Browsers support silencing uncaught errors by calling
  16626. // `preventDefault()` in window `error` handler.
  16627. // We record this information as an expando on the error.
  16628. if (error != null && error._suppressLogging) {
  16629. if (boundary.tag === ClassComponent) {
  16630. // The error is recoverable and was silenced.
  16631. // Ignore it and don't print the stack addendum.
  16632. // This is handy for testing error boundaries without noise.
  16633. return;
  16634. } // The error is fatal. Since the silencing might have
  16635. // been accidental, we'll surface it anyway.
  16636. // However, the browser would have silenced the original error
  16637. // so we'll print it first, and then print the stack addendum.
  16638. console['error'](error); // Don't transform to our wrapper
  16639. // For a more detailed description of this block, see:
  16640. // https://github.com/facebook/react/pull/13384
  16641. }
  16642. var componentName = source ? getComponentName(source.type) : null;
  16643. var componentNameMessage = componentName ? "The above error occurred in the <" + componentName + "> component:" : 'The above error occurred in one of your React components:';
  16644. var errorBoundaryMessage;
  16645. var errorBoundaryName = getComponentName(boundary.type);
  16646. if (errorBoundaryName) {
  16647. errorBoundaryMessage = "React will try to recreate this component tree from scratch " + ("using the error boundary you provided, " + errorBoundaryName + ".");
  16648. } else {
  16649. errorBoundaryMessage = 'Consider adding an error boundary to your tree to customize error handling behavior.\n' + 'Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.';
  16650. }
  16651. var combinedMessage = componentNameMessage + "\n" + componentStack + "\n\n" + ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack.
  16652. // We don't include the original error message and JS stack because the browser
  16653. // has already printed it. Even if the application swallows the error, it is still
  16654. // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils.
  16655. console['error'](combinedMessage); // Don't transform to our wrapper
  16656. } else {
  16657. // In production, we print the error directly.
  16658. // This will include the message, the JS stack, and anything the browser wants to show.
  16659. // We pass the error object instead of custom message so that the browser displays the error natively.
  16660. console['error'](error); // Don't transform to our wrapper
  16661. }
  16662. } catch (e) {
  16663. // This method must not throw, or React internal state will get messed up.
  16664. // If console.error is overridden, or logCapturedError() shows a dialog that throws,
  16665. // we want to report this error outside of the normal stack as a last resort.
  16666. // https://github.com/facebook/react/issues/13188
  16667. setTimeout(function () {
  16668. throw e;
  16669. });
  16670. }
  16671. }
  16672. var PossiblyWeakMap$1 = typeof WeakMap === 'function' ? WeakMap : Map;
  16673. function createRootErrorUpdate(fiber, errorInfo, lane) {
  16674. var update = createUpdate(NoTimestamp, lane); // Unmount the root by rendering null.
  16675. update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property
  16676. // being called "element".
  16677. update.payload = {
  16678. element: null
  16679. };
  16680. var error = errorInfo.value;
  16681. update.callback = function () {
  16682. onUncaughtError(error);
  16683. logCapturedError(fiber, errorInfo);
  16684. };
  16685. return update;
  16686. }
  16687. function createClassErrorUpdate(fiber, errorInfo, lane) {
  16688. var update = createUpdate(NoTimestamp, lane);
  16689. update.tag = CaptureUpdate;
  16690. var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
  16691. if (typeof getDerivedStateFromError === 'function') {
  16692. var error$1 = errorInfo.value;
  16693. update.payload = function () {
  16694. logCapturedError(fiber, errorInfo);
  16695. return getDerivedStateFromError(error$1);
  16696. };
  16697. }
  16698. var inst = fiber.stateNode;
  16699. if (inst !== null && typeof inst.componentDidCatch === 'function') {
  16700. update.callback = function callback() {
  16701. {
  16702. markFailedErrorBoundaryForHotReloading(fiber);
  16703. }
  16704. if (typeof getDerivedStateFromError !== 'function') {
  16705. // To preserve the preexisting retry behavior of error boundaries,
  16706. // we keep track of which ones already failed during this batch.
  16707. // This gets reset before we yield back to the browser.
  16708. // TODO: Warn in strict mode if getDerivedStateFromError is
  16709. // not defined.
  16710. markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined
  16711. logCapturedError(fiber, errorInfo);
  16712. }
  16713. var error$1 = errorInfo.value;
  16714. var stack = errorInfo.stack;
  16715. this.componentDidCatch(error$1, {
  16716. componentStack: stack !== null ? stack : ''
  16717. });
  16718. {
  16719. if (typeof getDerivedStateFromError !== 'function') {
  16720. // If componentDidCatch is the only error boundary method defined,
  16721. // then it needs to call setState to recover from errors.
  16722. // If no state update is scheduled then the boundary will swallow the error.
  16723. if (!includesSomeLane(fiber.lanes, SyncLane)) {
  16724. error('%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');
  16725. }
  16726. }
  16727. }
  16728. };
  16729. } else {
  16730. update.callback = function () {
  16731. markFailedErrorBoundaryForHotReloading(fiber);
  16732. };
  16733. }
  16734. return update;
  16735. }
  16736. function attachPingListener(root, wakeable, lanes) {
  16737. // Attach a listener to the promise to "ping" the root and retry. But only if
  16738. // one does not already exist for the lanes we're currently rendering (which
  16739. // acts like a "thread ID" here).
  16740. var pingCache = root.pingCache;
  16741. var threadIDs;
  16742. if (pingCache === null) {
  16743. pingCache = root.pingCache = new PossiblyWeakMap$1();
  16744. threadIDs = new Set();
  16745. pingCache.set(wakeable, threadIDs);
  16746. } else {
  16747. threadIDs = pingCache.get(wakeable);
  16748. if (threadIDs === undefined) {
  16749. threadIDs = new Set();
  16750. pingCache.set(wakeable, threadIDs);
  16751. }
  16752. }
  16753. if (!threadIDs.has(lanes)) {
  16754. // Memoize using the thread ID to prevent redundant listeners.
  16755. threadIDs.add(lanes);
  16756. var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes);
  16757. wakeable.then(ping, ping);
  16758. }
  16759. }
  16760. function throwException(root, returnFiber, sourceFiber, value, rootRenderLanes) {
  16761. // The source fiber did not complete.
  16762. sourceFiber.flags |= Incomplete; // Its effect list is no longer valid.
  16763. sourceFiber.firstEffect = sourceFiber.lastEffect = null;
  16764. if (value !== null && typeof value === 'object' && typeof value.then === 'function') {
  16765. // This is a wakeable.
  16766. var wakeable = value;
  16767. if ((sourceFiber.mode & BlockingMode) === NoMode) {
  16768. // Reset the memoizedState to what it was before we attempted
  16769. // to render it.
  16770. var currentSource = sourceFiber.alternate;
  16771. if (currentSource) {
  16772. sourceFiber.updateQueue = currentSource.updateQueue;
  16773. sourceFiber.memoizedState = currentSource.memoizedState;
  16774. sourceFiber.lanes = currentSource.lanes;
  16775. } else {
  16776. sourceFiber.updateQueue = null;
  16777. sourceFiber.memoizedState = null;
  16778. }
  16779. }
  16780. var hasInvisibleParentBoundary = hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext); // Schedule the nearest Suspense to re-render the timed out view.
  16781. var _workInProgress = returnFiber;
  16782. do {
  16783. if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)) {
  16784. // Found the nearest boundary.
  16785. // Stash the promise on the boundary fiber. If the boundary times out, we'll
  16786. // attach another listener to flip the boundary back to its normal state.
  16787. var wakeables = _workInProgress.updateQueue;
  16788. if (wakeables === null) {
  16789. var updateQueue = new Set();
  16790. updateQueue.add(wakeable);
  16791. _workInProgress.updateQueue = updateQueue;
  16792. } else {
  16793. wakeables.add(wakeable);
  16794. } // If the boundary is outside of blocking mode, we should *not*
  16795. // suspend the commit. Pretend as if the suspended component rendered
  16796. // null and keep rendering. In the commit phase, we'll schedule a
  16797. // subsequent synchronous update to re-render the Suspense.
  16798. //
  16799. // Note: It doesn't matter whether the component that suspended was
  16800. // inside a blocking mode tree. If the Suspense is outside of it, we
  16801. // should *not* suspend the commit.
  16802. if ((_workInProgress.mode & BlockingMode) === NoMode) {
  16803. _workInProgress.flags |= DidCapture;
  16804. sourceFiber.flags |= ForceUpdateForLegacySuspense; // We're going to commit this fiber even though it didn't complete.
  16805. // But we shouldn't call any lifecycle methods or callbacks. Remove
  16806. // all lifecycle effect tags.
  16807. sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete);
  16808. if (sourceFiber.tag === ClassComponent) {
  16809. var currentSourceFiber = sourceFiber.alternate;
  16810. if (currentSourceFiber === null) {
  16811. // This is a new mount. Change the tag so it's not mistaken for a
  16812. // completed class component. For example, we should not call
  16813. // componentWillUnmount if it is deleted.
  16814. sourceFiber.tag = IncompleteClassComponent;
  16815. } else {
  16816. // When we try rendering again, we should not reuse the current fiber,
  16817. // since it's known to be in an inconsistent state. Use a force update to
  16818. // prevent a bail out.
  16819. var update = createUpdate(NoTimestamp, SyncLane);
  16820. update.tag = ForceUpdate;
  16821. enqueueUpdate(sourceFiber, update);
  16822. }
  16823. } // The source fiber did not complete. Mark it with Sync priority to
  16824. // indicate that it still has pending work.
  16825. sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane); // Exit without suspending.
  16826. return;
  16827. } // Confirmed that the boundary is in a concurrent mode tree. Continue
  16828. // with the normal suspend path.
  16829. //
  16830. // After this we'll use a set of heuristics to determine whether this
  16831. // render pass will run to completion or restart or "suspend" the commit.
  16832. // The actual logic for this is spread out in different places.
  16833. //
  16834. // This first principle is that if we're going to suspend when we complete
  16835. // a root, then we should also restart if we get an update or ping that
  16836. // might unsuspend it, and vice versa. The only reason to suspend is
  16837. // because you think you might want to restart before committing. However,
  16838. // it doesn't make sense to restart only while in the period we're suspended.
  16839. //
  16840. // Restarting too aggressively is also not good because it starves out any
  16841. // intermediate loading state. So we use heuristics to determine when.
  16842. // Suspense Heuristics
  16843. //
  16844. // If nothing threw a Promise or all the same fallbacks are already showing,
  16845. // then don't suspend/restart.
  16846. //
  16847. // If this is an initial render of a new tree of Suspense boundaries and
  16848. // those trigger a fallback, then don't suspend/restart. We want to ensure
  16849. // that we can show the initial loading state as quickly as possible.
  16850. //
  16851. // If we hit a "Delayed" case, such as when we'd switch from content back into
  16852. // a fallback, then we should always suspend/restart. Transitions apply
  16853. // to this case. If none is defined, JND is used instead.
  16854. //
  16855. // If we're already showing a fallback and it gets "retried", allowing us to show
  16856. // another level, but there's still an inner boundary that would show a fallback,
  16857. // then we suspend/restart for 500ms since the last time we showed a fallback
  16858. // anywhere in the tree. This effectively throttles progressive loading into a
  16859. // consistent train of commits. This also gives us an opportunity to restart to
  16860. // get to the completed state slightly earlier.
  16861. //
  16862. // If there's ambiguity due to batching it's resolved in preference of:
  16863. // 1) "delayed", 2) "initial render", 3) "retry".
  16864. //
  16865. // We want to ensure that a "busy" state doesn't get force committed. We want to
  16866. // ensure that new initial loading states can commit as soon as possible.
  16867. attachPingListener(root, wakeable, rootRenderLanes);
  16868. _workInProgress.flags |= ShouldCapture;
  16869. _workInProgress.lanes = rootRenderLanes;
  16870. return;
  16871. } // This boundary already captured during this render. Continue to the next
  16872. // boundary.
  16873. _workInProgress = _workInProgress.return;
  16874. } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode.
  16875. // TODO: Use invariant so the message is stripped in prod?
  16876. 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.');
  16877. } // We didn't find a boundary that could handle this type of exception. Start
  16878. // over and traverse parent path again, this time treating the exception
  16879. // as an error.
  16880. renderDidError();
  16881. value = createCapturedValue(value, sourceFiber);
  16882. var workInProgress = returnFiber;
  16883. do {
  16884. switch (workInProgress.tag) {
  16885. case HostRoot:
  16886. {
  16887. var _errorInfo = value;
  16888. workInProgress.flags |= ShouldCapture;
  16889. var lane = pickArbitraryLane(rootRenderLanes);
  16890. workInProgress.lanes = mergeLanes(workInProgress.lanes, lane);
  16891. var _update = createRootErrorUpdate(workInProgress, _errorInfo, lane);
  16892. enqueueCapturedUpdate(workInProgress, _update);
  16893. return;
  16894. }
  16895. case ClassComponent:
  16896. // Capture and retry
  16897. var errorInfo = value;
  16898. var ctor = workInProgress.type;
  16899. var instance = workInProgress.stateNode;
  16900. if ((workInProgress.flags & DidCapture) === NoFlags && (typeof ctor.getDerivedStateFromError === 'function' || instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) {
  16901. workInProgress.flags |= ShouldCapture;
  16902. var _lane = pickArbitraryLane(rootRenderLanes);
  16903. workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state
  16904. var _update2 = createClassErrorUpdate(workInProgress, errorInfo, _lane);
  16905. enqueueCapturedUpdate(workInProgress, _update2);
  16906. return;
  16907. }
  16908. break;
  16909. }
  16910. workInProgress = workInProgress.return;
  16911. } while (workInProgress !== null);
  16912. }
  16913. var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
  16914. {
  16915. didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
  16916. }
  16917. var PossiblyWeakSet = typeof WeakSet === 'function' ? WeakSet : Set;
  16918. var callComponentWillUnmountWithTimer = function (current, instance) {
  16919. instance.props = current.memoizedProps;
  16920. instance.state = current.memoizedState;
  16921. {
  16922. instance.componentWillUnmount();
  16923. }
  16924. }; // Capture errors so they don't interrupt unmounting.
  16925. function safelyCallComponentWillUnmount(current, instance) {
  16926. {
  16927. invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current, instance);
  16928. if (hasCaughtError()) {
  16929. var unmountError = clearCaughtError();
  16930. captureCommitPhaseError(current, unmountError);
  16931. }
  16932. }
  16933. }
  16934. function safelyDetachRef(current) {
  16935. var ref = current.ref;
  16936. if (ref !== null) {
  16937. if (typeof ref === 'function') {
  16938. {
  16939. invokeGuardedCallback(null, ref, null, null);
  16940. if (hasCaughtError()) {
  16941. var refError = clearCaughtError();
  16942. captureCommitPhaseError(current, refError);
  16943. }
  16944. }
  16945. } else {
  16946. ref.current = null;
  16947. }
  16948. }
  16949. }
  16950. function safelyCallDestroy(current, destroy) {
  16951. {
  16952. invokeGuardedCallback(null, destroy, null);
  16953. if (hasCaughtError()) {
  16954. var error = clearCaughtError();
  16955. captureCommitPhaseError(current, error);
  16956. }
  16957. }
  16958. }
  16959. function commitBeforeMutationLifeCycles(current, finishedWork) {
  16960. switch (finishedWork.tag) {
  16961. case FunctionComponent:
  16962. case ForwardRef:
  16963. case SimpleMemoComponent:
  16964. case Block:
  16965. {
  16966. return;
  16967. }
  16968. case ClassComponent:
  16969. {
  16970. if (finishedWork.flags & Snapshot) {
  16971. if (current !== null) {
  16972. var prevProps = current.memoizedProps;
  16973. var prevState = current.memoizedState;
  16974. var instance = finishedWork.stateNode; // We could update instance props and state here,
  16975. // but instead we rely on them being set during last render.
  16976. // TODO: revisit this when we implement resuming.
  16977. {
  16978. if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
  16979. if (instance.props !== finishedWork.memoizedProps) {
  16980. error('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');
  16981. }
  16982. if (instance.state !== finishedWork.memoizedState) {
  16983. error('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.state`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance');
  16984. }
  16985. }
  16986. }
  16987. var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState);
  16988. {
  16989. var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate;
  16990. if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
  16991. didWarnSet.add(finishedWork.type);
  16992. error('%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork.type));
  16993. }
  16994. }
  16995. instance.__reactInternalSnapshotBeforeUpdate = snapshot;
  16996. }
  16997. }
  16998. return;
  16999. }
  17000. case HostRoot:
  17001. {
  17002. {
  17003. if (finishedWork.flags & Snapshot) {
  17004. var root = finishedWork.stateNode;
  17005. clearContainer(root.containerInfo);
  17006. }
  17007. }
  17008. return;
  17009. }
  17010. case HostComponent:
  17011. case HostText:
  17012. case HostPortal:
  17013. case IncompleteClassComponent:
  17014. // Nothing to do for these component types
  17015. return;
  17016. }
  17017. {
  17018. {
  17019. throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." );
  17020. }
  17021. }
  17022. }
  17023. function commitHookEffectListUnmount(tag, finishedWork) {
  17024. var updateQueue = finishedWork.updateQueue;
  17025. var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
  17026. if (lastEffect !== null) {
  17027. var firstEffect = lastEffect.next;
  17028. var effect = firstEffect;
  17029. do {
  17030. if ((effect.tag & tag) === tag) {
  17031. // Unmount
  17032. var destroy = effect.destroy;
  17033. effect.destroy = undefined;
  17034. if (destroy !== undefined) {
  17035. destroy();
  17036. }
  17037. }
  17038. effect = effect.next;
  17039. } while (effect !== firstEffect);
  17040. }
  17041. }
  17042. function commitHookEffectListMount(tag, finishedWork) {
  17043. var updateQueue = finishedWork.updateQueue;
  17044. var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
  17045. if (lastEffect !== null) {
  17046. var firstEffect = lastEffect.next;
  17047. var effect = firstEffect;
  17048. do {
  17049. if ((effect.tag & tag) === tag) {
  17050. // Mount
  17051. var create = effect.create;
  17052. effect.destroy = create();
  17053. {
  17054. var destroy = effect.destroy;
  17055. if (destroy !== undefined && typeof destroy !== 'function') {
  17056. var addendum = void 0;
  17057. if (destroy === null) {
  17058. addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).';
  17059. } else if (typeof destroy.then === 'function') {
  17060. 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://reactjs.org/link/hooks-data-fetching';
  17061. } else {
  17062. addendum = ' You returned: ' + destroy;
  17063. }
  17064. error('An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s', addendum);
  17065. }
  17066. }
  17067. }
  17068. effect = effect.next;
  17069. } while (effect !== firstEffect);
  17070. }
  17071. }
  17072. function schedulePassiveEffects(finishedWork) {
  17073. var updateQueue = finishedWork.updateQueue;
  17074. var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
  17075. if (lastEffect !== null) {
  17076. var firstEffect = lastEffect.next;
  17077. var effect = firstEffect;
  17078. do {
  17079. var _effect = effect,
  17080. next = _effect.next,
  17081. tag = _effect.tag;
  17082. if ((tag & Passive$1) !== NoFlags$1 && (tag & HasEffect) !== NoFlags$1) {
  17083. enqueuePendingPassiveHookEffectUnmount(finishedWork, effect);
  17084. enqueuePendingPassiveHookEffectMount(finishedWork, effect);
  17085. }
  17086. effect = next;
  17087. } while (effect !== firstEffect);
  17088. }
  17089. }
  17090. function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) {
  17091. switch (finishedWork.tag) {
  17092. case FunctionComponent:
  17093. case ForwardRef:
  17094. case SimpleMemoComponent:
  17095. case Block:
  17096. {
  17097. // At this point layout effects have already been destroyed (during mutation phase).
  17098. // This is done to prevent sibling component effects from interfering with each other,
  17099. // e.g. a destroy function in one component should never override a ref set
  17100. // by a create function in another component during the same commit.
  17101. {
  17102. commitHookEffectListMount(Layout | HasEffect, finishedWork);
  17103. }
  17104. schedulePassiveEffects(finishedWork);
  17105. return;
  17106. }
  17107. case ClassComponent:
  17108. {
  17109. var instance = finishedWork.stateNode;
  17110. if (finishedWork.flags & Update) {
  17111. if (current === null) {
  17112. // We could update instance props and state here,
  17113. // but instead we rely on them being set during last render.
  17114. // TODO: revisit this when we implement resuming.
  17115. {
  17116. if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
  17117. if (instance.props !== finishedWork.memoizedProps) {
  17118. error('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');
  17119. }
  17120. if (instance.state !== finishedWork.memoizedState) {
  17121. error('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.state`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance');
  17122. }
  17123. }
  17124. }
  17125. {
  17126. instance.componentDidMount();
  17127. }
  17128. } else {
  17129. var prevProps = finishedWork.elementType === finishedWork.type ? current.memoizedProps : resolveDefaultProps(finishedWork.type, current.memoizedProps);
  17130. var prevState = current.memoizedState; // We could update instance props and state here,
  17131. // but instead we rely on them being set during last render.
  17132. // TODO: revisit this when we implement resuming.
  17133. {
  17134. if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
  17135. if (instance.props !== finishedWork.memoizedProps) {
  17136. error('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');
  17137. }
  17138. if (instance.state !== finishedWork.memoizedState) {
  17139. error('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.state`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance');
  17140. }
  17141. }
  17142. }
  17143. {
  17144. instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate);
  17145. }
  17146. }
  17147. } // TODO: I think this is now always non-null by the time it reaches the
  17148. // commit phase. Consider removing the type check.
  17149. var updateQueue = finishedWork.updateQueue;
  17150. if (updateQueue !== null) {
  17151. {
  17152. if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
  17153. if (instance.props !== finishedWork.memoizedProps) {
  17154. error('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');
  17155. }
  17156. if (instance.state !== finishedWork.memoizedState) {
  17157. error('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.state`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance');
  17158. }
  17159. }
  17160. } // We could update instance props and state here,
  17161. // but instead we rely on them being set during last render.
  17162. // TODO: revisit this when we implement resuming.
  17163. commitUpdateQueue(finishedWork, updateQueue, instance);
  17164. }
  17165. return;
  17166. }
  17167. case HostRoot:
  17168. {
  17169. // TODO: I think this is now always non-null by the time it reaches the
  17170. // commit phase. Consider removing the type check.
  17171. var _updateQueue = finishedWork.updateQueue;
  17172. if (_updateQueue !== null) {
  17173. var _instance = null;
  17174. if (finishedWork.child !== null) {
  17175. switch (finishedWork.child.tag) {
  17176. case HostComponent:
  17177. _instance = getPublicInstance(finishedWork.child.stateNode);
  17178. break;
  17179. case ClassComponent:
  17180. _instance = finishedWork.child.stateNode;
  17181. break;
  17182. }
  17183. }
  17184. commitUpdateQueue(finishedWork, _updateQueue, _instance);
  17185. }
  17186. return;
  17187. }
  17188. case HostComponent:
  17189. {
  17190. var _instance2 = finishedWork.stateNode; // Renderers may schedule work to be done after host components are mounted
  17191. // (eg DOM renderer may schedule auto-focus for inputs and form controls).
  17192. // These effects should only be committed when components are first mounted,
  17193. // aka when there is no current/alternate.
  17194. if (current === null && finishedWork.flags & Update) {
  17195. var type = finishedWork.type;
  17196. var props = finishedWork.memoizedProps;
  17197. commitMount(_instance2, type, props);
  17198. }
  17199. return;
  17200. }
  17201. case HostText:
  17202. {
  17203. // We have no life-cycles associated with text.
  17204. return;
  17205. }
  17206. case HostPortal:
  17207. {
  17208. // We have no life-cycles associated with portals.
  17209. return;
  17210. }
  17211. case Profiler:
  17212. {
  17213. {
  17214. var _finishedWork$memoize2 = finishedWork.memoizedProps,
  17215. onCommit = _finishedWork$memoize2.onCommit,
  17216. onRender = _finishedWork$memoize2.onRender;
  17217. var effectDuration = finishedWork.stateNode.effectDuration;
  17218. var commitTime = getCommitTime();
  17219. if (typeof onRender === 'function') {
  17220. {
  17221. onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, commitTime, finishedRoot.memoizedInteractions);
  17222. }
  17223. }
  17224. }
  17225. return;
  17226. }
  17227. case SuspenseComponent:
  17228. {
  17229. commitSuspenseHydrationCallbacks(finishedRoot, finishedWork);
  17230. return;
  17231. }
  17232. case SuspenseListComponent:
  17233. case IncompleteClassComponent:
  17234. case FundamentalComponent:
  17235. case ScopeComponent:
  17236. case OffscreenComponent:
  17237. case LegacyHiddenComponent:
  17238. return;
  17239. }
  17240. {
  17241. {
  17242. throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." );
  17243. }
  17244. }
  17245. }
  17246. function hideOrUnhideAllChildren(finishedWork, isHidden) {
  17247. {
  17248. // We only have the top Fiber that was inserted but we need to recurse down its
  17249. // children to find all the terminal nodes.
  17250. var node = finishedWork;
  17251. while (true) {
  17252. if (node.tag === HostComponent) {
  17253. var instance = node.stateNode;
  17254. if (isHidden) {
  17255. hideInstance(instance);
  17256. } else {
  17257. unhideInstance(node.stateNode, node.memoizedProps);
  17258. }
  17259. } else if (node.tag === HostText) {
  17260. var _instance3 = node.stateNode;
  17261. if (isHidden) {
  17262. hideTextInstance(_instance3);
  17263. } else {
  17264. unhideTextInstance(_instance3, node.memoizedProps);
  17265. }
  17266. } else if ((node.tag === OffscreenComponent || node.tag === LegacyHiddenComponent) && node.memoizedState !== null && node !== finishedWork) ; else if (node.child !== null) {
  17267. node.child.return = node;
  17268. node = node.child;
  17269. continue;
  17270. }
  17271. if (node === finishedWork) {
  17272. return;
  17273. }
  17274. while (node.sibling === null) {
  17275. if (node.return === null || node.return === finishedWork) {
  17276. return;
  17277. }
  17278. node = node.return;
  17279. }
  17280. node.sibling.return = node.return;
  17281. node = node.sibling;
  17282. }
  17283. }
  17284. }
  17285. function commitAttachRef(finishedWork) {
  17286. var ref = finishedWork.ref;
  17287. if (ref !== null) {
  17288. var instance = finishedWork.stateNode;
  17289. var instanceToUse;
  17290. switch (finishedWork.tag) {
  17291. case HostComponent:
  17292. instanceToUse = getPublicInstance(instance);
  17293. break;
  17294. default:
  17295. instanceToUse = instance;
  17296. } // Moved outside to ensure DCE works with this flag
  17297. if (typeof ref === 'function') {
  17298. ref(instanceToUse);
  17299. } else {
  17300. {
  17301. if (!ref.hasOwnProperty('current')) {
  17302. error('Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().', getComponentName(finishedWork.type));
  17303. }
  17304. }
  17305. ref.current = instanceToUse;
  17306. }
  17307. }
  17308. }
  17309. function commitDetachRef(current) {
  17310. var currentRef = current.ref;
  17311. if (currentRef !== null) {
  17312. if (typeof currentRef === 'function') {
  17313. currentRef(null);
  17314. } else {
  17315. currentRef.current = null;
  17316. }
  17317. }
  17318. } // User-originating errors (lifecycles and refs) should not interrupt
  17319. // deletion, so don't let them throw. Host-originating errors should
  17320. // interrupt deletion, so it's okay
  17321. function commitUnmount(finishedRoot, current, renderPriorityLevel) {
  17322. onCommitUnmount(current);
  17323. switch (current.tag) {
  17324. case FunctionComponent:
  17325. case ForwardRef:
  17326. case MemoComponent:
  17327. case SimpleMemoComponent:
  17328. case Block:
  17329. {
  17330. var updateQueue = current.updateQueue;
  17331. if (updateQueue !== null) {
  17332. var lastEffect = updateQueue.lastEffect;
  17333. if (lastEffect !== null) {
  17334. var firstEffect = lastEffect.next;
  17335. var effect = firstEffect;
  17336. do {
  17337. var _effect2 = effect,
  17338. destroy = _effect2.destroy,
  17339. tag = _effect2.tag;
  17340. if (destroy !== undefined) {
  17341. if ((tag & Passive$1) !== NoFlags$1) {
  17342. enqueuePendingPassiveHookEffectUnmount(current, effect);
  17343. } else {
  17344. {
  17345. safelyCallDestroy(current, destroy);
  17346. }
  17347. }
  17348. }
  17349. effect = effect.next;
  17350. } while (effect !== firstEffect);
  17351. }
  17352. }
  17353. return;
  17354. }
  17355. case ClassComponent:
  17356. {
  17357. safelyDetachRef(current);
  17358. var instance = current.stateNode;
  17359. if (typeof instance.componentWillUnmount === 'function') {
  17360. safelyCallComponentWillUnmount(current, instance);
  17361. }
  17362. return;
  17363. }
  17364. case HostComponent:
  17365. {
  17366. safelyDetachRef(current);
  17367. return;
  17368. }
  17369. case HostPortal:
  17370. {
  17371. // TODO: this is recursive.
  17372. // We are also not using this parent because
  17373. // the portal will get pushed immediately.
  17374. {
  17375. unmountHostComponents(finishedRoot, current);
  17376. }
  17377. return;
  17378. }
  17379. case FundamentalComponent:
  17380. {
  17381. return;
  17382. }
  17383. case DehydratedFragment:
  17384. {
  17385. return;
  17386. }
  17387. case ScopeComponent:
  17388. {
  17389. return;
  17390. }
  17391. }
  17392. }
  17393. function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) {
  17394. // While we're inside a removed host node we don't want to call
  17395. // removeChild on the inner nodes because they're removed by the top
  17396. // call anyway. We also want to call componentWillUnmount on all
  17397. // composites before this host node is removed from the tree. Therefore
  17398. // we do an inner loop while we're still inside the host node.
  17399. var node = root;
  17400. while (true) {
  17401. commitUnmount(finishedRoot, node); // Visit children because they may contain more composite or host nodes.
  17402. // Skip portals because commitUnmount() currently visits them recursively.
  17403. if (node.child !== null && ( // If we use mutation we drill down into portals using commitUnmount above.
  17404. // If we don't use mutation we drill down into portals here instead.
  17405. node.tag !== HostPortal)) {
  17406. node.child.return = node;
  17407. node = node.child;
  17408. continue;
  17409. }
  17410. if (node === root) {
  17411. return;
  17412. }
  17413. while (node.sibling === null) {
  17414. if (node.return === null || node.return === root) {
  17415. return;
  17416. }
  17417. node = node.return;
  17418. }
  17419. node.sibling.return = node.return;
  17420. node = node.sibling;
  17421. }
  17422. }
  17423. function detachFiberMutation(fiber) {
  17424. // Cut off the return pointers to disconnect it from the tree. Ideally, we
  17425. // should clear the child pointer of the parent alternate to let this
  17426. // get GC:ed but we don't know which for sure which parent is the current
  17427. // one so we'll settle for GC:ing the subtree of this child. This child
  17428. // itself will be GC:ed when the parent updates the next time.
  17429. // Note: we cannot null out sibling here, otherwise it can cause issues
  17430. // with findDOMNode and how it requires the sibling field to carry out
  17431. // traversal in a later effect. See PR #16820. We now clear the sibling
  17432. // field after effects, see: detachFiberAfterEffects.
  17433. //
  17434. // Don't disconnect stateNode now; it will be detached in detachFiberAfterEffects.
  17435. // It may be required if the current component is an error boundary,
  17436. // and one of its descendants throws while unmounting a passive effect.
  17437. fiber.alternate = null;
  17438. fiber.child = null;
  17439. fiber.dependencies = null;
  17440. fiber.firstEffect = null;
  17441. fiber.lastEffect = null;
  17442. fiber.memoizedProps = null;
  17443. fiber.memoizedState = null;
  17444. fiber.pendingProps = null;
  17445. fiber.return = null;
  17446. fiber.updateQueue = null;
  17447. {
  17448. fiber._debugOwner = null;
  17449. }
  17450. }
  17451. function getHostParentFiber(fiber) {
  17452. var parent = fiber.return;
  17453. while (parent !== null) {
  17454. if (isHostParent(parent)) {
  17455. return parent;
  17456. }
  17457. parent = parent.return;
  17458. }
  17459. {
  17460. {
  17461. throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." );
  17462. }
  17463. }
  17464. }
  17465. function isHostParent(fiber) {
  17466. return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal;
  17467. }
  17468. function getHostSibling(fiber) {
  17469. // We're going to search forward into the tree until we find a sibling host
  17470. // node. Unfortunately, if multiple insertions are done in a row we have to
  17471. // search past them. This leads to exponential search for the next sibling.
  17472. // TODO: Find a more efficient way to do this.
  17473. var node = fiber;
  17474. siblings: while (true) {
  17475. // If we didn't find anything, let's try the next sibling.
  17476. while (node.sibling === null) {
  17477. if (node.return === null || isHostParent(node.return)) {
  17478. // If we pop out of the root or hit the parent the fiber we are the
  17479. // last sibling.
  17480. return null;
  17481. }
  17482. node = node.return;
  17483. }
  17484. node.sibling.return = node.return;
  17485. node = node.sibling;
  17486. while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedFragment) {
  17487. // If it is not host node and, we might have a host node inside it.
  17488. // Try to search down until we find one.
  17489. if (node.flags & Placement) {
  17490. // If we don't have a child, try the siblings instead.
  17491. continue siblings;
  17492. } // If we don't have a child, try the siblings instead.
  17493. // We also skip portals because they are not part of this host tree.
  17494. if (node.child === null || node.tag === HostPortal) {
  17495. continue siblings;
  17496. } else {
  17497. node.child.return = node;
  17498. node = node.child;
  17499. }
  17500. } // Check if this host node is stable or about to be placed.
  17501. if (!(node.flags & Placement)) {
  17502. // Found it!
  17503. return node.stateNode;
  17504. }
  17505. }
  17506. }
  17507. function commitPlacement(finishedWork) {
  17508. var parentFiber = getHostParentFiber(finishedWork); // Note: these two variables *must* always be updated together.
  17509. var parent;
  17510. var isContainer;
  17511. var parentStateNode = parentFiber.stateNode;
  17512. switch (parentFiber.tag) {
  17513. case HostComponent:
  17514. parent = parentStateNode;
  17515. isContainer = false;
  17516. break;
  17517. case HostRoot:
  17518. parent = parentStateNode.containerInfo;
  17519. isContainer = true;
  17520. break;
  17521. case HostPortal:
  17522. parent = parentStateNode.containerInfo;
  17523. isContainer = true;
  17524. break;
  17525. case FundamentalComponent:
  17526. // eslint-disable-next-line-no-fallthrough
  17527. default:
  17528. {
  17529. {
  17530. throw Error( "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." );
  17531. }
  17532. }
  17533. }
  17534. if (parentFiber.flags & ContentReset) {
  17535. // Reset the text content of the parent before doing any insertions
  17536. resetTextContent(parent); // Clear ContentReset from the effect tag
  17537. parentFiber.flags &= ~ContentReset;
  17538. }
  17539. var before = getHostSibling(finishedWork); // We only have the top Fiber that was inserted but we need to recurse down its
  17540. // children to find all the terminal nodes.
  17541. if (isContainer) {
  17542. insertOrAppendPlacementNodeIntoContainer(finishedWork, before, parent);
  17543. } else {
  17544. insertOrAppendPlacementNode(finishedWork, before, parent);
  17545. }
  17546. }
  17547. function insertOrAppendPlacementNodeIntoContainer(node, before, parent) {
  17548. var tag = node.tag;
  17549. var isHost = tag === HostComponent || tag === HostText;
  17550. if (isHost || enableFundamentalAPI ) {
  17551. var stateNode = isHost ? node.stateNode : node.stateNode.instance;
  17552. if (before) {
  17553. insertInContainerBefore(parent, stateNode, before);
  17554. } else {
  17555. appendChildToContainer(parent, stateNode);
  17556. }
  17557. } else if (tag === HostPortal) ; else {
  17558. var child = node.child;
  17559. if (child !== null) {
  17560. insertOrAppendPlacementNodeIntoContainer(child, before, parent);
  17561. var sibling = child.sibling;
  17562. while (sibling !== null) {
  17563. insertOrAppendPlacementNodeIntoContainer(sibling, before, parent);
  17564. sibling = sibling.sibling;
  17565. }
  17566. }
  17567. }
  17568. }
  17569. function insertOrAppendPlacementNode(node, before, parent) {
  17570. var tag = node.tag;
  17571. var isHost = tag === HostComponent || tag === HostText;
  17572. if (isHost || enableFundamentalAPI ) {
  17573. var stateNode = isHost ? node.stateNode : node.stateNode.instance;
  17574. if (before) {
  17575. insertBefore(parent, stateNode, before);
  17576. } else {
  17577. appendChild(parent, stateNode);
  17578. }
  17579. } else if (tag === HostPortal) ; else {
  17580. var child = node.child;
  17581. if (child !== null) {
  17582. insertOrAppendPlacementNode(child, before, parent);
  17583. var sibling = child.sibling;
  17584. while (sibling !== null) {
  17585. insertOrAppendPlacementNode(sibling, before, parent);
  17586. sibling = sibling.sibling;
  17587. }
  17588. }
  17589. }
  17590. }
  17591. function unmountHostComponents(finishedRoot, current, renderPriorityLevel) {
  17592. // We only have the top Fiber that was deleted but we need to recurse down its
  17593. // children to find all the terminal nodes.
  17594. var node = current; // Each iteration, currentParent is populated with node's host parent if not
  17595. // currentParentIsValid.
  17596. var currentParentIsValid = false; // Note: these two variables *must* always be updated together.
  17597. var currentParent;
  17598. var currentParentIsContainer;
  17599. while (true) {
  17600. if (!currentParentIsValid) {
  17601. var parent = node.return;
  17602. findParent: while (true) {
  17603. if (!(parent !== null)) {
  17604. {
  17605. throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." );
  17606. }
  17607. }
  17608. var parentStateNode = parent.stateNode;
  17609. switch (parent.tag) {
  17610. case HostComponent:
  17611. currentParent = parentStateNode;
  17612. currentParentIsContainer = false;
  17613. break findParent;
  17614. case HostRoot:
  17615. currentParent = parentStateNode.containerInfo;
  17616. currentParentIsContainer = true;
  17617. break findParent;
  17618. case HostPortal:
  17619. currentParent = parentStateNode.containerInfo;
  17620. currentParentIsContainer = true;
  17621. break findParent;
  17622. }
  17623. parent = parent.return;
  17624. }
  17625. currentParentIsValid = true;
  17626. }
  17627. if (node.tag === HostComponent || node.tag === HostText) {
  17628. commitNestedUnmounts(finishedRoot, node); // After all the children have unmounted, it is now safe to remove the
  17629. // node from the tree.
  17630. if (currentParentIsContainer) {
  17631. removeChildFromContainer(currentParent, node.stateNode);
  17632. } else {
  17633. removeChild(currentParent, node.stateNode);
  17634. } // Don't visit children because we already visited them.
  17635. } else if (node.tag === HostPortal) {
  17636. if (node.child !== null) {
  17637. // When we go into a portal, it becomes the parent to remove from.
  17638. // We will reassign it back when we pop the portal on the way up.
  17639. currentParent = node.stateNode.containerInfo;
  17640. currentParentIsContainer = true; // Visit children because portals might contain host components.
  17641. node.child.return = node;
  17642. node = node.child;
  17643. continue;
  17644. }
  17645. } else {
  17646. commitUnmount(finishedRoot, node); // Visit children because we may find more host components below.
  17647. if (node.child !== null) {
  17648. node.child.return = node;
  17649. node = node.child;
  17650. continue;
  17651. }
  17652. }
  17653. if (node === current) {
  17654. return;
  17655. }
  17656. while (node.sibling === null) {
  17657. if (node.return === null || node.return === current) {
  17658. return;
  17659. }
  17660. node = node.return;
  17661. if (node.tag === HostPortal) {
  17662. // When we go out of the portal, we need to restore the parent.
  17663. // Since we don't keep a stack of them, we will search for it.
  17664. currentParentIsValid = false;
  17665. }
  17666. }
  17667. node.sibling.return = node.return;
  17668. node = node.sibling;
  17669. }
  17670. }
  17671. function commitDeletion(finishedRoot, current, renderPriorityLevel) {
  17672. {
  17673. // Recursively delete all host nodes from the parent.
  17674. // Detach refs and call componentWillUnmount() on the whole subtree.
  17675. unmountHostComponents(finishedRoot, current);
  17676. }
  17677. var alternate = current.alternate;
  17678. detachFiberMutation(current);
  17679. if (alternate !== null) {
  17680. detachFiberMutation(alternate);
  17681. }
  17682. }
  17683. function commitWork(current, finishedWork) {
  17684. switch (finishedWork.tag) {
  17685. case FunctionComponent:
  17686. case ForwardRef:
  17687. case MemoComponent:
  17688. case SimpleMemoComponent:
  17689. case Block:
  17690. {
  17691. // Layout effects are destroyed during the mutation phase so that all
  17692. // destroy functions for all fibers are called before any create functions.
  17693. // This prevents sibling component effects from interfering with each other,
  17694. // e.g. a destroy function in one component should never override a ref set
  17695. // by a create function in another component during the same commit.
  17696. {
  17697. commitHookEffectListUnmount(Layout | HasEffect, finishedWork);
  17698. }
  17699. return;
  17700. }
  17701. case ClassComponent:
  17702. {
  17703. return;
  17704. }
  17705. case HostComponent:
  17706. {
  17707. var instance = finishedWork.stateNode;
  17708. if (instance != null) {
  17709. // Commit the work prepared earlier.
  17710. var newProps = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps
  17711. // as the newProps. The updatePayload will contain the real change in
  17712. // this case.
  17713. var oldProps = current !== null ? current.memoizedProps : newProps;
  17714. var type = finishedWork.type; // TODO: Type the updateQueue to be specific to host components.
  17715. var updatePayload = finishedWork.updateQueue;
  17716. finishedWork.updateQueue = null;
  17717. if (updatePayload !== null) {
  17718. commitUpdate(instance, updatePayload, type, oldProps, newProps);
  17719. }
  17720. }
  17721. return;
  17722. }
  17723. case HostText:
  17724. {
  17725. if (!(finishedWork.stateNode !== null)) {
  17726. {
  17727. throw Error( "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." );
  17728. }
  17729. }
  17730. var textInstance = finishedWork.stateNode;
  17731. var newText = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps
  17732. // as the newProps. The updatePayload will contain the real change in
  17733. // this case.
  17734. var oldText = current !== null ? current.memoizedProps : newText;
  17735. commitTextUpdate(textInstance, oldText, newText);
  17736. return;
  17737. }
  17738. case HostRoot:
  17739. {
  17740. {
  17741. var _root = finishedWork.stateNode;
  17742. if (_root.hydrate) {
  17743. // We've just hydrated. No need to hydrate again.
  17744. _root.hydrate = false;
  17745. commitHydratedContainer(_root.containerInfo);
  17746. }
  17747. }
  17748. return;
  17749. }
  17750. case Profiler:
  17751. {
  17752. return;
  17753. }
  17754. case SuspenseComponent:
  17755. {
  17756. commitSuspenseComponent(finishedWork);
  17757. attachSuspenseRetryListeners(finishedWork);
  17758. return;
  17759. }
  17760. case SuspenseListComponent:
  17761. {
  17762. attachSuspenseRetryListeners(finishedWork);
  17763. return;
  17764. }
  17765. case IncompleteClassComponent:
  17766. {
  17767. return;
  17768. }
  17769. case FundamentalComponent:
  17770. {
  17771. break;
  17772. }
  17773. case ScopeComponent:
  17774. {
  17775. break;
  17776. }
  17777. case OffscreenComponent:
  17778. case LegacyHiddenComponent:
  17779. {
  17780. var newState = finishedWork.memoizedState;
  17781. var isHidden = newState !== null;
  17782. hideOrUnhideAllChildren(finishedWork, isHidden);
  17783. return;
  17784. }
  17785. }
  17786. {
  17787. {
  17788. throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." );
  17789. }
  17790. }
  17791. }
  17792. function commitSuspenseComponent(finishedWork) {
  17793. var newState = finishedWork.memoizedState;
  17794. if (newState !== null) {
  17795. markCommitTimeOfFallback();
  17796. {
  17797. // Hide the Offscreen component that contains the primary children. TODO:
  17798. // Ideally, this effect would have been scheduled on the Offscreen fiber
  17799. // itself. That's how unhiding works: the Offscreen component schedules an
  17800. // effect on itself. However, in this case, the component didn't complete,
  17801. // so the fiber was never added to the effect list in the normal path. We
  17802. // could have appended it to the effect list in the Suspense component's
  17803. // second pass, but doing it this way is less complicated. This would be
  17804. // simpler if we got rid of the effect list and traversed the tree, like
  17805. // we're planning to do.
  17806. var primaryChildParent = finishedWork.child;
  17807. hideOrUnhideAllChildren(primaryChildParent, true);
  17808. }
  17809. }
  17810. }
  17811. function commitSuspenseHydrationCallbacks(finishedRoot, finishedWork) {
  17812. var newState = finishedWork.memoizedState;
  17813. if (newState === null) {
  17814. var current = finishedWork.alternate;
  17815. if (current !== null) {
  17816. var prevState = current.memoizedState;
  17817. if (prevState !== null) {
  17818. var suspenseInstance = prevState.dehydrated;
  17819. if (suspenseInstance !== null) {
  17820. commitHydratedSuspenseInstance(suspenseInstance);
  17821. }
  17822. }
  17823. }
  17824. }
  17825. }
  17826. function attachSuspenseRetryListeners(finishedWork) {
  17827. // If this boundary just timed out, then it will have a set of wakeables.
  17828. // For each wakeable, attach a listener so that when it resolves, React
  17829. // attempts to re-render the boundary in the primary (pre-timeout) state.
  17830. var wakeables = finishedWork.updateQueue;
  17831. if (wakeables !== null) {
  17832. finishedWork.updateQueue = null;
  17833. var retryCache = finishedWork.stateNode;
  17834. if (retryCache === null) {
  17835. retryCache = finishedWork.stateNode = new PossiblyWeakSet();
  17836. }
  17837. wakeables.forEach(function (wakeable) {
  17838. // Memoize using the boundary fiber to prevent redundant listeners.
  17839. var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable);
  17840. if (!retryCache.has(wakeable)) {
  17841. {
  17842. if (wakeable.__reactDoNotTraceInteractions !== true) {
  17843. retry = tracing.unstable_wrap(retry);
  17844. }
  17845. }
  17846. retryCache.add(wakeable);
  17847. wakeable.then(retry, retry);
  17848. }
  17849. });
  17850. }
  17851. } // This function detects when a Suspense boundary goes from visible to hidden.
  17852. // It returns false if the boundary is already hidden.
  17853. // TODO: Use an effect tag.
  17854. function isSuspenseBoundaryBeingHidden(current, finishedWork) {
  17855. if (current !== null) {
  17856. var oldState = current.memoizedState;
  17857. if (oldState === null || oldState.dehydrated !== null) {
  17858. var newState = finishedWork.memoizedState;
  17859. return newState !== null && newState.dehydrated === null;
  17860. }
  17861. }
  17862. return false;
  17863. }
  17864. function commitResetTextContent(current) {
  17865. resetTextContent(current.stateNode);
  17866. }
  17867. var COMPONENT_TYPE = 0;
  17868. var HAS_PSEUDO_CLASS_TYPE = 1;
  17869. var ROLE_TYPE = 2;
  17870. var TEST_NAME_TYPE = 3;
  17871. var TEXT_TYPE = 4;
  17872. if (typeof Symbol === 'function' && Symbol.for) {
  17873. var symbolFor$1 = Symbol.for;
  17874. COMPONENT_TYPE = symbolFor$1('selector.component');
  17875. HAS_PSEUDO_CLASS_TYPE = symbolFor$1('selector.has_pseudo_class');
  17876. ROLE_TYPE = symbolFor$1('selector.role');
  17877. TEST_NAME_TYPE = symbolFor$1('selector.test_id');
  17878. TEXT_TYPE = symbolFor$1('selector.text');
  17879. }
  17880. var commitHooks = [];
  17881. function onCommitRoot$1() {
  17882. {
  17883. commitHooks.forEach(function (commitHook) {
  17884. return commitHook();
  17885. });
  17886. }
  17887. }
  17888. var ceil = Math.ceil;
  17889. var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher,
  17890. ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner,
  17891. IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing;
  17892. var NoContext =
  17893. /* */
  17894. 0;
  17895. var BatchedContext =
  17896. /* */
  17897. 1;
  17898. var EventContext =
  17899. /* */
  17900. 2;
  17901. var DiscreteEventContext =
  17902. /* */
  17903. 4;
  17904. var LegacyUnbatchedContext =
  17905. /* */
  17906. 8;
  17907. var RenderContext =
  17908. /* */
  17909. 16;
  17910. var CommitContext =
  17911. /* */
  17912. 32;
  17913. var RetryAfterError =
  17914. /* */
  17915. 64;
  17916. var RootIncomplete = 0;
  17917. var RootFatalErrored = 1;
  17918. var RootErrored = 2;
  17919. var RootSuspended = 3;
  17920. var RootSuspendedWithDelay = 4;
  17921. var RootCompleted = 5; // Describes where we are in the React execution stack
  17922. var executionContext = NoContext; // The root we're working on
  17923. var workInProgressRoot = null; // The fiber we're working on
  17924. var workInProgress = null; // The lanes we're rendering
  17925. var workInProgressRootRenderLanes = NoLanes; // Stack that allows components to change the render lanes for its subtree
  17926. // This is a superset of the lanes we started working on at the root. The only
  17927. // case where it's different from `workInProgressRootRenderLanes` is when we
  17928. // enter a subtree that is hidden and needs to be unhidden: Suspense and
  17929. // Offscreen component.
  17930. //
  17931. // Most things in the work loop should deal with workInProgressRootRenderLanes.
  17932. // Most things in begin/complete phases should deal with subtreeRenderLanes.
  17933. var subtreeRenderLanes = NoLanes;
  17934. var subtreeRenderLanesCursor = createCursor(NoLanes); // Whether to root completed, errored, suspended, etc.
  17935. var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown
  17936. var workInProgressRootFatalError = null; // "Included" lanes refer to lanes that were worked on during this render. It's
  17937. // slightly different than `renderLanes` because `renderLanes` can change as you
  17938. // enter and exit an Offscreen tree. This value is the combination of all render
  17939. // lanes for the entire render phase.
  17940. var workInProgressRootIncludedLanes = NoLanes; // The work left over by components that were visited during this render. Only
  17941. // includes unprocessed updates, not work in bailed out children.
  17942. var workInProgressRootSkippedLanes = NoLanes; // Lanes that were updated (in an interleaved event) during this render.
  17943. var workInProgressRootUpdatedLanes = NoLanes; // Lanes that were pinged (in an interleaved event) during this render.
  17944. var workInProgressRootPingedLanes = NoLanes;
  17945. var mostRecentlyUpdatedRoot = null; // The most recent time we committed a fallback. This lets us ensure a train
  17946. // model where we don't commit new loading states in too quick succession.
  17947. var globalMostRecentFallbackTime = 0;
  17948. var FALLBACK_THROTTLE_MS = 500; // The absolute time for when we should start giving up on rendering
  17949. // more and prefer CPU suspense heuristics instead.
  17950. var workInProgressRootRenderTargetTime = Infinity; // How long a render is supposed to take before we start following CPU
  17951. // suspense heuristics and opt out of rendering more content.
  17952. var RENDER_TIMEOUT_MS = 500;
  17953. function resetRenderTimer() {
  17954. workInProgressRootRenderTargetTime = now() + RENDER_TIMEOUT_MS;
  17955. }
  17956. function getRenderTargetTime() {
  17957. return workInProgressRootRenderTargetTime;
  17958. }
  17959. var nextEffect = null;
  17960. var hasUncaughtError = false;
  17961. var firstUncaughtError = null;
  17962. var legacyErrorBoundariesThatAlreadyFailed = null;
  17963. var rootDoesHavePassiveEffects = false;
  17964. var rootWithPendingPassiveEffects = null;
  17965. var pendingPassiveEffectsRenderPriority = NoPriority$1;
  17966. var pendingPassiveEffectsLanes = NoLanes;
  17967. var pendingPassiveHookEffectsMount = [];
  17968. var pendingPassiveHookEffectsUnmount = [];
  17969. var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates
  17970. var NESTED_UPDATE_LIMIT = 50;
  17971. var nestedUpdateCount = 0;
  17972. var rootWithNestedUpdates = null;
  17973. var NESTED_PASSIVE_UPDATE_LIMIT = 50;
  17974. var nestedPassiveUpdateCount = 0; // Marks the need to reschedule pending interactions at these lanes
  17975. // during the commit phase. This enables them to be traced across components
  17976. // that spawn new work during render. E.g. hidden boundaries, suspended SSR
  17977. // hydration or SuspenseList.
  17978. // TODO: Can use a bitmask instead of an array
  17979. var spawnedWorkDuringRender = null; // If two updates are scheduled within the same event, we should treat their
  17980. // event times as simultaneous, even if the actual clock time has advanced
  17981. // between the first and second call.
  17982. var currentEventTime = NoTimestamp;
  17983. var currentEventWipLanes = NoLanes;
  17984. var currentEventPendingLanes = NoLanes; // Dev only flag that tracks if passive effects are currently being flushed.
  17985. // We warn about state updates for unmounted components differently in this case.
  17986. var isFlushingPassiveEffects = false;
  17987. var focusedInstanceHandle = null;
  17988. var shouldFireAfterActiveInstanceBlur = false;
  17989. function getWorkInProgressRoot() {
  17990. return workInProgressRoot;
  17991. }
  17992. function requestEventTime() {
  17993. if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
  17994. // We're inside React, so it's fine to read the actual time.
  17995. return now();
  17996. } // We're not inside React, so we may be in the middle of a browser event.
  17997. if (currentEventTime !== NoTimestamp) {
  17998. // Use the same start time for all updates until we enter React again.
  17999. return currentEventTime;
  18000. } // This is the first update since React yielded. Compute a new start time.
  18001. currentEventTime = now();
  18002. return currentEventTime;
  18003. }
  18004. function requestUpdateLane(fiber) {
  18005. // Special cases
  18006. var mode = fiber.mode;
  18007. if ((mode & BlockingMode) === NoMode) {
  18008. return SyncLane;
  18009. } else if ((mode & ConcurrentMode) === NoMode) {
  18010. return getCurrentPriorityLevel() === ImmediatePriority$1 ? SyncLane : SyncBatchedLane;
  18011. } // The algorithm for assigning an update to a lane should be stable for all
  18012. // updates at the same priority within the same event. To do this, the inputs
  18013. // to the algorithm must be the same. For example, we use the `renderLanes`
  18014. // to avoid choosing a lane that is already in the middle of rendering.
  18015. //
  18016. // However, the "included" lanes could be mutated in between updates in the
  18017. // same event, like if you perform an update inside `flushSync`. Or any other
  18018. // code path that might call `prepareFreshStack`.
  18019. //
  18020. // The trick we use is to cache the first of each of these inputs within an
  18021. // event. Then reset the cached values once we can be sure the event is over.
  18022. // Our heuristic for that is whenever we enter a concurrent work loop.
  18023. //
  18024. // We'll do the same for `currentEventPendingLanes` below.
  18025. if (currentEventWipLanes === NoLanes) {
  18026. currentEventWipLanes = workInProgressRootIncludedLanes;
  18027. }
  18028. var isTransition = requestCurrentTransition() !== NoTransition;
  18029. if (isTransition) {
  18030. if (currentEventPendingLanes !== NoLanes) {
  18031. currentEventPendingLanes = mostRecentlyUpdatedRoot !== null ? mostRecentlyUpdatedRoot.pendingLanes : NoLanes;
  18032. }
  18033. return findTransitionLane(currentEventWipLanes, currentEventPendingLanes);
  18034. } // TODO: Remove this dependency on the Scheduler priority.
  18035. // To do that, we're replacing it with an update lane priority.
  18036. var schedulerPriority = getCurrentPriorityLevel(); // The old behavior was using the priority level of the Scheduler.
  18037. // This couples React to the Scheduler internals, so we're replacing it
  18038. // with the currentUpdateLanePriority above. As an example of how this
  18039. // could be problematic, if we're not inside `Scheduler.runWithPriority`,
  18040. // then we'll get the priority of the current running Scheduler task,
  18041. // which is probably not what we want.
  18042. var lane;
  18043. if ( // TODO: Temporary. We're removing the concept of discrete updates.
  18044. (executionContext & DiscreteEventContext) !== NoContext && schedulerPriority === UserBlockingPriority$2) {
  18045. lane = findUpdateLane(InputDiscreteLanePriority, currentEventWipLanes);
  18046. } else {
  18047. var schedulerLanePriority = schedulerPriorityToLanePriority(schedulerPriority);
  18048. lane = findUpdateLane(schedulerLanePriority, currentEventWipLanes);
  18049. }
  18050. return lane;
  18051. }
  18052. function requestRetryLane(fiber) {
  18053. // This is a fork of `requestUpdateLane` designed specifically for Suspense
  18054. // "retries" — a special update that attempts to flip a Suspense boundary
  18055. // from its placeholder state to its primary/resolved state.
  18056. // Special cases
  18057. var mode = fiber.mode;
  18058. if ((mode & BlockingMode) === NoMode) {
  18059. return SyncLane;
  18060. } else if ((mode & ConcurrentMode) === NoMode) {
  18061. return getCurrentPriorityLevel() === ImmediatePriority$1 ? SyncLane : SyncBatchedLane;
  18062. } // See `requestUpdateLane` for explanation of `currentEventWipLanes`
  18063. if (currentEventWipLanes === NoLanes) {
  18064. currentEventWipLanes = workInProgressRootIncludedLanes;
  18065. }
  18066. return findRetryLane(currentEventWipLanes);
  18067. }
  18068. function scheduleUpdateOnFiber(fiber, lane, eventTime) {
  18069. checkForNestedUpdates();
  18070. warnAboutRenderPhaseUpdatesInDEV(fiber);
  18071. var root = markUpdateLaneFromFiberToRoot(fiber, lane);
  18072. if (root === null) {
  18073. warnAboutUpdateOnUnmountedFiberInDEV(fiber);
  18074. return null;
  18075. } // Mark that the root has a pending update.
  18076. markRootUpdated(root, lane, eventTime);
  18077. if (root === workInProgressRoot) {
  18078. // Received an update to a tree that's in the middle of rendering. Mark
  18079. // that there was an interleaved update work on this root. Unless the
  18080. // `deferRenderPhaseUpdateToNextBatch` flag is off and this is a render
  18081. // phase update. In that case, we don't treat render phase updates as if
  18082. // they were interleaved, for backwards compat reasons.
  18083. {
  18084. workInProgressRootUpdatedLanes = mergeLanes(workInProgressRootUpdatedLanes, lane);
  18085. }
  18086. if (workInProgressRootExitStatus === RootSuspendedWithDelay) {
  18087. // The root already suspended with a delay, which means this render
  18088. // definitely won't finish. Since we have a new update, let's mark it as
  18089. // suspended now, right before marking the incoming update. This has the
  18090. // effect of interrupting the current render and switching to the update.
  18091. // TODO: Make sure this doesn't override pings that happen while we've
  18092. // already started rendering.
  18093. markRootSuspended$1(root, workInProgressRootRenderLanes);
  18094. }
  18095. } // TODO: requestUpdateLanePriority also reads the priority. Pass the
  18096. // priority as an argument to that function and this one.
  18097. var priorityLevel = getCurrentPriorityLevel();
  18098. if (lane === SyncLane) {
  18099. if ( // Check if we're inside unbatchedUpdates
  18100. (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering
  18101. (executionContext & (RenderContext | CommitContext)) === NoContext) {
  18102. // Register pending interactions on the root to avoid losing traced interaction data.
  18103. schedulePendingInteractions(root, lane); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed
  18104. // root inside of batchedUpdates should be synchronous, but layout updates
  18105. // should be deferred until the end of the batch.
  18106. performSyncWorkOnRoot(root);
  18107. } else {
  18108. ensureRootIsScheduled(root, eventTime);
  18109. schedulePendingInteractions(root, lane);
  18110. if (executionContext === NoContext) {
  18111. // Flush the synchronous work now, unless we're already working or inside
  18112. // a batch. This is intentionally inside scheduleUpdateOnFiber instead of
  18113. // scheduleCallbackForFiber to preserve the ability to schedule a callback
  18114. // without immediately flushing it. We only do this for user-initiated
  18115. // updates, to preserve historical behavior of legacy mode.
  18116. resetRenderTimer();
  18117. flushSyncCallbackQueue();
  18118. }
  18119. }
  18120. } else {
  18121. // Schedule a discrete update but only if it's not Sync.
  18122. if ((executionContext & DiscreteEventContext) !== NoContext && ( // Only updates at user-blocking priority or greater are considered
  18123. // discrete, even inside a discrete event.
  18124. priorityLevel === UserBlockingPriority$2 || priorityLevel === ImmediatePriority$1)) {
  18125. // This is the result of a discrete event. Track the lowest priority
  18126. // discrete update per root so we can flush them early, if needed.
  18127. if (rootsWithPendingDiscreteUpdates === null) {
  18128. rootsWithPendingDiscreteUpdates = new Set([root]);
  18129. } else {
  18130. rootsWithPendingDiscreteUpdates.add(root);
  18131. }
  18132. } // Schedule other updates after in case the callback is sync.
  18133. ensureRootIsScheduled(root, eventTime);
  18134. schedulePendingInteractions(root, lane);
  18135. } // We use this when assigning a lane for a transition inside
  18136. // `requestUpdateLane`. We assume it's the same as the root being updated,
  18137. // since in the common case of a single root app it probably is. If it's not
  18138. // the same root, then it's not a huge deal, we just might batch more stuff
  18139. // together more than necessary.
  18140. mostRecentlyUpdatedRoot = root;
  18141. } // This is split into a separate function so we can mark a fiber with pending
  18142. // work without treating it as a typical update that originates from an event;
  18143. // e.g. retrying a Suspense boundary isn't an update, but it does schedule work
  18144. // on a fiber.
  18145. function markUpdateLaneFromFiberToRoot(sourceFiber, lane) {
  18146. // Update the source fiber's lanes
  18147. sourceFiber.lanes = mergeLanes(sourceFiber.lanes, lane);
  18148. var alternate = sourceFiber.alternate;
  18149. if (alternate !== null) {
  18150. alternate.lanes = mergeLanes(alternate.lanes, lane);
  18151. }
  18152. {
  18153. if (alternate === null && (sourceFiber.flags & (Placement | Hydrating)) !== NoFlags) {
  18154. warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber);
  18155. }
  18156. } // Walk the parent path to the root and update the child expiration time.
  18157. var node = sourceFiber;
  18158. var parent = sourceFiber.return;
  18159. while (parent !== null) {
  18160. parent.childLanes = mergeLanes(parent.childLanes, lane);
  18161. alternate = parent.alternate;
  18162. if (alternate !== null) {
  18163. alternate.childLanes = mergeLanes(alternate.childLanes, lane);
  18164. } else {
  18165. {
  18166. if ((parent.flags & (Placement | Hydrating)) !== NoFlags) {
  18167. warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber);
  18168. }
  18169. }
  18170. }
  18171. node = parent;
  18172. parent = parent.return;
  18173. }
  18174. if (node.tag === HostRoot) {
  18175. var root = node.stateNode;
  18176. return root;
  18177. } else {
  18178. return null;
  18179. }
  18180. } // Use this function to schedule a task for a root. There's only one task per
  18181. // root; if a task was already scheduled, we'll check to make sure the priority
  18182. // of the existing task is the same as the priority of the next level that the
  18183. // root has work on. This function is called on every update, and right before
  18184. // exiting a task.
  18185. function ensureRootIsScheduled(root, currentTime) {
  18186. var existingCallbackNode = root.callbackNode; // Check if any lanes are being starved by other work. If so, mark them as
  18187. // expired so we know to work on those next.
  18188. markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority.
  18189. var nextLanes = getNextLanes(root, root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes); // This returns the priority level computed during the `getNextLanes` call.
  18190. var newCallbackPriority = returnNextLanesPriority();
  18191. if (nextLanes === NoLanes) {
  18192. // Special case: There's nothing to work on.
  18193. if (existingCallbackNode !== null) {
  18194. cancelCallback(existingCallbackNode);
  18195. root.callbackNode = null;
  18196. root.callbackPriority = NoLanePriority;
  18197. }
  18198. return;
  18199. } // Check if there's an existing task. We may be able to reuse it.
  18200. if (existingCallbackNode !== null) {
  18201. var existingCallbackPriority = root.callbackPriority;
  18202. if (existingCallbackPriority === newCallbackPriority) {
  18203. // The priority hasn't changed. We can reuse the existing task. Exit.
  18204. return;
  18205. } // The priority changed. Cancel the existing callback. We'll schedule a new
  18206. // one below.
  18207. cancelCallback(existingCallbackNode);
  18208. } // Schedule a new callback.
  18209. var newCallbackNode;
  18210. if (newCallbackPriority === SyncLanePriority) {
  18211. // Special case: Sync React callbacks are scheduled on a special
  18212. // internal queue
  18213. newCallbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
  18214. } else if (newCallbackPriority === SyncBatchedLanePriority) {
  18215. newCallbackNode = scheduleCallback(ImmediatePriority$1, performSyncWorkOnRoot.bind(null, root));
  18216. } else {
  18217. var schedulerPriorityLevel = lanePriorityToSchedulerPriority(newCallbackPriority);
  18218. newCallbackNode = scheduleCallback(schedulerPriorityLevel, performConcurrentWorkOnRoot.bind(null, root));
  18219. }
  18220. root.callbackPriority = newCallbackPriority;
  18221. root.callbackNode = newCallbackNode;
  18222. } // This is the entry point for every concurrent task, i.e. anything that
  18223. // goes through Scheduler.
  18224. function performConcurrentWorkOnRoot(root) {
  18225. // Since we know we're in a React event, we can clear the current
  18226. // event time. The next update will compute a new event time.
  18227. currentEventTime = NoTimestamp;
  18228. currentEventWipLanes = NoLanes;
  18229. currentEventPendingLanes = NoLanes;
  18230. if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
  18231. {
  18232. throw Error( "Should not already be working." );
  18233. }
  18234. } // Flush any pending passive effects before deciding which lanes to work on,
  18235. // in case they schedule additional work.
  18236. var originalCallbackNode = root.callbackNode;
  18237. var didFlushPassiveEffects = flushPassiveEffects();
  18238. if (didFlushPassiveEffects) {
  18239. // Something in the passive effect phase may have canceled the current task.
  18240. // Check if the task node for this root was changed.
  18241. if (root.callbackNode !== originalCallbackNode) {
  18242. // The current task was canceled. Exit. We don't need to call
  18243. // `ensureRootIsScheduled` because the check above implies either that
  18244. // there's a new task, or that there's no remaining work on this root.
  18245. return null;
  18246. }
  18247. } // Determine the next expiration time to work on, using the fields stored
  18248. // on the root.
  18249. var lanes = getNextLanes(root, root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes);
  18250. if (lanes === NoLanes) {
  18251. // Defensive coding. This is never expected to happen.
  18252. return null;
  18253. }
  18254. var exitStatus = renderRootConcurrent(root, lanes);
  18255. if (includesSomeLane(workInProgressRootIncludedLanes, workInProgressRootUpdatedLanes)) {
  18256. // The render included lanes that were updated during the render phase.
  18257. // For example, when unhiding a hidden tree, we include all the lanes
  18258. // that were previously skipped when the tree was hidden. That set of
  18259. // lanes is a superset of the lanes we started rendering with.
  18260. //
  18261. // So we'll throw out the current work and restart.
  18262. prepareFreshStack(root, NoLanes);
  18263. } else if (exitStatus !== RootIncomplete) {
  18264. if (exitStatus === RootErrored) {
  18265. executionContext |= RetryAfterError; // If an error occurred during hydration,
  18266. // discard server response and fall back to client side render.
  18267. if (root.hydrate) {
  18268. root.hydrate = false;
  18269. clearContainer(root.containerInfo);
  18270. } // If something threw an error, try rendering one more time. We'll render
  18271. // synchronously to block concurrent data mutations, and we'll includes
  18272. // all pending updates are included. If it still fails after the second
  18273. // attempt, we'll give up and commit the resulting tree.
  18274. lanes = getLanesToRetrySynchronouslyOnError(root);
  18275. if (lanes !== NoLanes) {
  18276. exitStatus = renderRootSync(root, lanes);
  18277. }
  18278. }
  18279. if (exitStatus === RootFatalErrored) {
  18280. var fatalError = workInProgressRootFatalError;
  18281. prepareFreshStack(root, NoLanes);
  18282. markRootSuspended$1(root, lanes);
  18283. ensureRootIsScheduled(root, now());
  18284. throw fatalError;
  18285. } // We now have a consistent tree. The next step is either to commit it,
  18286. // or, if something suspended, wait to commit it after a timeout.
  18287. var finishedWork = root.current.alternate;
  18288. root.finishedWork = finishedWork;
  18289. root.finishedLanes = lanes;
  18290. finishConcurrentRender(root, exitStatus, lanes);
  18291. }
  18292. ensureRootIsScheduled(root, now());
  18293. if (root.callbackNode === originalCallbackNode) {
  18294. // The task node scheduled for this root is the same one that's
  18295. // currently executed. Need to return a continuation.
  18296. return performConcurrentWorkOnRoot.bind(null, root);
  18297. }
  18298. return null;
  18299. }
  18300. function finishConcurrentRender(root, exitStatus, lanes) {
  18301. switch (exitStatus) {
  18302. case RootIncomplete:
  18303. case RootFatalErrored:
  18304. {
  18305. {
  18306. {
  18307. throw Error( "Root did not complete. This is a bug in React." );
  18308. }
  18309. }
  18310. }
  18311. // Flow knows about invariant, so it complains if I add a break
  18312. // statement, but eslint doesn't know about invariant, so it complains
  18313. // if I do. eslint-disable-next-line no-fallthrough
  18314. case RootErrored:
  18315. {
  18316. // We should have already attempted to retry this tree. If we reached
  18317. // this point, it errored again. Commit it.
  18318. commitRoot(root);
  18319. break;
  18320. }
  18321. case RootSuspended:
  18322. {
  18323. markRootSuspended$1(root, lanes); // We have an acceptable loading state. We need to figure out if we
  18324. // should immediately commit it or wait a bit.
  18325. if (includesOnlyRetries(lanes) && // do not delay if we're inside an act() scope
  18326. !shouldForceFlushFallbacksInDEV()) {
  18327. // This render only included retries, no updates. Throttle committing
  18328. // retries so that we don't show too many loading states too quickly.
  18329. var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now(); // Don't bother with a very short suspense time.
  18330. if (msUntilTimeout > 10) {
  18331. var nextLanes = getNextLanes(root, NoLanes);
  18332. if (nextLanes !== NoLanes) {
  18333. // There's additional work on this root.
  18334. break;
  18335. }
  18336. var suspendedLanes = root.suspendedLanes;
  18337. if (!isSubsetOfLanes(suspendedLanes, lanes)) {
  18338. // We should prefer to render the fallback of at the last
  18339. // suspended level. Ping the last suspended level to try
  18340. // rendering it again.
  18341. // FIXME: What if the suspended lanes are Idle? Should not restart.
  18342. var eventTime = requestEventTime();
  18343. markRootPinged(root, suspendedLanes);
  18344. break;
  18345. } // The render is suspended, it hasn't timed out, and there's no
  18346. // lower priority work to do. Instead of committing the fallback
  18347. // immediately, wait for more data to arrive.
  18348. root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), msUntilTimeout);
  18349. break;
  18350. }
  18351. } // The work expired. Commit immediately.
  18352. commitRoot(root);
  18353. break;
  18354. }
  18355. case RootSuspendedWithDelay:
  18356. {
  18357. markRootSuspended$1(root, lanes);
  18358. if (includesOnlyTransitions(lanes)) {
  18359. // This is a transition, so we should exit without committing a
  18360. // placeholder and without scheduling a timeout. Delay indefinitely
  18361. // until we receive more data.
  18362. break;
  18363. }
  18364. if (!shouldForceFlushFallbacksInDEV()) {
  18365. // This is not a transition, but we did trigger an avoided state.
  18366. // Schedule a placeholder to display after a short delay, using the Just
  18367. // Noticeable Difference.
  18368. // TODO: Is the JND optimization worth the added complexity? If this is
  18369. // the only reason we track the event time, then probably not.
  18370. // Consider removing.
  18371. var mostRecentEventTime = getMostRecentEventTime(root, lanes);
  18372. var eventTimeMs = mostRecentEventTime;
  18373. var timeElapsedMs = now() - eventTimeMs;
  18374. var _msUntilTimeout = jnd(timeElapsedMs) - timeElapsedMs; // Don't bother with a very short suspense time.
  18375. if (_msUntilTimeout > 10) {
  18376. // Instead of committing the fallback immediately, wait for more data
  18377. // to arrive.
  18378. root.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root), _msUntilTimeout);
  18379. break;
  18380. }
  18381. } // Commit the placeholder.
  18382. commitRoot(root);
  18383. break;
  18384. }
  18385. case RootCompleted:
  18386. {
  18387. // The work completed. Ready to commit.
  18388. commitRoot(root);
  18389. break;
  18390. }
  18391. default:
  18392. {
  18393. {
  18394. {
  18395. throw Error( "Unknown root exit status." );
  18396. }
  18397. }
  18398. }
  18399. }
  18400. }
  18401. function markRootSuspended$1(root, suspendedLanes) {
  18402. // When suspending, we should always exclude lanes that were pinged or (more
  18403. // rarely, since we try to avoid it) updated during the render phase.
  18404. // TODO: Lol maybe there's a better way to factor this besides this
  18405. // obnoxiously named function :)
  18406. suspendedLanes = removeLanes(suspendedLanes, workInProgressRootPingedLanes);
  18407. suspendedLanes = removeLanes(suspendedLanes, workInProgressRootUpdatedLanes);
  18408. markRootSuspended(root, suspendedLanes);
  18409. } // This is the entry point for synchronous tasks that don't go
  18410. // through Scheduler
  18411. function performSyncWorkOnRoot(root) {
  18412. if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
  18413. {
  18414. throw Error( "Should not already be working." );
  18415. }
  18416. }
  18417. flushPassiveEffects();
  18418. var lanes;
  18419. var exitStatus;
  18420. if (root === workInProgressRoot && includesSomeLane(root.expiredLanes, workInProgressRootRenderLanes)) {
  18421. // There's a partial tree, and at least one of its lanes has expired. Finish
  18422. // rendering it before rendering the rest of the expired work.
  18423. lanes = workInProgressRootRenderLanes;
  18424. exitStatus = renderRootSync(root, lanes);
  18425. if (includesSomeLane(workInProgressRootIncludedLanes, workInProgressRootUpdatedLanes)) {
  18426. // The render included lanes that were updated during the render phase.
  18427. // For example, when unhiding a hidden tree, we include all the lanes
  18428. // that were previously skipped when the tree was hidden. That set of
  18429. // lanes is a superset of the lanes we started rendering with.
  18430. //
  18431. // Note that this only happens when part of the tree is rendered
  18432. // concurrently. If the whole tree is rendered synchronously, then there
  18433. // are no interleaved events.
  18434. lanes = getNextLanes(root, lanes);
  18435. exitStatus = renderRootSync(root, lanes);
  18436. }
  18437. } else {
  18438. lanes = getNextLanes(root, NoLanes);
  18439. exitStatus = renderRootSync(root, lanes);
  18440. }
  18441. if (root.tag !== LegacyRoot && exitStatus === RootErrored) {
  18442. executionContext |= RetryAfterError; // If an error occurred during hydration,
  18443. // discard server response and fall back to client side render.
  18444. if (root.hydrate) {
  18445. root.hydrate = false;
  18446. clearContainer(root.containerInfo);
  18447. } // If something threw an error, try rendering one more time. We'll render
  18448. // synchronously to block concurrent data mutations, and we'll includes
  18449. // all pending updates are included. If it still fails after the second
  18450. // attempt, we'll give up and commit the resulting tree.
  18451. lanes = getLanesToRetrySynchronouslyOnError(root);
  18452. if (lanes !== NoLanes) {
  18453. exitStatus = renderRootSync(root, lanes);
  18454. }
  18455. }
  18456. if (exitStatus === RootFatalErrored) {
  18457. var fatalError = workInProgressRootFatalError;
  18458. prepareFreshStack(root, NoLanes);
  18459. markRootSuspended$1(root, lanes);
  18460. ensureRootIsScheduled(root, now());
  18461. throw fatalError;
  18462. } // We now have a consistent tree. Because this is a sync render, we
  18463. // will commit it even if something suspended.
  18464. var finishedWork = root.current.alternate;
  18465. root.finishedWork = finishedWork;
  18466. root.finishedLanes = lanes;
  18467. commitRoot(root); // Before exiting, make sure there's a callback scheduled for the next
  18468. // pending level.
  18469. ensureRootIsScheduled(root, now());
  18470. return null;
  18471. }
  18472. function flushDiscreteUpdates() {
  18473. // TODO: Should be able to flush inside batchedUpdates, but not inside `act`.
  18474. // However, `act` uses `batchedUpdates`, so there's no way to distinguish
  18475. // those two cases. Need to fix this before exposing flushDiscreteUpdates
  18476. // as a public API.
  18477. if ((executionContext & (BatchedContext | RenderContext | CommitContext)) !== NoContext) {
  18478. {
  18479. if ((executionContext & RenderContext) !== NoContext) {
  18480. error('unstable_flushDiscreteUpdates: Cannot flush updates when React is ' + 'already rendering.');
  18481. }
  18482. } // We're already rendering, so we can't synchronously flush pending work.
  18483. // This is probably a nested event dispatch triggered by a lifecycle/effect,
  18484. // like `el.focus()`. Exit.
  18485. return;
  18486. }
  18487. flushPendingDiscreteUpdates(); // If the discrete updates scheduled passive effects, flush them now so that
  18488. // they fire before the next serial event.
  18489. flushPassiveEffects();
  18490. }
  18491. function flushPendingDiscreteUpdates() {
  18492. if (rootsWithPendingDiscreteUpdates !== null) {
  18493. // For each root with pending discrete updates, schedule a callback to
  18494. // immediately flush them.
  18495. var roots = rootsWithPendingDiscreteUpdates;
  18496. rootsWithPendingDiscreteUpdates = null;
  18497. roots.forEach(function (root) {
  18498. markDiscreteUpdatesExpired(root);
  18499. ensureRootIsScheduled(root, now());
  18500. });
  18501. } // Now flush the immediate queue.
  18502. flushSyncCallbackQueue();
  18503. }
  18504. function batchedUpdates$1(fn, a) {
  18505. var prevExecutionContext = executionContext;
  18506. executionContext |= BatchedContext;
  18507. try {
  18508. return fn(a);
  18509. } finally {
  18510. executionContext = prevExecutionContext;
  18511. if (executionContext === NoContext) {
  18512. // Flush the immediate callbacks that were scheduled during this batch
  18513. resetRenderTimer();
  18514. flushSyncCallbackQueue();
  18515. }
  18516. }
  18517. }
  18518. function batchedEventUpdates$1(fn, a) {
  18519. var prevExecutionContext = executionContext;
  18520. executionContext |= EventContext;
  18521. try {
  18522. return fn(a);
  18523. } finally {
  18524. executionContext = prevExecutionContext;
  18525. if (executionContext === NoContext) {
  18526. // Flush the immediate callbacks that were scheduled during this batch
  18527. resetRenderTimer();
  18528. flushSyncCallbackQueue();
  18529. }
  18530. }
  18531. }
  18532. function discreteUpdates$1(fn, a, b, c, d) {
  18533. var prevExecutionContext = executionContext;
  18534. executionContext |= DiscreteEventContext;
  18535. {
  18536. try {
  18537. return runWithPriority$1(UserBlockingPriority$2, fn.bind(null, a, b, c, d));
  18538. } finally {
  18539. executionContext = prevExecutionContext;
  18540. if (executionContext === NoContext) {
  18541. // Flush the immediate callbacks that were scheduled during this batch
  18542. resetRenderTimer();
  18543. flushSyncCallbackQueue();
  18544. }
  18545. }
  18546. }
  18547. }
  18548. function unbatchedUpdates(fn, a) {
  18549. var prevExecutionContext = executionContext;
  18550. executionContext &= ~BatchedContext;
  18551. executionContext |= LegacyUnbatchedContext;
  18552. try {
  18553. return fn(a);
  18554. } finally {
  18555. executionContext = prevExecutionContext;
  18556. if (executionContext === NoContext) {
  18557. // Flush the immediate callbacks that were scheduled during this batch
  18558. resetRenderTimer();
  18559. flushSyncCallbackQueue();
  18560. }
  18561. }
  18562. }
  18563. function flushSync(fn, a) {
  18564. var prevExecutionContext = executionContext;
  18565. if ((prevExecutionContext & (RenderContext | CommitContext)) !== NoContext) {
  18566. {
  18567. error('flushSync was called from inside a lifecycle method. React cannot ' + 'flush when React is already rendering. Consider moving this call to ' + 'a scheduler task or micro task.');
  18568. }
  18569. return fn(a);
  18570. }
  18571. executionContext |= BatchedContext;
  18572. {
  18573. try {
  18574. if (fn) {
  18575. return runWithPriority$1(ImmediatePriority$1, fn.bind(null, a));
  18576. } else {
  18577. return undefined;
  18578. }
  18579. } finally {
  18580. executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch.
  18581. // Note that this will happen even if batchedUpdates is higher up
  18582. // the stack.
  18583. flushSyncCallbackQueue();
  18584. }
  18585. }
  18586. }
  18587. function pushRenderLanes(fiber, lanes) {
  18588. push(subtreeRenderLanesCursor, subtreeRenderLanes, fiber);
  18589. subtreeRenderLanes = mergeLanes(subtreeRenderLanes, lanes);
  18590. workInProgressRootIncludedLanes = mergeLanes(workInProgressRootIncludedLanes, lanes);
  18591. }
  18592. function popRenderLanes(fiber) {
  18593. subtreeRenderLanes = subtreeRenderLanesCursor.current;
  18594. pop(subtreeRenderLanesCursor, fiber);
  18595. }
  18596. function prepareFreshStack(root, lanes) {
  18597. root.finishedWork = null;
  18598. root.finishedLanes = NoLanes;
  18599. var timeoutHandle = root.timeoutHandle;
  18600. if (timeoutHandle !== noTimeout) {
  18601. // The root previous suspended and scheduled a timeout to commit a fallback
  18602. // state. Now that we have additional work, cancel the timeout.
  18603. root.timeoutHandle = noTimeout; // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
  18604. cancelTimeout(timeoutHandle);
  18605. }
  18606. if (workInProgress !== null) {
  18607. var interruptedWork = workInProgress.return;
  18608. while (interruptedWork !== null) {
  18609. unwindInterruptedWork(interruptedWork);
  18610. interruptedWork = interruptedWork.return;
  18611. }
  18612. }
  18613. workInProgressRoot = root;
  18614. workInProgress = createWorkInProgress(root.current, null);
  18615. workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes;
  18616. workInProgressRootExitStatus = RootIncomplete;
  18617. workInProgressRootFatalError = null;
  18618. workInProgressRootSkippedLanes = NoLanes;
  18619. workInProgressRootUpdatedLanes = NoLanes;
  18620. workInProgressRootPingedLanes = NoLanes;
  18621. {
  18622. spawnedWorkDuringRender = null;
  18623. }
  18624. {
  18625. ReactStrictModeWarnings.discardPendingWarnings();
  18626. }
  18627. }
  18628. function handleError(root, thrownValue) {
  18629. do {
  18630. var erroredWork = workInProgress;
  18631. try {
  18632. // Reset module-level state that was set during the render phase.
  18633. resetContextDependencies();
  18634. resetHooksAfterThrow();
  18635. resetCurrentFiber(); // TODO: I found and added this missing line while investigating a
  18636. // separate issue. Write a regression test using string refs.
  18637. ReactCurrentOwner$2.current = null;
  18638. if (erroredWork === null || erroredWork.return === null) {
  18639. // Expected to be working on a non-root fiber. This is a fatal error
  18640. // because there's no ancestor that can handle it; the root is
  18641. // supposed to capture all errors that weren't caught by an error
  18642. // boundary.
  18643. workInProgressRootExitStatus = RootFatalErrored;
  18644. workInProgressRootFatalError = thrownValue; // Set `workInProgress` to null. This represents advancing to the next
  18645. // sibling, or the parent if there are no siblings. But since the root
  18646. // has no siblings nor a parent, we set it to null. Usually this is
  18647. // handled by `completeUnitOfWork` or `unwindWork`, but since we're
  18648. // intentionally not calling those, we need set it here.
  18649. // TODO: Consider calling `unwindWork` to pop the contexts.
  18650. workInProgress = null;
  18651. return;
  18652. }
  18653. if (enableProfilerTimer && erroredWork.mode & ProfileMode) {
  18654. // Record the time spent rendering before an error was thrown. This
  18655. // avoids inaccurate Profiler durations in the case of a
  18656. // suspended render.
  18657. stopProfilerTimerIfRunningAndRecordDelta(erroredWork, true);
  18658. }
  18659. throwException(root, erroredWork.return, erroredWork, thrownValue, workInProgressRootRenderLanes);
  18660. completeUnitOfWork(erroredWork);
  18661. } catch (yetAnotherThrownValue) {
  18662. // Something in the return path also threw.
  18663. thrownValue = yetAnotherThrownValue;
  18664. if (workInProgress === erroredWork && erroredWork !== null) {
  18665. // If this boundary has already errored, then we had trouble processing
  18666. // the error. Bubble it to the next boundary.
  18667. erroredWork = erroredWork.return;
  18668. workInProgress = erroredWork;
  18669. } else {
  18670. erroredWork = workInProgress;
  18671. }
  18672. continue;
  18673. } // Return to the normal work loop.
  18674. return;
  18675. } while (true);
  18676. }
  18677. function pushDispatcher() {
  18678. var prevDispatcher = ReactCurrentDispatcher$2.current;
  18679. ReactCurrentDispatcher$2.current = ContextOnlyDispatcher;
  18680. if (prevDispatcher === null) {
  18681. // The React isomorphic package does not include a default dispatcher.
  18682. // Instead the first renderer will lazily attach one, in order to give
  18683. // nicer error messages.
  18684. return ContextOnlyDispatcher;
  18685. } else {
  18686. return prevDispatcher;
  18687. }
  18688. }
  18689. function popDispatcher(prevDispatcher) {
  18690. ReactCurrentDispatcher$2.current = prevDispatcher;
  18691. }
  18692. function pushInteractions(root) {
  18693. {
  18694. var prevInteractions = tracing.__interactionsRef.current;
  18695. tracing.__interactionsRef.current = root.memoizedInteractions;
  18696. return prevInteractions;
  18697. }
  18698. }
  18699. function popInteractions(prevInteractions) {
  18700. {
  18701. tracing.__interactionsRef.current = prevInteractions;
  18702. }
  18703. }
  18704. function markCommitTimeOfFallback() {
  18705. globalMostRecentFallbackTime = now();
  18706. }
  18707. function markSkippedUpdateLanes(lane) {
  18708. workInProgressRootSkippedLanes = mergeLanes(lane, workInProgressRootSkippedLanes);
  18709. }
  18710. function renderDidSuspend() {
  18711. if (workInProgressRootExitStatus === RootIncomplete) {
  18712. workInProgressRootExitStatus = RootSuspended;
  18713. }
  18714. }
  18715. function renderDidSuspendDelayIfPossible() {
  18716. if (workInProgressRootExitStatus === RootIncomplete || workInProgressRootExitStatus === RootSuspended) {
  18717. workInProgressRootExitStatus = RootSuspendedWithDelay;
  18718. } // Check if there are updates that we skipped tree that might have unblocked
  18719. // this render.
  18720. if (workInProgressRoot !== null && (includesNonIdleWork(workInProgressRootSkippedLanes) || includesNonIdleWork(workInProgressRootUpdatedLanes))) {
  18721. // Mark the current render as suspended so that we switch to working on
  18722. // the updates that were skipped. Usually we only suspend at the end of
  18723. // the render phase.
  18724. // TODO: We should probably always mark the root as suspended immediately
  18725. // (inside this function), since by suspending at the end of the render
  18726. // phase introduces a potential mistake where we suspend lanes that were
  18727. // pinged or updated while we were rendering.
  18728. markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes);
  18729. }
  18730. }
  18731. function renderDidError() {
  18732. if (workInProgressRootExitStatus !== RootCompleted) {
  18733. workInProgressRootExitStatus = RootErrored;
  18734. }
  18735. } // Called during render to determine if anything has suspended.
  18736. // Returns false if we're not sure.
  18737. function renderHasNotSuspendedYet() {
  18738. // If something errored or completed, we can't really be sure,
  18739. // so those are false.
  18740. return workInProgressRootExitStatus === RootIncomplete;
  18741. }
  18742. function renderRootSync(root, lanes) {
  18743. var prevExecutionContext = executionContext;
  18744. executionContext |= RenderContext;
  18745. var prevDispatcher = pushDispatcher(); // If the root or lanes have changed, throw out the existing stack
  18746. // and prepare a fresh one. Otherwise we'll continue where we left off.
  18747. if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) {
  18748. prepareFreshStack(root, lanes);
  18749. startWorkOnPendingInteractions(root, lanes);
  18750. }
  18751. var prevInteractions = pushInteractions(root);
  18752. do {
  18753. try {
  18754. workLoopSync();
  18755. break;
  18756. } catch (thrownValue) {
  18757. handleError(root, thrownValue);
  18758. }
  18759. } while (true);
  18760. resetContextDependencies();
  18761. {
  18762. popInteractions(prevInteractions);
  18763. }
  18764. executionContext = prevExecutionContext;
  18765. popDispatcher(prevDispatcher);
  18766. if (workInProgress !== null) {
  18767. // This is a sync render, so we should have finished the whole tree.
  18768. {
  18769. {
  18770. throw Error( "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." );
  18771. }
  18772. }
  18773. }
  18774. workInProgressRoot = null;
  18775. workInProgressRootRenderLanes = NoLanes;
  18776. return workInProgressRootExitStatus;
  18777. } // The work loop is an extremely hot path. Tell Closure not to inline it.
  18778. /** @noinline */
  18779. function workLoopSync() {
  18780. // Already timed out, so perform work without checking if we need to yield.
  18781. while (workInProgress !== null) {
  18782. performUnitOfWork(workInProgress);
  18783. }
  18784. }
  18785. function renderRootConcurrent(root, lanes) {
  18786. var prevExecutionContext = executionContext;
  18787. executionContext |= RenderContext;
  18788. var prevDispatcher = pushDispatcher(); // If the root or lanes have changed, throw out the existing stack
  18789. // and prepare a fresh one. Otherwise we'll continue where we left off.
  18790. if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) {
  18791. resetRenderTimer();
  18792. prepareFreshStack(root, lanes);
  18793. startWorkOnPendingInteractions(root, lanes);
  18794. }
  18795. var prevInteractions = pushInteractions(root);
  18796. do {
  18797. try {
  18798. workLoopConcurrent();
  18799. break;
  18800. } catch (thrownValue) {
  18801. handleError(root, thrownValue);
  18802. }
  18803. } while (true);
  18804. resetContextDependencies();
  18805. {
  18806. popInteractions(prevInteractions);
  18807. }
  18808. popDispatcher(prevDispatcher);
  18809. executionContext = prevExecutionContext;
  18810. if (workInProgress !== null) {
  18811. return RootIncomplete;
  18812. } else {
  18813. workInProgressRoot = null;
  18814. workInProgressRootRenderLanes = NoLanes; // Return the final exit status.
  18815. return workInProgressRootExitStatus;
  18816. }
  18817. }
  18818. /** @noinline */
  18819. function workLoopConcurrent() {
  18820. // Perform work until Scheduler asks us to yield
  18821. while (workInProgress !== null && !shouldYield()) {
  18822. performUnitOfWork(workInProgress);
  18823. }
  18824. }
  18825. function performUnitOfWork(unitOfWork) {
  18826. // The current, flushed, state of this fiber is the alternate. Ideally
  18827. // nothing should rely on this, but relying on it here means that we don't
  18828. // need an additional field on the work in progress.
  18829. var current = unitOfWork.alternate;
  18830. setCurrentFiber(unitOfWork);
  18831. var next;
  18832. if ( (unitOfWork.mode & ProfileMode) !== NoMode) {
  18833. startProfilerTimer(unitOfWork);
  18834. next = beginWork$1(current, unitOfWork, subtreeRenderLanes);
  18835. stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);
  18836. } else {
  18837. next = beginWork$1(current, unitOfWork, subtreeRenderLanes);
  18838. }
  18839. resetCurrentFiber();
  18840. unitOfWork.memoizedProps = unitOfWork.pendingProps;
  18841. if (next === null) {
  18842. // If this doesn't spawn new work, complete the current work.
  18843. completeUnitOfWork(unitOfWork);
  18844. } else {
  18845. workInProgress = next;
  18846. }
  18847. ReactCurrentOwner$2.current = null;
  18848. }
  18849. function completeUnitOfWork(unitOfWork) {
  18850. // Attempt to complete the current unit of work, then move to the next
  18851. // sibling. If there are no more siblings, return to the parent fiber.
  18852. var completedWork = unitOfWork;
  18853. do {
  18854. // The current, flushed, state of this fiber is the alternate. Ideally
  18855. // nothing should rely on this, but relying on it here means that we don't
  18856. // need an additional field on the work in progress.
  18857. var current = completedWork.alternate;
  18858. var returnFiber = completedWork.return; // Check if the work completed or if something threw.
  18859. if ((completedWork.flags & Incomplete) === NoFlags) {
  18860. setCurrentFiber(completedWork);
  18861. var next = void 0;
  18862. if ( (completedWork.mode & ProfileMode) === NoMode) {
  18863. next = completeWork(current, completedWork, subtreeRenderLanes);
  18864. } else {
  18865. startProfilerTimer(completedWork);
  18866. next = completeWork(current, completedWork, subtreeRenderLanes); // Update render duration assuming we didn't error.
  18867. stopProfilerTimerIfRunningAndRecordDelta(completedWork, false);
  18868. }
  18869. resetCurrentFiber();
  18870. if (next !== null) {
  18871. // Completing this fiber spawned new work. Work on that next.
  18872. workInProgress = next;
  18873. return;
  18874. }
  18875. resetChildLanes(completedWork);
  18876. if (returnFiber !== null && // Do not append effects to parents if a sibling failed to complete
  18877. (returnFiber.flags & Incomplete) === NoFlags) {
  18878. // Append all the effects of the subtree and this fiber onto the effect
  18879. // list of the parent. The completion order of the children affects the
  18880. // side-effect order.
  18881. if (returnFiber.firstEffect === null) {
  18882. returnFiber.firstEffect = completedWork.firstEffect;
  18883. }
  18884. if (completedWork.lastEffect !== null) {
  18885. if (returnFiber.lastEffect !== null) {
  18886. returnFiber.lastEffect.nextEffect = completedWork.firstEffect;
  18887. }
  18888. returnFiber.lastEffect = completedWork.lastEffect;
  18889. } // If this fiber had side-effects, we append it AFTER the children's
  18890. // side-effects. We can perform certain side-effects earlier if needed,
  18891. // by doing multiple passes over the effect list. We don't want to
  18892. // schedule our own side-effect on our own list because if end up
  18893. // reusing children we'll schedule this effect onto itself since we're
  18894. // at the end.
  18895. var flags = completedWork.flags; // Skip both NoWork and PerformedWork tags when creating the effect
  18896. // list. PerformedWork effect is read by React DevTools but shouldn't be
  18897. // committed.
  18898. if (flags > PerformedWork) {
  18899. if (returnFiber.lastEffect !== null) {
  18900. returnFiber.lastEffect.nextEffect = completedWork;
  18901. } else {
  18902. returnFiber.firstEffect = completedWork;
  18903. }
  18904. returnFiber.lastEffect = completedWork;
  18905. }
  18906. }
  18907. } else {
  18908. // This fiber did not complete because something threw. Pop values off
  18909. // the stack without entering the complete phase. If this is a boundary,
  18910. // capture values if possible.
  18911. var _next = unwindWork(completedWork); // Because this fiber did not complete, don't reset its expiration time.
  18912. if (_next !== null) {
  18913. // If completing this work spawned new work, do that next. We'll come
  18914. // back here again.
  18915. // Since we're restarting, remove anything that is not a host effect
  18916. // from the effect tag.
  18917. _next.flags &= HostEffectMask;
  18918. workInProgress = _next;
  18919. return;
  18920. }
  18921. if ( (completedWork.mode & ProfileMode) !== NoMode) {
  18922. // Record the render duration for the fiber that errored.
  18923. stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); // Include the time spent working on failed children before continuing.
  18924. var actualDuration = completedWork.actualDuration;
  18925. var child = completedWork.child;
  18926. while (child !== null) {
  18927. actualDuration += child.actualDuration;
  18928. child = child.sibling;
  18929. }
  18930. completedWork.actualDuration = actualDuration;
  18931. }
  18932. if (returnFiber !== null) {
  18933. // Mark the parent fiber as incomplete and clear its effect list.
  18934. returnFiber.firstEffect = returnFiber.lastEffect = null;
  18935. returnFiber.flags |= Incomplete;
  18936. }
  18937. }
  18938. var siblingFiber = completedWork.sibling;
  18939. if (siblingFiber !== null) {
  18940. // If there is more work to do in this returnFiber, do that next.
  18941. workInProgress = siblingFiber;
  18942. return;
  18943. } // Otherwise, return to the parent
  18944. completedWork = returnFiber; // Update the next thing we're working on in case something throws.
  18945. workInProgress = completedWork;
  18946. } while (completedWork !== null); // We've reached the root.
  18947. if (workInProgressRootExitStatus === RootIncomplete) {
  18948. workInProgressRootExitStatus = RootCompleted;
  18949. }
  18950. }
  18951. function resetChildLanes(completedWork) {
  18952. if ( // TODO: Move this check out of the hot path by moving `resetChildLanes`
  18953. // to switch statement in `completeWork`.
  18954. (completedWork.tag === LegacyHiddenComponent || completedWork.tag === OffscreenComponent) && completedWork.memoizedState !== null && !includesSomeLane(subtreeRenderLanes, OffscreenLane) && (completedWork.mode & ConcurrentMode) !== NoLanes) {
  18955. // The children of this component are hidden. Don't bubble their
  18956. // expiration times.
  18957. return;
  18958. }
  18959. var newChildLanes = NoLanes; // Bubble up the earliest expiration time.
  18960. if ( (completedWork.mode & ProfileMode) !== NoMode) {
  18961. // In profiling mode, resetChildExpirationTime is also used to reset
  18962. // profiler durations.
  18963. var actualDuration = completedWork.actualDuration;
  18964. var treeBaseDuration = completedWork.selfBaseDuration; // When a fiber is cloned, its actualDuration is reset to 0. This value will
  18965. // only be updated if work is done on the fiber (i.e. it doesn't bailout).
  18966. // When work is done, it should bubble to the parent's actualDuration. If
  18967. // the fiber has not been cloned though, (meaning no work was done), then
  18968. // this value will reflect the amount of time spent working on a previous
  18969. // render. In that case it should not bubble. We determine whether it was
  18970. // cloned by comparing the child pointer.
  18971. var shouldBubbleActualDurations = completedWork.alternate === null || completedWork.child !== completedWork.alternate.child;
  18972. var child = completedWork.child;
  18973. while (child !== null) {
  18974. newChildLanes = mergeLanes(newChildLanes, mergeLanes(child.lanes, child.childLanes));
  18975. if (shouldBubbleActualDurations) {
  18976. actualDuration += child.actualDuration;
  18977. }
  18978. treeBaseDuration += child.treeBaseDuration;
  18979. child = child.sibling;
  18980. }
  18981. var isTimedOutSuspense = completedWork.tag === SuspenseComponent && completedWork.memoizedState !== null;
  18982. if (isTimedOutSuspense) {
  18983. // Don't count time spent in a timed out Suspense subtree as part of the base duration.
  18984. var primaryChildFragment = completedWork.child;
  18985. if (primaryChildFragment !== null) {
  18986. treeBaseDuration -= primaryChildFragment.treeBaseDuration;
  18987. }
  18988. }
  18989. completedWork.actualDuration = actualDuration;
  18990. completedWork.treeBaseDuration = treeBaseDuration;
  18991. } else {
  18992. var _child = completedWork.child;
  18993. while (_child !== null) {
  18994. newChildLanes = mergeLanes(newChildLanes, mergeLanes(_child.lanes, _child.childLanes));
  18995. _child = _child.sibling;
  18996. }
  18997. }
  18998. completedWork.childLanes = newChildLanes;
  18999. }
  19000. function commitRoot(root) {
  19001. var renderPriorityLevel = getCurrentPriorityLevel();
  19002. runWithPriority$1(ImmediatePriority$1, commitRootImpl.bind(null, root, renderPriorityLevel));
  19003. return null;
  19004. }
  19005. function commitRootImpl(root, renderPriorityLevel) {
  19006. do {
  19007. // `flushPassiveEffects` will call `flushSyncUpdateQueue` at the end, which
  19008. // means `flushPassiveEffects` will sometimes result in additional
  19009. // passive effects. So we need to keep flushing in a loop until there are
  19010. // no more pending effects.
  19011. // TODO: Might be better if `flushPassiveEffects` did not automatically
  19012. // flush synchronous work at the end, to avoid factoring hazards like this.
  19013. flushPassiveEffects();
  19014. } while (rootWithPendingPassiveEffects !== null);
  19015. flushRenderPhaseStrictModeWarningsInDEV();
  19016. if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
  19017. {
  19018. throw Error( "Should not already be working." );
  19019. }
  19020. }
  19021. var finishedWork = root.finishedWork;
  19022. var lanes = root.finishedLanes;
  19023. if (finishedWork === null) {
  19024. return null;
  19025. }
  19026. root.finishedWork = null;
  19027. root.finishedLanes = NoLanes;
  19028. if (!(finishedWork !== root.current)) {
  19029. {
  19030. throw Error( "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." );
  19031. }
  19032. } // commitRoot never returns a continuation; it always finishes synchronously.
  19033. // So we can clear these now to allow a new callback to be scheduled.
  19034. root.callbackNode = null; // Update the first and last pending times on this root. The new first
  19035. // pending time is whatever is left on the root fiber.
  19036. var remainingLanes = mergeLanes(finishedWork.lanes, finishedWork.childLanes);
  19037. markRootFinished(root, remainingLanes); // Clear already finished discrete updates in case that a later call of
  19038. // `flushDiscreteUpdates` starts a useless render pass which may cancels
  19039. // a scheduled timeout.
  19040. if (rootsWithPendingDiscreteUpdates !== null) {
  19041. if (!hasDiscreteLanes(remainingLanes) && rootsWithPendingDiscreteUpdates.has(root)) {
  19042. rootsWithPendingDiscreteUpdates.delete(root);
  19043. }
  19044. }
  19045. if (root === workInProgressRoot) {
  19046. // We can reset these now that they are finished.
  19047. workInProgressRoot = null;
  19048. workInProgress = null;
  19049. workInProgressRootRenderLanes = NoLanes;
  19050. } // Get the list of effects.
  19051. var firstEffect;
  19052. if (finishedWork.flags > PerformedWork) {
  19053. // A fiber's effect list consists only of its children, not itself. So if
  19054. // the root has an effect, we need to add it to the end of the list. The
  19055. // resulting list is the set that would belong to the root's parent, if it
  19056. // had one; that is, all the effects in the tree including the root.
  19057. if (finishedWork.lastEffect !== null) {
  19058. finishedWork.lastEffect.nextEffect = finishedWork;
  19059. firstEffect = finishedWork.firstEffect;
  19060. } else {
  19061. firstEffect = finishedWork;
  19062. }
  19063. } else {
  19064. // There is no effect on the root.
  19065. firstEffect = finishedWork.firstEffect;
  19066. }
  19067. if (firstEffect !== null) {
  19068. var prevExecutionContext = executionContext;
  19069. executionContext |= CommitContext;
  19070. var prevInteractions = pushInteractions(root); // Reset this to null before calling lifecycles
  19071. ReactCurrentOwner$2.current = null; // The commit phase is broken into several sub-phases. We do a separate pass
  19072. // of the effect list for each phase: all mutation effects come before all
  19073. // layout effects, and so on.
  19074. // The first phase a "before mutation" phase. We use this phase to read the
  19075. // state of the host tree right before we mutate it. This is where
  19076. // getSnapshotBeforeUpdate is called.
  19077. focusedInstanceHandle = prepareForCommit(root.containerInfo);
  19078. shouldFireAfterActiveInstanceBlur = false;
  19079. nextEffect = firstEffect;
  19080. do {
  19081. {
  19082. invokeGuardedCallback(null, commitBeforeMutationEffects, null);
  19083. if (hasCaughtError()) {
  19084. if (!(nextEffect !== null)) {
  19085. {
  19086. throw Error( "Should be working on an effect." );
  19087. }
  19088. }
  19089. var error = clearCaughtError();
  19090. captureCommitPhaseError(nextEffect, error);
  19091. nextEffect = nextEffect.nextEffect;
  19092. }
  19093. }
  19094. } while (nextEffect !== null); // We no longer need to track the active instance fiber
  19095. focusedInstanceHandle = null;
  19096. {
  19097. // Mark the current commit time to be shared by all Profilers in this
  19098. // batch. This enables them to be grouped later.
  19099. recordCommitTime();
  19100. } // The next phase is the mutation phase, where we mutate the host tree.
  19101. nextEffect = firstEffect;
  19102. do {
  19103. {
  19104. invokeGuardedCallback(null, commitMutationEffects, null, root, renderPriorityLevel);
  19105. if (hasCaughtError()) {
  19106. if (!(nextEffect !== null)) {
  19107. {
  19108. throw Error( "Should be working on an effect." );
  19109. }
  19110. }
  19111. var _error = clearCaughtError();
  19112. captureCommitPhaseError(nextEffect, _error);
  19113. nextEffect = nextEffect.nextEffect;
  19114. }
  19115. }
  19116. } while (nextEffect !== null);
  19117. resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after
  19118. // the mutation phase, so that the previous tree is still current during
  19119. // componentWillUnmount, but before the layout phase, so that the finished
  19120. // work is current during componentDidMount/Update.
  19121. root.current = finishedWork; // The next phase is the layout phase, where we call effects that read
  19122. // the host tree after it's been mutated. The idiomatic use case for this is
  19123. // layout, but class component lifecycles also fire here for legacy reasons.
  19124. nextEffect = firstEffect;
  19125. do {
  19126. {
  19127. invokeGuardedCallback(null, commitLayoutEffects, null, root, lanes);
  19128. if (hasCaughtError()) {
  19129. if (!(nextEffect !== null)) {
  19130. {
  19131. throw Error( "Should be working on an effect." );
  19132. }
  19133. }
  19134. var _error2 = clearCaughtError();
  19135. captureCommitPhaseError(nextEffect, _error2);
  19136. nextEffect = nextEffect.nextEffect;
  19137. }
  19138. }
  19139. } while (nextEffect !== null);
  19140. nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an
  19141. // opportunity to paint.
  19142. requestPaint();
  19143. {
  19144. popInteractions(prevInteractions);
  19145. }
  19146. executionContext = prevExecutionContext;
  19147. } else {
  19148. // No effects.
  19149. root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were
  19150. // no effects.
  19151. // TODO: Maybe there's a better way to report this.
  19152. {
  19153. recordCommitTime();
  19154. }
  19155. }
  19156. var rootDidHavePassiveEffects = rootDoesHavePassiveEffects;
  19157. if (rootDoesHavePassiveEffects) {
  19158. // This commit has passive effects. Stash a reference to them. But don't
  19159. // schedule a callback until after flushing layout work.
  19160. rootDoesHavePassiveEffects = false;
  19161. rootWithPendingPassiveEffects = root;
  19162. pendingPassiveEffectsLanes = lanes;
  19163. pendingPassiveEffectsRenderPriority = renderPriorityLevel;
  19164. } else {
  19165. // We are done with the effect chain at this point so let's clear the
  19166. // nextEffect pointers to assist with GC. If we have passive effects, we'll
  19167. // clear this in flushPassiveEffects.
  19168. nextEffect = firstEffect;
  19169. while (nextEffect !== null) {
  19170. var nextNextEffect = nextEffect.nextEffect;
  19171. nextEffect.nextEffect = null;
  19172. if (nextEffect.flags & Deletion) {
  19173. detachFiberAfterEffects(nextEffect);
  19174. }
  19175. nextEffect = nextNextEffect;
  19176. }
  19177. } // Read this again, since an effect might have updated it
  19178. remainingLanes = root.pendingLanes; // Check if there's remaining work on this root
  19179. if (remainingLanes !== NoLanes) {
  19180. {
  19181. if (spawnedWorkDuringRender !== null) {
  19182. var expirationTimes = spawnedWorkDuringRender;
  19183. spawnedWorkDuringRender = null;
  19184. for (var i = 0; i < expirationTimes.length; i++) {
  19185. scheduleInteractions(root, expirationTimes[i], root.memoizedInteractions);
  19186. }
  19187. }
  19188. schedulePendingInteractions(root, remainingLanes);
  19189. }
  19190. } else {
  19191. // If there's no remaining work, we can clear the set of already failed
  19192. // error boundaries.
  19193. legacyErrorBoundariesThatAlreadyFailed = null;
  19194. }
  19195. {
  19196. if (!rootDidHavePassiveEffects) {
  19197. // If there are no passive effects, then we can complete the pending interactions.
  19198. // Otherwise, we'll wait until after the passive effects are flushed.
  19199. // Wait to do this until after remaining work has been scheduled,
  19200. // so that we don't prematurely signal complete for interactions when there's e.g. hidden work.
  19201. finishPendingInteractions(root, lanes);
  19202. }
  19203. }
  19204. if (remainingLanes === SyncLane) {
  19205. // Count the number of times the root synchronously re-renders without
  19206. // finishing. If there are too many, it indicates an infinite update loop.
  19207. if (root === rootWithNestedUpdates) {
  19208. nestedUpdateCount++;
  19209. } else {
  19210. nestedUpdateCount = 0;
  19211. rootWithNestedUpdates = root;
  19212. }
  19213. } else {
  19214. nestedUpdateCount = 0;
  19215. }
  19216. onCommitRoot(finishedWork.stateNode, renderPriorityLevel);
  19217. {
  19218. onCommitRoot$1();
  19219. } // Always call this before exiting `commitRoot`, to ensure that any
  19220. // additional work on this root is scheduled.
  19221. ensureRootIsScheduled(root, now());
  19222. if (hasUncaughtError) {
  19223. hasUncaughtError = false;
  19224. var _error3 = firstUncaughtError;
  19225. firstUncaughtError = null;
  19226. throw _error3;
  19227. }
  19228. if ((executionContext & LegacyUnbatchedContext) !== NoContext) {
  19229. // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired
  19230. // synchronously, but layout updates should be deferred until the end
  19231. // of the batch.
  19232. return null;
  19233. } // If layout work was scheduled, flush it now.
  19234. flushSyncCallbackQueue();
  19235. return null;
  19236. }
  19237. function commitBeforeMutationEffects() {
  19238. while (nextEffect !== null) {
  19239. var current = nextEffect.alternate;
  19240. if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) {
  19241. if ((nextEffect.flags & Deletion) !== NoFlags) {
  19242. if (doesFiberContain(nextEffect, focusedInstanceHandle)) {
  19243. shouldFireAfterActiveInstanceBlur = true;
  19244. }
  19245. } else {
  19246. // TODO: Move this out of the hot path using a dedicated effect tag.
  19247. if (nextEffect.tag === SuspenseComponent && isSuspenseBoundaryBeingHidden(current, nextEffect) && doesFiberContain(nextEffect, focusedInstanceHandle)) {
  19248. shouldFireAfterActiveInstanceBlur = true;
  19249. }
  19250. }
  19251. }
  19252. var flags = nextEffect.flags;
  19253. if ((flags & Snapshot) !== NoFlags) {
  19254. setCurrentFiber(nextEffect);
  19255. commitBeforeMutationLifeCycles(current, nextEffect);
  19256. resetCurrentFiber();
  19257. }
  19258. if ((flags & Passive) !== NoFlags) {
  19259. // If there are passive effects, schedule a callback to flush at
  19260. // the earliest opportunity.
  19261. if (!rootDoesHavePassiveEffects) {
  19262. rootDoesHavePassiveEffects = true;
  19263. scheduleCallback(NormalPriority$1, function () {
  19264. flushPassiveEffects();
  19265. return null;
  19266. });
  19267. }
  19268. }
  19269. nextEffect = nextEffect.nextEffect;
  19270. }
  19271. }
  19272. function commitMutationEffects(root, renderPriorityLevel) {
  19273. // TODO: Should probably move the bulk of this function to commitWork.
  19274. while (nextEffect !== null) {
  19275. setCurrentFiber(nextEffect);
  19276. var flags = nextEffect.flags;
  19277. if (flags & ContentReset) {
  19278. commitResetTextContent(nextEffect);
  19279. }
  19280. if (flags & Ref) {
  19281. var current = nextEffect.alternate;
  19282. if (current !== null) {
  19283. commitDetachRef(current);
  19284. }
  19285. } // The following switch statement is only concerned about placement,
  19286. // updates, and deletions. To avoid needing to add a case for every possible
  19287. // bitmap value, we remove the secondary effects from the effect tag and
  19288. // switch on that value.
  19289. var primaryFlags = flags & (Placement | Update | Deletion | Hydrating);
  19290. switch (primaryFlags) {
  19291. case Placement:
  19292. {
  19293. commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is
  19294. // inserted, before any life-cycles like componentDidMount gets called.
  19295. // TODO: findDOMNode doesn't rely on this any more but isMounted does
  19296. // and isMounted is deprecated anyway so we should be able to kill this.
  19297. nextEffect.flags &= ~Placement;
  19298. break;
  19299. }
  19300. case PlacementAndUpdate:
  19301. {
  19302. // Placement
  19303. commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is
  19304. // inserted, before any life-cycles like componentDidMount gets called.
  19305. nextEffect.flags &= ~Placement; // Update
  19306. var _current = nextEffect.alternate;
  19307. commitWork(_current, nextEffect);
  19308. break;
  19309. }
  19310. case Hydrating:
  19311. {
  19312. nextEffect.flags &= ~Hydrating;
  19313. break;
  19314. }
  19315. case HydratingAndUpdate:
  19316. {
  19317. nextEffect.flags &= ~Hydrating; // Update
  19318. var _current2 = nextEffect.alternate;
  19319. commitWork(_current2, nextEffect);
  19320. break;
  19321. }
  19322. case Update:
  19323. {
  19324. var _current3 = nextEffect.alternate;
  19325. commitWork(_current3, nextEffect);
  19326. break;
  19327. }
  19328. case Deletion:
  19329. {
  19330. commitDeletion(root, nextEffect);
  19331. break;
  19332. }
  19333. }
  19334. resetCurrentFiber();
  19335. nextEffect = nextEffect.nextEffect;
  19336. }
  19337. }
  19338. function commitLayoutEffects(root, committedLanes) {
  19339. while (nextEffect !== null) {
  19340. setCurrentFiber(nextEffect);
  19341. var flags = nextEffect.flags;
  19342. if (flags & (Update | Callback)) {
  19343. var current = nextEffect.alternate;
  19344. commitLifeCycles(root, current, nextEffect);
  19345. }
  19346. {
  19347. if (flags & Ref) {
  19348. commitAttachRef(nextEffect);
  19349. }
  19350. }
  19351. resetCurrentFiber();
  19352. nextEffect = nextEffect.nextEffect;
  19353. }
  19354. }
  19355. function flushPassiveEffects() {
  19356. // Returns whether passive effects were flushed.
  19357. if (pendingPassiveEffectsRenderPriority !== NoPriority$1) {
  19358. var priorityLevel = pendingPassiveEffectsRenderPriority > NormalPriority$1 ? NormalPriority$1 : pendingPassiveEffectsRenderPriority;
  19359. pendingPassiveEffectsRenderPriority = NoPriority$1;
  19360. {
  19361. return runWithPriority$1(priorityLevel, flushPassiveEffectsImpl);
  19362. }
  19363. }
  19364. return false;
  19365. }
  19366. function enqueuePendingPassiveHookEffectMount(fiber, effect) {
  19367. pendingPassiveHookEffectsMount.push(effect, fiber);
  19368. if (!rootDoesHavePassiveEffects) {
  19369. rootDoesHavePassiveEffects = true;
  19370. scheduleCallback(NormalPriority$1, function () {
  19371. flushPassiveEffects();
  19372. return null;
  19373. });
  19374. }
  19375. }
  19376. function enqueuePendingPassiveHookEffectUnmount(fiber, effect) {
  19377. pendingPassiveHookEffectsUnmount.push(effect, fiber);
  19378. {
  19379. fiber.flags |= PassiveUnmountPendingDev;
  19380. var alternate = fiber.alternate;
  19381. if (alternate !== null) {
  19382. alternate.flags |= PassiveUnmountPendingDev;
  19383. }
  19384. }
  19385. if (!rootDoesHavePassiveEffects) {
  19386. rootDoesHavePassiveEffects = true;
  19387. scheduleCallback(NormalPriority$1, function () {
  19388. flushPassiveEffects();
  19389. return null;
  19390. });
  19391. }
  19392. }
  19393. function invokePassiveEffectCreate(effect) {
  19394. var create = effect.create;
  19395. effect.destroy = create();
  19396. }
  19397. function flushPassiveEffectsImpl() {
  19398. if (rootWithPendingPassiveEffects === null) {
  19399. return false;
  19400. }
  19401. var root = rootWithPendingPassiveEffects;
  19402. var lanes = pendingPassiveEffectsLanes;
  19403. rootWithPendingPassiveEffects = null;
  19404. pendingPassiveEffectsLanes = NoLanes;
  19405. if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
  19406. {
  19407. throw Error( "Cannot flush passive effects while already rendering." );
  19408. }
  19409. }
  19410. {
  19411. isFlushingPassiveEffects = true;
  19412. }
  19413. var prevExecutionContext = executionContext;
  19414. executionContext |= CommitContext;
  19415. var prevInteractions = pushInteractions(root); // It's important that ALL pending passive effect destroy functions are called
  19416. // before ANY passive effect create functions are called.
  19417. // Otherwise effects in sibling components might interfere with each other.
  19418. // e.g. a destroy function in one component may unintentionally override a ref
  19419. // value set by a create function in another component.
  19420. // Layout effects have the same constraint.
  19421. // First pass: Destroy stale passive effects.
  19422. var unmountEffects = pendingPassiveHookEffectsUnmount;
  19423. pendingPassiveHookEffectsUnmount = [];
  19424. for (var i = 0; i < unmountEffects.length; i += 2) {
  19425. var _effect = unmountEffects[i];
  19426. var fiber = unmountEffects[i + 1];
  19427. var destroy = _effect.destroy;
  19428. _effect.destroy = undefined;
  19429. {
  19430. fiber.flags &= ~PassiveUnmountPendingDev;
  19431. var alternate = fiber.alternate;
  19432. if (alternate !== null) {
  19433. alternate.flags &= ~PassiveUnmountPendingDev;
  19434. }
  19435. }
  19436. if (typeof destroy === 'function') {
  19437. {
  19438. setCurrentFiber(fiber);
  19439. {
  19440. invokeGuardedCallback(null, destroy, null);
  19441. }
  19442. if (hasCaughtError()) {
  19443. if (!(fiber !== null)) {
  19444. {
  19445. throw Error( "Should be working on an effect." );
  19446. }
  19447. }
  19448. var error = clearCaughtError();
  19449. captureCommitPhaseError(fiber, error);
  19450. }
  19451. resetCurrentFiber();
  19452. }
  19453. }
  19454. } // Second pass: Create new passive effects.
  19455. var mountEffects = pendingPassiveHookEffectsMount;
  19456. pendingPassiveHookEffectsMount = [];
  19457. for (var _i = 0; _i < mountEffects.length; _i += 2) {
  19458. var _effect2 = mountEffects[_i];
  19459. var _fiber = mountEffects[_i + 1];
  19460. {
  19461. setCurrentFiber(_fiber);
  19462. {
  19463. invokeGuardedCallback(null, invokePassiveEffectCreate, null, _effect2);
  19464. }
  19465. if (hasCaughtError()) {
  19466. if (!(_fiber !== null)) {
  19467. {
  19468. throw Error( "Should be working on an effect." );
  19469. }
  19470. }
  19471. var _error4 = clearCaughtError();
  19472. captureCommitPhaseError(_fiber, _error4);
  19473. }
  19474. resetCurrentFiber();
  19475. }
  19476. } // Note: This currently assumes there are no passive effects on the root fiber
  19477. // because the root is not part of its own effect list.
  19478. // This could change in the future.
  19479. var effect = root.current.firstEffect;
  19480. while (effect !== null) {
  19481. var nextNextEffect = effect.nextEffect; // Remove nextEffect pointer to assist GC
  19482. effect.nextEffect = null;
  19483. if (effect.flags & Deletion) {
  19484. detachFiberAfterEffects(effect);
  19485. }
  19486. effect = nextNextEffect;
  19487. }
  19488. {
  19489. popInteractions(prevInteractions);
  19490. finishPendingInteractions(root, lanes);
  19491. }
  19492. {
  19493. isFlushingPassiveEffects = false;
  19494. }
  19495. executionContext = prevExecutionContext;
  19496. flushSyncCallbackQueue(); // If additional passive effects were scheduled, increment a counter. If this
  19497. // exceeds the limit, we'll fire a warning.
  19498. nestedPassiveUpdateCount = rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1;
  19499. return true;
  19500. }
  19501. function isAlreadyFailedLegacyErrorBoundary(instance) {
  19502. return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance);
  19503. }
  19504. function markLegacyErrorBoundaryAsFailed(instance) {
  19505. if (legacyErrorBoundariesThatAlreadyFailed === null) {
  19506. legacyErrorBoundariesThatAlreadyFailed = new Set([instance]);
  19507. } else {
  19508. legacyErrorBoundariesThatAlreadyFailed.add(instance);
  19509. }
  19510. }
  19511. function prepareToThrowUncaughtError(error) {
  19512. if (!hasUncaughtError) {
  19513. hasUncaughtError = true;
  19514. firstUncaughtError = error;
  19515. }
  19516. }
  19517. var onUncaughtError = prepareToThrowUncaughtError;
  19518. function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) {
  19519. var errorInfo = createCapturedValue(error, sourceFiber);
  19520. var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane);
  19521. enqueueUpdate(rootFiber, update);
  19522. var eventTime = requestEventTime();
  19523. var root = markUpdateLaneFromFiberToRoot(rootFiber, SyncLane);
  19524. if (root !== null) {
  19525. markRootUpdated(root, SyncLane, eventTime);
  19526. ensureRootIsScheduled(root, eventTime);
  19527. schedulePendingInteractions(root, SyncLane);
  19528. }
  19529. }
  19530. function captureCommitPhaseError(sourceFiber, error) {
  19531. if (sourceFiber.tag === HostRoot) {
  19532. // Error was thrown at the root. There is no parent, so the root
  19533. // itself should capture it.
  19534. captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error);
  19535. return;
  19536. }
  19537. var fiber = sourceFiber.return;
  19538. while (fiber !== null) {
  19539. if (fiber.tag === HostRoot) {
  19540. captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error);
  19541. return;
  19542. } else if (fiber.tag === ClassComponent) {
  19543. var ctor = fiber.type;
  19544. var instance = fiber.stateNode;
  19545. if (typeof ctor.getDerivedStateFromError === 'function' || typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) {
  19546. var errorInfo = createCapturedValue(error, sourceFiber);
  19547. var update = createClassErrorUpdate(fiber, errorInfo, SyncLane);
  19548. enqueueUpdate(fiber, update);
  19549. var eventTime = requestEventTime();
  19550. var root = markUpdateLaneFromFiberToRoot(fiber, SyncLane);
  19551. if (root !== null) {
  19552. markRootUpdated(root, SyncLane, eventTime);
  19553. ensureRootIsScheduled(root, eventTime);
  19554. schedulePendingInteractions(root, SyncLane);
  19555. } else {
  19556. // This component has already been unmounted.
  19557. // We can't schedule any follow up work for the root because the fiber is already unmounted,
  19558. // but we can still call the log-only boundary so the error isn't swallowed.
  19559. //
  19560. // TODO This is only a temporary bandaid for the old reconciler fork.
  19561. // We can delete this special case once the new fork is merged.
  19562. if (typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance)) {
  19563. try {
  19564. instance.componentDidCatch(error, errorInfo);
  19565. } catch (errorToIgnore) {// TODO Ignore this error? Rethrow it?
  19566. // This is kind of an edge case.
  19567. }
  19568. }
  19569. }
  19570. return;
  19571. }
  19572. }
  19573. fiber = fiber.return;
  19574. }
  19575. }
  19576. function pingSuspendedRoot(root, wakeable, pingedLanes) {
  19577. var pingCache = root.pingCache;
  19578. if (pingCache !== null) {
  19579. // The wakeable resolved, so we no longer need to memoize, because it will
  19580. // never be thrown again.
  19581. pingCache.delete(wakeable);
  19582. }
  19583. var eventTime = requestEventTime();
  19584. markRootPinged(root, pingedLanes);
  19585. if (workInProgressRoot === root && isSubsetOfLanes(workInProgressRootRenderLanes, pingedLanes)) {
  19586. // Received a ping at the same priority level at which we're currently
  19587. // rendering. We might want to restart this render. This should mirror
  19588. // the logic of whether or not a root suspends once it completes.
  19589. // TODO: If we're rendering sync either due to Sync, Batched or expired,
  19590. // we should probably never restart.
  19591. // If we're suspended with delay, or if it's a retry, we'll always suspend
  19592. // so we can always restart.
  19593. if (workInProgressRootExitStatus === RootSuspendedWithDelay || workInProgressRootExitStatus === RootSuspended && includesOnlyRetries(workInProgressRootRenderLanes) && now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) {
  19594. // Restart from the root.
  19595. prepareFreshStack(root, NoLanes);
  19596. } else {
  19597. // Even though we can't restart right now, we might get an
  19598. // opportunity later. So we mark this render as having a ping.
  19599. workInProgressRootPingedLanes = mergeLanes(workInProgressRootPingedLanes, pingedLanes);
  19600. }
  19601. }
  19602. ensureRootIsScheduled(root, eventTime);
  19603. schedulePendingInteractions(root, pingedLanes);
  19604. }
  19605. function retryTimedOutBoundary(boundaryFiber, retryLane) {
  19606. // The boundary fiber (a Suspense component or SuspenseList component)
  19607. // previously was rendered in its fallback state. One of the promises that
  19608. // suspended it has resolved, which means at least part of the tree was
  19609. // likely unblocked. Try rendering again, at a new expiration time.
  19610. if (retryLane === NoLane) {
  19611. retryLane = requestRetryLane(boundaryFiber);
  19612. } // TODO: Special case idle priority?
  19613. var eventTime = requestEventTime();
  19614. var root = markUpdateLaneFromFiberToRoot(boundaryFiber, retryLane);
  19615. if (root !== null) {
  19616. markRootUpdated(root, retryLane, eventTime);
  19617. ensureRootIsScheduled(root, eventTime);
  19618. schedulePendingInteractions(root, retryLane);
  19619. }
  19620. }
  19621. function resolveRetryWakeable(boundaryFiber, wakeable) {
  19622. var retryLane = NoLane; // Default
  19623. var retryCache;
  19624. {
  19625. retryCache = boundaryFiber.stateNode;
  19626. }
  19627. if (retryCache !== null) {
  19628. // The wakeable resolved, so we no longer need to memoize, because it will
  19629. // never be thrown again.
  19630. retryCache.delete(wakeable);
  19631. }
  19632. retryTimedOutBoundary(boundaryFiber, retryLane);
  19633. } // Computes the next Just Noticeable Difference (JND) boundary.
  19634. // The theory is that a person can't tell the difference between small differences in time.
  19635. // Therefore, if we wait a bit longer than necessary that won't translate to a noticeable
  19636. // difference in the experience. However, waiting for longer might mean that we can avoid
  19637. // showing an intermediate loading state. The longer we have already waited, the harder it
  19638. // is to tell small differences in time. Therefore, the longer we've already waited,
  19639. // the longer we can wait additionally. At some point we have to give up though.
  19640. // We pick a train model where the next boundary commits at a consistent schedule.
  19641. // These particular numbers are vague estimates. We expect to adjust them based on research.
  19642. function jnd(timeElapsed) {
  19643. return timeElapsed < 120 ? 120 : timeElapsed < 480 ? 480 : timeElapsed < 1080 ? 1080 : timeElapsed < 1920 ? 1920 : timeElapsed < 3000 ? 3000 : timeElapsed < 4320 ? 4320 : ceil(timeElapsed / 1960) * 1960;
  19644. }
  19645. function checkForNestedUpdates() {
  19646. if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
  19647. nestedUpdateCount = 0;
  19648. rootWithNestedUpdates = null;
  19649. {
  19650. {
  19651. throw Error( "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." );
  19652. }
  19653. }
  19654. }
  19655. {
  19656. if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) {
  19657. nestedPassiveUpdateCount = 0;
  19658. error('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.');
  19659. }
  19660. }
  19661. }
  19662. function flushRenderPhaseStrictModeWarningsInDEV() {
  19663. {
  19664. ReactStrictModeWarnings.flushLegacyContextWarning();
  19665. {
  19666. ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
  19667. }
  19668. }
  19669. }
  19670. var didWarnStateUpdateForNotYetMountedComponent = null;
  19671. function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) {
  19672. {
  19673. if ((executionContext & RenderContext) !== NoContext) {
  19674. // We let the other warning about render phase updates deal with this one.
  19675. return;
  19676. }
  19677. if (!(fiber.mode & (BlockingMode | ConcurrentMode))) {
  19678. return;
  19679. }
  19680. var tag = fiber.tag;
  19681. if (tag !== IndeterminateComponent && tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent && tag !== Block) {
  19682. // Only warn for user-defined components, not internal ones like Suspense.
  19683. return;
  19684. } // We show the whole stack but dedupe on the top component's name because
  19685. // the problematic code almost always lies inside that component.
  19686. var componentName = getComponentName(fiber.type) || 'ReactComponent';
  19687. if (didWarnStateUpdateForNotYetMountedComponent !== null) {
  19688. if (didWarnStateUpdateForNotYetMountedComponent.has(componentName)) {
  19689. return;
  19690. }
  19691. didWarnStateUpdateForNotYetMountedComponent.add(componentName);
  19692. } else {
  19693. didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]);
  19694. }
  19695. var previousFiber = current;
  19696. try {
  19697. setCurrentFiber(fiber);
  19698. error("Can't perform a React state update on a component that hasn't mounted yet. " + 'This indicates that you have a side-effect in your render function that ' + 'asynchronously later calls tries to update the component. Move this work to ' + 'useEffect instead.');
  19699. } finally {
  19700. if (previousFiber) {
  19701. setCurrentFiber(fiber);
  19702. } else {
  19703. resetCurrentFiber();
  19704. }
  19705. }
  19706. }
  19707. }
  19708. var didWarnStateUpdateForUnmountedComponent = null;
  19709. function warnAboutUpdateOnUnmountedFiberInDEV(fiber) {
  19710. {
  19711. var tag = fiber.tag;
  19712. if (tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent && tag !== Block) {
  19713. // Only warn for user-defined components, not internal ones like Suspense.
  19714. return;
  19715. } // If there are pending passive effects unmounts for this Fiber,
  19716. // we can assume that they would have prevented this update.
  19717. if ((fiber.flags & PassiveUnmountPendingDev) !== NoFlags) {
  19718. return;
  19719. } // We show the whole stack but dedupe on the top component's name because
  19720. // the problematic code almost always lies inside that component.
  19721. var componentName = getComponentName(fiber.type) || 'ReactComponent';
  19722. if (didWarnStateUpdateForUnmountedComponent !== null) {
  19723. if (didWarnStateUpdateForUnmountedComponent.has(componentName)) {
  19724. return;
  19725. }
  19726. didWarnStateUpdateForUnmountedComponent.add(componentName);
  19727. } else {
  19728. didWarnStateUpdateForUnmountedComponent = new Set([componentName]);
  19729. }
  19730. if (isFlushingPassiveEffects) ; else {
  19731. var previousFiber = current;
  19732. try {
  19733. setCurrentFiber(fiber);
  19734. error("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.', tag === ClassComponent ? 'the componentWillUnmount method' : 'a useEffect cleanup function');
  19735. } finally {
  19736. if (previousFiber) {
  19737. setCurrentFiber(fiber);
  19738. } else {
  19739. resetCurrentFiber();
  19740. }
  19741. }
  19742. }
  19743. }
  19744. }
  19745. var beginWork$1;
  19746. {
  19747. var dummyFiber = null;
  19748. beginWork$1 = function (current, unitOfWork, lanes) {
  19749. // If a component throws an error, we replay it again in a synchronously
  19750. // dispatched event, so that the debugger will treat it as an uncaught
  19751. // error See ReactErrorUtils for more information.
  19752. // Before entering the begin phase, copy the work-in-progress onto a dummy
  19753. // fiber. If beginWork throws, we'll use this to reset the state.
  19754. var originalWorkInProgressCopy = assignFiberPropertiesInDEV(dummyFiber, unitOfWork);
  19755. try {
  19756. return beginWork(current, unitOfWork, lanes);
  19757. } catch (originalError) {
  19758. if (originalError !== null && typeof originalError === 'object' && typeof originalError.then === 'function') {
  19759. // Don't replay promises. Treat everything else like an error.
  19760. throw originalError;
  19761. } // Keep this code in sync with handleError; any changes here must have
  19762. // corresponding changes there.
  19763. resetContextDependencies();
  19764. resetHooksAfterThrow(); // Don't reset current debug fiber, since we're about to work on the
  19765. // same fiber again.
  19766. // Unwind the failed stack frame
  19767. unwindInterruptedWork(unitOfWork); // Restore the original properties of the fiber.
  19768. assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy);
  19769. if ( unitOfWork.mode & ProfileMode) {
  19770. // Reset the profiler timer.
  19771. startProfilerTimer(unitOfWork);
  19772. } // Run beginWork again.
  19773. invokeGuardedCallback(null, beginWork, null, current, unitOfWork, lanes);
  19774. if (hasCaughtError()) {
  19775. var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`.
  19776. // Rethrow this error instead of the original one.
  19777. throw replayError;
  19778. } else {
  19779. // This branch is reachable if the render phase is impure.
  19780. throw originalError;
  19781. }
  19782. }
  19783. };
  19784. }
  19785. var didWarnAboutUpdateInRender = false;
  19786. var didWarnAboutUpdateInRenderForAnotherComponent;
  19787. {
  19788. didWarnAboutUpdateInRenderForAnotherComponent = new Set();
  19789. }
  19790. function warnAboutRenderPhaseUpdatesInDEV(fiber) {
  19791. {
  19792. if (isRendering && (executionContext & RenderContext) !== NoContext && !getIsUpdatingOpaqueValueInRenderPhaseInDEV()) {
  19793. switch (fiber.tag) {
  19794. case FunctionComponent:
  19795. case ForwardRef:
  19796. case SimpleMemoComponent:
  19797. {
  19798. var renderingComponentName = workInProgress && getComponentName(workInProgress.type) || 'Unknown'; // Dedupe by the rendering component because it's the one that needs to be fixed.
  19799. var dedupeKey = renderingComponentName;
  19800. if (!didWarnAboutUpdateInRenderForAnotherComponent.has(dedupeKey)) {
  19801. didWarnAboutUpdateInRenderForAnotherComponent.add(dedupeKey);
  19802. var setStateComponentName = getComponentName(fiber.type) || 'Unknown';
  19803. error('Cannot update a component (`%s`) while rendering a ' + 'different component (`%s`). To locate the bad setState() call inside `%s`, ' + 'follow the stack trace as described in https://reactjs.org/link/setstate-in-render', setStateComponentName, renderingComponentName, renderingComponentName);
  19804. }
  19805. break;
  19806. }
  19807. case ClassComponent:
  19808. {
  19809. if (!didWarnAboutUpdateInRender) {
  19810. error('Cannot update during an existing state transition (such as ' + 'within `render`). Render methods should be a pure ' + 'function of props and state.');
  19811. didWarnAboutUpdateInRender = true;
  19812. }
  19813. break;
  19814. }
  19815. }
  19816. }
  19817. }
  19818. } // a 'shared' variable that changes when act() opens/closes in tests.
  19819. var IsThisRendererActing = {
  19820. current: false
  19821. };
  19822. function warnIfNotScopedWithMatchingAct(fiber) {
  19823. {
  19824. if ( IsSomeRendererActing.current === true && IsThisRendererActing.current !== true) {
  19825. var previousFiber = current;
  19826. try {
  19827. setCurrentFiber(fiber);
  19828. error("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' + // Break up imports to avoid accidentally parsing them as dependencies.
  19829. 'import {act} fr' + "om 'react-dom/test-utils';\n" + '// ...\n' + 'act(() => ...);\n\n' + '// for react-test-renderer:\n' + // Break up imports to avoid accidentally parsing them as dependencies.
  19830. 'import TestRenderer fr' + "om react-test-renderer';\n" + 'const {act} = TestRenderer;\n' + '// ...\n' + 'act(() => ...);');
  19831. } finally {
  19832. if (previousFiber) {
  19833. setCurrentFiber(fiber);
  19834. } else {
  19835. resetCurrentFiber();
  19836. }
  19837. }
  19838. }
  19839. }
  19840. }
  19841. function warnIfNotCurrentlyActingEffectsInDEV(fiber) {
  19842. {
  19843. if ( (fiber.mode & StrictMode) !== NoMode && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
  19844. error('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://reactjs.org/link/wrap-tests-with-act', getComponentName(fiber.type));
  19845. }
  19846. }
  19847. }
  19848. function warnIfNotCurrentlyActingUpdatesInDEV(fiber) {
  19849. {
  19850. if ( executionContext === NoContext && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
  19851. var previousFiber = current;
  19852. try {
  19853. setCurrentFiber(fiber);
  19854. error('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://reactjs.org/link/wrap-tests-with-act', getComponentName(fiber.type));
  19855. } finally {
  19856. if (previousFiber) {
  19857. setCurrentFiber(fiber);
  19858. } else {
  19859. resetCurrentFiber();
  19860. }
  19861. }
  19862. }
  19863. }
  19864. }
  19865. var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV; // In tests, we want to enforce a mocked scheduler.
  19866. var didWarnAboutUnmockedScheduler = false; // TODO Before we release concurrent mode, revisit this and decide whether a mocked
  19867. // scheduler is the actual recommendation. The alternative could be a testing build,
  19868. // a new lib, or whatever; we dunno just yet. This message is for early adopters
  19869. // to get their tests right.
  19870. function warnIfUnmockedScheduler(fiber) {
  19871. {
  19872. if (didWarnAboutUnmockedScheduler === false && Scheduler.unstable_flushAllWithoutAsserting === undefined) {
  19873. if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) {
  19874. didWarnAboutUnmockedScheduler = true;
  19875. error('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' + // Break up requires to avoid accidentally parsing them as dependencies.
  19876. "jest.mock('scheduler', () => require" + "('scheduler/unstable_mock'));\n\n" + 'For more info, visit https://reactjs.org/link/mock-scheduler');
  19877. }
  19878. }
  19879. }
  19880. }
  19881. function computeThreadID(root, lane) {
  19882. // Interaction threads are unique per root and expiration time.
  19883. // NOTE: Intentionally unsound cast. All that matters is that it's a number
  19884. // and it represents a batch of work. Could make a helper function instead,
  19885. // but meh this is fine for now.
  19886. return lane * 1000 + root.interactionThreadID;
  19887. }
  19888. function markSpawnedWork(lane) {
  19889. if (spawnedWorkDuringRender === null) {
  19890. spawnedWorkDuringRender = [lane];
  19891. } else {
  19892. spawnedWorkDuringRender.push(lane);
  19893. }
  19894. }
  19895. function scheduleInteractions(root, lane, interactions) {
  19896. if (interactions.size > 0) {
  19897. var pendingInteractionMap = root.pendingInteractionMap;
  19898. var pendingInteractions = pendingInteractionMap.get(lane);
  19899. if (pendingInteractions != null) {
  19900. interactions.forEach(function (interaction) {
  19901. if (!pendingInteractions.has(interaction)) {
  19902. // Update the pending async work count for previously unscheduled interaction.
  19903. interaction.__count++;
  19904. }
  19905. pendingInteractions.add(interaction);
  19906. });
  19907. } else {
  19908. pendingInteractionMap.set(lane, new Set(interactions)); // Update the pending async work count for the current interactions.
  19909. interactions.forEach(function (interaction) {
  19910. interaction.__count++;
  19911. });
  19912. }
  19913. var subscriber = tracing.__subscriberRef.current;
  19914. if (subscriber !== null) {
  19915. var threadID = computeThreadID(root, lane);
  19916. subscriber.onWorkScheduled(interactions, threadID);
  19917. }
  19918. }
  19919. }
  19920. function schedulePendingInteractions(root, lane) {
  19921. scheduleInteractions(root, lane, tracing.__interactionsRef.current);
  19922. }
  19923. function startWorkOnPendingInteractions(root, lanes) {
  19924. // we can accurately attribute time spent working on it, And so that cascading
  19925. // work triggered during the render phase will be associated with it.
  19926. var interactions = new Set();
  19927. root.pendingInteractionMap.forEach(function (scheduledInteractions, scheduledLane) {
  19928. if (includesSomeLane(lanes, scheduledLane)) {
  19929. scheduledInteractions.forEach(function (interaction) {
  19930. return interactions.add(interaction);
  19931. });
  19932. }
  19933. }); // Store the current set of interactions on the FiberRoot for a few reasons:
  19934. // We can re-use it in hot functions like performConcurrentWorkOnRoot()
  19935. // without having to recalculate it. We will also use it in commitWork() to
  19936. // pass to any Profiler onRender() hooks. This also provides DevTools with a
  19937. // way to access it when the onCommitRoot() hook is called.
  19938. root.memoizedInteractions = interactions;
  19939. if (interactions.size > 0) {
  19940. var subscriber = tracing.__subscriberRef.current;
  19941. if (subscriber !== null) {
  19942. var threadID = computeThreadID(root, lanes);
  19943. try {
  19944. subscriber.onWorkStarted(interactions, threadID);
  19945. } catch (error) {
  19946. // If the subscriber throws, rethrow it in a separate task
  19947. scheduleCallback(ImmediatePriority$1, function () {
  19948. throw error;
  19949. });
  19950. }
  19951. }
  19952. }
  19953. }
  19954. function finishPendingInteractions(root, committedLanes) {
  19955. var remainingLanesAfterCommit = root.pendingLanes;
  19956. var subscriber;
  19957. try {
  19958. subscriber = tracing.__subscriberRef.current;
  19959. if (subscriber !== null && root.memoizedInteractions.size > 0) {
  19960. // FIXME: More than one lane can finish in a single commit.
  19961. var threadID = computeThreadID(root, committedLanes);
  19962. subscriber.onWorkStopped(root.memoizedInteractions, threadID);
  19963. }
  19964. } catch (error) {
  19965. // If the subscriber throws, rethrow it in a separate task
  19966. scheduleCallback(ImmediatePriority$1, function () {
  19967. throw error;
  19968. });
  19969. } finally {
  19970. // Clear completed interactions from the pending Map.
  19971. // Unless the render was suspended or cascading work was scheduled,
  19972. // In which case– leave pending interactions until the subsequent render.
  19973. var pendingInteractionMap = root.pendingInteractionMap;
  19974. pendingInteractionMap.forEach(function (scheduledInteractions, lane) {
  19975. // Only decrement the pending interaction count if we're done.
  19976. // If there's still work at the current priority,
  19977. // That indicates that we are waiting for suspense data.
  19978. if (!includesSomeLane(remainingLanesAfterCommit, lane)) {
  19979. pendingInteractionMap.delete(lane);
  19980. scheduledInteractions.forEach(function (interaction) {
  19981. interaction.__count--;
  19982. if (subscriber !== null && interaction.__count === 0) {
  19983. try {
  19984. subscriber.onInteractionScheduledWorkCompleted(interaction);
  19985. } catch (error) {
  19986. // If the subscriber throws, rethrow it in a separate task
  19987. scheduleCallback(ImmediatePriority$1, function () {
  19988. throw error;
  19989. });
  19990. }
  19991. }
  19992. });
  19993. }
  19994. });
  19995. }
  19996. } // `act` testing API
  19997. function shouldForceFlushFallbacksInDEV() {
  19998. // Never force flush in production. This function should get stripped out.
  19999. return actingUpdatesScopeDepth > 0;
  20000. }
  20001. // so we can tell if any async act() calls try to run in parallel.
  20002. var actingUpdatesScopeDepth = 0;
  20003. function detachFiberAfterEffects(fiber) {
  20004. fiber.sibling = null;
  20005. fiber.stateNode = null;
  20006. }
  20007. var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below.
  20008. var failedBoundaries = null;
  20009. var setRefreshHandler = function (handler) {
  20010. {
  20011. resolveFamily = handler;
  20012. }
  20013. };
  20014. function resolveFunctionForHotReloading(type) {
  20015. {
  20016. if (resolveFamily === null) {
  20017. // Hot reloading is disabled.
  20018. return type;
  20019. }
  20020. var family = resolveFamily(type);
  20021. if (family === undefined) {
  20022. return type;
  20023. } // Use the latest known implementation.
  20024. return family.current;
  20025. }
  20026. }
  20027. function resolveClassForHotReloading(type) {
  20028. // No implementation differences.
  20029. return resolveFunctionForHotReloading(type);
  20030. }
  20031. function resolveForwardRefForHotReloading(type) {
  20032. {
  20033. if (resolveFamily === null) {
  20034. // Hot reloading is disabled.
  20035. return type;
  20036. }
  20037. var family = resolveFamily(type);
  20038. if (family === undefined) {
  20039. // Check if we're dealing with a real forwardRef. Don't want to crash early.
  20040. if (type !== null && type !== undefined && typeof type.render === 'function') {
  20041. // ForwardRef is special because its resolved .type is an object,
  20042. // but it's possible that we only have its inner render function in the map.
  20043. // If that inner render function is different, we'll build a new forwardRef type.
  20044. var currentRender = resolveFunctionForHotReloading(type.render);
  20045. if (type.render !== currentRender) {
  20046. var syntheticType = {
  20047. $$typeof: REACT_FORWARD_REF_TYPE,
  20048. render: currentRender
  20049. };
  20050. if (type.displayName !== undefined) {
  20051. syntheticType.displayName = type.displayName;
  20052. }
  20053. return syntheticType;
  20054. }
  20055. }
  20056. return type;
  20057. } // Use the latest known implementation.
  20058. return family.current;
  20059. }
  20060. }
  20061. function isCompatibleFamilyForHotReloading(fiber, element) {
  20062. {
  20063. if (resolveFamily === null) {
  20064. // Hot reloading is disabled.
  20065. return false;
  20066. }
  20067. var prevType = fiber.elementType;
  20068. var nextType = element.type; // If we got here, we know types aren't === equal.
  20069. var needsCompareFamilies = false;
  20070. var $$typeofNextType = typeof nextType === 'object' && nextType !== null ? nextType.$$typeof : null;
  20071. switch (fiber.tag) {
  20072. case ClassComponent:
  20073. {
  20074. if (typeof nextType === 'function') {
  20075. needsCompareFamilies = true;
  20076. }
  20077. break;
  20078. }
  20079. case FunctionComponent:
  20080. {
  20081. if (typeof nextType === 'function') {
  20082. needsCompareFamilies = true;
  20083. } else if ($$typeofNextType === REACT_LAZY_TYPE) {
  20084. // We don't know the inner type yet.
  20085. // We're going to assume that the lazy inner type is stable,
  20086. // and so it is sufficient to avoid reconciling it away.
  20087. // We're not going to unwrap or actually use the new lazy type.
  20088. needsCompareFamilies = true;
  20089. }
  20090. break;
  20091. }
  20092. case ForwardRef:
  20093. {
  20094. if ($$typeofNextType === REACT_FORWARD_REF_TYPE) {
  20095. needsCompareFamilies = true;
  20096. } else if ($$typeofNextType === REACT_LAZY_TYPE) {
  20097. needsCompareFamilies = true;
  20098. }
  20099. break;
  20100. }
  20101. case MemoComponent:
  20102. case SimpleMemoComponent:
  20103. {
  20104. if ($$typeofNextType === REACT_MEMO_TYPE) {
  20105. // TODO: if it was but can no longer be simple,
  20106. // we shouldn't set this.
  20107. needsCompareFamilies = true;
  20108. } else if ($$typeofNextType === REACT_LAZY_TYPE) {
  20109. needsCompareFamilies = true;
  20110. }
  20111. break;
  20112. }
  20113. default:
  20114. return false;
  20115. } // Check if both types have a family and it's the same one.
  20116. if (needsCompareFamilies) {
  20117. // Note: memo() and forwardRef() we'll compare outer rather than inner type.
  20118. // This means both of them need to be registered to preserve state.
  20119. // If we unwrapped and compared the inner types for wrappers instead,
  20120. // then we would risk falsely saying two separate memo(Foo)
  20121. // calls are equivalent because they wrap the same Foo function.
  20122. var prevFamily = resolveFamily(prevType);
  20123. if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) {
  20124. return true;
  20125. }
  20126. }
  20127. return false;
  20128. }
  20129. }
  20130. function markFailedErrorBoundaryForHotReloading(fiber) {
  20131. {
  20132. if (resolveFamily === null) {
  20133. // Hot reloading is disabled.
  20134. return;
  20135. }
  20136. if (typeof WeakSet !== 'function') {
  20137. return;
  20138. }
  20139. if (failedBoundaries === null) {
  20140. failedBoundaries = new WeakSet();
  20141. }
  20142. failedBoundaries.add(fiber);
  20143. }
  20144. }
  20145. var scheduleRefresh = function (root, update) {
  20146. {
  20147. if (resolveFamily === null) {
  20148. // Hot reloading is disabled.
  20149. return;
  20150. }
  20151. var staleFamilies = update.staleFamilies,
  20152. updatedFamilies = update.updatedFamilies;
  20153. flushPassiveEffects();
  20154. flushSync(function () {
  20155. scheduleFibersWithFamiliesRecursively(root.current, updatedFamilies, staleFamilies);
  20156. });
  20157. }
  20158. };
  20159. var scheduleRoot = function (root, element) {
  20160. {
  20161. if (root.context !== emptyContextObject) {
  20162. // Super edge case: root has a legacy _renderSubtree context
  20163. // but we don't know the parentComponent so we can't pass it.
  20164. // Just ignore. We'll delete this with _renderSubtree code path later.
  20165. return;
  20166. }
  20167. flushPassiveEffects();
  20168. flushSync(function () {
  20169. updateContainer(element, root, null, null);
  20170. });
  20171. }
  20172. };
  20173. function scheduleFibersWithFamiliesRecursively(fiber, updatedFamilies, staleFamilies) {
  20174. {
  20175. var alternate = fiber.alternate,
  20176. child = fiber.child,
  20177. sibling = fiber.sibling,
  20178. tag = fiber.tag,
  20179. type = fiber.type;
  20180. var candidateType = null;
  20181. switch (tag) {
  20182. case FunctionComponent:
  20183. case SimpleMemoComponent:
  20184. case ClassComponent:
  20185. candidateType = type;
  20186. break;
  20187. case ForwardRef:
  20188. candidateType = type.render;
  20189. break;
  20190. }
  20191. if (resolveFamily === null) {
  20192. throw new Error('Expected resolveFamily to be set during hot reload.');
  20193. }
  20194. var needsRender = false;
  20195. var needsRemount = false;
  20196. if (candidateType !== null) {
  20197. var family = resolveFamily(candidateType);
  20198. if (family !== undefined) {
  20199. if (staleFamilies.has(family)) {
  20200. needsRemount = true;
  20201. } else if (updatedFamilies.has(family)) {
  20202. if (tag === ClassComponent) {
  20203. needsRemount = true;
  20204. } else {
  20205. needsRender = true;
  20206. }
  20207. }
  20208. }
  20209. }
  20210. if (failedBoundaries !== null) {
  20211. if (failedBoundaries.has(fiber) || alternate !== null && failedBoundaries.has(alternate)) {
  20212. needsRemount = true;
  20213. }
  20214. }
  20215. if (needsRemount) {
  20216. fiber._debugNeedsRemount = true;
  20217. }
  20218. if (needsRemount || needsRender) {
  20219. scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
  20220. }
  20221. if (child !== null && !needsRemount) {
  20222. scheduleFibersWithFamiliesRecursively(child, updatedFamilies, staleFamilies);
  20223. }
  20224. if (sibling !== null) {
  20225. scheduleFibersWithFamiliesRecursively(sibling, updatedFamilies, staleFamilies);
  20226. }
  20227. }
  20228. }
  20229. var findHostInstancesForRefresh = function (root, families) {
  20230. {
  20231. var hostInstances = new Set();
  20232. var types = new Set(families.map(function (family) {
  20233. return family.current;
  20234. }));
  20235. findHostInstancesForMatchingFibersRecursively(root.current, types, hostInstances);
  20236. return hostInstances;
  20237. }
  20238. };
  20239. function findHostInstancesForMatchingFibersRecursively(fiber, types, hostInstances) {
  20240. {
  20241. var child = fiber.child,
  20242. sibling = fiber.sibling,
  20243. tag = fiber.tag,
  20244. type = fiber.type;
  20245. var candidateType = null;
  20246. switch (tag) {
  20247. case FunctionComponent:
  20248. case SimpleMemoComponent:
  20249. case ClassComponent:
  20250. candidateType = type;
  20251. break;
  20252. case ForwardRef:
  20253. candidateType = type.render;
  20254. break;
  20255. }
  20256. var didMatch = false;
  20257. if (candidateType !== null) {
  20258. if (types.has(candidateType)) {
  20259. didMatch = true;
  20260. }
  20261. }
  20262. if (didMatch) {
  20263. // We have a match. This only drills down to the closest host components.
  20264. // There's no need to search deeper because for the purpose of giving
  20265. // visual feedback, "flashing" outermost parent rectangles is sufficient.
  20266. findHostInstancesForFiberShallowly(fiber, hostInstances);
  20267. } else {
  20268. // If there's no match, maybe there will be one further down in the child tree.
  20269. if (child !== null) {
  20270. findHostInstancesForMatchingFibersRecursively(child, types, hostInstances);
  20271. }
  20272. }
  20273. if (sibling !== null) {
  20274. findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances);
  20275. }
  20276. }
  20277. }
  20278. function findHostInstancesForFiberShallowly(fiber, hostInstances) {
  20279. {
  20280. var foundHostInstances = findChildHostInstancesForFiberShallowly(fiber, hostInstances);
  20281. if (foundHostInstances) {
  20282. return;
  20283. } // If we didn't find any host children, fallback to closest host parent.
  20284. var node = fiber;
  20285. while (true) {
  20286. switch (node.tag) {
  20287. case HostComponent:
  20288. hostInstances.add(node.stateNode);
  20289. return;
  20290. case HostPortal:
  20291. hostInstances.add(node.stateNode.containerInfo);
  20292. return;
  20293. case HostRoot:
  20294. hostInstances.add(node.stateNode.containerInfo);
  20295. return;
  20296. }
  20297. if (node.return === null) {
  20298. throw new Error('Expected to reach root first.');
  20299. }
  20300. node = node.return;
  20301. }
  20302. }
  20303. }
  20304. function findChildHostInstancesForFiberShallowly(fiber, hostInstances) {
  20305. {
  20306. var node = fiber;
  20307. var foundHostInstances = false;
  20308. while (true) {
  20309. if (node.tag === HostComponent) {
  20310. // We got a match.
  20311. foundHostInstances = true;
  20312. hostInstances.add(node.stateNode); // There may still be more, so keep searching.
  20313. } else if (node.child !== null) {
  20314. node.child.return = node;
  20315. node = node.child;
  20316. continue;
  20317. }
  20318. if (node === fiber) {
  20319. return foundHostInstances;
  20320. }
  20321. while (node.sibling === null) {
  20322. if (node.return === null || node.return === fiber) {
  20323. return foundHostInstances;
  20324. }
  20325. node = node.return;
  20326. }
  20327. node.sibling.return = node.return;
  20328. node = node.sibling;
  20329. }
  20330. }
  20331. return false;
  20332. }
  20333. var hasBadMapPolyfill;
  20334. {
  20335. hasBadMapPolyfill = false;
  20336. try {
  20337. var nonExtensibleObject = Object.preventExtensions({});
  20338. /* eslint-disable no-new */
  20339. new Map([[nonExtensibleObject, null]]);
  20340. new Set([nonExtensibleObject]);
  20341. /* eslint-enable no-new */
  20342. } catch (e) {
  20343. // TODO: Consider warning about bad polyfills
  20344. hasBadMapPolyfill = true;
  20345. }
  20346. }
  20347. var debugCounter = 1;
  20348. function FiberNode(tag, pendingProps, key, mode) {
  20349. // Instance
  20350. this.tag = tag;
  20351. this.key = key;
  20352. this.elementType = null;
  20353. this.type = null;
  20354. this.stateNode = null; // Fiber
  20355. this.return = null;
  20356. this.child = null;
  20357. this.sibling = null;
  20358. this.index = 0;
  20359. this.ref = null;
  20360. this.pendingProps = pendingProps;
  20361. this.memoizedProps = null;
  20362. this.updateQueue = null;
  20363. this.memoizedState = null;
  20364. this.dependencies = null;
  20365. this.mode = mode; // Effects
  20366. this.flags = NoFlags;
  20367. this.nextEffect = null;
  20368. this.firstEffect = null;
  20369. this.lastEffect = null;
  20370. this.lanes = NoLanes;
  20371. this.childLanes = NoLanes;
  20372. this.alternate = null;
  20373. {
  20374. // Note: The following is done to avoid a v8 performance cliff.
  20375. //
  20376. // Initializing the fields below to smis and later updating them with
  20377. // double values will cause Fibers to end up having separate shapes.
  20378. // This behavior/bug has something to do with Object.preventExtension().
  20379. // Fortunately this only impacts DEV builds.
  20380. // Unfortunately it makes React unusably slow for some applications.
  20381. // To work around this, initialize the fields below with doubles.
  20382. //
  20383. // Learn more about this here:
  20384. // https://github.com/facebook/react/issues/14365
  20385. // https://bugs.chromium.org/p/v8/issues/detail?id=8538
  20386. this.actualDuration = Number.NaN;
  20387. this.actualStartTime = Number.NaN;
  20388. this.selfBaseDuration = Number.NaN;
  20389. this.treeBaseDuration = Number.NaN; // It's okay to replace the initial doubles with smis after initialization.
  20390. // This won't trigger the performance cliff mentioned above,
  20391. // and it simplifies other profiler code (including DevTools).
  20392. this.actualDuration = 0;
  20393. this.actualStartTime = -1;
  20394. this.selfBaseDuration = 0;
  20395. this.treeBaseDuration = 0;
  20396. }
  20397. {
  20398. // This isn't directly used but is handy for debugging internals:
  20399. this._debugID = debugCounter++;
  20400. this._debugSource = null;
  20401. this._debugOwner = null;
  20402. this._debugNeedsRemount = false;
  20403. this._debugHookTypes = null;
  20404. if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {
  20405. Object.preventExtensions(this);
  20406. }
  20407. }
  20408. } // This is a constructor function, rather than a POJO constructor, still
  20409. // please ensure we do the following:
  20410. // 1) Nobody should add any instance methods on this. Instance methods can be
  20411. // more difficult to predict when they get optimized and they are almost
  20412. // never inlined properly in static compilers.
  20413. // 2) Nobody should rely on `instanceof Fiber` for type testing. We should
  20414. // always know when it is a fiber.
  20415. // 3) We might want to experiment with using numeric keys since they are easier
  20416. // to optimize in a non-JIT environment.
  20417. // 4) We can easily go from a constructor to a createFiber object literal if that
  20418. // is faster.
  20419. // 5) It should be easy to port this to a C struct and keep a C implementation
  20420. // compatible.
  20421. var createFiber = function (tag, pendingProps, key, mode) {
  20422. // $FlowFixMe: the shapes are exact here but Flow doesn't like constructors
  20423. return new FiberNode(tag, pendingProps, key, mode);
  20424. };
  20425. function shouldConstruct$1(Component) {
  20426. var prototype = Component.prototype;
  20427. return !!(prototype && prototype.isReactComponent);
  20428. }
  20429. function isSimpleFunctionComponent(type) {
  20430. return typeof type === 'function' && !shouldConstruct$1(type) && type.defaultProps === undefined;
  20431. }
  20432. function resolveLazyComponentTag(Component) {
  20433. if (typeof Component === 'function') {
  20434. return shouldConstruct$1(Component) ? ClassComponent : FunctionComponent;
  20435. } else if (Component !== undefined && Component !== null) {
  20436. var $$typeof = Component.$$typeof;
  20437. if ($$typeof === REACT_FORWARD_REF_TYPE) {
  20438. return ForwardRef;
  20439. }
  20440. if ($$typeof === REACT_MEMO_TYPE) {
  20441. return MemoComponent;
  20442. }
  20443. }
  20444. return IndeterminateComponent;
  20445. } // This is used to create an alternate fiber to do work on.
  20446. function createWorkInProgress(current, pendingProps) {
  20447. var workInProgress = current.alternate;
  20448. if (workInProgress === null) {
  20449. // We use a double buffering pooling technique because we know that we'll
  20450. // only ever need at most two versions of a tree. We pool the "other" unused
  20451. // node that we're free to reuse. This is lazily created to avoid allocating
  20452. // extra objects for things that are never updated. It also allow us to
  20453. // reclaim the extra memory if needed.
  20454. workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
  20455. workInProgress.elementType = current.elementType;
  20456. workInProgress.type = current.type;
  20457. workInProgress.stateNode = current.stateNode;
  20458. {
  20459. // DEV-only fields
  20460. workInProgress._debugID = current._debugID;
  20461. workInProgress._debugSource = current._debugSource;
  20462. workInProgress._debugOwner = current._debugOwner;
  20463. workInProgress._debugHookTypes = current._debugHookTypes;
  20464. }
  20465. workInProgress.alternate = current;
  20466. current.alternate = workInProgress;
  20467. } else {
  20468. workInProgress.pendingProps = pendingProps; // Needed because Blocks store data on type.
  20469. workInProgress.type = current.type; // We already have an alternate.
  20470. // Reset the effect tag.
  20471. workInProgress.flags = NoFlags; // The effect list is no longer valid.
  20472. workInProgress.nextEffect = null;
  20473. workInProgress.firstEffect = null;
  20474. workInProgress.lastEffect = null;
  20475. {
  20476. // We intentionally reset, rather than copy, actualDuration & actualStartTime.
  20477. // This prevents time from endlessly accumulating in new commits.
  20478. // This has the downside of resetting values for different priority renders,
  20479. // But works for yielding (the common case) and should support resuming.
  20480. workInProgress.actualDuration = 0;
  20481. workInProgress.actualStartTime = -1;
  20482. }
  20483. }
  20484. workInProgress.childLanes = current.childLanes;
  20485. workInProgress.lanes = current.lanes;
  20486. workInProgress.child = current.child;
  20487. workInProgress.memoizedProps = current.memoizedProps;
  20488. workInProgress.memoizedState = current.memoizedState;
  20489. workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so
  20490. // it cannot be shared with the current fiber.
  20491. var currentDependencies = current.dependencies;
  20492. workInProgress.dependencies = currentDependencies === null ? null : {
  20493. lanes: currentDependencies.lanes,
  20494. firstContext: currentDependencies.firstContext
  20495. }; // These will be overridden during the parent's reconciliation
  20496. workInProgress.sibling = current.sibling;
  20497. workInProgress.index = current.index;
  20498. workInProgress.ref = current.ref;
  20499. {
  20500. workInProgress.selfBaseDuration = current.selfBaseDuration;
  20501. workInProgress.treeBaseDuration = current.treeBaseDuration;
  20502. }
  20503. {
  20504. workInProgress._debugNeedsRemount = current._debugNeedsRemount;
  20505. switch (workInProgress.tag) {
  20506. case IndeterminateComponent:
  20507. case FunctionComponent:
  20508. case SimpleMemoComponent:
  20509. workInProgress.type = resolveFunctionForHotReloading(current.type);
  20510. break;
  20511. case ClassComponent:
  20512. workInProgress.type = resolveClassForHotReloading(current.type);
  20513. break;
  20514. case ForwardRef:
  20515. workInProgress.type = resolveForwardRefForHotReloading(current.type);
  20516. break;
  20517. }
  20518. }
  20519. return workInProgress;
  20520. } // Used to reuse a Fiber for a second pass.
  20521. function resetWorkInProgress(workInProgress, renderLanes) {
  20522. // This resets the Fiber to what createFiber or createWorkInProgress would
  20523. // have set the values to before during the first pass. Ideally this wouldn't
  20524. // be necessary but unfortunately many code paths reads from the workInProgress
  20525. // when they should be reading from current and writing to workInProgress.
  20526. // We assume pendingProps, index, key, ref, return are still untouched to
  20527. // avoid doing another reconciliation.
  20528. // Reset the effect tag but keep any Placement tags, since that's something
  20529. // that child fiber is setting, not the reconciliation.
  20530. workInProgress.flags &= Placement; // The effect list is no longer valid.
  20531. workInProgress.nextEffect = null;
  20532. workInProgress.firstEffect = null;
  20533. workInProgress.lastEffect = null;
  20534. var current = workInProgress.alternate;
  20535. if (current === null) {
  20536. // Reset to createFiber's initial values.
  20537. workInProgress.childLanes = NoLanes;
  20538. workInProgress.lanes = renderLanes;
  20539. workInProgress.child = null;
  20540. workInProgress.memoizedProps = null;
  20541. workInProgress.memoizedState = null;
  20542. workInProgress.updateQueue = null;
  20543. workInProgress.dependencies = null;
  20544. workInProgress.stateNode = null;
  20545. {
  20546. // Note: We don't reset the actualTime counts. It's useful to accumulate
  20547. // actual time across multiple render passes.
  20548. workInProgress.selfBaseDuration = 0;
  20549. workInProgress.treeBaseDuration = 0;
  20550. }
  20551. } else {
  20552. // Reset to the cloned values that createWorkInProgress would've.
  20553. workInProgress.childLanes = current.childLanes;
  20554. workInProgress.lanes = current.lanes;
  20555. workInProgress.child = current.child;
  20556. workInProgress.memoizedProps = current.memoizedProps;
  20557. workInProgress.memoizedState = current.memoizedState;
  20558. workInProgress.updateQueue = current.updateQueue; // Needed because Blocks store data on type.
  20559. workInProgress.type = current.type; // Clone the dependencies object. This is mutated during the render phase, so
  20560. // it cannot be shared with the current fiber.
  20561. var currentDependencies = current.dependencies;
  20562. workInProgress.dependencies = currentDependencies === null ? null : {
  20563. lanes: currentDependencies.lanes,
  20564. firstContext: currentDependencies.firstContext
  20565. };
  20566. {
  20567. // Note: We don't reset the actualTime counts. It's useful to accumulate
  20568. // actual time across multiple render passes.
  20569. workInProgress.selfBaseDuration = current.selfBaseDuration;
  20570. workInProgress.treeBaseDuration = current.treeBaseDuration;
  20571. }
  20572. }
  20573. return workInProgress;
  20574. }
  20575. function createHostRootFiber(tag) {
  20576. var mode;
  20577. if (tag === ConcurrentRoot) {
  20578. mode = ConcurrentMode | BlockingMode | StrictMode;
  20579. } else if (tag === BlockingRoot) {
  20580. mode = BlockingMode | StrictMode;
  20581. } else {
  20582. mode = NoMode;
  20583. }
  20584. if ( isDevToolsPresent) {
  20585. // Always collect profile timings when DevTools are present.
  20586. // This enables DevTools to start capturing timing at any point–
  20587. // Without some nodes in the tree having empty base times.
  20588. mode |= ProfileMode;
  20589. }
  20590. return createFiber(HostRoot, null, null, mode);
  20591. }
  20592. function createFiberFromTypeAndProps(type, // React$ElementType
  20593. key, pendingProps, owner, mode, lanes) {
  20594. var fiberTag = IndeterminateComponent; // The resolved type is set if we know what the final type will be. I.e. it's not lazy.
  20595. var resolvedType = type;
  20596. if (typeof type === 'function') {
  20597. if (shouldConstruct$1(type)) {
  20598. fiberTag = ClassComponent;
  20599. {
  20600. resolvedType = resolveClassForHotReloading(resolvedType);
  20601. }
  20602. } else {
  20603. {
  20604. resolvedType = resolveFunctionForHotReloading(resolvedType);
  20605. }
  20606. }
  20607. } else if (typeof type === 'string') {
  20608. fiberTag = HostComponent;
  20609. } else {
  20610. getTag: switch (type) {
  20611. case REACT_FRAGMENT_TYPE:
  20612. return createFiberFromFragment(pendingProps.children, mode, lanes, key);
  20613. case REACT_DEBUG_TRACING_MODE_TYPE:
  20614. fiberTag = Mode;
  20615. mode |= DebugTracingMode;
  20616. break;
  20617. case REACT_STRICT_MODE_TYPE:
  20618. fiberTag = Mode;
  20619. mode |= StrictMode;
  20620. break;
  20621. case REACT_PROFILER_TYPE:
  20622. return createFiberFromProfiler(pendingProps, mode, lanes, key);
  20623. case REACT_SUSPENSE_TYPE:
  20624. return createFiberFromSuspense(pendingProps, mode, lanes, key);
  20625. case REACT_SUSPENSE_LIST_TYPE:
  20626. return createFiberFromSuspenseList(pendingProps, mode, lanes, key);
  20627. case REACT_OFFSCREEN_TYPE:
  20628. return createFiberFromOffscreen(pendingProps, mode, lanes, key);
  20629. case REACT_LEGACY_HIDDEN_TYPE:
  20630. return createFiberFromLegacyHidden(pendingProps, mode, lanes, key);
  20631. case REACT_SCOPE_TYPE:
  20632. // eslint-disable-next-line no-fallthrough
  20633. default:
  20634. {
  20635. if (typeof type === 'object' && type !== null) {
  20636. switch (type.$$typeof) {
  20637. case REACT_PROVIDER_TYPE:
  20638. fiberTag = ContextProvider;
  20639. break getTag;
  20640. case REACT_CONTEXT_TYPE:
  20641. // This is a consumer
  20642. fiberTag = ContextConsumer;
  20643. break getTag;
  20644. case REACT_FORWARD_REF_TYPE:
  20645. fiberTag = ForwardRef;
  20646. {
  20647. resolvedType = resolveForwardRefForHotReloading(resolvedType);
  20648. }
  20649. break getTag;
  20650. case REACT_MEMO_TYPE:
  20651. fiberTag = MemoComponent;
  20652. break getTag;
  20653. case REACT_LAZY_TYPE:
  20654. fiberTag = LazyComponent;
  20655. resolvedType = null;
  20656. break getTag;
  20657. case REACT_BLOCK_TYPE:
  20658. fiberTag = Block;
  20659. break getTag;
  20660. }
  20661. }
  20662. var info = '';
  20663. {
  20664. if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
  20665. 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.';
  20666. }
  20667. var ownerName = owner ? getComponentName(owner.type) : null;
  20668. if (ownerName) {
  20669. info += '\n\nCheck the render method of `' + ownerName + '`.';
  20670. }
  20671. }
  20672. {
  20673. {
  20674. throw Error( "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + (type == null ? type : typeof type) + "." + info );
  20675. }
  20676. }
  20677. }
  20678. }
  20679. }
  20680. var fiber = createFiber(fiberTag, pendingProps, key, mode);
  20681. fiber.elementType = type;
  20682. fiber.type = resolvedType;
  20683. fiber.lanes = lanes;
  20684. {
  20685. fiber._debugOwner = owner;
  20686. }
  20687. return fiber;
  20688. }
  20689. function createFiberFromElement(element, mode, lanes) {
  20690. var owner = null;
  20691. {
  20692. owner = element._owner;
  20693. }
  20694. var type = element.type;
  20695. var key = element.key;
  20696. var pendingProps = element.props;
  20697. var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, lanes);
  20698. {
  20699. fiber._debugSource = element._source;
  20700. fiber._debugOwner = element._owner;
  20701. }
  20702. return fiber;
  20703. }
  20704. function createFiberFromFragment(elements, mode, lanes, key) {
  20705. var fiber = createFiber(Fragment, elements, key, mode);
  20706. fiber.lanes = lanes;
  20707. return fiber;
  20708. }
  20709. function createFiberFromProfiler(pendingProps, mode, lanes, key) {
  20710. {
  20711. if (typeof pendingProps.id !== 'string') {
  20712. error('Profiler must specify an "id" as a prop');
  20713. }
  20714. }
  20715. var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode); // TODO: The Profiler fiber shouldn't have a type. It has a tag.
  20716. fiber.elementType = REACT_PROFILER_TYPE;
  20717. fiber.type = REACT_PROFILER_TYPE;
  20718. fiber.lanes = lanes;
  20719. {
  20720. fiber.stateNode = {
  20721. effectDuration: 0,
  20722. passiveEffectDuration: 0
  20723. };
  20724. }
  20725. return fiber;
  20726. }
  20727. function createFiberFromSuspense(pendingProps, mode, lanes, key) {
  20728. var fiber = createFiber(SuspenseComponent, pendingProps, key, mode); // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag.
  20729. // This needs to be fixed in getComponentName so that it relies on the tag
  20730. // instead.
  20731. fiber.type = REACT_SUSPENSE_TYPE;
  20732. fiber.elementType = REACT_SUSPENSE_TYPE;
  20733. fiber.lanes = lanes;
  20734. return fiber;
  20735. }
  20736. function createFiberFromSuspenseList(pendingProps, mode, lanes, key) {
  20737. var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode);
  20738. {
  20739. // TODO: The SuspenseListComponent fiber shouldn't have a type. It has a tag.
  20740. // This needs to be fixed in getComponentName so that it relies on the tag
  20741. // instead.
  20742. fiber.type = REACT_SUSPENSE_LIST_TYPE;
  20743. }
  20744. fiber.elementType = REACT_SUSPENSE_LIST_TYPE;
  20745. fiber.lanes = lanes;
  20746. return fiber;
  20747. }
  20748. function createFiberFromOffscreen(pendingProps, mode, lanes, key) {
  20749. var fiber = createFiber(OffscreenComponent, pendingProps, key, mode); // TODO: The OffscreenComponent fiber shouldn't have a type. It has a tag.
  20750. // This needs to be fixed in getComponentName so that it relies on the tag
  20751. // instead.
  20752. {
  20753. fiber.type = REACT_OFFSCREEN_TYPE;
  20754. }
  20755. fiber.elementType = REACT_OFFSCREEN_TYPE;
  20756. fiber.lanes = lanes;
  20757. return fiber;
  20758. }
  20759. function createFiberFromLegacyHidden(pendingProps, mode, lanes, key) {
  20760. var fiber = createFiber(LegacyHiddenComponent, pendingProps, key, mode); // TODO: The LegacyHidden fiber shouldn't have a type. It has a tag.
  20761. // This needs to be fixed in getComponentName so that it relies on the tag
  20762. // instead.
  20763. {
  20764. fiber.type = REACT_LEGACY_HIDDEN_TYPE;
  20765. }
  20766. fiber.elementType = REACT_LEGACY_HIDDEN_TYPE;
  20767. fiber.lanes = lanes;
  20768. return fiber;
  20769. }
  20770. function createFiberFromText(content, mode, lanes) {
  20771. var fiber = createFiber(HostText, content, null, mode);
  20772. fiber.lanes = lanes;
  20773. return fiber;
  20774. }
  20775. function createFiberFromHostInstanceForDeletion() {
  20776. var fiber = createFiber(HostComponent, null, null, NoMode); // TODO: These should not need a type.
  20777. fiber.elementType = 'DELETED';
  20778. fiber.type = 'DELETED';
  20779. return fiber;
  20780. }
  20781. function createFiberFromPortal(portal, mode, lanes) {
  20782. var pendingProps = portal.children !== null ? portal.children : [];
  20783. var fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
  20784. fiber.lanes = lanes;
  20785. fiber.stateNode = {
  20786. containerInfo: portal.containerInfo,
  20787. pendingChildren: null,
  20788. // Used by persistent updates
  20789. implementation: portal.implementation
  20790. };
  20791. return fiber;
  20792. } // Used for stashing WIP properties to replay failed work in DEV.
  20793. function assignFiberPropertiesInDEV(target, source) {
  20794. if (target === null) {
  20795. // This Fiber's initial properties will always be overwritten.
  20796. // We only use a Fiber to ensure the same hidden class so DEV isn't slow.
  20797. target = createFiber(IndeterminateComponent, null, null, NoMode);
  20798. } // This is intentionally written as a list of all properties.
  20799. // We tried to use Object.assign() instead but this is called in
  20800. // the hottest path, and Object.assign() was too slow:
  20801. // https://github.com/facebook/react/issues/12502
  20802. // This code is DEV-only so size is not a concern.
  20803. target.tag = source.tag;
  20804. target.key = source.key;
  20805. target.elementType = source.elementType;
  20806. target.type = source.type;
  20807. target.stateNode = source.stateNode;
  20808. target.return = source.return;
  20809. target.child = source.child;
  20810. target.sibling = source.sibling;
  20811. target.index = source.index;
  20812. target.ref = source.ref;
  20813. target.pendingProps = source.pendingProps;
  20814. target.memoizedProps = source.memoizedProps;
  20815. target.updateQueue = source.updateQueue;
  20816. target.memoizedState = source.memoizedState;
  20817. target.dependencies = source.dependencies;
  20818. target.mode = source.mode;
  20819. target.flags = source.flags;
  20820. target.nextEffect = source.nextEffect;
  20821. target.firstEffect = source.firstEffect;
  20822. target.lastEffect = source.lastEffect;
  20823. target.lanes = source.lanes;
  20824. target.childLanes = source.childLanes;
  20825. target.alternate = source.alternate;
  20826. {
  20827. target.actualDuration = source.actualDuration;
  20828. target.actualStartTime = source.actualStartTime;
  20829. target.selfBaseDuration = source.selfBaseDuration;
  20830. target.treeBaseDuration = source.treeBaseDuration;
  20831. }
  20832. target._debugID = source._debugID;
  20833. target._debugSource = source._debugSource;
  20834. target._debugOwner = source._debugOwner;
  20835. target._debugNeedsRemount = source._debugNeedsRemount;
  20836. target._debugHookTypes = source._debugHookTypes;
  20837. return target;
  20838. }
  20839. function FiberRootNode(containerInfo, tag, hydrate) {
  20840. this.tag = tag;
  20841. this.containerInfo = containerInfo;
  20842. this.pendingChildren = null;
  20843. this.current = null;
  20844. this.pingCache = null;
  20845. this.finishedWork = null;
  20846. this.timeoutHandle = noTimeout;
  20847. this.context = null;
  20848. this.pendingContext = null;
  20849. this.hydrate = hydrate;
  20850. this.callbackNode = null;
  20851. this.callbackPriority = NoLanePriority;
  20852. this.eventTimes = createLaneMap(NoLanes);
  20853. this.expirationTimes = createLaneMap(NoTimestamp);
  20854. this.pendingLanes = NoLanes;
  20855. this.suspendedLanes = NoLanes;
  20856. this.pingedLanes = NoLanes;
  20857. this.expiredLanes = NoLanes;
  20858. this.mutableReadLanes = NoLanes;
  20859. this.finishedLanes = NoLanes;
  20860. this.entangledLanes = NoLanes;
  20861. this.entanglements = createLaneMap(NoLanes);
  20862. {
  20863. this.mutableSourceEagerHydrationData = null;
  20864. }
  20865. {
  20866. this.interactionThreadID = tracing.unstable_getThreadID();
  20867. this.memoizedInteractions = new Set();
  20868. this.pendingInteractionMap = new Map();
  20869. }
  20870. {
  20871. switch (tag) {
  20872. case BlockingRoot:
  20873. this._debugRootType = 'createBlockingRoot()';
  20874. break;
  20875. case ConcurrentRoot:
  20876. this._debugRootType = 'createRoot()';
  20877. break;
  20878. case LegacyRoot:
  20879. this._debugRootType = 'createLegacyRoot()';
  20880. break;
  20881. }
  20882. }
  20883. }
  20884. function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) {
  20885. var root = new FiberRootNode(containerInfo, tag, hydrate);
  20886. // stateNode is any.
  20887. var uninitializedFiber = createHostRootFiber(tag);
  20888. root.current = uninitializedFiber;
  20889. uninitializedFiber.stateNode = root;
  20890. initializeUpdateQueue(uninitializedFiber);
  20891. return root;
  20892. }
  20893. // This ensures that the version used for server rendering matches the one
  20894. // that is eventually read during hydration.
  20895. // If they don't match there's a potential tear and a full deopt render is required.
  20896. function registerMutableSourceForHydration(root, mutableSource) {
  20897. var getVersion = mutableSource._getVersion;
  20898. var version = getVersion(mutableSource._source); // TODO Clear this data once all pending hydration work is finished.
  20899. // Retaining it forever may interfere with GC.
  20900. if (root.mutableSourceEagerHydrationData == null) {
  20901. root.mutableSourceEagerHydrationData = [mutableSource, version];
  20902. } else {
  20903. root.mutableSourceEagerHydrationData.push(mutableSource, version);
  20904. }
  20905. }
  20906. function createPortal(children, containerInfo, // TODO: figure out the API for cross-renderer implementation.
  20907. implementation) {
  20908. var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  20909. return {
  20910. // This tag allow us to uniquely identify this as a React Portal
  20911. $$typeof: REACT_PORTAL_TYPE,
  20912. key: key == null ? null : '' + key,
  20913. children: children,
  20914. containerInfo: containerInfo,
  20915. implementation: implementation
  20916. };
  20917. }
  20918. var didWarnAboutNestedUpdates;
  20919. var didWarnAboutFindNodeInStrictMode;
  20920. {
  20921. didWarnAboutNestedUpdates = false;
  20922. didWarnAboutFindNodeInStrictMode = {};
  20923. }
  20924. function getContextForSubtree(parentComponent) {
  20925. if (!parentComponent) {
  20926. return emptyContextObject;
  20927. }
  20928. var fiber = get(parentComponent);
  20929. var parentContext = findCurrentUnmaskedContext(fiber);
  20930. if (fiber.tag === ClassComponent) {
  20931. var Component = fiber.type;
  20932. if (isContextProvider(Component)) {
  20933. return processChildContext(fiber, Component, parentContext);
  20934. }
  20935. }
  20936. return parentContext;
  20937. }
  20938. function findHostInstanceWithWarning(component, methodName) {
  20939. {
  20940. var fiber = get(component);
  20941. if (fiber === undefined) {
  20942. if (typeof component.render === 'function') {
  20943. {
  20944. {
  20945. throw Error( "Unable to find node on an unmounted component." );
  20946. }
  20947. }
  20948. } else {
  20949. {
  20950. {
  20951. throw Error( "Argument appears to not be a ReactComponent. Keys: " + Object.keys(component) );
  20952. }
  20953. }
  20954. }
  20955. }
  20956. var hostFiber = findCurrentHostFiber(fiber);
  20957. if (hostFiber === null) {
  20958. return null;
  20959. }
  20960. if (hostFiber.mode & StrictMode) {
  20961. var componentName = getComponentName(fiber.type) || 'Component';
  20962. if (!didWarnAboutFindNodeInStrictMode[componentName]) {
  20963. didWarnAboutFindNodeInStrictMode[componentName] = true;
  20964. var previousFiber = current;
  20965. try {
  20966. setCurrentFiber(hostFiber);
  20967. if (fiber.mode & StrictMode) {
  20968. error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which is inside StrictMode. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-find-node', methodName, methodName, componentName);
  20969. } else {
  20970. error('%s is deprecated in StrictMode. ' + '%s was passed an instance of %s which renders StrictMode children. ' + 'Instead, add a ref directly to the element you want to reference. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-find-node', methodName, methodName, componentName);
  20971. }
  20972. } finally {
  20973. // Ideally this should reset to previous but this shouldn't be called in
  20974. // render and there's another warning for that anyway.
  20975. if (previousFiber) {
  20976. setCurrentFiber(previousFiber);
  20977. } else {
  20978. resetCurrentFiber();
  20979. }
  20980. }
  20981. }
  20982. }
  20983. return hostFiber.stateNode;
  20984. }
  20985. }
  20986. function createContainer(containerInfo, tag, hydrate, hydrationCallbacks) {
  20987. return createFiberRoot(containerInfo, tag, hydrate);
  20988. }
  20989. function updateContainer(element, container, parentComponent, callback) {
  20990. {
  20991. onScheduleRoot(container, element);
  20992. }
  20993. var current$1 = container.current;
  20994. var eventTime = requestEventTime();
  20995. {
  20996. // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
  20997. if ('undefined' !== typeof jest) {
  20998. warnIfUnmockedScheduler(current$1);
  20999. warnIfNotScopedWithMatchingAct(current$1);
  21000. }
  21001. }
  21002. var lane = requestUpdateLane(current$1);
  21003. var context = getContextForSubtree(parentComponent);
  21004. if (container.context === null) {
  21005. container.context = context;
  21006. } else {
  21007. container.pendingContext = context;
  21008. }
  21009. {
  21010. if (isRendering && current !== null && !didWarnAboutNestedUpdates) {
  21011. didWarnAboutNestedUpdates = true;
  21012. error('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');
  21013. }
  21014. }
  21015. var update = createUpdate(eventTime, lane); // Caution: React DevTools currently depends on this property
  21016. // being called "element".
  21017. update.payload = {
  21018. element: element
  21019. };
  21020. callback = callback === undefined ? null : callback;
  21021. if (callback !== null) {
  21022. {
  21023. if (typeof callback !== 'function') {
  21024. error('render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback);
  21025. }
  21026. }
  21027. update.callback = callback;
  21028. }
  21029. enqueueUpdate(current$1, update);
  21030. scheduleUpdateOnFiber(current$1, lane, eventTime);
  21031. return lane;
  21032. }
  21033. function getPublicRootInstance(container) {
  21034. var containerFiber = container.current;
  21035. if (!containerFiber.child) {
  21036. return null;
  21037. }
  21038. switch (containerFiber.child.tag) {
  21039. case HostComponent:
  21040. return getPublicInstance(containerFiber.child.stateNode);
  21041. default:
  21042. return containerFiber.child.stateNode;
  21043. }
  21044. }
  21045. function markRetryLaneImpl(fiber, retryLane) {
  21046. var suspenseState = fiber.memoizedState;
  21047. if (suspenseState !== null && suspenseState.dehydrated !== null) {
  21048. suspenseState.retryLane = higherPriorityLane(suspenseState.retryLane, retryLane);
  21049. }
  21050. } // Increases the priority of thennables when they resolve within this boundary.
  21051. function markRetryLaneIfNotHydrated(fiber, retryLane) {
  21052. markRetryLaneImpl(fiber, retryLane);
  21053. var alternate = fiber.alternate;
  21054. if (alternate) {
  21055. markRetryLaneImpl(alternate, retryLane);
  21056. }
  21057. }
  21058. function attemptUserBlockingHydration$1(fiber) {
  21059. if (fiber.tag !== SuspenseComponent) {
  21060. // We ignore HostRoots here because we can't increase
  21061. // their priority and they should not suspend on I/O,
  21062. // since you have to wrap anything that might suspend in
  21063. // Suspense.
  21064. return;
  21065. }
  21066. var eventTime = requestEventTime();
  21067. var lane = InputDiscreteHydrationLane;
  21068. scheduleUpdateOnFiber(fiber, lane, eventTime);
  21069. markRetryLaneIfNotHydrated(fiber, lane);
  21070. }
  21071. function attemptContinuousHydration$1(fiber) {
  21072. if (fiber.tag !== SuspenseComponent) {
  21073. // We ignore HostRoots here because we can't increase
  21074. // their priority and they should not suspend on I/O,
  21075. // since you have to wrap anything that might suspend in
  21076. // Suspense.
  21077. return;
  21078. }
  21079. var eventTime = requestEventTime();
  21080. var lane = SelectiveHydrationLane;
  21081. scheduleUpdateOnFiber(fiber, lane, eventTime);
  21082. markRetryLaneIfNotHydrated(fiber, lane);
  21083. }
  21084. function attemptHydrationAtCurrentPriority$1(fiber) {
  21085. if (fiber.tag !== SuspenseComponent) {
  21086. // We ignore HostRoots here because we can't increase
  21087. // their priority other than synchronously flush it.
  21088. return;
  21089. }
  21090. var eventTime = requestEventTime();
  21091. var lane = requestUpdateLane(fiber);
  21092. scheduleUpdateOnFiber(fiber, lane, eventTime);
  21093. markRetryLaneIfNotHydrated(fiber, lane);
  21094. }
  21095. function runWithPriority$2(priority, fn) {
  21096. try {
  21097. setCurrentUpdateLanePriority(priority);
  21098. return fn();
  21099. } finally {
  21100. }
  21101. }
  21102. function findHostInstanceWithNoPortals(fiber) {
  21103. var hostFiber = findCurrentHostFiberWithNoPortals(fiber);
  21104. if (hostFiber === null) {
  21105. return null;
  21106. }
  21107. if (hostFiber.tag === FundamentalComponent) {
  21108. return hostFiber.stateNode.instance;
  21109. }
  21110. return hostFiber.stateNode;
  21111. }
  21112. var shouldSuspendImpl = function (fiber) {
  21113. return false;
  21114. };
  21115. function shouldSuspend(fiber) {
  21116. return shouldSuspendImpl(fiber);
  21117. }
  21118. var overrideHookState = null;
  21119. var overrideHookStateDeletePath = null;
  21120. var overrideHookStateRenamePath = null;
  21121. var overrideProps = null;
  21122. var overridePropsDeletePath = null;
  21123. var overridePropsRenamePath = null;
  21124. var scheduleUpdate = null;
  21125. var setSuspenseHandler = null;
  21126. {
  21127. var copyWithDeleteImpl = function (obj, path, index) {
  21128. var key = path[index];
  21129. var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj);
  21130. if (index + 1 === path.length) {
  21131. if (Array.isArray(updated)) {
  21132. updated.splice(key, 1);
  21133. } else {
  21134. delete updated[key];
  21135. }
  21136. return updated;
  21137. } // $FlowFixMe number or string is fine here
  21138. updated[key] = copyWithDeleteImpl(obj[key], path, index + 1);
  21139. return updated;
  21140. };
  21141. var copyWithDelete = function (obj, path) {
  21142. return copyWithDeleteImpl(obj, path, 0);
  21143. };
  21144. var copyWithRenameImpl = function (obj, oldPath, newPath, index) {
  21145. var oldKey = oldPath[index];
  21146. var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj);
  21147. if (index + 1 === oldPath.length) {
  21148. var newKey = newPath[index]; // $FlowFixMe number or string is fine here
  21149. updated[newKey] = updated[oldKey];
  21150. if (Array.isArray(updated)) {
  21151. updated.splice(oldKey, 1);
  21152. } else {
  21153. delete updated[oldKey];
  21154. }
  21155. } else {
  21156. // $FlowFixMe number or string is fine here
  21157. updated[oldKey] = copyWithRenameImpl( // $FlowFixMe number or string is fine here
  21158. obj[oldKey], oldPath, newPath, index + 1);
  21159. }
  21160. return updated;
  21161. };
  21162. var copyWithRename = function (obj, oldPath, newPath) {
  21163. if (oldPath.length !== newPath.length) {
  21164. warn('copyWithRename() expects paths of the same length');
  21165. return;
  21166. } else {
  21167. for (var i = 0; i < newPath.length - 1; i++) {
  21168. if (oldPath[i] !== newPath[i]) {
  21169. warn('copyWithRename() expects paths to be the same except for the deepest key');
  21170. return;
  21171. }
  21172. }
  21173. }
  21174. return copyWithRenameImpl(obj, oldPath, newPath, 0);
  21175. };
  21176. var copyWithSetImpl = function (obj, path, index, value) {
  21177. if (index >= path.length) {
  21178. return value;
  21179. }
  21180. var key = path[index];
  21181. var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj); // $FlowFixMe number or string is fine here
  21182. updated[key] = copyWithSetImpl(obj[key], path, index + 1, value);
  21183. return updated;
  21184. };
  21185. var copyWithSet = function (obj, path, value) {
  21186. return copyWithSetImpl(obj, path, 0, value);
  21187. };
  21188. var findHook = function (fiber, id) {
  21189. // For now, the "id" of stateful hooks is just the stateful hook index.
  21190. // This may change in the future with e.g. nested hooks.
  21191. var currentHook = fiber.memoizedState;
  21192. while (currentHook !== null && id > 0) {
  21193. currentHook = currentHook.next;
  21194. id--;
  21195. }
  21196. return currentHook;
  21197. }; // Support DevTools editable values for useState and useReducer.
  21198. overrideHookState = function (fiber, id, path, value) {
  21199. var hook = findHook(fiber, id);
  21200. if (hook !== null) {
  21201. var newState = copyWithSet(hook.memoizedState, path, value);
  21202. hook.memoizedState = newState;
  21203. hook.baseState = newState; // We aren't actually adding an update to the queue,
  21204. // because there is no update we can add for useReducer hooks that won't trigger an error.
  21205. // (There's no appropriate action type for DevTools overrides.)
  21206. // As a result though, React will see the scheduled update as a noop and bailout.
  21207. // Shallow cloning props works as a workaround for now to bypass the bailout check.
  21208. fiber.memoizedProps = _assign({}, fiber.memoizedProps);
  21209. scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
  21210. }
  21211. };
  21212. overrideHookStateDeletePath = function (fiber, id, path) {
  21213. var hook = findHook(fiber, id);
  21214. if (hook !== null) {
  21215. var newState = copyWithDelete(hook.memoizedState, path);
  21216. hook.memoizedState = newState;
  21217. hook.baseState = newState; // We aren't actually adding an update to the queue,
  21218. // because there is no update we can add for useReducer hooks that won't trigger an error.
  21219. // (There's no appropriate action type for DevTools overrides.)
  21220. // As a result though, React will see the scheduled update as a noop and bailout.
  21221. // Shallow cloning props works as a workaround for now to bypass the bailout check.
  21222. fiber.memoizedProps = _assign({}, fiber.memoizedProps);
  21223. scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
  21224. }
  21225. };
  21226. overrideHookStateRenamePath = function (fiber, id, oldPath, newPath) {
  21227. var hook = findHook(fiber, id);
  21228. if (hook !== null) {
  21229. var newState = copyWithRename(hook.memoizedState, oldPath, newPath);
  21230. hook.memoizedState = newState;
  21231. hook.baseState = newState; // We aren't actually adding an update to the queue,
  21232. // because there is no update we can add for useReducer hooks that won't trigger an error.
  21233. // (There's no appropriate action type for DevTools overrides.)
  21234. // As a result though, React will see the scheduled update as a noop and bailout.
  21235. // Shallow cloning props works as a workaround for now to bypass the bailout check.
  21236. fiber.memoizedProps = _assign({}, fiber.memoizedProps);
  21237. scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
  21238. }
  21239. }; // Support DevTools props for function components, forwardRef, memo, host components, etc.
  21240. overrideProps = function (fiber, path, value) {
  21241. fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value);
  21242. if (fiber.alternate) {
  21243. fiber.alternate.pendingProps = fiber.pendingProps;
  21244. }
  21245. scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
  21246. };
  21247. overridePropsDeletePath = function (fiber, path) {
  21248. fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path);
  21249. if (fiber.alternate) {
  21250. fiber.alternate.pendingProps = fiber.pendingProps;
  21251. }
  21252. scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
  21253. };
  21254. overridePropsRenamePath = function (fiber, oldPath, newPath) {
  21255. fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath);
  21256. if (fiber.alternate) {
  21257. fiber.alternate.pendingProps = fiber.pendingProps;
  21258. }
  21259. scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
  21260. };
  21261. scheduleUpdate = function (fiber) {
  21262. scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
  21263. };
  21264. setSuspenseHandler = function (newShouldSuspendImpl) {
  21265. shouldSuspendImpl = newShouldSuspendImpl;
  21266. };
  21267. }
  21268. function findHostInstanceByFiber(fiber) {
  21269. var hostFiber = findCurrentHostFiber(fiber);
  21270. if (hostFiber === null) {
  21271. return null;
  21272. }
  21273. return hostFiber.stateNode;
  21274. }
  21275. function emptyFindFiberByHostInstance(instance) {
  21276. return null;
  21277. }
  21278. function getCurrentFiberForDevTools() {
  21279. return current;
  21280. }
  21281. function injectIntoDevTools(devToolsConfig) {
  21282. var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
  21283. var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
  21284. return injectInternals({
  21285. bundleType: devToolsConfig.bundleType,
  21286. version: devToolsConfig.version,
  21287. rendererPackageName: devToolsConfig.rendererPackageName,
  21288. rendererConfig: devToolsConfig.rendererConfig,
  21289. overrideHookState: overrideHookState,
  21290. overrideHookStateDeletePath: overrideHookStateDeletePath,
  21291. overrideHookStateRenamePath: overrideHookStateRenamePath,
  21292. overrideProps: overrideProps,
  21293. overridePropsDeletePath: overridePropsDeletePath,
  21294. overridePropsRenamePath: overridePropsRenamePath,
  21295. setSuspenseHandler: setSuspenseHandler,
  21296. scheduleUpdate: scheduleUpdate,
  21297. currentDispatcherRef: ReactCurrentDispatcher,
  21298. findHostInstanceByFiber: findHostInstanceByFiber,
  21299. findFiberByHostInstance: findFiberByHostInstance || emptyFindFiberByHostInstance,
  21300. // React Refresh
  21301. findHostInstancesForRefresh: findHostInstancesForRefresh ,
  21302. scheduleRefresh: scheduleRefresh ,
  21303. scheduleRoot: scheduleRoot ,
  21304. setRefreshHandler: setRefreshHandler ,
  21305. // Enables DevTools to append owner stacks to error messages in DEV mode.
  21306. getCurrentFiber: getCurrentFiberForDevTools
  21307. });
  21308. }
  21309. function ReactDOMRoot(container, options) {
  21310. this._internalRoot = createRootImpl(container, ConcurrentRoot, options);
  21311. }
  21312. function ReactDOMBlockingRoot(container, tag, options) {
  21313. this._internalRoot = createRootImpl(container, tag, options);
  21314. }
  21315. ReactDOMRoot.prototype.render = ReactDOMBlockingRoot.prototype.render = function (children) {
  21316. var root = this._internalRoot;
  21317. {
  21318. if (typeof arguments[1] === 'function') {
  21319. error('render(...): does not support the second callback argument. ' + 'To execute a side effect after rendering, declare it in a component body with useEffect().');
  21320. }
  21321. var container = root.containerInfo;
  21322. if (container.nodeType !== COMMENT_NODE) {
  21323. var hostInstance = findHostInstanceWithNoPortals(root.current);
  21324. if (hostInstance) {
  21325. if (hostInstance.parentNode !== container) {
  21326. error('render(...): It looks like the React-rendered content of the ' + 'root container was removed without using React. This is not ' + 'supported and will cause errors. Instead, call ' + "root.unmount() to empty a root's container.");
  21327. }
  21328. }
  21329. }
  21330. }
  21331. updateContainer(children, root, null, null);
  21332. };
  21333. ReactDOMRoot.prototype.unmount = ReactDOMBlockingRoot.prototype.unmount = function () {
  21334. {
  21335. if (typeof arguments[0] === 'function') {
  21336. error('unmount(...): does not support a callback argument. ' + 'To execute a side effect after rendering, declare it in a component body with useEffect().');
  21337. }
  21338. }
  21339. var root = this._internalRoot;
  21340. var container = root.containerInfo;
  21341. updateContainer(null, root, null, function () {
  21342. unmarkContainerAsRoot(container);
  21343. });
  21344. };
  21345. function createRootImpl(container, tag, options) {
  21346. // Tag is either LegacyRoot or Concurrent Root
  21347. var hydrate = options != null && options.hydrate === true;
  21348. var hydrationCallbacks = options != null && options.hydrationOptions || null;
  21349. var mutableSources = options != null && options.hydrationOptions != null && options.hydrationOptions.mutableSources || null;
  21350. var root = createContainer(container, tag, hydrate);
  21351. markContainerAsRoot(root.current, container);
  21352. var containerNodeType = container.nodeType;
  21353. {
  21354. var rootContainerElement = container.nodeType === COMMENT_NODE ? container.parentNode : container;
  21355. listenToAllSupportedEvents(rootContainerElement);
  21356. }
  21357. if (mutableSources) {
  21358. for (var i = 0; i < mutableSources.length; i++) {
  21359. var mutableSource = mutableSources[i];
  21360. registerMutableSourceForHydration(root, mutableSource);
  21361. }
  21362. }
  21363. return root;
  21364. }
  21365. function createLegacyRoot(container, options) {
  21366. return new ReactDOMBlockingRoot(container, LegacyRoot, options);
  21367. }
  21368. function isValidContainer(node) {
  21369. 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 '));
  21370. }
  21371. var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner;
  21372. var topLevelUpdateWarnings;
  21373. var warnedAboutHydrateAPI = false;
  21374. {
  21375. topLevelUpdateWarnings = function (container) {
  21376. if (container._reactRootContainer && container.nodeType !== COMMENT_NODE) {
  21377. var hostInstance = findHostInstanceWithNoPortals(container._reactRootContainer._internalRoot.current);
  21378. if (hostInstance) {
  21379. if (hostInstance.parentNode !== container) {
  21380. error('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.');
  21381. }
  21382. }
  21383. }
  21384. var isRootRenderedBySomeReact = !!container._reactRootContainer;
  21385. var rootEl = getReactRootElementInContainer(container);
  21386. var hasNonRootReactChild = !!(rootEl && getInstanceFromNode(rootEl));
  21387. if (hasNonRootReactChild && !isRootRenderedBySomeReact) {
  21388. error('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.');
  21389. }
  21390. if (container.nodeType === ELEMENT_NODE && container.tagName && container.tagName.toUpperCase() === 'BODY') {
  21391. error('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.');
  21392. }
  21393. };
  21394. }
  21395. function getReactRootElementInContainer(container) {
  21396. if (!container) {
  21397. return null;
  21398. }
  21399. if (container.nodeType === DOCUMENT_NODE) {
  21400. return container.documentElement;
  21401. } else {
  21402. return container.firstChild;
  21403. }
  21404. }
  21405. function shouldHydrateDueToLegacyHeuristic(container) {
  21406. var rootElement = getReactRootElementInContainer(container);
  21407. return !!(rootElement && rootElement.nodeType === ELEMENT_NODE && rootElement.hasAttribute(ROOT_ATTRIBUTE_NAME));
  21408. }
  21409. function legacyCreateRootFromDOMContainer(container, forceHydrate) {
  21410. var shouldHydrate = forceHydrate || shouldHydrateDueToLegacyHeuristic(container); // First clear any existing content.
  21411. if (!shouldHydrate) {
  21412. var warned = false;
  21413. var rootSibling;
  21414. while (rootSibling = container.lastChild) {
  21415. {
  21416. if (!warned && rootSibling.nodeType === ELEMENT_NODE && rootSibling.hasAttribute(ROOT_ATTRIBUTE_NAME)) {
  21417. warned = true;
  21418. error('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.');
  21419. }
  21420. }
  21421. container.removeChild(rootSibling);
  21422. }
  21423. }
  21424. {
  21425. if (shouldHydrate && !forceHydrate && !warnedAboutHydrateAPI) {
  21426. warnedAboutHydrateAPI = true;
  21427. warn('render(): Calling ReactDOM.render() to hydrate server-rendered markup ' + 'will stop working in React v18. Replace the ReactDOM.render() call ' + 'with ReactDOM.hydrate() if you want React to attach to the server HTML.');
  21428. }
  21429. }
  21430. return createLegacyRoot(container, shouldHydrate ? {
  21431. hydrate: true
  21432. } : undefined);
  21433. }
  21434. function warnOnInvalidCallback$1(callback, callerName) {
  21435. {
  21436. if (callback !== null && typeof callback !== 'function') {
  21437. error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
  21438. }
  21439. }
  21440. }
  21441. function legacyRenderSubtreeIntoContainer(parentComponent, children, container, forceHydrate, callback) {
  21442. {
  21443. topLevelUpdateWarnings(container);
  21444. warnOnInvalidCallback$1(callback === undefined ? null : callback, 'render');
  21445. } // TODO: Without `any` type, Flow says "Property cannot be accessed on any
  21446. // member of intersection type." Whyyyyyy.
  21447. var root = container._reactRootContainer;
  21448. var fiberRoot;
  21449. if (!root) {
  21450. // Initial mount
  21451. root = container._reactRootContainer = legacyCreateRootFromDOMContainer(container, forceHydrate);
  21452. fiberRoot = root._internalRoot;
  21453. if (typeof callback === 'function') {
  21454. var originalCallback = callback;
  21455. callback = function () {
  21456. var instance = getPublicRootInstance(fiberRoot);
  21457. originalCallback.call(instance);
  21458. };
  21459. } // Initial mount should not be batched.
  21460. unbatchedUpdates(function () {
  21461. updateContainer(children, fiberRoot, parentComponent, callback);
  21462. });
  21463. } else {
  21464. fiberRoot = root._internalRoot;
  21465. if (typeof callback === 'function') {
  21466. var _originalCallback = callback;
  21467. callback = function () {
  21468. var instance = getPublicRootInstance(fiberRoot);
  21469. _originalCallback.call(instance);
  21470. };
  21471. } // Update
  21472. updateContainer(children, fiberRoot, parentComponent, callback);
  21473. }
  21474. return getPublicRootInstance(fiberRoot);
  21475. }
  21476. function findDOMNode(componentOrElement) {
  21477. {
  21478. var owner = ReactCurrentOwner$3.current;
  21479. if (owner !== null && owner.stateNode !== null) {
  21480. var warnedAboutRefsInRender = owner.stateNode._warnedAboutRefsInRender;
  21481. if (!warnedAboutRefsInRender) {
  21482. error('%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');
  21483. }
  21484. owner.stateNode._warnedAboutRefsInRender = true;
  21485. }
  21486. }
  21487. if (componentOrElement == null) {
  21488. return null;
  21489. }
  21490. if (componentOrElement.nodeType === ELEMENT_NODE) {
  21491. return componentOrElement;
  21492. }
  21493. {
  21494. return findHostInstanceWithWarning(componentOrElement, 'findDOMNode');
  21495. }
  21496. }
  21497. function hydrate(element, container, callback) {
  21498. if (!isValidContainer(container)) {
  21499. {
  21500. throw Error( "Target container is not a DOM element." );
  21501. }
  21502. }
  21503. {
  21504. var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined;
  21505. if (isModernRoot) {
  21506. error('You are calling ReactDOM.hydrate() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. ' + 'Did you mean to call createRoot(container, {hydrate: true}).render(element)?');
  21507. }
  21508. } // TODO: throw or warn if we couldn't hydrate?
  21509. return legacyRenderSubtreeIntoContainer(null, element, container, true, callback);
  21510. }
  21511. function render(element, container, callback) {
  21512. if (!isValidContainer(container)) {
  21513. {
  21514. throw Error( "Target container is not a DOM element." );
  21515. }
  21516. }
  21517. {
  21518. var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined;
  21519. if (isModernRoot) {
  21520. error('You are calling ReactDOM.render() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. ' + 'Did you mean to call root.render(element)?');
  21521. }
  21522. }
  21523. return legacyRenderSubtreeIntoContainer(null, element, container, false, callback);
  21524. }
  21525. function unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) {
  21526. if (!isValidContainer(containerNode)) {
  21527. {
  21528. throw Error( "Target container is not a DOM element." );
  21529. }
  21530. }
  21531. if (!(parentComponent != null && has(parentComponent))) {
  21532. {
  21533. throw Error( "parentComponent must be a valid React Component" );
  21534. }
  21535. }
  21536. return legacyRenderSubtreeIntoContainer(parentComponent, element, containerNode, false, callback);
  21537. }
  21538. function unmountComponentAtNode(container) {
  21539. if (!isValidContainer(container)) {
  21540. {
  21541. throw Error( "unmountComponentAtNode(...): Target container is not a DOM element." );
  21542. }
  21543. }
  21544. {
  21545. var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === undefined;
  21546. if (isModernRoot) {
  21547. error('You are calling ReactDOM.unmountComponentAtNode() on a container that was previously ' + 'passed to ReactDOM.createRoot(). This is not supported. Did you mean to call root.unmount()?');
  21548. }
  21549. }
  21550. if (container._reactRootContainer) {
  21551. {
  21552. var rootEl = getReactRootElementInContainer(container);
  21553. var renderedByDifferentReact = rootEl && !getInstanceFromNode(rootEl);
  21554. if (renderedByDifferentReact) {
  21555. error("unmountComponentAtNode(): The node you're attempting to unmount " + 'was rendered by another copy of React.');
  21556. }
  21557. } // Unmount should not be batched.
  21558. unbatchedUpdates(function () {
  21559. legacyRenderSubtreeIntoContainer(null, null, container, false, function () {
  21560. // $FlowFixMe This should probably use `delete container._reactRootContainer`
  21561. container._reactRootContainer = null;
  21562. unmarkContainerAsRoot(container);
  21563. });
  21564. }); // If you call unmountComponentAtNode twice in quick succession, you'll
  21565. // get `true` twice. That's probably fine?
  21566. return true;
  21567. } else {
  21568. {
  21569. var _rootEl = getReactRootElementInContainer(container);
  21570. var hasNonRootReactChild = !!(_rootEl && getInstanceFromNode(_rootEl)); // Check if the container itself is a React root node.
  21571. var isContainerReactRoot = container.nodeType === ELEMENT_NODE && isValidContainer(container.parentNode) && !!container.parentNode._reactRootContainer;
  21572. if (hasNonRootReactChild) {
  21573. error("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.');
  21574. }
  21575. }
  21576. return false;
  21577. }
  21578. }
  21579. setAttemptUserBlockingHydration(attemptUserBlockingHydration$1);
  21580. setAttemptContinuousHydration(attemptContinuousHydration$1);
  21581. setAttemptHydrationAtCurrentPriority(attemptHydrationAtCurrentPriority$1);
  21582. setAttemptHydrationAtPriority(runWithPriority$2);
  21583. var didWarnAboutUnstableCreatePortal = false;
  21584. {
  21585. if (typeof Map !== 'function' || // $FlowIssue Flow incorrectly thinks Map has no prototype
  21586. Map.prototype == null || typeof Map.prototype.forEach !== 'function' || typeof Set !== 'function' || // $FlowIssue Flow incorrectly thinks Set has no prototype
  21587. Set.prototype == null || typeof Set.prototype.clear !== 'function' || typeof Set.prototype.forEach !== 'function') {
  21588. error('React depends on Map and Set built-in types. Make sure that you load a ' + 'polyfill in older browsers. https://reactjs.org/link/react-polyfills');
  21589. }
  21590. }
  21591. setRestoreImplementation(restoreControlledState$3);
  21592. setBatchingImplementation(batchedUpdates$1, discreteUpdates$1, flushDiscreteUpdates, batchedEventUpdates$1);
  21593. function createPortal$1(children, container) {
  21594. var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  21595. if (!isValidContainer(container)) {
  21596. {
  21597. throw Error( "Target container is not a DOM element." );
  21598. }
  21599. } // TODO: pass ReactDOM portal implementation as third argument
  21600. // $FlowFixMe The Flow type is opaque but there's no way to actually create it.
  21601. return createPortal(children, container, null, key);
  21602. }
  21603. function renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) {
  21604. return unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback);
  21605. }
  21606. function unstable_createPortal(children, container) {
  21607. var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  21608. {
  21609. if (!didWarnAboutUnstableCreatePortal) {
  21610. didWarnAboutUnstableCreatePortal = true;
  21611. warn('The ReactDOM.unstable_createPortal() alias has been deprecated, ' + 'and will be removed in React 18+. Update your code to use ' + 'ReactDOM.createPortal() instead. It has the exact same API, ' + 'but without the "unstable_" prefix.');
  21612. }
  21613. }
  21614. return createPortal$1(children, container, key);
  21615. }
  21616. var Internals = {
  21617. // Keep in sync with ReactTestUtils.js, and ReactTestUtilsAct.js.
  21618. // This is an array for better minification.
  21619. Events: [getInstanceFromNode, getNodeFromInstance, getFiberCurrentPropsFromNode, enqueueStateRestore, restoreStateIfNeeded, flushPassiveEffects, // TODO: This is related to `act`, not events. Move to separate key?
  21620. IsThisRendererActing]
  21621. };
  21622. var foundDevTools = injectIntoDevTools({
  21623. findFiberByHostInstance: getClosestInstanceFromNode,
  21624. bundleType: 1 ,
  21625. version: ReactVersion,
  21626. rendererPackageName: 'react-dom'
  21627. });
  21628. {
  21629. if (!foundDevTools && canUseDOM && window.top === window.self) {
  21630. // If we're in Chrome or Firefox, provide a download link if not installed.
  21631. if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) {
  21632. var protocol = window.location.protocol; // Don't warn in exotic cases like chrome-extension://.
  21633. if (/^(https?|file):$/.test(protocol)) {
  21634. // eslint-disable-next-line react-internal/no-production-logging
  21635. console.info('%cDownload the React DevTools ' + 'for a better development experience: ' + 'https://reactjs.org/link/react-devtools' + (protocol === 'file:' ? '\nYou might need to use a local HTTP server (instead of file://): ' + 'https://reactjs.org/link/react-devtools-faq' : ''), 'font-weight:bold');
  21636. }
  21637. }
  21638. }
  21639. }
  21640. exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals;
  21641. exports.createPortal = createPortal$1;
  21642. exports.findDOMNode = findDOMNode;
  21643. exports.flushSync = flushSync;
  21644. exports.hydrate = hydrate;
  21645. exports.render = render;
  21646. exports.unmountComponentAtNode = unmountComponentAtNode;
  21647. exports.unstable_batchedUpdates = batchedUpdates$1;
  21648. exports.unstable_createPortal = unstable_createPortal;
  21649. exports.unstable_renderSubtreeIntoContainer = renderSubtreeIntoContainer;
  21650. exports.version = ReactVersion;
  21651. })();
  21652. }