react-dom-server-legacy.browser.development.js 238 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018
  1. /**
  2. * @license React
  3. * react-dom-server-legacy.browser.development.js
  4. *
  5. * Copyright (c) Facebook, Inc. and its affiliates.
  6. *
  7. * This source code is licensed under the MIT license found in the
  8. * LICENSE file in the root directory of this source tree.
  9. */
  10. 'use strict';
  11. if (process.env.NODE_ENV !== "production") {
  12. (function() {
  13. 'use strict';
  14. var React = require('react');
  15. var ReactVersion = '18.2.0';
  16. var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
  17. // by calls to these methods by a Babel plugin.
  18. //
  19. // In PROD (or in packages without access to React internals),
  20. // they are left as they are instead.
  21. function warn(format) {
  22. {
  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. }
  31. function error(format) {
  32. {
  33. {
  34. for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  35. args[_key2 - 1] = arguments[_key2];
  36. }
  37. printWarning('error', format, args);
  38. }
  39. }
  40. }
  41. function printWarning(level, format, args) {
  42. // When changing this logic, you might want to also
  43. // update consoleWithStackDev.www.js as well.
  44. {
  45. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  46. var stack = ReactDebugCurrentFrame.getStackAddendum();
  47. if (stack !== '') {
  48. format += '%s';
  49. args = args.concat([stack]);
  50. } // eslint-disable-next-line react-internal/safe-string-coercion
  51. var argsWithFormat = args.map(function (item) {
  52. return String(item);
  53. }); // Careful: RN currently depends on this prefix
  54. argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
  55. // breaks IE9: https://github.com/facebook/react/issues/13610
  56. // eslint-disable-next-line react-internal/no-production-logging
  57. Function.prototype.apply.call(console[level], console, argsWithFormat);
  58. }
  59. }
  60. function scheduleWork(callback) {
  61. callback();
  62. }
  63. function beginWriting(destination) {}
  64. function writeChunk(destination, chunk) {
  65. writeChunkAndReturn(destination, chunk);
  66. }
  67. function writeChunkAndReturn(destination, chunk) {
  68. return destination.push(chunk);
  69. }
  70. function completeWriting(destination) {}
  71. function close(destination) {
  72. destination.push(null);
  73. }
  74. function stringToChunk(content) {
  75. return content;
  76. }
  77. function stringToPrecomputedChunk(content) {
  78. return content;
  79. }
  80. function closeWithError(destination, error) {
  81. // $FlowFixMe: This is an Error object or the destination accepts other types.
  82. destination.destroy(error);
  83. }
  84. /*
  85. * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol
  86. * and Temporal.* types. See https://github.com/facebook/react/pull/22064.
  87. *
  88. * The functions in this module will throw an easier-to-understand,
  89. * easier-to-debug exception with a clear errors message message explaining the
  90. * problem. (Instead of a confusing exception thrown inside the implementation
  91. * of the `value` object).
  92. */
  93. // $FlowFixMe only called in DEV, so void return is not possible.
  94. function typeName(value) {
  95. {
  96. // toStringTag is needed for namespaced types like Temporal.Instant
  97. var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
  98. var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';
  99. return type;
  100. }
  101. } // $FlowFixMe only called in DEV, so void return is not possible.
  102. function willCoercionThrow(value) {
  103. {
  104. try {
  105. testStringCoercion(value);
  106. return false;
  107. } catch (e) {
  108. return true;
  109. }
  110. }
  111. }
  112. function testStringCoercion(value) {
  113. // If you ended up here by following an exception call stack, here's what's
  114. // happened: you supplied an object or symbol value to React (as a prop, key,
  115. // DOM attribute, CSS property, string ref, etc.) and when React tried to
  116. // coerce it to a string using `'' + value`, an exception was thrown.
  117. //
  118. // The most common types that will cause this exception are `Symbol` instances
  119. // and Temporal objects like `Temporal.Instant`. But any object that has a
  120. // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
  121. // exception. (Library authors do this to prevent users from using built-in
  122. // numeric operators like `+` or comparison operators like `>=` because custom
  123. // methods are needed to perform accurate arithmetic or comparison.)
  124. //
  125. // To fix the problem, coerce this object or symbol value to a string before
  126. // passing it to React. The most reliable way is usually `String(value)`.
  127. //
  128. // To find which value is throwing, check the browser or debugger console.
  129. // Before this exception was thrown, there should be `console.error` output
  130. // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
  131. // problem and how that type was used: key, atrribute, input value prop, etc.
  132. // In most cases, this console output also shows the component and its
  133. // ancestor components where the exception happened.
  134. //
  135. // eslint-disable-next-line react-internal/safe-string-coercion
  136. return '' + value;
  137. }
  138. function checkAttributeStringCoercion(value, attributeName) {
  139. {
  140. if (willCoercionThrow(value)) {
  141. error('The provided `%s` attribute is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', attributeName, typeName(value));
  142. return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
  143. }
  144. }
  145. }
  146. function checkCSSPropertyStringCoercion(value, propName) {
  147. {
  148. if (willCoercionThrow(value)) {
  149. error('The provided `%s` CSS property is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', propName, typeName(value));
  150. return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
  151. }
  152. }
  153. }
  154. function checkHtmlStringCoercion(value) {
  155. {
  156. if (willCoercionThrow(value)) {
  157. error('The provided HTML markup uses a value of unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));
  158. return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
  159. }
  160. }
  161. }
  162. var hasOwnProperty = Object.prototype.hasOwnProperty;
  163. // A reserved attribute.
  164. // It is handled by React separately and shouldn't be written to the DOM.
  165. var RESERVED = 0; // A simple string attribute.
  166. // Attributes that aren't in the filter are presumed to have this type.
  167. var STRING = 1; // A string attribute that accepts booleans in React. In HTML, these are called
  168. // "enumerated" attributes with "true" and "false" as possible values.
  169. // When true, it should be set to a "true" string.
  170. // When false, it should be set to a "false" string.
  171. var BOOLEANISH_STRING = 2; // A real boolean attribute.
  172. // When true, it should be present (set either to an empty string or its name).
  173. // When false, it should be omitted.
  174. var BOOLEAN = 3; // An attribute that can be used as a flag as well as with a value.
  175. // When true, it should be present (set either to an empty string or its name).
  176. // When false, it should be omitted.
  177. // For any other value, should be present with that value.
  178. var OVERLOADED_BOOLEAN = 4; // An attribute that must be numeric or parse as a numeric.
  179. // When falsy, it should be removed.
  180. var NUMERIC = 5; // An attribute that must be positive numeric or parse as a positive numeric.
  181. // When falsy, it should be removed.
  182. var POSITIVE_NUMERIC = 6;
  183. /* eslint-disable max-len */
  184. 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";
  185. /* eslint-enable max-len */
  186. var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
  187. var VALID_ATTRIBUTE_NAME_REGEX = new RegExp('^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$');
  188. var illegalAttributeNameCache = {};
  189. var validatedAttributeNameCache = {};
  190. function isAttributeNameSafe(attributeName) {
  191. if (hasOwnProperty.call(validatedAttributeNameCache, attributeName)) {
  192. return true;
  193. }
  194. if (hasOwnProperty.call(illegalAttributeNameCache, attributeName)) {
  195. return false;
  196. }
  197. if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
  198. validatedAttributeNameCache[attributeName] = true;
  199. return true;
  200. }
  201. illegalAttributeNameCache[attributeName] = true;
  202. {
  203. error('Invalid attribute name: `%s`', attributeName);
  204. }
  205. return false;
  206. }
  207. function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) {
  208. if (propertyInfo !== null && propertyInfo.type === RESERVED) {
  209. return false;
  210. }
  211. switch (typeof value) {
  212. case 'function': // $FlowIssue symbol is perfectly valid here
  213. case 'symbol':
  214. // eslint-disable-line
  215. return true;
  216. case 'boolean':
  217. {
  218. if (isCustomComponentTag) {
  219. return false;
  220. }
  221. if (propertyInfo !== null) {
  222. return !propertyInfo.acceptsBooleans;
  223. } else {
  224. var prefix = name.toLowerCase().slice(0, 5);
  225. return prefix !== 'data-' && prefix !== 'aria-';
  226. }
  227. }
  228. default:
  229. return false;
  230. }
  231. }
  232. function getPropertyInfo(name) {
  233. return properties.hasOwnProperty(name) ? properties[name] : null;
  234. }
  235. function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL, removeEmptyString) {
  236. this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN;
  237. this.attributeName = attributeName;
  238. this.attributeNamespace = attributeNamespace;
  239. this.mustUseProperty = mustUseProperty;
  240. this.propertyName = name;
  241. this.type = type;
  242. this.sanitizeURL = sanitizeURL;
  243. this.removeEmptyString = removeEmptyString;
  244. } // When adding attributes to this list, be sure to also add them to
  245. // the `possibleStandardNames` module to ensure casing and incorrect
  246. // name warnings.
  247. var properties = {}; // These props are reserved by React. They shouldn't be written to the DOM.
  248. var reservedProps = ['children', 'dangerouslySetInnerHTML', // TODO: This prevents the assignment of defaultValue to regular
  249. // elements (not just inputs). Now that ReactDOMInput assigns to the
  250. // defaultValue property -- do we need this?
  251. 'defaultValue', 'defaultChecked', 'innerHTML', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'style'];
  252. reservedProps.forEach(function (name) {
  253. properties[name] = new PropertyInfoRecord(name, RESERVED, false, // mustUseProperty
  254. name, // attributeName
  255. null, // attributeNamespace
  256. false, // sanitizeURL
  257. false);
  258. }); // A few React string attributes have a different name.
  259. // This is a mapping from React prop names to the attribute names.
  260. [['acceptCharset', 'accept-charset'], ['className', 'class'], ['htmlFor', 'for'], ['httpEquiv', 'http-equiv']].forEach(function (_ref) {
  261. var name = _ref[0],
  262. attributeName = _ref[1];
  263. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  264. attributeName, // attributeName
  265. null, // attributeNamespace
  266. false, // sanitizeURL
  267. false);
  268. }); // These are "enumerated" HTML attributes that accept "true" and "false".
  269. // In React, we let users pass `true` and `false` even though technically
  270. // these aren't boolean attributes (they are coerced to strings).
  271. ['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(function (name) {
  272. properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
  273. name.toLowerCase(), // attributeName
  274. null, // attributeNamespace
  275. false, // sanitizeURL
  276. false);
  277. }); // These are "enumerated" SVG attributes that accept "true" and "false".
  278. // In React, we let users pass `true` and `false` even though technically
  279. // these aren't boolean attributes (they are coerced to strings).
  280. // Since these are SVG attributes, their attribute names are case-sensitive.
  281. ['autoReverse', 'externalResourcesRequired', 'focusable', 'preserveAlpha'].forEach(function (name) {
  282. properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, // mustUseProperty
  283. name, // attributeName
  284. null, // attributeNamespace
  285. false, // sanitizeURL
  286. false);
  287. }); // These are HTML boolean attributes.
  288. ['allowFullScreen', 'async', // Note: there is a special case that prevents it from being written to the DOM
  289. // on the client side because the browsers are inconsistent. Instead we call focus().
  290. 'autoFocus', 'autoPlay', 'controls', 'default', 'defer', 'disabled', 'disablePictureInPicture', 'disableRemotePlayback', 'formNoValidate', 'hidden', 'loop', 'noModule', 'noValidate', 'open', 'playsInline', 'readOnly', 'required', 'reversed', 'scoped', 'seamless', // Microdata
  291. 'itemScope'].forEach(function (name) {
  292. properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, // mustUseProperty
  293. name.toLowerCase(), // attributeName
  294. null, // attributeNamespace
  295. false, // sanitizeURL
  296. false);
  297. }); // These are the few React props that we set as DOM properties
  298. // rather than attributes. These are all booleans.
  299. ['checked', // Note: `option.selected` is not updated if `select.multiple` is
  300. // disabled with `removeAttribute`. We have special logic for handling this.
  301. 'multiple', 'muted', 'selected' // NOTE: if you add a camelCased prop to this list,
  302. // you'll need to set attributeName to name.toLowerCase()
  303. // instead in the assignment below.
  304. ].forEach(function (name) {
  305. properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, // mustUseProperty
  306. name, // attributeName
  307. null, // attributeNamespace
  308. false, // sanitizeURL
  309. false);
  310. }); // These are HTML attributes that are "overloaded booleans": they behave like
  311. // booleans, but can also accept a string value.
  312. ['capture', 'download' // NOTE: if you add a camelCased prop to this list,
  313. // you'll need to set attributeName to name.toLowerCase()
  314. // instead in the assignment below.
  315. ].forEach(function (name) {
  316. properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, // mustUseProperty
  317. name, // attributeName
  318. null, // attributeNamespace
  319. false, // sanitizeURL
  320. false);
  321. }); // These are HTML attributes that must be positive numbers.
  322. ['cols', 'rows', 'size', 'span' // NOTE: if you add a camelCased prop to this list,
  323. // you'll need to set attributeName to name.toLowerCase()
  324. // instead in the assignment below.
  325. ].forEach(function (name) {
  326. properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, // mustUseProperty
  327. name, // attributeName
  328. null, // attributeNamespace
  329. false, // sanitizeURL
  330. false);
  331. }); // These are HTML attributes that must be numbers.
  332. ['rowSpan', 'start'].forEach(function (name) {
  333. properties[name] = new PropertyInfoRecord(name, NUMERIC, false, // mustUseProperty
  334. name.toLowerCase(), // attributeName
  335. null, // attributeNamespace
  336. false, // sanitizeURL
  337. false);
  338. });
  339. var CAMELIZE = /[\-\:]([a-z])/g;
  340. var capitalize = function (token) {
  341. return token[1].toUpperCase();
  342. }; // This is a list of all SVG attributes that need special casing, namespacing,
  343. // or boolean value assignment. Regular attributes that just accept strings
  344. // and have the same names are omitted, just like in the HTML attribute filter.
  345. // Some of these attributes can be hard to find. This list was created by
  346. // scraping the MDN documentation.
  347. ['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,
  348. // you'll need to set attributeName to name.toLowerCase()
  349. // instead in the assignment below.
  350. ].forEach(function (attributeName) {
  351. var name = attributeName.replace(CAMELIZE, capitalize);
  352. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  353. attributeName, null, // attributeNamespace
  354. false, // sanitizeURL
  355. false);
  356. }); // String SVG attributes with the xlink namespace.
  357. ['xlink:actuate', 'xlink:arcrole', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type' // NOTE: if you add a camelCased prop to this list,
  358. // you'll need to set attributeName to name.toLowerCase()
  359. // instead in the assignment below.
  360. ].forEach(function (attributeName) {
  361. var name = attributeName.replace(CAMELIZE, capitalize);
  362. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  363. attributeName, 'http://www.w3.org/1999/xlink', false, // sanitizeURL
  364. false);
  365. }); // String SVG attributes with the xml namespace.
  366. ['xml:base', 'xml:lang', 'xml:space' // NOTE: if you add a camelCased prop to this list,
  367. // you'll need to set attributeName to name.toLowerCase()
  368. // instead in the assignment below.
  369. ].forEach(function (attributeName) {
  370. var name = attributeName.replace(CAMELIZE, capitalize);
  371. properties[name] = new PropertyInfoRecord(name, STRING, false, // mustUseProperty
  372. attributeName, 'http://www.w3.org/XML/1998/namespace', false, // sanitizeURL
  373. false);
  374. }); // These attribute exists both in HTML and SVG.
  375. // The attribute name is case-sensitive in SVG so we can't just use
  376. // the React name like we do for attributes that exist only in HTML.
  377. ['tabIndex', 'crossOrigin'].forEach(function (attributeName) {
  378. properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
  379. attributeName.toLowerCase(), // attributeName
  380. null, // attributeNamespace
  381. false, // sanitizeURL
  382. false);
  383. }); // These attributes accept URLs. These must not allow javascript: URLS.
  384. // These will also need to accept Trusted Types object in the future.
  385. var xlinkHref = 'xlinkHref';
  386. properties[xlinkHref] = new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty
  387. 'xlink:href', 'http://www.w3.org/1999/xlink', true, // sanitizeURL
  388. false);
  389. ['src', 'href', 'action', 'formAction'].forEach(function (attributeName) {
  390. properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
  391. attributeName.toLowerCase(), // attributeName
  392. null, // attributeNamespace
  393. true, // sanitizeURL
  394. true);
  395. });
  396. /**
  397. * CSS properties which accept numbers but are not in units of "px".
  398. */
  399. var isUnitlessNumber = {
  400. animationIterationCount: true,
  401. aspectRatio: true,
  402. borderImageOutset: true,
  403. borderImageSlice: true,
  404. borderImageWidth: true,
  405. boxFlex: true,
  406. boxFlexGroup: true,
  407. boxOrdinalGroup: true,
  408. columnCount: true,
  409. columns: true,
  410. flex: true,
  411. flexGrow: true,
  412. flexPositive: true,
  413. flexShrink: true,
  414. flexNegative: true,
  415. flexOrder: true,
  416. gridArea: true,
  417. gridRow: true,
  418. gridRowEnd: true,
  419. gridRowSpan: true,
  420. gridRowStart: true,
  421. gridColumn: true,
  422. gridColumnEnd: true,
  423. gridColumnSpan: true,
  424. gridColumnStart: true,
  425. fontWeight: true,
  426. lineClamp: true,
  427. lineHeight: true,
  428. opacity: true,
  429. order: true,
  430. orphans: true,
  431. tabSize: true,
  432. widows: true,
  433. zIndex: true,
  434. zoom: true,
  435. // SVG-related properties
  436. fillOpacity: true,
  437. floodOpacity: true,
  438. stopOpacity: true,
  439. strokeDasharray: true,
  440. strokeDashoffset: true,
  441. strokeMiterlimit: true,
  442. strokeOpacity: true,
  443. strokeWidth: true
  444. };
  445. /**
  446. * @param {string} prefix vendor-specific prefix, eg: Webkit
  447. * @param {string} key style name, eg: transitionDuration
  448. * @return {string} style name prefixed with `prefix`, properly camelCased, eg:
  449. * WebkitTransitionDuration
  450. */
  451. function prefixKey(prefix, key) {
  452. return prefix + key.charAt(0).toUpperCase() + key.substring(1);
  453. }
  454. /**
  455. * Support style names that may come passed in prefixed by adding permutations
  456. * of vendor prefixes.
  457. */
  458. var prefixes = ['Webkit', 'ms', 'Moz', 'O']; // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
  459. // infinite loop, because it iterates over the newly added props too.
  460. Object.keys(isUnitlessNumber).forEach(function (prop) {
  461. prefixes.forEach(function (prefix) {
  462. isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
  463. });
  464. });
  465. var hasReadOnlyValue = {
  466. button: true,
  467. checkbox: true,
  468. image: true,
  469. hidden: true,
  470. radio: true,
  471. reset: true,
  472. submit: true
  473. };
  474. function checkControlledValueProps(tagName, props) {
  475. {
  476. if (!(hasReadOnlyValue[props.type] || props.onChange || props.onInput || props.readOnly || props.disabled || props.value == null)) {
  477. 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`.');
  478. }
  479. if (!(props.onChange || props.readOnly || props.disabled || props.checked == null)) {
  480. 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`.');
  481. }
  482. }
  483. }
  484. function isCustomComponent(tagName, props) {
  485. if (tagName.indexOf('-') === -1) {
  486. return typeof props.is === 'string';
  487. }
  488. switch (tagName) {
  489. // These are reserved SVG and MathML elements.
  490. // We don't mind this list too much because we expect it to never grow.
  491. // The alternative is to track the namespace in a few places which is convoluted.
  492. // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
  493. case 'annotation-xml':
  494. case 'color-profile':
  495. case 'font-face':
  496. case 'font-face-src':
  497. case 'font-face-uri':
  498. case 'font-face-format':
  499. case 'font-face-name':
  500. case 'missing-glyph':
  501. return false;
  502. default:
  503. return true;
  504. }
  505. }
  506. var ariaProperties = {
  507. 'aria-current': 0,
  508. // state
  509. 'aria-description': 0,
  510. 'aria-details': 0,
  511. 'aria-disabled': 0,
  512. // state
  513. 'aria-hidden': 0,
  514. // state
  515. 'aria-invalid': 0,
  516. // state
  517. 'aria-keyshortcuts': 0,
  518. 'aria-label': 0,
  519. 'aria-roledescription': 0,
  520. // Widget Attributes
  521. 'aria-autocomplete': 0,
  522. 'aria-checked': 0,
  523. 'aria-expanded': 0,
  524. 'aria-haspopup': 0,
  525. 'aria-level': 0,
  526. 'aria-modal': 0,
  527. 'aria-multiline': 0,
  528. 'aria-multiselectable': 0,
  529. 'aria-orientation': 0,
  530. 'aria-placeholder': 0,
  531. 'aria-pressed': 0,
  532. 'aria-readonly': 0,
  533. 'aria-required': 0,
  534. 'aria-selected': 0,
  535. 'aria-sort': 0,
  536. 'aria-valuemax': 0,
  537. 'aria-valuemin': 0,
  538. 'aria-valuenow': 0,
  539. 'aria-valuetext': 0,
  540. // Live Region Attributes
  541. 'aria-atomic': 0,
  542. 'aria-busy': 0,
  543. 'aria-live': 0,
  544. 'aria-relevant': 0,
  545. // Drag-and-Drop Attributes
  546. 'aria-dropeffect': 0,
  547. 'aria-grabbed': 0,
  548. // Relationship Attributes
  549. 'aria-activedescendant': 0,
  550. 'aria-colcount': 0,
  551. 'aria-colindex': 0,
  552. 'aria-colspan': 0,
  553. 'aria-controls': 0,
  554. 'aria-describedby': 0,
  555. 'aria-errormessage': 0,
  556. 'aria-flowto': 0,
  557. 'aria-labelledby': 0,
  558. 'aria-owns': 0,
  559. 'aria-posinset': 0,
  560. 'aria-rowcount': 0,
  561. 'aria-rowindex': 0,
  562. 'aria-rowspan': 0,
  563. 'aria-setsize': 0
  564. };
  565. var warnedProperties = {};
  566. var rARIA = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
  567. var rARIACamel = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
  568. function validateProperty(tagName, name) {
  569. {
  570. if (hasOwnProperty.call(warnedProperties, name) && warnedProperties[name]) {
  571. return true;
  572. }
  573. if (rARIACamel.test(name)) {
  574. var ariaName = 'aria-' + name.slice(4).toLowerCase();
  575. var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null; // If this is an aria-* attribute, but is not listed in the known DOM
  576. // DOM properties, then it is an invalid aria-* attribute.
  577. if (correctName == null) {
  578. error('Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.', name);
  579. warnedProperties[name] = true;
  580. return true;
  581. } // aria-* attributes should be lowercase; suggest the lowercase version.
  582. if (name !== correctName) {
  583. error('Invalid ARIA attribute `%s`. Did you mean `%s`?', name, correctName);
  584. warnedProperties[name] = true;
  585. return true;
  586. }
  587. }
  588. if (rARIA.test(name)) {
  589. var lowerCasedName = name.toLowerCase();
  590. var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null; // If this is an aria-* attribute, but is not listed in the known DOM
  591. // DOM properties, then it is an invalid aria-* attribute.
  592. if (standardName == null) {
  593. warnedProperties[name] = true;
  594. return false;
  595. } // aria-* attributes should be lowercase; suggest the lowercase version.
  596. if (name !== standardName) {
  597. error('Unknown ARIA attribute `%s`. Did you mean `%s`?', name, standardName);
  598. warnedProperties[name] = true;
  599. return true;
  600. }
  601. }
  602. }
  603. return true;
  604. }
  605. function warnInvalidARIAProps(type, props) {
  606. {
  607. var invalidProps = [];
  608. for (var key in props) {
  609. var isValid = validateProperty(type, key);
  610. if (!isValid) {
  611. invalidProps.push(key);
  612. }
  613. }
  614. var unknownPropString = invalidProps.map(function (prop) {
  615. return '`' + prop + '`';
  616. }).join(', ');
  617. if (invalidProps.length === 1) {
  618. error('Invalid aria prop %s on <%s> tag. ' + 'For details, see https://reactjs.org/link/invalid-aria-props', unknownPropString, type);
  619. } else if (invalidProps.length > 1) {
  620. error('Invalid aria props %s on <%s> tag. ' + 'For details, see https://reactjs.org/link/invalid-aria-props', unknownPropString, type);
  621. }
  622. }
  623. }
  624. function validateProperties(type, props) {
  625. if (isCustomComponent(type, props)) {
  626. return;
  627. }
  628. warnInvalidARIAProps(type, props);
  629. }
  630. var didWarnValueNull = false;
  631. function validateProperties$1(type, props) {
  632. {
  633. if (type !== 'input' && type !== 'textarea' && type !== 'select') {
  634. return;
  635. }
  636. if (props != null && props.value === null && !didWarnValueNull) {
  637. didWarnValueNull = true;
  638. if (type === 'select' && props.multiple) {
  639. 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);
  640. } else {
  641. error('`value` prop on `%s` should not be null. ' + 'Consider using an empty string to clear the component or `undefined` ' + 'for uncontrolled components.', type);
  642. }
  643. }
  644. }
  645. }
  646. // When adding attributes to the HTML or SVG allowed attribute list, be sure to
  647. // also add them to this module to ensure casing and incorrect name
  648. // warnings.
  649. var possibleStandardNames = {
  650. // HTML
  651. accept: 'accept',
  652. acceptcharset: 'acceptCharset',
  653. 'accept-charset': 'acceptCharset',
  654. accesskey: 'accessKey',
  655. action: 'action',
  656. allowfullscreen: 'allowFullScreen',
  657. alt: 'alt',
  658. as: 'as',
  659. async: 'async',
  660. autocapitalize: 'autoCapitalize',
  661. autocomplete: 'autoComplete',
  662. autocorrect: 'autoCorrect',
  663. autofocus: 'autoFocus',
  664. autoplay: 'autoPlay',
  665. autosave: 'autoSave',
  666. capture: 'capture',
  667. cellpadding: 'cellPadding',
  668. cellspacing: 'cellSpacing',
  669. challenge: 'challenge',
  670. charset: 'charSet',
  671. checked: 'checked',
  672. children: 'children',
  673. cite: 'cite',
  674. class: 'className',
  675. classid: 'classID',
  676. classname: 'className',
  677. cols: 'cols',
  678. colspan: 'colSpan',
  679. content: 'content',
  680. contenteditable: 'contentEditable',
  681. contextmenu: 'contextMenu',
  682. controls: 'controls',
  683. controlslist: 'controlsList',
  684. coords: 'coords',
  685. crossorigin: 'crossOrigin',
  686. dangerouslysetinnerhtml: 'dangerouslySetInnerHTML',
  687. data: 'data',
  688. datetime: 'dateTime',
  689. default: 'default',
  690. defaultchecked: 'defaultChecked',
  691. defaultvalue: 'defaultValue',
  692. defer: 'defer',
  693. dir: 'dir',
  694. disabled: 'disabled',
  695. disablepictureinpicture: 'disablePictureInPicture',
  696. disableremoteplayback: 'disableRemotePlayback',
  697. download: 'download',
  698. draggable: 'draggable',
  699. enctype: 'encType',
  700. enterkeyhint: 'enterKeyHint',
  701. for: 'htmlFor',
  702. form: 'form',
  703. formmethod: 'formMethod',
  704. formaction: 'formAction',
  705. formenctype: 'formEncType',
  706. formnovalidate: 'formNoValidate',
  707. formtarget: 'formTarget',
  708. frameborder: 'frameBorder',
  709. headers: 'headers',
  710. height: 'height',
  711. hidden: 'hidden',
  712. high: 'high',
  713. href: 'href',
  714. hreflang: 'hrefLang',
  715. htmlfor: 'htmlFor',
  716. httpequiv: 'httpEquiv',
  717. 'http-equiv': 'httpEquiv',
  718. icon: 'icon',
  719. id: 'id',
  720. imagesizes: 'imageSizes',
  721. imagesrcset: 'imageSrcSet',
  722. innerhtml: 'innerHTML',
  723. inputmode: 'inputMode',
  724. integrity: 'integrity',
  725. is: 'is',
  726. itemid: 'itemID',
  727. itemprop: 'itemProp',
  728. itemref: 'itemRef',
  729. itemscope: 'itemScope',
  730. itemtype: 'itemType',
  731. keyparams: 'keyParams',
  732. keytype: 'keyType',
  733. kind: 'kind',
  734. label: 'label',
  735. lang: 'lang',
  736. list: 'list',
  737. loop: 'loop',
  738. low: 'low',
  739. manifest: 'manifest',
  740. marginwidth: 'marginWidth',
  741. marginheight: 'marginHeight',
  742. max: 'max',
  743. maxlength: 'maxLength',
  744. media: 'media',
  745. mediagroup: 'mediaGroup',
  746. method: 'method',
  747. min: 'min',
  748. minlength: 'minLength',
  749. multiple: 'multiple',
  750. muted: 'muted',
  751. name: 'name',
  752. nomodule: 'noModule',
  753. nonce: 'nonce',
  754. novalidate: 'noValidate',
  755. open: 'open',
  756. optimum: 'optimum',
  757. pattern: 'pattern',
  758. placeholder: 'placeholder',
  759. playsinline: 'playsInline',
  760. poster: 'poster',
  761. preload: 'preload',
  762. profile: 'profile',
  763. radiogroup: 'radioGroup',
  764. readonly: 'readOnly',
  765. referrerpolicy: 'referrerPolicy',
  766. rel: 'rel',
  767. required: 'required',
  768. reversed: 'reversed',
  769. role: 'role',
  770. rows: 'rows',
  771. rowspan: 'rowSpan',
  772. sandbox: 'sandbox',
  773. scope: 'scope',
  774. scoped: 'scoped',
  775. scrolling: 'scrolling',
  776. seamless: 'seamless',
  777. selected: 'selected',
  778. shape: 'shape',
  779. size: 'size',
  780. sizes: 'sizes',
  781. span: 'span',
  782. spellcheck: 'spellCheck',
  783. src: 'src',
  784. srcdoc: 'srcDoc',
  785. srclang: 'srcLang',
  786. srcset: 'srcSet',
  787. start: 'start',
  788. step: 'step',
  789. style: 'style',
  790. summary: 'summary',
  791. tabindex: 'tabIndex',
  792. target: 'target',
  793. title: 'title',
  794. type: 'type',
  795. usemap: 'useMap',
  796. value: 'value',
  797. width: 'width',
  798. wmode: 'wmode',
  799. wrap: 'wrap',
  800. // SVG
  801. about: 'about',
  802. accentheight: 'accentHeight',
  803. 'accent-height': 'accentHeight',
  804. accumulate: 'accumulate',
  805. additive: 'additive',
  806. alignmentbaseline: 'alignmentBaseline',
  807. 'alignment-baseline': 'alignmentBaseline',
  808. allowreorder: 'allowReorder',
  809. alphabetic: 'alphabetic',
  810. amplitude: 'amplitude',
  811. arabicform: 'arabicForm',
  812. 'arabic-form': 'arabicForm',
  813. ascent: 'ascent',
  814. attributename: 'attributeName',
  815. attributetype: 'attributeType',
  816. autoreverse: 'autoReverse',
  817. azimuth: 'azimuth',
  818. basefrequency: 'baseFrequency',
  819. baselineshift: 'baselineShift',
  820. 'baseline-shift': 'baselineShift',
  821. baseprofile: 'baseProfile',
  822. bbox: 'bbox',
  823. begin: 'begin',
  824. bias: 'bias',
  825. by: 'by',
  826. calcmode: 'calcMode',
  827. capheight: 'capHeight',
  828. 'cap-height': 'capHeight',
  829. clip: 'clip',
  830. clippath: 'clipPath',
  831. 'clip-path': 'clipPath',
  832. clippathunits: 'clipPathUnits',
  833. cliprule: 'clipRule',
  834. 'clip-rule': 'clipRule',
  835. color: 'color',
  836. colorinterpolation: 'colorInterpolation',
  837. 'color-interpolation': 'colorInterpolation',
  838. colorinterpolationfilters: 'colorInterpolationFilters',
  839. 'color-interpolation-filters': 'colorInterpolationFilters',
  840. colorprofile: 'colorProfile',
  841. 'color-profile': 'colorProfile',
  842. colorrendering: 'colorRendering',
  843. 'color-rendering': 'colorRendering',
  844. contentscripttype: 'contentScriptType',
  845. contentstyletype: 'contentStyleType',
  846. cursor: 'cursor',
  847. cx: 'cx',
  848. cy: 'cy',
  849. d: 'd',
  850. datatype: 'datatype',
  851. decelerate: 'decelerate',
  852. descent: 'descent',
  853. diffuseconstant: 'diffuseConstant',
  854. direction: 'direction',
  855. display: 'display',
  856. divisor: 'divisor',
  857. dominantbaseline: 'dominantBaseline',
  858. 'dominant-baseline': 'dominantBaseline',
  859. dur: 'dur',
  860. dx: 'dx',
  861. dy: 'dy',
  862. edgemode: 'edgeMode',
  863. elevation: 'elevation',
  864. enablebackground: 'enableBackground',
  865. 'enable-background': 'enableBackground',
  866. end: 'end',
  867. exponent: 'exponent',
  868. externalresourcesrequired: 'externalResourcesRequired',
  869. fill: 'fill',
  870. fillopacity: 'fillOpacity',
  871. 'fill-opacity': 'fillOpacity',
  872. fillrule: 'fillRule',
  873. 'fill-rule': 'fillRule',
  874. filter: 'filter',
  875. filterres: 'filterRes',
  876. filterunits: 'filterUnits',
  877. floodopacity: 'floodOpacity',
  878. 'flood-opacity': 'floodOpacity',
  879. floodcolor: 'floodColor',
  880. 'flood-color': 'floodColor',
  881. focusable: 'focusable',
  882. fontfamily: 'fontFamily',
  883. 'font-family': 'fontFamily',
  884. fontsize: 'fontSize',
  885. 'font-size': 'fontSize',
  886. fontsizeadjust: 'fontSizeAdjust',
  887. 'font-size-adjust': 'fontSizeAdjust',
  888. fontstretch: 'fontStretch',
  889. 'font-stretch': 'fontStretch',
  890. fontstyle: 'fontStyle',
  891. 'font-style': 'fontStyle',
  892. fontvariant: 'fontVariant',
  893. 'font-variant': 'fontVariant',
  894. fontweight: 'fontWeight',
  895. 'font-weight': 'fontWeight',
  896. format: 'format',
  897. from: 'from',
  898. fx: 'fx',
  899. fy: 'fy',
  900. g1: 'g1',
  901. g2: 'g2',
  902. glyphname: 'glyphName',
  903. 'glyph-name': 'glyphName',
  904. glyphorientationhorizontal: 'glyphOrientationHorizontal',
  905. 'glyph-orientation-horizontal': 'glyphOrientationHorizontal',
  906. glyphorientationvertical: 'glyphOrientationVertical',
  907. 'glyph-orientation-vertical': 'glyphOrientationVertical',
  908. glyphref: 'glyphRef',
  909. gradienttransform: 'gradientTransform',
  910. gradientunits: 'gradientUnits',
  911. hanging: 'hanging',
  912. horizadvx: 'horizAdvX',
  913. 'horiz-adv-x': 'horizAdvX',
  914. horizoriginx: 'horizOriginX',
  915. 'horiz-origin-x': 'horizOriginX',
  916. ideographic: 'ideographic',
  917. imagerendering: 'imageRendering',
  918. 'image-rendering': 'imageRendering',
  919. in2: 'in2',
  920. in: 'in',
  921. inlist: 'inlist',
  922. intercept: 'intercept',
  923. k1: 'k1',
  924. k2: 'k2',
  925. k3: 'k3',
  926. k4: 'k4',
  927. k: 'k',
  928. kernelmatrix: 'kernelMatrix',
  929. kernelunitlength: 'kernelUnitLength',
  930. kerning: 'kerning',
  931. keypoints: 'keyPoints',
  932. keysplines: 'keySplines',
  933. keytimes: 'keyTimes',
  934. lengthadjust: 'lengthAdjust',
  935. letterspacing: 'letterSpacing',
  936. 'letter-spacing': 'letterSpacing',
  937. lightingcolor: 'lightingColor',
  938. 'lighting-color': 'lightingColor',
  939. limitingconeangle: 'limitingConeAngle',
  940. local: 'local',
  941. markerend: 'markerEnd',
  942. 'marker-end': 'markerEnd',
  943. markerheight: 'markerHeight',
  944. markermid: 'markerMid',
  945. 'marker-mid': 'markerMid',
  946. markerstart: 'markerStart',
  947. 'marker-start': 'markerStart',
  948. markerunits: 'markerUnits',
  949. markerwidth: 'markerWidth',
  950. mask: 'mask',
  951. maskcontentunits: 'maskContentUnits',
  952. maskunits: 'maskUnits',
  953. mathematical: 'mathematical',
  954. mode: 'mode',
  955. numoctaves: 'numOctaves',
  956. offset: 'offset',
  957. opacity: 'opacity',
  958. operator: 'operator',
  959. order: 'order',
  960. orient: 'orient',
  961. orientation: 'orientation',
  962. origin: 'origin',
  963. overflow: 'overflow',
  964. overlineposition: 'overlinePosition',
  965. 'overline-position': 'overlinePosition',
  966. overlinethickness: 'overlineThickness',
  967. 'overline-thickness': 'overlineThickness',
  968. paintorder: 'paintOrder',
  969. 'paint-order': 'paintOrder',
  970. panose1: 'panose1',
  971. 'panose-1': 'panose1',
  972. pathlength: 'pathLength',
  973. patterncontentunits: 'patternContentUnits',
  974. patterntransform: 'patternTransform',
  975. patternunits: 'patternUnits',
  976. pointerevents: 'pointerEvents',
  977. 'pointer-events': 'pointerEvents',
  978. points: 'points',
  979. pointsatx: 'pointsAtX',
  980. pointsaty: 'pointsAtY',
  981. pointsatz: 'pointsAtZ',
  982. prefix: 'prefix',
  983. preservealpha: 'preserveAlpha',
  984. preserveaspectratio: 'preserveAspectRatio',
  985. primitiveunits: 'primitiveUnits',
  986. property: 'property',
  987. r: 'r',
  988. radius: 'radius',
  989. refx: 'refX',
  990. refy: 'refY',
  991. renderingintent: 'renderingIntent',
  992. 'rendering-intent': 'renderingIntent',
  993. repeatcount: 'repeatCount',
  994. repeatdur: 'repeatDur',
  995. requiredextensions: 'requiredExtensions',
  996. requiredfeatures: 'requiredFeatures',
  997. resource: 'resource',
  998. restart: 'restart',
  999. result: 'result',
  1000. results: 'results',
  1001. rotate: 'rotate',
  1002. rx: 'rx',
  1003. ry: 'ry',
  1004. scale: 'scale',
  1005. security: 'security',
  1006. seed: 'seed',
  1007. shaperendering: 'shapeRendering',
  1008. 'shape-rendering': 'shapeRendering',
  1009. slope: 'slope',
  1010. spacing: 'spacing',
  1011. specularconstant: 'specularConstant',
  1012. specularexponent: 'specularExponent',
  1013. speed: 'speed',
  1014. spreadmethod: 'spreadMethod',
  1015. startoffset: 'startOffset',
  1016. stddeviation: 'stdDeviation',
  1017. stemh: 'stemh',
  1018. stemv: 'stemv',
  1019. stitchtiles: 'stitchTiles',
  1020. stopcolor: 'stopColor',
  1021. 'stop-color': 'stopColor',
  1022. stopopacity: 'stopOpacity',
  1023. 'stop-opacity': 'stopOpacity',
  1024. strikethroughposition: 'strikethroughPosition',
  1025. 'strikethrough-position': 'strikethroughPosition',
  1026. strikethroughthickness: 'strikethroughThickness',
  1027. 'strikethrough-thickness': 'strikethroughThickness',
  1028. string: 'string',
  1029. stroke: 'stroke',
  1030. strokedasharray: 'strokeDasharray',
  1031. 'stroke-dasharray': 'strokeDasharray',
  1032. strokedashoffset: 'strokeDashoffset',
  1033. 'stroke-dashoffset': 'strokeDashoffset',
  1034. strokelinecap: 'strokeLinecap',
  1035. 'stroke-linecap': 'strokeLinecap',
  1036. strokelinejoin: 'strokeLinejoin',
  1037. 'stroke-linejoin': 'strokeLinejoin',
  1038. strokemiterlimit: 'strokeMiterlimit',
  1039. 'stroke-miterlimit': 'strokeMiterlimit',
  1040. strokewidth: 'strokeWidth',
  1041. 'stroke-width': 'strokeWidth',
  1042. strokeopacity: 'strokeOpacity',
  1043. 'stroke-opacity': 'strokeOpacity',
  1044. suppresscontenteditablewarning: 'suppressContentEditableWarning',
  1045. suppresshydrationwarning: 'suppressHydrationWarning',
  1046. surfacescale: 'surfaceScale',
  1047. systemlanguage: 'systemLanguage',
  1048. tablevalues: 'tableValues',
  1049. targetx: 'targetX',
  1050. targety: 'targetY',
  1051. textanchor: 'textAnchor',
  1052. 'text-anchor': 'textAnchor',
  1053. textdecoration: 'textDecoration',
  1054. 'text-decoration': 'textDecoration',
  1055. textlength: 'textLength',
  1056. textrendering: 'textRendering',
  1057. 'text-rendering': 'textRendering',
  1058. to: 'to',
  1059. transform: 'transform',
  1060. typeof: 'typeof',
  1061. u1: 'u1',
  1062. u2: 'u2',
  1063. underlineposition: 'underlinePosition',
  1064. 'underline-position': 'underlinePosition',
  1065. underlinethickness: 'underlineThickness',
  1066. 'underline-thickness': 'underlineThickness',
  1067. unicode: 'unicode',
  1068. unicodebidi: 'unicodeBidi',
  1069. 'unicode-bidi': 'unicodeBidi',
  1070. unicoderange: 'unicodeRange',
  1071. 'unicode-range': 'unicodeRange',
  1072. unitsperem: 'unitsPerEm',
  1073. 'units-per-em': 'unitsPerEm',
  1074. unselectable: 'unselectable',
  1075. valphabetic: 'vAlphabetic',
  1076. 'v-alphabetic': 'vAlphabetic',
  1077. values: 'values',
  1078. vectoreffect: 'vectorEffect',
  1079. 'vector-effect': 'vectorEffect',
  1080. version: 'version',
  1081. vertadvy: 'vertAdvY',
  1082. 'vert-adv-y': 'vertAdvY',
  1083. vertoriginx: 'vertOriginX',
  1084. 'vert-origin-x': 'vertOriginX',
  1085. vertoriginy: 'vertOriginY',
  1086. 'vert-origin-y': 'vertOriginY',
  1087. vhanging: 'vHanging',
  1088. 'v-hanging': 'vHanging',
  1089. videographic: 'vIdeographic',
  1090. 'v-ideographic': 'vIdeographic',
  1091. viewbox: 'viewBox',
  1092. viewtarget: 'viewTarget',
  1093. visibility: 'visibility',
  1094. vmathematical: 'vMathematical',
  1095. 'v-mathematical': 'vMathematical',
  1096. vocab: 'vocab',
  1097. widths: 'widths',
  1098. wordspacing: 'wordSpacing',
  1099. 'word-spacing': 'wordSpacing',
  1100. writingmode: 'writingMode',
  1101. 'writing-mode': 'writingMode',
  1102. x1: 'x1',
  1103. x2: 'x2',
  1104. x: 'x',
  1105. xchannelselector: 'xChannelSelector',
  1106. xheight: 'xHeight',
  1107. 'x-height': 'xHeight',
  1108. xlinkactuate: 'xlinkActuate',
  1109. 'xlink:actuate': 'xlinkActuate',
  1110. xlinkarcrole: 'xlinkArcrole',
  1111. 'xlink:arcrole': 'xlinkArcrole',
  1112. xlinkhref: 'xlinkHref',
  1113. 'xlink:href': 'xlinkHref',
  1114. xlinkrole: 'xlinkRole',
  1115. 'xlink:role': 'xlinkRole',
  1116. xlinkshow: 'xlinkShow',
  1117. 'xlink:show': 'xlinkShow',
  1118. xlinktitle: 'xlinkTitle',
  1119. 'xlink:title': 'xlinkTitle',
  1120. xlinktype: 'xlinkType',
  1121. 'xlink:type': 'xlinkType',
  1122. xmlbase: 'xmlBase',
  1123. 'xml:base': 'xmlBase',
  1124. xmllang: 'xmlLang',
  1125. 'xml:lang': 'xmlLang',
  1126. xmlns: 'xmlns',
  1127. 'xml:space': 'xmlSpace',
  1128. xmlnsxlink: 'xmlnsXlink',
  1129. 'xmlns:xlink': 'xmlnsXlink',
  1130. xmlspace: 'xmlSpace',
  1131. y1: 'y1',
  1132. y2: 'y2',
  1133. y: 'y',
  1134. ychannelselector: 'yChannelSelector',
  1135. z: 'z',
  1136. zoomandpan: 'zoomAndPan'
  1137. };
  1138. var validateProperty$1 = function () {};
  1139. {
  1140. var warnedProperties$1 = {};
  1141. var EVENT_NAME_REGEX = /^on./;
  1142. var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/;
  1143. var rARIA$1 = new RegExp('^(aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$');
  1144. var rARIACamel$1 = new RegExp('^(aria)[A-Z][' + ATTRIBUTE_NAME_CHAR + ']*$');
  1145. validateProperty$1 = function (tagName, name, value, eventRegistry) {
  1146. if (hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) {
  1147. return true;
  1148. }
  1149. var lowerCasedName = name.toLowerCase();
  1150. if (lowerCasedName === 'onfocusin' || lowerCasedName === 'onfocusout') {
  1151. 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.');
  1152. warnedProperties$1[name] = true;
  1153. return true;
  1154. } // We can't rely on the event system being injected on the server.
  1155. if (eventRegistry != null) {
  1156. var registrationNameDependencies = eventRegistry.registrationNameDependencies,
  1157. possibleRegistrationNames = eventRegistry.possibleRegistrationNames;
  1158. if (registrationNameDependencies.hasOwnProperty(name)) {
  1159. return true;
  1160. }
  1161. var registrationName = possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames[lowerCasedName] : null;
  1162. if (registrationName != null) {
  1163. error('Invalid event handler property `%s`. Did you mean `%s`?', name, registrationName);
  1164. warnedProperties$1[name] = true;
  1165. return true;
  1166. }
  1167. if (EVENT_NAME_REGEX.test(name)) {
  1168. error('Unknown event handler property `%s`. It will be ignored.', name);
  1169. warnedProperties$1[name] = true;
  1170. return true;
  1171. }
  1172. } else if (EVENT_NAME_REGEX.test(name)) {
  1173. // If no event plugins have been injected, we are in a server environment.
  1174. // So we can't tell if the event name is correct for sure, but we can filter
  1175. // out known bad ones like `onclick`. We can't suggest a specific replacement though.
  1176. if (INVALID_EVENT_NAME_REGEX.test(name)) {
  1177. error('Invalid event handler property `%s`. ' + 'React events use the camelCase naming convention, for example `onClick`.', name);
  1178. }
  1179. warnedProperties$1[name] = true;
  1180. return true;
  1181. } // Let the ARIA attribute hook validate ARIA attributes
  1182. if (rARIA$1.test(name) || rARIACamel$1.test(name)) {
  1183. return true;
  1184. }
  1185. if (lowerCasedName === 'innerhtml') {
  1186. error('Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.');
  1187. warnedProperties$1[name] = true;
  1188. return true;
  1189. }
  1190. if (lowerCasedName === 'aria') {
  1191. error('The `aria` attribute is reserved for future use in React. ' + 'Pass individual `aria-` attributes instead.');
  1192. warnedProperties$1[name] = true;
  1193. return true;
  1194. }
  1195. if (lowerCasedName === 'is' && value !== null && value !== undefined && typeof value !== 'string') {
  1196. error('Received a `%s` for a string attribute `is`. If this is expected, cast ' + 'the value to a string.', typeof value);
  1197. warnedProperties$1[name] = true;
  1198. return true;
  1199. }
  1200. if (typeof value === 'number' && isNaN(value)) {
  1201. error('Received NaN for the `%s` attribute. If this is expected, cast ' + 'the value to a string.', name);
  1202. warnedProperties$1[name] = true;
  1203. return true;
  1204. }
  1205. var propertyInfo = getPropertyInfo(name);
  1206. var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED; // Known attributes should match the casing specified in the property config.
  1207. if (possibleStandardNames.hasOwnProperty(lowerCasedName)) {
  1208. var standardName = possibleStandardNames[lowerCasedName];
  1209. if (standardName !== name) {
  1210. error('Invalid DOM property `%s`. Did you mean `%s`?', name, standardName);
  1211. warnedProperties$1[name] = true;
  1212. return true;
  1213. }
  1214. } else if (!isReserved && name !== lowerCasedName) {
  1215. // Unknown attributes should have lowercase casing since that's how they
  1216. // will be cased anyway with server rendering.
  1217. 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);
  1218. warnedProperties$1[name] = true;
  1219. return true;
  1220. }
  1221. if (typeof value === 'boolean' && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
  1222. if (value) {
  1223. 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);
  1224. } else {
  1225. 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);
  1226. }
  1227. warnedProperties$1[name] = true;
  1228. return true;
  1229. } // Now that we've validated casing, do not validate
  1230. // data types for reserved props
  1231. if (isReserved) {
  1232. return true;
  1233. } // Warn when a known attribute is a bad type
  1234. if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
  1235. warnedProperties$1[name] = true;
  1236. return false;
  1237. } // Warn when passing the strings 'false' or 'true' into a boolean prop
  1238. if ((value === 'false' || value === 'true') && propertyInfo !== null && propertyInfo.type === BOOLEAN) {
  1239. 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);
  1240. warnedProperties$1[name] = true;
  1241. return true;
  1242. }
  1243. return true;
  1244. };
  1245. }
  1246. var warnUnknownProperties = function (type, props, eventRegistry) {
  1247. {
  1248. var unknownProps = [];
  1249. for (var key in props) {
  1250. var isValid = validateProperty$1(type, key, props[key], eventRegistry);
  1251. if (!isValid) {
  1252. unknownProps.push(key);
  1253. }
  1254. }
  1255. var unknownPropString = unknownProps.map(function (prop) {
  1256. return '`' + prop + '`';
  1257. }).join(', ');
  1258. if (unknownProps.length === 1) {
  1259. 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);
  1260. } else if (unknownProps.length > 1) {
  1261. 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);
  1262. }
  1263. }
  1264. };
  1265. function validateProperties$2(type, props, eventRegistry) {
  1266. if (isCustomComponent(type, props)) {
  1267. return;
  1268. }
  1269. warnUnknownProperties(type, props, eventRegistry);
  1270. }
  1271. var warnValidStyle = function () {};
  1272. {
  1273. // 'msTransform' is correct, but the other prefixes should be capitalized
  1274. var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
  1275. var msPattern = /^-ms-/;
  1276. var hyphenPattern = /-(.)/g; // style values shouldn't contain a semicolon
  1277. var badStyleValueWithSemicolonPattern = /;\s*$/;
  1278. var warnedStyleNames = {};
  1279. var warnedStyleValues = {};
  1280. var warnedForNaNValue = false;
  1281. var warnedForInfinityValue = false;
  1282. var camelize = function (string) {
  1283. return string.replace(hyphenPattern, function (_, character) {
  1284. return character.toUpperCase();
  1285. });
  1286. };
  1287. var warnHyphenatedStyleName = function (name) {
  1288. if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
  1289. return;
  1290. }
  1291. warnedStyleNames[name] = true;
  1292. error('Unsupported style property %s. Did you mean %s?', name, // As Andi Smith suggests
  1293. // (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
  1294. // is converted to lowercase `ms`.
  1295. camelize(name.replace(msPattern, 'ms-')));
  1296. };
  1297. var warnBadVendoredStyleName = function (name) {
  1298. if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
  1299. return;
  1300. }
  1301. warnedStyleNames[name] = true;
  1302. error('Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1));
  1303. };
  1304. var warnStyleValueWithSemicolon = function (name, value) {
  1305. if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
  1306. return;
  1307. }
  1308. warnedStyleValues[value] = true;
  1309. error("Style property values shouldn't contain a semicolon. " + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, ''));
  1310. };
  1311. var warnStyleValueIsNaN = function (name, value) {
  1312. if (warnedForNaNValue) {
  1313. return;
  1314. }
  1315. warnedForNaNValue = true;
  1316. error('`NaN` is an invalid value for the `%s` css style property.', name);
  1317. };
  1318. var warnStyleValueIsInfinity = function (name, value) {
  1319. if (warnedForInfinityValue) {
  1320. return;
  1321. }
  1322. warnedForInfinityValue = true;
  1323. error('`Infinity` is an invalid value for the `%s` css style property.', name);
  1324. };
  1325. warnValidStyle = function (name, value) {
  1326. if (name.indexOf('-') > -1) {
  1327. warnHyphenatedStyleName(name);
  1328. } else if (badVendoredStyleNamePattern.test(name)) {
  1329. warnBadVendoredStyleName(name);
  1330. } else if (badStyleValueWithSemicolonPattern.test(value)) {
  1331. warnStyleValueWithSemicolon(name, value);
  1332. }
  1333. if (typeof value === 'number') {
  1334. if (isNaN(value)) {
  1335. warnStyleValueIsNaN(name, value);
  1336. } else if (!isFinite(value)) {
  1337. warnStyleValueIsInfinity(name, value);
  1338. }
  1339. }
  1340. };
  1341. }
  1342. var warnValidStyle$1 = warnValidStyle;
  1343. // code copied and modified from escape-html
  1344. var matchHtmlRegExp = /["'&<>]/;
  1345. /**
  1346. * Escapes special characters and HTML entities in a given html string.
  1347. *
  1348. * @param {string} string HTML string to escape for later insertion
  1349. * @return {string}
  1350. * @public
  1351. */
  1352. function escapeHtml(string) {
  1353. {
  1354. checkHtmlStringCoercion(string);
  1355. }
  1356. var str = '' + string;
  1357. var match = matchHtmlRegExp.exec(str);
  1358. if (!match) {
  1359. return str;
  1360. }
  1361. var escape;
  1362. var html = '';
  1363. var index;
  1364. var lastIndex = 0;
  1365. for (index = match.index; index < str.length; index++) {
  1366. switch (str.charCodeAt(index)) {
  1367. case 34:
  1368. // "
  1369. escape = '&quot;';
  1370. break;
  1371. case 38:
  1372. // &
  1373. escape = '&amp;';
  1374. break;
  1375. case 39:
  1376. // '
  1377. escape = '&#x27;'; // modified from escape-html; used to be '&#39'
  1378. break;
  1379. case 60:
  1380. // <
  1381. escape = '&lt;';
  1382. break;
  1383. case 62:
  1384. // >
  1385. escape = '&gt;';
  1386. break;
  1387. default:
  1388. continue;
  1389. }
  1390. if (lastIndex !== index) {
  1391. html += str.substring(lastIndex, index);
  1392. }
  1393. lastIndex = index + 1;
  1394. html += escape;
  1395. }
  1396. return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
  1397. } // end code copied and modified from escape-html
  1398. /**
  1399. * Escapes text to prevent scripting attacks.
  1400. *
  1401. * @param {*} text Text value to escape.
  1402. * @return {string} An escaped string.
  1403. */
  1404. function escapeTextForBrowser(text) {
  1405. if (typeof text === 'boolean' || typeof text === 'number') {
  1406. // this shortcircuit helps perf for types that we know will never have
  1407. // special characters, especially given that this function is used often
  1408. // for numeric dom ids.
  1409. return '' + text;
  1410. }
  1411. return escapeHtml(text);
  1412. }
  1413. var uppercasePattern = /([A-Z])/g;
  1414. var msPattern$1 = /^ms-/;
  1415. /**
  1416. * Hyphenates a camelcased CSS property name, for example:
  1417. *
  1418. * > hyphenateStyleName('backgroundColor')
  1419. * < "background-color"
  1420. * > hyphenateStyleName('MozTransition')
  1421. * < "-moz-transition"
  1422. * > hyphenateStyleName('msTransition')
  1423. * < "-ms-transition"
  1424. *
  1425. * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
  1426. * is converted to `-ms-`.
  1427. */
  1428. function hyphenateStyleName(name) {
  1429. return name.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern$1, '-ms-');
  1430. }
  1431. // and any newline or tab are filtered out as if they're not part of the URL.
  1432. // https://url.spec.whatwg.org/#url-parsing
  1433. // Tab or newline are defined as \r\n\t:
  1434. // https://infra.spec.whatwg.org/#ascii-tab-or-newline
  1435. // A C0 control is a code point in the range \u0000 NULL to \u001F
  1436. // INFORMATION SEPARATOR ONE, inclusive:
  1437. // https://infra.spec.whatwg.org/#c0-control-or-space
  1438. /* eslint-disable max-len */
  1439. 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;
  1440. var didWarn = false;
  1441. function sanitizeURL(url) {
  1442. {
  1443. if (!didWarn && isJavaScriptProtocol.test(url)) {
  1444. didWarn = true;
  1445. 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));
  1446. }
  1447. }
  1448. }
  1449. var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
  1450. function isArray(a) {
  1451. return isArrayImpl(a);
  1452. }
  1453. var startInlineScript = stringToPrecomputedChunk('<script>');
  1454. var endInlineScript = stringToPrecomputedChunk('</script>');
  1455. var startScriptSrc = stringToPrecomputedChunk('<script src="');
  1456. var startModuleSrc = stringToPrecomputedChunk('<script type="module" src="');
  1457. var endAsyncScript = stringToPrecomputedChunk('" async=""></script>');
  1458. /**
  1459. * This escaping function is designed to work with bootstrapScriptContent only.
  1460. * because we know we are escaping the entire script. We can avoid for instance
  1461. * escaping html comment string sequences that are valid javascript as well because
  1462. * if there are no sebsequent <script sequences the html parser will never enter
  1463. * script data double escaped state (see: https://www.w3.org/TR/html53/syntax.html#script-data-double-escaped-state)
  1464. *
  1465. * While untrusted script content should be made safe before using this api it will
  1466. * ensure that the script cannot be early terminated or never terminated state
  1467. */
  1468. function escapeBootstrapScriptContent(scriptText) {
  1469. {
  1470. checkHtmlStringCoercion(scriptText);
  1471. }
  1472. return ('' + scriptText).replace(scriptRegex, scriptReplacer);
  1473. }
  1474. var scriptRegex = /(<\/|<)(s)(cript)/gi;
  1475. var scriptReplacer = function (match, prefix, s, suffix) {
  1476. return "" + prefix + (s === 's' ? "\\u0073" : "\\u0053") + suffix;
  1477. }; // Allows us to keep track of what we've already written so we can refer back to it.
  1478. function createResponseState(identifierPrefix, nonce, bootstrapScriptContent, bootstrapScripts, bootstrapModules) {
  1479. var idPrefix = identifierPrefix === undefined ? '' : identifierPrefix;
  1480. var inlineScriptWithNonce = nonce === undefined ? startInlineScript : stringToPrecomputedChunk('<script nonce="' + escapeTextForBrowser(nonce) + '">');
  1481. var bootstrapChunks = [];
  1482. if (bootstrapScriptContent !== undefined) {
  1483. bootstrapChunks.push(inlineScriptWithNonce, stringToChunk(escapeBootstrapScriptContent(bootstrapScriptContent)), endInlineScript);
  1484. }
  1485. if (bootstrapScripts !== undefined) {
  1486. for (var i = 0; i < bootstrapScripts.length; i++) {
  1487. bootstrapChunks.push(startScriptSrc, stringToChunk(escapeTextForBrowser(bootstrapScripts[i])), endAsyncScript);
  1488. }
  1489. }
  1490. if (bootstrapModules !== undefined) {
  1491. for (var _i = 0; _i < bootstrapModules.length; _i++) {
  1492. bootstrapChunks.push(startModuleSrc, stringToChunk(escapeTextForBrowser(bootstrapModules[_i])), endAsyncScript);
  1493. }
  1494. }
  1495. return {
  1496. bootstrapChunks: bootstrapChunks,
  1497. startInlineScript: inlineScriptWithNonce,
  1498. placeholderPrefix: stringToPrecomputedChunk(idPrefix + 'P:'),
  1499. segmentPrefix: stringToPrecomputedChunk(idPrefix + 'S:'),
  1500. boundaryPrefix: idPrefix + 'B:',
  1501. idPrefix: idPrefix,
  1502. nextSuspenseID: 0,
  1503. sentCompleteSegmentFunction: false,
  1504. sentCompleteBoundaryFunction: false,
  1505. sentClientRenderFunction: false
  1506. };
  1507. } // Constants for the insertion mode we're currently writing in. We don't encode all HTML5 insertion
  1508. // modes. We only include the variants as they matter for the sake of our purposes.
  1509. // We don't actually provide the namespace therefore we use constants instead of the string.
  1510. var ROOT_HTML_MODE = 0; // Used for the root most element tag.
  1511. var HTML_MODE = 1;
  1512. var SVG_MODE = 2;
  1513. var MATHML_MODE = 3;
  1514. var HTML_TABLE_MODE = 4;
  1515. var HTML_TABLE_BODY_MODE = 5;
  1516. var HTML_TABLE_ROW_MODE = 6;
  1517. var HTML_COLGROUP_MODE = 7; // We have a greater than HTML_TABLE_MODE check elsewhere. If you add more cases here, make sure it
  1518. // still makes sense
  1519. function createFormatContext(insertionMode, selectedValue) {
  1520. return {
  1521. insertionMode: insertionMode,
  1522. selectedValue: selectedValue
  1523. };
  1524. }
  1525. function getChildFormatContext(parentContext, type, props) {
  1526. switch (type) {
  1527. case 'select':
  1528. return createFormatContext(HTML_MODE, props.value != null ? props.value : props.defaultValue);
  1529. case 'svg':
  1530. return createFormatContext(SVG_MODE, null);
  1531. case 'math':
  1532. return createFormatContext(MATHML_MODE, null);
  1533. case 'foreignObject':
  1534. return createFormatContext(HTML_MODE, null);
  1535. // Table parents are special in that their children can only be created at all if they're
  1536. // wrapped in a table parent. So we need to encode that we're entering this mode.
  1537. case 'table':
  1538. return createFormatContext(HTML_TABLE_MODE, null);
  1539. case 'thead':
  1540. case 'tbody':
  1541. case 'tfoot':
  1542. return createFormatContext(HTML_TABLE_BODY_MODE, null);
  1543. case 'colgroup':
  1544. return createFormatContext(HTML_COLGROUP_MODE, null);
  1545. case 'tr':
  1546. return createFormatContext(HTML_TABLE_ROW_MODE, null);
  1547. }
  1548. if (parentContext.insertionMode >= HTML_TABLE_MODE) {
  1549. // Whatever tag this was, it wasn't a table parent or other special parent, so we must have
  1550. // entered plain HTML again.
  1551. return createFormatContext(HTML_MODE, null);
  1552. }
  1553. if (parentContext.insertionMode === ROOT_HTML_MODE) {
  1554. // We've emitted the root and is now in plain HTML mode.
  1555. return createFormatContext(HTML_MODE, null);
  1556. }
  1557. return parentContext;
  1558. }
  1559. var UNINITIALIZED_SUSPENSE_BOUNDARY_ID = null;
  1560. function assignSuspenseBoundaryID(responseState) {
  1561. var generatedID = responseState.nextSuspenseID++;
  1562. return stringToPrecomputedChunk(responseState.boundaryPrefix + generatedID.toString(16));
  1563. }
  1564. function makeId(responseState, treeId, localId) {
  1565. var idPrefix = responseState.idPrefix;
  1566. var id = ':' + idPrefix + 'R' + treeId; // Unless this is the first id at this level, append a number at the end
  1567. // that represents the position of this useId hook among all the useId
  1568. // hooks for this fiber.
  1569. if (localId > 0) {
  1570. id += 'H' + localId.toString(32);
  1571. }
  1572. return id + ':';
  1573. }
  1574. function encodeHTMLTextNode(text) {
  1575. return escapeTextForBrowser(text);
  1576. }
  1577. var textSeparator = stringToPrecomputedChunk('<!-- -->');
  1578. function pushTextInstance(target, text, responseState, textEmbedded) {
  1579. if (text === '') {
  1580. // Empty text doesn't have a DOM node representation and the hydration is aware of this.
  1581. return textEmbedded;
  1582. }
  1583. if (textEmbedded) {
  1584. target.push(textSeparator);
  1585. }
  1586. target.push(stringToChunk(encodeHTMLTextNode(text)));
  1587. return true;
  1588. } // Called when Fizz is done with a Segment. Currently the only purpose is to conditionally
  1589. // emit a text separator when we don't know for sure it is safe to omit
  1590. function pushSegmentFinale(target, responseState, lastPushedText, textEmbedded) {
  1591. if (lastPushedText && textEmbedded) {
  1592. target.push(textSeparator);
  1593. }
  1594. }
  1595. var styleNameCache = new Map();
  1596. function processStyleName(styleName) {
  1597. var chunk = styleNameCache.get(styleName);
  1598. if (chunk !== undefined) {
  1599. return chunk;
  1600. }
  1601. var result = stringToPrecomputedChunk(escapeTextForBrowser(hyphenateStyleName(styleName)));
  1602. styleNameCache.set(styleName, result);
  1603. return result;
  1604. }
  1605. var styleAttributeStart = stringToPrecomputedChunk(' style="');
  1606. var styleAssign = stringToPrecomputedChunk(':');
  1607. var styleSeparator = stringToPrecomputedChunk(';');
  1608. function pushStyle(target, responseState, style) {
  1609. if (typeof style !== 'object') {
  1610. throw new Error('The `style` prop expects a mapping from style properties to values, ' + "not a string. For example, style={{marginRight: spacing + 'em'}} when " + 'using JSX.');
  1611. }
  1612. var isFirst = true;
  1613. for (var styleName in style) {
  1614. if (!hasOwnProperty.call(style, styleName)) {
  1615. continue;
  1616. } // If you provide unsafe user data here they can inject arbitrary CSS
  1617. // which may be problematic (I couldn't repro this):
  1618. // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
  1619. // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
  1620. // This is not an XSS hole but instead a potential CSS injection issue
  1621. // which has lead to a greater discussion about how we're going to
  1622. // trust URLs moving forward. See #2115901
  1623. var styleValue = style[styleName];
  1624. if (styleValue == null || typeof styleValue === 'boolean' || styleValue === '') {
  1625. // TODO: We used to set empty string as a style with an empty value. Does that ever make sense?
  1626. continue;
  1627. }
  1628. var nameChunk = void 0;
  1629. var valueChunk = void 0;
  1630. var isCustomProperty = styleName.indexOf('--') === 0;
  1631. if (isCustomProperty) {
  1632. nameChunk = stringToChunk(escapeTextForBrowser(styleName));
  1633. {
  1634. checkCSSPropertyStringCoercion(styleValue, styleName);
  1635. }
  1636. valueChunk = stringToChunk(escapeTextForBrowser(('' + styleValue).trim()));
  1637. } else {
  1638. {
  1639. warnValidStyle$1(styleName, styleValue);
  1640. }
  1641. nameChunk = processStyleName(styleName);
  1642. if (typeof styleValue === 'number') {
  1643. if (styleValue !== 0 && !hasOwnProperty.call(isUnitlessNumber, styleName)) {
  1644. valueChunk = stringToChunk(styleValue + 'px'); // Presumes implicit 'px' suffix for unitless numbers
  1645. } else {
  1646. valueChunk = stringToChunk('' + styleValue);
  1647. }
  1648. } else {
  1649. {
  1650. checkCSSPropertyStringCoercion(styleValue, styleName);
  1651. }
  1652. valueChunk = stringToChunk(escapeTextForBrowser(('' + styleValue).trim()));
  1653. }
  1654. }
  1655. if (isFirst) {
  1656. isFirst = false; // If it's first, we don't need any separators prefixed.
  1657. target.push(styleAttributeStart, nameChunk, styleAssign, valueChunk);
  1658. } else {
  1659. target.push(styleSeparator, nameChunk, styleAssign, valueChunk);
  1660. }
  1661. }
  1662. if (!isFirst) {
  1663. target.push(attributeEnd);
  1664. }
  1665. }
  1666. var attributeSeparator = stringToPrecomputedChunk(' ');
  1667. var attributeAssign = stringToPrecomputedChunk('="');
  1668. var attributeEnd = stringToPrecomputedChunk('"');
  1669. var attributeEmptyString = stringToPrecomputedChunk('=""');
  1670. function pushAttribute(target, responseState, name, value) {
  1671. switch (name) {
  1672. case 'style':
  1673. {
  1674. pushStyle(target, responseState, value);
  1675. return;
  1676. }
  1677. case 'defaultValue':
  1678. case 'defaultChecked': // These shouldn't be set as attributes on generic HTML elements.
  1679. case 'innerHTML': // Must use dangerouslySetInnerHTML instead.
  1680. case 'suppressContentEditableWarning':
  1681. case 'suppressHydrationWarning':
  1682. // Ignored. These are built-in to React on the client.
  1683. return;
  1684. }
  1685. if ( // shouldIgnoreAttribute
  1686. // We have already filtered out null/undefined and reserved words.
  1687. name.length > 2 && (name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) {
  1688. return;
  1689. }
  1690. var propertyInfo = getPropertyInfo(name);
  1691. if (propertyInfo !== null) {
  1692. // shouldRemoveAttribute
  1693. switch (typeof value) {
  1694. case 'function': // $FlowIssue symbol is perfectly valid here
  1695. case 'symbol':
  1696. // eslint-disable-line
  1697. return;
  1698. case 'boolean':
  1699. {
  1700. if (!propertyInfo.acceptsBooleans) {
  1701. return;
  1702. }
  1703. }
  1704. }
  1705. var attributeName = propertyInfo.attributeName;
  1706. var attributeNameChunk = stringToChunk(attributeName); // TODO: If it's known we can cache the chunk.
  1707. switch (propertyInfo.type) {
  1708. case BOOLEAN:
  1709. if (value) {
  1710. target.push(attributeSeparator, attributeNameChunk, attributeEmptyString);
  1711. }
  1712. return;
  1713. case OVERLOADED_BOOLEAN:
  1714. if (value === true) {
  1715. target.push(attributeSeparator, attributeNameChunk, attributeEmptyString);
  1716. } else if (value === false) ; else {
  1717. target.push(attributeSeparator, attributeNameChunk, attributeAssign, stringToChunk(escapeTextForBrowser(value)), attributeEnd);
  1718. }
  1719. return;
  1720. case NUMERIC:
  1721. if (!isNaN(value)) {
  1722. target.push(attributeSeparator, attributeNameChunk, attributeAssign, stringToChunk(escapeTextForBrowser(value)), attributeEnd);
  1723. }
  1724. break;
  1725. case POSITIVE_NUMERIC:
  1726. if (!isNaN(value) && value >= 1) {
  1727. target.push(attributeSeparator, attributeNameChunk, attributeAssign, stringToChunk(escapeTextForBrowser(value)), attributeEnd);
  1728. }
  1729. break;
  1730. default:
  1731. if (propertyInfo.sanitizeURL) {
  1732. {
  1733. checkAttributeStringCoercion(value, attributeName);
  1734. }
  1735. value = '' + value;
  1736. sanitizeURL(value);
  1737. }
  1738. target.push(attributeSeparator, attributeNameChunk, attributeAssign, stringToChunk(escapeTextForBrowser(value)), attributeEnd);
  1739. }
  1740. } else if (isAttributeNameSafe(name)) {
  1741. // shouldRemoveAttribute
  1742. switch (typeof value) {
  1743. case 'function': // $FlowIssue symbol is perfectly valid here
  1744. case 'symbol':
  1745. // eslint-disable-line
  1746. return;
  1747. case 'boolean':
  1748. {
  1749. var prefix = name.toLowerCase().slice(0, 5);
  1750. if (prefix !== 'data-' && prefix !== 'aria-') {
  1751. return;
  1752. }
  1753. }
  1754. }
  1755. target.push(attributeSeparator, stringToChunk(name), attributeAssign, stringToChunk(escapeTextForBrowser(value)), attributeEnd);
  1756. }
  1757. }
  1758. var endOfStartTag = stringToPrecomputedChunk('>');
  1759. var endOfStartTagSelfClosing = stringToPrecomputedChunk('/>');
  1760. function pushInnerHTML(target, innerHTML, children) {
  1761. if (innerHTML != null) {
  1762. if (children != null) {
  1763. throw new Error('Can only set one of `children` or `props.dangerouslySetInnerHTML`.');
  1764. }
  1765. if (typeof innerHTML !== 'object' || !('__html' in innerHTML)) {
  1766. throw new Error('`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' + 'Please visit https://reactjs.org/link/dangerously-set-inner-html ' + 'for more information.');
  1767. }
  1768. var html = innerHTML.__html;
  1769. if (html !== null && html !== undefined) {
  1770. {
  1771. checkHtmlStringCoercion(html);
  1772. }
  1773. target.push(stringToChunk('' + html));
  1774. }
  1775. }
  1776. } // TODO: Move these to ResponseState so that we warn for every request.
  1777. // It would help debugging in stateful servers (e.g. service worker).
  1778. var didWarnDefaultInputValue = false;
  1779. var didWarnDefaultChecked = false;
  1780. var didWarnDefaultSelectValue = false;
  1781. var didWarnDefaultTextareaValue = false;
  1782. var didWarnInvalidOptionChildren = false;
  1783. var didWarnInvalidOptionInnerHTML = false;
  1784. var didWarnSelectedSetOnOption = false;
  1785. function checkSelectProp(props, propName) {
  1786. {
  1787. var value = props[propName];
  1788. if (value != null) {
  1789. var array = isArray(value);
  1790. if (props.multiple && !array) {
  1791. error('The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.', propName);
  1792. } else if (!props.multiple && array) {
  1793. error('The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.', propName);
  1794. }
  1795. }
  1796. }
  1797. }
  1798. function pushStartSelect(target, props, responseState) {
  1799. {
  1800. checkControlledValueProps('select', props);
  1801. checkSelectProp(props, 'value');
  1802. checkSelectProp(props, 'defaultValue');
  1803. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnDefaultSelectValue) {
  1804. 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');
  1805. didWarnDefaultSelectValue = true;
  1806. }
  1807. }
  1808. target.push(startChunkForTag('select'));
  1809. var children = null;
  1810. var innerHTML = null;
  1811. for (var propKey in props) {
  1812. if (hasOwnProperty.call(props, propKey)) {
  1813. var propValue = props[propKey];
  1814. if (propValue == null) {
  1815. continue;
  1816. }
  1817. switch (propKey) {
  1818. case 'children':
  1819. children = propValue;
  1820. break;
  1821. case 'dangerouslySetInnerHTML':
  1822. // TODO: This doesn't really make sense for select since it can't use the controlled
  1823. // value in the innerHTML.
  1824. innerHTML = propValue;
  1825. break;
  1826. case 'defaultValue':
  1827. case 'value':
  1828. // These are set on the Context instead and applied to the nested options.
  1829. break;
  1830. default:
  1831. pushAttribute(target, responseState, propKey, propValue);
  1832. break;
  1833. }
  1834. }
  1835. }
  1836. target.push(endOfStartTag);
  1837. pushInnerHTML(target, innerHTML, children);
  1838. return children;
  1839. }
  1840. function flattenOptionChildren(children) {
  1841. var content = ''; // Flatten children and warn if they aren't strings or numbers;
  1842. // invalid types are ignored.
  1843. React.Children.forEach(children, function (child) {
  1844. if (child == null) {
  1845. return;
  1846. }
  1847. content += child;
  1848. {
  1849. if (!didWarnInvalidOptionChildren && typeof child !== 'string' && typeof child !== 'number') {
  1850. didWarnInvalidOptionChildren = true;
  1851. error('Cannot infer the option value of complex children. ' + 'Pass a `value` prop or use a plain string as children to <option>.');
  1852. }
  1853. }
  1854. });
  1855. return content;
  1856. }
  1857. var selectedMarkerAttribute = stringToPrecomputedChunk(' selected=""');
  1858. function pushStartOption(target, props, responseState, formatContext) {
  1859. var selectedValue = formatContext.selectedValue;
  1860. target.push(startChunkForTag('option'));
  1861. var children = null;
  1862. var value = null;
  1863. var selected = null;
  1864. var innerHTML = null;
  1865. for (var propKey in props) {
  1866. if (hasOwnProperty.call(props, propKey)) {
  1867. var propValue = props[propKey];
  1868. if (propValue == null) {
  1869. continue;
  1870. }
  1871. switch (propKey) {
  1872. case 'children':
  1873. children = propValue;
  1874. break;
  1875. case 'selected':
  1876. // ignore
  1877. selected = propValue;
  1878. {
  1879. // TODO: Remove support for `selected` in <option>.
  1880. if (!didWarnSelectedSetOnOption) {
  1881. error('Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.');
  1882. didWarnSelectedSetOnOption = true;
  1883. }
  1884. }
  1885. break;
  1886. case 'dangerouslySetInnerHTML':
  1887. innerHTML = propValue;
  1888. break;
  1889. // eslint-disable-next-line-no-fallthrough
  1890. case 'value':
  1891. value = propValue;
  1892. // We intentionally fallthrough to also set the attribute on the node.
  1893. // eslint-disable-next-line-no-fallthrough
  1894. default:
  1895. pushAttribute(target, responseState, propKey, propValue);
  1896. break;
  1897. }
  1898. }
  1899. }
  1900. if (selectedValue != null) {
  1901. var stringValue;
  1902. if (value !== null) {
  1903. {
  1904. checkAttributeStringCoercion(value, 'value');
  1905. }
  1906. stringValue = '' + value;
  1907. } else {
  1908. {
  1909. if (innerHTML !== null) {
  1910. if (!didWarnInvalidOptionInnerHTML) {
  1911. didWarnInvalidOptionInnerHTML = true;
  1912. error('Pass a `value` prop if you set dangerouslyInnerHTML so React knows ' + 'which value should be selected.');
  1913. }
  1914. }
  1915. }
  1916. stringValue = flattenOptionChildren(children);
  1917. }
  1918. if (isArray(selectedValue)) {
  1919. // multiple
  1920. for (var i = 0; i < selectedValue.length; i++) {
  1921. {
  1922. checkAttributeStringCoercion(selectedValue[i], 'value');
  1923. }
  1924. var v = '' + selectedValue[i];
  1925. if (v === stringValue) {
  1926. target.push(selectedMarkerAttribute);
  1927. break;
  1928. }
  1929. }
  1930. } else {
  1931. {
  1932. checkAttributeStringCoercion(selectedValue, 'select.value');
  1933. }
  1934. if ('' + selectedValue === stringValue) {
  1935. target.push(selectedMarkerAttribute);
  1936. }
  1937. }
  1938. } else if (selected) {
  1939. target.push(selectedMarkerAttribute);
  1940. }
  1941. target.push(endOfStartTag);
  1942. pushInnerHTML(target, innerHTML, children);
  1943. return children;
  1944. }
  1945. function pushInput(target, props, responseState) {
  1946. {
  1947. checkControlledValueProps('input', props);
  1948. if (props.checked !== undefined && props.defaultChecked !== undefined && !didWarnDefaultChecked) {
  1949. 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', 'A component', props.type);
  1950. didWarnDefaultChecked = true;
  1951. }
  1952. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnDefaultInputValue) {
  1953. 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', 'A component', props.type);
  1954. didWarnDefaultInputValue = true;
  1955. }
  1956. }
  1957. target.push(startChunkForTag('input'));
  1958. var value = null;
  1959. var defaultValue = null;
  1960. var checked = null;
  1961. var defaultChecked = null;
  1962. for (var propKey in props) {
  1963. if (hasOwnProperty.call(props, propKey)) {
  1964. var propValue = props[propKey];
  1965. if (propValue == null) {
  1966. continue;
  1967. }
  1968. switch (propKey) {
  1969. case 'children':
  1970. case 'dangerouslySetInnerHTML':
  1971. throw new Error('input' + " is a self-closing tag and must neither have `children` nor " + 'use `dangerouslySetInnerHTML`.');
  1972. // eslint-disable-next-line-no-fallthrough
  1973. case 'defaultChecked':
  1974. defaultChecked = propValue;
  1975. break;
  1976. case 'defaultValue':
  1977. defaultValue = propValue;
  1978. break;
  1979. case 'checked':
  1980. checked = propValue;
  1981. break;
  1982. case 'value':
  1983. value = propValue;
  1984. break;
  1985. default:
  1986. pushAttribute(target, responseState, propKey, propValue);
  1987. break;
  1988. }
  1989. }
  1990. }
  1991. if (checked !== null) {
  1992. pushAttribute(target, responseState, 'checked', checked);
  1993. } else if (defaultChecked !== null) {
  1994. pushAttribute(target, responseState, 'checked', defaultChecked);
  1995. }
  1996. if (value !== null) {
  1997. pushAttribute(target, responseState, 'value', value);
  1998. } else if (defaultValue !== null) {
  1999. pushAttribute(target, responseState, 'value', defaultValue);
  2000. }
  2001. target.push(endOfStartTagSelfClosing);
  2002. return null;
  2003. }
  2004. function pushStartTextArea(target, props, responseState) {
  2005. {
  2006. checkControlledValueProps('textarea', props);
  2007. if (props.value !== undefined && props.defaultValue !== undefined && !didWarnDefaultTextareaValue) {
  2008. error('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');
  2009. didWarnDefaultTextareaValue = true;
  2010. }
  2011. }
  2012. target.push(startChunkForTag('textarea'));
  2013. var value = null;
  2014. var defaultValue = null;
  2015. var children = null;
  2016. for (var propKey in props) {
  2017. if (hasOwnProperty.call(props, propKey)) {
  2018. var propValue = props[propKey];
  2019. if (propValue == null) {
  2020. continue;
  2021. }
  2022. switch (propKey) {
  2023. case 'children':
  2024. children = propValue;
  2025. break;
  2026. case 'value':
  2027. value = propValue;
  2028. break;
  2029. case 'defaultValue':
  2030. defaultValue = propValue;
  2031. break;
  2032. case 'dangerouslySetInnerHTML':
  2033. throw new Error('`dangerouslySetInnerHTML` does not make sense on <textarea>.');
  2034. // eslint-disable-next-line-no-fallthrough
  2035. default:
  2036. pushAttribute(target, responseState, propKey, propValue);
  2037. break;
  2038. }
  2039. }
  2040. }
  2041. if (value === null && defaultValue !== null) {
  2042. value = defaultValue;
  2043. }
  2044. target.push(endOfStartTag); // TODO (yungsters): Remove support for children content in <textarea>.
  2045. if (children != null) {
  2046. {
  2047. error('Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.');
  2048. }
  2049. if (value != null) {
  2050. throw new Error('If you supply `defaultValue` on a <textarea>, do not pass children.');
  2051. }
  2052. if (isArray(children)) {
  2053. if (children.length > 1) {
  2054. throw new Error('<textarea> can only have at most one child.');
  2055. } // TODO: remove the coercion and the DEV check below because it will
  2056. // always be overwritten by the coercion several lines below it. #22309
  2057. {
  2058. checkHtmlStringCoercion(children[0]);
  2059. }
  2060. value = '' + children[0];
  2061. }
  2062. {
  2063. checkHtmlStringCoercion(children);
  2064. }
  2065. value = '' + children;
  2066. }
  2067. if (typeof value === 'string' && value[0] === '\n') {
  2068. // text/html ignores the first character in these tags if it's a newline
  2069. // Prefer to break application/xml over text/html (for now) by adding
  2070. // a newline specifically to get eaten by the parser. (Alternately for
  2071. // textareas, replacing "^\n" with "\r\n" doesn't get eaten, and the first
  2072. // \r is normalized out by HTMLTextAreaElement#value.)
  2073. // See: <http://www.w3.org/TR/html-polyglot/#newlines-in-textarea-and-pre>
  2074. // See: <http://www.w3.org/TR/html5/syntax.html#element-restrictions>
  2075. // See: <http://www.w3.org/TR/html5/syntax.html#newlines>
  2076. // See: Parsing of "textarea" "listing" and "pre" elements
  2077. // from <http://www.w3.org/TR/html5/syntax.html#parsing-main-inbody>
  2078. target.push(leadingNewline);
  2079. } // ToString and push directly instead of recurse over children.
  2080. // We don't really support complex children in the value anyway.
  2081. // This also currently avoids a trailing comment node which breaks textarea.
  2082. if (value !== null) {
  2083. {
  2084. checkAttributeStringCoercion(value, 'value');
  2085. }
  2086. target.push(stringToChunk(encodeHTMLTextNode('' + value)));
  2087. }
  2088. return null;
  2089. }
  2090. function pushSelfClosing(target, props, tag, responseState) {
  2091. target.push(startChunkForTag(tag));
  2092. for (var propKey in props) {
  2093. if (hasOwnProperty.call(props, propKey)) {
  2094. var propValue = props[propKey];
  2095. if (propValue == null) {
  2096. continue;
  2097. }
  2098. switch (propKey) {
  2099. case 'children':
  2100. case 'dangerouslySetInnerHTML':
  2101. throw new Error(tag + " is a self-closing tag and must neither have `children` nor " + 'use `dangerouslySetInnerHTML`.');
  2102. // eslint-disable-next-line-no-fallthrough
  2103. default:
  2104. pushAttribute(target, responseState, propKey, propValue);
  2105. break;
  2106. }
  2107. }
  2108. }
  2109. target.push(endOfStartTagSelfClosing);
  2110. return null;
  2111. }
  2112. function pushStartMenuItem(target, props, responseState) {
  2113. target.push(startChunkForTag('menuitem'));
  2114. for (var propKey in props) {
  2115. if (hasOwnProperty.call(props, propKey)) {
  2116. var propValue = props[propKey];
  2117. if (propValue == null) {
  2118. continue;
  2119. }
  2120. switch (propKey) {
  2121. case 'children':
  2122. case 'dangerouslySetInnerHTML':
  2123. throw new Error('menuitems cannot have `children` nor `dangerouslySetInnerHTML`.');
  2124. // eslint-disable-next-line-no-fallthrough
  2125. default:
  2126. pushAttribute(target, responseState, propKey, propValue);
  2127. break;
  2128. }
  2129. }
  2130. }
  2131. target.push(endOfStartTag);
  2132. return null;
  2133. }
  2134. function pushStartTitle(target, props, responseState) {
  2135. target.push(startChunkForTag('title'));
  2136. var children = null;
  2137. for (var propKey in props) {
  2138. if (hasOwnProperty.call(props, propKey)) {
  2139. var propValue = props[propKey];
  2140. if (propValue == null) {
  2141. continue;
  2142. }
  2143. switch (propKey) {
  2144. case 'children':
  2145. children = propValue;
  2146. break;
  2147. case 'dangerouslySetInnerHTML':
  2148. throw new Error('`dangerouslySetInnerHTML` does not make sense on <title>.');
  2149. // eslint-disable-next-line-no-fallthrough
  2150. default:
  2151. pushAttribute(target, responseState, propKey, propValue);
  2152. break;
  2153. }
  2154. }
  2155. }
  2156. target.push(endOfStartTag);
  2157. {
  2158. var child = Array.isArray(children) && children.length < 2 ? children[0] || null : children;
  2159. if (Array.isArray(children) && children.length > 1) {
  2160. error('A title element received an array with more than 1 element as children. ' + 'In browsers title Elements can only have Text Nodes as children. If ' + 'the children being rendered output more than a single text node in aggregate the browser ' + 'will display markup and comments as text in the title and hydration will likely fail and ' + 'fall back to client rendering');
  2161. } else if (child != null && child.$$typeof != null) {
  2162. error('A title element received a React element for children. ' + 'In the browser title Elements can only have Text Nodes as children. If ' + 'the children being rendered output more than a single text node in aggregate the browser ' + 'will display markup and comments as text in the title and hydration will likely fail and ' + 'fall back to client rendering');
  2163. } else if (child != null && typeof child !== 'string' && typeof child !== 'number') {
  2164. error('A title element received a value that was not a string or number for children. ' + 'In the browser title Elements can only have Text Nodes as children. If ' + 'the children being rendered output more than a single text node in aggregate the browser ' + 'will display markup and comments as text in the title and hydration will likely fail and ' + 'fall back to client rendering');
  2165. }
  2166. }
  2167. return children;
  2168. }
  2169. function pushStartGenericElement(target, props, tag, responseState) {
  2170. target.push(startChunkForTag(tag));
  2171. var children = null;
  2172. var innerHTML = null;
  2173. for (var propKey in props) {
  2174. if (hasOwnProperty.call(props, propKey)) {
  2175. var propValue = props[propKey];
  2176. if (propValue == null) {
  2177. continue;
  2178. }
  2179. switch (propKey) {
  2180. case 'children':
  2181. children = propValue;
  2182. break;
  2183. case 'dangerouslySetInnerHTML':
  2184. innerHTML = propValue;
  2185. break;
  2186. default:
  2187. pushAttribute(target, responseState, propKey, propValue);
  2188. break;
  2189. }
  2190. }
  2191. }
  2192. target.push(endOfStartTag);
  2193. pushInnerHTML(target, innerHTML, children);
  2194. if (typeof children === 'string') {
  2195. // Special case children as a string to avoid the unnecessary comment.
  2196. // TODO: Remove this special case after the general optimization is in place.
  2197. target.push(stringToChunk(encodeHTMLTextNode(children)));
  2198. return null;
  2199. }
  2200. return children;
  2201. }
  2202. function pushStartCustomElement(target, props, tag, responseState) {
  2203. target.push(startChunkForTag(tag));
  2204. var children = null;
  2205. var innerHTML = null;
  2206. for (var propKey in props) {
  2207. if (hasOwnProperty.call(props, propKey)) {
  2208. var propValue = props[propKey];
  2209. if (propValue == null) {
  2210. continue;
  2211. }
  2212. switch (propKey) {
  2213. case 'children':
  2214. children = propValue;
  2215. break;
  2216. case 'dangerouslySetInnerHTML':
  2217. innerHTML = propValue;
  2218. break;
  2219. case 'style':
  2220. pushStyle(target, responseState, propValue);
  2221. break;
  2222. case 'suppressContentEditableWarning':
  2223. case 'suppressHydrationWarning':
  2224. // Ignored. These are built-in to React on the client.
  2225. break;
  2226. default:
  2227. if (isAttributeNameSafe(propKey) && typeof propValue !== 'function' && typeof propValue !== 'symbol') {
  2228. target.push(attributeSeparator, stringToChunk(propKey), attributeAssign, stringToChunk(escapeTextForBrowser(propValue)), attributeEnd);
  2229. }
  2230. break;
  2231. }
  2232. }
  2233. }
  2234. target.push(endOfStartTag);
  2235. pushInnerHTML(target, innerHTML, children);
  2236. return children;
  2237. }
  2238. var leadingNewline = stringToPrecomputedChunk('\n');
  2239. function pushStartPreformattedElement(target, props, tag, responseState) {
  2240. target.push(startChunkForTag(tag));
  2241. var children = null;
  2242. var innerHTML = null;
  2243. for (var propKey in props) {
  2244. if (hasOwnProperty.call(props, propKey)) {
  2245. var propValue = props[propKey];
  2246. if (propValue == null) {
  2247. continue;
  2248. }
  2249. switch (propKey) {
  2250. case 'children':
  2251. children = propValue;
  2252. break;
  2253. case 'dangerouslySetInnerHTML':
  2254. innerHTML = propValue;
  2255. break;
  2256. default:
  2257. pushAttribute(target, responseState, propKey, propValue);
  2258. break;
  2259. }
  2260. }
  2261. }
  2262. target.push(endOfStartTag); // text/html ignores the first character in these tags if it's a newline
  2263. // Prefer to break application/xml over text/html (for now) by adding
  2264. // a newline specifically to get eaten by the parser. (Alternately for
  2265. // textareas, replacing "^\n" with "\r\n" doesn't get eaten, and the first
  2266. // \r is normalized out by HTMLTextAreaElement#value.)
  2267. // See: <http://www.w3.org/TR/html-polyglot/#newlines-in-textarea-and-pre>
  2268. // See: <http://www.w3.org/TR/html5/syntax.html#element-restrictions>
  2269. // See: <http://www.w3.org/TR/html5/syntax.html#newlines>
  2270. // See: Parsing of "textarea" "listing" and "pre" elements
  2271. // from <http://www.w3.org/TR/html5/syntax.html#parsing-main-inbody>
  2272. // TODO: This doesn't deal with the case where the child is an array
  2273. // or component that returns a string.
  2274. if (innerHTML != null) {
  2275. if (children != null) {
  2276. throw new Error('Can only set one of `children` or `props.dangerouslySetInnerHTML`.');
  2277. }
  2278. if (typeof innerHTML !== 'object' || !('__html' in innerHTML)) {
  2279. throw new Error('`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' + 'Please visit https://reactjs.org/link/dangerously-set-inner-html ' + 'for more information.');
  2280. }
  2281. var html = innerHTML.__html;
  2282. if (html !== null && html !== undefined) {
  2283. if (typeof html === 'string' && html.length > 0 && html[0] === '\n') {
  2284. target.push(leadingNewline, stringToChunk(html));
  2285. } else {
  2286. {
  2287. checkHtmlStringCoercion(html);
  2288. }
  2289. target.push(stringToChunk('' + html));
  2290. }
  2291. }
  2292. }
  2293. if (typeof children === 'string' && children[0] === '\n') {
  2294. target.push(leadingNewline);
  2295. }
  2296. return children;
  2297. } // We accept any tag to be rendered but since this gets injected into arbitrary
  2298. // HTML, we want to make sure that it's a safe tag.
  2299. // http://www.w3.org/TR/REC-xml/#NT-Name
  2300. var VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/; // Simplified subset
  2301. var validatedTagCache = new Map();
  2302. function startChunkForTag(tag) {
  2303. var tagStartChunk = validatedTagCache.get(tag);
  2304. if (tagStartChunk === undefined) {
  2305. if (!VALID_TAG_REGEX.test(tag)) {
  2306. throw new Error("Invalid tag: " + tag);
  2307. }
  2308. tagStartChunk = stringToPrecomputedChunk('<' + tag);
  2309. validatedTagCache.set(tag, tagStartChunk);
  2310. }
  2311. return tagStartChunk;
  2312. }
  2313. var DOCTYPE = stringToPrecomputedChunk('<!DOCTYPE html>');
  2314. function pushStartInstance(target, type, props, responseState, formatContext) {
  2315. {
  2316. validateProperties(type, props);
  2317. validateProperties$1(type, props);
  2318. validateProperties$2(type, props, null);
  2319. if (!props.suppressContentEditableWarning && props.contentEditable && props.children != null) {
  2320. 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.');
  2321. }
  2322. if (formatContext.insertionMode !== SVG_MODE && formatContext.insertionMode !== MATHML_MODE) {
  2323. if (type.indexOf('-') === -1 && typeof props.is !== 'string' && type.toLowerCase() !== type) {
  2324. error('<%s /> is using incorrect casing. ' + 'Use PascalCase for React components, ' + 'or lowercase for HTML elements.', type);
  2325. }
  2326. }
  2327. }
  2328. switch (type) {
  2329. // Special tags
  2330. case 'select':
  2331. return pushStartSelect(target, props, responseState);
  2332. case 'option':
  2333. return pushStartOption(target, props, responseState, formatContext);
  2334. case 'textarea':
  2335. return pushStartTextArea(target, props, responseState);
  2336. case 'input':
  2337. return pushInput(target, props, responseState);
  2338. case 'menuitem':
  2339. return pushStartMenuItem(target, props, responseState);
  2340. case 'title':
  2341. return pushStartTitle(target, props, responseState);
  2342. // Newline eating tags
  2343. case 'listing':
  2344. case 'pre':
  2345. {
  2346. return pushStartPreformattedElement(target, props, type, responseState);
  2347. }
  2348. // Omitted close tags
  2349. case 'area':
  2350. case 'base':
  2351. case 'br':
  2352. case 'col':
  2353. case 'embed':
  2354. case 'hr':
  2355. case 'img':
  2356. case 'keygen':
  2357. case 'link':
  2358. case 'meta':
  2359. case 'param':
  2360. case 'source':
  2361. case 'track':
  2362. case 'wbr':
  2363. {
  2364. return pushSelfClosing(target, props, type, responseState);
  2365. }
  2366. // These are reserved SVG and MathML elements, that are never custom elements.
  2367. // https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
  2368. case 'annotation-xml':
  2369. case 'color-profile':
  2370. case 'font-face':
  2371. case 'font-face-src':
  2372. case 'font-face-uri':
  2373. case 'font-face-format':
  2374. case 'font-face-name':
  2375. case 'missing-glyph':
  2376. {
  2377. return pushStartGenericElement(target, props, type, responseState);
  2378. }
  2379. case 'html':
  2380. {
  2381. if (formatContext.insertionMode === ROOT_HTML_MODE) {
  2382. // If we're rendering the html tag and we're at the root (i.e. not in foreignObject)
  2383. // then we also emit the DOCTYPE as part of the root content as a convenience for
  2384. // rendering the whole document.
  2385. target.push(DOCTYPE);
  2386. }
  2387. return pushStartGenericElement(target, props, type, responseState);
  2388. }
  2389. default:
  2390. {
  2391. if (type.indexOf('-') === -1 && typeof props.is !== 'string') {
  2392. // Generic element
  2393. return pushStartGenericElement(target, props, type, responseState);
  2394. } else {
  2395. // Custom element
  2396. return pushStartCustomElement(target, props, type, responseState);
  2397. }
  2398. }
  2399. }
  2400. }
  2401. var endTag1 = stringToPrecomputedChunk('</');
  2402. var endTag2 = stringToPrecomputedChunk('>');
  2403. function pushEndInstance(target, type, props) {
  2404. switch (type) {
  2405. // Omitted close tags
  2406. // TODO: Instead of repeating this switch we could try to pass a flag from above.
  2407. // That would require returning a tuple. Which might be ok if it gets inlined.
  2408. case 'area':
  2409. case 'base':
  2410. case 'br':
  2411. case 'col':
  2412. case 'embed':
  2413. case 'hr':
  2414. case 'img':
  2415. case 'input':
  2416. case 'keygen':
  2417. case 'link':
  2418. case 'meta':
  2419. case 'param':
  2420. case 'source':
  2421. case 'track':
  2422. case 'wbr':
  2423. {
  2424. // No close tag needed.
  2425. break;
  2426. }
  2427. default:
  2428. {
  2429. target.push(endTag1, stringToChunk(type), endTag2);
  2430. }
  2431. }
  2432. }
  2433. function writeCompletedRoot(destination, responseState) {
  2434. var bootstrapChunks = responseState.bootstrapChunks;
  2435. var i = 0;
  2436. for (; i < bootstrapChunks.length - 1; i++) {
  2437. writeChunk(destination, bootstrapChunks[i]);
  2438. }
  2439. if (i < bootstrapChunks.length) {
  2440. return writeChunkAndReturn(destination, bootstrapChunks[i]);
  2441. }
  2442. return true;
  2443. } // Structural Nodes
  2444. // A placeholder is a node inside a hidden partial tree that can be filled in later, but before
  2445. // display. It's never visible to users. We use the template tag because it can be used in every
  2446. // type of parent. <script> tags also work in every other tag except <colgroup>.
  2447. var placeholder1 = stringToPrecomputedChunk('<template id="');
  2448. var placeholder2 = stringToPrecomputedChunk('"></template>');
  2449. function writePlaceholder(destination, responseState, id) {
  2450. writeChunk(destination, placeholder1);
  2451. writeChunk(destination, responseState.placeholderPrefix);
  2452. var formattedID = stringToChunk(id.toString(16));
  2453. writeChunk(destination, formattedID);
  2454. return writeChunkAndReturn(destination, placeholder2);
  2455. } // Suspense boundaries are encoded as comments.
  2456. var startCompletedSuspenseBoundary = stringToPrecomputedChunk('<!--$-->');
  2457. var startPendingSuspenseBoundary1 = stringToPrecomputedChunk('<!--$?--><template id="');
  2458. var startPendingSuspenseBoundary2 = stringToPrecomputedChunk('"></template>');
  2459. var startClientRenderedSuspenseBoundary = stringToPrecomputedChunk('<!--$!-->');
  2460. var endSuspenseBoundary = stringToPrecomputedChunk('<!--/$-->');
  2461. var clientRenderedSuspenseBoundaryError1 = stringToPrecomputedChunk('<template');
  2462. var clientRenderedSuspenseBoundaryErrorAttrInterstitial = stringToPrecomputedChunk('"');
  2463. var clientRenderedSuspenseBoundaryError1A = stringToPrecomputedChunk(' data-dgst="');
  2464. var clientRenderedSuspenseBoundaryError1B = stringToPrecomputedChunk(' data-msg="');
  2465. var clientRenderedSuspenseBoundaryError1C = stringToPrecomputedChunk(' data-stck="');
  2466. var clientRenderedSuspenseBoundaryError2 = stringToPrecomputedChunk('></template>');
  2467. function writeStartCompletedSuspenseBoundary(destination, responseState) {
  2468. return writeChunkAndReturn(destination, startCompletedSuspenseBoundary);
  2469. }
  2470. function writeStartPendingSuspenseBoundary(destination, responseState, id) {
  2471. writeChunk(destination, startPendingSuspenseBoundary1);
  2472. if (id === null) {
  2473. throw new Error('An ID must have been assigned before we can complete the boundary.');
  2474. }
  2475. writeChunk(destination, id);
  2476. return writeChunkAndReturn(destination, startPendingSuspenseBoundary2);
  2477. }
  2478. function writeStartClientRenderedSuspenseBoundary(destination, responseState, errorDigest, errorMesssage, errorComponentStack) {
  2479. var result;
  2480. result = writeChunkAndReturn(destination, startClientRenderedSuspenseBoundary);
  2481. writeChunk(destination, clientRenderedSuspenseBoundaryError1);
  2482. if (errorDigest) {
  2483. writeChunk(destination, clientRenderedSuspenseBoundaryError1A);
  2484. writeChunk(destination, stringToChunk(escapeTextForBrowser(errorDigest)));
  2485. writeChunk(destination, clientRenderedSuspenseBoundaryErrorAttrInterstitial);
  2486. }
  2487. {
  2488. if (errorMesssage) {
  2489. writeChunk(destination, clientRenderedSuspenseBoundaryError1B);
  2490. writeChunk(destination, stringToChunk(escapeTextForBrowser(errorMesssage)));
  2491. writeChunk(destination, clientRenderedSuspenseBoundaryErrorAttrInterstitial);
  2492. }
  2493. if (errorComponentStack) {
  2494. writeChunk(destination, clientRenderedSuspenseBoundaryError1C);
  2495. writeChunk(destination, stringToChunk(escapeTextForBrowser(errorComponentStack)));
  2496. writeChunk(destination, clientRenderedSuspenseBoundaryErrorAttrInterstitial);
  2497. }
  2498. }
  2499. result = writeChunkAndReturn(destination, clientRenderedSuspenseBoundaryError2);
  2500. return result;
  2501. }
  2502. function writeEndCompletedSuspenseBoundary(destination, responseState) {
  2503. return writeChunkAndReturn(destination, endSuspenseBoundary);
  2504. }
  2505. function writeEndPendingSuspenseBoundary(destination, responseState) {
  2506. return writeChunkAndReturn(destination, endSuspenseBoundary);
  2507. }
  2508. function writeEndClientRenderedSuspenseBoundary(destination, responseState) {
  2509. return writeChunkAndReturn(destination, endSuspenseBoundary);
  2510. }
  2511. var startSegmentHTML = stringToPrecomputedChunk('<div hidden id="');
  2512. var startSegmentHTML2 = stringToPrecomputedChunk('">');
  2513. var endSegmentHTML = stringToPrecomputedChunk('</div>');
  2514. var startSegmentSVG = stringToPrecomputedChunk('<svg aria-hidden="true" style="display:none" id="');
  2515. var startSegmentSVG2 = stringToPrecomputedChunk('">');
  2516. var endSegmentSVG = stringToPrecomputedChunk('</svg>');
  2517. var startSegmentMathML = stringToPrecomputedChunk('<math aria-hidden="true" style="display:none" id="');
  2518. var startSegmentMathML2 = stringToPrecomputedChunk('">');
  2519. var endSegmentMathML = stringToPrecomputedChunk('</math>');
  2520. var startSegmentTable = stringToPrecomputedChunk('<table hidden id="');
  2521. var startSegmentTable2 = stringToPrecomputedChunk('">');
  2522. var endSegmentTable = stringToPrecomputedChunk('</table>');
  2523. var startSegmentTableBody = stringToPrecomputedChunk('<table hidden><tbody id="');
  2524. var startSegmentTableBody2 = stringToPrecomputedChunk('">');
  2525. var endSegmentTableBody = stringToPrecomputedChunk('</tbody></table>');
  2526. var startSegmentTableRow = stringToPrecomputedChunk('<table hidden><tr id="');
  2527. var startSegmentTableRow2 = stringToPrecomputedChunk('">');
  2528. var endSegmentTableRow = stringToPrecomputedChunk('</tr></table>');
  2529. var startSegmentColGroup = stringToPrecomputedChunk('<table hidden><colgroup id="');
  2530. var startSegmentColGroup2 = stringToPrecomputedChunk('">');
  2531. var endSegmentColGroup = stringToPrecomputedChunk('</colgroup></table>');
  2532. function writeStartSegment(destination, responseState, formatContext, id) {
  2533. switch (formatContext.insertionMode) {
  2534. case ROOT_HTML_MODE:
  2535. case HTML_MODE:
  2536. {
  2537. writeChunk(destination, startSegmentHTML);
  2538. writeChunk(destination, responseState.segmentPrefix);
  2539. writeChunk(destination, stringToChunk(id.toString(16)));
  2540. return writeChunkAndReturn(destination, startSegmentHTML2);
  2541. }
  2542. case SVG_MODE:
  2543. {
  2544. writeChunk(destination, startSegmentSVG);
  2545. writeChunk(destination, responseState.segmentPrefix);
  2546. writeChunk(destination, stringToChunk(id.toString(16)));
  2547. return writeChunkAndReturn(destination, startSegmentSVG2);
  2548. }
  2549. case MATHML_MODE:
  2550. {
  2551. writeChunk(destination, startSegmentMathML);
  2552. writeChunk(destination, responseState.segmentPrefix);
  2553. writeChunk(destination, stringToChunk(id.toString(16)));
  2554. return writeChunkAndReturn(destination, startSegmentMathML2);
  2555. }
  2556. case HTML_TABLE_MODE:
  2557. {
  2558. writeChunk(destination, startSegmentTable);
  2559. writeChunk(destination, responseState.segmentPrefix);
  2560. writeChunk(destination, stringToChunk(id.toString(16)));
  2561. return writeChunkAndReturn(destination, startSegmentTable2);
  2562. }
  2563. // TODO: For the rest of these, there will be extra wrapper nodes that never
  2564. // get deleted from the document. We need to delete the table too as part
  2565. // of the injected scripts. They are invisible though so it's not too terrible
  2566. // and it's kind of an edge case to suspend in a table. Totally supported though.
  2567. case HTML_TABLE_BODY_MODE:
  2568. {
  2569. writeChunk(destination, startSegmentTableBody);
  2570. writeChunk(destination, responseState.segmentPrefix);
  2571. writeChunk(destination, stringToChunk(id.toString(16)));
  2572. return writeChunkAndReturn(destination, startSegmentTableBody2);
  2573. }
  2574. case HTML_TABLE_ROW_MODE:
  2575. {
  2576. writeChunk(destination, startSegmentTableRow);
  2577. writeChunk(destination, responseState.segmentPrefix);
  2578. writeChunk(destination, stringToChunk(id.toString(16)));
  2579. return writeChunkAndReturn(destination, startSegmentTableRow2);
  2580. }
  2581. case HTML_COLGROUP_MODE:
  2582. {
  2583. writeChunk(destination, startSegmentColGroup);
  2584. writeChunk(destination, responseState.segmentPrefix);
  2585. writeChunk(destination, stringToChunk(id.toString(16)));
  2586. return writeChunkAndReturn(destination, startSegmentColGroup2);
  2587. }
  2588. default:
  2589. {
  2590. throw new Error('Unknown insertion mode. This is a bug in React.');
  2591. }
  2592. }
  2593. }
  2594. function writeEndSegment(destination, formatContext) {
  2595. switch (formatContext.insertionMode) {
  2596. case ROOT_HTML_MODE:
  2597. case HTML_MODE:
  2598. {
  2599. return writeChunkAndReturn(destination, endSegmentHTML);
  2600. }
  2601. case SVG_MODE:
  2602. {
  2603. return writeChunkAndReturn(destination, endSegmentSVG);
  2604. }
  2605. case MATHML_MODE:
  2606. {
  2607. return writeChunkAndReturn(destination, endSegmentMathML);
  2608. }
  2609. case HTML_TABLE_MODE:
  2610. {
  2611. return writeChunkAndReturn(destination, endSegmentTable);
  2612. }
  2613. case HTML_TABLE_BODY_MODE:
  2614. {
  2615. return writeChunkAndReturn(destination, endSegmentTableBody);
  2616. }
  2617. case HTML_TABLE_ROW_MODE:
  2618. {
  2619. return writeChunkAndReturn(destination, endSegmentTableRow);
  2620. }
  2621. case HTML_COLGROUP_MODE:
  2622. {
  2623. return writeChunkAndReturn(destination, endSegmentColGroup);
  2624. }
  2625. default:
  2626. {
  2627. throw new Error('Unknown insertion mode. This is a bug in React.');
  2628. }
  2629. }
  2630. } // Instruction Set
  2631. // The following code is the source scripts that we then minify and inline below,
  2632. // with renamed function names that we hope don't collide:
  2633. // const COMMENT_NODE = 8;
  2634. // const SUSPENSE_START_DATA = '$';
  2635. // const SUSPENSE_END_DATA = '/$';
  2636. // const SUSPENSE_PENDING_START_DATA = '$?';
  2637. // const SUSPENSE_FALLBACK_START_DATA = '$!';
  2638. //
  2639. // function clientRenderBoundary(suspenseBoundaryID, errorDigest, errorMsg, errorComponentStack) {
  2640. // // Find the fallback's first element.
  2641. // const suspenseIdNode = document.getElementById(suspenseBoundaryID);
  2642. // if (!suspenseIdNode) {
  2643. // // The user must have already navigated away from this tree.
  2644. // // E.g. because the parent was hydrated.
  2645. // return;
  2646. // }
  2647. // // Find the boundary around the fallback. This is always the previous node.
  2648. // const suspenseNode = suspenseIdNode.previousSibling;
  2649. // // Tag it to be client rendered.
  2650. // suspenseNode.data = SUSPENSE_FALLBACK_START_DATA;
  2651. // // assign error metadata to first sibling
  2652. // let dataset = suspenseIdNode.dataset;
  2653. // if (errorDigest) dataset.dgst = errorDigest;
  2654. // if (errorMsg) dataset.msg = errorMsg;
  2655. // if (errorComponentStack) dataset.stck = errorComponentStack;
  2656. // // Tell React to retry it if the parent already hydrated.
  2657. // if (suspenseNode._reactRetry) {
  2658. // suspenseNode._reactRetry();
  2659. // }
  2660. // }
  2661. //
  2662. // function completeBoundary(suspenseBoundaryID, contentID) {
  2663. // // Find the fallback's first element.
  2664. // const suspenseIdNode = document.getElementById(suspenseBoundaryID);
  2665. // const contentNode = document.getElementById(contentID);
  2666. // // We'll detach the content node so that regardless of what happens next we don't leave in the tree.
  2667. // // This might also help by not causing recalcing each time we move a child from here to the target.
  2668. // contentNode.parentNode.removeChild(contentNode);
  2669. // if (!suspenseIdNode) {
  2670. // // The user must have already navigated away from this tree.
  2671. // // E.g. because the parent was hydrated. That's fine there's nothing to do
  2672. // // but we have to make sure that we already deleted the container node.
  2673. // return;
  2674. // }
  2675. // // Find the boundary around the fallback. This is always the previous node.
  2676. // const suspenseNode = suspenseIdNode.previousSibling;
  2677. //
  2678. // // Clear all the existing children. This is complicated because
  2679. // // there can be embedded Suspense boundaries in the fallback.
  2680. // // This is similar to clearSuspenseBoundary in ReactDOMHostConfig.
  2681. // // TODO: We could avoid this if we never emitted suspense boundaries in fallback trees.
  2682. // // They never hydrate anyway. However, currently we support incrementally loading the fallback.
  2683. // const parentInstance = suspenseNode.parentNode;
  2684. // let node = suspenseNode.nextSibling;
  2685. // let depth = 0;
  2686. // do {
  2687. // if (node && node.nodeType === COMMENT_NODE) {
  2688. // const data = node.data;
  2689. // if (data === SUSPENSE_END_DATA) {
  2690. // if (depth === 0) {
  2691. // break;
  2692. // } else {
  2693. // depth--;
  2694. // }
  2695. // } else if (
  2696. // data === SUSPENSE_START_DATA ||
  2697. // data === SUSPENSE_PENDING_START_DATA ||
  2698. // data === SUSPENSE_FALLBACK_START_DATA
  2699. // ) {
  2700. // depth++;
  2701. // }
  2702. // }
  2703. //
  2704. // const nextNode = node.nextSibling;
  2705. // parentInstance.removeChild(node);
  2706. // node = nextNode;
  2707. // } while (node);
  2708. //
  2709. // const endOfBoundary = node;
  2710. //
  2711. // // Insert all the children from the contentNode between the start and end of suspense boundary.
  2712. // while (contentNode.firstChild) {
  2713. // parentInstance.insertBefore(contentNode.firstChild, endOfBoundary);
  2714. // }
  2715. // suspenseNode.data = SUSPENSE_START_DATA;
  2716. // if (suspenseNode._reactRetry) {
  2717. // suspenseNode._reactRetry();
  2718. // }
  2719. // }
  2720. //
  2721. // function completeSegment(containerID, placeholderID) {
  2722. // const segmentContainer = document.getElementById(containerID);
  2723. // const placeholderNode = document.getElementById(placeholderID);
  2724. // // We always expect both nodes to exist here because, while we might
  2725. // // have navigated away from the main tree, we still expect the detached
  2726. // // tree to exist.
  2727. // segmentContainer.parentNode.removeChild(segmentContainer);
  2728. // while (segmentContainer.firstChild) {
  2729. // placeholderNode.parentNode.insertBefore(
  2730. // segmentContainer.firstChild,
  2731. // placeholderNode,
  2732. // );
  2733. // }
  2734. // placeholderNode.parentNode.removeChild(placeholderNode);
  2735. // }
  2736. var completeSegmentFunction = 'function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)}';
  2737. var completeBoundaryFunction = 'function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}}';
  2738. var clientRenderFunction = 'function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())}';
  2739. var completeSegmentScript1Full = stringToPrecomputedChunk(completeSegmentFunction + ';$RS("');
  2740. var completeSegmentScript1Partial = stringToPrecomputedChunk('$RS("');
  2741. var completeSegmentScript2 = stringToPrecomputedChunk('","');
  2742. var completeSegmentScript3 = stringToPrecomputedChunk('")</script>');
  2743. function writeCompletedSegmentInstruction(destination, responseState, contentSegmentID) {
  2744. writeChunk(destination, responseState.startInlineScript);
  2745. if (!responseState.sentCompleteSegmentFunction) {
  2746. // The first time we write this, we'll need to include the full implementation.
  2747. responseState.sentCompleteSegmentFunction = true;
  2748. writeChunk(destination, completeSegmentScript1Full);
  2749. } else {
  2750. // Future calls can just reuse the same function.
  2751. writeChunk(destination, completeSegmentScript1Partial);
  2752. }
  2753. writeChunk(destination, responseState.segmentPrefix);
  2754. var formattedID = stringToChunk(contentSegmentID.toString(16));
  2755. writeChunk(destination, formattedID);
  2756. writeChunk(destination, completeSegmentScript2);
  2757. writeChunk(destination, responseState.placeholderPrefix);
  2758. writeChunk(destination, formattedID);
  2759. return writeChunkAndReturn(destination, completeSegmentScript3);
  2760. }
  2761. var completeBoundaryScript1Full = stringToPrecomputedChunk(completeBoundaryFunction + ';$RC("');
  2762. var completeBoundaryScript1Partial = stringToPrecomputedChunk('$RC("');
  2763. var completeBoundaryScript2 = stringToPrecomputedChunk('","');
  2764. var completeBoundaryScript3 = stringToPrecomputedChunk('")</script>');
  2765. function writeCompletedBoundaryInstruction(destination, responseState, boundaryID, contentSegmentID) {
  2766. writeChunk(destination, responseState.startInlineScript);
  2767. if (!responseState.sentCompleteBoundaryFunction) {
  2768. // The first time we write this, we'll need to include the full implementation.
  2769. responseState.sentCompleteBoundaryFunction = true;
  2770. writeChunk(destination, completeBoundaryScript1Full);
  2771. } else {
  2772. // Future calls can just reuse the same function.
  2773. writeChunk(destination, completeBoundaryScript1Partial);
  2774. }
  2775. if (boundaryID === null) {
  2776. throw new Error('An ID must have been assigned before we can complete the boundary.');
  2777. }
  2778. var formattedContentID = stringToChunk(contentSegmentID.toString(16));
  2779. writeChunk(destination, boundaryID);
  2780. writeChunk(destination, completeBoundaryScript2);
  2781. writeChunk(destination, responseState.segmentPrefix);
  2782. writeChunk(destination, formattedContentID);
  2783. return writeChunkAndReturn(destination, completeBoundaryScript3);
  2784. }
  2785. var clientRenderScript1Full = stringToPrecomputedChunk(clientRenderFunction + ';$RX("');
  2786. var clientRenderScript1Partial = stringToPrecomputedChunk('$RX("');
  2787. var clientRenderScript1A = stringToPrecomputedChunk('"');
  2788. var clientRenderScript2 = stringToPrecomputedChunk(')</script>');
  2789. var clientRenderErrorScriptArgInterstitial = stringToPrecomputedChunk(',');
  2790. function writeClientRenderBoundaryInstruction(destination, responseState, boundaryID, errorDigest, errorMessage, errorComponentStack) {
  2791. writeChunk(destination, responseState.startInlineScript);
  2792. if (!responseState.sentClientRenderFunction) {
  2793. // The first time we write this, we'll need to include the full implementation.
  2794. responseState.sentClientRenderFunction = true;
  2795. writeChunk(destination, clientRenderScript1Full);
  2796. } else {
  2797. // Future calls can just reuse the same function.
  2798. writeChunk(destination, clientRenderScript1Partial);
  2799. }
  2800. if (boundaryID === null) {
  2801. throw new Error('An ID must have been assigned before we can complete the boundary.');
  2802. }
  2803. writeChunk(destination, boundaryID);
  2804. writeChunk(destination, clientRenderScript1A);
  2805. if (errorDigest || errorMessage || errorComponentStack) {
  2806. writeChunk(destination, clientRenderErrorScriptArgInterstitial);
  2807. writeChunk(destination, stringToChunk(escapeJSStringsForInstructionScripts(errorDigest || '')));
  2808. }
  2809. if (errorMessage || errorComponentStack) {
  2810. writeChunk(destination, clientRenderErrorScriptArgInterstitial);
  2811. writeChunk(destination, stringToChunk(escapeJSStringsForInstructionScripts(errorMessage || '')));
  2812. }
  2813. if (errorComponentStack) {
  2814. writeChunk(destination, clientRenderErrorScriptArgInterstitial);
  2815. writeChunk(destination, stringToChunk(escapeJSStringsForInstructionScripts(errorComponentStack)));
  2816. }
  2817. return writeChunkAndReturn(destination, clientRenderScript2);
  2818. }
  2819. var regexForJSStringsInScripts = /[<\u2028\u2029]/g;
  2820. function escapeJSStringsForInstructionScripts(input) {
  2821. var escaped = JSON.stringify(input);
  2822. return escaped.replace(regexForJSStringsInScripts, function (match) {
  2823. switch (match) {
  2824. // santizing breaking out of strings and script tags
  2825. case '<':
  2826. return "\\u003c";
  2827. case "\u2028":
  2828. return "\\u2028";
  2829. case "\u2029":
  2830. return "\\u2029";
  2831. default:
  2832. {
  2833. // eslint-disable-next-line react-internal/prod-error-codes
  2834. throw new Error('escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React');
  2835. }
  2836. }
  2837. });
  2838. }
  2839. function createResponseState$1(generateStaticMarkup, identifierPrefix) {
  2840. var responseState = createResponseState(identifierPrefix, undefined);
  2841. return {
  2842. // Keep this in sync with ReactDOMServerFormatConfig
  2843. bootstrapChunks: responseState.bootstrapChunks,
  2844. startInlineScript: responseState.startInlineScript,
  2845. placeholderPrefix: responseState.placeholderPrefix,
  2846. segmentPrefix: responseState.segmentPrefix,
  2847. boundaryPrefix: responseState.boundaryPrefix,
  2848. idPrefix: responseState.idPrefix,
  2849. nextSuspenseID: responseState.nextSuspenseID,
  2850. sentCompleteSegmentFunction: responseState.sentCompleteSegmentFunction,
  2851. sentCompleteBoundaryFunction: responseState.sentCompleteBoundaryFunction,
  2852. sentClientRenderFunction: responseState.sentClientRenderFunction,
  2853. // This is an extra field for the legacy renderer
  2854. generateStaticMarkup: generateStaticMarkup
  2855. };
  2856. }
  2857. function createRootFormatContext() {
  2858. return {
  2859. insertionMode: HTML_MODE,
  2860. // We skip the root mode because we don't want to emit the DOCTYPE in legacy mode.
  2861. selectedValue: null
  2862. };
  2863. }
  2864. function pushTextInstance$1(target, text, responseState, textEmbedded) {
  2865. if (responseState.generateStaticMarkup) {
  2866. target.push(stringToChunk(escapeTextForBrowser(text)));
  2867. return false;
  2868. } else {
  2869. return pushTextInstance(target, text, responseState, textEmbedded);
  2870. }
  2871. }
  2872. function pushSegmentFinale$1(target, responseState, lastPushedText, textEmbedded) {
  2873. if (responseState.generateStaticMarkup) {
  2874. return;
  2875. } else {
  2876. return pushSegmentFinale(target, responseState, lastPushedText, textEmbedded);
  2877. }
  2878. }
  2879. function writeStartCompletedSuspenseBoundary$1(destination, responseState) {
  2880. if (responseState.generateStaticMarkup) {
  2881. // A completed boundary is done and doesn't need a representation in the HTML
  2882. // if we're not going to be hydrating it.
  2883. return true;
  2884. }
  2885. return writeStartCompletedSuspenseBoundary(destination);
  2886. }
  2887. function writeStartClientRenderedSuspenseBoundary$1(destination, responseState, // flushing these error arguments are not currently supported in this legacy streaming format.
  2888. errorDigest, errorMessage, errorComponentStack) {
  2889. if (responseState.generateStaticMarkup) {
  2890. // A client rendered boundary is done and doesn't need a representation in the HTML
  2891. // since we'll never hydrate it. This is arguably an error in static generation.
  2892. return true;
  2893. }
  2894. return writeStartClientRenderedSuspenseBoundary(destination, responseState, errorDigest, errorMessage, errorComponentStack);
  2895. }
  2896. function writeEndCompletedSuspenseBoundary$1(destination, responseState) {
  2897. if (responseState.generateStaticMarkup) {
  2898. return true;
  2899. }
  2900. return writeEndCompletedSuspenseBoundary(destination);
  2901. }
  2902. function writeEndClientRenderedSuspenseBoundary$1(destination, responseState) {
  2903. if (responseState.generateStaticMarkup) {
  2904. return true;
  2905. }
  2906. return writeEndClientRenderedSuspenseBoundary(destination);
  2907. }
  2908. var assign = Object.assign;
  2909. // ATTENTION
  2910. // When adding new symbols to this file,
  2911. // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
  2912. // The Symbol used to tag the ReactElement-like types.
  2913. var REACT_ELEMENT_TYPE = Symbol.for('react.element');
  2914. var REACT_PORTAL_TYPE = Symbol.for('react.portal');
  2915. var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
  2916. var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
  2917. var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
  2918. var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
  2919. var REACT_CONTEXT_TYPE = Symbol.for('react.context');
  2920. var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
  2921. var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
  2922. var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
  2923. var REACT_MEMO_TYPE = Symbol.for('react.memo');
  2924. var REACT_LAZY_TYPE = Symbol.for('react.lazy');
  2925. var REACT_SCOPE_TYPE = Symbol.for('react.scope');
  2926. var REACT_DEBUG_TRACING_MODE_TYPE = Symbol.for('react.debug_trace_mode');
  2927. var REACT_LEGACY_HIDDEN_TYPE = Symbol.for('react.legacy_hidden');
  2928. var REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED = Symbol.for('react.default_value');
  2929. var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
  2930. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  2931. function getIteratorFn(maybeIterable) {
  2932. if (maybeIterable === null || typeof maybeIterable !== 'object') {
  2933. return null;
  2934. }
  2935. var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
  2936. if (typeof maybeIterator === 'function') {
  2937. return maybeIterator;
  2938. }
  2939. return null;
  2940. }
  2941. function getWrappedName(outerType, innerType, wrapperName) {
  2942. var displayName = outerType.displayName;
  2943. if (displayName) {
  2944. return displayName;
  2945. }
  2946. var functionName = innerType.displayName || innerType.name || '';
  2947. return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;
  2948. } // Keep in sync with react-reconciler/getComponentNameFromFiber
  2949. function getContextName(type) {
  2950. return type.displayName || 'Context';
  2951. } // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
  2952. function getComponentNameFromType(type) {
  2953. if (type == null) {
  2954. // Host root, text node or just invalid type.
  2955. return null;
  2956. }
  2957. {
  2958. if (typeof type.tag === 'number') {
  2959. error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
  2960. }
  2961. }
  2962. if (typeof type === 'function') {
  2963. return type.displayName || type.name || null;
  2964. }
  2965. if (typeof type === 'string') {
  2966. return type;
  2967. }
  2968. switch (type) {
  2969. case REACT_FRAGMENT_TYPE:
  2970. return 'Fragment';
  2971. case REACT_PORTAL_TYPE:
  2972. return 'Portal';
  2973. case REACT_PROFILER_TYPE:
  2974. return 'Profiler';
  2975. case REACT_STRICT_MODE_TYPE:
  2976. return 'StrictMode';
  2977. case REACT_SUSPENSE_TYPE:
  2978. return 'Suspense';
  2979. case REACT_SUSPENSE_LIST_TYPE:
  2980. return 'SuspenseList';
  2981. }
  2982. if (typeof type === 'object') {
  2983. switch (type.$$typeof) {
  2984. case REACT_CONTEXT_TYPE:
  2985. var context = type;
  2986. return getContextName(context) + '.Consumer';
  2987. case REACT_PROVIDER_TYPE:
  2988. var provider = type;
  2989. return getContextName(provider._context) + '.Provider';
  2990. case REACT_FORWARD_REF_TYPE:
  2991. return getWrappedName(type, type.render, 'ForwardRef');
  2992. case REACT_MEMO_TYPE:
  2993. var outerName = type.displayName || null;
  2994. if (outerName !== null) {
  2995. return outerName;
  2996. }
  2997. return getComponentNameFromType(type.type) || 'Memo';
  2998. case REACT_LAZY_TYPE:
  2999. {
  3000. var lazyComponent = type;
  3001. var payload = lazyComponent._payload;
  3002. var init = lazyComponent._init;
  3003. try {
  3004. return getComponentNameFromType(init(payload));
  3005. } catch (x) {
  3006. return null;
  3007. }
  3008. }
  3009. // eslint-disable-next-line no-fallthrough
  3010. }
  3011. }
  3012. return null;
  3013. }
  3014. // Helpers to patch console.logs to avoid logging during side-effect free
  3015. // replaying on render function. This currently only patches the object
  3016. // lazily which won't cover if the log function was extracted eagerly.
  3017. // We could also eagerly patch the method.
  3018. var disabledDepth = 0;
  3019. var prevLog;
  3020. var prevInfo;
  3021. var prevWarn;
  3022. var prevError;
  3023. var prevGroup;
  3024. var prevGroupCollapsed;
  3025. var prevGroupEnd;
  3026. function disabledLog() {}
  3027. disabledLog.__reactDisabledLog = true;
  3028. function disableLogs() {
  3029. {
  3030. if (disabledDepth === 0) {
  3031. /* eslint-disable react-internal/no-production-logging */
  3032. prevLog = console.log;
  3033. prevInfo = console.info;
  3034. prevWarn = console.warn;
  3035. prevError = console.error;
  3036. prevGroup = console.group;
  3037. prevGroupCollapsed = console.groupCollapsed;
  3038. prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
  3039. var props = {
  3040. configurable: true,
  3041. enumerable: true,
  3042. value: disabledLog,
  3043. writable: true
  3044. }; // $FlowFixMe Flow thinks console is immutable.
  3045. Object.defineProperties(console, {
  3046. info: props,
  3047. log: props,
  3048. warn: props,
  3049. error: props,
  3050. group: props,
  3051. groupCollapsed: props,
  3052. groupEnd: props
  3053. });
  3054. /* eslint-enable react-internal/no-production-logging */
  3055. }
  3056. disabledDepth++;
  3057. }
  3058. }
  3059. function reenableLogs() {
  3060. {
  3061. disabledDepth--;
  3062. if (disabledDepth === 0) {
  3063. /* eslint-disable react-internal/no-production-logging */
  3064. var props = {
  3065. configurable: true,
  3066. enumerable: true,
  3067. writable: true
  3068. }; // $FlowFixMe Flow thinks console is immutable.
  3069. Object.defineProperties(console, {
  3070. log: assign({}, props, {
  3071. value: prevLog
  3072. }),
  3073. info: assign({}, props, {
  3074. value: prevInfo
  3075. }),
  3076. warn: assign({}, props, {
  3077. value: prevWarn
  3078. }),
  3079. error: assign({}, props, {
  3080. value: prevError
  3081. }),
  3082. group: assign({}, props, {
  3083. value: prevGroup
  3084. }),
  3085. groupCollapsed: assign({}, props, {
  3086. value: prevGroupCollapsed
  3087. }),
  3088. groupEnd: assign({}, props, {
  3089. value: prevGroupEnd
  3090. })
  3091. });
  3092. /* eslint-enable react-internal/no-production-logging */
  3093. }
  3094. if (disabledDepth < 0) {
  3095. error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
  3096. }
  3097. }
  3098. }
  3099. var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
  3100. var prefix;
  3101. function describeBuiltInComponentFrame(name, source, ownerFn) {
  3102. {
  3103. if (prefix === undefined) {
  3104. // Extract the VM specific prefix used by each line.
  3105. try {
  3106. throw Error();
  3107. } catch (x) {
  3108. var match = x.stack.trim().match(/\n( *(at )?)/);
  3109. prefix = match && match[1] || '';
  3110. }
  3111. } // We use the prefix to ensure our stacks line up with native stack frames.
  3112. return '\n' + prefix + name;
  3113. }
  3114. }
  3115. var reentry = false;
  3116. var componentFrameCache;
  3117. {
  3118. var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
  3119. componentFrameCache = new PossiblyWeakMap();
  3120. }
  3121. function describeNativeComponentFrame(fn, construct) {
  3122. // If something asked for a stack inside a fake render, it should get ignored.
  3123. if ( !fn || reentry) {
  3124. return '';
  3125. }
  3126. {
  3127. var frame = componentFrameCache.get(fn);
  3128. if (frame !== undefined) {
  3129. return frame;
  3130. }
  3131. }
  3132. var control;
  3133. reentry = true;
  3134. var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
  3135. Error.prepareStackTrace = undefined;
  3136. var previousDispatcher;
  3137. {
  3138. previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function
  3139. // for warnings.
  3140. ReactCurrentDispatcher.current = null;
  3141. disableLogs();
  3142. }
  3143. try {
  3144. // This should throw.
  3145. if (construct) {
  3146. // Something should be setting the props in the constructor.
  3147. var Fake = function () {
  3148. throw Error();
  3149. }; // $FlowFixMe
  3150. Object.defineProperty(Fake.prototype, 'props', {
  3151. set: function () {
  3152. // We use a throwing setter instead of frozen or non-writable props
  3153. // because that won't throw in a non-strict mode function.
  3154. throw Error();
  3155. }
  3156. });
  3157. if (typeof Reflect === 'object' && Reflect.construct) {
  3158. // We construct a different control for this case to include any extra
  3159. // frames added by the construct call.
  3160. try {
  3161. Reflect.construct(Fake, []);
  3162. } catch (x) {
  3163. control = x;
  3164. }
  3165. Reflect.construct(fn, [], Fake);
  3166. } else {
  3167. try {
  3168. Fake.call();
  3169. } catch (x) {
  3170. control = x;
  3171. }
  3172. fn.call(Fake.prototype);
  3173. }
  3174. } else {
  3175. try {
  3176. throw Error();
  3177. } catch (x) {
  3178. control = x;
  3179. }
  3180. fn();
  3181. }
  3182. } catch (sample) {
  3183. // This is inlined manually because closure doesn't do it for us.
  3184. if (sample && control && typeof sample.stack === 'string') {
  3185. // This extracts the first frame from the sample that isn't also in the control.
  3186. // Skipping one frame that we assume is the frame that calls the two.
  3187. var sampleLines = sample.stack.split('\n');
  3188. var controlLines = control.stack.split('\n');
  3189. var s = sampleLines.length - 1;
  3190. var c = controlLines.length - 1;
  3191. while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
  3192. // We expect at least one stack frame to be shared.
  3193. // Typically this will be the root most one. However, stack frames may be
  3194. // cut off due to maximum stack limits. In this case, one maybe cut off
  3195. // earlier than the other. We assume that the sample is longer or the same
  3196. // and there for cut off earlier. So we should find the root most frame in
  3197. // the sample somewhere in the control.
  3198. c--;
  3199. }
  3200. for (; s >= 1 && c >= 0; s--, c--) {
  3201. // Next we find the first one that isn't the same which should be the
  3202. // frame that called our sample function and the control.
  3203. if (sampleLines[s] !== controlLines[c]) {
  3204. // In V8, the first line is describing the message but other VMs don't.
  3205. // If we're about to return the first line, and the control is also on the same
  3206. // line, that's a pretty good indicator that our sample threw at same line as
  3207. // the control. I.e. before we entered the sample frame. So we ignore this result.
  3208. // This can happen if you passed a class to function component, or non-function.
  3209. if (s !== 1 || c !== 1) {
  3210. do {
  3211. s--;
  3212. c--; // We may still have similar intermediate frames from the construct call.
  3213. // The next one that isn't the same should be our match though.
  3214. if (c < 0 || sampleLines[s] !== controlLines[c]) {
  3215. // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
  3216. var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>"
  3217. // but we have a user-provided "displayName"
  3218. // splice it in to make the stack more readable.
  3219. if (fn.displayName && _frame.includes('<anonymous>')) {
  3220. _frame = _frame.replace('<anonymous>', fn.displayName);
  3221. }
  3222. {
  3223. if (typeof fn === 'function') {
  3224. componentFrameCache.set(fn, _frame);
  3225. }
  3226. } // Return the line we found.
  3227. return _frame;
  3228. }
  3229. } while (s >= 1 && c >= 0);
  3230. }
  3231. break;
  3232. }
  3233. }
  3234. }
  3235. } finally {
  3236. reentry = false;
  3237. {
  3238. ReactCurrentDispatcher.current = previousDispatcher;
  3239. reenableLogs();
  3240. }
  3241. Error.prepareStackTrace = previousPrepareStackTrace;
  3242. } // Fallback to just using the name if we couldn't make it throw.
  3243. var name = fn ? fn.displayName || fn.name : '';
  3244. var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
  3245. {
  3246. if (typeof fn === 'function') {
  3247. componentFrameCache.set(fn, syntheticFrame);
  3248. }
  3249. }
  3250. return syntheticFrame;
  3251. }
  3252. function describeClassComponentFrame(ctor, source, ownerFn) {
  3253. {
  3254. return describeNativeComponentFrame(ctor, true);
  3255. }
  3256. }
  3257. function describeFunctionComponentFrame(fn, source, ownerFn) {
  3258. {
  3259. return describeNativeComponentFrame(fn, false);
  3260. }
  3261. }
  3262. function shouldConstruct(Component) {
  3263. var prototype = Component.prototype;
  3264. return !!(prototype && prototype.isReactComponent);
  3265. }
  3266. function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
  3267. if (type == null) {
  3268. return '';
  3269. }
  3270. if (typeof type === 'function') {
  3271. {
  3272. return describeNativeComponentFrame(type, shouldConstruct(type));
  3273. }
  3274. }
  3275. if (typeof type === 'string') {
  3276. return describeBuiltInComponentFrame(type);
  3277. }
  3278. switch (type) {
  3279. case REACT_SUSPENSE_TYPE:
  3280. return describeBuiltInComponentFrame('Suspense');
  3281. case REACT_SUSPENSE_LIST_TYPE:
  3282. return describeBuiltInComponentFrame('SuspenseList');
  3283. }
  3284. if (typeof type === 'object') {
  3285. switch (type.$$typeof) {
  3286. case REACT_FORWARD_REF_TYPE:
  3287. return describeFunctionComponentFrame(type.render);
  3288. case REACT_MEMO_TYPE:
  3289. // Memo may contain any component type so we recursively resolve it.
  3290. return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
  3291. case REACT_LAZY_TYPE:
  3292. {
  3293. var lazyComponent = type;
  3294. var payload = lazyComponent._payload;
  3295. var init = lazyComponent._init;
  3296. try {
  3297. // Lazy may contain any component type so we recursively resolve it.
  3298. return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
  3299. } catch (x) {}
  3300. }
  3301. }
  3302. }
  3303. return '';
  3304. }
  3305. var loggedTypeFailures = {};
  3306. var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
  3307. function setCurrentlyValidatingElement(element) {
  3308. {
  3309. if (element) {
  3310. var owner = element._owner;
  3311. var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
  3312. ReactDebugCurrentFrame.setExtraStackFrame(stack);
  3313. } else {
  3314. ReactDebugCurrentFrame.setExtraStackFrame(null);
  3315. }
  3316. }
  3317. }
  3318. function checkPropTypes(typeSpecs, values, location, componentName, element) {
  3319. {
  3320. // $FlowFixMe This is okay but Flow doesn't know it.
  3321. var has = Function.call.bind(hasOwnProperty);
  3322. for (var typeSpecName in typeSpecs) {
  3323. if (has(typeSpecs, typeSpecName)) {
  3324. var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
  3325. // fail the render phase where it didn't fail before. So we log it.
  3326. // After these have been cleaned up, we'll let them throw.
  3327. try {
  3328. // This is intentionally an invariant that gets caught. It's the same
  3329. // behavior as without this statement except with a better message.
  3330. if (typeof typeSpecs[typeSpecName] !== 'function') {
  3331. // eslint-disable-next-line react-internal/prod-error-codes
  3332. 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`.');
  3333. err.name = 'Invariant Violation';
  3334. throw err;
  3335. }
  3336. error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
  3337. } catch (ex) {
  3338. error$1 = ex;
  3339. }
  3340. if (error$1 && !(error$1 instanceof Error)) {
  3341. setCurrentlyValidatingElement(element);
  3342. 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);
  3343. setCurrentlyValidatingElement(null);
  3344. }
  3345. if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
  3346. // Only monitor this failure once because there tends to be a lot of the
  3347. // same error.
  3348. loggedTypeFailures[error$1.message] = true;
  3349. setCurrentlyValidatingElement(element);
  3350. error('Failed %s type: %s', location, error$1.message);
  3351. setCurrentlyValidatingElement(null);
  3352. }
  3353. }
  3354. }
  3355. }
  3356. }
  3357. var warnedAboutMissingGetChildContext;
  3358. {
  3359. warnedAboutMissingGetChildContext = {};
  3360. }
  3361. var emptyContextObject = {};
  3362. {
  3363. Object.freeze(emptyContextObject);
  3364. }
  3365. function getMaskedContext(type, unmaskedContext) {
  3366. {
  3367. var contextTypes = type.contextTypes;
  3368. if (!contextTypes) {
  3369. return emptyContextObject;
  3370. }
  3371. var context = {};
  3372. for (var key in contextTypes) {
  3373. context[key] = unmaskedContext[key];
  3374. }
  3375. {
  3376. var name = getComponentNameFromType(type) || 'Unknown';
  3377. checkPropTypes(contextTypes, context, 'context', name);
  3378. }
  3379. return context;
  3380. }
  3381. }
  3382. function processChildContext(instance, type, parentContext, childContextTypes) {
  3383. {
  3384. // TODO (bvaughn) Replace this behavior with an invariant() in the future.
  3385. // It has only been added in Fiber to match the (unintentional) behavior in Stack.
  3386. if (typeof instance.getChildContext !== 'function') {
  3387. {
  3388. var componentName = getComponentNameFromType(type) || 'Unknown';
  3389. if (!warnedAboutMissingGetChildContext[componentName]) {
  3390. warnedAboutMissingGetChildContext[componentName] = true;
  3391. 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);
  3392. }
  3393. }
  3394. return parentContext;
  3395. }
  3396. var childContext = instance.getChildContext();
  3397. for (var contextKey in childContext) {
  3398. if (!(contextKey in childContextTypes)) {
  3399. throw new Error((getComponentNameFromType(type) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes.");
  3400. }
  3401. }
  3402. {
  3403. var name = getComponentNameFromType(type) || 'Unknown';
  3404. checkPropTypes(childContextTypes, childContext, 'child context', name);
  3405. }
  3406. return assign({}, parentContext, childContext);
  3407. }
  3408. }
  3409. var rendererSigil;
  3410. {
  3411. // Use this to detect multiple renderers using the same context
  3412. rendererSigil = {};
  3413. } // Used to store the parent path of all context overrides in a shared linked list.
  3414. // Forming a reverse tree.
  3415. var rootContextSnapshot = null; // We assume that this runtime owns the "current" field on all ReactContext instances.
  3416. // This global (actually thread local) state represents what state all those "current",
  3417. // fields are currently in.
  3418. var currentActiveSnapshot = null;
  3419. function popNode(prev) {
  3420. {
  3421. prev.context._currentValue2 = prev.parentValue;
  3422. }
  3423. }
  3424. function pushNode(next) {
  3425. {
  3426. next.context._currentValue2 = next.value;
  3427. }
  3428. }
  3429. function popToNearestCommonAncestor(prev, next) {
  3430. if (prev === next) ; else {
  3431. popNode(prev);
  3432. var parentPrev = prev.parent;
  3433. var parentNext = next.parent;
  3434. if (parentPrev === null) {
  3435. if (parentNext !== null) {
  3436. throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
  3437. }
  3438. } else {
  3439. if (parentNext === null) {
  3440. throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
  3441. }
  3442. popToNearestCommonAncestor(parentPrev, parentNext);
  3443. } // On the way back, we push the new ones that weren't common.
  3444. pushNode(next);
  3445. }
  3446. }
  3447. function popAllPrevious(prev) {
  3448. popNode(prev);
  3449. var parentPrev = prev.parent;
  3450. if (parentPrev !== null) {
  3451. popAllPrevious(parentPrev);
  3452. }
  3453. }
  3454. function pushAllNext(next) {
  3455. var parentNext = next.parent;
  3456. if (parentNext !== null) {
  3457. pushAllNext(parentNext);
  3458. }
  3459. pushNode(next);
  3460. }
  3461. function popPreviousToCommonLevel(prev, next) {
  3462. popNode(prev);
  3463. var parentPrev = prev.parent;
  3464. if (parentPrev === null) {
  3465. throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.');
  3466. }
  3467. if (parentPrev.depth === next.depth) {
  3468. // We found the same level. Now we just need to find a shared ancestor.
  3469. popToNearestCommonAncestor(parentPrev, next);
  3470. } else {
  3471. // We must still be deeper.
  3472. popPreviousToCommonLevel(parentPrev, next);
  3473. }
  3474. }
  3475. function popNextToCommonLevel(prev, next) {
  3476. var parentNext = next.parent;
  3477. if (parentNext === null) {
  3478. throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.');
  3479. }
  3480. if (prev.depth === parentNext.depth) {
  3481. // We found the same level. Now we just need to find a shared ancestor.
  3482. popToNearestCommonAncestor(prev, parentNext);
  3483. } else {
  3484. // We must still be deeper.
  3485. popNextToCommonLevel(prev, parentNext);
  3486. }
  3487. pushNode(next);
  3488. } // Perform context switching to the new snapshot.
  3489. // To make it cheap to read many contexts, while not suspending, we make the switch eagerly by
  3490. // updating all the context's current values. That way reads, always just read the current value.
  3491. // At the cost of updating contexts even if they're never read by this subtree.
  3492. function switchContext(newSnapshot) {
  3493. // The basic algorithm we need to do is to pop back any contexts that are no longer on the stack.
  3494. // We also need to update any new contexts that are now on the stack with the deepest value.
  3495. // The easiest way to update new contexts is to just reapply them in reverse order from the
  3496. // perspective of the backpointers. To avoid allocating a lot when switching, we use the stack
  3497. // for that. Therefore this algorithm is recursive.
  3498. // 1) First we pop which ever snapshot tree was deepest. Popping old contexts as we go.
  3499. // 2) Then we find the nearest common ancestor from there. Popping old contexts as we go.
  3500. // 3) Then we reapply new contexts on the way back up the stack.
  3501. var prev = currentActiveSnapshot;
  3502. var next = newSnapshot;
  3503. if (prev !== next) {
  3504. if (prev === null) {
  3505. // $FlowFixMe: This has to be non-null since it's not equal to prev.
  3506. pushAllNext(next);
  3507. } else if (next === null) {
  3508. popAllPrevious(prev);
  3509. } else if (prev.depth === next.depth) {
  3510. popToNearestCommonAncestor(prev, next);
  3511. } else if (prev.depth > next.depth) {
  3512. popPreviousToCommonLevel(prev, next);
  3513. } else {
  3514. popNextToCommonLevel(prev, next);
  3515. }
  3516. currentActiveSnapshot = next;
  3517. }
  3518. }
  3519. function pushProvider(context, nextValue) {
  3520. var prevValue;
  3521. {
  3522. prevValue = context._currentValue2;
  3523. context._currentValue2 = nextValue;
  3524. {
  3525. if (context._currentRenderer2 !== undefined && context._currentRenderer2 !== null && context._currentRenderer2 !== rendererSigil) {
  3526. error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.');
  3527. }
  3528. context._currentRenderer2 = rendererSigil;
  3529. }
  3530. }
  3531. var prevNode = currentActiveSnapshot;
  3532. var newNode = {
  3533. parent: prevNode,
  3534. depth: prevNode === null ? 0 : prevNode.depth + 1,
  3535. context: context,
  3536. parentValue: prevValue,
  3537. value: nextValue
  3538. };
  3539. currentActiveSnapshot = newNode;
  3540. return newNode;
  3541. }
  3542. function popProvider(context) {
  3543. var prevSnapshot = currentActiveSnapshot;
  3544. if (prevSnapshot === null) {
  3545. throw new Error('Tried to pop a Context at the root of the app. This is a bug in React.');
  3546. }
  3547. {
  3548. if (prevSnapshot.context !== context) {
  3549. error('The parent context is not the expected context. This is probably a bug in React.');
  3550. }
  3551. }
  3552. {
  3553. var _value = prevSnapshot.parentValue;
  3554. if (_value === REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED) {
  3555. prevSnapshot.context._currentValue2 = prevSnapshot.context._defaultValue;
  3556. } else {
  3557. prevSnapshot.context._currentValue2 = _value;
  3558. }
  3559. {
  3560. if (context._currentRenderer2 !== undefined && context._currentRenderer2 !== null && context._currentRenderer2 !== rendererSigil) {
  3561. error('Detected multiple renderers concurrently rendering the ' + 'same context provider. This is currently unsupported.');
  3562. }
  3563. context._currentRenderer2 = rendererSigil;
  3564. }
  3565. }
  3566. return currentActiveSnapshot = prevSnapshot.parent;
  3567. }
  3568. function getActiveContext() {
  3569. return currentActiveSnapshot;
  3570. }
  3571. function readContext(context) {
  3572. var value = context._currentValue2;
  3573. return value;
  3574. }
  3575. /**
  3576. * `ReactInstanceMap` maintains a mapping from a public facing stateful
  3577. * instance (key) and the internal representation (value). This allows public
  3578. * methods to accept the user facing instance as an argument and map them back
  3579. * to internal methods.
  3580. *
  3581. * Note that this module is currently shared and assumed to be stateless.
  3582. * If this becomes an actual Map, that will break.
  3583. */
  3584. function get(key) {
  3585. return key._reactInternals;
  3586. }
  3587. function set(key, value) {
  3588. key._reactInternals = value;
  3589. }
  3590. var didWarnAboutNoopUpdateForComponent = {};
  3591. var didWarnAboutDeprecatedWillMount = {};
  3592. var didWarnAboutUninitializedState;
  3593. var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate;
  3594. var didWarnAboutLegacyLifecyclesAndDerivedState;
  3595. var didWarnAboutUndefinedDerivedState;
  3596. var warnOnUndefinedDerivedState;
  3597. var warnOnInvalidCallback;
  3598. var didWarnAboutDirectlyAssigningPropsToState;
  3599. var didWarnAboutContextTypeAndContextTypes;
  3600. var didWarnAboutInvalidateContextType;
  3601. {
  3602. didWarnAboutUninitializedState = new Set();
  3603. didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set();
  3604. didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
  3605. didWarnAboutDirectlyAssigningPropsToState = new Set();
  3606. didWarnAboutUndefinedDerivedState = new Set();
  3607. didWarnAboutContextTypeAndContextTypes = new Set();
  3608. didWarnAboutInvalidateContextType = new Set();
  3609. var didWarnOnInvalidCallback = new Set();
  3610. warnOnInvalidCallback = function (callback, callerName) {
  3611. if (callback === null || typeof callback === 'function') {
  3612. return;
  3613. }
  3614. var key = callerName + '_' + callback;
  3615. if (!didWarnOnInvalidCallback.has(key)) {
  3616. didWarnOnInvalidCallback.add(key);
  3617. error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
  3618. }
  3619. };
  3620. warnOnUndefinedDerivedState = function (type, partialState) {
  3621. if (partialState === undefined) {
  3622. var componentName = getComponentNameFromType(type) || 'Component';
  3623. if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
  3624. didWarnAboutUndefinedDerivedState.add(componentName);
  3625. error('%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
  3626. }
  3627. }
  3628. };
  3629. }
  3630. function warnNoop(publicInstance, callerName) {
  3631. {
  3632. var _constructor = publicInstance.constructor;
  3633. var componentName = _constructor && getComponentNameFromType(_constructor) || 'ReactClass';
  3634. var warningKey = componentName + '.' + callerName;
  3635. if (didWarnAboutNoopUpdateForComponent[warningKey]) {
  3636. return;
  3637. }
  3638. error('%s(...): Can only update a mounting component. ' + 'This usually means you called %s() outside componentWillMount() on the server. ' + 'This is a no-op.\n\nPlease check the code for the %s component.', callerName, callerName, componentName);
  3639. didWarnAboutNoopUpdateForComponent[warningKey] = true;
  3640. }
  3641. }
  3642. var classComponentUpdater = {
  3643. isMounted: function (inst) {
  3644. return false;
  3645. },
  3646. enqueueSetState: function (inst, payload, callback) {
  3647. var internals = get(inst);
  3648. if (internals.queue === null) {
  3649. warnNoop(inst, 'setState');
  3650. } else {
  3651. internals.queue.push(payload);
  3652. {
  3653. if (callback !== undefined && callback !== null) {
  3654. warnOnInvalidCallback(callback, 'setState');
  3655. }
  3656. }
  3657. }
  3658. },
  3659. enqueueReplaceState: function (inst, payload, callback) {
  3660. var internals = get(inst);
  3661. internals.replace = true;
  3662. internals.queue = [payload];
  3663. {
  3664. if (callback !== undefined && callback !== null) {
  3665. warnOnInvalidCallback(callback, 'setState');
  3666. }
  3667. }
  3668. },
  3669. enqueueForceUpdate: function (inst, callback) {
  3670. var internals = get(inst);
  3671. if (internals.queue === null) {
  3672. warnNoop(inst, 'forceUpdate');
  3673. } else {
  3674. {
  3675. if (callback !== undefined && callback !== null) {
  3676. warnOnInvalidCallback(callback, 'setState');
  3677. }
  3678. }
  3679. }
  3680. }
  3681. };
  3682. function applyDerivedStateFromProps(instance, ctor, getDerivedStateFromProps, prevState, nextProps) {
  3683. var partialState = getDerivedStateFromProps(nextProps, prevState);
  3684. {
  3685. warnOnUndefinedDerivedState(ctor, partialState);
  3686. } // Merge the partial state and the previous state.
  3687. var newState = partialState === null || partialState === undefined ? prevState : assign({}, prevState, partialState);
  3688. return newState;
  3689. }
  3690. function constructClassInstance(ctor, props, maskedLegacyContext) {
  3691. var context = emptyContextObject;
  3692. var contextType = ctor.contextType;
  3693. {
  3694. if ('contextType' in ctor) {
  3695. var isValid = // Allow null for conditional declaration
  3696. contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer>
  3697. if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
  3698. didWarnAboutInvalidateContextType.add(ctor);
  3699. var addendum = '';
  3700. if (contextType === undefined) {
  3701. 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.';
  3702. } else if (typeof contextType !== 'object') {
  3703. addendum = ' However, it is set to a ' + typeof contextType + '.';
  3704. } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
  3705. addendum = ' Did you accidentally pass the Context.Provider instead?';
  3706. } else if (contextType._context !== undefined) {
  3707. // <Context.Consumer>
  3708. addendum = ' Did you accidentally pass the Context.Consumer instead?';
  3709. } else {
  3710. addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.';
  3711. }
  3712. error('%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentNameFromType(ctor) || 'Component', addendum);
  3713. }
  3714. }
  3715. }
  3716. if (typeof contextType === 'object' && contextType !== null) {
  3717. context = readContext(contextType);
  3718. } else {
  3719. context = maskedLegacyContext;
  3720. }
  3721. var instance = new ctor(props, context);
  3722. {
  3723. if (typeof ctor.getDerivedStateFromProps === 'function' && (instance.state === null || instance.state === undefined)) {
  3724. var componentName = getComponentNameFromType(ctor) || 'Component';
  3725. if (!didWarnAboutUninitializedState.has(componentName)) {
  3726. didWarnAboutUninitializedState.add(componentName);
  3727. 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);
  3728. }
  3729. } // If new component APIs are defined, "unsafe" lifecycles won't be called.
  3730. // Warn about these lifecycles if they are present.
  3731. // Don't warn about react-lifecycles-compat polyfilled methods though.
  3732. if (typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function') {
  3733. var foundWillMountName = null;
  3734. var foundWillReceivePropsName = null;
  3735. var foundWillUpdateName = null;
  3736. if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) {
  3737. foundWillMountName = 'componentWillMount';
  3738. } else if (typeof instance.UNSAFE_componentWillMount === 'function') {
  3739. foundWillMountName = 'UNSAFE_componentWillMount';
  3740. }
  3741. if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
  3742. foundWillReceivePropsName = 'componentWillReceiveProps';
  3743. } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') {
  3744. foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
  3745. }
  3746. if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
  3747. foundWillUpdateName = 'componentWillUpdate';
  3748. } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
  3749. foundWillUpdateName = 'UNSAFE_componentWillUpdate';
  3750. }
  3751. if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
  3752. var _componentName = getComponentNameFromType(ctor) || 'Component';
  3753. var newApiName = typeof ctor.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()';
  3754. if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) {
  3755. didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName);
  3756. 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 : '');
  3757. }
  3758. }
  3759. }
  3760. }
  3761. return instance;
  3762. }
  3763. function checkClassInstance(instance, ctor, newProps) {
  3764. {
  3765. var name = getComponentNameFromType(ctor) || 'Component';
  3766. var renderPresent = instance.render;
  3767. if (!renderPresent) {
  3768. if (ctor.prototype && typeof ctor.prototype.render === 'function') {
  3769. error('%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
  3770. } else {
  3771. error('%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
  3772. }
  3773. }
  3774. if (instance.getInitialState && !instance.getInitialState.isReactClassApproved && !instance.state) {
  3775. 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);
  3776. }
  3777. if (instance.getDefaultProps && !instance.getDefaultProps.isReactClassApproved) {
  3778. 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);
  3779. }
  3780. if (instance.propTypes) {
  3781. error('propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name);
  3782. }
  3783. if (instance.contextType) {
  3784. error('contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name);
  3785. }
  3786. {
  3787. if (instance.contextTypes) {
  3788. error('contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name);
  3789. }
  3790. if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
  3791. didWarnAboutContextTypeAndContextTypes.add(ctor);
  3792. error('%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
  3793. }
  3794. }
  3795. if (typeof instance.componentShouldUpdate === 'function') {
  3796. 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);
  3797. }
  3798. if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
  3799. error('%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentNameFromType(ctor) || 'A pure component');
  3800. }
  3801. if (typeof instance.componentDidUnmount === 'function') {
  3802. error('%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name);
  3803. }
  3804. if (typeof instance.componentDidReceiveProps === 'function') {
  3805. 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);
  3806. }
  3807. if (typeof instance.componentWillRecieveProps === 'function') {
  3808. error('%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name);
  3809. }
  3810. if (typeof instance.UNSAFE_componentWillRecieveProps === 'function') {
  3811. error('%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name);
  3812. }
  3813. var hasMutatedProps = instance.props !== newProps;
  3814. if (instance.props !== undefined && hasMutatedProps) {
  3815. error('%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name);
  3816. }
  3817. if (instance.defaultProps) {
  3818. 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);
  3819. }
  3820. if (typeof instance.getSnapshotBeforeUpdate === 'function' && typeof instance.componentDidUpdate !== 'function' && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) {
  3821. didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor);
  3822. error('%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' + 'This component defines getSnapshotBeforeUpdate() only.', getComponentNameFromType(ctor));
  3823. }
  3824. if (typeof instance.getDerivedStateFromProps === 'function') {
  3825. error('%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name);
  3826. }
  3827. if (typeof instance.getDerivedStateFromError === 'function') {
  3828. error('%s: getDerivedStateFromError() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name);
  3829. }
  3830. if (typeof ctor.getSnapshotBeforeUpdate === 'function') {
  3831. error('%s: getSnapshotBeforeUpdate() is defined as a static method ' + 'and will be ignored. Instead, declare it as an instance method.', name);
  3832. }
  3833. var _state = instance.state;
  3834. if (_state && (typeof _state !== 'object' || isArray(_state))) {
  3835. error('%s.state: must be set to an object or null', name);
  3836. }
  3837. if (typeof instance.getChildContext === 'function' && typeof ctor.childContextTypes !== 'object') {
  3838. error('%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name);
  3839. }
  3840. }
  3841. }
  3842. function callComponentWillMount(type, instance) {
  3843. var oldState = instance.state;
  3844. if (typeof instance.componentWillMount === 'function') {
  3845. {
  3846. if ( instance.componentWillMount.__suppressDeprecationWarning !== true) {
  3847. var componentName = getComponentNameFromType(type) || 'Unknown';
  3848. if (!didWarnAboutDeprecatedWillMount[componentName]) {
  3849. warn( // keep this warning in sync with ReactStrictModeWarning.js
  3850. 'componentWillMount has been renamed, and is not recommended for use. ' + 'See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n' + '* Move code from componentWillMount to componentDidMount (preferred in most cases) ' + 'or the constructor.\n' + '\nPlease update the following components: %s', componentName);
  3851. didWarnAboutDeprecatedWillMount[componentName] = true;
  3852. }
  3853. }
  3854. }
  3855. instance.componentWillMount();
  3856. }
  3857. if (typeof instance.UNSAFE_componentWillMount === 'function') {
  3858. instance.UNSAFE_componentWillMount();
  3859. }
  3860. if (oldState !== instance.state) {
  3861. {
  3862. error('%s.componentWillMount(): Assigning directly to this.state is ' + "deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentNameFromType(type) || 'Component');
  3863. }
  3864. classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
  3865. }
  3866. }
  3867. function processUpdateQueue(internalInstance, inst, props, maskedLegacyContext) {
  3868. if (internalInstance.queue !== null && internalInstance.queue.length > 0) {
  3869. var oldQueue = internalInstance.queue;
  3870. var oldReplace = internalInstance.replace;
  3871. internalInstance.queue = null;
  3872. internalInstance.replace = false;
  3873. if (oldReplace && oldQueue.length === 1) {
  3874. inst.state = oldQueue[0];
  3875. } else {
  3876. var nextState = oldReplace ? oldQueue[0] : inst.state;
  3877. var dontMutate = true;
  3878. for (var i = oldReplace ? 1 : 0; i < oldQueue.length; i++) {
  3879. var partial = oldQueue[i];
  3880. var partialState = typeof partial === 'function' ? partial.call(inst, nextState, props, maskedLegacyContext) : partial;
  3881. if (partialState != null) {
  3882. if (dontMutate) {
  3883. dontMutate = false;
  3884. nextState = assign({}, nextState, partialState);
  3885. } else {
  3886. assign(nextState, partialState);
  3887. }
  3888. }
  3889. }
  3890. inst.state = nextState;
  3891. }
  3892. } else {
  3893. internalInstance.queue = null;
  3894. }
  3895. } // Invokes the mount life-cycles on a previously never rendered instance.
  3896. function mountClassInstance(instance, ctor, newProps, maskedLegacyContext) {
  3897. {
  3898. checkClassInstance(instance, ctor, newProps);
  3899. }
  3900. var initialState = instance.state !== undefined ? instance.state : null;
  3901. instance.updater = classComponentUpdater;
  3902. instance.props = newProps;
  3903. instance.state = initialState; // We don't bother initializing the refs object on the server, since we're not going to resolve them anyway.
  3904. // The internal instance will be used to manage updates that happen during this mount.
  3905. var internalInstance = {
  3906. queue: [],
  3907. replace: false
  3908. };
  3909. set(instance, internalInstance);
  3910. var contextType = ctor.contextType;
  3911. if (typeof contextType === 'object' && contextType !== null) {
  3912. instance.context = readContext(contextType);
  3913. } else {
  3914. instance.context = maskedLegacyContext;
  3915. }
  3916. {
  3917. if (instance.state === newProps) {
  3918. var componentName = getComponentNameFromType(ctor) || 'Component';
  3919. if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) {
  3920. didWarnAboutDirectlyAssigningPropsToState.add(componentName);
  3921. 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);
  3922. }
  3923. }
  3924. }
  3925. var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
  3926. if (typeof getDerivedStateFromProps === 'function') {
  3927. instance.state = applyDerivedStateFromProps(instance, ctor, getDerivedStateFromProps, initialState, newProps);
  3928. } // In order to support react-lifecycles-compat polyfilled components,
  3929. // Unsafe lifecycles should not be invoked for components using the new APIs.
  3930. if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
  3931. callComponentWillMount(ctor, instance); // If we had additional state updates during this life-cycle, let's
  3932. // process them now.
  3933. processUpdateQueue(internalInstance, instance, newProps, maskedLegacyContext);
  3934. }
  3935. }
  3936. // Ids are base 32 strings whose binary representation corresponds to the
  3937. // position of a node in a tree.
  3938. // Every time the tree forks into multiple children, we add additional bits to
  3939. // the left of the sequence that represent the position of the child within the
  3940. // current level of children.
  3941. //
  3942. // 00101 00010001011010101
  3943. // ╰─┬─╯ ╰───────┬───────╯
  3944. // Fork 5 of 20 Parent id
  3945. //
  3946. // The leading 0s are important. In the above example, you only need 3 bits to
  3947. // represent slot 5. However, you need 5 bits to represent all the forks at
  3948. // the current level, so we must account for the empty bits at the end.
  3949. //
  3950. // For this same reason, slots are 1-indexed instead of 0-indexed. Otherwise,
  3951. // the zeroth id at a level would be indistinguishable from its parent.
  3952. //
  3953. // If a node has only one child, and does not materialize an id (i.e. does not
  3954. // contain a useId hook), then we don't need to allocate any space in the
  3955. // sequence. It's treated as a transparent indirection. For example, these two
  3956. // trees produce the same ids:
  3957. //
  3958. // <> <>
  3959. // <Indirection> <A />
  3960. // <A /> <B />
  3961. // </Indirection> </>
  3962. // <B />
  3963. // </>
  3964. //
  3965. // However, we cannot skip any node that materializes an id. Otherwise, a parent
  3966. // id that does not fork would be indistinguishable from its child id. For
  3967. // example, this tree does not fork, but the parent and child must have
  3968. // different ids.
  3969. //
  3970. // <Parent>
  3971. // <Child />
  3972. // </Parent>
  3973. //
  3974. // To handle this scenario, every time we materialize an id, we allocate a
  3975. // new level with a single slot. You can think of this as a fork with only one
  3976. // prong, or an array of children with length 1.
  3977. //
  3978. // It's possible for the size of the sequence to exceed 32 bits, the max
  3979. // size for bitwise operations. When this happens, we make more room by
  3980. // converting the right part of the id to a string and storing it in an overflow
  3981. // variable. We use a base 32 string representation, because 32 is the largest
  3982. // power of 2 that is supported by toString(). We want the base to be large so
  3983. // that the resulting ids are compact, and we want the base to be a power of 2
  3984. // because every log2(base) bits corresponds to a single character, i.e. every
  3985. // log2(32) = 5 bits. That means we can lop bits off the end 5 at a time without
  3986. // affecting the final result.
  3987. var emptyTreeContext = {
  3988. id: 1,
  3989. overflow: ''
  3990. };
  3991. function getTreeId(context) {
  3992. var overflow = context.overflow;
  3993. var idWithLeadingBit = context.id;
  3994. var id = idWithLeadingBit & ~getLeadingBit(idWithLeadingBit);
  3995. return id.toString(32) + overflow;
  3996. }
  3997. function pushTreeContext(baseContext, totalChildren, index) {
  3998. var baseIdWithLeadingBit = baseContext.id;
  3999. var baseOverflow = baseContext.overflow; // The leftmost 1 marks the end of the sequence, non-inclusive. It's not part
  4000. // of the id; we use it to account for leading 0s.
  4001. var baseLength = getBitLength(baseIdWithLeadingBit) - 1;
  4002. var baseId = baseIdWithLeadingBit & ~(1 << baseLength);
  4003. var slot = index + 1;
  4004. var length = getBitLength(totalChildren) + baseLength; // 30 is the max length we can store without overflowing, taking into
  4005. // consideration the leading 1 we use to mark the end of the sequence.
  4006. if (length > 30) {
  4007. // We overflowed the bitwise-safe range. Fall back to slower algorithm.
  4008. // This branch assumes the length of the base id is greater than 5; it won't
  4009. // work for smaller ids, because you need 5 bits per character.
  4010. //
  4011. // We encode the id in multiple steps: first the base id, then the
  4012. // remaining digits.
  4013. //
  4014. // Each 5 bit sequence corresponds to a single base 32 character. So for
  4015. // example, if the current id is 23 bits long, we can convert 20 of those
  4016. // bits into a string of 4 characters, with 3 bits left over.
  4017. //
  4018. // First calculate how many bits in the base id represent a complete
  4019. // sequence of characters.
  4020. var numberOfOverflowBits = baseLength - baseLength % 5; // Then create a bitmask that selects only those bits.
  4021. var newOverflowBits = (1 << numberOfOverflowBits) - 1; // Select the bits, and convert them to a base 32 string.
  4022. var newOverflow = (baseId & newOverflowBits).toString(32); // Now we can remove those bits from the base id.
  4023. var restOfBaseId = baseId >> numberOfOverflowBits;
  4024. var restOfBaseLength = baseLength - numberOfOverflowBits; // Finally, encode the rest of the bits using the normal algorithm. Because
  4025. // we made more room, this time it won't overflow.
  4026. var restOfLength = getBitLength(totalChildren) + restOfBaseLength;
  4027. var restOfNewBits = slot << restOfBaseLength;
  4028. var id = restOfNewBits | restOfBaseId;
  4029. var overflow = newOverflow + baseOverflow;
  4030. return {
  4031. id: 1 << restOfLength | id,
  4032. overflow: overflow
  4033. };
  4034. } else {
  4035. // Normal path
  4036. var newBits = slot << baseLength;
  4037. var _id = newBits | baseId;
  4038. var _overflow = baseOverflow;
  4039. return {
  4040. id: 1 << length | _id,
  4041. overflow: _overflow
  4042. };
  4043. }
  4044. }
  4045. function getBitLength(number) {
  4046. return 32 - clz32(number);
  4047. }
  4048. function getLeadingBit(id) {
  4049. return 1 << getBitLength(id) - 1;
  4050. } // TODO: Math.clz32 is supported in Node 12+. Maybe we can drop the fallback.
  4051. var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback; // Count leading zeros.
  4052. // Based on:
  4053. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
  4054. var log = Math.log;
  4055. var LN2 = Math.LN2;
  4056. function clz32Fallback(x) {
  4057. var asUint = x >>> 0;
  4058. if (asUint === 0) {
  4059. return 32;
  4060. }
  4061. return 31 - (log(asUint) / LN2 | 0) | 0;
  4062. }
  4063. /**
  4064. * inlined Object.is polyfill to avoid requiring consumers ship their own
  4065. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  4066. */
  4067. function is(x, y) {
  4068. return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
  4069. ;
  4070. }
  4071. var objectIs = typeof Object.is === 'function' ? Object.is : is;
  4072. var currentlyRenderingComponent = null;
  4073. var currentlyRenderingTask = null;
  4074. var firstWorkInProgressHook = null;
  4075. var workInProgressHook = null; // Whether the work-in-progress hook is a re-rendered hook
  4076. var isReRender = false; // Whether an update was scheduled during the currently executing render pass.
  4077. var didScheduleRenderPhaseUpdate = false; // Counts the number of useId hooks in this component
  4078. var localIdCounter = 0; // Lazily created map of render-phase updates
  4079. var renderPhaseUpdates = null; // Counter to prevent infinite loops.
  4080. var numberOfReRenders = 0;
  4081. var RE_RENDER_LIMIT = 25;
  4082. var isInHookUserCodeInDev = false; // In DEV, this is the name of the currently executing primitive hook
  4083. var currentHookNameInDev;
  4084. function resolveCurrentlyRenderingComponent() {
  4085. if (currentlyRenderingComponent === null) {
  4086. throw new 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:\n' + '1. You might have mismatching versions of React and the renderer (such as React DOM)\n' + '2. You might be breaking the Rules of Hooks\n' + '3. You might have more than one copy of React in the same app\n' + 'See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.');
  4087. }
  4088. {
  4089. if (isInHookUserCodeInDev) {
  4090. 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');
  4091. }
  4092. }
  4093. return currentlyRenderingComponent;
  4094. }
  4095. function areHookInputsEqual(nextDeps, prevDeps) {
  4096. if (prevDeps === null) {
  4097. {
  4098. 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);
  4099. }
  4100. return false;
  4101. }
  4102. {
  4103. // Don't bother comparing lengths in prod because these arrays should be
  4104. // passed inline.
  4105. if (nextDeps.length !== prevDeps.length) {
  4106. 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, "[" + nextDeps.join(', ') + "]", "[" + prevDeps.join(', ') + "]");
  4107. }
  4108. }
  4109. for (var i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
  4110. if (objectIs(nextDeps[i], prevDeps[i])) {
  4111. continue;
  4112. }
  4113. return false;
  4114. }
  4115. return true;
  4116. }
  4117. function createHook() {
  4118. if (numberOfReRenders > 0) {
  4119. throw new Error('Rendered more hooks than during the previous render');
  4120. }
  4121. return {
  4122. memoizedState: null,
  4123. queue: null,
  4124. next: null
  4125. };
  4126. }
  4127. function createWorkInProgressHook() {
  4128. if (workInProgressHook === null) {
  4129. // This is the first hook in the list
  4130. if (firstWorkInProgressHook === null) {
  4131. isReRender = false;
  4132. firstWorkInProgressHook = workInProgressHook = createHook();
  4133. } else {
  4134. // There's already a work-in-progress. Reuse it.
  4135. isReRender = true;
  4136. workInProgressHook = firstWorkInProgressHook;
  4137. }
  4138. } else {
  4139. if (workInProgressHook.next === null) {
  4140. isReRender = false; // Append to the end of the list
  4141. workInProgressHook = workInProgressHook.next = createHook();
  4142. } else {
  4143. // There's already a work-in-progress. Reuse it.
  4144. isReRender = true;
  4145. workInProgressHook = workInProgressHook.next;
  4146. }
  4147. }
  4148. return workInProgressHook;
  4149. }
  4150. function prepareToUseHooks(task, componentIdentity) {
  4151. currentlyRenderingComponent = componentIdentity;
  4152. currentlyRenderingTask = task;
  4153. {
  4154. isInHookUserCodeInDev = false;
  4155. } // The following should have already been reset
  4156. // didScheduleRenderPhaseUpdate = false;
  4157. // localIdCounter = 0;
  4158. // firstWorkInProgressHook = null;
  4159. // numberOfReRenders = 0;
  4160. // renderPhaseUpdates = null;
  4161. // workInProgressHook = null;
  4162. localIdCounter = 0;
  4163. }
  4164. function finishHooks(Component, props, children, refOrContext) {
  4165. // This must be called after every function component to prevent hooks from
  4166. // being used in classes.
  4167. while (didScheduleRenderPhaseUpdate) {
  4168. // Updates were scheduled during the render phase. They are stored in
  4169. // the `renderPhaseUpdates` map. Call the component again, reusing the
  4170. // work-in-progress hooks and applying the additional updates on top. Keep
  4171. // restarting until no more updates are scheduled.
  4172. didScheduleRenderPhaseUpdate = false;
  4173. localIdCounter = 0;
  4174. numberOfReRenders += 1; // Start over from the beginning of the list
  4175. workInProgressHook = null;
  4176. children = Component(props, refOrContext);
  4177. }
  4178. resetHooksState();
  4179. return children;
  4180. }
  4181. function checkDidRenderIdHook() {
  4182. // This should be called immediately after every finishHooks call.
  4183. // Conceptually, it's part of the return value of finishHooks; it's only a
  4184. // separate function to avoid using an array tuple.
  4185. var didRenderIdHook = localIdCounter !== 0;
  4186. return didRenderIdHook;
  4187. } // Reset the internal hooks state if an error occurs while rendering a component
  4188. function resetHooksState() {
  4189. {
  4190. isInHookUserCodeInDev = false;
  4191. }
  4192. currentlyRenderingComponent = null;
  4193. currentlyRenderingTask = null;
  4194. didScheduleRenderPhaseUpdate = false;
  4195. firstWorkInProgressHook = null;
  4196. numberOfReRenders = 0;
  4197. renderPhaseUpdates = null;
  4198. workInProgressHook = null;
  4199. }
  4200. function readContext$1(context) {
  4201. {
  4202. if (isInHookUserCodeInDev) {
  4203. 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().');
  4204. }
  4205. }
  4206. return readContext(context);
  4207. }
  4208. function useContext(context) {
  4209. {
  4210. currentHookNameInDev = 'useContext';
  4211. }
  4212. resolveCurrentlyRenderingComponent();
  4213. return readContext(context);
  4214. }
  4215. function basicStateReducer(state, action) {
  4216. // $FlowFixMe: Flow doesn't like mixed types
  4217. return typeof action === 'function' ? action(state) : action;
  4218. }
  4219. function useState(initialState) {
  4220. {
  4221. currentHookNameInDev = 'useState';
  4222. }
  4223. return useReducer(basicStateReducer, // useReducer has a special case to support lazy useState initializers
  4224. initialState);
  4225. }
  4226. function useReducer(reducer, initialArg, init) {
  4227. {
  4228. if (reducer !== basicStateReducer) {
  4229. currentHookNameInDev = 'useReducer';
  4230. }
  4231. }
  4232. currentlyRenderingComponent = resolveCurrentlyRenderingComponent();
  4233. workInProgressHook = createWorkInProgressHook();
  4234. if (isReRender) {
  4235. // This is a re-render. Apply the new render phase updates to the previous
  4236. // current hook.
  4237. var queue = workInProgressHook.queue;
  4238. var dispatch = queue.dispatch;
  4239. if (renderPhaseUpdates !== null) {
  4240. // Render phase updates are stored in a map of queue -> linked list
  4241. var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
  4242. if (firstRenderPhaseUpdate !== undefined) {
  4243. renderPhaseUpdates.delete(queue);
  4244. var newState = workInProgressHook.memoizedState;
  4245. var update = firstRenderPhaseUpdate;
  4246. do {
  4247. // Process this render phase update. We don't have to check the
  4248. // priority because it will always be the same as the current
  4249. // render's.
  4250. var action = update.action;
  4251. {
  4252. isInHookUserCodeInDev = true;
  4253. }
  4254. newState = reducer(newState, action);
  4255. {
  4256. isInHookUserCodeInDev = false;
  4257. }
  4258. update = update.next;
  4259. } while (update !== null);
  4260. workInProgressHook.memoizedState = newState;
  4261. return [newState, dispatch];
  4262. }
  4263. }
  4264. return [workInProgressHook.memoizedState, dispatch];
  4265. } else {
  4266. {
  4267. isInHookUserCodeInDev = true;
  4268. }
  4269. var initialState;
  4270. if (reducer === basicStateReducer) {
  4271. // Special case for `useState`.
  4272. initialState = typeof initialArg === 'function' ? initialArg() : initialArg;
  4273. } else {
  4274. initialState = init !== undefined ? init(initialArg) : initialArg;
  4275. }
  4276. {
  4277. isInHookUserCodeInDev = false;
  4278. }
  4279. workInProgressHook.memoizedState = initialState;
  4280. var _queue = workInProgressHook.queue = {
  4281. last: null,
  4282. dispatch: null
  4283. };
  4284. var _dispatch = _queue.dispatch = dispatchAction.bind(null, currentlyRenderingComponent, _queue);
  4285. return [workInProgressHook.memoizedState, _dispatch];
  4286. }
  4287. }
  4288. function useMemo(nextCreate, deps) {
  4289. currentlyRenderingComponent = resolveCurrentlyRenderingComponent();
  4290. workInProgressHook = createWorkInProgressHook();
  4291. var nextDeps = deps === undefined ? null : deps;
  4292. if (workInProgressHook !== null) {
  4293. var prevState = workInProgressHook.memoizedState;
  4294. if (prevState !== null) {
  4295. if (nextDeps !== null) {
  4296. var prevDeps = prevState[1];
  4297. if (areHookInputsEqual(nextDeps, prevDeps)) {
  4298. return prevState[0];
  4299. }
  4300. }
  4301. }
  4302. }
  4303. {
  4304. isInHookUserCodeInDev = true;
  4305. }
  4306. var nextValue = nextCreate();
  4307. {
  4308. isInHookUserCodeInDev = false;
  4309. }
  4310. workInProgressHook.memoizedState = [nextValue, nextDeps];
  4311. return nextValue;
  4312. }
  4313. function useRef(initialValue) {
  4314. currentlyRenderingComponent = resolveCurrentlyRenderingComponent();
  4315. workInProgressHook = createWorkInProgressHook();
  4316. var previousRef = workInProgressHook.memoizedState;
  4317. if (previousRef === null) {
  4318. var ref = {
  4319. current: initialValue
  4320. };
  4321. {
  4322. Object.seal(ref);
  4323. }
  4324. workInProgressHook.memoizedState = ref;
  4325. return ref;
  4326. } else {
  4327. return previousRef;
  4328. }
  4329. }
  4330. function useLayoutEffect(create, inputs) {
  4331. {
  4332. currentHookNameInDev = 'useLayoutEffect';
  4333. error('useLayoutEffect does nothing on the server, because its effect cannot ' + "be encoded into the server renderer's output format. This will lead " + 'to a mismatch between the initial, non-hydrated UI and the intended ' + 'UI. To avoid this, useLayoutEffect should only be used in ' + 'components that render exclusively on the client. ' + 'See https://reactjs.org/link/uselayouteffect-ssr for common fixes.');
  4334. }
  4335. }
  4336. function dispatchAction(componentIdentity, queue, action) {
  4337. if (numberOfReRenders >= RE_RENDER_LIMIT) {
  4338. throw new Error('Too many re-renders. React limits the number of renders to prevent ' + 'an infinite loop.');
  4339. }
  4340. if (componentIdentity === currentlyRenderingComponent) {
  4341. // This is a render phase update. Stash it in a lazily-created map of
  4342. // queue -> linked list of updates. After this render pass, we'll restart
  4343. // and apply the stashed updates on top of the work-in-progress hook.
  4344. didScheduleRenderPhaseUpdate = true;
  4345. var update = {
  4346. action: action,
  4347. next: null
  4348. };
  4349. if (renderPhaseUpdates === null) {
  4350. renderPhaseUpdates = new Map();
  4351. }
  4352. var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue);
  4353. if (firstRenderPhaseUpdate === undefined) {
  4354. renderPhaseUpdates.set(queue, update);
  4355. } else {
  4356. // Append the update to the end of the list.
  4357. var lastRenderPhaseUpdate = firstRenderPhaseUpdate;
  4358. while (lastRenderPhaseUpdate.next !== null) {
  4359. lastRenderPhaseUpdate = lastRenderPhaseUpdate.next;
  4360. }
  4361. lastRenderPhaseUpdate.next = update;
  4362. }
  4363. }
  4364. }
  4365. function useCallback(callback, deps) {
  4366. return useMemo(function () {
  4367. return callback;
  4368. }, deps);
  4369. } // TODO Decide on how to implement this hook for server rendering.
  4370. // If a mutation occurs during render, consider triggering a Suspense boundary
  4371. // and falling back to client rendering.
  4372. function useMutableSource(source, getSnapshot, subscribe) {
  4373. resolveCurrentlyRenderingComponent();
  4374. return getSnapshot(source._source);
  4375. }
  4376. function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
  4377. if (getServerSnapshot === undefined) {
  4378. throw new Error('Missing getServerSnapshot, which is required for ' + 'server-rendered content. Will revert to client rendering.');
  4379. }
  4380. return getServerSnapshot();
  4381. }
  4382. function useDeferredValue(value) {
  4383. resolveCurrentlyRenderingComponent();
  4384. return value;
  4385. }
  4386. function unsupportedStartTransition() {
  4387. throw new Error('startTransition cannot be called during server rendering.');
  4388. }
  4389. function useTransition() {
  4390. resolveCurrentlyRenderingComponent();
  4391. return [false, unsupportedStartTransition];
  4392. }
  4393. function useId() {
  4394. var task = currentlyRenderingTask;
  4395. var treeId = getTreeId(task.treeContext);
  4396. var responseState = currentResponseState;
  4397. if (responseState === null) {
  4398. throw new Error('Invalid hook call. Hooks can only be called inside of the body of a function component.');
  4399. }
  4400. var localId = localIdCounter++;
  4401. return makeId(responseState, treeId, localId);
  4402. }
  4403. function noop() {}
  4404. var Dispatcher = {
  4405. readContext: readContext$1,
  4406. useContext: useContext,
  4407. useMemo: useMemo,
  4408. useReducer: useReducer,
  4409. useRef: useRef,
  4410. useState: useState,
  4411. useInsertionEffect: noop,
  4412. useLayoutEffect: useLayoutEffect,
  4413. useCallback: useCallback,
  4414. // useImperativeHandle is not run in the server environment
  4415. useImperativeHandle: noop,
  4416. // Effects are not run in the server environment.
  4417. useEffect: noop,
  4418. // Debugging effect
  4419. useDebugValue: noop,
  4420. useDeferredValue: useDeferredValue,
  4421. useTransition: useTransition,
  4422. useId: useId,
  4423. // Subscriptions are not setup in a server environment.
  4424. useMutableSource: useMutableSource,
  4425. useSyncExternalStore: useSyncExternalStore
  4426. };
  4427. var currentResponseState = null;
  4428. function setCurrentResponseState(responseState) {
  4429. currentResponseState = responseState;
  4430. }
  4431. function getStackByComponentStackNode(componentStack) {
  4432. try {
  4433. var info = '';
  4434. var node = componentStack;
  4435. do {
  4436. switch (node.tag) {
  4437. case 0:
  4438. info += describeBuiltInComponentFrame(node.type, null, null);
  4439. break;
  4440. case 1:
  4441. info += describeFunctionComponentFrame(node.type, null, null);
  4442. break;
  4443. case 2:
  4444. info += describeClassComponentFrame(node.type, null, null);
  4445. break;
  4446. }
  4447. node = node.parent;
  4448. } while (node);
  4449. return info;
  4450. } catch (x) {
  4451. return '\nError generating stack: ' + x.message + '\n' + x.stack;
  4452. }
  4453. }
  4454. var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;
  4455. var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
  4456. var PENDING = 0;
  4457. var COMPLETED = 1;
  4458. var FLUSHED = 2;
  4459. var ABORTED = 3;
  4460. var ERRORED = 4;
  4461. var OPEN = 0;
  4462. var CLOSING = 1;
  4463. var CLOSED = 2;
  4464. // This is a default heuristic for how to split up the HTML content into progressive
  4465. // loading. Our goal is to be able to display additional new content about every 500ms.
  4466. // Faster than that is unnecessary and should be throttled on the client. It also
  4467. // adds unnecessary overhead to do more splits. We don't know if it's a higher or lower
  4468. // end device but higher end suffer less from the overhead than lower end does from
  4469. // not getting small enough pieces. We error on the side of low end.
  4470. // We base this on low end 3G speeds which is about 500kbits per second. We assume
  4471. // that there can be a reasonable drop off from max bandwidth which leaves you with
  4472. // as little as 80%. We can receive half of that each 500ms - at best. In practice,
  4473. // a little bandwidth is lost to processing and contention - e.g. CSS and images that
  4474. // are downloaded along with the main content. So we estimate about half of that to be
  4475. // the lower end throughput. In other words, we expect that you can at least show
  4476. // about 12.5kb of content per 500ms. Not counting starting latency for the first
  4477. // paint.
  4478. // 500 * 1024 / 8 * .8 * 0.5 / 2
  4479. var DEFAULT_PROGRESSIVE_CHUNK_SIZE = 12800;
  4480. function defaultErrorHandler(error) {
  4481. console['error'](error); // Don't transform to our wrapper
  4482. return null;
  4483. }
  4484. function noop$1() {}
  4485. function createRequest(children, responseState, rootFormatContext, progressiveChunkSize, onError, onAllReady, onShellReady, onShellError, onFatalError) {
  4486. var pingedTasks = [];
  4487. var abortSet = new Set();
  4488. var request = {
  4489. destination: null,
  4490. responseState: responseState,
  4491. progressiveChunkSize: progressiveChunkSize === undefined ? DEFAULT_PROGRESSIVE_CHUNK_SIZE : progressiveChunkSize,
  4492. status: OPEN,
  4493. fatalError: null,
  4494. nextSegmentId: 0,
  4495. allPendingTasks: 0,
  4496. pendingRootTasks: 0,
  4497. completedRootSegment: null,
  4498. abortableTasks: abortSet,
  4499. pingedTasks: pingedTasks,
  4500. clientRenderedBoundaries: [],
  4501. completedBoundaries: [],
  4502. partialBoundaries: [],
  4503. onError: onError === undefined ? defaultErrorHandler : onError,
  4504. onAllReady: onAllReady === undefined ? noop$1 : onAllReady,
  4505. onShellReady: onShellReady === undefined ? noop$1 : onShellReady,
  4506. onShellError: onShellError === undefined ? noop$1 : onShellError,
  4507. onFatalError: onFatalError === undefined ? noop$1 : onFatalError
  4508. }; // This segment represents the root fallback.
  4509. var rootSegment = createPendingSegment(request, 0, null, rootFormatContext, // Root segments are never embedded in Text on either edge
  4510. false, false); // There is no parent so conceptually, we're unblocked to flush this segment.
  4511. rootSegment.parentFlushed = true;
  4512. var rootTask = createTask(request, children, null, rootSegment, abortSet, emptyContextObject, rootContextSnapshot, emptyTreeContext);
  4513. pingedTasks.push(rootTask);
  4514. return request;
  4515. }
  4516. function pingTask(request, task) {
  4517. var pingedTasks = request.pingedTasks;
  4518. pingedTasks.push(task);
  4519. if (pingedTasks.length === 1) {
  4520. scheduleWork(function () {
  4521. return performWork(request);
  4522. });
  4523. }
  4524. }
  4525. function createSuspenseBoundary(request, fallbackAbortableTasks) {
  4526. return {
  4527. id: UNINITIALIZED_SUSPENSE_BOUNDARY_ID,
  4528. rootSegmentID: -1,
  4529. parentFlushed: false,
  4530. pendingTasks: 0,
  4531. forceClientRender: false,
  4532. completedSegments: [],
  4533. byteSize: 0,
  4534. fallbackAbortableTasks: fallbackAbortableTasks,
  4535. errorDigest: null
  4536. };
  4537. }
  4538. function createTask(request, node, blockedBoundary, blockedSegment, abortSet, legacyContext, context, treeContext) {
  4539. request.allPendingTasks++;
  4540. if (blockedBoundary === null) {
  4541. request.pendingRootTasks++;
  4542. } else {
  4543. blockedBoundary.pendingTasks++;
  4544. }
  4545. var task = {
  4546. node: node,
  4547. ping: function () {
  4548. return pingTask(request, task);
  4549. },
  4550. blockedBoundary: blockedBoundary,
  4551. blockedSegment: blockedSegment,
  4552. abortSet: abortSet,
  4553. legacyContext: legacyContext,
  4554. context: context,
  4555. treeContext: treeContext
  4556. };
  4557. {
  4558. task.componentStack = null;
  4559. }
  4560. abortSet.add(task);
  4561. return task;
  4562. }
  4563. function createPendingSegment(request, index, boundary, formatContext, lastPushedText, textEmbedded) {
  4564. return {
  4565. status: PENDING,
  4566. id: -1,
  4567. // lazily assigned later
  4568. index: index,
  4569. parentFlushed: false,
  4570. chunks: [],
  4571. children: [],
  4572. formatContext: formatContext,
  4573. boundary: boundary,
  4574. lastPushedText: lastPushedText,
  4575. textEmbedded: textEmbedded
  4576. };
  4577. } // DEV-only global reference to the currently executing task
  4578. var currentTaskInDEV = null;
  4579. function getCurrentStackInDEV() {
  4580. {
  4581. if (currentTaskInDEV === null || currentTaskInDEV.componentStack === null) {
  4582. return '';
  4583. }
  4584. return getStackByComponentStackNode(currentTaskInDEV.componentStack);
  4585. }
  4586. }
  4587. function pushBuiltInComponentStackInDEV(task, type) {
  4588. {
  4589. task.componentStack = {
  4590. tag: 0,
  4591. parent: task.componentStack,
  4592. type: type
  4593. };
  4594. }
  4595. }
  4596. function pushFunctionComponentStackInDEV(task, type) {
  4597. {
  4598. task.componentStack = {
  4599. tag: 1,
  4600. parent: task.componentStack,
  4601. type: type
  4602. };
  4603. }
  4604. }
  4605. function pushClassComponentStackInDEV(task, type) {
  4606. {
  4607. task.componentStack = {
  4608. tag: 2,
  4609. parent: task.componentStack,
  4610. type: type
  4611. };
  4612. }
  4613. }
  4614. function popComponentStackInDEV(task) {
  4615. {
  4616. if (task.componentStack === null) {
  4617. error('Unexpectedly popped too many stack frames. This is a bug in React.');
  4618. } else {
  4619. task.componentStack = task.componentStack.parent;
  4620. }
  4621. }
  4622. } // stash the component stack of an unwinding error until it is processed
  4623. var lastBoundaryErrorComponentStackDev = null;
  4624. function captureBoundaryErrorDetailsDev(boundary, error) {
  4625. {
  4626. var errorMessage;
  4627. if (typeof error === 'string') {
  4628. errorMessage = error;
  4629. } else if (error && typeof error.message === 'string') {
  4630. errorMessage = error.message;
  4631. } else {
  4632. // eslint-disable-next-line react-internal/safe-string-coercion
  4633. errorMessage = String(error);
  4634. }
  4635. var errorComponentStack = lastBoundaryErrorComponentStackDev || getCurrentStackInDEV();
  4636. lastBoundaryErrorComponentStackDev = null;
  4637. boundary.errorMessage = errorMessage;
  4638. boundary.errorComponentStack = errorComponentStack;
  4639. }
  4640. }
  4641. function logRecoverableError(request, error) {
  4642. // If this callback errors, we intentionally let that error bubble up to become a fatal error
  4643. // so that someone fixes the error reporting instead of hiding it.
  4644. var errorDigest = request.onError(error);
  4645. if (errorDigest != null && typeof errorDigest !== 'string') {
  4646. // eslint-disable-next-line react-internal/prod-error-codes
  4647. throw new Error("onError returned something with a type other than \"string\". onError should return a string and may return null or undefined but must not return anything else. It received something of type \"" + typeof errorDigest + "\" instead");
  4648. }
  4649. return errorDigest;
  4650. }
  4651. function fatalError(request, error) {
  4652. // This is called outside error handling code such as if the root errors outside
  4653. // a suspense boundary or if the root suspense boundary's fallback errors.
  4654. // It's also called if React itself or its host configs errors.
  4655. var onShellError = request.onShellError;
  4656. onShellError(error);
  4657. var onFatalError = request.onFatalError;
  4658. onFatalError(error);
  4659. if (request.destination !== null) {
  4660. request.status = CLOSED;
  4661. closeWithError(request.destination, error);
  4662. } else {
  4663. request.status = CLOSING;
  4664. request.fatalError = error;
  4665. }
  4666. }
  4667. function renderSuspenseBoundary(request, task, props) {
  4668. pushBuiltInComponentStackInDEV(task, 'Suspense');
  4669. var parentBoundary = task.blockedBoundary;
  4670. var parentSegment = task.blockedSegment; // Each time we enter a suspense boundary, we split out into a new segment for
  4671. // the fallback so that we can later replace that segment with the content.
  4672. // This also lets us split out the main content even if it doesn't suspend,
  4673. // in case it ends up generating a large subtree of content.
  4674. var fallback = props.fallback;
  4675. var content = props.children;
  4676. var fallbackAbortSet = new Set();
  4677. var newBoundary = createSuspenseBoundary(request, fallbackAbortSet);
  4678. var insertionIndex = parentSegment.chunks.length; // The children of the boundary segment is actually the fallback.
  4679. var boundarySegment = createPendingSegment(request, insertionIndex, newBoundary, parentSegment.formatContext, // boundaries never require text embedding at their edges because comment nodes bound them
  4680. false, false);
  4681. parentSegment.children.push(boundarySegment); // The parentSegment has a child Segment at this index so we reset the lastPushedText marker on the parent
  4682. parentSegment.lastPushedText = false; // This segment is the actual child content. We can start rendering that immediately.
  4683. var contentRootSegment = createPendingSegment(request, 0, null, parentSegment.formatContext, // boundaries never require text embedding at their edges because comment nodes bound them
  4684. false, false); // We mark the root segment as having its parent flushed. It's not really flushed but there is
  4685. // no parent segment so there's nothing to wait on.
  4686. contentRootSegment.parentFlushed = true; // Currently this is running synchronously. We could instead schedule this to pingedTasks.
  4687. // I suspect that there might be some efficiency benefits from not creating the suspended task
  4688. // and instead just using the stack if possible.
  4689. // TODO: Call this directly instead of messing with saving and restoring contexts.
  4690. // We can reuse the current context and task to render the content immediately without
  4691. // context switching. We just need to temporarily switch which boundary and which segment
  4692. // we're writing to. If something suspends, it'll spawn new suspended task with that context.
  4693. task.blockedBoundary = newBoundary;
  4694. task.blockedSegment = contentRootSegment;
  4695. try {
  4696. // We use the safe form because we don't handle suspending here. Only error handling.
  4697. renderNode(request, task, content);
  4698. pushSegmentFinale$1(contentRootSegment.chunks, request.responseState, contentRootSegment.lastPushedText, contentRootSegment.textEmbedded);
  4699. contentRootSegment.status = COMPLETED;
  4700. queueCompletedSegment(newBoundary, contentRootSegment);
  4701. if (newBoundary.pendingTasks === 0) {
  4702. // This must have been the last segment we were waiting on. This boundary is now complete.
  4703. // Therefore we won't need the fallback. We early return so that we don't have to create
  4704. // the fallback.
  4705. popComponentStackInDEV(task);
  4706. return;
  4707. }
  4708. } catch (error) {
  4709. contentRootSegment.status = ERRORED;
  4710. newBoundary.forceClientRender = true;
  4711. newBoundary.errorDigest = logRecoverableError(request, error);
  4712. {
  4713. captureBoundaryErrorDetailsDev(newBoundary, error);
  4714. } // We don't need to decrement any task numbers because we didn't spawn any new task.
  4715. // We don't need to schedule any task because we know the parent has written yet.
  4716. // We do need to fallthrough to create the fallback though.
  4717. } finally {
  4718. task.blockedBoundary = parentBoundary;
  4719. task.blockedSegment = parentSegment;
  4720. } // We create suspended task for the fallback because we don't want to actually work
  4721. // on it yet in case we finish the main content, so we queue for later.
  4722. var suspendedFallbackTask = createTask(request, fallback, parentBoundary, boundarySegment, fallbackAbortSet, task.legacyContext, task.context, task.treeContext);
  4723. {
  4724. suspendedFallbackTask.componentStack = task.componentStack;
  4725. } // TODO: This should be queued at a separate lower priority queue so that we only work
  4726. // on preparing fallbacks if we don't have any more main content to task on.
  4727. request.pingedTasks.push(suspendedFallbackTask);
  4728. popComponentStackInDEV(task);
  4729. }
  4730. function renderHostElement(request, task, type, props) {
  4731. pushBuiltInComponentStackInDEV(task, type);
  4732. var segment = task.blockedSegment;
  4733. var children = pushStartInstance(segment.chunks, type, props, request.responseState, segment.formatContext);
  4734. segment.lastPushedText = false;
  4735. var prevContext = segment.formatContext;
  4736. segment.formatContext = getChildFormatContext(prevContext, type, props); // We use the non-destructive form because if something suspends, we still
  4737. // need to pop back up and finish this subtree of HTML.
  4738. renderNode(request, task, children); // We expect that errors will fatal the whole task and that we don't need
  4739. // the correct context. Therefore this is not in a finally.
  4740. segment.formatContext = prevContext;
  4741. pushEndInstance(segment.chunks, type);
  4742. segment.lastPushedText = false;
  4743. popComponentStackInDEV(task);
  4744. }
  4745. function shouldConstruct$1(Component) {
  4746. return Component.prototype && Component.prototype.isReactComponent;
  4747. }
  4748. function renderWithHooks(request, task, Component, props, secondArg) {
  4749. var componentIdentity = {};
  4750. prepareToUseHooks(task, componentIdentity);
  4751. var result = Component(props, secondArg);
  4752. return finishHooks(Component, props, result, secondArg);
  4753. }
  4754. function finishClassComponent(request, task, instance, Component, props) {
  4755. var nextChildren = instance.render();
  4756. {
  4757. if (instance.props !== props) {
  4758. if (!didWarnAboutReassigningProps) {
  4759. error('It looks like %s is reassigning its own `this.props` while rendering. ' + 'This is not supported and can lead to confusing bugs.', getComponentNameFromType(Component) || 'a component');
  4760. }
  4761. didWarnAboutReassigningProps = true;
  4762. }
  4763. }
  4764. {
  4765. var childContextTypes = Component.childContextTypes;
  4766. if (childContextTypes !== null && childContextTypes !== undefined) {
  4767. var previousContext = task.legacyContext;
  4768. var mergedContext = processChildContext(instance, Component, previousContext, childContextTypes);
  4769. task.legacyContext = mergedContext;
  4770. renderNodeDestructive(request, task, nextChildren);
  4771. task.legacyContext = previousContext;
  4772. return;
  4773. }
  4774. }
  4775. renderNodeDestructive(request, task, nextChildren);
  4776. }
  4777. function renderClassComponent(request, task, Component, props) {
  4778. pushClassComponentStackInDEV(task, Component);
  4779. var maskedContext = getMaskedContext(Component, task.legacyContext) ;
  4780. var instance = constructClassInstance(Component, props, maskedContext);
  4781. mountClassInstance(instance, Component, props, maskedContext);
  4782. finishClassComponent(request, task, instance, Component, props);
  4783. popComponentStackInDEV(task);
  4784. }
  4785. var didWarnAboutBadClass = {};
  4786. var didWarnAboutModulePatternComponent = {};
  4787. var didWarnAboutContextTypeOnFunctionComponent = {};
  4788. var didWarnAboutGetDerivedStateOnFunctionComponent = {};
  4789. var didWarnAboutReassigningProps = false;
  4790. var didWarnAboutGenerators = false;
  4791. var didWarnAboutMaps = false;
  4792. var hasWarnedAboutUsingContextAsConsumer = false; // This would typically be a function component but we still support module pattern
  4793. // components for some reason.
  4794. function renderIndeterminateComponent(request, task, Component, props) {
  4795. var legacyContext;
  4796. {
  4797. legacyContext = getMaskedContext(Component, task.legacyContext);
  4798. }
  4799. pushFunctionComponentStackInDEV(task, Component);
  4800. {
  4801. if (Component.prototype && typeof Component.prototype.render === 'function') {
  4802. var componentName = getComponentNameFromType(Component) || 'Unknown';
  4803. if (!didWarnAboutBadClass[componentName]) {
  4804. 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);
  4805. didWarnAboutBadClass[componentName] = true;
  4806. }
  4807. }
  4808. }
  4809. var value = renderWithHooks(request, task, Component, props, legacyContext);
  4810. var hasId = checkDidRenderIdHook();
  4811. {
  4812. // Support for module components is deprecated and is removed behind a flag.
  4813. // Whether or not it would crash later, we want to show a good message in DEV first.
  4814. if (typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
  4815. var _componentName = getComponentNameFromType(Component) || 'Unknown';
  4816. if (!didWarnAboutModulePatternComponent[_componentName]) {
  4817. 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);
  4818. didWarnAboutModulePatternComponent[_componentName] = true;
  4819. }
  4820. }
  4821. }
  4822. if ( // Run these checks in production only if the flag is off.
  4823. // Eventually we'll delete this branch altogether.
  4824. typeof value === 'object' && value !== null && typeof value.render === 'function' && value.$$typeof === undefined) {
  4825. {
  4826. var _componentName2 = getComponentNameFromType(Component) || 'Unknown';
  4827. if (!didWarnAboutModulePatternComponent[_componentName2]) {
  4828. 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);
  4829. didWarnAboutModulePatternComponent[_componentName2] = true;
  4830. }
  4831. }
  4832. mountClassInstance(value, Component, props, legacyContext);
  4833. finishClassComponent(request, task, value, Component, props);
  4834. } else {
  4835. {
  4836. validateFunctionComponentInDev(Component);
  4837. } // We're now successfully past this task, and we don't have to pop back to
  4838. // the previous task every again, so we can use the destructive recursive form.
  4839. if (hasId) {
  4840. // This component materialized an id. We treat this as its own level, with
  4841. // a single "child" slot.
  4842. var prevTreeContext = task.treeContext;
  4843. var totalChildren = 1;
  4844. var index = 0;
  4845. task.treeContext = pushTreeContext(prevTreeContext, totalChildren, index);
  4846. try {
  4847. renderNodeDestructive(request, task, value);
  4848. } finally {
  4849. task.treeContext = prevTreeContext;
  4850. }
  4851. } else {
  4852. renderNodeDestructive(request, task, value);
  4853. }
  4854. }
  4855. popComponentStackInDEV(task);
  4856. }
  4857. function validateFunctionComponentInDev(Component) {
  4858. {
  4859. if (Component) {
  4860. if (Component.childContextTypes) {
  4861. error('%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component');
  4862. }
  4863. }
  4864. if (typeof Component.getDerivedStateFromProps === 'function') {
  4865. var _componentName3 = getComponentNameFromType(Component) || 'Unknown';
  4866. if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]) {
  4867. error('%s: Function components do not support getDerivedStateFromProps.', _componentName3);
  4868. didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] = true;
  4869. }
  4870. }
  4871. if (typeof Component.contextType === 'object' && Component.contextType !== null) {
  4872. var _componentName4 = getComponentNameFromType(Component) || 'Unknown';
  4873. if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) {
  4874. error('%s: Function components do not support contextType.', _componentName4);
  4875. didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true;
  4876. }
  4877. }
  4878. }
  4879. }
  4880. function resolveDefaultProps(Component, baseProps) {
  4881. if (Component && Component.defaultProps) {
  4882. // Resolve default props. Taken from ReactElement
  4883. var props = assign({}, baseProps);
  4884. var defaultProps = Component.defaultProps;
  4885. for (var propName in defaultProps) {
  4886. if (props[propName] === undefined) {
  4887. props[propName] = defaultProps[propName];
  4888. }
  4889. }
  4890. return props;
  4891. }
  4892. return baseProps;
  4893. }
  4894. function renderForwardRef(request, task, type, props, ref) {
  4895. pushFunctionComponentStackInDEV(task, type.render);
  4896. var children = renderWithHooks(request, task, type.render, props, ref);
  4897. var hasId = checkDidRenderIdHook();
  4898. if (hasId) {
  4899. // This component materialized an id. We treat this as its own level, with
  4900. // a single "child" slot.
  4901. var prevTreeContext = task.treeContext;
  4902. var totalChildren = 1;
  4903. var index = 0;
  4904. task.treeContext = pushTreeContext(prevTreeContext, totalChildren, index);
  4905. try {
  4906. renderNodeDestructive(request, task, children);
  4907. } finally {
  4908. task.treeContext = prevTreeContext;
  4909. }
  4910. } else {
  4911. renderNodeDestructive(request, task, children);
  4912. }
  4913. popComponentStackInDEV(task);
  4914. }
  4915. function renderMemo(request, task, type, props, ref) {
  4916. var innerType = type.type;
  4917. var resolvedProps = resolveDefaultProps(innerType, props);
  4918. renderElement(request, task, innerType, resolvedProps, ref);
  4919. }
  4920. function renderContextConsumer(request, task, context, props) {
  4921. // The logic below for Context differs depending on PROD or DEV mode. In
  4922. // DEV mode, we create a separate object for Context.Consumer that acts
  4923. // like a proxy to Context. This proxy object adds unnecessary code in PROD
  4924. // so we use the old behaviour (Context.Consumer references Context) to
  4925. // reduce size and overhead. The separate object references context via
  4926. // a property called "_context", which also gives us the ability to check
  4927. // in DEV mode if this property exists or not and warn if it does not.
  4928. {
  4929. if (context._context === undefined) {
  4930. // This may be because it's a Context (rather than a Consumer).
  4931. // Or it may be because it's older React where they're the same thing.
  4932. // We only want to warn if we're sure it's a new React.
  4933. if (context !== context.Consumer) {
  4934. if (!hasWarnedAboutUsingContextAsConsumer) {
  4935. hasWarnedAboutUsingContextAsConsumer = true;
  4936. error('Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
  4937. }
  4938. }
  4939. } else {
  4940. context = context._context;
  4941. }
  4942. }
  4943. var render = props.children;
  4944. {
  4945. if (typeof render !== 'function') {
  4946. 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.');
  4947. }
  4948. }
  4949. var newValue = readContext(context);
  4950. var newChildren = render(newValue);
  4951. renderNodeDestructive(request, task, newChildren);
  4952. }
  4953. function renderContextProvider(request, task, type, props) {
  4954. var context = type._context;
  4955. var value = props.value;
  4956. var children = props.children;
  4957. var prevSnapshot;
  4958. {
  4959. prevSnapshot = task.context;
  4960. }
  4961. task.context = pushProvider(context, value);
  4962. renderNodeDestructive(request, task, children);
  4963. task.context = popProvider(context);
  4964. {
  4965. if (prevSnapshot !== task.context) {
  4966. error('Popping the context provider did not return back to the original snapshot. This is a bug in React.');
  4967. }
  4968. }
  4969. }
  4970. function renderLazyComponent(request, task, lazyComponent, props, ref) {
  4971. pushBuiltInComponentStackInDEV(task, 'Lazy');
  4972. var payload = lazyComponent._payload;
  4973. var init = lazyComponent._init;
  4974. var Component = init(payload);
  4975. var resolvedProps = resolveDefaultProps(Component, props);
  4976. renderElement(request, task, Component, resolvedProps, ref);
  4977. popComponentStackInDEV(task);
  4978. }
  4979. function renderElement(request, task, type, props, ref) {
  4980. if (typeof type === 'function') {
  4981. if (shouldConstruct$1(type)) {
  4982. renderClassComponent(request, task, type, props);
  4983. return;
  4984. } else {
  4985. renderIndeterminateComponent(request, task, type, props);
  4986. return;
  4987. }
  4988. }
  4989. if (typeof type === 'string') {
  4990. renderHostElement(request, task, type, props);
  4991. return;
  4992. }
  4993. switch (type) {
  4994. // TODO: LegacyHidden acts the same as a fragment. This only works
  4995. // because we currently assume that every instance of LegacyHidden is
  4996. // accompanied by a host component wrapper. In the hidden mode, the host
  4997. // component is given a `hidden` attribute, which ensures that the
  4998. // initial HTML is not visible. To support the use of LegacyHidden as a
  4999. // true fragment, without an extra DOM node, we would have to hide the
  5000. // initial HTML in some other way.
  5001. // TODO: Add REACT_OFFSCREEN_TYPE here too with the same capability.
  5002. case REACT_LEGACY_HIDDEN_TYPE:
  5003. case REACT_DEBUG_TRACING_MODE_TYPE:
  5004. case REACT_STRICT_MODE_TYPE:
  5005. case REACT_PROFILER_TYPE:
  5006. case REACT_FRAGMENT_TYPE:
  5007. {
  5008. renderNodeDestructive(request, task, props.children);
  5009. return;
  5010. }
  5011. case REACT_SUSPENSE_LIST_TYPE:
  5012. {
  5013. pushBuiltInComponentStackInDEV(task, 'SuspenseList'); // TODO: SuspenseList should control the boundaries.
  5014. renderNodeDestructive(request, task, props.children);
  5015. popComponentStackInDEV(task);
  5016. return;
  5017. }
  5018. case REACT_SCOPE_TYPE:
  5019. {
  5020. throw new Error('ReactDOMServer does not yet support scope components.');
  5021. }
  5022. // eslint-disable-next-line-no-fallthrough
  5023. case REACT_SUSPENSE_TYPE:
  5024. {
  5025. {
  5026. renderSuspenseBoundary(request, task, props);
  5027. }
  5028. return;
  5029. }
  5030. }
  5031. if (typeof type === 'object' && type !== null) {
  5032. switch (type.$$typeof) {
  5033. case REACT_FORWARD_REF_TYPE:
  5034. {
  5035. renderForwardRef(request, task, type, props, ref);
  5036. return;
  5037. }
  5038. case REACT_MEMO_TYPE:
  5039. {
  5040. renderMemo(request, task, type, props, ref);
  5041. return;
  5042. }
  5043. case REACT_PROVIDER_TYPE:
  5044. {
  5045. renderContextProvider(request, task, type, props);
  5046. return;
  5047. }
  5048. case REACT_CONTEXT_TYPE:
  5049. {
  5050. renderContextConsumer(request, task, type, props);
  5051. return;
  5052. }
  5053. case REACT_LAZY_TYPE:
  5054. {
  5055. renderLazyComponent(request, task, type, props);
  5056. return;
  5057. }
  5058. }
  5059. }
  5060. var info = '';
  5061. {
  5062. if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
  5063. 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.';
  5064. }
  5065. }
  5066. throw new 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));
  5067. }
  5068. function validateIterable(iterable, iteratorFn) {
  5069. {
  5070. // We don't support rendering Generators because it's a mutation.
  5071. // See https://github.com/facebook/react/issues/12995
  5072. if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag
  5073. iterable[Symbol.toStringTag] === 'Generator') {
  5074. if (!didWarnAboutGenerators) {
  5075. 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.');
  5076. }
  5077. didWarnAboutGenerators = true;
  5078. } // Warn about using Maps as children
  5079. if (iterable.entries === iteratorFn) {
  5080. if (!didWarnAboutMaps) {
  5081. error('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');
  5082. }
  5083. didWarnAboutMaps = true;
  5084. }
  5085. }
  5086. }
  5087. function renderNodeDestructive(request, task, node) {
  5088. {
  5089. // In Dev we wrap renderNodeDestructiveImpl in a try / catch so we can capture
  5090. // a component stack at the right place in the tree. We don't do this in renderNode
  5091. // becuase it is not called at every layer of the tree and we may lose frames
  5092. try {
  5093. return renderNodeDestructiveImpl(request, task, node);
  5094. } catch (x) {
  5095. if (typeof x === 'object' && x !== null && typeof x.then === 'function') ; else {
  5096. // This is an error, stash the component stack if it is null.
  5097. lastBoundaryErrorComponentStackDev = lastBoundaryErrorComponentStackDev !== null ? lastBoundaryErrorComponentStackDev : getCurrentStackInDEV();
  5098. } // rethrow so normal suspense logic can handle thrown value accordingly
  5099. throw x;
  5100. }
  5101. }
  5102. } // This function by it self renders a node and consumes the task by mutating it
  5103. // to update the current execution state.
  5104. function renderNodeDestructiveImpl(request, task, node) {
  5105. // Stash the node we're working on. We'll pick up from this task in case
  5106. // something suspends.
  5107. task.node = node; // Handle object types
  5108. if (typeof node === 'object' && node !== null) {
  5109. switch (node.$$typeof) {
  5110. case REACT_ELEMENT_TYPE:
  5111. {
  5112. var element = node;
  5113. var type = element.type;
  5114. var props = element.props;
  5115. var ref = element.ref;
  5116. renderElement(request, task, type, props, ref);
  5117. return;
  5118. }
  5119. case REACT_PORTAL_TYPE:
  5120. throw new Error('Portals are not currently supported by the server renderer. ' + 'Render them conditionally so that they only appear on the client render.');
  5121. // eslint-disable-next-line-no-fallthrough
  5122. case REACT_LAZY_TYPE:
  5123. {
  5124. var lazyNode = node;
  5125. var payload = lazyNode._payload;
  5126. var init = lazyNode._init;
  5127. var resolvedNode;
  5128. {
  5129. try {
  5130. resolvedNode = init(payload);
  5131. } catch (x) {
  5132. if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
  5133. // this Lazy initializer is suspending. push a temporary frame onto the stack so it can be
  5134. // popped off in spawnNewSuspendedTask. This aligns stack behavior between Lazy in element position
  5135. // vs Component position. We do not want the frame for Errors so we exclusively do this in
  5136. // the wakeable branch
  5137. pushBuiltInComponentStackInDEV(task, 'Lazy');
  5138. }
  5139. throw x;
  5140. }
  5141. }
  5142. renderNodeDestructive(request, task, resolvedNode);
  5143. return;
  5144. }
  5145. }
  5146. if (isArray(node)) {
  5147. renderChildrenArray(request, task, node);
  5148. return;
  5149. }
  5150. var iteratorFn = getIteratorFn(node);
  5151. if (iteratorFn) {
  5152. {
  5153. validateIterable(node, iteratorFn);
  5154. }
  5155. var iterator = iteratorFn.call(node);
  5156. if (iterator) {
  5157. // We need to know how many total children are in this set, so that we
  5158. // can allocate enough id slots to acommodate them. So we must exhaust
  5159. // the iterator before we start recursively rendering the children.
  5160. // TODO: This is not great but I think it's inherent to the id
  5161. // generation algorithm.
  5162. var step = iterator.next(); // If there are not entries, we need to push an empty so we start by checking that.
  5163. if (!step.done) {
  5164. var children = [];
  5165. do {
  5166. children.push(step.value);
  5167. step = iterator.next();
  5168. } while (!step.done);
  5169. renderChildrenArray(request, task, children);
  5170. return;
  5171. }
  5172. return;
  5173. }
  5174. }
  5175. var childString = Object.prototype.toString.call(node);
  5176. throw new Error("Objects are not valid as a React child (found: " + (childString === '[object Object]' ? 'object with keys {' + Object.keys(node).join(', ') + '}' : childString) + "). " + 'If you meant to render a collection of children, use an array ' + 'instead.');
  5177. }
  5178. if (typeof node === 'string') {
  5179. var segment = task.blockedSegment;
  5180. segment.lastPushedText = pushTextInstance$1(task.blockedSegment.chunks, node, request.responseState, segment.lastPushedText);
  5181. return;
  5182. }
  5183. if (typeof node === 'number') {
  5184. var _segment = task.blockedSegment;
  5185. _segment.lastPushedText = pushTextInstance$1(task.blockedSegment.chunks, '' + node, request.responseState, _segment.lastPushedText);
  5186. return;
  5187. }
  5188. {
  5189. if (typeof node === 'function') {
  5190. 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.');
  5191. }
  5192. }
  5193. }
  5194. function renderChildrenArray(request, task, children) {
  5195. var totalChildren = children.length;
  5196. for (var i = 0; i < totalChildren; i++) {
  5197. var prevTreeContext = task.treeContext;
  5198. task.treeContext = pushTreeContext(prevTreeContext, totalChildren, i);
  5199. try {
  5200. // We need to use the non-destructive form so that we can safely pop back
  5201. // up and render the sibling if something suspends.
  5202. renderNode(request, task, children[i]);
  5203. } finally {
  5204. task.treeContext = prevTreeContext;
  5205. }
  5206. }
  5207. }
  5208. function spawnNewSuspendedTask(request, task, x) {
  5209. // Something suspended, we'll need to create a new segment and resolve it later.
  5210. var segment = task.blockedSegment;
  5211. var insertionIndex = segment.chunks.length;
  5212. var newSegment = createPendingSegment(request, insertionIndex, null, segment.formatContext, // Adopt the parent segment's leading text embed
  5213. segment.lastPushedText, // Assume we are text embedded at the trailing edge
  5214. true);
  5215. segment.children.push(newSegment); // Reset lastPushedText for current Segment since the new Segment "consumed" it
  5216. segment.lastPushedText = false;
  5217. var newTask = createTask(request, task.node, task.blockedBoundary, newSegment, task.abortSet, task.legacyContext, task.context, task.treeContext);
  5218. {
  5219. if (task.componentStack !== null) {
  5220. // We pop one task off the stack because the node that suspended will be tried again,
  5221. // which will add it back onto the stack.
  5222. newTask.componentStack = task.componentStack.parent;
  5223. }
  5224. }
  5225. var ping = newTask.ping;
  5226. x.then(ping, ping);
  5227. } // This is a non-destructive form of rendering a node. If it suspends it spawns
  5228. // a new task and restores the context of this task to what it was before.
  5229. function renderNode(request, task, node) {
  5230. // TODO: Store segment.children.length here and reset it in case something
  5231. // suspended partially through writing something.
  5232. // Snapshot the current context in case something throws to interrupt the
  5233. // process.
  5234. var previousFormatContext = task.blockedSegment.formatContext;
  5235. var previousLegacyContext = task.legacyContext;
  5236. var previousContext = task.context;
  5237. var previousComponentStack = null;
  5238. {
  5239. previousComponentStack = task.componentStack;
  5240. }
  5241. try {
  5242. return renderNodeDestructive(request, task, node);
  5243. } catch (x) {
  5244. resetHooksState();
  5245. if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
  5246. spawnNewSuspendedTask(request, task, x); // Restore the context. We assume that this will be restored by the inner
  5247. // functions in case nothing throws so we don't use "finally" here.
  5248. task.blockedSegment.formatContext = previousFormatContext;
  5249. task.legacyContext = previousLegacyContext;
  5250. task.context = previousContext; // Restore all active ReactContexts to what they were before.
  5251. switchContext(previousContext);
  5252. {
  5253. task.componentStack = previousComponentStack;
  5254. }
  5255. return;
  5256. } else {
  5257. // Restore the context. We assume that this will be restored by the inner
  5258. // functions in case nothing throws so we don't use "finally" here.
  5259. task.blockedSegment.formatContext = previousFormatContext;
  5260. task.legacyContext = previousLegacyContext;
  5261. task.context = previousContext; // Restore all active ReactContexts to what they were before.
  5262. switchContext(previousContext);
  5263. {
  5264. task.componentStack = previousComponentStack;
  5265. } // We assume that we don't need the correct context.
  5266. // Let's terminate the rest of the tree and don't render any siblings.
  5267. throw x;
  5268. }
  5269. }
  5270. }
  5271. function erroredTask(request, boundary, segment, error) {
  5272. // Report the error to a global handler.
  5273. var errorDigest = logRecoverableError(request, error);
  5274. if (boundary === null) {
  5275. fatalError(request, error);
  5276. } else {
  5277. boundary.pendingTasks--;
  5278. if (!boundary.forceClientRender) {
  5279. boundary.forceClientRender = true;
  5280. boundary.errorDigest = errorDigest;
  5281. {
  5282. captureBoundaryErrorDetailsDev(boundary, error);
  5283. } // Regardless of what happens next, this boundary won't be displayed,
  5284. // so we can flush it, if the parent already flushed.
  5285. if (boundary.parentFlushed) {
  5286. // We don't have a preference where in the queue this goes since it's likely
  5287. // to error on the client anyway. However, intentionally client-rendered
  5288. // boundaries should be flushed earlier so that they can start on the client.
  5289. // We reuse the same queue for errors.
  5290. request.clientRenderedBoundaries.push(boundary);
  5291. }
  5292. }
  5293. }
  5294. request.allPendingTasks--;
  5295. if (request.allPendingTasks === 0) {
  5296. var onAllReady = request.onAllReady;
  5297. onAllReady();
  5298. }
  5299. }
  5300. function abortTaskSoft(task) {
  5301. // This aborts task without aborting the parent boundary that it blocks.
  5302. // It's used for when we didn't need this task to complete the tree.
  5303. // If task was needed, then it should use abortTask instead.
  5304. var request = this;
  5305. var boundary = task.blockedBoundary;
  5306. var segment = task.blockedSegment;
  5307. segment.status = ABORTED;
  5308. finishedTask(request, boundary, segment);
  5309. }
  5310. function abortTask(task, request, reason) {
  5311. // This aborts the task and aborts the parent that it blocks, putting it into
  5312. // client rendered mode.
  5313. var boundary = task.blockedBoundary;
  5314. var segment = task.blockedSegment;
  5315. segment.status = ABORTED;
  5316. if (boundary === null) {
  5317. request.allPendingTasks--; // We didn't complete the root so we have nothing to show. We can close
  5318. // the request;
  5319. if (request.status !== CLOSED) {
  5320. request.status = CLOSED;
  5321. if (request.destination !== null) {
  5322. close(request.destination);
  5323. }
  5324. }
  5325. } else {
  5326. boundary.pendingTasks--;
  5327. if (!boundary.forceClientRender) {
  5328. boundary.forceClientRender = true;
  5329. var _error = reason === undefined ? new Error('The render was aborted by the server without a reason.') : reason;
  5330. boundary.errorDigest = request.onError(_error);
  5331. {
  5332. var errorPrefix = 'The server did not finish this Suspense boundary: ';
  5333. if (_error && typeof _error.message === 'string') {
  5334. _error = errorPrefix + _error.message;
  5335. } else {
  5336. // eslint-disable-next-line react-internal/safe-string-coercion
  5337. _error = errorPrefix + String(_error);
  5338. }
  5339. var previousTaskInDev = currentTaskInDEV;
  5340. currentTaskInDEV = task;
  5341. try {
  5342. captureBoundaryErrorDetailsDev(boundary, _error);
  5343. } finally {
  5344. currentTaskInDEV = previousTaskInDev;
  5345. }
  5346. }
  5347. if (boundary.parentFlushed) {
  5348. request.clientRenderedBoundaries.push(boundary);
  5349. }
  5350. } // If this boundary was still pending then we haven't already cancelled its fallbacks.
  5351. // We'll need to abort the fallbacks, which will also error that parent boundary.
  5352. boundary.fallbackAbortableTasks.forEach(function (fallbackTask) {
  5353. return abortTask(fallbackTask, request, reason);
  5354. });
  5355. boundary.fallbackAbortableTasks.clear();
  5356. request.allPendingTasks--;
  5357. if (request.allPendingTasks === 0) {
  5358. var onAllReady = request.onAllReady;
  5359. onAllReady();
  5360. }
  5361. }
  5362. }
  5363. function queueCompletedSegment(boundary, segment) {
  5364. if (segment.chunks.length === 0 && segment.children.length === 1 && segment.children[0].boundary === null) {
  5365. // This is an empty segment. There's nothing to write, so we can instead transfer the ID
  5366. // to the child. That way any existing references point to the child.
  5367. var childSegment = segment.children[0];
  5368. childSegment.id = segment.id;
  5369. childSegment.parentFlushed = true;
  5370. if (childSegment.status === COMPLETED) {
  5371. queueCompletedSegment(boundary, childSegment);
  5372. }
  5373. } else {
  5374. var completedSegments = boundary.completedSegments;
  5375. completedSegments.push(segment);
  5376. }
  5377. }
  5378. function finishedTask(request, boundary, segment) {
  5379. if (boundary === null) {
  5380. if (segment.parentFlushed) {
  5381. if (request.completedRootSegment !== null) {
  5382. throw new Error('There can only be one root segment. This is a bug in React.');
  5383. }
  5384. request.completedRootSegment = segment;
  5385. }
  5386. request.pendingRootTasks--;
  5387. if (request.pendingRootTasks === 0) {
  5388. // We have completed the shell so the shell can't error anymore.
  5389. request.onShellError = noop$1;
  5390. var onShellReady = request.onShellReady;
  5391. onShellReady();
  5392. }
  5393. } else {
  5394. boundary.pendingTasks--;
  5395. if (boundary.forceClientRender) ; else if (boundary.pendingTasks === 0) {
  5396. // This must have been the last segment we were waiting on. This boundary is now complete.
  5397. if (segment.parentFlushed) {
  5398. // Our parent segment already flushed, so we need to schedule this segment to be emitted.
  5399. // If it is a segment that was aborted, we'll write other content instead so we don't need
  5400. // to emit it.
  5401. if (segment.status === COMPLETED) {
  5402. queueCompletedSegment(boundary, segment);
  5403. }
  5404. }
  5405. if (boundary.parentFlushed) {
  5406. // The segment might be part of a segment that didn't flush yet, but if the boundary's
  5407. // parent flushed, we need to schedule the boundary to be emitted.
  5408. request.completedBoundaries.push(boundary);
  5409. } // We can now cancel any pending task on the fallback since we won't need to show it anymore.
  5410. // This needs to happen after we read the parentFlushed flags because aborting can finish
  5411. // work which can trigger user code, which can start flushing, which can change those flags.
  5412. boundary.fallbackAbortableTasks.forEach(abortTaskSoft, request);
  5413. boundary.fallbackAbortableTasks.clear();
  5414. } else {
  5415. if (segment.parentFlushed) {
  5416. // Our parent already flushed, so we need to schedule this segment to be emitted.
  5417. // If it is a segment that was aborted, we'll write other content instead so we don't need
  5418. // to emit it.
  5419. if (segment.status === COMPLETED) {
  5420. queueCompletedSegment(boundary, segment);
  5421. var completedSegments = boundary.completedSegments;
  5422. if (completedSegments.length === 1) {
  5423. // This is the first time since we last flushed that we completed anything.
  5424. // We can schedule this boundary to emit its partially completed segments early
  5425. // in case the parent has already been flushed.
  5426. if (boundary.parentFlushed) {
  5427. request.partialBoundaries.push(boundary);
  5428. }
  5429. }
  5430. }
  5431. }
  5432. }
  5433. }
  5434. request.allPendingTasks--;
  5435. if (request.allPendingTasks === 0) {
  5436. // This needs to be called at the very end so that we can synchronously write the result
  5437. // in the callback if needed.
  5438. var onAllReady = request.onAllReady;
  5439. onAllReady();
  5440. }
  5441. }
  5442. function retryTask(request, task) {
  5443. var segment = task.blockedSegment;
  5444. if (segment.status !== PENDING) {
  5445. // We completed this by other means before we had a chance to retry it.
  5446. return;
  5447. } // We restore the context to what it was when we suspended.
  5448. // We don't restore it after we leave because it's likely that we'll end up
  5449. // needing a very similar context soon again.
  5450. switchContext(task.context);
  5451. var prevTaskInDEV = null;
  5452. {
  5453. prevTaskInDEV = currentTaskInDEV;
  5454. currentTaskInDEV = task;
  5455. }
  5456. try {
  5457. // We call the destructive form that mutates this task. That way if something
  5458. // suspends again, we can reuse the same task instead of spawning a new one.
  5459. renderNodeDestructive(request, task, task.node);
  5460. pushSegmentFinale$1(segment.chunks, request.responseState, segment.lastPushedText, segment.textEmbedded);
  5461. task.abortSet.delete(task);
  5462. segment.status = COMPLETED;
  5463. finishedTask(request, task.blockedBoundary, segment);
  5464. } catch (x) {
  5465. resetHooksState();
  5466. if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
  5467. // Something suspended again, let's pick it back up later.
  5468. var ping = task.ping;
  5469. x.then(ping, ping);
  5470. } else {
  5471. task.abortSet.delete(task);
  5472. segment.status = ERRORED;
  5473. erroredTask(request, task.blockedBoundary, segment, x);
  5474. }
  5475. } finally {
  5476. {
  5477. currentTaskInDEV = prevTaskInDEV;
  5478. }
  5479. }
  5480. }
  5481. function performWork(request) {
  5482. if (request.status === CLOSED) {
  5483. return;
  5484. }
  5485. var prevContext = getActiveContext();
  5486. var prevDispatcher = ReactCurrentDispatcher$1.current;
  5487. ReactCurrentDispatcher$1.current = Dispatcher;
  5488. var prevGetCurrentStackImpl;
  5489. {
  5490. prevGetCurrentStackImpl = ReactDebugCurrentFrame$1.getCurrentStack;
  5491. ReactDebugCurrentFrame$1.getCurrentStack = getCurrentStackInDEV;
  5492. }
  5493. var prevResponseState = currentResponseState;
  5494. setCurrentResponseState(request.responseState);
  5495. try {
  5496. var pingedTasks = request.pingedTasks;
  5497. var i;
  5498. for (i = 0; i < pingedTasks.length; i++) {
  5499. var task = pingedTasks[i];
  5500. retryTask(request, task);
  5501. }
  5502. pingedTasks.splice(0, i);
  5503. if (request.destination !== null) {
  5504. flushCompletedQueues(request, request.destination);
  5505. }
  5506. } catch (error) {
  5507. logRecoverableError(request, error);
  5508. fatalError(request, error);
  5509. } finally {
  5510. setCurrentResponseState(prevResponseState);
  5511. ReactCurrentDispatcher$1.current = prevDispatcher;
  5512. {
  5513. ReactDebugCurrentFrame$1.getCurrentStack = prevGetCurrentStackImpl;
  5514. }
  5515. if (prevDispatcher === Dispatcher) {
  5516. // This means that we were in a reentrant work loop. This could happen
  5517. // in a renderer that supports synchronous work like renderToString,
  5518. // when it's called from within another renderer.
  5519. // Normally we don't bother switching the contexts to their root/default
  5520. // values when leaving because we'll likely need the same or similar
  5521. // context again. However, when we're inside a synchronous loop like this
  5522. // we'll to restore the context to what it was before returning.
  5523. switchContext(prevContext);
  5524. }
  5525. }
  5526. }
  5527. function flushSubtree(request, destination, segment) {
  5528. segment.parentFlushed = true;
  5529. switch (segment.status) {
  5530. case PENDING:
  5531. {
  5532. // We're emitting a placeholder for this segment to be filled in later.
  5533. // Therefore we'll need to assign it an ID - to refer to it by.
  5534. var segmentID = segment.id = request.nextSegmentId++; // When this segment finally completes it won't be embedded in text since it will flush separately
  5535. segment.lastPushedText = false;
  5536. segment.textEmbedded = false;
  5537. return writePlaceholder(destination, request.responseState, segmentID);
  5538. }
  5539. case COMPLETED:
  5540. {
  5541. segment.status = FLUSHED;
  5542. var r = true;
  5543. var chunks = segment.chunks;
  5544. var chunkIdx = 0;
  5545. var children = segment.children;
  5546. for (var childIdx = 0; childIdx < children.length; childIdx++) {
  5547. var nextChild = children[childIdx]; // Write all the chunks up until the next child.
  5548. for (; chunkIdx < nextChild.index; chunkIdx++) {
  5549. writeChunk(destination, chunks[chunkIdx]);
  5550. }
  5551. r = flushSegment(request, destination, nextChild);
  5552. } // Finally just write all the remaining chunks
  5553. for (; chunkIdx < chunks.length - 1; chunkIdx++) {
  5554. writeChunk(destination, chunks[chunkIdx]);
  5555. }
  5556. if (chunkIdx < chunks.length) {
  5557. r = writeChunkAndReturn(destination, chunks[chunkIdx]);
  5558. }
  5559. return r;
  5560. }
  5561. default:
  5562. {
  5563. throw new Error('Aborted, errored or already flushed boundaries should not be flushed again. This is a bug in React.');
  5564. }
  5565. }
  5566. }
  5567. function flushSegment(request, destination, segment) {
  5568. var boundary = segment.boundary;
  5569. if (boundary === null) {
  5570. // Not a suspense boundary.
  5571. return flushSubtree(request, destination, segment);
  5572. }
  5573. boundary.parentFlushed = true; // This segment is a Suspense boundary. We need to decide whether to
  5574. // emit the content or the fallback now.
  5575. if (boundary.forceClientRender) {
  5576. // Emit a client rendered suspense boundary wrapper.
  5577. // We never queue the inner boundary so we'll never emit its content or partial segments.
  5578. writeStartClientRenderedSuspenseBoundary$1(destination, request.responseState, boundary.errorDigest, boundary.errorMessage, boundary.errorComponentStack); // Flush the fallback.
  5579. flushSubtree(request, destination, segment);
  5580. return writeEndClientRenderedSuspenseBoundary$1(destination, request.responseState);
  5581. } else if (boundary.pendingTasks > 0) {
  5582. // This boundary is still loading. Emit a pending suspense boundary wrapper.
  5583. // Assign an ID to refer to the future content by.
  5584. boundary.rootSegmentID = request.nextSegmentId++;
  5585. if (boundary.completedSegments.length > 0) {
  5586. // If this is at least partially complete, we can queue it to be partially emitted early.
  5587. request.partialBoundaries.push(boundary);
  5588. } /// This is the first time we should have referenced this ID.
  5589. var id = boundary.id = assignSuspenseBoundaryID(request.responseState);
  5590. writeStartPendingSuspenseBoundary(destination, request.responseState, id); // Flush the fallback.
  5591. flushSubtree(request, destination, segment);
  5592. return writeEndPendingSuspenseBoundary(destination, request.responseState);
  5593. } else if (boundary.byteSize > request.progressiveChunkSize) {
  5594. // This boundary is large and will be emitted separately so that we can progressively show
  5595. // other content. We add it to the queue during the flush because we have to ensure that
  5596. // the parent flushes first so that there's something to inject it into.
  5597. // We also have to make sure that it's emitted into the queue in a deterministic slot.
  5598. // I.e. we can't insert it here when it completes.
  5599. // Assign an ID to refer to the future content by.
  5600. boundary.rootSegmentID = request.nextSegmentId++;
  5601. request.completedBoundaries.push(boundary); // Emit a pending rendered suspense boundary wrapper.
  5602. writeStartPendingSuspenseBoundary(destination, request.responseState, boundary.id); // Flush the fallback.
  5603. flushSubtree(request, destination, segment);
  5604. return writeEndPendingSuspenseBoundary(destination, request.responseState);
  5605. } else {
  5606. // We can inline this boundary's content as a complete boundary.
  5607. writeStartCompletedSuspenseBoundary$1(destination, request.responseState);
  5608. var completedSegments = boundary.completedSegments;
  5609. if (completedSegments.length !== 1) {
  5610. throw new Error('A previously unvisited boundary must have exactly one root segment. This is a bug in React.');
  5611. }
  5612. var contentSegment = completedSegments[0];
  5613. flushSegment(request, destination, contentSegment);
  5614. return writeEndCompletedSuspenseBoundary$1(destination, request.responseState);
  5615. }
  5616. }
  5617. function flushClientRenderedBoundary(request, destination, boundary) {
  5618. return writeClientRenderBoundaryInstruction(destination, request.responseState, boundary.id, boundary.errorDigest, boundary.errorMessage, boundary.errorComponentStack);
  5619. }
  5620. function flushSegmentContainer(request, destination, segment) {
  5621. writeStartSegment(destination, request.responseState, segment.formatContext, segment.id);
  5622. flushSegment(request, destination, segment);
  5623. return writeEndSegment(destination, segment.formatContext);
  5624. }
  5625. function flushCompletedBoundary(request, destination, boundary) {
  5626. var completedSegments = boundary.completedSegments;
  5627. var i = 0;
  5628. for (; i < completedSegments.length; i++) {
  5629. var segment = completedSegments[i];
  5630. flushPartiallyCompletedSegment(request, destination, boundary, segment);
  5631. }
  5632. completedSegments.length = 0;
  5633. return writeCompletedBoundaryInstruction(destination, request.responseState, boundary.id, boundary.rootSegmentID);
  5634. }
  5635. function flushPartialBoundary(request, destination, boundary) {
  5636. var completedSegments = boundary.completedSegments;
  5637. var i = 0;
  5638. for (; i < completedSegments.length; i++) {
  5639. var segment = completedSegments[i];
  5640. if (!flushPartiallyCompletedSegment(request, destination, boundary, segment)) {
  5641. i++;
  5642. completedSegments.splice(0, i); // Only write as much as the buffer wants. Something higher priority
  5643. // might want to write later.
  5644. return false;
  5645. }
  5646. }
  5647. completedSegments.splice(0, i);
  5648. return true;
  5649. }
  5650. function flushPartiallyCompletedSegment(request, destination, boundary, segment) {
  5651. if (segment.status === FLUSHED) {
  5652. // We've already flushed this inline.
  5653. return true;
  5654. }
  5655. var segmentID = segment.id;
  5656. if (segmentID === -1) {
  5657. // This segment wasn't previously referred to. This happens at the root of
  5658. // a boundary. We make kind of a leap here and assume this is the root.
  5659. var rootSegmentID = segment.id = boundary.rootSegmentID;
  5660. if (rootSegmentID === -1) {
  5661. throw new Error('A root segment ID must have been assigned by now. This is a bug in React.');
  5662. }
  5663. return flushSegmentContainer(request, destination, segment);
  5664. } else {
  5665. flushSegmentContainer(request, destination, segment);
  5666. return writeCompletedSegmentInstruction(destination, request.responseState, segmentID);
  5667. }
  5668. }
  5669. function flushCompletedQueues(request, destination) {
  5670. try {
  5671. // The structure of this is to go through each queue one by one and write
  5672. // until the sink tells us to stop. When we should stop, we still finish writing
  5673. // that item fully and then yield. At that point we remove the already completed
  5674. // items up until the point we completed them.
  5675. // TODO: Emit preloading.
  5676. // TODO: It's kind of unfortunate to keep checking this array after we've already
  5677. // emitted the root.
  5678. var completedRootSegment = request.completedRootSegment;
  5679. if (completedRootSegment !== null && request.pendingRootTasks === 0) {
  5680. flushSegment(request, destination, completedRootSegment);
  5681. request.completedRootSegment = null;
  5682. writeCompletedRoot(destination, request.responseState);
  5683. } // We emit client rendering instructions for already emitted boundaries first.
  5684. // This is so that we can signal to the client to start client rendering them as
  5685. // soon as possible.
  5686. var clientRenderedBoundaries = request.clientRenderedBoundaries;
  5687. var i;
  5688. for (i = 0; i < clientRenderedBoundaries.length; i++) {
  5689. var boundary = clientRenderedBoundaries[i];
  5690. if (!flushClientRenderedBoundary(request, destination, boundary)) {
  5691. request.destination = null;
  5692. i++;
  5693. clientRenderedBoundaries.splice(0, i);
  5694. return;
  5695. }
  5696. }
  5697. clientRenderedBoundaries.splice(0, i); // Next we emit any complete boundaries. It's better to favor boundaries
  5698. // that are completely done since we can actually show them, than it is to emit
  5699. // any individual segments from a partially complete boundary.
  5700. var completedBoundaries = request.completedBoundaries;
  5701. for (i = 0; i < completedBoundaries.length; i++) {
  5702. var _boundary = completedBoundaries[i];
  5703. if (!flushCompletedBoundary(request, destination, _boundary)) {
  5704. request.destination = null;
  5705. i++;
  5706. completedBoundaries.splice(0, i);
  5707. return;
  5708. }
  5709. }
  5710. completedBoundaries.splice(0, i); // Allow anything written so far to flush to the underlying sink before
  5711. // we continue with lower priorities.
  5712. completeWriting(destination);
  5713. beginWriting(destination); // TODO: Here we'll emit data used by hydration.
  5714. // Next we emit any segments of any boundaries that are partially complete
  5715. // but not deeply complete.
  5716. var partialBoundaries = request.partialBoundaries;
  5717. for (i = 0; i < partialBoundaries.length; i++) {
  5718. var _boundary2 = partialBoundaries[i];
  5719. if (!flushPartialBoundary(request, destination, _boundary2)) {
  5720. request.destination = null;
  5721. i++;
  5722. partialBoundaries.splice(0, i);
  5723. return;
  5724. }
  5725. }
  5726. partialBoundaries.splice(0, i); // Next we check the completed boundaries again. This may have had
  5727. // boundaries added to it in case they were too larged to be inlined.
  5728. // New ones might be added in this loop.
  5729. var largeBoundaries = request.completedBoundaries;
  5730. for (i = 0; i < largeBoundaries.length; i++) {
  5731. var _boundary3 = largeBoundaries[i];
  5732. if (!flushCompletedBoundary(request, destination, _boundary3)) {
  5733. request.destination = null;
  5734. i++;
  5735. largeBoundaries.splice(0, i);
  5736. return;
  5737. }
  5738. }
  5739. largeBoundaries.splice(0, i);
  5740. } finally {
  5741. if (request.allPendingTasks === 0 && request.pingedTasks.length === 0 && request.clientRenderedBoundaries.length === 0 && request.completedBoundaries.length === 0 // We don't need to check any partially completed segments because
  5742. // either they have pending task or they're complete.
  5743. ) {
  5744. {
  5745. if (request.abortableTasks.size !== 0) {
  5746. error('There was still abortable task at the root when we closed. This is a bug in React.');
  5747. }
  5748. } // We're done.
  5749. close(destination);
  5750. }
  5751. }
  5752. }
  5753. function startWork(request) {
  5754. scheduleWork(function () {
  5755. return performWork(request);
  5756. });
  5757. }
  5758. function startFlowing(request, destination) {
  5759. if (request.status === CLOSING) {
  5760. request.status = CLOSED;
  5761. closeWithError(destination, request.fatalError);
  5762. return;
  5763. }
  5764. if (request.status === CLOSED) {
  5765. return;
  5766. }
  5767. if (request.destination !== null) {
  5768. // We're already flowing.
  5769. return;
  5770. }
  5771. request.destination = destination;
  5772. try {
  5773. flushCompletedQueues(request, destination);
  5774. } catch (error) {
  5775. logRecoverableError(request, error);
  5776. fatalError(request, error);
  5777. }
  5778. } // This is called to early terminate a request. It puts all pending boundaries in client rendered state.
  5779. function abort(request, reason) {
  5780. try {
  5781. var abortableTasks = request.abortableTasks;
  5782. abortableTasks.forEach(function (task) {
  5783. return abortTask(task, request, reason);
  5784. });
  5785. abortableTasks.clear();
  5786. if (request.destination !== null) {
  5787. flushCompletedQueues(request, request.destination);
  5788. }
  5789. } catch (error) {
  5790. logRecoverableError(request, error);
  5791. fatalError(request, error);
  5792. }
  5793. }
  5794. function onError() {// Non-fatal errors are ignored.
  5795. }
  5796. function renderToStringImpl(children, options, generateStaticMarkup, abortReason) {
  5797. var didFatal = false;
  5798. var fatalError = null;
  5799. var result = '';
  5800. var destination = {
  5801. push: function (chunk) {
  5802. if (chunk !== null) {
  5803. result += chunk;
  5804. }
  5805. return true;
  5806. },
  5807. destroy: function (error) {
  5808. didFatal = true;
  5809. fatalError = error;
  5810. }
  5811. };
  5812. var readyToStream = false;
  5813. function onShellReady() {
  5814. readyToStream = true;
  5815. }
  5816. var request = createRequest(children, createResponseState$1(generateStaticMarkup, options ? options.identifierPrefix : undefined), createRootFormatContext(), Infinity, onError, undefined, onShellReady, undefined, undefined);
  5817. startWork(request); // If anything suspended and is still pending, we'll abort it before writing.
  5818. // That way we write only client-rendered boundaries from the start.
  5819. abort(request, abortReason);
  5820. startFlowing(request, destination);
  5821. if (didFatal) {
  5822. throw fatalError;
  5823. }
  5824. if (!readyToStream) {
  5825. // Note: This error message is the one we use on the client. It doesn't
  5826. // really make sense here. But this is the legacy server renderer, anyway.
  5827. // We're going to delete it soon.
  5828. throw new Error('A component suspended while responding to synchronous input. This ' + 'will cause the UI to be replaced with a loading indicator. To fix, ' + 'updates that suspend should be wrapped with startTransition.');
  5829. }
  5830. return result;
  5831. }
  5832. function renderToString(children, options) {
  5833. return renderToStringImpl(children, options, false, 'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server');
  5834. }
  5835. function renderToStaticMarkup(children, options) {
  5836. return renderToStringImpl(children, options, true, 'The server used "renderToStaticMarkup" which does not support Suspense. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server');
  5837. }
  5838. function renderToNodeStream() {
  5839. throw new Error('ReactDOMServer.renderToNodeStream(): The streaming API is not available ' + 'in the browser. Use ReactDOMServer.renderToString() instead.');
  5840. }
  5841. function renderToStaticNodeStream() {
  5842. throw new Error('ReactDOMServer.renderToStaticNodeStream(): The streaming API is not available ' + 'in the browser. Use ReactDOMServer.renderToStaticMarkup() instead.');
  5843. }
  5844. exports.renderToNodeStream = renderToNodeStream;
  5845. exports.renderToStaticMarkup = renderToStaticMarkup;
  5846. exports.renderToStaticNodeStream = renderToStaticNodeStream;
  5847. exports.renderToString = renderToString;
  5848. exports.version = ReactVersion;
  5849. })();
  5850. }