chunk-KFYUZA3E.js 293 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508
  1. import {
  2. createHotContext
  3. } from "/build/_shared/chunk-OJSEL2DI.js";
  4. import {
  5. require_react_dom
  6. } from "/build/_shared/chunk-GIAAE3CH.js";
  7. import {
  8. require_react
  9. } from "/build/_shared/chunk-BOXFZXVX.js";
  10. import {
  11. __commonJS,
  12. __esm,
  13. __export,
  14. __toCommonJS,
  15. __toESM
  16. } from "/build/_shared/chunk-PNG5AS42.js";
  17. // node_modules/@remix-run/router/dist/router.js
  18. var router_exports = {};
  19. __export(router_exports, {
  20. AbortedDeferredError: () => AbortedDeferredError,
  21. Action: () => Action,
  22. IDLE_BLOCKER: () => IDLE_BLOCKER,
  23. IDLE_FETCHER: () => IDLE_FETCHER,
  24. IDLE_NAVIGATION: () => IDLE_NAVIGATION,
  25. UNSAFE_DEFERRED_SYMBOL: () => UNSAFE_DEFERRED_SYMBOL,
  26. UNSAFE_DeferredData: () => DeferredData,
  27. UNSAFE_ErrorResponseImpl: () => ErrorResponseImpl,
  28. UNSAFE_convertRouteMatchToUiMatch: () => convertRouteMatchToUiMatch,
  29. UNSAFE_convertRoutesToDataRoutes: () => convertRoutesToDataRoutes,
  30. UNSAFE_getResolveToMatches: () => getResolveToMatches,
  31. UNSAFE_invariant: () => invariant,
  32. UNSAFE_warning: () => warning,
  33. createBrowserHistory: () => createBrowserHistory,
  34. createHashHistory: () => createHashHistory,
  35. createMemoryHistory: () => createMemoryHistory,
  36. createPath: () => createPath,
  37. createRouter: () => createRouter,
  38. createStaticHandler: () => createStaticHandler,
  39. defer: () => defer,
  40. generatePath: () => generatePath,
  41. getStaticContextFromError: () => getStaticContextFromError,
  42. getToPathname: () => getToPathname,
  43. isDeferredData: () => isDeferredData,
  44. isRouteErrorResponse: () => isRouteErrorResponse,
  45. joinPaths: () => joinPaths,
  46. json: () => json,
  47. matchPath: () => matchPath,
  48. matchRoutes: () => matchRoutes,
  49. normalizePathname: () => normalizePathname,
  50. parsePath: () => parsePath,
  51. redirect: () => redirect,
  52. redirectDocument: () => redirectDocument,
  53. resolvePath: () => resolvePath,
  54. resolveTo: () => resolveTo,
  55. stripBasename: () => stripBasename
  56. });
  57. function _extends() {
  58. _extends = Object.assign ? Object.assign.bind() : function(target) {
  59. for (var i = 1; i < arguments.length; i++) {
  60. var source = arguments[i];
  61. for (var key in source) {
  62. if (Object.prototype.hasOwnProperty.call(source, key)) {
  63. target[key] = source[key];
  64. }
  65. }
  66. }
  67. return target;
  68. };
  69. return _extends.apply(this, arguments);
  70. }
  71. function createMemoryHistory(options) {
  72. if (options === void 0) {
  73. options = {};
  74. }
  75. let {
  76. initialEntries = ["/"],
  77. initialIndex,
  78. v5Compat = false
  79. } = options;
  80. let entries;
  81. entries = initialEntries.map((entry, index2) => createMemoryLocation(entry, typeof entry === "string" ? null : entry.state, index2 === 0 ? "default" : void 0));
  82. let index = clampIndex(initialIndex == null ? entries.length - 1 : initialIndex);
  83. let action = Action.Pop;
  84. let listener = null;
  85. function clampIndex(n) {
  86. return Math.min(Math.max(n, 0), entries.length - 1);
  87. }
  88. function getCurrentLocation() {
  89. return entries[index];
  90. }
  91. function createMemoryLocation(to, state, key) {
  92. if (state === void 0) {
  93. state = null;
  94. }
  95. let location = createLocation(entries ? getCurrentLocation().pathname : "/", to, state, key);
  96. warning(location.pathname.charAt(0) === "/", "relative pathnames are not supported in memory history: " + JSON.stringify(to));
  97. return location;
  98. }
  99. function createHref(to) {
  100. return typeof to === "string" ? to : createPath(to);
  101. }
  102. let history = {
  103. get index() {
  104. return index;
  105. },
  106. get action() {
  107. return action;
  108. },
  109. get location() {
  110. return getCurrentLocation();
  111. },
  112. createHref,
  113. createURL(to) {
  114. return new URL(createHref(to), "http://localhost");
  115. },
  116. encodeLocation(to) {
  117. let path = typeof to === "string" ? parsePath(to) : to;
  118. return {
  119. pathname: path.pathname || "",
  120. search: path.search || "",
  121. hash: path.hash || ""
  122. };
  123. },
  124. push(to, state) {
  125. action = Action.Push;
  126. let nextLocation = createMemoryLocation(to, state);
  127. index += 1;
  128. entries.splice(index, entries.length, nextLocation);
  129. if (v5Compat && listener) {
  130. listener({
  131. action,
  132. location: nextLocation,
  133. delta: 1
  134. });
  135. }
  136. },
  137. replace(to, state) {
  138. action = Action.Replace;
  139. let nextLocation = createMemoryLocation(to, state);
  140. entries[index] = nextLocation;
  141. if (v5Compat && listener) {
  142. listener({
  143. action,
  144. location: nextLocation,
  145. delta: 0
  146. });
  147. }
  148. },
  149. go(delta) {
  150. action = Action.Pop;
  151. let nextIndex = clampIndex(index + delta);
  152. let nextLocation = entries[nextIndex];
  153. index = nextIndex;
  154. if (listener) {
  155. listener({
  156. action,
  157. location: nextLocation,
  158. delta
  159. });
  160. }
  161. },
  162. listen(fn) {
  163. listener = fn;
  164. return () => {
  165. listener = null;
  166. };
  167. }
  168. };
  169. return history;
  170. }
  171. function createBrowserHistory(options) {
  172. if (options === void 0) {
  173. options = {};
  174. }
  175. function createBrowserLocation(window2, globalHistory) {
  176. let {
  177. pathname,
  178. search,
  179. hash
  180. } = window2.location;
  181. return createLocation(
  182. "",
  183. {
  184. pathname,
  185. search,
  186. hash
  187. },
  188. // state defaults to `null` because `window.history.state` does
  189. globalHistory.state && globalHistory.state.usr || null,
  190. globalHistory.state && globalHistory.state.key || "default"
  191. );
  192. }
  193. function createBrowserHref(window2, to) {
  194. return typeof to === "string" ? to : createPath(to);
  195. }
  196. return getUrlBasedHistory(createBrowserLocation, createBrowserHref, null, options);
  197. }
  198. function createHashHistory(options) {
  199. if (options === void 0) {
  200. options = {};
  201. }
  202. function createHashLocation(window2, globalHistory) {
  203. let {
  204. pathname = "/",
  205. search = "",
  206. hash = ""
  207. } = parsePath(window2.location.hash.substr(1));
  208. if (!pathname.startsWith("/") && !pathname.startsWith(".")) {
  209. pathname = "/" + pathname;
  210. }
  211. return createLocation(
  212. "",
  213. {
  214. pathname,
  215. search,
  216. hash
  217. },
  218. // state defaults to `null` because `window.history.state` does
  219. globalHistory.state && globalHistory.state.usr || null,
  220. globalHistory.state && globalHistory.state.key || "default"
  221. );
  222. }
  223. function createHashHref(window2, to) {
  224. let base = window2.document.querySelector("base");
  225. let href = "";
  226. if (base && base.getAttribute("href")) {
  227. let url = window2.location.href;
  228. let hashIndex = url.indexOf("#");
  229. href = hashIndex === -1 ? url : url.slice(0, hashIndex);
  230. }
  231. return href + "#" + (typeof to === "string" ? to : createPath(to));
  232. }
  233. function validateHashLocation(location, to) {
  234. warning(location.pathname.charAt(0) === "/", "relative pathnames are not supported in hash history.push(" + JSON.stringify(to) + ")");
  235. }
  236. return getUrlBasedHistory(createHashLocation, createHashHref, validateHashLocation, options);
  237. }
  238. function invariant(value, message) {
  239. if (value === false || value === null || typeof value === "undefined") {
  240. throw new Error(message);
  241. }
  242. }
  243. function warning(cond, message) {
  244. if (!cond) {
  245. if (typeof console !== "undefined")
  246. console.warn(message);
  247. try {
  248. throw new Error(message);
  249. } catch (e) {
  250. }
  251. }
  252. }
  253. function createKey() {
  254. return Math.random().toString(36).substr(2, 8);
  255. }
  256. function getHistoryState(location, index) {
  257. return {
  258. usr: location.state,
  259. key: location.key,
  260. idx: index
  261. };
  262. }
  263. function createLocation(current, to, state, key) {
  264. if (state === void 0) {
  265. state = null;
  266. }
  267. let location = _extends({
  268. pathname: typeof current === "string" ? current : current.pathname,
  269. search: "",
  270. hash: ""
  271. }, typeof to === "string" ? parsePath(to) : to, {
  272. state,
  273. // TODO: This could be cleaned up. push/replace should probably just take
  274. // full Locations now and avoid the need to run through this flow at all
  275. // But that's a pretty big refactor to the current test suite so going to
  276. // keep as is for the time being and just let any incoming keys take precedence
  277. key: to && to.key || key || createKey()
  278. });
  279. return location;
  280. }
  281. function createPath(_ref) {
  282. let {
  283. pathname = "/",
  284. search = "",
  285. hash = ""
  286. } = _ref;
  287. if (search && search !== "?")
  288. pathname += search.charAt(0) === "?" ? search : "?" + search;
  289. if (hash && hash !== "#")
  290. pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
  291. return pathname;
  292. }
  293. function parsePath(path) {
  294. let parsedPath = {};
  295. if (path) {
  296. let hashIndex = path.indexOf("#");
  297. if (hashIndex >= 0) {
  298. parsedPath.hash = path.substr(hashIndex);
  299. path = path.substr(0, hashIndex);
  300. }
  301. let searchIndex = path.indexOf("?");
  302. if (searchIndex >= 0) {
  303. parsedPath.search = path.substr(searchIndex);
  304. path = path.substr(0, searchIndex);
  305. }
  306. if (path) {
  307. parsedPath.pathname = path;
  308. }
  309. }
  310. return parsedPath;
  311. }
  312. function getUrlBasedHistory(getLocation, createHref, validateLocation, options) {
  313. if (options === void 0) {
  314. options = {};
  315. }
  316. let {
  317. window: window2 = document.defaultView,
  318. v5Compat = false
  319. } = options;
  320. let globalHistory = window2.history;
  321. let action = Action.Pop;
  322. let listener = null;
  323. let index = getIndex();
  324. if (index == null) {
  325. index = 0;
  326. globalHistory.replaceState(_extends({}, globalHistory.state, {
  327. idx: index
  328. }), "");
  329. }
  330. function getIndex() {
  331. let state = globalHistory.state || {
  332. idx: null
  333. };
  334. return state.idx;
  335. }
  336. function handlePop() {
  337. action = Action.Pop;
  338. let nextIndex = getIndex();
  339. let delta = nextIndex == null ? null : nextIndex - index;
  340. index = nextIndex;
  341. if (listener) {
  342. listener({
  343. action,
  344. location: history.location,
  345. delta
  346. });
  347. }
  348. }
  349. function push(to, state) {
  350. action = Action.Push;
  351. let location = createLocation(history.location, to, state);
  352. if (validateLocation)
  353. validateLocation(location, to);
  354. index = getIndex() + 1;
  355. let historyState = getHistoryState(location, index);
  356. let url = history.createHref(location);
  357. try {
  358. globalHistory.pushState(historyState, "", url);
  359. } catch (error) {
  360. if (error instanceof DOMException && error.name === "DataCloneError") {
  361. throw error;
  362. }
  363. window2.location.assign(url);
  364. }
  365. if (v5Compat && listener) {
  366. listener({
  367. action,
  368. location: history.location,
  369. delta: 1
  370. });
  371. }
  372. }
  373. function replace(to, state) {
  374. action = Action.Replace;
  375. let location = createLocation(history.location, to, state);
  376. if (validateLocation)
  377. validateLocation(location, to);
  378. index = getIndex();
  379. let historyState = getHistoryState(location, index);
  380. let url = history.createHref(location);
  381. globalHistory.replaceState(historyState, "", url);
  382. if (v5Compat && listener) {
  383. listener({
  384. action,
  385. location: history.location,
  386. delta: 0
  387. });
  388. }
  389. }
  390. function createURL(to) {
  391. let base = window2.location.origin !== "null" ? window2.location.origin : window2.location.href;
  392. let href = typeof to === "string" ? to : createPath(to);
  393. invariant(base, "No window.location.(origin|href) available to create URL for href: " + href);
  394. return new URL(href, base);
  395. }
  396. let history = {
  397. get action() {
  398. return action;
  399. },
  400. get location() {
  401. return getLocation(window2, globalHistory);
  402. },
  403. listen(fn) {
  404. if (listener) {
  405. throw new Error("A history only accepts one active listener");
  406. }
  407. window2.addEventListener(PopStateEventType, handlePop);
  408. listener = fn;
  409. return () => {
  410. window2.removeEventListener(PopStateEventType, handlePop);
  411. listener = null;
  412. };
  413. },
  414. createHref(to) {
  415. return createHref(window2, to);
  416. },
  417. createURL,
  418. encodeLocation(to) {
  419. let url = createURL(to);
  420. return {
  421. pathname: url.pathname,
  422. search: url.search,
  423. hash: url.hash
  424. };
  425. },
  426. push,
  427. replace,
  428. go(n) {
  429. return globalHistory.go(n);
  430. }
  431. };
  432. return history;
  433. }
  434. function isIndexRoute(route) {
  435. return route.index === true;
  436. }
  437. function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath, manifest) {
  438. if (parentPath === void 0) {
  439. parentPath = [];
  440. }
  441. if (manifest === void 0) {
  442. manifest = {};
  443. }
  444. return routes.map((route, index) => {
  445. let treePath = [...parentPath, index];
  446. let id = typeof route.id === "string" ? route.id : treePath.join("-");
  447. invariant(route.index !== true || !route.children, "Cannot specify children on an index route");
  448. invariant(!manifest[id], 'Found a route id collision on id "' + id + `". Route id's must be globally unique within Data Router usages`);
  449. if (isIndexRoute(route)) {
  450. let indexRoute = _extends({}, route, mapRouteProperties2(route), {
  451. id
  452. });
  453. manifest[id] = indexRoute;
  454. return indexRoute;
  455. } else {
  456. let pathOrLayoutRoute = _extends({}, route, mapRouteProperties2(route), {
  457. id,
  458. children: void 0
  459. });
  460. manifest[id] = pathOrLayoutRoute;
  461. if (route.children) {
  462. pathOrLayoutRoute.children = convertRoutesToDataRoutes(route.children, mapRouteProperties2, treePath, manifest);
  463. }
  464. return pathOrLayoutRoute;
  465. }
  466. });
  467. }
  468. function matchRoutes(routes, locationArg, basename) {
  469. if (basename === void 0) {
  470. basename = "/";
  471. }
  472. let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
  473. let pathname = stripBasename(location.pathname || "/", basename);
  474. if (pathname == null) {
  475. return null;
  476. }
  477. let branches = flattenRoutes(routes);
  478. rankRouteBranches(branches);
  479. let matches = null;
  480. for (let i = 0; matches == null && i < branches.length; ++i) {
  481. matches = matchRouteBranch(
  482. branches[i],
  483. // Incoming pathnames are generally encoded from either window.location
  484. // or from router.navigate, but we want to match against the unencoded
  485. // paths in the route definitions. Memory router locations won't be
  486. // encoded here but there also shouldn't be anything to decode so this
  487. // should be a safe operation. This avoids needing matchRoutes to be
  488. // history-aware.
  489. safelyDecodeURI(pathname)
  490. );
  491. }
  492. return matches;
  493. }
  494. function convertRouteMatchToUiMatch(match, loaderData) {
  495. let {
  496. route,
  497. pathname,
  498. params
  499. } = match;
  500. return {
  501. id: route.id,
  502. pathname,
  503. params,
  504. data: loaderData[route.id],
  505. handle: route.handle
  506. };
  507. }
  508. function flattenRoutes(routes, branches, parentsMeta, parentPath) {
  509. if (branches === void 0) {
  510. branches = [];
  511. }
  512. if (parentsMeta === void 0) {
  513. parentsMeta = [];
  514. }
  515. if (parentPath === void 0) {
  516. parentPath = "";
  517. }
  518. let flattenRoute = (route, index, relativePath) => {
  519. let meta = {
  520. relativePath: relativePath === void 0 ? route.path || "" : relativePath,
  521. caseSensitive: route.caseSensitive === true,
  522. childrenIndex: index,
  523. route
  524. };
  525. if (meta.relativePath.startsWith("/")) {
  526. invariant(meta.relativePath.startsWith(parentPath), 'Absolute route path "' + meta.relativePath + '" nested under path ' + ('"' + parentPath + '" is not valid. An absolute child route path ') + "must start with the combined path of all its parent routes.");
  527. meta.relativePath = meta.relativePath.slice(parentPath.length);
  528. }
  529. let path = joinPaths([parentPath, meta.relativePath]);
  530. let routesMeta = parentsMeta.concat(meta);
  531. if (route.children && route.children.length > 0) {
  532. invariant(
  533. // Our types know better, but runtime JS may not!
  534. // @ts-expect-error
  535. route.index !== true,
  536. "Index routes must not have child routes. Please remove " + ('all child routes from route path "' + path + '".')
  537. );
  538. flattenRoutes(route.children, branches, routesMeta, path);
  539. }
  540. if (route.path == null && !route.index) {
  541. return;
  542. }
  543. branches.push({
  544. path,
  545. score: computeScore(path, route.index),
  546. routesMeta
  547. });
  548. };
  549. routes.forEach((route, index) => {
  550. var _route$path;
  551. if (route.path === "" || !((_route$path = route.path) != null && _route$path.includes("?"))) {
  552. flattenRoute(route, index);
  553. } else {
  554. for (let exploded of explodeOptionalSegments(route.path)) {
  555. flattenRoute(route, index, exploded);
  556. }
  557. }
  558. });
  559. return branches;
  560. }
  561. function explodeOptionalSegments(path) {
  562. let segments = path.split("/");
  563. if (segments.length === 0)
  564. return [];
  565. let [first, ...rest] = segments;
  566. let isOptional = first.endsWith("?");
  567. let required = first.replace(/\?$/, "");
  568. if (rest.length === 0) {
  569. return isOptional ? [required, ""] : [required];
  570. }
  571. let restExploded = explodeOptionalSegments(rest.join("/"));
  572. let result = [];
  573. result.push(...restExploded.map((subpath) => subpath === "" ? required : [required, subpath].join("/")));
  574. if (isOptional) {
  575. result.push(...restExploded);
  576. }
  577. return result.map((exploded) => path.startsWith("/") && exploded === "" ? "/" : exploded);
  578. }
  579. function rankRouteBranches(branches) {
  580. branches.sort((a, b) => a.score !== b.score ? b.score - a.score : compareIndexes(a.routesMeta.map((meta) => meta.childrenIndex), b.routesMeta.map((meta) => meta.childrenIndex)));
  581. }
  582. function computeScore(path, index) {
  583. let segments = path.split("/");
  584. let initialScore = segments.length;
  585. if (segments.some(isSplat)) {
  586. initialScore += splatPenalty;
  587. }
  588. if (index) {
  589. initialScore += indexRouteValue;
  590. }
  591. return segments.filter((s) => !isSplat(s)).reduce((score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue), initialScore);
  592. }
  593. function compareIndexes(a, b) {
  594. let siblings = a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]);
  595. return siblings ? (
  596. // If two routes are siblings, we should try to match the earlier sibling
  597. // first. This allows people to have fine-grained control over the matching
  598. // behavior by simply putting routes with identical paths in the order they
  599. // want them tried.
  600. a[a.length - 1] - b[b.length - 1]
  601. ) : (
  602. // Otherwise, it doesn't really make sense to rank non-siblings by index,
  603. // so they sort equally.
  604. 0
  605. );
  606. }
  607. function matchRouteBranch(branch, pathname) {
  608. let {
  609. routesMeta
  610. } = branch;
  611. let matchedParams = {};
  612. let matchedPathname = "/";
  613. let matches = [];
  614. for (let i = 0; i < routesMeta.length; ++i) {
  615. let meta = routesMeta[i];
  616. let end = i === routesMeta.length - 1;
  617. let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
  618. let match = matchPath({
  619. path: meta.relativePath,
  620. caseSensitive: meta.caseSensitive,
  621. end
  622. }, remainingPathname);
  623. if (!match)
  624. return null;
  625. Object.assign(matchedParams, match.params);
  626. let route = meta.route;
  627. matches.push({
  628. // TODO: Can this as be avoided?
  629. params: matchedParams,
  630. pathname: joinPaths([matchedPathname, match.pathname]),
  631. pathnameBase: normalizePathname(joinPaths([matchedPathname, match.pathnameBase])),
  632. route
  633. });
  634. if (match.pathnameBase !== "/") {
  635. matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);
  636. }
  637. }
  638. return matches;
  639. }
  640. function generatePath(originalPath, params) {
  641. if (params === void 0) {
  642. params = {};
  643. }
  644. let path = originalPath;
  645. if (path.endsWith("*") && path !== "*" && !path.endsWith("/*")) {
  646. warning(false, 'Route path "' + path + '" will be treated as if it were ' + ('"' + path.replace(/\*$/, "/*") + '" because the `*` character must ') + "always follow a `/` in the pattern. To get rid of this warning, " + ('please change the route path to "' + path.replace(/\*$/, "/*") + '".'));
  647. path = path.replace(/\*$/, "/*");
  648. }
  649. const prefix = path.startsWith("/") ? "/" : "";
  650. const stringify = (p) => p == null ? "" : typeof p === "string" ? p : String(p);
  651. const segments = path.split(/\/+/).map((segment, index, array) => {
  652. const isLastSegment = index === array.length - 1;
  653. if (isLastSegment && segment === "*") {
  654. const star = "*";
  655. return stringify(params[star]);
  656. }
  657. const keyMatch = segment.match(/^:([\w-]+)(\??)$/);
  658. if (keyMatch) {
  659. const [, key, optional] = keyMatch;
  660. let param = params[key];
  661. invariant(optional === "?" || param != null, 'Missing ":' + key + '" param');
  662. return stringify(param);
  663. }
  664. return segment.replace(/\?$/g, "");
  665. }).filter((segment) => !!segment);
  666. return prefix + segments.join("/");
  667. }
  668. function matchPath(pattern, pathname) {
  669. if (typeof pattern === "string") {
  670. pattern = {
  671. path: pattern,
  672. caseSensitive: false,
  673. end: true
  674. };
  675. }
  676. let [matcher, compiledParams] = compilePath(pattern.path, pattern.caseSensitive, pattern.end);
  677. let match = pathname.match(matcher);
  678. if (!match)
  679. return null;
  680. let matchedPathname = match[0];
  681. let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
  682. let captureGroups = match.slice(1);
  683. let params = compiledParams.reduce((memo, _ref, index) => {
  684. let {
  685. paramName,
  686. isOptional
  687. } = _ref;
  688. if (paramName === "*") {
  689. let splatValue = captureGroups[index] || "";
  690. pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
  691. }
  692. const value = captureGroups[index];
  693. if (isOptional && !value) {
  694. memo[paramName] = void 0;
  695. } else {
  696. memo[paramName] = safelyDecodeURIComponent(value || "", paramName);
  697. }
  698. return memo;
  699. }, {});
  700. return {
  701. params,
  702. pathname: matchedPathname,
  703. pathnameBase,
  704. pattern
  705. };
  706. }
  707. function compilePath(path, caseSensitive, end) {
  708. if (caseSensitive === void 0) {
  709. caseSensitive = false;
  710. }
  711. if (end === void 0) {
  712. end = true;
  713. }
  714. warning(path === "*" || !path.endsWith("*") || path.endsWith("/*"), 'Route path "' + path + '" will be treated as if it were ' + ('"' + path.replace(/\*$/, "/*") + '" because the `*` character must ') + "always follow a `/` in the pattern. To get rid of this warning, " + ('please change the route path to "' + path.replace(/\*$/, "/*") + '".'));
  715. let params = [];
  716. let regexpSource = "^" + path.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(/\/:([\w-]+)(\?)?/g, (_, paramName, isOptional) => {
  717. params.push({
  718. paramName,
  719. isOptional: isOptional != null
  720. });
  721. return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
  722. });
  723. if (path.endsWith("*")) {
  724. params.push({
  725. paramName: "*"
  726. });
  727. regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
  728. } else if (end) {
  729. regexpSource += "\\/*$";
  730. } else if (path !== "" && path !== "/") {
  731. regexpSource += "(?:(?=\\/|$))";
  732. } else
  733. ;
  734. let matcher = new RegExp(regexpSource, caseSensitive ? void 0 : "i");
  735. return [matcher, params];
  736. }
  737. function safelyDecodeURI(value) {
  738. try {
  739. return decodeURI(value);
  740. } catch (error) {
  741. warning(false, 'The URL path "' + value + '" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent ' + ("encoding (" + error + ")."));
  742. return value;
  743. }
  744. }
  745. function safelyDecodeURIComponent(value, paramName) {
  746. try {
  747. return decodeURIComponent(value);
  748. } catch (error) {
  749. warning(false, 'The value for the URL param "' + paramName + '" will not be decoded because' + (' the string "' + value + '" is a malformed URL segment. This is probably') + (" due to a bad percent encoding (" + error + ")."));
  750. return value;
  751. }
  752. }
  753. function stripBasename(pathname, basename) {
  754. if (basename === "/")
  755. return pathname;
  756. if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {
  757. return null;
  758. }
  759. let startIndex = basename.endsWith("/") ? basename.length - 1 : basename.length;
  760. let nextChar = pathname.charAt(startIndex);
  761. if (nextChar && nextChar !== "/") {
  762. return null;
  763. }
  764. return pathname.slice(startIndex) || "/";
  765. }
  766. function resolvePath(to, fromPathname) {
  767. if (fromPathname === void 0) {
  768. fromPathname = "/";
  769. }
  770. let {
  771. pathname: toPathname,
  772. search = "",
  773. hash = ""
  774. } = typeof to === "string" ? parsePath(to) : to;
  775. let pathname = toPathname ? toPathname.startsWith("/") ? toPathname : resolvePathname(toPathname, fromPathname) : fromPathname;
  776. return {
  777. pathname,
  778. search: normalizeSearch(search),
  779. hash: normalizeHash(hash)
  780. };
  781. }
  782. function resolvePathname(relativePath, fromPathname) {
  783. let segments = fromPathname.replace(/\/+$/, "").split("/");
  784. let relativeSegments = relativePath.split("/");
  785. relativeSegments.forEach((segment) => {
  786. if (segment === "..") {
  787. if (segments.length > 1)
  788. segments.pop();
  789. } else if (segment !== ".") {
  790. segments.push(segment);
  791. }
  792. });
  793. return segments.length > 1 ? segments.join("/") : "/";
  794. }
  795. function getInvalidPathError(char, field, dest, path) {
  796. return "Cannot include a '" + char + "' character in a manually specified " + ("`to." + field + "` field [" + JSON.stringify(path) + "]. Please separate it out to the ") + ("`to." + dest + "` field. Alternatively you may provide the full path as ") + 'a string in <Link to="..."> and the router will parse it for you.';
  797. }
  798. function getPathContributingMatches(matches) {
  799. return matches.filter((match, index) => index === 0 || match.route.path && match.route.path.length > 0);
  800. }
  801. function getResolveToMatches(matches, v7_relativeSplatPath) {
  802. let pathMatches = getPathContributingMatches(matches);
  803. if (v7_relativeSplatPath) {
  804. return pathMatches.map((match, idx) => idx === matches.length - 1 ? match.pathname : match.pathnameBase);
  805. }
  806. return pathMatches.map((match) => match.pathnameBase);
  807. }
  808. function resolveTo(toArg, routePathnames, locationPathname, isPathRelative) {
  809. if (isPathRelative === void 0) {
  810. isPathRelative = false;
  811. }
  812. let to;
  813. if (typeof toArg === "string") {
  814. to = parsePath(toArg);
  815. } else {
  816. to = _extends({}, toArg);
  817. invariant(!to.pathname || !to.pathname.includes("?"), getInvalidPathError("?", "pathname", "search", to));
  818. invariant(!to.pathname || !to.pathname.includes("#"), getInvalidPathError("#", "pathname", "hash", to));
  819. invariant(!to.search || !to.search.includes("#"), getInvalidPathError("#", "search", "hash", to));
  820. }
  821. let isEmptyPath = toArg === "" || to.pathname === "";
  822. let toPathname = isEmptyPath ? "/" : to.pathname;
  823. let from;
  824. if (toPathname == null) {
  825. from = locationPathname;
  826. } else {
  827. let routePathnameIndex = routePathnames.length - 1;
  828. if (!isPathRelative && toPathname.startsWith("..")) {
  829. let toSegments = toPathname.split("/");
  830. while (toSegments[0] === "..") {
  831. toSegments.shift();
  832. routePathnameIndex -= 1;
  833. }
  834. to.pathname = toSegments.join("/");
  835. }
  836. from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
  837. }
  838. let path = resolvePath(to, from);
  839. let hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/");
  840. let hasCurrentTrailingSlash = (isEmptyPath || toPathname === ".") && locationPathname.endsWith("/");
  841. if (!path.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) {
  842. path.pathname += "/";
  843. }
  844. return path;
  845. }
  846. function getToPathname(to) {
  847. return to === "" || to.pathname === "" ? "/" : typeof to === "string" ? parsePath(to).pathname : to.pathname;
  848. }
  849. function isTrackedPromise(value) {
  850. return value instanceof Promise && value._tracked === true;
  851. }
  852. function unwrapTrackedPromise(value) {
  853. if (!isTrackedPromise(value)) {
  854. return value;
  855. }
  856. if (value._error) {
  857. throw value._error;
  858. }
  859. return value._data;
  860. }
  861. function isRouteErrorResponse(error) {
  862. return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
  863. }
  864. function createRouter(init) {
  865. const routerWindow = init.window ? init.window : typeof window !== "undefined" ? window : void 0;
  866. const isBrowser2 = typeof routerWindow !== "undefined" && typeof routerWindow.document !== "undefined" && typeof routerWindow.document.createElement !== "undefined";
  867. const isServer = !isBrowser2;
  868. invariant(init.routes.length > 0, "You must provide a non-empty routes array to createRouter");
  869. let mapRouteProperties2;
  870. if (init.mapRouteProperties) {
  871. mapRouteProperties2 = init.mapRouteProperties;
  872. } else if (init.detectErrorBoundary) {
  873. let detectErrorBoundary = init.detectErrorBoundary;
  874. mapRouteProperties2 = (route) => ({
  875. hasErrorBoundary: detectErrorBoundary(route)
  876. });
  877. } else {
  878. mapRouteProperties2 = defaultMapRouteProperties;
  879. }
  880. let manifest = {};
  881. let dataRoutes = convertRoutesToDataRoutes(init.routes, mapRouteProperties2, void 0, manifest);
  882. let inFlightDataRoutes;
  883. let basename = init.basename || "/";
  884. let future = _extends({
  885. v7_fetcherPersist: false,
  886. v7_normalizeFormMethod: false,
  887. v7_partialHydration: false,
  888. v7_prependBasename: false,
  889. v7_relativeSplatPath: false
  890. }, init.future);
  891. let unlistenHistory = null;
  892. let subscribers = /* @__PURE__ */ new Set();
  893. let savedScrollPositions2 = null;
  894. let getScrollRestorationKey = null;
  895. let getScrollPosition = null;
  896. let initialScrollRestored = init.hydrationData != null;
  897. let initialMatches = matchRoutes(dataRoutes, init.history.location, basename);
  898. let initialErrors = null;
  899. if (initialMatches == null) {
  900. let error = getInternalRouterError(404, {
  901. pathname: init.history.location.pathname
  902. });
  903. let {
  904. matches,
  905. route
  906. } = getShortCircuitMatches(dataRoutes);
  907. initialMatches = matches;
  908. initialErrors = {
  909. [route.id]: error
  910. };
  911. }
  912. let initialized;
  913. let hasLazyRoutes = initialMatches.some((m) => m.route.lazy);
  914. let hasLoaders = initialMatches.some((m) => m.route.loader);
  915. if (hasLazyRoutes) {
  916. initialized = false;
  917. } else if (!hasLoaders) {
  918. initialized = true;
  919. } else if (future.v7_partialHydration) {
  920. let loaderData = init.hydrationData ? init.hydrationData.loaderData : null;
  921. let errors = init.hydrationData ? init.hydrationData.errors : null;
  922. initialized = initialMatches.every((m) => m.route.loader && m.route.loader.hydrate !== true && (loaderData && loaderData[m.route.id] !== void 0 || errors && errors[m.route.id] !== void 0));
  923. } else {
  924. initialized = init.hydrationData != null;
  925. }
  926. let router2;
  927. let state = {
  928. historyAction: init.history.action,
  929. location: init.history.location,
  930. matches: initialMatches,
  931. initialized,
  932. navigation: IDLE_NAVIGATION,
  933. // Don't restore on initial updateState() if we were SSR'd
  934. restoreScrollPosition: init.hydrationData != null ? false : null,
  935. preventScrollReset: false,
  936. revalidation: "idle",
  937. loaderData: init.hydrationData && init.hydrationData.loaderData || {},
  938. actionData: init.hydrationData && init.hydrationData.actionData || null,
  939. errors: init.hydrationData && init.hydrationData.errors || initialErrors,
  940. fetchers: /* @__PURE__ */ new Map(),
  941. blockers: /* @__PURE__ */ new Map()
  942. };
  943. let pendingAction = Action.Pop;
  944. let pendingPreventScrollReset = false;
  945. let pendingNavigationController;
  946. let pendingViewTransitionEnabled = false;
  947. let appliedViewTransitions = /* @__PURE__ */ new Map();
  948. let removePageHideEventListener = null;
  949. let isUninterruptedRevalidation = false;
  950. let isRevalidationRequired = false;
  951. let cancelledDeferredRoutes = [];
  952. let cancelledFetcherLoads = [];
  953. let fetchControllers = /* @__PURE__ */ new Map();
  954. let incrementingLoadId = 0;
  955. let pendingNavigationLoadId = -1;
  956. let fetchReloadIds = /* @__PURE__ */ new Map();
  957. let fetchRedirectIds = /* @__PURE__ */ new Set();
  958. let fetchLoadMatches = /* @__PURE__ */ new Map();
  959. let activeFetchers = /* @__PURE__ */ new Map();
  960. let deletedFetchers = /* @__PURE__ */ new Set();
  961. let activeDeferreds = /* @__PURE__ */ new Map();
  962. let blockerFunctions = /* @__PURE__ */ new Map();
  963. let ignoreNextHistoryUpdate = false;
  964. function initialize() {
  965. unlistenHistory = init.history.listen((_ref) => {
  966. let {
  967. action: historyAction,
  968. location,
  969. delta
  970. } = _ref;
  971. if (ignoreNextHistoryUpdate) {
  972. ignoreNextHistoryUpdate = false;
  973. return;
  974. }
  975. warning(blockerFunctions.size === 0 || delta != null, "You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");
  976. let blockerKey = shouldBlockNavigation({
  977. currentLocation: state.location,
  978. nextLocation: location,
  979. historyAction
  980. });
  981. if (blockerKey && delta != null) {
  982. ignoreNextHistoryUpdate = true;
  983. init.history.go(delta * -1);
  984. updateBlocker(blockerKey, {
  985. state: "blocked",
  986. location,
  987. proceed() {
  988. updateBlocker(blockerKey, {
  989. state: "proceeding",
  990. proceed: void 0,
  991. reset: void 0,
  992. location
  993. });
  994. init.history.go(delta);
  995. },
  996. reset() {
  997. let blockers = new Map(state.blockers);
  998. blockers.set(blockerKey, IDLE_BLOCKER);
  999. updateState({
  1000. blockers
  1001. });
  1002. }
  1003. });
  1004. return;
  1005. }
  1006. return startNavigation(historyAction, location);
  1007. });
  1008. if (isBrowser2) {
  1009. restoreAppliedTransitions(routerWindow, appliedViewTransitions);
  1010. let _saveAppliedTransitions = () => persistAppliedTransitions(routerWindow, appliedViewTransitions);
  1011. routerWindow.addEventListener("pagehide", _saveAppliedTransitions);
  1012. removePageHideEventListener = () => routerWindow.removeEventListener("pagehide", _saveAppliedTransitions);
  1013. }
  1014. if (!state.initialized) {
  1015. startNavigation(Action.Pop, state.location, {
  1016. initialHydration: true
  1017. });
  1018. }
  1019. return router2;
  1020. }
  1021. function dispose() {
  1022. if (unlistenHistory) {
  1023. unlistenHistory();
  1024. }
  1025. if (removePageHideEventListener) {
  1026. removePageHideEventListener();
  1027. }
  1028. subscribers.clear();
  1029. pendingNavigationController && pendingNavigationController.abort();
  1030. state.fetchers.forEach((_, key) => deleteFetcher(key));
  1031. state.blockers.forEach((_, key) => deleteBlocker(key));
  1032. }
  1033. function subscribe(fn) {
  1034. subscribers.add(fn);
  1035. return () => subscribers.delete(fn);
  1036. }
  1037. function updateState(newState, opts) {
  1038. if (opts === void 0) {
  1039. opts = {};
  1040. }
  1041. state = _extends({}, state, newState);
  1042. let completedFetchers = [];
  1043. let deletedFetchersKeys = [];
  1044. if (future.v7_fetcherPersist) {
  1045. state.fetchers.forEach((fetcher, key) => {
  1046. if (fetcher.state === "idle") {
  1047. if (deletedFetchers.has(key)) {
  1048. deletedFetchersKeys.push(key);
  1049. } else {
  1050. completedFetchers.push(key);
  1051. }
  1052. }
  1053. });
  1054. }
  1055. [...subscribers].forEach((subscriber) => subscriber(state, {
  1056. deletedFetchers: deletedFetchersKeys,
  1057. unstable_viewTransitionOpts: opts.viewTransitionOpts,
  1058. unstable_flushSync: opts.flushSync === true
  1059. }));
  1060. if (future.v7_fetcherPersist) {
  1061. completedFetchers.forEach((key) => state.fetchers.delete(key));
  1062. deletedFetchersKeys.forEach((key) => deleteFetcher(key));
  1063. }
  1064. }
  1065. function completeNavigation(location, newState, _temp) {
  1066. var _location$state, _location$state2;
  1067. let {
  1068. flushSync
  1069. } = _temp === void 0 ? {} : _temp;
  1070. let isActionReload = state.actionData != null && state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && state.navigation.state === "loading" && ((_location$state = location.state) == null ? void 0 : _location$state._isRedirect) !== true;
  1071. let actionData;
  1072. if (newState.actionData) {
  1073. if (Object.keys(newState.actionData).length > 0) {
  1074. actionData = newState.actionData;
  1075. } else {
  1076. actionData = null;
  1077. }
  1078. } else if (isActionReload) {
  1079. actionData = state.actionData;
  1080. } else {
  1081. actionData = null;
  1082. }
  1083. let loaderData = newState.loaderData ? mergeLoaderData(state.loaderData, newState.loaderData, newState.matches || [], newState.errors) : state.loaderData;
  1084. let blockers = state.blockers;
  1085. if (blockers.size > 0) {
  1086. blockers = new Map(blockers);
  1087. blockers.forEach((_, k) => blockers.set(k, IDLE_BLOCKER));
  1088. }
  1089. let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && ((_location$state2 = location.state) == null ? void 0 : _location$state2._isRedirect) !== true;
  1090. if (inFlightDataRoutes) {
  1091. dataRoutes = inFlightDataRoutes;
  1092. inFlightDataRoutes = void 0;
  1093. }
  1094. if (isUninterruptedRevalidation)
  1095. ;
  1096. else if (pendingAction === Action.Pop)
  1097. ;
  1098. else if (pendingAction === Action.Push) {
  1099. init.history.push(location, location.state);
  1100. } else if (pendingAction === Action.Replace) {
  1101. init.history.replace(location, location.state);
  1102. }
  1103. let viewTransitionOpts;
  1104. if (pendingAction === Action.Pop) {
  1105. let priorPaths = appliedViewTransitions.get(state.location.pathname);
  1106. if (priorPaths && priorPaths.has(location.pathname)) {
  1107. viewTransitionOpts = {
  1108. currentLocation: state.location,
  1109. nextLocation: location
  1110. };
  1111. } else if (appliedViewTransitions.has(location.pathname)) {
  1112. viewTransitionOpts = {
  1113. currentLocation: location,
  1114. nextLocation: state.location
  1115. };
  1116. }
  1117. } else if (pendingViewTransitionEnabled) {
  1118. let toPaths = appliedViewTransitions.get(state.location.pathname);
  1119. if (toPaths) {
  1120. toPaths.add(location.pathname);
  1121. } else {
  1122. toPaths = /* @__PURE__ */ new Set([location.pathname]);
  1123. appliedViewTransitions.set(state.location.pathname, toPaths);
  1124. }
  1125. viewTransitionOpts = {
  1126. currentLocation: state.location,
  1127. nextLocation: location
  1128. };
  1129. }
  1130. updateState(_extends({}, newState, {
  1131. actionData,
  1132. loaderData,
  1133. historyAction: pendingAction,
  1134. location,
  1135. initialized: true,
  1136. navigation: IDLE_NAVIGATION,
  1137. revalidation: "idle",
  1138. restoreScrollPosition: getSavedScrollPosition(location, newState.matches || state.matches),
  1139. preventScrollReset,
  1140. blockers
  1141. }), {
  1142. viewTransitionOpts,
  1143. flushSync: flushSync === true
  1144. });
  1145. pendingAction = Action.Pop;
  1146. pendingPreventScrollReset = false;
  1147. pendingViewTransitionEnabled = false;
  1148. isUninterruptedRevalidation = false;
  1149. isRevalidationRequired = false;
  1150. cancelledDeferredRoutes = [];
  1151. cancelledFetcherLoads = [];
  1152. }
  1153. async function navigate(to, opts) {
  1154. if (typeof to === "number") {
  1155. init.history.go(to);
  1156. return;
  1157. }
  1158. let normalizedPath = normalizeTo(state.location, state.matches, basename, future.v7_prependBasename, to, future.v7_relativeSplatPath, opts == null ? void 0 : opts.fromRouteId, opts == null ? void 0 : opts.relative);
  1159. let {
  1160. path,
  1161. submission,
  1162. error
  1163. } = normalizeNavigateOptions(future.v7_normalizeFormMethod, false, normalizedPath, opts);
  1164. let currentLocation = state.location;
  1165. let nextLocation = createLocation(state.location, path, opts && opts.state);
  1166. nextLocation = _extends({}, nextLocation, init.history.encodeLocation(nextLocation));
  1167. let userReplace = opts && opts.replace != null ? opts.replace : void 0;
  1168. let historyAction = Action.Push;
  1169. if (userReplace === true) {
  1170. historyAction = Action.Replace;
  1171. } else if (userReplace === false)
  1172. ;
  1173. else if (submission != null && isMutationMethod(submission.formMethod) && submission.formAction === state.location.pathname + state.location.search) {
  1174. historyAction = Action.Replace;
  1175. }
  1176. let preventScrollReset = opts && "preventScrollReset" in opts ? opts.preventScrollReset === true : void 0;
  1177. let flushSync = (opts && opts.unstable_flushSync) === true;
  1178. let blockerKey = shouldBlockNavigation({
  1179. currentLocation,
  1180. nextLocation,
  1181. historyAction
  1182. });
  1183. if (blockerKey) {
  1184. updateBlocker(blockerKey, {
  1185. state: "blocked",
  1186. location: nextLocation,
  1187. proceed() {
  1188. updateBlocker(blockerKey, {
  1189. state: "proceeding",
  1190. proceed: void 0,
  1191. reset: void 0,
  1192. location: nextLocation
  1193. });
  1194. navigate(to, opts);
  1195. },
  1196. reset() {
  1197. let blockers = new Map(state.blockers);
  1198. blockers.set(blockerKey, IDLE_BLOCKER);
  1199. updateState({
  1200. blockers
  1201. });
  1202. }
  1203. });
  1204. return;
  1205. }
  1206. return await startNavigation(historyAction, nextLocation, {
  1207. submission,
  1208. // Send through the formData serialization error if we have one so we can
  1209. // render at the right error boundary after we match routes
  1210. pendingError: error,
  1211. preventScrollReset,
  1212. replace: opts && opts.replace,
  1213. enableViewTransition: opts && opts.unstable_viewTransition,
  1214. flushSync
  1215. });
  1216. }
  1217. function revalidate() {
  1218. interruptActiveLoads();
  1219. updateState({
  1220. revalidation: "loading"
  1221. });
  1222. if (state.navigation.state === "submitting") {
  1223. return;
  1224. }
  1225. if (state.navigation.state === "idle") {
  1226. startNavigation(state.historyAction, state.location, {
  1227. startUninterruptedRevalidation: true
  1228. });
  1229. return;
  1230. }
  1231. startNavigation(pendingAction || state.historyAction, state.navigation.location, {
  1232. overrideNavigation: state.navigation
  1233. });
  1234. }
  1235. async function startNavigation(historyAction, location, opts) {
  1236. pendingNavigationController && pendingNavigationController.abort();
  1237. pendingNavigationController = null;
  1238. pendingAction = historyAction;
  1239. isUninterruptedRevalidation = (opts && opts.startUninterruptedRevalidation) === true;
  1240. saveScrollPosition(state.location, state.matches);
  1241. pendingPreventScrollReset = (opts && opts.preventScrollReset) === true;
  1242. pendingViewTransitionEnabled = (opts && opts.enableViewTransition) === true;
  1243. let routesToUse = inFlightDataRoutes || dataRoutes;
  1244. let loadingNavigation = opts && opts.overrideNavigation;
  1245. let matches = matchRoutes(routesToUse, location, basename);
  1246. let flushSync = (opts && opts.flushSync) === true;
  1247. if (!matches) {
  1248. let error = getInternalRouterError(404, {
  1249. pathname: location.pathname
  1250. });
  1251. let {
  1252. matches: notFoundMatches,
  1253. route
  1254. } = getShortCircuitMatches(routesToUse);
  1255. cancelActiveDeferreds();
  1256. completeNavigation(location, {
  1257. matches: notFoundMatches,
  1258. loaderData: {},
  1259. errors: {
  1260. [route.id]: error
  1261. }
  1262. }, {
  1263. flushSync
  1264. });
  1265. return;
  1266. }
  1267. if (state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
  1268. completeNavigation(location, {
  1269. matches
  1270. }, {
  1271. flushSync
  1272. });
  1273. return;
  1274. }
  1275. pendingNavigationController = new AbortController();
  1276. let request = createClientSideRequest(init.history, location, pendingNavigationController.signal, opts && opts.submission);
  1277. let pendingActionData;
  1278. let pendingError;
  1279. if (opts && opts.pendingError) {
  1280. pendingError = {
  1281. [findNearestBoundary(matches).route.id]: opts.pendingError
  1282. };
  1283. } else if (opts && opts.submission && isMutationMethod(opts.submission.formMethod)) {
  1284. let actionOutput = await handleAction(request, location, opts.submission, matches, {
  1285. replace: opts.replace,
  1286. flushSync
  1287. });
  1288. if (actionOutput.shortCircuited) {
  1289. return;
  1290. }
  1291. pendingActionData = actionOutput.pendingActionData;
  1292. pendingError = actionOutput.pendingActionError;
  1293. loadingNavigation = getLoadingNavigation(location, opts.submission);
  1294. flushSync = false;
  1295. request = new Request(request.url, {
  1296. signal: request.signal
  1297. });
  1298. }
  1299. let {
  1300. shortCircuited,
  1301. loaderData,
  1302. errors
  1303. } = await handleLoaders(request, location, matches, loadingNavigation, opts && opts.submission, opts && opts.fetcherSubmission, opts && opts.replace, opts && opts.initialHydration === true, flushSync, pendingActionData, pendingError);
  1304. if (shortCircuited) {
  1305. return;
  1306. }
  1307. pendingNavigationController = null;
  1308. completeNavigation(location, _extends({
  1309. matches
  1310. }, pendingActionData ? {
  1311. actionData: pendingActionData
  1312. } : {}, {
  1313. loaderData,
  1314. errors
  1315. }));
  1316. }
  1317. async function handleAction(request, location, submission, matches, opts) {
  1318. if (opts === void 0) {
  1319. opts = {};
  1320. }
  1321. interruptActiveLoads();
  1322. let navigation = getSubmittingNavigation(location, submission);
  1323. updateState({
  1324. navigation
  1325. }, {
  1326. flushSync: opts.flushSync === true
  1327. });
  1328. let result;
  1329. let actionMatch = getTargetMatch(matches, location);
  1330. if (!actionMatch.route.action && !actionMatch.route.lazy) {
  1331. result = {
  1332. type: ResultType.error,
  1333. error: getInternalRouterError(405, {
  1334. method: request.method,
  1335. pathname: location.pathname,
  1336. routeId: actionMatch.route.id
  1337. })
  1338. };
  1339. } else {
  1340. result = await callLoaderOrAction("action", request, actionMatch, matches, manifest, mapRouteProperties2, basename, future.v7_relativeSplatPath);
  1341. if (request.signal.aborted) {
  1342. return {
  1343. shortCircuited: true
  1344. };
  1345. }
  1346. }
  1347. if (isRedirectResult(result)) {
  1348. let replace;
  1349. if (opts && opts.replace != null) {
  1350. replace = opts.replace;
  1351. } else {
  1352. replace = result.location === state.location.pathname + state.location.search;
  1353. }
  1354. await startRedirectNavigation(state, result, {
  1355. submission,
  1356. replace
  1357. });
  1358. return {
  1359. shortCircuited: true
  1360. };
  1361. }
  1362. if (isErrorResult(result)) {
  1363. let boundaryMatch = findNearestBoundary(matches, actionMatch.route.id);
  1364. if ((opts && opts.replace) !== true) {
  1365. pendingAction = Action.Push;
  1366. }
  1367. return {
  1368. // Send back an empty object we can use to clear out any prior actionData
  1369. pendingActionData: {},
  1370. pendingActionError: {
  1371. [boundaryMatch.route.id]: result.error
  1372. }
  1373. };
  1374. }
  1375. if (isDeferredResult(result)) {
  1376. throw getInternalRouterError(400, {
  1377. type: "defer-action"
  1378. });
  1379. }
  1380. return {
  1381. pendingActionData: {
  1382. [actionMatch.route.id]: result.data
  1383. }
  1384. };
  1385. }
  1386. async function handleLoaders(request, location, matches, overrideNavigation, submission, fetcherSubmission, replace, initialHydration, flushSync, pendingActionData, pendingError) {
  1387. let loadingNavigation = overrideNavigation || getLoadingNavigation(location, submission);
  1388. let activeSubmission = submission || fetcherSubmission || getSubmissionFromNavigation(loadingNavigation);
  1389. let routesToUse = inFlightDataRoutes || dataRoutes;
  1390. let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(init.history, state, matches, activeSubmission, location, future.v7_partialHydration && initialHydration === true, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, deletedFetchers, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionData, pendingError);
  1391. cancelActiveDeferreds((routeId) => !(matches && matches.some((m) => m.route.id === routeId)) || matchesToLoad && matchesToLoad.some((m) => m.route.id === routeId));
  1392. pendingNavigationLoadId = ++incrementingLoadId;
  1393. if (matchesToLoad.length === 0 && revalidatingFetchers.length === 0) {
  1394. let updatedFetchers2 = markFetchRedirectsDone();
  1395. completeNavigation(location, _extends({
  1396. matches,
  1397. loaderData: {},
  1398. // Commit pending error if we're short circuiting
  1399. errors: pendingError || null
  1400. }, pendingActionData ? {
  1401. actionData: pendingActionData
  1402. } : {}, updatedFetchers2 ? {
  1403. fetchers: new Map(state.fetchers)
  1404. } : {}), {
  1405. flushSync
  1406. });
  1407. return {
  1408. shortCircuited: true
  1409. };
  1410. }
  1411. if (!isUninterruptedRevalidation && (!future.v7_partialHydration || !initialHydration)) {
  1412. revalidatingFetchers.forEach((rf) => {
  1413. let fetcher = state.fetchers.get(rf.key);
  1414. let revalidatingFetcher = getLoadingFetcher(void 0, fetcher ? fetcher.data : void 0);
  1415. state.fetchers.set(rf.key, revalidatingFetcher);
  1416. });
  1417. let actionData = pendingActionData || state.actionData;
  1418. updateState(_extends({
  1419. navigation: loadingNavigation
  1420. }, actionData ? Object.keys(actionData).length === 0 ? {
  1421. actionData: null
  1422. } : {
  1423. actionData
  1424. } : {}, revalidatingFetchers.length > 0 ? {
  1425. fetchers: new Map(state.fetchers)
  1426. } : {}), {
  1427. flushSync
  1428. });
  1429. }
  1430. revalidatingFetchers.forEach((rf) => {
  1431. if (fetchControllers.has(rf.key)) {
  1432. abortFetcher(rf.key);
  1433. }
  1434. if (rf.controller) {
  1435. fetchControllers.set(rf.key, rf.controller);
  1436. }
  1437. });
  1438. let abortPendingFetchRevalidations = () => revalidatingFetchers.forEach((f) => abortFetcher(f.key));
  1439. if (pendingNavigationController) {
  1440. pendingNavigationController.signal.addEventListener("abort", abortPendingFetchRevalidations);
  1441. }
  1442. let {
  1443. results,
  1444. loaderResults,
  1445. fetcherResults
  1446. } = await callLoadersAndMaybeResolveData(state.matches, matches, matchesToLoad, revalidatingFetchers, request);
  1447. if (request.signal.aborted) {
  1448. return {
  1449. shortCircuited: true
  1450. };
  1451. }
  1452. if (pendingNavigationController) {
  1453. pendingNavigationController.signal.removeEventListener("abort", abortPendingFetchRevalidations);
  1454. }
  1455. revalidatingFetchers.forEach((rf) => fetchControllers.delete(rf.key));
  1456. let redirect4 = findRedirect(results);
  1457. if (redirect4) {
  1458. if (redirect4.idx >= matchesToLoad.length) {
  1459. let fetcherKey = revalidatingFetchers[redirect4.idx - matchesToLoad.length].key;
  1460. fetchRedirectIds.add(fetcherKey);
  1461. }
  1462. await startRedirectNavigation(state, redirect4.result, {
  1463. replace
  1464. });
  1465. return {
  1466. shortCircuited: true
  1467. };
  1468. }
  1469. let {
  1470. loaderData,
  1471. errors
  1472. } = processLoaderData(state, matches, matchesToLoad, loaderResults, pendingError, revalidatingFetchers, fetcherResults, activeDeferreds);
  1473. activeDeferreds.forEach((deferredData, routeId) => {
  1474. deferredData.subscribe((aborted) => {
  1475. if (aborted || deferredData.done) {
  1476. activeDeferreds.delete(routeId);
  1477. }
  1478. });
  1479. });
  1480. let updatedFetchers = markFetchRedirectsDone();
  1481. let didAbortFetchLoads = abortStaleFetchLoads(pendingNavigationLoadId);
  1482. let shouldUpdateFetchers = updatedFetchers || didAbortFetchLoads || revalidatingFetchers.length > 0;
  1483. return _extends({
  1484. loaderData,
  1485. errors
  1486. }, shouldUpdateFetchers ? {
  1487. fetchers: new Map(state.fetchers)
  1488. } : {});
  1489. }
  1490. function fetch2(key, routeId, href, opts) {
  1491. if (isServer) {
  1492. throw new Error("router.fetch() was called during the server render, but it shouldn't be. You are likely calling a useFetcher() method in the body of your component. Try moving it to a useEffect or a callback.");
  1493. }
  1494. if (fetchControllers.has(key))
  1495. abortFetcher(key);
  1496. let flushSync = (opts && opts.unstable_flushSync) === true;
  1497. let routesToUse = inFlightDataRoutes || dataRoutes;
  1498. let normalizedPath = normalizeTo(state.location, state.matches, basename, future.v7_prependBasename, href, future.v7_relativeSplatPath, routeId, opts == null ? void 0 : opts.relative);
  1499. let matches = matchRoutes(routesToUse, normalizedPath, basename);
  1500. if (!matches) {
  1501. setFetcherError(key, routeId, getInternalRouterError(404, {
  1502. pathname: normalizedPath
  1503. }), {
  1504. flushSync
  1505. });
  1506. return;
  1507. }
  1508. let {
  1509. path,
  1510. submission,
  1511. error
  1512. } = normalizeNavigateOptions(future.v7_normalizeFormMethod, true, normalizedPath, opts);
  1513. if (error) {
  1514. setFetcherError(key, routeId, error, {
  1515. flushSync
  1516. });
  1517. return;
  1518. }
  1519. let match = getTargetMatch(matches, path);
  1520. pendingPreventScrollReset = (opts && opts.preventScrollReset) === true;
  1521. if (submission && isMutationMethod(submission.formMethod)) {
  1522. handleFetcherAction(key, routeId, path, match, matches, flushSync, submission);
  1523. return;
  1524. }
  1525. fetchLoadMatches.set(key, {
  1526. routeId,
  1527. path
  1528. });
  1529. handleFetcherLoader(key, routeId, path, match, matches, flushSync, submission);
  1530. }
  1531. async function handleFetcherAction(key, routeId, path, match, requestMatches, flushSync, submission) {
  1532. interruptActiveLoads();
  1533. fetchLoadMatches.delete(key);
  1534. if (!match.route.action && !match.route.lazy) {
  1535. let error = getInternalRouterError(405, {
  1536. method: submission.formMethod,
  1537. pathname: path,
  1538. routeId
  1539. });
  1540. setFetcherError(key, routeId, error, {
  1541. flushSync
  1542. });
  1543. return;
  1544. }
  1545. let existingFetcher = state.fetchers.get(key);
  1546. updateFetcherState(key, getSubmittingFetcher(submission, existingFetcher), {
  1547. flushSync
  1548. });
  1549. let abortController = new AbortController();
  1550. let fetchRequest = createClientSideRequest(init.history, path, abortController.signal, submission);
  1551. fetchControllers.set(key, abortController);
  1552. let originatingLoadId = incrementingLoadId;
  1553. let actionResult = await callLoaderOrAction("action", fetchRequest, match, requestMatches, manifest, mapRouteProperties2, basename, future.v7_relativeSplatPath);
  1554. if (fetchRequest.signal.aborted) {
  1555. if (fetchControllers.get(key) === abortController) {
  1556. fetchControllers.delete(key);
  1557. }
  1558. return;
  1559. }
  1560. if (future.v7_fetcherPersist && deletedFetchers.has(key)) {
  1561. if (isRedirectResult(actionResult) || isErrorResult(actionResult)) {
  1562. updateFetcherState(key, getDoneFetcher(void 0));
  1563. return;
  1564. }
  1565. } else {
  1566. if (isRedirectResult(actionResult)) {
  1567. fetchControllers.delete(key);
  1568. if (pendingNavigationLoadId > originatingLoadId) {
  1569. updateFetcherState(key, getDoneFetcher(void 0));
  1570. return;
  1571. } else {
  1572. fetchRedirectIds.add(key);
  1573. updateFetcherState(key, getLoadingFetcher(submission));
  1574. return startRedirectNavigation(state, actionResult, {
  1575. fetcherSubmission: submission
  1576. });
  1577. }
  1578. }
  1579. if (isErrorResult(actionResult)) {
  1580. setFetcherError(key, routeId, actionResult.error);
  1581. return;
  1582. }
  1583. }
  1584. if (isDeferredResult(actionResult)) {
  1585. throw getInternalRouterError(400, {
  1586. type: "defer-action"
  1587. });
  1588. }
  1589. let nextLocation = state.navigation.location || state.location;
  1590. let revalidationRequest = createClientSideRequest(init.history, nextLocation, abortController.signal);
  1591. let routesToUse = inFlightDataRoutes || dataRoutes;
  1592. let matches = state.navigation.state !== "idle" ? matchRoutes(routesToUse, state.navigation.location, basename) : state.matches;
  1593. invariant(matches, "Didn't find any matches after fetcher action");
  1594. let loadId = ++incrementingLoadId;
  1595. fetchReloadIds.set(key, loadId);
  1596. let loadFetcher = getLoadingFetcher(submission, actionResult.data);
  1597. state.fetchers.set(key, loadFetcher);
  1598. let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(
  1599. init.history,
  1600. state,
  1601. matches,
  1602. submission,
  1603. nextLocation,
  1604. false,
  1605. isRevalidationRequired,
  1606. cancelledDeferredRoutes,
  1607. cancelledFetcherLoads,
  1608. deletedFetchers,
  1609. fetchLoadMatches,
  1610. fetchRedirectIds,
  1611. routesToUse,
  1612. basename,
  1613. {
  1614. [match.route.id]: actionResult.data
  1615. },
  1616. void 0
  1617. // No need to send through errors since we short circuit above
  1618. );
  1619. revalidatingFetchers.filter((rf) => rf.key !== key).forEach((rf) => {
  1620. let staleKey = rf.key;
  1621. let existingFetcher2 = state.fetchers.get(staleKey);
  1622. let revalidatingFetcher = getLoadingFetcher(void 0, existingFetcher2 ? existingFetcher2.data : void 0);
  1623. state.fetchers.set(staleKey, revalidatingFetcher);
  1624. if (fetchControllers.has(staleKey)) {
  1625. abortFetcher(staleKey);
  1626. }
  1627. if (rf.controller) {
  1628. fetchControllers.set(staleKey, rf.controller);
  1629. }
  1630. });
  1631. updateState({
  1632. fetchers: new Map(state.fetchers)
  1633. });
  1634. let abortPendingFetchRevalidations = () => revalidatingFetchers.forEach((rf) => abortFetcher(rf.key));
  1635. abortController.signal.addEventListener("abort", abortPendingFetchRevalidations);
  1636. let {
  1637. results,
  1638. loaderResults,
  1639. fetcherResults
  1640. } = await callLoadersAndMaybeResolveData(state.matches, matches, matchesToLoad, revalidatingFetchers, revalidationRequest);
  1641. if (abortController.signal.aborted) {
  1642. return;
  1643. }
  1644. abortController.signal.removeEventListener("abort", abortPendingFetchRevalidations);
  1645. fetchReloadIds.delete(key);
  1646. fetchControllers.delete(key);
  1647. revalidatingFetchers.forEach((r) => fetchControllers.delete(r.key));
  1648. let redirect4 = findRedirect(results);
  1649. if (redirect4) {
  1650. if (redirect4.idx >= matchesToLoad.length) {
  1651. let fetcherKey = revalidatingFetchers[redirect4.idx - matchesToLoad.length].key;
  1652. fetchRedirectIds.add(fetcherKey);
  1653. }
  1654. return startRedirectNavigation(state, redirect4.result);
  1655. }
  1656. let {
  1657. loaderData,
  1658. errors
  1659. } = processLoaderData(state, state.matches, matchesToLoad, loaderResults, void 0, revalidatingFetchers, fetcherResults, activeDeferreds);
  1660. if (state.fetchers.has(key)) {
  1661. let doneFetcher = getDoneFetcher(actionResult.data);
  1662. state.fetchers.set(key, doneFetcher);
  1663. }
  1664. abortStaleFetchLoads(loadId);
  1665. if (state.navigation.state === "loading" && loadId > pendingNavigationLoadId) {
  1666. invariant(pendingAction, "Expected pending action");
  1667. pendingNavigationController && pendingNavigationController.abort();
  1668. completeNavigation(state.navigation.location, {
  1669. matches,
  1670. loaderData,
  1671. errors,
  1672. fetchers: new Map(state.fetchers)
  1673. });
  1674. } else {
  1675. updateState({
  1676. errors,
  1677. loaderData: mergeLoaderData(state.loaderData, loaderData, matches, errors),
  1678. fetchers: new Map(state.fetchers)
  1679. });
  1680. isRevalidationRequired = false;
  1681. }
  1682. }
  1683. async function handleFetcherLoader(key, routeId, path, match, matches, flushSync, submission) {
  1684. let existingFetcher = state.fetchers.get(key);
  1685. updateFetcherState(key, getLoadingFetcher(submission, existingFetcher ? existingFetcher.data : void 0), {
  1686. flushSync
  1687. });
  1688. let abortController = new AbortController();
  1689. let fetchRequest = createClientSideRequest(init.history, path, abortController.signal);
  1690. fetchControllers.set(key, abortController);
  1691. let originatingLoadId = incrementingLoadId;
  1692. let result = await callLoaderOrAction("loader", fetchRequest, match, matches, manifest, mapRouteProperties2, basename, future.v7_relativeSplatPath);
  1693. if (isDeferredResult(result)) {
  1694. result = await resolveDeferredData(result, fetchRequest.signal, true) || result;
  1695. }
  1696. if (fetchControllers.get(key) === abortController) {
  1697. fetchControllers.delete(key);
  1698. }
  1699. if (fetchRequest.signal.aborted) {
  1700. return;
  1701. }
  1702. if (deletedFetchers.has(key)) {
  1703. updateFetcherState(key, getDoneFetcher(void 0));
  1704. return;
  1705. }
  1706. if (isRedirectResult(result)) {
  1707. if (pendingNavigationLoadId > originatingLoadId) {
  1708. updateFetcherState(key, getDoneFetcher(void 0));
  1709. return;
  1710. } else {
  1711. fetchRedirectIds.add(key);
  1712. await startRedirectNavigation(state, result);
  1713. return;
  1714. }
  1715. }
  1716. if (isErrorResult(result)) {
  1717. setFetcherError(key, routeId, result.error);
  1718. return;
  1719. }
  1720. invariant(!isDeferredResult(result), "Unhandled fetcher deferred data");
  1721. updateFetcherState(key, getDoneFetcher(result.data));
  1722. }
  1723. async function startRedirectNavigation(state2, redirect4, _temp2) {
  1724. let {
  1725. submission,
  1726. fetcherSubmission,
  1727. replace
  1728. } = _temp2 === void 0 ? {} : _temp2;
  1729. if (redirect4.revalidate) {
  1730. isRevalidationRequired = true;
  1731. }
  1732. let redirectLocation = createLocation(state2.location, redirect4.location, {
  1733. _isRedirect: true
  1734. });
  1735. invariant(redirectLocation, "Expected a location on the redirect navigation");
  1736. if (isBrowser2) {
  1737. let isDocumentReload = false;
  1738. if (redirect4.reloadDocument) {
  1739. isDocumentReload = true;
  1740. } else if (ABSOLUTE_URL_REGEX.test(redirect4.location)) {
  1741. const url = init.history.createURL(redirect4.location);
  1742. isDocumentReload = // Hard reload if it's an absolute URL to a new origin
  1743. url.origin !== routerWindow.location.origin || // Hard reload if it's an absolute URL that does not match our basename
  1744. stripBasename(url.pathname, basename) == null;
  1745. }
  1746. if (isDocumentReload) {
  1747. if (replace) {
  1748. routerWindow.location.replace(redirect4.location);
  1749. } else {
  1750. routerWindow.location.assign(redirect4.location);
  1751. }
  1752. return;
  1753. }
  1754. }
  1755. pendingNavigationController = null;
  1756. let redirectHistoryAction = replace === true ? Action.Replace : Action.Push;
  1757. let {
  1758. formMethod,
  1759. formAction,
  1760. formEncType
  1761. } = state2.navigation;
  1762. if (!submission && !fetcherSubmission && formMethod && formAction && formEncType) {
  1763. submission = getSubmissionFromNavigation(state2.navigation);
  1764. }
  1765. let activeSubmission = submission || fetcherSubmission;
  1766. if (redirectPreserveMethodStatusCodes.has(redirect4.status) && activeSubmission && isMutationMethod(activeSubmission.formMethod)) {
  1767. await startNavigation(redirectHistoryAction, redirectLocation, {
  1768. submission: _extends({}, activeSubmission, {
  1769. formAction: redirect4.location
  1770. }),
  1771. // Preserve this flag across redirects
  1772. preventScrollReset: pendingPreventScrollReset
  1773. });
  1774. } else {
  1775. let overrideNavigation = getLoadingNavigation(redirectLocation, submission);
  1776. await startNavigation(redirectHistoryAction, redirectLocation, {
  1777. overrideNavigation,
  1778. // Send fetcher submissions through for shouldRevalidate
  1779. fetcherSubmission,
  1780. // Preserve this flag across redirects
  1781. preventScrollReset: pendingPreventScrollReset
  1782. });
  1783. }
  1784. }
  1785. async function callLoadersAndMaybeResolveData(currentMatches, matches, matchesToLoad, fetchersToLoad, request) {
  1786. let results = await Promise.all([...matchesToLoad.map((match) => callLoaderOrAction("loader", request, match, matches, manifest, mapRouteProperties2, basename, future.v7_relativeSplatPath)), ...fetchersToLoad.map((f) => {
  1787. if (f.matches && f.match && f.controller) {
  1788. return callLoaderOrAction("loader", createClientSideRequest(init.history, f.path, f.controller.signal), f.match, f.matches, manifest, mapRouteProperties2, basename, future.v7_relativeSplatPath);
  1789. } else {
  1790. let error = {
  1791. type: ResultType.error,
  1792. error: getInternalRouterError(404, {
  1793. pathname: f.path
  1794. })
  1795. };
  1796. return error;
  1797. }
  1798. })]);
  1799. let loaderResults = results.slice(0, matchesToLoad.length);
  1800. let fetcherResults = results.slice(matchesToLoad.length);
  1801. await Promise.all([resolveDeferredResults(currentMatches, matchesToLoad, loaderResults, loaderResults.map(() => request.signal), false, state.loaderData), resolveDeferredResults(currentMatches, fetchersToLoad.map((f) => f.match), fetcherResults, fetchersToLoad.map((f) => f.controller ? f.controller.signal : null), true)]);
  1802. return {
  1803. results,
  1804. loaderResults,
  1805. fetcherResults
  1806. };
  1807. }
  1808. function interruptActiveLoads() {
  1809. isRevalidationRequired = true;
  1810. cancelledDeferredRoutes.push(...cancelActiveDeferreds());
  1811. fetchLoadMatches.forEach((_, key) => {
  1812. if (fetchControllers.has(key)) {
  1813. cancelledFetcherLoads.push(key);
  1814. abortFetcher(key);
  1815. }
  1816. });
  1817. }
  1818. function updateFetcherState(key, fetcher, opts) {
  1819. if (opts === void 0) {
  1820. opts = {};
  1821. }
  1822. state.fetchers.set(key, fetcher);
  1823. updateState({
  1824. fetchers: new Map(state.fetchers)
  1825. }, {
  1826. flushSync: (opts && opts.flushSync) === true
  1827. });
  1828. }
  1829. function setFetcherError(key, routeId, error, opts) {
  1830. if (opts === void 0) {
  1831. opts = {};
  1832. }
  1833. let boundaryMatch = findNearestBoundary(state.matches, routeId);
  1834. deleteFetcher(key);
  1835. updateState({
  1836. errors: {
  1837. [boundaryMatch.route.id]: error
  1838. },
  1839. fetchers: new Map(state.fetchers)
  1840. }, {
  1841. flushSync: (opts && opts.flushSync) === true
  1842. });
  1843. }
  1844. function getFetcher(key) {
  1845. if (future.v7_fetcherPersist) {
  1846. activeFetchers.set(key, (activeFetchers.get(key) || 0) + 1);
  1847. if (deletedFetchers.has(key)) {
  1848. deletedFetchers.delete(key);
  1849. }
  1850. }
  1851. return state.fetchers.get(key) || IDLE_FETCHER;
  1852. }
  1853. function deleteFetcher(key) {
  1854. let fetcher = state.fetchers.get(key);
  1855. if (fetchControllers.has(key) && !(fetcher && fetcher.state === "loading" && fetchReloadIds.has(key))) {
  1856. abortFetcher(key);
  1857. }
  1858. fetchLoadMatches.delete(key);
  1859. fetchReloadIds.delete(key);
  1860. fetchRedirectIds.delete(key);
  1861. deletedFetchers.delete(key);
  1862. state.fetchers.delete(key);
  1863. }
  1864. function deleteFetcherAndUpdateState(key) {
  1865. if (future.v7_fetcherPersist) {
  1866. let count = (activeFetchers.get(key) || 0) - 1;
  1867. if (count <= 0) {
  1868. activeFetchers.delete(key);
  1869. deletedFetchers.add(key);
  1870. } else {
  1871. activeFetchers.set(key, count);
  1872. }
  1873. } else {
  1874. deleteFetcher(key);
  1875. }
  1876. updateState({
  1877. fetchers: new Map(state.fetchers)
  1878. });
  1879. }
  1880. function abortFetcher(key) {
  1881. let controller = fetchControllers.get(key);
  1882. invariant(controller, "Expected fetch controller: " + key);
  1883. controller.abort();
  1884. fetchControllers.delete(key);
  1885. }
  1886. function markFetchersDone(keys) {
  1887. for (let key of keys) {
  1888. let fetcher = getFetcher(key);
  1889. let doneFetcher = getDoneFetcher(fetcher.data);
  1890. state.fetchers.set(key, doneFetcher);
  1891. }
  1892. }
  1893. function markFetchRedirectsDone() {
  1894. let doneKeys = [];
  1895. let updatedFetchers = false;
  1896. for (let key of fetchRedirectIds) {
  1897. let fetcher = state.fetchers.get(key);
  1898. invariant(fetcher, "Expected fetcher: " + key);
  1899. if (fetcher.state === "loading") {
  1900. fetchRedirectIds.delete(key);
  1901. doneKeys.push(key);
  1902. updatedFetchers = true;
  1903. }
  1904. }
  1905. markFetchersDone(doneKeys);
  1906. return updatedFetchers;
  1907. }
  1908. function abortStaleFetchLoads(landedId) {
  1909. let yeetedKeys = [];
  1910. for (let [key, id] of fetchReloadIds) {
  1911. if (id < landedId) {
  1912. let fetcher = state.fetchers.get(key);
  1913. invariant(fetcher, "Expected fetcher: " + key);
  1914. if (fetcher.state === "loading") {
  1915. abortFetcher(key);
  1916. fetchReloadIds.delete(key);
  1917. yeetedKeys.push(key);
  1918. }
  1919. }
  1920. }
  1921. markFetchersDone(yeetedKeys);
  1922. return yeetedKeys.length > 0;
  1923. }
  1924. function getBlocker(key, fn) {
  1925. let blocker = state.blockers.get(key) || IDLE_BLOCKER;
  1926. if (blockerFunctions.get(key) !== fn) {
  1927. blockerFunctions.set(key, fn);
  1928. }
  1929. return blocker;
  1930. }
  1931. function deleteBlocker(key) {
  1932. state.blockers.delete(key);
  1933. blockerFunctions.delete(key);
  1934. }
  1935. function updateBlocker(key, newBlocker) {
  1936. let blocker = state.blockers.get(key) || IDLE_BLOCKER;
  1937. invariant(blocker.state === "unblocked" && newBlocker.state === "blocked" || blocker.state === "blocked" && newBlocker.state === "blocked" || blocker.state === "blocked" && newBlocker.state === "proceeding" || blocker.state === "blocked" && newBlocker.state === "unblocked" || blocker.state === "proceeding" && newBlocker.state === "unblocked", "Invalid blocker state transition: " + blocker.state + " -> " + newBlocker.state);
  1938. let blockers = new Map(state.blockers);
  1939. blockers.set(key, newBlocker);
  1940. updateState({
  1941. blockers
  1942. });
  1943. }
  1944. function shouldBlockNavigation(_ref2) {
  1945. let {
  1946. currentLocation,
  1947. nextLocation,
  1948. historyAction
  1949. } = _ref2;
  1950. if (blockerFunctions.size === 0) {
  1951. return;
  1952. }
  1953. if (blockerFunctions.size > 1) {
  1954. warning(false, "A router only supports one blocker at a time");
  1955. }
  1956. let entries = Array.from(blockerFunctions.entries());
  1957. let [blockerKey, blockerFunction] = entries[entries.length - 1];
  1958. let blocker = state.blockers.get(blockerKey);
  1959. if (blocker && blocker.state === "proceeding") {
  1960. return;
  1961. }
  1962. if (blockerFunction({
  1963. currentLocation,
  1964. nextLocation,
  1965. historyAction
  1966. })) {
  1967. return blockerKey;
  1968. }
  1969. }
  1970. function cancelActiveDeferreds(predicate) {
  1971. let cancelledRouteIds = [];
  1972. activeDeferreds.forEach((dfd, routeId) => {
  1973. if (!predicate || predicate(routeId)) {
  1974. dfd.cancel();
  1975. cancelledRouteIds.push(routeId);
  1976. activeDeferreds.delete(routeId);
  1977. }
  1978. });
  1979. return cancelledRouteIds;
  1980. }
  1981. function enableScrollRestoration(positions, getPosition, getKey) {
  1982. savedScrollPositions2 = positions;
  1983. getScrollPosition = getPosition;
  1984. getScrollRestorationKey = getKey || null;
  1985. if (!initialScrollRestored && state.navigation === IDLE_NAVIGATION) {
  1986. initialScrollRestored = true;
  1987. let y = getSavedScrollPosition(state.location, state.matches);
  1988. if (y != null) {
  1989. updateState({
  1990. restoreScrollPosition: y
  1991. });
  1992. }
  1993. }
  1994. return () => {
  1995. savedScrollPositions2 = null;
  1996. getScrollPosition = null;
  1997. getScrollRestorationKey = null;
  1998. };
  1999. }
  2000. function getScrollKey(location, matches) {
  2001. if (getScrollRestorationKey) {
  2002. let key = getScrollRestorationKey(location, matches.map((m) => convertRouteMatchToUiMatch(m, state.loaderData)));
  2003. return key || location.key;
  2004. }
  2005. return location.key;
  2006. }
  2007. function saveScrollPosition(location, matches) {
  2008. if (savedScrollPositions2 && getScrollPosition) {
  2009. let key = getScrollKey(location, matches);
  2010. savedScrollPositions2[key] = getScrollPosition();
  2011. }
  2012. }
  2013. function getSavedScrollPosition(location, matches) {
  2014. if (savedScrollPositions2) {
  2015. let key = getScrollKey(location, matches);
  2016. let y = savedScrollPositions2[key];
  2017. if (typeof y === "number") {
  2018. return y;
  2019. }
  2020. }
  2021. return null;
  2022. }
  2023. function _internalSetRoutes(newRoutes) {
  2024. manifest = {};
  2025. inFlightDataRoutes = convertRoutesToDataRoutes(newRoutes, mapRouteProperties2, void 0, manifest);
  2026. }
  2027. router2 = {
  2028. get basename() {
  2029. return basename;
  2030. },
  2031. get future() {
  2032. return future;
  2033. },
  2034. get state() {
  2035. return state;
  2036. },
  2037. get routes() {
  2038. return dataRoutes;
  2039. },
  2040. get window() {
  2041. return routerWindow;
  2042. },
  2043. initialize,
  2044. subscribe,
  2045. enableScrollRestoration,
  2046. navigate,
  2047. fetch: fetch2,
  2048. revalidate,
  2049. // Passthrough to history-aware createHref used by useHref so we get proper
  2050. // hash-aware URLs in DOM paths
  2051. createHref: (to) => init.history.createHref(to),
  2052. encodeLocation: (to) => init.history.encodeLocation(to),
  2053. getFetcher,
  2054. deleteFetcher: deleteFetcherAndUpdateState,
  2055. dispose,
  2056. getBlocker,
  2057. deleteBlocker,
  2058. _internalFetchControllers: fetchControllers,
  2059. _internalActiveDeferreds: activeDeferreds,
  2060. // TODO: Remove setRoutes, it's temporary to avoid dealing with
  2061. // updating the tree while validating the update algorithm.
  2062. _internalSetRoutes
  2063. };
  2064. return router2;
  2065. }
  2066. function createStaticHandler(routes, opts) {
  2067. invariant(routes.length > 0, "You must provide a non-empty routes array to createStaticHandler");
  2068. let manifest = {};
  2069. let basename = (opts ? opts.basename : null) || "/";
  2070. let mapRouteProperties2;
  2071. if (opts != null && opts.mapRouteProperties) {
  2072. mapRouteProperties2 = opts.mapRouteProperties;
  2073. } else if (opts != null && opts.detectErrorBoundary) {
  2074. let detectErrorBoundary = opts.detectErrorBoundary;
  2075. mapRouteProperties2 = (route) => ({
  2076. hasErrorBoundary: detectErrorBoundary(route)
  2077. });
  2078. } else {
  2079. mapRouteProperties2 = defaultMapRouteProperties;
  2080. }
  2081. let future = _extends({
  2082. v7_relativeSplatPath: false,
  2083. v7_throwAbortReason: false
  2084. }, opts ? opts.future : null);
  2085. let dataRoutes = convertRoutesToDataRoutes(routes, mapRouteProperties2, void 0, manifest);
  2086. async function query(request, _temp3) {
  2087. let {
  2088. requestContext
  2089. } = _temp3 === void 0 ? {} : _temp3;
  2090. let url = new URL(request.url);
  2091. let method = request.method;
  2092. let location = createLocation("", createPath(url), null, "default");
  2093. let matches = matchRoutes(dataRoutes, location, basename);
  2094. if (!isValidMethod(method) && method !== "HEAD") {
  2095. let error = getInternalRouterError(405, {
  2096. method
  2097. });
  2098. let {
  2099. matches: methodNotAllowedMatches,
  2100. route
  2101. } = getShortCircuitMatches(dataRoutes);
  2102. return {
  2103. basename,
  2104. location,
  2105. matches: methodNotAllowedMatches,
  2106. loaderData: {},
  2107. actionData: null,
  2108. errors: {
  2109. [route.id]: error
  2110. },
  2111. statusCode: error.status,
  2112. loaderHeaders: {},
  2113. actionHeaders: {},
  2114. activeDeferreds: null
  2115. };
  2116. } else if (!matches) {
  2117. let error = getInternalRouterError(404, {
  2118. pathname: location.pathname
  2119. });
  2120. let {
  2121. matches: notFoundMatches,
  2122. route
  2123. } = getShortCircuitMatches(dataRoutes);
  2124. return {
  2125. basename,
  2126. location,
  2127. matches: notFoundMatches,
  2128. loaderData: {},
  2129. actionData: null,
  2130. errors: {
  2131. [route.id]: error
  2132. },
  2133. statusCode: error.status,
  2134. loaderHeaders: {},
  2135. actionHeaders: {},
  2136. activeDeferreds: null
  2137. };
  2138. }
  2139. let result = await queryImpl(request, location, matches, requestContext);
  2140. if (isResponse(result)) {
  2141. return result;
  2142. }
  2143. return _extends({
  2144. location,
  2145. basename
  2146. }, result);
  2147. }
  2148. async function queryRoute(request, _temp4) {
  2149. let {
  2150. routeId,
  2151. requestContext
  2152. } = _temp4 === void 0 ? {} : _temp4;
  2153. let url = new URL(request.url);
  2154. let method = request.method;
  2155. let location = createLocation("", createPath(url), null, "default");
  2156. let matches = matchRoutes(dataRoutes, location, basename);
  2157. if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") {
  2158. throw getInternalRouterError(405, {
  2159. method
  2160. });
  2161. } else if (!matches) {
  2162. throw getInternalRouterError(404, {
  2163. pathname: location.pathname
  2164. });
  2165. }
  2166. let match = routeId ? matches.find((m) => m.route.id === routeId) : getTargetMatch(matches, location);
  2167. if (routeId && !match) {
  2168. throw getInternalRouterError(403, {
  2169. pathname: location.pathname,
  2170. routeId
  2171. });
  2172. } else if (!match) {
  2173. throw getInternalRouterError(404, {
  2174. pathname: location.pathname
  2175. });
  2176. }
  2177. let result = await queryImpl(request, location, matches, requestContext, match);
  2178. if (isResponse(result)) {
  2179. return result;
  2180. }
  2181. let error = result.errors ? Object.values(result.errors)[0] : void 0;
  2182. if (error !== void 0) {
  2183. throw error;
  2184. }
  2185. if (result.actionData) {
  2186. return Object.values(result.actionData)[0];
  2187. }
  2188. if (result.loaderData) {
  2189. var _result$activeDeferre;
  2190. let data = Object.values(result.loaderData)[0];
  2191. if ((_result$activeDeferre = result.activeDeferreds) != null && _result$activeDeferre[match.route.id]) {
  2192. data[UNSAFE_DEFERRED_SYMBOL] = result.activeDeferreds[match.route.id];
  2193. }
  2194. return data;
  2195. }
  2196. return void 0;
  2197. }
  2198. async function queryImpl(request, location, matches, requestContext, routeMatch) {
  2199. invariant(request.signal, "query()/queryRoute() requests must contain an AbortController signal");
  2200. try {
  2201. if (isMutationMethod(request.method.toLowerCase())) {
  2202. let result2 = await submit(request, matches, routeMatch || getTargetMatch(matches, location), requestContext, routeMatch != null);
  2203. return result2;
  2204. }
  2205. let result = await loadRouteData(request, matches, requestContext, routeMatch);
  2206. return isResponse(result) ? result : _extends({}, result, {
  2207. actionData: null,
  2208. actionHeaders: {}
  2209. });
  2210. } catch (e) {
  2211. if (isQueryRouteResponse(e)) {
  2212. if (e.type === ResultType.error) {
  2213. throw e.response;
  2214. }
  2215. return e.response;
  2216. }
  2217. if (isRedirectResponse(e)) {
  2218. return e;
  2219. }
  2220. throw e;
  2221. }
  2222. }
  2223. async function submit(request, matches, actionMatch, requestContext, isRouteRequest) {
  2224. let result;
  2225. if (!actionMatch.route.action && !actionMatch.route.lazy) {
  2226. let error = getInternalRouterError(405, {
  2227. method: request.method,
  2228. pathname: new URL(request.url).pathname,
  2229. routeId: actionMatch.route.id
  2230. });
  2231. if (isRouteRequest) {
  2232. throw error;
  2233. }
  2234. result = {
  2235. type: ResultType.error,
  2236. error
  2237. };
  2238. } else {
  2239. result = await callLoaderOrAction("action", request, actionMatch, matches, manifest, mapRouteProperties2, basename, future.v7_relativeSplatPath, {
  2240. isStaticRequest: true,
  2241. isRouteRequest,
  2242. requestContext
  2243. });
  2244. if (request.signal.aborted) {
  2245. throwStaticHandlerAbortedError(request, isRouteRequest, future);
  2246. }
  2247. }
  2248. if (isRedirectResult(result)) {
  2249. throw new Response(null, {
  2250. status: result.status,
  2251. headers: {
  2252. Location: result.location
  2253. }
  2254. });
  2255. }
  2256. if (isDeferredResult(result)) {
  2257. let error = getInternalRouterError(400, {
  2258. type: "defer-action"
  2259. });
  2260. if (isRouteRequest) {
  2261. throw error;
  2262. }
  2263. result = {
  2264. type: ResultType.error,
  2265. error
  2266. };
  2267. }
  2268. if (isRouteRequest) {
  2269. if (isErrorResult(result)) {
  2270. throw result.error;
  2271. }
  2272. return {
  2273. matches: [actionMatch],
  2274. loaderData: {},
  2275. actionData: {
  2276. [actionMatch.route.id]: result.data
  2277. },
  2278. errors: null,
  2279. // Note: statusCode + headers are unused here since queryRoute will
  2280. // return the raw Response or value
  2281. statusCode: 200,
  2282. loaderHeaders: {},
  2283. actionHeaders: {},
  2284. activeDeferreds: null
  2285. };
  2286. }
  2287. if (isErrorResult(result)) {
  2288. let boundaryMatch = findNearestBoundary(matches, actionMatch.route.id);
  2289. let context2 = await loadRouteData(request, matches, requestContext, void 0, {
  2290. [boundaryMatch.route.id]: result.error
  2291. });
  2292. return _extends({}, context2, {
  2293. statusCode: isRouteErrorResponse(result.error) ? result.error.status : 500,
  2294. actionData: null,
  2295. actionHeaders: _extends({}, result.headers ? {
  2296. [actionMatch.route.id]: result.headers
  2297. } : {})
  2298. });
  2299. }
  2300. let loaderRequest = new Request(request.url, {
  2301. headers: request.headers,
  2302. redirect: request.redirect,
  2303. signal: request.signal
  2304. });
  2305. let context = await loadRouteData(loaderRequest, matches, requestContext);
  2306. return _extends({}, context, result.statusCode ? {
  2307. statusCode: result.statusCode
  2308. } : {}, {
  2309. actionData: {
  2310. [actionMatch.route.id]: result.data
  2311. },
  2312. actionHeaders: _extends({}, result.headers ? {
  2313. [actionMatch.route.id]: result.headers
  2314. } : {})
  2315. });
  2316. }
  2317. async function loadRouteData(request, matches, requestContext, routeMatch, pendingActionError) {
  2318. let isRouteRequest = routeMatch != null;
  2319. if (isRouteRequest && !(routeMatch != null && routeMatch.route.loader) && !(routeMatch != null && routeMatch.route.lazy)) {
  2320. throw getInternalRouterError(400, {
  2321. method: request.method,
  2322. pathname: new URL(request.url).pathname,
  2323. routeId: routeMatch == null ? void 0 : routeMatch.route.id
  2324. });
  2325. }
  2326. let requestMatches = routeMatch ? [routeMatch] : getLoaderMatchesUntilBoundary(matches, Object.keys(pendingActionError || {})[0]);
  2327. let matchesToLoad = requestMatches.filter((m) => m.route.loader || m.route.lazy);
  2328. if (matchesToLoad.length === 0) {
  2329. return {
  2330. matches,
  2331. // Add a null for all matched routes for proper revalidation on the client
  2332. loaderData: matches.reduce((acc, m) => Object.assign(acc, {
  2333. [m.route.id]: null
  2334. }), {}),
  2335. errors: pendingActionError || null,
  2336. statusCode: 200,
  2337. loaderHeaders: {},
  2338. activeDeferreds: null
  2339. };
  2340. }
  2341. let results = await Promise.all([...matchesToLoad.map((match) => callLoaderOrAction("loader", request, match, matches, manifest, mapRouteProperties2, basename, future.v7_relativeSplatPath, {
  2342. isStaticRequest: true,
  2343. isRouteRequest,
  2344. requestContext
  2345. }))]);
  2346. if (request.signal.aborted) {
  2347. throwStaticHandlerAbortedError(request, isRouteRequest, future);
  2348. }
  2349. let activeDeferreds = /* @__PURE__ */ new Map();
  2350. let context = processRouteLoaderData(matches, matchesToLoad, results, pendingActionError, activeDeferreds);
  2351. let executedLoaders = new Set(matchesToLoad.map((match) => match.route.id));
  2352. matches.forEach((match) => {
  2353. if (!executedLoaders.has(match.route.id)) {
  2354. context.loaderData[match.route.id] = null;
  2355. }
  2356. });
  2357. return _extends({}, context, {
  2358. matches,
  2359. activeDeferreds: activeDeferreds.size > 0 ? Object.fromEntries(activeDeferreds.entries()) : null
  2360. });
  2361. }
  2362. return {
  2363. dataRoutes,
  2364. query,
  2365. queryRoute
  2366. };
  2367. }
  2368. function getStaticContextFromError(routes, context, error) {
  2369. let newContext = _extends({}, context, {
  2370. statusCode: isRouteErrorResponse(error) ? error.status : 500,
  2371. errors: {
  2372. [context._deepestRenderedBoundaryId || routes[0].id]: error
  2373. }
  2374. });
  2375. return newContext;
  2376. }
  2377. function throwStaticHandlerAbortedError(request, isRouteRequest, future) {
  2378. if (future.v7_throwAbortReason && request.signal.reason !== void 0) {
  2379. throw request.signal.reason;
  2380. }
  2381. let method = isRouteRequest ? "queryRoute" : "query";
  2382. throw new Error(method + "() call aborted: " + request.method + " " + request.url);
  2383. }
  2384. function isSubmissionNavigation(opts) {
  2385. return opts != null && ("formData" in opts && opts.formData != null || "body" in opts && opts.body !== void 0);
  2386. }
  2387. function normalizeTo(location, matches, basename, prependBasename, to, v7_relativeSplatPath, fromRouteId, relative) {
  2388. let contextualMatches;
  2389. let activeRouteMatch;
  2390. if (fromRouteId) {
  2391. contextualMatches = [];
  2392. for (let match of matches) {
  2393. contextualMatches.push(match);
  2394. if (match.route.id === fromRouteId) {
  2395. activeRouteMatch = match;
  2396. break;
  2397. }
  2398. }
  2399. } else {
  2400. contextualMatches = matches;
  2401. activeRouteMatch = matches[matches.length - 1];
  2402. }
  2403. let path = resolveTo(to ? to : ".", getResolveToMatches(contextualMatches, v7_relativeSplatPath), stripBasename(location.pathname, basename) || location.pathname, relative === "path");
  2404. if (to == null) {
  2405. path.search = location.search;
  2406. path.hash = location.hash;
  2407. }
  2408. if ((to == null || to === "" || to === ".") && activeRouteMatch && activeRouteMatch.route.index && !hasNakedIndexQuery(path.search)) {
  2409. path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
  2410. }
  2411. if (prependBasename && basename !== "/") {
  2412. path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
  2413. }
  2414. return createPath(path);
  2415. }
  2416. function normalizeNavigateOptions(normalizeFormMethod, isFetcher, path, opts) {
  2417. if (!opts || !isSubmissionNavigation(opts)) {
  2418. return {
  2419. path
  2420. };
  2421. }
  2422. if (opts.formMethod && !isValidMethod(opts.formMethod)) {
  2423. return {
  2424. path,
  2425. error: getInternalRouterError(405, {
  2426. method: opts.formMethod
  2427. })
  2428. };
  2429. }
  2430. let getInvalidBodyError = () => ({
  2431. path,
  2432. error: getInternalRouterError(400, {
  2433. type: "invalid-body"
  2434. })
  2435. });
  2436. let rawFormMethod = opts.formMethod || "get";
  2437. let formMethod = normalizeFormMethod ? rawFormMethod.toUpperCase() : rawFormMethod.toLowerCase();
  2438. let formAction = stripHashFromPath(path);
  2439. if (opts.body !== void 0) {
  2440. if (opts.formEncType === "text/plain") {
  2441. if (!isMutationMethod(formMethod)) {
  2442. return getInvalidBodyError();
  2443. }
  2444. let text = typeof opts.body === "string" ? opts.body : opts.body instanceof FormData || opts.body instanceof URLSearchParams ? (
  2445. // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#plain-text-form-data
  2446. Array.from(opts.body.entries()).reduce((acc, _ref3) => {
  2447. let [name, value] = _ref3;
  2448. return "" + acc + name + "=" + value + "\n";
  2449. }, "")
  2450. ) : String(opts.body);
  2451. return {
  2452. path,
  2453. submission: {
  2454. formMethod,
  2455. formAction,
  2456. formEncType: opts.formEncType,
  2457. formData: void 0,
  2458. json: void 0,
  2459. text
  2460. }
  2461. };
  2462. } else if (opts.formEncType === "application/json") {
  2463. if (!isMutationMethod(formMethod)) {
  2464. return getInvalidBodyError();
  2465. }
  2466. try {
  2467. let json4 = typeof opts.body === "string" ? JSON.parse(opts.body) : opts.body;
  2468. return {
  2469. path,
  2470. submission: {
  2471. formMethod,
  2472. formAction,
  2473. formEncType: opts.formEncType,
  2474. formData: void 0,
  2475. json: json4,
  2476. text: void 0
  2477. }
  2478. };
  2479. } catch (e) {
  2480. return getInvalidBodyError();
  2481. }
  2482. }
  2483. }
  2484. invariant(typeof FormData === "function", "FormData is not available in this environment");
  2485. let searchParams;
  2486. let formData;
  2487. if (opts.formData) {
  2488. searchParams = convertFormDataToSearchParams(opts.formData);
  2489. formData = opts.formData;
  2490. } else if (opts.body instanceof FormData) {
  2491. searchParams = convertFormDataToSearchParams(opts.body);
  2492. formData = opts.body;
  2493. } else if (opts.body instanceof URLSearchParams) {
  2494. searchParams = opts.body;
  2495. formData = convertSearchParamsToFormData(searchParams);
  2496. } else if (opts.body == null) {
  2497. searchParams = new URLSearchParams();
  2498. formData = new FormData();
  2499. } else {
  2500. try {
  2501. searchParams = new URLSearchParams(opts.body);
  2502. formData = convertSearchParamsToFormData(searchParams);
  2503. } catch (e) {
  2504. return getInvalidBodyError();
  2505. }
  2506. }
  2507. let submission = {
  2508. formMethod,
  2509. formAction,
  2510. formEncType: opts && opts.formEncType || "application/x-www-form-urlencoded",
  2511. formData,
  2512. json: void 0,
  2513. text: void 0
  2514. };
  2515. if (isMutationMethod(submission.formMethod)) {
  2516. return {
  2517. path,
  2518. submission
  2519. };
  2520. }
  2521. let parsedPath = parsePath(path);
  2522. if (isFetcher && parsedPath.search && hasNakedIndexQuery(parsedPath.search)) {
  2523. searchParams.append("index", "");
  2524. }
  2525. parsedPath.search = "?" + searchParams;
  2526. return {
  2527. path: createPath(parsedPath),
  2528. submission
  2529. };
  2530. }
  2531. function getLoaderMatchesUntilBoundary(matches, boundaryId) {
  2532. let boundaryMatches = matches;
  2533. if (boundaryId) {
  2534. let index = matches.findIndex((m) => m.route.id === boundaryId);
  2535. if (index >= 0) {
  2536. boundaryMatches = matches.slice(0, index);
  2537. }
  2538. }
  2539. return boundaryMatches;
  2540. }
  2541. function getMatchesToLoad(history, state, matches, submission, location, isInitialLoad, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, deletedFetchers, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionData, pendingError) {
  2542. let actionResult = pendingError ? Object.values(pendingError)[0] : pendingActionData ? Object.values(pendingActionData)[0] : void 0;
  2543. let currentUrl = history.createURL(state.location);
  2544. let nextUrl = history.createURL(location);
  2545. let boundaryId = pendingError ? Object.keys(pendingError)[0] : void 0;
  2546. let boundaryMatches = getLoaderMatchesUntilBoundary(matches, boundaryId);
  2547. let navigationMatches = boundaryMatches.filter((match, index) => {
  2548. let {
  2549. route
  2550. } = match;
  2551. if (route.lazy) {
  2552. return true;
  2553. }
  2554. if (route.loader == null) {
  2555. return false;
  2556. }
  2557. if (isInitialLoad) {
  2558. if (route.loader.hydrate) {
  2559. return true;
  2560. }
  2561. return state.loaderData[route.id] === void 0 && // Don't re-run if the loader ran and threw an error
  2562. (!state.errors || state.errors[route.id] === void 0);
  2563. }
  2564. if (isNewLoader(state.loaderData, state.matches[index], match) || cancelledDeferredRoutes.some((id) => id === match.route.id)) {
  2565. return true;
  2566. }
  2567. let currentRouteMatch = state.matches[index];
  2568. let nextRouteMatch = match;
  2569. return shouldRevalidateLoader(match, _extends({
  2570. currentUrl,
  2571. currentParams: currentRouteMatch.params,
  2572. nextUrl,
  2573. nextParams: nextRouteMatch.params
  2574. }, submission, {
  2575. actionResult,
  2576. defaultShouldRevalidate: (
  2577. // Forced revalidation due to submission, useRevalidator, or X-Remix-Revalidate
  2578. isRevalidationRequired || // Clicked the same link, resubmitted a GET form
  2579. currentUrl.pathname + currentUrl.search === nextUrl.pathname + nextUrl.search || // Search params affect all loaders
  2580. currentUrl.search !== nextUrl.search || isNewRouteInstance(currentRouteMatch, nextRouteMatch)
  2581. )
  2582. }));
  2583. });
  2584. let revalidatingFetchers = [];
  2585. fetchLoadMatches.forEach((f, key) => {
  2586. if (isInitialLoad || !matches.some((m) => m.route.id === f.routeId) || deletedFetchers.has(key)) {
  2587. return;
  2588. }
  2589. let fetcherMatches = matchRoutes(routesToUse, f.path, basename);
  2590. if (!fetcherMatches) {
  2591. revalidatingFetchers.push({
  2592. key,
  2593. routeId: f.routeId,
  2594. path: f.path,
  2595. matches: null,
  2596. match: null,
  2597. controller: null
  2598. });
  2599. return;
  2600. }
  2601. let fetcher = state.fetchers.get(key);
  2602. let fetcherMatch = getTargetMatch(fetcherMatches, f.path);
  2603. let shouldRevalidate = false;
  2604. if (fetchRedirectIds.has(key)) {
  2605. shouldRevalidate = false;
  2606. } else if (cancelledFetcherLoads.includes(key)) {
  2607. shouldRevalidate = true;
  2608. } else if (fetcher && fetcher.state !== "idle" && fetcher.data === void 0) {
  2609. shouldRevalidate = isRevalidationRequired;
  2610. } else {
  2611. shouldRevalidate = shouldRevalidateLoader(fetcherMatch, _extends({
  2612. currentUrl,
  2613. currentParams: state.matches[state.matches.length - 1].params,
  2614. nextUrl,
  2615. nextParams: matches[matches.length - 1].params
  2616. }, submission, {
  2617. actionResult,
  2618. defaultShouldRevalidate: isRevalidationRequired
  2619. }));
  2620. }
  2621. if (shouldRevalidate) {
  2622. revalidatingFetchers.push({
  2623. key,
  2624. routeId: f.routeId,
  2625. path: f.path,
  2626. matches: fetcherMatches,
  2627. match: fetcherMatch,
  2628. controller: new AbortController()
  2629. });
  2630. }
  2631. });
  2632. return [navigationMatches, revalidatingFetchers];
  2633. }
  2634. function isNewLoader(currentLoaderData, currentMatch, match) {
  2635. let isNew = (
  2636. // [a] -> [a, b]
  2637. !currentMatch || // [a, b] -> [a, c]
  2638. match.route.id !== currentMatch.route.id
  2639. );
  2640. let isMissingData = currentLoaderData[match.route.id] === void 0;
  2641. return isNew || isMissingData;
  2642. }
  2643. function isNewRouteInstance(currentMatch, match) {
  2644. let currentPath = currentMatch.route.path;
  2645. return (
  2646. // param change for this match, /users/123 -> /users/456
  2647. currentMatch.pathname !== match.pathname || // splat param changed, which is not present in match.path
  2648. // e.g. /files/images/avatar.jpg -> files/finances.xls
  2649. currentPath != null && currentPath.endsWith("*") && currentMatch.params["*"] !== match.params["*"]
  2650. );
  2651. }
  2652. function shouldRevalidateLoader(loaderMatch, arg) {
  2653. if (loaderMatch.route.shouldRevalidate) {
  2654. let routeChoice = loaderMatch.route.shouldRevalidate(arg);
  2655. if (typeof routeChoice === "boolean") {
  2656. return routeChoice;
  2657. }
  2658. }
  2659. return arg.defaultShouldRevalidate;
  2660. }
  2661. async function loadLazyRouteModule(route, mapRouteProperties2, manifest) {
  2662. if (!route.lazy) {
  2663. return;
  2664. }
  2665. let lazyRoute = await route.lazy();
  2666. if (!route.lazy) {
  2667. return;
  2668. }
  2669. let routeToUpdate = manifest[route.id];
  2670. invariant(routeToUpdate, "No route found in manifest");
  2671. let routeUpdates = {};
  2672. for (let lazyRouteProperty in lazyRoute) {
  2673. let staticRouteValue = routeToUpdate[lazyRouteProperty];
  2674. let isPropertyStaticallyDefined = staticRouteValue !== void 0 && // This property isn't static since it should always be updated based
  2675. // on the route updates
  2676. lazyRouteProperty !== "hasErrorBoundary";
  2677. warning(!isPropertyStaticallyDefined, 'Route "' + routeToUpdate.id + '" has a static property "' + lazyRouteProperty + '" defined but its lazy function is also returning a value for this property. ' + ('The lazy route property "' + lazyRouteProperty + '" will be ignored.'));
  2678. if (!isPropertyStaticallyDefined && !immutableRouteKeys.has(lazyRouteProperty)) {
  2679. routeUpdates[lazyRouteProperty] = lazyRoute[lazyRouteProperty];
  2680. }
  2681. }
  2682. Object.assign(routeToUpdate, routeUpdates);
  2683. Object.assign(routeToUpdate, _extends({}, mapRouteProperties2(routeToUpdate), {
  2684. lazy: void 0
  2685. }));
  2686. }
  2687. async function callLoaderOrAction(type, request, match, matches, manifest, mapRouteProperties2, basename, v7_relativeSplatPath, opts) {
  2688. if (opts === void 0) {
  2689. opts = {};
  2690. }
  2691. let resultType;
  2692. let result;
  2693. let onReject;
  2694. let runHandler = (handler) => {
  2695. let reject;
  2696. let abortPromise = new Promise((_, r) => reject = r);
  2697. onReject = () => reject();
  2698. request.signal.addEventListener("abort", onReject);
  2699. return Promise.race([handler({
  2700. request,
  2701. params: match.params,
  2702. context: opts.requestContext
  2703. }), abortPromise]);
  2704. };
  2705. try {
  2706. let handler = match.route[type];
  2707. if (match.route.lazy) {
  2708. if (handler) {
  2709. let handlerError;
  2710. let values = await Promise.all([
  2711. // If the handler throws, don't let it immediately bubble out,
  2712. // since we need to let the lazy() execution finish so we know if this
  2713. // route has a boundary that can handle the error
  2714. runHandler(handler).catch((e) => {
  2715. handlerError = e;
  2716. }),
  2717. loadLazyRouteModule(match.route, mapRouteProperties2, manifest)
  2718. ]);
  2719. if (handlerError) {
  2720. throw handlerError;
  2721. }
  2722. result = values[0];
  2723. } else {
  2724. await loadLazyRouteModule(match.route, mapRouteProperties2, manifest);
  2725. handler = match.route[type];
  2726. if (handler) {
  2727. result = await runHandler(handler);
  2728. } else if (type === "action") {
  2729. let url = new URL(request.url);
  2730. let pathname = url.pathname + url.search;
  2731. throw getInternalRouterError(405, {
  2732. method: request.method,
  2733. pathname,
  2734. routeId: match.route.id
  2735. });
  2736. } else {
  2737. return {
  2738. type: ResultType.data,
  2739. data: void 0
  2740. };
  2741. }
  2742. }
  2743. } else if (!handler) {
  2744. let url = new URL(request.url);
  2745. let pathname = url.pathname + url.search;
  2746. throw getInternalRouterError(404, {
  2747. pathname
  2748. });
  2749. } else {
  2750. result = await runHandler(handler);
  2751. }
  2752. invariant(result !== void 0, "You defined " + (type === "action" ? "an action" : "a loader") + " for route " + ('"' + match.route.id + "\" but didn't return anything from your `" + type + "` ") + "function. Please return a value or `null`.");
  2753. } catch (e) {
  2754. resultType = ResultType.error;
  2755. result = e;
  2756. } finally {
  2757. if (onReject) {
  2758. request.signal.removeEventListener("abort", onReject);
  2759. }
  2760. }
  2761. if (isResponse(result)) {
  2762. let status = result.status;
  2763. if (redirectStatusCodes.has(status)) {
  2764. let location = result.headers.get("Location");
  2765. invariant(location, "Redirects returned/thrown from loaders/actions must have a Location header");
  2766. if (!ABSOLUTE_URL_REGEX.test(location)) {
  2767. location = normalizeTo(new URL(request.url), matches.slice(0, matches.indexOf(match) + 1), basename, true, location, v7_relativeSplatPath);
  2768. } else if (!opts.isStaticRequest) {
  2769. let currentUrl = new URL(request.url);
  2770. let url = location.startsWith("//") ? new URL(currentUrl.protocol + location) : new URL(location);
  2771. let isSameBasename = stripBasename(url.pathname, basename) != null;
  2772. if (url.origin === currentUrl.origin && isSameBasename) {
  2773. location = url.pathname + url.search + url.hash;
  2774. }
  2775. }
  2776. if (opts.isStaticRequest) {
  2777. result.headers.set("Location", location);
  2778. throw result;
  2779. }
  2780. return {
  2781. type: ResultType.redirect,
  2782. status,
  2783. location,
  2784. revalidate: result.headers.get("X-Remix-Revalidate") !== null,
  2785. reloadDocument: result.headers.get("X-Remix-Reload-Document") !== null
  2786. };
  2787. }
  2788. if (opts.isRouteRequest) {
  2789. let queryRouteResponse = {
  2790. type: resultType === ResultType.error ? ResultType.error : ResultType.data,
  2791. response: result
  2792. };
  2793. throw queryRouteResponse;
  2794. }
  2795. let data;
  2796. try {
  2797. let contentType = result.headers.get("Content-Type");
  2798. if (contentType && /\bapplication\/json\b/.test(contentType)) {
  2799. if (result.body == null) {
  2800. data = null;
  2801. } else {
  2802. data = await result.json();
  2803. }
  2804. } else {
  2805. data = await result.text();
  2806. }
  2807. } catch (e) {
  2808. return {
  2809. type: ResultType.error,
  2810. error: e
  2811. };
  2812. }
  2813. if (resultType === ResultType.error) {
  2814. return {
  2815. type: resultType,
  2816. error: new ErrorResponseImpl(status, result.statusText, data),
  2817. headers: result.headers
  2818. };
  2819. }
  2820. return {
  2821. type: ResultType.data,
  2822. data,
  2823. statusCode: result.status,
  2824. headers: result.headers
  2825. };
  2826. }
  2827. if (resultType === ResultType.error) {
  2828. return {
  2829. type: resultType,
  2830. error: result
  2831. };
  2832. }
  2833. if (isDeferredData(result)) {
  2834. var _result$init, _result$init2;
  2835. return {
  2836. type: ResultType.deferred,
  2837. deferredData: result,
  2838. statusCode: (_result$init = result.init) == null ? void 0 : _result$init.status,
  2839. headers: ((_result$init2 = result.init) == null ? void 0 : _result$init2.headers) && new Headers(result.init.headers)
  2840. };
  2841. }
  2842. return {
  2843. type: ResultType.data,
  2844. data: result
  2845. };
  2846. }
  2847. function createClientSideRequest(history, location, signal, submission) {
  2848. let url = history.createURL(stripHashFromPath(location)).toString();
  2849. let init = {
  2850. signal
  2851. };
  2852. if (submission && isMutationMethod(submission.formMethod)) {
  2853. let {
  2854. formMethod,
  2855. formEncType
  2856. } = submission;
  2857. init.method = formMethod.toUpperCase();
  2858. if (formEncType === "application/json") {
  2859. init.headers = new Headers({
  2860. "Content-Type": formEncType
  2861. });
  2862. init.body = JSON.stringify(submission.json);
  2863. } else if (formEncType === "text/plain") {
  2864. init.body = submission.text;
  2865. } else if (formEncType === "application/x-www-form-urlencoded" && submission.formData) {
  2866. init.body = convertFormDataToSearchParams(submission.formData);
  2867. } else {
  2868. init.body = submission.formData;
  2869. }
  2870. }
  2871. return new Request(url, init);
  2872. }
  2873. function convertFormDataToSearchParams(formData) {
  2874. let searchParams = new URLSearchParams();
  2875. for (let [key, value] of formData.entries()) {
  2876. searchParams.append(key, typeof value === "string" ? value : value.name);
  2877. }
  2878. return searchParams;
  2879. }
  2880. function convertSearchParamsToFormData(searchParams) {
  2881. let formData = new FormData();
  2882. for (let [key, value] of searchParams.entries()) {
  2883. formData.append(key, value);
  2884. }
  2885. return formData;
  2886. }
  2887. function processRouteLoaderData(matches, matchesToLoad, results, pendingError, activeDeferreds) {
  2888. let loaderData = {};
  2889. let errors = null;
  2890. let statusCode;
  2891. let foundError = false;
  2892. let loaderHeaders = {};
  2893. results.forEach((result, index) => {
  2894. let id = matchesToLoad[index].route.id;
  2895. invariant(!isRedirectResult(result), "Cannot handle redirect results in processLoaderData");
  2896. if (isErrorResult(result)) {
  2897. let boundaryMatch = findNearestBoundary(matches, id);
  2898. let error = result.error;
  2899. if (pendingError) {
  2900. error = Object.values(pendingError)[0];
  2901. pendingError = void 0;
  2902. }
  2903. errors = errors || {};
  2904. if (errors[boundaryMatch.route.id] == null) {
  2905. errors[boundaryMatch.route.id] = error;
  2906. }
  2907. loaderData[id] = void 0;
  2908. if (!foundError) {
  2909. foundError = true;
  2910. statusCode = isRouteErrorResponse(result.error) ? result.error.status : 500;
  2911. }
  2912. if (result.headers) {
  2913. loaderHeaders[id] = result.headers;
  2914. }
  2915. } else {
  2916. if (isDeferredResult(result)) {
  2917. activeDeferreds.set(id, result.deferredData);
  2918. loaderData[id] = result.deferredData.data;
  2919. } else {
  2920. loaderData[id] = result.data;
  2921. }
  2922. if (result.statusCode != null && result.statusCode !== 200 && !foundError) {
  2923. statusCode = result.statusCode;
  2924. }
  2925. if (result.headers) {
  2926. loaderHeaders[id] = result.headers;
  2927. }
  2928. }
  2929. });
  2930. if (pendingError) {
  2931. errors = pendingError;
  2932. loaderData[Object.keys(pendingError)[0]] = void 0;
  2933. }
  2934. return {
  2935. loaderData,
  2936. errors,
  2937. statusCode: statusCode || 200,
  2938. loaderHeaders
  2939. };
  2940. }
  2941. function processLoaderData(state, matches, matchesToLoad, results, pendingError, revalidatingFetchers, fetcherResults, activeDeferreds) {
  2942. let {
  2943. loaderData,
  2944. errors
  2945. } = processRouteLoaderData(matches, matchesToLoad, results, pendingError, activeDeferreds);
  2946. for (let index = 0; index < revalidatingFetchers.length; index++) {
  2947. let {
  2948. key,
  2949. match,
  2950. controller
  2951. } = revalidatingFetchers[index];
  2952. invariant(fetcherResults !== void 0 && fetcherResults[index] !== void 0, "Did not find corresponding fetcher result");
  2953. let result = fetcherResults[index];
  2954. if (controller && controller.signal.aborted) {
  2955. continue;
  2956. } else if (isErrorResult(result)) {
  2957. let boundaryMatch = findNearestBoundary(state.matches, match == null ? void 0 : match.route.id);
  2958. if (!(errors && errors[boundaryMatch.route.id])) {
  2959. errors = _extends({}, errors, {
  2960. [boundaryMatch.route.id]: result.error
  2961. });
  2962. }
  2963. state.fetchers.delete(key);
  2964. } else if (isRedirectResult(result)) {
  2965. invariant(false, "Unhandled fetcher revalidation redirect");
  2966. } else if (isDeferredResult(result)) {
  2967. invariant(false, "Unhandled fetcher deferred data");
  2968. } else {
  2969. let doneFetcher = getDoneFetcher(result.data);
  2970. state.fetchers.set(key, doneFetcher);
  2971. }
  2972. }
  2973. return {
  2974. loaderData,
  2975. errors
  2976. };
  2977. }
  2978. function mergeLoaderData(loaderData, newLoaderData, matches, errors) {
  2979. let mergedLoaderData = _extends({}, newLoaderData);
  2980. for (let match of matches) {
  2981. let id = match.route.id;
  2982. if (newLoaderData.hasOwnProperty(id)) {
  2983. if (newLoaderData[id] !== void 0) {
  2984. mergedLoaderData[id] = newLoaderData[id];
  2985. }
  2986. } else if (loaderData[id] !== void 0 && match.route.loader) {
  2987. mergedLoaderData[id] = loaderData[id];
  2988. }
  2989. if (errors && errors.hasOwnProperty(id)) {
  2990. break;
  2991. }
  2992. }
  2993. return mergedLoaderData;
  2994. }
  2995. function findNearestBoundary(matches, routeId) {
  2996. let eligibleMatches = routeId ? matches.slice(0, matches.findIndex((m) => m.route.id === routeId) + 1) : [...matches];
  2997. return eligibleMatches.reverse().find((m) => m.route.hasErrorBoundary === true) || matches[0];
  2998. }
  2999. function getShortCircuitMatches(routes) {
  3000. let route = routes.length === 1 ? routes[0] : routes.find((r) => r.index || !r.path || r.path === "/") || {
  3001. id: "__shim-error-route__"
  3002. };
  3003. return {
  3004. matches: [{
  3005. params: {},
  3006. pathname: "",
  3007. pathnameBase: "",
  3008. route
  3009. }],
  3010. route
  3011. };
  3012. }
  3013. function getInternalRouterError(status, _temp5) {
  3014. let {
  3015. pathname,
  3016. routeId,
  3017. method,
  3018. type
  3019. } = _temp5 === void 0 ? {} : _temp5;
  3020. let statusText = "Unknown Server Error";
  3021. let errorMessage = "Unknown @remix-run/router error";
  3022. if (status === 400) {
  3023. statusText = "Bad Request";
  3024. if (method && pathname && routeId) {
  3025. errorMessage = "You made a " + method + ' request to "' + pathname + '" but ' + ('did not provide a `loader` for route "' + routeId + '", ') + "so there is no way to handle the request.";
  3026. } else if (type === "defer-action") {
  3027. errorMessage = "defer() is not supported in actions";
  3028. } else if (type === "invalid-body") {
  3029. errorMessage = "Unable to encode submission body";
  3030. }
  3031. } else if (status === 403) {
  3032. statusText = "Forbidden";
  3033. errorMessage = 'Route "' + routeId + '" does not match URL "' + pathname + '"';
  3034. } else if (status === 404) {
  3035. statusText = "Not Found";
  3036. errorMessage = 'No route matches URL "' + pathname + '"';
  3037. } else if (status === 405) {
  3038. statusText = "Method Not Allowed";
  3039. if (method && pathname && routeId) {
  3040. errorMessage = "You made a " + method.toUpperCase() + ' request to "' + pathname + '" but ' + ('did not provide an `action` for route "' + routeId + '", ') + "so there is no way to handle the request.";
  3041. } else if (method) {
  3042. errorMessage = 'Invalid request method "' + method.toUpperCase() + '"';
  3043. }
  3044. }
  3045. return new ErrorResponseImpl(status || 500, statusText, new Error(errorMessage), true);
  3046. }
  3047. function findRedirect(results) {
  3048. for (let i = results.length - 1; i >= 0; i--) {
  3049. let result = results[i];
  3050. if (isRedirectResult(result)) {
  3051. return {
  3052. result,
  3053. idx: i
  3054. };
  3055. }
  3056. }
  3057. }
  3058. function stripHashFromPath(path) {
  3059. let parsedPath = typeof path === "string" ? parsePath(path) : path;
  3060. return createPath(_extends({}, parsedPath, {
  3061. hash: ""
  3062. }));
  3063. }
  3064. function isHashChangeOnly(a, b) {
  3065. if (a.pathname !== b.pathname || a.search !== b.search) {
  3066. return false;
  3067. }
  3068. if (a.hash === "") {
  3069. return b.hash !== "";
  3070. } else if (a.hash === b.hash) {
  3071. return true;
  3072. } else if (b.hash !== "") {
  3073. return true;
  3074. }
  3075. return false;
  3076. }
  3077. function isDeferredResult(result) {
  3078. return result.type === ResultType.deferred;
  3079. }
  3080. function isErrorResult(result) {
  3081. return result.type === ResultType.error;
  3082. }
  3083. function isRedirectResult(result) {
  3084. return (result && result.type) === ResultType.redirect;
  3085. }
  3086. function isDeferredData(value) {
  3087. let deferred = value;
  3088. return deferred && typeof deferred === "object" && typeof deferred.data === "object" && typeof deferred.subscribe === "function" && typeof deferred.cancel === "function" && typeof deferred.resolveData === "function";
  3089. }
  3090. function isResponse(value) {
  3091. return value != null && typeof value.status === "number" && typeof value.statusText === "string" && typeof value.headers === "object" && typeof value.body !== "undefined";
  3092. }
  3093. function isRedirectResponse(result) {
  3094. if (!isResponse(result)) {
  3095. return false;
  3096. }
  3097. let status = result.status;
  3098. let location = result.headers.get("Location");
  3099. return status >= 300 && status <= 399 && location != null;
  3100. }
  3101. function isQueryRouteResponse(obj) {
  3102. return obj && isResponse(obj.response) && (obj.type === ResultType.data || obj.type === ResultType.error);
  3103. }
  3104. function isValidMethod(method) {
  3105. return validRequestMethods.has(method.toLowerCase());
  3106. }
  3107. function isMutationMethod(method) {
  3108. return validMutationMethods.has(method.toLowerCase());
  3109. }
  3110. async function resolveDeferredResults(currentMatches, matchesToLoad, results, signals, isFetcher, currentLoaderData) {
  3111. for (let index = 0; index < results.length; index++) {
  3112. let result = results[index];
  3113. let match = matchesToLoad[index];
  3114. if (!match) {
  3115. continue;
  3116. }
  3117. let currentMatch = currentMatches.find((m) => m.route.id === match.route.id);
  3118. let isRevalidatingLoader = currentMatch != null && !isNewRouteInstance(currentMatch, match) && (currentLoaderData && currentLoaderData[match.route.id]) !== void 0;
  3119. if (isDeferredResult(result) && (isFetcher || isRevalidatingLoader)) {
  3120. let signal = signals[index];
  3121. invariant(signal, "Expected an AbortSignal for revalidating fetcher deferred result");
  3122. await resolveDeferredData(result, signal, isFetcher).then((result2) => {
  3123. if (result2) {
  3124. results[index] = result2 || results[index];
  3125. }
  3126. });
  3127. }
  3128. }
  3129. }
  3130. async function resolveDeferredData(result, signal, unwrap) {
  3131. if (unwrap === void 0) {
  3132. unwrap = false;
  3133. }
  3134. let aborted = await result.deferredData.resolveData(signal);
  3135. if (aborted) {
  3136. return;
  3137. }
  3138. if (unwrap) {
  3139. try {
  3140. return {
  3141. type: ResultType.data,
  3142. data: result.deferredData.unwrappedData
  3143. };
  3144. } catch (e) {
  3145. return {
  3146. type: ResultType.error,
  3147. error: e
  3148. };
  3149. }
  3150. }
  3151. return {
  3152. type: ResultType.data,
  3153. data: result.deferredData.data
  3154. };
  3155. }
  3156. function hasNakedIndexQuery(search) {
  3157. return new URLSearchParams(search).getAll("index").some((v) => v === "");
  3158. }
  3159. function getTargetMatch(matches, location) {
  3160. let search = typeof location === "string" ? parsePath(location).search : location.search;
  3161. if (matches[matches.length - 1].route.index && hasNakedIndexQuery(search || "")) {
  3162. return matches[matches.length - 1];
  3163. }
  3164. let pathMatches = getPathContributingMatches(matches);
  3165. return pathMatches[pathMatches.length - 1];
  3166. }
  3167. function getSubmissionFromNavigation(navigation) {
  3168. let {
  3169. formMethod,
  3170. formAction,
  3171. formEncType,
  3172. text,
  3173. formData,
  3174. json: json4
  3175. } = navigation;
  3176. if (!formMethod || !formAction || !formEncType) {
  3177. return;
  3178. }
  3179. if (text != null) {
  3180. return {
  3181. formMethod,
  3182. formAction,
  3183. formEncType,
  3184. formData: void 0,
  3185. json: void 0,
  3186. text
  3187. };
  3188. } else if (formData != null) {
  3189. return {
  3190. formMethod,
  3191. formAction,
  3192. formEncType,
  3193. formData,
  3194. json: void 0,
  3195. text: void 0
  3196. };
  3197. } else if (json4 !== void 0) {
  3198. return {
  3199. formMethod,
  3200. formAction,
  3201. formEncType,
  3202. formData: void 0,
  3203. json: json4,
  3204. text: void 0
  3205. };
  3206. }
  3207. }
  3208. function getLoadingNavigation(location, submission) {
  3209. if (submission) {
  3210. let navigation = {
  3211. state: "loading",
  3212. location,
  3213. formMethod: submission.formMethod,
  3214. formAction: submission.formAction,
  3215. formEncType: submission.formEncType,
  3216. formData: submission.formData,
  3217. json: submission.json,
  3218. text: submission.text
  3219. };
  3220. return navigation;
  3221. } else {
  3222. let navigation = {
  3223. state: "loading",
  3224. location,
  3225. formMethod: void 0,
  3226. formAction: void 0,
  3227. formEncType: void 0,
  3228. formData: void 0,
  3229. json: void 0,
  3230. text: void 0
  3231. };
  3232. return navigation;
  3233. }
  3234. }
  3235. function getSubmittingNavigation(location, submission) {
  3236. let navigation = {
  3237. state: "submitting",
  3238. location,
  3239. formMethod: submission.formMethod,
  3240. formAction: submission.formAction,
  3241. formEncType: submission.formEncType,
  3242. formData: submission.formData,
  3243. json: submission.json,
  3244. text: submission.text
  3245. };
  3246. return navigation;
  3247. }
  3248. function getLoadingFetcher(submission, data) {
  3249. if (submission) {
  3250. let fetcher = {
  3251. state: "loading",
  3252. formMethod: submission.formMethod,
  3253. formAction: submission.formAction,
  3254. formEncType: submission.formEncType,
  3255. formData: submission.formData,
  3256. json: submission.json,
  3257. text: submission.text,
  3258. data
  3259. };
  3260. return fetcher;
  3261. } else {
  3262. let fetcher = {
  3263. state: "loading",
  3264. formMethod: void 0,
  3265. formAction: void 0,
  3266. formEncType: void 0,
  3267. formData: void 0,
  3268. json: void 0,
  3269. text: void 0,
  3270. data
  3271. };
  3272. return fetcher;
  3273. }
  3274. }
  3275. function getSubmittingFetcher(submission, existingFetcher) {
  3276. let fetcher = {
  3277. state: "submitting",
  3278. formMethod: submission.formMethod,
  3279. formAction: submission.formAction,
  3280. formEncType: submission.formEncType,
  3281. formData: submission.formData,
  3282. json: submission.json,
  3283. text: submission.text,
  3284. data: existingFetcher ? existingFetcher.data : void 0
  3285. };
  3286. return fetcher;
  3287. }
  3288. function getDoneFetcher(data) {
  3289. let fetcher = {
  3290. state: "idle",
  3291. formMethod: void 0,
  3292. formAction: void 0,
  3293. formEncType: void 0,
  3294. formData: void 0,
  3295. json: void 0,
  3296. text: void 0,
  3297. data
  3298. };
  3299. return fetcher;
  3300. }
  3301. function restoreAppliedTransitions(_window, transitions) {
  3302. try {
  3303. let sessionPositions = _window.sessionStorage.getItem(TRANSITIONS_STORAGE_KEY);
  3304. if (sessionPositions) {
  3305. let json4 = JSON.parse(sessionPositions);
  3306. for (let [k, v] of Object.entries(json4 || {})) {
  3307. if (v && Array.isArray(v)) {
  3308. transitions.set(k, new Set(v || []));
  3309. }
  3310. }
  3311. }
  3312. } catch (e) {
  3313. }
  3314. }
  3315. function persistAppliedTransitions(_window, transitions) {
  3316. if (transitions.size > 0) {
  3317. let json4 = {};
  3318. for (let [k, v] of transitions) {
  3319. json4[k] = [...v];
  3320. }
  3321. try {
  3322. _window.sessionStorage.setItem(TRANSITIONS_STORAGE_KEY, JSON.stringify(json4));
  3323. } catch (error) {
  3324. warning(false, "Failed to save applied view transitions in sessionStorage (" + error + ").");
  3325. }
  3326. }
  3327. }
  3328. var Action, PopStateEventType, ResultType, immutableRouteKeys, paramRe, dynamicSegmentValue, indexRouteValue, emptySegmentValue, staticSegmentValue, splatPenalty, isSplat, joinPaths, normalizePathname, normalizeSearch, normalizeHash, json, AbortedDeferredError, DeferredData, defer, redirect, redirectDocument, ErrorResponseImpl, validMutationMethodsArr, validMutationMethods, validRequestMethodsArr, validRequestMethods, redirectStatusCodes, redirectPreserveMethodStatusCodes, IDLE_NAVIGATION, IDLE_FETCHER, IDLE_BLOCKER, ABSOLUTE_URL_REGEX, defaultMapRouteProperties, TRANSITIONS_STORAGE_KEY, UNSAFE_DEFERRED_SYMBOL;
  3329. var init_router = __esm({
  3330. "node_modules/@remix-run/router/dist/router.js"() {
  3331. (function(Action2) {
  3332. Action2["Pop"] = "POP";
  3333. Action2["Push"] = "PUSH";
  3334. Action2["Replace"] = "REPLACE";
  3335. })(Action || (Action = {}));
  3336. PopStateEventType = "popstate";
  3337. (function(ResultType2) {
  3338. ResultType2["data"] = "data";
  3339. ResultType2["deferred"] = "deferred";
  3340. ResultType2["redirect"] = "redirect";
  3341. ResultType2["error"] = "error";
  3342. })(ResultType || (ResultType = {}));
  3343. immutableRouteKeys = /* @__PURE__ */ new Set(["lazy", "caseSensitive", "path", "id", "index", "children"]);
  3344. paramRe = /^:[\w-]+$/;
  3345. dynamicSegmentValue = 3;
  3346. indexRouteValue = 2;
  3347. emptySegmentValue = 1;
  3348. staticSegmentValue = 10;
  3349. splatPenalty = -2;
  3350. isSplat = (s) => s === "*";
  3351. joinPaths = (paths) => paths.join("/").replace(/\/\/+/g, "/");
  3352. normalizePathname = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
  3353. normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
  3354. normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
  3355. json = function json2(data, init) {
  3356. if (init === void 0) {
  3357. init = {};
  3358. }
  3359. let responseInit = typeof init === "number" ? {
  3360. status: init
  3361. } : init;
  3362. let headers = new Headers(responseInit.headers);
  3363. if (!headers.has("Content-Type")) {
  3364. headers.set("Content-Type", "application/json; charset=utf-8");
  3365. }
  3366. return new Response(JSON.stringify(data), _extends({}, responseInit, {
  3367. headers
  3368. }));
  3369. };
  3370. AbortedDeferredError = class extends Error {
  3371. };
  3372. DeferredData = class {
  3373. constructor(data, responseInit) {
  3374. this.pendingKeysSet = /* @__PURE__ */ new Set();
  3375. this.subscribers = /* @__PURE__ */ new Set();
  3376. this.deferredKeys = [];
  3377. invariant(data && typeof data === "object" && !Array.isArray(data), "defer() only accepts plain objects");
  3378. let reject;
  3379. this.abortPromise = new Promise((_, r) => reject = r);
  3380. this.controller = new AbortController();
  3381. let onAbort = () => reject(new AbortedDeferredError("Deferred data aborted"));
  3382. this.unlistenAbortSignal = () => this.controller.signal.removeEventListener("abort", onAbort);
  3383. this.controller.signal.addEventListener("abort", onAbort);
  3384. this.data = Object.entries(data).reduce((acc, _ref2) => {
  3385. let [key, value] = _ref2;
  3386. return Object.assign(acc, {
  3387. [key]: this.trackPromise(key, value)
  3388. });
  3389. }, {});
  3390. if (this.done) {
  3391. this.unlistenAbortSignal();
  3392. }
  3393. this.init = responseInit;
  3394. }
  3395. trackPromise(key, value) {
  3396. if (!(value instanceof Promise)) {
  3397. return value;
  3398. }
  3399. this.deferredKeys.push(key);
  3400. this.pendingKeysSet.add(key);
  3401. let promise = Promise.race([value, this.abortPromise]).then((data) => this.onSettle(promise, key, void 0, data), (error) => this.onSettle(promise, key, error));
  3402. promise.catch(() => {
  3403. });
  3404. Object.defineProperty(promise, "_tracked", {
  3405. get: () => true
  3406. });
  3407. return promise;
  3408. }
  3409. onSettle(promise, key, error, data) {
  3410. if (this.controller.signal.aborted && error instanceof AbortedDeferredError) {
  3411. this.unlistenAbortSignal();
  3412. Object.defineProperty(promise, "_error", {
  3413. get: () => error
  3414. });
  3415. return Promise.reject(error);
  3416. }
  3417. this.pendingKeysSet.delete(key);
  3418. if (this.done) {
  3419. this.unlistenAbortSignal();
  3420. }
  3421. if (error === void 0 && data === void 0) {
  3422. let undefinedError = new Error('Deferred data for key "' + key + '" resolved/rejected with `undefined`, you must resolve/reject with a value or `null`.');
  3423. Object.defineProperty(promise, "_error", {
  3424. get: () => undefinedError
  3425. });
  3426. this.emit(false, key);
  3427. return Promise.reject(undefinedError);
  3428. }
  3429. if (data === void 0) {
  3430. Object.defineProperty(promise, "_error", {
  3431. get: () => error
  3432. });
  3433. this.emit(false, key);
  3434. return Promise.reject(error);
  3435. }
  3436. Object.defineProperty(promise, "_data", {
  3437. get: () => data
  3438. });
  3439. this.emit(false, key);
  3440. return data;
  3441. }
  3442. emit(aborted, settledKey) {
  3443. this.subscribers.forEach((subscriber) => subscriber(aborted, settledKey));
  3444. }
  3445. subscribe(fn) {
  3446. this.subscribers.add(fn);
  3447. return () => this.subscribers.delete(fn);
  3448. }
  3449. cancel() {
  3450. this.controller.abort();
  3451. this.pendingKeysSet.forEach((v, k) => this.pendingKeysSet.delete(k));
  3452. this.emit(true);
  3453. }
  3454. async resolveData(signal) {
  3455. let aborted = false;
  3456. if (!this.done) {
  3457. let onAbort = () => this.cancel();
  3458. signal.addEventListener("abort", onAbort);
  3459. aborted = await new Promise((resolve) => {
  3460. this.subscribe((aborted2) => {
  3461. signal.removeEventListener("abort", onAbort);
  3462. if (aborted2 || this.done) {
  3463. resolve(aborted2);
  3464. }
  3465. });
  3466. });
  3467. }
  3468. return aborted;
  3469. }
  3470. get done() {
  3471. return this.pendingKeysSet.size === 0;
  3472. }
  3473. get unwrappedData() {
  3474. invariant(this.data !== null && this.done, "Can only unwrap data on initialized and settled deferreds");
  3475. return Object.entries(this.data).reduce((acc, _ref3) => {
  3476. let [key, value] = _ref3;
  3477. return Object.assign(acc, {
  3478. [key]: unwrapTrackedPromise(value)
  3479. });
  3480. }, {});
  3481. }
  3482. get pendingKeys() {
  3483. return Array.from(this.pendingKeysSet);
  3484. }
  3485. };
  3486. defer = function defer2(data, init) {
  3487. if (init === void 0) {
  3488. init = {};
  3489. }
  3490. let responseInit = typeof init === "number" ? {
  3491. status: init
  3492. } : init;
  3493. return new DeferredData(data, responseInit);
  3494. };
  3495. redirect = function redirect2(url, init) {
  3496. if (init === void 0) {
  3497. init = 302;
  3498. }
  3499. let responseInit = init;
  3500. if (typeof responseInit === "number") {
  3501. responseInit = {
  3502. status: responseInit
  3503. };
  3504. } else if (typeof responseInit.status === "undefined") {
  3505. responseInit.status = 302;
  3506. }
  3507. let headers = new Headers(responseInit.headers);
  3508. headers.set("Location", url);
  3509. return new Response(null, _extends({}, responseInit, {
  3510. headers
  3511. }));
  3512. };
  3513. redirectDocument = (url, init) => {
  3514. let response = redirect(url, init);
  3515. response.headers.set("X-Remix-Reload-Document", "true");
  3516. return response;
  3517. };
  3518. ErrorResponseImpl = class {
  3519. constructor(status, statusText, data, internal) {
  3520. if (internal === void 0) {
  3521. internal = false;
  3522. }
  3523. this.status = status;
  3524. this.statusText = statusText || "";
  3525. this.internal = internal;
  3526. if (data instanceof Error) {
  3527. this.data = data.toString();
  3528. this.error = data;
  3529. } else {
  3530. this.data = data;
  3531. }
  3532. }
  3533. };
  3534. validMutationMethodsArr = ["post", "put", "patch", "delete"];
  3535. validMutationMethods = new Set(validMutationMethodsArr);
  3536. validRequestMethodsArr = ["get", ...validMutationMethodsArr];
  3537. validRequestMethods = new Set(validRequestMethodsArr);
  3538. redirectStatusCodes = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
  3539. redirectPreserveMethodStatusCodes = /* @__PURE__ */ new Set([307, 308]);
  3540. IDLE_NAVIGATION = {
  3541. state: "idle",
  3542. location: void 0,
  3543. formMethod: void 0,
  3544. formAction: void 0,
  3545. formEncType: void 0,
  3546. formData: void 0,
  3547. json: void 0,
  3548. text: void 0
  3549. };
  3550. IDLE_FETCHER = {
  3551. state: "idle",
  3552. data: void 0,
  3553. formMethod: void 0,
  3554. formAction: void 0,
  3555. formEncType: void 0,
  3556. formData: void 0,
  3557. json: void 0,
  3558. text: void 0
  3559. };
  3560. IDLE_BLOCKER = {
  3561. state: "unblocked",
  3562. proceed: void 0,
  3563. reset: void 0,
  3564. location: void 0
  3565. };
  3566. ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
  3567. defaultMapRouteProperties = (route) => ({
  3568. hasErrorBoundary: Boolean(route.hasErrorBoundary)
  3569. });
  3570. TRANSITIONS_STORAGE_KEY = "remix-router-transitions";
  3571. UNSAFE_DEFERRED_SYMBOL = Symbol("deferred");
  3572. }
  3573. });
  3574. // node_modules/react-router/dist/index.js
  3575. var dist_exports = {};
  3576. __export(dist_exports, {
  3577. AbortedDeferredError: () => AbortedDeferredError,
  3578. Await: () => Await,
  3579. MemoryRouter: () => MemoryRouter,
  3580. Navigate: () => Navigate,
  3581. NavigationType: () => Action,
  3582. Outlet: () => Outlet,
  3583. Route: () => Route,
  3584. Router: () => Router,
  3585. RouterProvider: () => RouterProvider,
  3586. Routes: () => Routes,
  3587. UNSAFE_DataRouterContext: () => DataRouterContext,
  3588. UNSAFE_DataRouterStateContext: () => DataRouterStateContext,
  3589. UNSAFE_LocationContext: () => LocationContext,
  3590. UNSAFE_NavigationContext: () => NavigationContext,
  3591. UNSAFE_RouteContext: () => RouteContext,
  3592. UNSAFE_mapRouteProperties: () => mapRouteProperties,
  3593. UNSAFE_useRouteId: () => useRouteId,
  3594. UNSAFE_useRoutesImpl: () => useRoutesImpl,
  3595. createMemoryRouter: () => createMemoryRouter,
  3596. createPath: () => createPath,
  3597. createRoutesFromChildren: () => createRoutesFromChildren,
  3598. createRoutesFromElements: () => createRoutesFromChildren,
  3599. defer: () => defer,
  3600. generatePath: () => generatePath,
  3601. isRouteErrorResponse: () => isRouteErrorResponse,
  3602. json: () => json,
  3603. matchPath: () => matchPath,
  3604. matchRoutes: () => matchRoutes,
  3605. parsePath: () => parsePath,
  3606. redirect: () => redirect,
  3607. redirectDocument: () => redirectDocument,
  3608. renderMatches: () => renderMatches,
  3609. resolvePath: () => resolvePath,
  3610. useActionData: () => useActionData,
  3611. useAsyncError: () => useAsyncError,
  3612. useAsyncValue: () => useAsyncValue,
  3613. useBlocker: () => useBlocker,
  3614. useHref: () => useHref,
  3615. useInRouterContext: () => useInRouterContext,
  3616. useLoaderData: () => useLoaderData,
  3617. useLocation: () => useLocation,
  3618. useMatch: () => useMatch,
  3619. useMatches: () => useMatches,
  3620. useNavigate: () => useNavigate,
  3621. useNavigation: () => useNavigation,
  3622. useNavigationType: () => useNavigationType,
  3623. useOutlet: () => useOutlet,
  3624. useOutletContext: () => useOutletContext,
  3625. useParams: () => useParams,
  3626. useResolvedPath: () => useResolvedPath,
  3627. useRevalidator: () => useRevalidator,
  3628. useRouteError: () => useRouteError,
  3629. useRouteLoaderData: () => useRouteLoaderData,
  3630. useRoutes: () => useRoutes
  3631. });
  3632. function _extends2() {
  3633. _extends2 = Object.assign ? Object.assign.bind() : function(target) {
  3634. for (var i = 1; i < arguments.length; i++) {
  3635. var source = arguments[i];
  3636. for (var key in source) {
  3637. if (Object.prototype.hasOwnProperty.call(source, key)) {
  3638. target[key] = source[key];
  3639. }
  3640. }
  3641. }
  3642. return target;
  3643. };
  3644. return _extends2.apply(this, arguments);
  3645. }
  3646. function useHref(to, _temp) {
  3647. let {
  3648. relative
  3649. } = _temp === void 0 ? {} : _temp;
  3650. !useInRouterContext() ? true ? invariant(
  3651. false,
  3652. // TODO: This error is probably because they somehow have 2 versions of the
  3653. // router loaded. We can help them understand how to avoid that.
  3654. "useHref() may be used only in the context of a <Router> component."
  3655. ) : invariant(false) : void 0;
  3656. let {
  3657. basename,
  3658. navigator
  3659. } = React.useContext(NavigationContext);
  3660. let {
  3661. hash,
  3662. pathname,
  3663. search
  3664. } = useResolvedPath(to, {
  3665. relative
  3666. });
  3667. let joinedPathname = pathname;
  3668. if (basename !== "/") {
  3669. joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
  3670. }
  3671. return navigator.createHref({
  3672. pathname: joinedPathname,
  3673. search,
  3674. hash
  3675. });
  3676. }
  3677. function useInRouterContext() {
  3678. return React.useContext(LocationContext) != null;
  3679. }
  3680. function useLocation() {
  3681. !useInRouterContext() ? true ? invariant(
  3682. false,
  3683. // TODO: This error is probably because they somehow have 2 versions of the
  3684. // router loaded. We can help them understand how to avoid that.
  3685. "useLocation() may be used only in the context of a <Router> component."
  3686. ) : invariant(false) : void 0;
  3687. return React.useContext(LocationContext).location;
  3688. }
  3689. function useNavigationType() {
  3690. return React.useContext(LocationContext).navigationType;
  3691. }
  3692. function useMatch(pattern) {
  3693. !useInRouterContext() ? true ? invariant(
  3694. false,
  3695. // TODO: This error is probably because they somehow have 2 versions of the
  3696. // router loaded. We can help them understand how to avoid that.
  3697. "useMatch() may be used only in the context of a <Router> component."
  3698. ) : invariant(false) : void 0;
  3699. let {
  3700. pathname
  3701. } = useLocation();
  3702. return React.useMemo(() => matchPath(pattern, pathname), [pathname, pattern]);
  3703. }
  3704. function useIsomorphicLayoutEffect(cb) {
  3705. let isStatic = React.useContext(NavigationContext).static;
  3706. if (!isStatic) {
  3707. React.useLayoutEffect(cb);
  3708. }
  3709. }
  3710. function useNavigate() {
  3711. let {
  3712. isDataRoute
  3713. } = React.useContext(RouteContext);
  3714. return isDataRoute ? useNavigateStable() : useNavigateUnstable();
  3715. }
  3716. function useNavigateUnstable() {
  3717. !useInRouterContext() ? true ? invariant(
  3718. false,
  3719. // TODO: This error is probably because they somehow have 2 versions of the
  3720. // router loaded. We can help them understand how to avoid that.
  3721. "useNavigate() may be used only in the context of a <Router> component."
  3722. ) : invariant(false) : void 0;
  3723. let dataRouterContext = React.useContext(DataRouterContext);
  3724. let {
  3725. basename,
  3726. future,
  3727. navigator
  3728. } = React.useContext(NavigationContext);
  3729. let {
  3730. matches
  3731. } = React.useContext(RouteContext);
  3732. let {
  3733. pathname: locationPathname
  3734. } = useLocation();
  3735. let routePathnamesJson = JSON.stringify(getResolveToMatches(matches, future.v7_relativeSplatPath));
  3736. let activeRef = React.useRef(false);
  3737. useIsomorphicLayoutEffect(() => {
  3738. activeRef.current = true;
  3739. });
  3740. let navigate = React.useCallback(function(to, options) {
  3741. if (options === void 0) {
  3742. options = {};
  3743. }
  3744. true ? warning(activeRef.current, navigateEffectWarning) : void 0;
  3745. if (!activeRef.current)
  3746. return;
  3747. if (typeof to === "number") {
  3748. navigator.go(to);
  3749. return;
  3750. }
  3751. let path = resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, options.relative === "path");
  3752. if (dataRouterContext == null && basename !== "/") {
  3753. path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
  3754. }
  3755. (!!options.replace ? navigator.replace : navigator.push)(path, options.state, options);
  3756. }, [basename, navigator, routePathnamesJson, locationPathname, dataRouterContext]);
  3757. return navigate;
  3758. }
  3759. function useOutletContext() {
  3760. return React.useContext(OutletContext);
  3761. }
  3762. function useOutlet(context) {
  3763. let outlet = React.useContext(RouteContext).outlet;
  3764. if (outlet) {
  3765. return /* @__PURE__ */ React.createElement(OutletContext.Provider, {
  3766. value: context
  3767. }, outlet);
  3768. }
  3769. return outlet;
  3770. }
  3771. function useParams() {
  3772. let {
  3773. matches
  3774. } = React.useContext(RouteContext);
  3775. let routeMatch = matches[matches.length - 1];
  3776. return routeMatch ? routeMatch.params : {};
  3777. }
  3778. function useResolvedPath(to, _temp2) {
  3779. let {
  3780. relative
  3781. } = _temp2 === void 0 ? {} : _temp2;
  3782. let {
  3783. future
  3784. } = React.useContext(NavigationContext);
  3785. let {
  3786. matches
  3787. } = React.useContext(RouteContext);
  3788. let {
  3789. pathname: locationPathname
  3790. } = useLocation();
  3791. let routePathnamesJson = JSON.stringify(getResolveToMatches(matches, future.v7_relativeSplatPath));
  3792. return React.useMemo(() => resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, relative === "path"), [to, routePathnamesJson, locationPathname, relative]);
  3793. }
  3794. function useRoutes(routes, locationArg) {
  3795. return useRoutesImpl(routes, locationArg);
  3796. }
  3797. function useRoutesImpl(routes, locationArg, dataRouterState, future) {
  3798. !useInRouterContext() ? true ? invariant(
  3799. false,
  3800. // TODO: This error is probably because they somehow have 2 versions of the
  3801. // router loaded. We can help them understand how to avoid that.
  3802. "useRoutes() may be used only in the context of a <Router> component."
  3803. ) : invariant(false) : void 0;
  3804. let {
  3805. navigator
  3806. } = React.useContext(NavigationContext);
  3807. let {
  3808. matches: parentMatches
  3809. } = React.useContext(RouteContext);
  3810. let routeMatch = parentMatches[parentMatches.length - 1];
  3811. let parentParams = routeMatch ? routeMatch.params : {};
  3812. let parentPathname = routeMatch ? routeMatch.pathname : "/";
  3813. let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
  3814. let parentRoute = routeMatch && routeMatch.route;
  3815. if (true) {
  3816. let parentPath = parentRoute && parentRoute.path || "";
  3817. warningOnce(parentPathname, !parentRoute || parentPath.endsWith("*"), "You rendered descendant <Routes> (or called `useRoutes()`) at " + ('"' + parentPathname + '" (under <Route path="' + parentPath + '">) but the ') + `parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
  3818. ` + ('Please change the parent <Route path="' + parentPath + '"> to <Route ') + ('path="' + (parentPath === "/" ? "*" : parentPath + "/*") + '">.'));
  3819. }
  3820. let locationFromContext = useLocation();
  3821. let location;
  3822. if (locationArg) {
  3823. var _parsedLocationArg$pa;
  3824. let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
  3825. !(parentPathnameBase === "/" || ((_parsedLocationArg$pa = parsedLocationArg.pathname) == null ? void 0 : _parsedLocationArg$pa.startsWith(parentPathnameBase))) ? true ? invariant(false, "When overriding the location using `<Routes location>` or `useRoutes(routes, location)`, the location pathname must begin with the portion of the URL pathname that was " + ('matched by all parent routes. The current pathname base is "' + parentPathnameBase + '" ') + ('but pathname "' + parsedLocationArg.pathname + '" was given in the `location` prop.')) : invariant(false) : void 0;
  3826. location = parsedLocationArg;
  3827. } else {
  3828. location = locationFromContext;
  3829. }
  3830. let pathname = location.pathname || "/";
  3831. let remainingPathname = parentPathnameBase === "/" ? pathname : pathname.slice(parentPathnameBase.length) || "/";
  3832. let matches = matchRoutes(routes, {
  3833. pathname: remainingPathname
  3834. });
  3835. if (true) {
  3836. true ? warning(parentRoute || matches != null, 'No routes matched location "' + location.pathname + location.search + location.hash + '" ') : void 0;
  3837. true ? warning(matches == null || matches[matches.length - 1].route.element !== void 0 || matches[matches.length - 1].route.Component !== void 0 || matches[matches.length - 1].route.lazy !== void 0, 'Matched leaf route at location "' + location.pathname + location.search + location.hash + '" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.') : void 0;
  3838. }
  3839. let renderedMatches = _renderMatches(matches && matches.map((match) => Object.assign({}, match, {
  3840. params: Object.assign({}, parentParams, match.params),
  3841. pathname: joinPaths([
  3842. parentPathnameBase,
  3843. // Re-encode pathnames that were decoded inside matchRoutes
  3844. navigator.encodeLocation ? navigator.encodeLocation(match.pathname).pathname : match.pathname
  3845. ]),
  3846. pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
  3847. parentPathnameBase,
  3848. // Re-encode pathnames that were decoded inside matchRoutes
  3849. navigator.encodeLocation ? navigator.encodeLocation(match.pathnameBase).pathname : match.pathnameBase
  3850. ])
  3851. })), parentMatches, dataRouterState, future);
  3852. if (locationArg && renderedMatches) {
  3853. return /* @__PURE__ */ React.createElement(LocationContext.Provider, {
  3854. value: {
  3855. location: _extends2({
  3856. pathname: "/",
  3857. search: "",
  3858. hash: "",
  3859. state: null,
  3860. key: "default"
  3861. }, location),
  3862. navigationType: Action.Pop
  3863. }
  3864. }, renderedMatches);
  3865. }
  3866. return renderedMatches;
  3867. }
  3868. function DefaultErrorComponent() {
  3869. let error = useRouteError();
  3870. let message = isRouteErrorResponse(error) ? error.status + " " + error.statusText : error instanceof Error ? error.message : JSON.stringify(error);
  3871. let stack = error instanceof Error ? error.stack : null;
  3872. let lightgrey = "rgba(200,200,200, 0.5)";
  3873. let preStyles = {
  3874. padding: "0.5rem",
  3875. backgroundColor: lightgrey
  3876. };
  3877. let codeStyles = {
  3878. padding: "2px 4px",
  3879. backgroundColor: lightgrey
  3880. };
  3881. let devInfo = null;
  3882. if (true) {
  3883. console.error("Error handled by React Router default ErrorBoundary:", error);
  3884. devInfo = /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", null, "\u{1F4BF} Hey developer \u{1F44B}"), /* @__PURE__ */ React.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /* @__PURE__ */ React.createElement("code", {
  3885. style: codeStyles
  3886. }, "ErrorBoundary"), " or", " ", /* @__PURE__ */ React.createElement("code", {
  3887. style: codeStyles
  3888. }, "errorElement"), " prop on your route."));
  3889. }
  3890. return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ React.createElement("h3", {
  3891. style: {
  3892. fontStyle: "italic"
  3893. }
  3894. }, message), stack ? /* @__PURE__ */ React.createElement("pre", {
  3895. style: preStyles
  3896. }, stack) : null, devInfo);
  3897. }
  3898. function RenderedRoute(_ref) {
  3899. let {
  3900. routeContext,
  3901. match,
  3902. children
  3903. } = _ref;
  3904. let dataRouterContext = React.useContext(DataRouterContext);
  3905. if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
  3906. dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
  3907. }
  3908. return /* @__PURE__ */ React.createElement(RouteContext.Provider, {
  3909. value: routeContext
  3910. }, children);
  3911. }
  3912. function _renderMatches(matches, parentMatches, dataRouterState, future) {
  3913. var _dataRouterState2;
  3914. if (parentMatches === void 0) {
  3915. parentMatches = [];
  3916. }
  3917. if (dataRouterState === void 0) {
  3918. dataRouterState = null;
  3919. }
  3920. if (future === void 0) {
  3921. future = null;
  3922. }
  3923. if (matches == null) {
  3924. var _dataRouterState;
  3925. if ((_dataRouterState = dataRouterState) != null && _dataRouterState.errors) {
  3926. matches = dataRouterState.matches;
  3927. } else {
  3928. return null;
  3929. }
  3930. }
  3931. let renderedMatches = matches;
  3932. let errors = (_dataRouterState2 = dataRouterState) == null ? void 0 : _dataRouterState2.errors;
  3933. if (errors != null) {
  3934. let errorIndex = renderedMatches.findIndex((m) => m.route.id && (errors == null ? void 0 : errors[m.route.id]));
  3935. !(errorIndex >= 0) ? true ? invariant(false, "Could not find a matching route for errors on route IDs: " + Object.keys(errors).join(",")) : invariant(false) : void 0;
  3936. renderedMatches = renderedMatches.slice(0, Math.min(renderedMatches.length, errorIndex + 1));
  3937. }
  3938. let renderFallback = false;
  3939. let fallbackIndex = -1;
  3940. if (dataRouterState && future && future.v7_partialHydration) {
  3941. for (let i = 0; i < renderedMatches.length; i++) {
  3942. let match = renderedMatches[i];
  3943. if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
  3944. fallbackIndex = i;
  3945. }
  3946. if (match.route.id) {
  3947. let {
  3948. loaderData,
  3949. errors: errors2
  3950. } = dataRouterState;
  3951. let needsToRunLoader = match.route.loader && loaderData[match.route.id] === void 0 && (!errors2 || errors2[match.route.id] === void 0);
  3952. if (match.route.lazy || needsToRunLoader) {
  3953. renderFallback = true;
  3954. if (fallbackIndex >= 0) {
  3955. renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
  3956. } else {
  3957. renderedMatches = [renderedMatches[0]];
  3958. }
  3959. break;
  3960. }
  3961. }
  3962. }
  3963. }
  3964. return renderedMatches.reduceRight((outlet, match, index) => {
  3965. let error;
  3966. let shouldRenderHydrateFallback = false;
  3967. let errorElement = null;
  3968. let hydrateFallbackElement = null;
  3969. if (dataRouterState) {
  3970. error = errors && match.route.id ? errors[match.route.id] : void 0;
  3971. errorElement = match.route.errorElement || defaultErrorElement;
  3972. if (renderFallback) {
  3973. if (fallbackIndex < 0 && index === 0) {
  3974. warningOnce("route-fallback", false, "No `HydrateFallback` element provided to render during initial hydration");
  3975. shouldRenderHydrateFallback = true;
  3976. hydrateFallbackElement = null;
  3977. } else if (fallbackIndex === index) {
  3978. shouldRenderHydrateFallback = true;
  3979. hydrateFallbackElement = match.route.hydrateFallbackElement || null;
  3980. }
  3981. }
  3982. }
  3983. let matches2 = parentMatches.concat(renderedMatches.slice(0, index + 1));
  3984. let getChildren = () => {
  3985. let children;
  3986. if (error) {
  3987. children = errorElement;
  3988. } else if (shouldRenderHydrateFallback) {
  3989. children = hydrateFallbackElement;
  3990. } else if (match.route.Component) {
  3991. children = /* @__PURE__ */ React.createElement(match.route.Component, null);
  3992. } else if (match.route.element) {
  3993. children = match.route.element;
  3994. } else {
  3995. children = outlet;
  3996. }
  3997. return /* @__PURE__ */ React.createElement(RenderedRoute, {
  3998. match,
  3999. routeContext: {
  4000. outlet,
  4001. matches: matches2,
  4002. isDataRoute: dataRouterState != null
  4003. },
  4004. children
  4005. });
  4006. };
  4007. return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /* @__PURE__ */ React.createElement(RenderErrorBoundary, {
  4008. location: dataRouterState.location,
  4009. revalidation: dataRouterState.revalidation,
  4010. component: errorElement,
  4011. error,
  4012. children: getChildren(),
  4013. routeContext: {
  4014. outlet: null,
  4015. matches: matches2,
  4016. isDataRoute: true
  4017. }
  4018. }) : getChildren();
  4019. }, null);
  4020. }
  4021. function getDataRouterConsoleError(hookName) {
  4022. return hookName + " must be used within a data router. See https://reactrouter.com/routers/picking-a-router.";
  4023. }
  4024. function useDataRouterContext(hookName) {
  4025. let ctx = React.useContext(DataRouterContext);
  4026. !ctx ? true ? invariant(false, getDataRouterConsoleError(hookName)) : invariant(false) : void 0;
  4027. return ctx;
  4028. }
  4029. function useDataRouterState(hookName) {
  4030. let state = React.useContext(DataRouterStateContext);
  4031. !state ? true ? invariant(false, getDataRouterConsoleError(hookName)) : invariant(false) : void 0;
  4032. return state;
  4033. }
  4034. function useRouteContext(hookName) {
  4035. let route = React.useContext(RouteContext);
  4036. !route ? true ? invariant(false, getDataRouterConsoleError(hookName)) : invariant(false) : void 0;
  4037. return route;
  4038. }
  4039. function useCurrentRouteId(hookName) {
  4040. let route = useRouteContext(hookName);
  4041. let thisRoute = route.matches[route.matches.length - 1];
  4042. !thisRoute.route.id ? true ? invariant(false, hookName + ' can only be used on routes that contain a unique "id"') : invariant(false) : void 0;
  4043. return thisRoute.route.id;
  4044. }
  4045. function useRouteId() {
  4046. return useCurrentRouteId(DataRouterStateHook.UseRouteId);
  4047. }
  4048. function useNavigation() {
  4049. let state = useDataRouterState(DataRouterStateHook.UseNavigation);
  4050. return state.navigation;
  4051. }
  4052. function useRevalidator() {
  4053. let dataRouterContext = useDataRouterContext(DataRouterHook.UseRevalidator);
  4054. let state = useDataRouterState(DataRouterStateHook.UseRevalidator);
  4055. return React.useMemo(() => ({
  4056. revalidate: dataRouterContext.router.revalidate,
  4057. state: state.revalidation
  4058. }), [dataRouterContext.router.revalidate, state.revalidation]);
  4059. }
  4060. function useMatches() {
  4061. let {
  4062. matches,
  4063. loaderData
  4064. } = useDataRouterState(DataRouterStateHook.UseMatches);
  4065. return React.useMemo(() => matches.map((m) => convertRouteMatchToUiMatch(m, loaderData)), [matches, loaderData]);
  4066. }
  4067. function useLoaderData() {
  4068. let state = useDataRouterState(DataRouterStateHook.UseLoaderData);
  4069. let routeId = useCurrentRouteId(DataRouterStateHook.UseLoaderData);
  4070. if (state.errors && state.errors[routeId] != null) {
  4071. console.error("You cannot `useLoaderData` in an errorElement (routeId: " + routeId + ")");
  4072. return void 0;
  4073. }
  4074. return state.loaderData[routeId];
  4075. }
  4076. function useRouteLoaderData(routeId) {
  4077. let state = useDataRouterState(DataRouterStateHook.UseRouteLoaderData);
  4078. return state.loaderData[routeId];
  4079. }
  4080. function useActionData() {
  4081. let state = useDataRouterState(DataRouterStateHook.UseActionData);
  4082. let routeId = useCurrentRouteId(DataRouterStateHook.UseLoaderData);
  4083. return state.actionData ? state.actionData[routeId] : void 0;
  4084. }
  4085. function useRouteError() {
  4086. var _state$errors;
  4087. let error = React.useContext(RouteErrorContext);
  4088. let state = useDataRouterState(DataRouterStateHook.UseRouteError);
  4089. let routeId = useCurrentRouteId(DataRouterStateHook.UseRouteError);
  4090. if (error !== void 0) {
  4091. return error;
  4092. }
  4093. return (_state$errors = state.errors) == null ? void 0 : _state$errors[routeId];
  4094. }
  4095. function useAsyncValue() {
  4096. let value = React.useContext(AwaitContext);
  4097. return value == null ? void 0 : value._data;
  4098. }
  4099. function useAsyncError() {
  4100. let value = React.useContext(AwaitContext);
  4101. return value == null ? void 0 : value._error;
  4102. }
  4103. function useBlocker(shouldBlock) {
  4104. let {
  4105. router: router2,
  4106. basename
  4107. } = useDataRouterContext(DataRouterHook.UseBlocker);
  4108. let state = useDataRouterState(DataRouterStateHook.UseBlocker);
  4109. let [blockerKey, setBlockerKey] = React.useState("");
  4110. let blockerFunction = React.useCallback((arg) => {
  4111. if (typeof shouldBlock !== "function") {
  4112. return !!shouldBlock;
  4113. }
  4114. if (basename === "/") {
  4115. return shouldBlock(arg);
  4116. }
  4117. let {
  4118. currentLocation,
  4119. nextLocation,
  4120. historyAction
  4121. } = arg;
  4122. return shouldBlock({
  4123. currentLocation: _extends2({}, currentLocation, {
  4124. pathname: stripBasename(currentLocation.pathname, basename) || currentLocation.pathname
  4125. }),
  4126. nextLocation: _extends2({}, nextLocation, {
  4127. pathname: stripBasename(nextLocation.pathname, basename) || nextLocation.pathname
  4128. }),
  4129. historyAction
  4130. });
  4131. }, [basename, shouldBlock]);
  4132. React.useEffect(() => {
  4133. let key = String(++blockerId);
  4134. setBlockerKey(key);
  4135. return () => router2.deleteBlocker(key);
  4136. }, [router2]);
  4137. React.useEffect(() => {
  4138. if (blockerKey !== "") {
  4139. router2.getBlocker(blockerKey, blockerFunction);
  4140. }
  4141. }, [router2, blockerKey, blockerFunction]);
  4142. return blockerKey && state.blockers.has(blockerKey) ? state.blockers.get(blockerKey) : IDLE_BLOCKER;
  4143. }
  4144. function useNavigateStable() {
  4145. let {
  4146. router: router2
  4147. } = useDataRouterContext(DataRouterHook.UseNavigateStable);
  4148. let id = useCurrentRouteId(DataRouterStateHook.UseNavigateStable);
  4149. let activeRef = React.useRef(false);
  4150. useIsomorphicLayoutEffect(() => {
  4151. activeRef.current = true;
  4152. });
  4153. let navigate = React.useCallback(function(to, options) {
  4154. if (options === void 0) {
  4155. options = {};
  4156. }
  4157. true ? warning(activeRef.current, navigateEffectWarning) : void 0;
  4158. if (!activeRef.current)
  4159. return;
  4160. if (typeof to === "number") {
  4161. router2.navigate(to);
  4162. } else {
  4163. router2.navigate(to, _extends2({
  4164. fromRouteId: id
  4165. }, options));
  4166. }
  4167. }, [router2, id]);
  4168. return navigate;
  4169. }
  4170. function warningOnce(key, cond, message) {
  4171. if (!cond && !alreadyWarned[key]) {
  4172. alreadyWarned[key] = true;
  4173. true ? warning(false, message) : void 0;
  4174. }
  4175. }
  4176. function RouterProvider(_ref) {
  4177. let {
  4178. fallbackElement,
  4179. router: router2,
  4180. future
  4181. } = _ref;
  4182. let [state, setStateImpl] = React.useState(router2.state);
  4183. let {
  4184. v7_startTransition
  4185. } = future || {};
  4186. let setState = React.useCallback((newState) => {
  4187. if (v7_startTransition && startTransitionImpl) {
  4188. startTransitionImpl(() => setStateImpl(newState));
  4189. } else {
  4190. setStateImpl(newState);
  4191. }
  4192. }, [setStateImpl, v7_startTransition]);
  4193. React.useLayoutEffect(() => router2.subscribe(setState), [router2, setState]);
  4194. React.useEffect(() => {
  4195. true ? warning(fallbackElement == null || !router2.future.v7_partialHydration, "`<RouterProvider fallbackElement>` is deprecated when using `v7_partialHydration`, use a `HydrateFallback` component instead") : void 0;
  4196. }, []);
  4197. let navigator = React.useMemo(() => {
  4198. return {
  4199. createHref: router2.createHref,
  4200. encodeLocation: router2.encodeLocation,
  4201. go: (n) => router2.navigate(n),
  4202. push: (to, state2, opts) => router2.navigate(to, {
  4203. state: state2,
  4204. preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
  4205. }),
  4206. replace: (to, state2, opts) => router2.navigate(to, {
  4207. replace: true,
  4208. state: state2,
  4209. preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
  4210. })
  4211. };
  4212. }, [router2]);
  4213. let basename = router2.basename || "/";
  4214. let dataRouterContext = React.useMemo(() => ({
  4215. router: router2,
  4216. navigator,
  4217. static: false,
  4218. basename
  4219. }), [router2, navigator, basename]);
  4220. return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(DataRouterContext.Provider, {
  4221. value: dataRouterContext
  4222. }, /* @__PURE__ */ React.createElement(DataRouterStateContext.Provider, {
  4223. value: state
  4224. }, /* @__PURE__ */ React.createElement(Router, {
  4225. basename,
  4226. location: state.location,
  4227. navigationType: state.historyAction,
  4228. navigator,
  4229. future: {
  4230. v7_relativeSplatPath: router2.future.v7_relativeSplatPath
  4231. }
  4232. }, state.initialized || router2.future.v7_partialHydration ? /* @__PURE__ */ React.createElement(DataRoutes, {
  4233. routes: router2.routes,
  4234. future: router2.future,
  4235. state
  4236. }) : fallbackElement))), null);
  4237. }
  4238. function DataRoutes(_ref2) {
  4239. let {
  4240. routes,
  4241. future,
  4242. state
  4243. } = _ref2;
  4244. return useRoutesImpl(routes, void 0, state, future);
  4245. }
  4246. function MemoryRouter(_ref3) {
  4247. let {
  4248. basename,
  4249. children,
  4250. initialEntries,
  4251. initialIndex,
  4252. future
  4253. } = _ref3;
  4254. let historyRef = React.useRef();
  4255. if (historyRef.current == null) {
  4256. historyRef.current = createMemoryHistory({
  4257. initialEntries,
  4258. initialIndex,
  4259. v5Compat: true
  4260. });
  4261. }
  4262. let history = historyRef.current;
  4263. let [state, setStateImpl] = React.useState({
  4264. action: history.action,
  4265. location: history.location
  4266. });
  4267. let {
  4268. v7_startTransition
  4269. } = future || {};
  4270. let setState = React.useCallback((newState) => {
  4271. v7_startTransition && startTransitionImpl ? startTransitionImpl(() => setStateImpl(newState)) : setStateImpl(newState);
  4272. }, [setStateImpl, v7_startTransition]);
  4273. React.useLayoutEffect(() => history.listen(setState), [history, setState]);
  4274. return /* @__PURE__ */ React.createElement(Router, {
  4275. basename,
  4276. children,
  4277. location: state.location,
  4278. navigationType: state.action,
  4279. navigator: history,
  4280. future
  4281. });
  4282. }
  4283. function Navigate(_ref4) {
  4284. let {
  4285. to,
  4286. replace,
  4287. state,
  4288. relative
  4289. } = _ref4;
  4290. !useInRouterContext() ? true ? invariant(
  4291. false,
  4292. // TODO: This error is probably because they somehow have 2 versions of
  4293. // the router loaded. We can help them understand how to avoid that.
  4294. "<Navigate> may be used only in the context of a <Router> component."
  4295. ) : invariant(false) : void 0;
  4296. let {
  4297. future,
  4298. static: isStatic
  4299. } = React.useContext(NavigationContext);
  4300. true ? warning(!isStatic, "<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.") : void 0;
  4301. let {
  4302. matches
  4303. } = React.useContext(RouteContext);
  4304. let {
  4305. pathname: locationPathname
  4306. } = useLocation();
  4307. let navigate = useNavigate();
  4308. let path = resolveTo(to, getResolveToMatches(matches, future.v7_relativeSplatPath), locationPathname, relative === "path");
  4309. let jsonPath = JSON.stringify(path);
  4310. React.useEffect(() => navigate(JSON.parse(jsonPath), {
  4311. replace,
  4312. state,
  4313. relative
  4314. }), [navigate, jsonPath, relative, replace, state]);
  4315. return null;
  4316. }
  4317. function Outlet(props) {
  4318. return useOutlet(props.context);
  4319. }
  4320. function Route(_props) {
  4321. true ? invariant(false, "A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.") : invariant(false);
  4322. }
  4323. function Router(_ref5) {
  4324. let {
  4325. basename: basenameProp = "/",
  4326. children = null,
  4327. location: locationProp,
  4328. navigationType = Action.Pop,
  4329. navigator,
  4330. static: staticProp = false,
  4331. future
  4332. } = _ref5;
  4333. !!useInRouterContext() ? true ? invariant(false, "You cannot render a <Router> inside another <Router>. You should never have more than one in your app.") : invariant(false) : void 0;
  4334. let basename = basenameProp.replace(/^\/*/, "/");
  4335. let navigationContext = React.useMemo(() => ({
  4336. basename,
  4337. navigator,
  4338. static: staticProp,
  4339. future: _extends2({
  4340. v7_relativeSplatPath: false
  4341. }, future)
  4342. }), [basename, future, navigator, staticProp]);
  4343. if (typeof locationProp === "string") {
  4344. locationProp = parsePath(locationProp);
  4345. }
  4346. let {
  4347. pathname = "/",
  4348. search = "",
  4349. hash = "",
  4350. state = null,
  4351. key = "default"
  4352. } = locationProp;
  4353. let locationContext = React.useMemo(() => {
  4354. let trailingPathname = stripBasename(pathname, basename);
  4355. if (trailingPathname == null) {
  4356. return null;
  4357. }
  4358. return {
  4359. location: {
  4360. pathname: trailingPathname,
  4361. search,
  4362. hash,
  4363. state,
  4364. key
  4365. },
  4366. navigationType
  4367. };
  4368. }, [basename, pathname, search, hash, state, key, navigationType]);
  4369. true ? warning(locationContext != null, '<Router basename="' + basename + '"> is not able to match the URL ' + ('"' + pathname + search + hash + '" because it does not start with the ') + "basename, so the <Router> won't render anything.") : void 0;
  4370. if (locationContext == null) {
  4371. return null;
  4372. }
  4373. return /* @__PURE__ */ React.createElement(NavigationContext.Provider, {
  4374. value: navigationContext
  4375. }, /* @__PURE__ */ React.createElement(LocationContext.Provider, {
  4376. children,
  4377. value: locationContext
  4378. }));
  4379. }
  4380. function Routes(_ref6) {
  4381. let {
  4382. children,
  4383. location
  4384. } = _ref6;
  4385. return useRoutes(createRoutesFromChildren(children), location);
  4386. }
  4387. function Await(_ref7) {
  4388. let {
  4389. children,
  4390. errorElement,
  4391. resolve
  4392. } = _ref7;
  4393. return /* @__PURE__ */ React.createElement(AwaitErrorBoundary, {
  4394. resolve,
  4395. errorElement
  4396. }, /* @__PURE__ */ React.createElement(ResolveAwait, null, children));
  4397. }
  4398. function ResolveAwait(_ref8) {
  4399. let {
  4400. children
  4401. } = _ref8;
  4402. let data = useAsyncValue();
  4403. let toRender = typeof children === "function" ? children(data) : children;
  4404. return /* @__PURE__ */ React.createElement(React.Fragment, null, toRender);
  4405. }
  4406. function createRoutesFromChildren(children, parentPath) {
  4407. if (parentPath === void 0) {
  4408. parentPath = [];
  4409. }
  4410. let routes = [];
  4411. React.Children.forEach(children, (element, index) => {
  4412. if (!/* @__PURE__ */ React.isValidElement(element)) {
  4413. return;
  4414. }
  4415. let treePath = [...parentPath, index];
  4416. if (element.type === React.Fragment) {
  4417. routes.push.apply(routes, createRoutesFromChildren(element.props.children, treePath));
  4418. return;
  4419. }
  4420. !(element.type === Route) ? true ? invariant(false, "[" + (typeof element.type === "string" ? element.type : element.type.name) + "] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>") : invariant(false) : void 0;
  4421. !(!element.props.index || !element.props.children) ? true ? invariant(false, "An index route cannot have child routes.") : invariant(false) : void 0;
  4422. let route = {
  4423. id: element.props.id || treePath.join("-"),
  4424. caseSensitive: element.props.caseSensitive,
  4425. element: element.props.element,
  4426. Component: element.props.Component,
  4427. index: element.props.index,
  4428. path: element.props.path,
  4429. loader: element.props.loader,
  4430. action: element.props.action,
  4431. errorElement: element.props.errorElement,
  4432. ErrorBoundary: element.props.ErrorBoundary,
  4433. hasErrorBoundary: element.props.ErrorBoundary != null || element.props.errorElement != null,
  4434. shouldRevalidate: element.props.shouldRevalidate,
  4435. handle: element.props.handle,
  4436. lazy: element.props.lazy
  4437. };
  4438. if (element.props.children) {
  4439. route.children = createRoutesFromChildren(element.props.children, treePath);
  4440. }
  4441. routes.push(route);
  4442. });
  4443. return routes;
  4444. }
  4445. function renderMatches(matches) {
  4446. return _renderMatches(matches);
  4447. }
  4448. function mapRouteProperties(route) {
  4449. let updates = {
  4450. // Note: this check also occurs in createRoutesFromChildren so update
  4451. // there if you change this -- please and thank you!
  4452. hasErrorBoundary: route.ErrorBoundary != null || route.errorElement != null
  4453. };
  4454. if (route.Component) {
  4455. if (true) {
  4456. if (route.element) {
  4457. true ? warning(false, "You should not include both `Component` and `element` on your route - `Component` will be used.") : void 0;
  4458. }
  4459. }
  4460. Object.assign(updates, {
  4461. element: /* @__PURE__ */ React.createElement(route.Component),
  4462. Component: void 0
  4463. });
  4464. }
  4465. if (route.HydrateFallback) {
  4466. if (true) {
  4467. if (route.hydrateFallbackElement) {
  4468. true ? warning(false, "You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - `HydrateFallback` will be used.") : void 0;
  4469. }
  4470. }
  4471. Object.assign(updates, {
  4472. hydrateFallbackElement: /* @__PURE__ */ React.createElement(route.HydrateFallback),
  4473. HydrateFallback: void 0
  4474. });
  4475. }
  4476. if (route.ErrorBoundary) {
  4477. if (true) {
  4478. if (route.errorElement) {
  4479. true ? warning(false, "You should not include both `ErrorBoundary` and `errorElement` on your route - `ErrorBoundary` will be used.") : void 0;
  4480. }
  4481. }
  4482. Object.assign(updates, {
  4483. errorElement: /* @__PURE__ */ React.createElement(route.ErrorBoundary),
  4484. ErrorBoundary: void 0
  4485. });
  4486. }
  4487. return updates;
  4488. }
  4489. function createMemoryRouter(routes, opts) {
  4490. return createRouter({
  4491. basename: opts == null ? void 0 : opts.basename,
  4492. future: _extends2({}, opts == null ? void 0 : opts.future, {
  4493. v7_prependBasename: true
  4494. }),
  4495. history: createMemoryHistory({
  4496. initialEntries: opts == null ? void 0 : opts.initialEntries,
  4497. initialIndex: opts == null ? void 0 : opts.initialIndex
  4498. }),
  4499. hydrationData: opts == null ? void 0 : opts.hydrationData,
  4500. routes,
  4501. mapRouteProperties
  4502. }).initialize();
  4503. }
  4504. var React, DataRouterContext, DataRouterStateContext, AwaitContext, NavigationContext, LocationContext, RouteContext, RouteErrorContext, navigateEffectWarning, OutletContext, defaultErrorElement, RenderErrorBoundary, DataRouterHook, DataRouterStateHook, blockerId, alreadyWarned, START_TRANSITION, startTransitionImpl, AwaitRenderStatus, neverSettledPromise, AwaitErrorBoundary;
  4505. var init_dist = __esm({
  4506. "node_modules/react-router/dist/index.js"() {
  4507. React = __toESM(require_react());
  4508. init_router();
  4509. init_router();
  4510. DataRouterContext = /* @__PURE__ */ React.createContext(null);
  4511. if (true) {
  4512. DataRouterContext.displayName = "DataRouter";
  4513. }
  4514. DataRouterStateContext = /* @__PURE__ */ React.createContext(null);
  4515. if (true) {
  4516. DataRouterStateContext.displayName = "DataRouterState";
  4517. }
  4518. AwaitContext = /* @__PURE__ */ React.createContext(null);
  4519. if (true) {
  4520. AwaitContext.displayName = "Await";
  4521. }
  4522. NavigationContext = /* @__PURE__ */ React.createContext(null);
  4523. if (true) {
  4524. NavigationContext.displayName = "Navigation";
  4525. }
  4526. LocationContext = /* @__PURE__ */ React.createContext(null);
  4527. if (true) {
  4528. LocationContext.displayName = "Location";
  4529. }
  4530. RouteContext = /* @__PURE__ */ React.createContext({
  4531. outlet: null,
  4532. matches: [],
  4533. isDataRoute: false
  4534. });
  4535. if (true) {
  4536. RouteContext.displayName = "Route";
  4537. }
  4538. RouteErrorContext = /* @__PURE__ */ React.createContext(null);
  4539. if (true) {
  4540. RouteErrorContext.displayName = "RouteError";
  4541. }
  4542. navigateEffectWarning = "You should call navigate() in a React.useEffect(), not when your component is first rendered.";
  4543. OutletContext = /* @__PURE__ */ React.createContext(null);
  4544. defaultErrorElement = /* @__PURE__ */ React.createElement(DefaultErrorComponent, null);
  4545. RenderErrorBoundary = class extends React.Component {
  4546. constructor(props) {
  4547. super(props);
  4548. this.state = {
  4549. location: props.location,
  4550. revalidation: props.revalidation,
  4551. error: props.error
  4552. };
  4553. }
  4554. static getDerivedStateFromError(error) {
  4555. return {
  4556. error
  4557. };
  4558. }
  4559. static getDerivedStateFromProps(props, state) {
  4560. if (state.location !== props.location || state.revalidation !== "idle" && props.revalidation === "idle") {
  4561. return {
  4562. error: props.error,
  4563. location: props.location,
  4564. revalidation: props.revalidation
  4565. };
  4566. }
  4567. return {
  4568. error: props.error !== void 0 ? props.error : state.error,
  4569. location: state.location,
  4570. revalidation: props.revalidation || state.revalidation
  4571. };
  4572. }
  4573. componentDidCatch(error, errorInfo) {
  4574. console.error("React Router caught the following error during render", error, errorInfo);
  4575. }
  4576. render() {
  4577. return this.state.error !== void 0 ? /* @__PURE__ */ React.createElement(RouteContext.Provider, {
  4578. value: this.props.routeContext
  4579. }, /* @__PURE__ */ React.createElement(RouteErrorContext.Provider, {
  4580. value: this.state.error,
  4581. children: this.props.component
  4582. })) : this.props.children;
  4583. }
  4584. };
  4585. DataRouterHook = /* @__PURE__ */ function(DataRouterHook3) {
  4586. DataRouterHook3["UseBlocker"] = "useBlocker";
  4587. DataRouterHook3["UseRevalidator"] = "useRevalidator";
  4588. DataRouterHook3["UseNavigateStable"] = "useNavigate";
  4589. return DataRouterHook3;
  4590. }(DataRouterHook || {});
  4591. DataRouterStateHook = /* @__PURE__ */ function(DataRouterStateHook3) {
  4592. DataRouterStateHook3["UseBlocker"] = "useBlocker";
  4593. DataRouterStateHook3["UseLoaderData"] = "useLoaderData";
  4594. DataRouterStateHook3["UseActionData"] = "useActionData";
  4595. DataRouterStateHook3["UseRouteError"] = "useRouteError";
  4596. DataRouterStateHook3["UseNavigation"] = "useNavigation";
  4597. DataRouterStateHook3["UseRouteLoaderData"] = "useRouteLoaderData";
  4598. DataRouterStateHook3["UseMatches"] = "useMatches";
  4599. DataRouterStateHook3["UseRevalidator"] = "useRevalidator";
  4600. DataRouterStateHook3["UseNavigateStable"] = "useNavigate";
  4601. DataRouterStateHook3["UseRouteId"] = "useRouteId";
  4602. return DataRouterStateHook3;
  4603. }(DataRouterStateHook || {});
  4604. blockerId = 0;
  4605. alreadyWarned = {};
  4606. START_TRANSITION = "startTransition";
  4607. startTransitionImpl = React[START_TRANSITION];
  4608. AwaitRenderStatus = /* @__PURE__ */ function(AwaitRenderStatus2) {
  4609. AwaitRenderStatus2[AwaitRenderStatus2["pending"] = 0] = "pending";
  4610. AwaitRenderStatus2[AwaitRenderStatus2["success"] = 1] = "success";
  4611. AwaitRenderStatus2[AwaitRenderStatus2["error"] = 2] = "error";
  4612. return AwaitRenderStatus2;
  4613. }(AwaitRenderStatus || {});
  4614. neverSettledPromise = new Promise(() => {
  4615. });
  4616. AwaitErrorBoundary = class extends React.Component {
  4617. constructor(props) {
  4618. super(props);
  4619. this.state = {
  4620. error: null
  4621. };
  4622. }
  4623. static getDerivedStateFromError(error) {
  4624. return {
  4625. error
  4626. };
  4627. }
  4628. componentDidCatch(error, errorInfo) {
  4629. console.error("<Await> caught the following error during render", error, errorInfo);
  4630. }
  4631. render() {
  4632. let {
  4633. children,
  4634. errorElement,
  4635. resolve
  4636. } = this.props;
  4637. let promise = null;
  4638. let status = AwaitRenderStatus.pending;
  4639. if (!(resolve instanceof Promise)) {
  4640. status = AwaitRenderStatus.success;
  4641. promise = Promise.resolve();
  4642. Object.defineProperty(promise, "_tracked", {
  4643. get: () => true
  4644. });
  4645. Object.defineProperty(promise, "_data", {
  4646. get: () => resolve
  4647. });
  4648. } else if (this.state.error) {
  4649. status = AwaitRenderStatus.error;
  4650. let renderError = this.state.error;
  4651. promise = Promise.reject().catch(() => {
  4652. });
  4653. Object.defineProperty(promise, "_tracked", {
  4654. get: () => true
  4655. });
  4656. Object.defineProperty(promise, "_error", {
  4657. get: () => renderError
  4658. });
  4659. } else if (resolve._tracked) {
  4660. promise = resolve;
  4661. status = promise._error !== void 0 ? AwaitRenderStatus.error : promise._data !== void 0 ? AwaitRenderStatus.success : AwaitRenderStatus.pending;
  4662. } else {
  4663. status = AwaitRenderStatus.pending;
  4664. Object.defineProperty(resolve, "_tracked", {
  4665. get: () => true
  4666. });
  4667. promise = resolve.then((data) => Object.defineProperty(resolve, "_data", {
  4668. get: () => data
  4669. }), (error) => Object.defineProperty(resolve, "_error", {
  4670. get: () => error
  4671. }));
  4672. }
  4673. if (status === AwaitRenderStatus.error && promise._error instanceof AbortedDeferredError) {
  4674. throw neverSettledPromise;
  4675. }
  4676. if (status === AwaitRenderStatus.error && !errorElement) {
  4677. throw promise._error;
  4678. }
  4679. if (status === AwaitRenderStatus.error) {
  4680. return /* @__PURE__ */ React.createElement(AwaitContext.Provider, {
  4681. value: promise,
  4682. children: errorElement
  4683. });
  4684. }
  4685. if (status === AwaitRenderStatus.success) {
  4686. return /* @__PURE__ */ React.createElement(AwaitContext.Provider, {
  4687. value: promise,
  4688. children
  4689. });
  4690. }
  4691. throw promise;
  4692. }
  4693. };
  4694. }
  4695. });
  4696. // node_modules/react-router-dom/dist/index.js
  4697. var dist_exports2 = {};
  4698. __export(dist_exports2, {
  4699. AbortedDeferredError: () => AbortedDeferredError,
  4700. Await: () => Await,
  4701. BrowserRouter: () => BrowserRouter,
  4702. Form: () => Form,
  4703. HashRouter: () => HashRouter,
  4704. Link: () => Link,
  4705. MemoryRouter: () => MemoryRouter,
  4706. NavLink: () => NavLink,
  4707. Navigate: () => Navigate,
  4708. NavigationType: () => Action,
  4709. Outlet: () => Outlet,
  4710. Route: () => Route,
  4711. Router: () => Router,
  4712. RouterProvider: () => RouterProvider2,
  4713. Routes: () => Routes,
  4714. ScrollRestoration: () => ScrollRestoration,
  4715. UNSAFE_DataRouterContext: () => DataRouterContext,
  4716. UNSAFE_DataRouterStateContext: () => DataRouterStateContext,
  4717. UNSAFE_FetchersContext: () => FetchersContext,
  4718. UNSAFE_LocationContext: () => LocationContext,
  4719. UNSAFE_NavigationContext: () => NavigationContext,
  4720. UNSAFE_RouteContext: () => RouteContext,
  4721. UNSAFE_ViewTransitionContext: () => ViewTransitionContext,
  4722. UNSAFE_useRouteId: () => useRouteId,
  4723. UNSAFE_useScrollRestoration: () => useScrollRestoration,
  4724. createBrowserRouter: () => createBrowserRouter,
  4725. createHashRouter: () => createHashRouter,
  4726. createMemoryRouter: () => createMemoryRouter,
  4727. createPath: () => createPath,
  4728. createRoutesFromChildren: () => createRoutesFromChildren,
  4729. createRoutesFromElements: () => createRoutesFromChildren,
  4730. createSearchParams: () => createSearchParams,
  4731. defer: () => defer,
  4732. generatePath: () => generatePath,
  4733. isRouteErrorResponse: () => isRouteErrorResponse,
  4734. json: () => json,
  4735. matchPath: () => matchPath,
  4736. matchRoutes: () => matchRoutes,
  4737. parsePath: () => parsePath,
  4738. redirect: () => redirect,
  4739. redirectDocument: () => redirectDocument,
  4740. renderMatches: () => renderMatches,
  4741. resolvePath: () => resolvePath,
  4742. unstable_HistoryRouter: () => HistoryRouter,
  4743. unstable_usePrompt: () => usePrompt,
  4744. unstable_useViewTransitionState: () => useViewTransitionState,
  4745. useActionData: () => useActionData,
  4746. useAsyncError: () => useAsyncError,
  4747. useAsyncValue: () => useAsyncValue,
  4748. useBeforeUnload: () => useBeforeUnload,
  4749. useBlocker: () => useBlocker,
  4750. useFetcher: () => useFetcher,
  4751. useFetchers: () => useFetchers,
  4752. useFormAction: () => useFormAction,
  4753. useHref: () => useHref,
  4754. useInRouterContext: () => useInRouterContext,
  4755. useLinkClickHandler: () => useLinkClickHandler,
  4756. useLoaderData: () => useLoaderData,
  4757. useLocation: () => useLocation,
  4758. useMatch: () => useMatch,
  4759. useMatches: () => useMatches,
  4760. useNavigate: () => useNavigate,
  4761. useNavigation: () => useNavigation,
  4762. useNavigationType: () => useNavigationType,
  4763. useOutlet: () => useOutlet,
  4764. useOutletContext: () => useOutletContext,
  4765. useParams: () => useParams,
  4766. useResolvedPath: () => useResolvedPath,
  4767. useRevalidator: () => useRevalidator,
  4768. useRouteError: () => useRouteError,
  4769. useRouteLoaderData: () => useRouteLoaderData,
  4770. useRoutes: () => useRoutes,
  4771. useSearchParams: () => useSearchParams,
  4772. useSubmit: () => useSubmit
  4773. });
  4774. function _extends3() {
  4775. _extends3 = Object.assign ? Object.assign.bind() : function(target) {
  4776. for (var i = 1; i < arguments.length; i++) {
  4777. var source = arguments[i];
  4778. for (var key in source) {
  4779. if (Object.prototype.hasOwnProperty.call(source, key)) {
  4780. target[key] = source[key];
  4781. }
  4782. }
  4783. }
  4784. return target;
  4785. };
  4786. return _extends3.apply(this, arguments);
  4787. }
  4788. function _objectWithoutPropertiesLoose(source, excluded) {
  4789. if (source == null)
  4790. return {};
  4791. var target = {};
  4792. var sourceKeys = Object.keys(source);
  4793. var key, i;
  4794. for (i = 0; i < sourceKeys.length; i++) {
  4795. key = sourceKeys[i];
  4796. if (excluded.indexOf(key) >= 0)
  4797. continue;
  4798. target[key] = source[key];
  4799. }
  4800. return target;
  4801. }
  4802. function isHtmlElement(object) {
  4803. return object != null && typeof object.tagName === "string";
  4804. }
  4805. function isButtonElement(object) {
  4806. return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
  4807. }
  4808. function isFormElement(object) {
  4809. return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
  4810. }
  4811. function isInputElement(object) {
  4812. return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
  4813. }
  4814. function isModifiedEvent(event) {
  4815. return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
  4816. }
  4817. function shouldProcessLinkClick(event, target) {
  4818. return event.button === 0 && // Ignore everything but left clicks
  4819. (!target || target === "_self") && // Let browser handle "target=_blank" etc.
  4820. !isModifiedEvent(event);
  4821. }
  4822. function createSearchParams(init) {
  4823. if (init === void 0) {
  4824. init = "";
  4825. }
  4826. return new URLSearchParams(typeof init === "string" || Array.isArray(init) || init instanceof URLSearchParams ? init : Object.keys(init).reduce((memo, key) => {
  4827. let value = init[key];
  4828. return memo.concat(Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]);
  4829. }, []));
  4830. }
  4831. function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
  4832. let searchParams = createSearchParams(locationSearch);
  4833. if (defaultSearchParams) {
  4834. defaultSearchParams.forEach((_, key) => {
  4835. if (!searchParams.has(key)) {
  4836. defaultSearchParams.getAll(key).forEach((value) => {
  4837. searchParams.append(key, value);
  4838. });
  4839. }
  4840. });
  4841. }
  4842. return searchParams;
  4843. }
  4844. function isFormDataSubmitterSupported() {
  4845. if (_formDataSupportsSubmitter === null) {
  4846. try {
  4847. new FormData(
  4848. document.createElement("form"),
  4849. // @ts-expect-error if FormData supports the submitter parameter, this will throw
  4850. 0
  4851. );
  4852. _formDataSupportsSubmitter = false;
  4853. } catch (e) {
  4854. _formDataSupportsSubmitter = true;
  4855. }
  4856. }
  4857. return _formDataSupportsSubmitter;
  4858. }
  4859. function getFormEncType(encType) {
  4860. if (encType != null && !supportedFormEncTypes.has(encType)) {
  4861. true ? warning(false, '"' + encType + '" is not a valid `encType` for `<Form>`/`<fetcher.Form>` ' + ('and will default to "' + defaultEncType + '"')) : void 0;
  4862. return null;
  4863. }
  4864. return encType;
  4865. }
  4866. function getFormSubmissionInfo(target, basename) {
  4867. let method;
  4868. let action;
  4869. let encType;
  4870. let formData;
  4871. let body;
  4872. if (isFormElement(target)) {
  4873. let attr = target.getAttribute("action");
  4874. action = attr ? stripBasename(attr, basename) : null;
  4875. method = target.getAttribute("method") || defaultMethod;
  4876. encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
  4877. formData = new FormData(target);
  4878. } else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
  4879. let form = target.form;
  4880. if (form == null) {
  4881. throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');
  4882. }
  4883. let attr = target.getAttribute("formaction") || form.getAttribute("action");
  4884. action = attr ? stripBasename(attr, basename) : null;
  4885. method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
  4886. encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
  4887. formData = new FormData(form, target);
  4888. if (!isFormDataSubmitterSupported()) {
  4889. let {
  4890. name,
  4891. type,
  4892. value
  4893. } = target;
  4894. if (type === "image") {
  4895. let prefix = name ? name + "." : "";
  4896. formData.append(prefix + "x", "0");
  4897. formData.append(prefix + "y", "0");
  4898. } else if (name) {
  4899. formData.append(name, value);
  4900. }
  4901. }
  4902. } else if (isHtmlElement(target)) {
  4903. throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');
  4904. } else {
  4905. method = defaultMethod;
  4906. action = null;
  4907. encType = defaultEncType;
  4908. body = target;
  4909. }
  4910. if (formData && encType === "text/plain") {
  4911. body = formData;
  4912. formData = void 0;
  4913. }
  4914. return {
  4915. action,
  4916. method: method.toLowerCase(),
  4917. encType,
  4918. formData,
  4919. body
  4920. };
  4921. }
  4922. function createBrowserRouter(routes, opts) {
  4923. return createRouter({
  4924. basename: opts == null ? void 0 : opts.basename,
  4925. future: _extends3({}, opts == null ? void 0 : opts.future, {
  4926. v7_prependBasename: true
  4927. }),
  4928. history: createBrowserHistory({
  4929. window: opts == null ? void 0 : opts.window
  4930. }),
  4931. hydrationData: (opts == null ? void 0 : opts.hydrationData) || parseHydrationData(),
  4932. routes,
  4933. mapRouteProperties,
  4934. window: opts == null ? void 0 : opts.window
  4935. }).initialize();
  4936. }
  4937. function createHashRouter(routes, opts) {
  4938. return createRouter({
  4939. basename: opts == null ? void 0 : opts.basename,
  4940. future: _extends3({}, opts == null ? void 0 : opts.future, {
  4941. v7_prependBasename: true
  4942. }),
  4943. history: createHashHistory({
  4944. window: opts == null ? void 0 : opts.window
  4945. }),
  4946. hydrationData: (opts == null ? void 0 : opts.hydrationData) || parseHydrationData(),
  4947. routes,
  4948. mapRouteProperties,
  4949. window: opts == null ? void 0 : opts.window
  4950. }).initialize();
  4951. }
  4952. function parseHydrationData() {
  4953. var _window;
  4954. let state = (_window = window) == null ? void 0 : _window.__staticRouterHydrationData;
  4955. if (state && state.errors) {
  4956. state = _extends3({}, state, {
  4957. errors: deserializeErrors(state.errors)
  4958. });
  4959. }
  4960. return state;
  4961. }
  4962. function deserializeErrors(errors) {
  4963. if (!errors)
  4964. return null;
  4965. let entries = Object.entries(errors);
  4966. let serialized = {};
  4967. for (let [key, val] of entries) {
  4968. if (val && val.__type === "RouteErrorResponse") {
  4969. serialized[key] = new ErrorResponseImpl(val.status, val.statusText, val.data, val.internal === true);
  4970. } else if (val && val.__type === "Error") {
  4971. if (val.__subType) {
  4972. let ErrorConstructor = window[val.__subType];
  4973. if (typeof ErrorConstructor === "function") {
  4974. try {
  4975. let error = new ErrorConstructor(val.message);
  4976. error.stack = "";
  4977. serialized[key] = error;
  4978. } catch (e) {
  4979. }
  4980. }
  4981. }
  4982. if (serialized[key] == null) {
  4983. let error = new Error(val.message);
  4984. error.stack = "";
  4985. serialized[key] = error;
  4986. }
  4987. } else {
  4988. serialized[key] = val;
  4989. }
  4990. }
  4991. return serialized;
  4992. }
  4993. function startTransitionSafe(cb) {
  4994. if (startTransitionImpl2) {
  4995. startTransitionImpl2(cb);
  4996. } else {
  4997. cb();
  4998. }
  4999. }
  5000. function flushSyncSafe(cb) {
  5001. if (flushSyncImpl) {
  5002. flushSyncImpl(cb);
  5003. } else {
  5004. cb();
  5005. }
  5006. }
  5007. function RouterProvider2(_ref) {
  5008. let {
  5009. fallbackElement,
  5010. router: router2,
  5011. future
  5012. } = _ref;
  5013. let [state, setStateImpl] = React2.useState(router2.state);
  5014. let [pendingState, setPendingState] = React2.useState();
  5015. let [vtContext, setVtContext] = React2.useState({
  5016. isTransitioning: false
  5017. });
  5018. let [renderDfd, setRenderDfd] = React2.useState();
  5019. let [transition, setTransition] = React2.useState();
  5020. let [interruption, setInterruption] = React2.useState();
  5021. let fetcherData = React2.useRef(/* @__PURE__ */ new Map());
  5022. let {
  5023. v7_startTransition
  5024. } = future || {};
  5025. let optInStartTransition = React2.useCallback((cb) => {
  5026. if (v7_startTransition) {
  5027. startTransitionSafe(cb);
  5028. } else {
  5029. cb();
  5030. }
  5031. }, [v7_startTransition]);
  5032. let setState = React2.useCallback((newState, _ref2) => {
  5033. let {
  5034. deletedFetchers,
  5035. unstable_flushSync: flushSync,
  5036. unstable_viewTransitionOpts: viewTransitionOpts
  5037. } = _ref2;
  5038. deletedFetchers.forEach((key) => fetcherData.current.delete(key));
  5039. newState.fetchers.forEach((fetcher, key) => {
  5040. if (fetcher.data !== void 0) {
  5041. fetcherData.current.set(key, fetcher.data);
  5042. }
  5043. });
  5044. let isViewTransitionUnavailable = router2.window == null || typeof router2.window.document.startViewTransition !== "function";
  5045. if (!viewTransitionOpts || isViewTransitionUnavailable) {
  5046. if (flushSync) {
  5047. flushSyncSafe(() => setStateImpl(newState));
  5048. } else {
  5049. optInStartTransition(() => setStateImpl(newState));
  5050. }
  5051. return;
  5052. }
  5053. if (flushSync) {
  5054. flushSyncSafe(() => {
  5055. if (transition) {
  5056. renderDfd && renderDfd.resolve();
  5057. transition.skipTransition();
  5058. }
  5059. setVtContext({
  5060. isTransitioning: true,
  5061. flushSync: true,
  5062. currentLocation: viewTransitionOpts.currentLocation,
  5063. nextLocation: viewTransitionOpts.nextLocation
  5064. });
  5065. });
  5066. let t = router2.window.document.startViewTransition(() => {
  5067. flushSyncSafe(() => setStateImpl(newState));
  5068. });
  5069. t.finished.finally(() => {
  5070. flushSyncSafe(() => {
  5071. setRenderDfd(void 0);
  5072. setTransition(void 0);
  5073. setPendingState(void 0);
  5074. setVtContext({
  5075. isTransitioning: false
  5076. });
  5077. });
  5078. });
  5079. flushSyncSafe(() => setTransition(t));
  5080. return;
  5081. }
  5082. if (transition) {
  5083. renderDfd && renderDfd.resolve();
  5084. transition.skipTransition();
  5085. setInterruption({
  5086. state: newState,
  5087. currentLocation: viewTransitionOpts.currentLocation,
  5088. nextLocation: viewTransitionOpts.nextLocation
  5089. });
  5090. } else {
  5091. setPendingState(newState);
  5092. setVtContext({
  5093. isTransitioning: true,
  5094. flushSync: false,
  5095. currentLocation: viewTransitionOpts.currentLocation,
  5096. nextLocation: viewTransitionOpts.nextLocation
  5097. });
  5098. }
  5099. }, [router2.window, transition, renderDfd, fetcherData, optInStartTransition]);
  5100. React2.useLayoutEffect(() => router2.subscribe(setState), [router2, setState]);
  5101. React2.useEffect(() => {
  5102. if (vtContext.isTransitioning && !vtContext.flushSync) {
  5103. setRenderDfd(new Deferred());
  5104. }
  5105. }, [vtContext]);
  5106. React2.useEffect(() => {
  5107. if (renderDfd && pendingState && router2.window) {
  5108. let newState = pendingState;
  5109. let renderPromise = renderDfd.promise;
  5110. let transition2 = router2.window.document.startViewTransition(async () => {
  5111. optInStartTransition(() => setStateImpl(newState));
  5112. await renderPromise;
  5113. });
  5114. transition2.finished.finally(() => {
  5115. setRenderDfd(void 0);
  5116. setTransition(void 0);
  5117. setPendingState(void 0);
  5118. setVtContext({
  5119. isTransitioning: false
  5120. });
  5121. });
  5122. setTransition(transition2);
  5123. }
  5124. }, [optInStartTransition, pendingState, renderDfd, router2.window]);
  5125. React2.useEffect(() => {
  5126. if (renderDfd && pendingState && state.location.key === pendingState.location.key) {
  5127. renderDfd.resolve();
  5128. }
  5129. }, [renderDfd, transition, state.location, pendingState]);
  5130. React2.useEffect(() => {
  5131. if (!vtContext.isTransitioning && interruption) {
  5132. setPendingState(interruption.state);
  5133. setVtContext({
  5134. isTransitioning: true,
  5135. flushSync: false,
  5136. currentLocation: interruption.currentLocation,
  5137. nextLocation: interruption.nextLocation
  5138. });
  5139. setInterruption(void 0);
  5140. }
  5141. }, [vtContext.isTransitioning, interruption]);
  5142. React2.useEffect(() => {
  5143. true ? warning(fallbackElement == null || !router2.future.v7_partialHydration, "`<RouterProvider fallbackElement>` is deprecated when using `v7_partialHydration`, use a `HydrateFallback` component instead") : void 0;
  5144. }, []);
  5145. let navigator = React2.useMemo(() => {
  5146. return {
  5147. createHref: router2.createHref,
  5148. encodeLocation: router2.encodeLocation,
  5149. go: (n) => router2.navigate(n),
  5150. push: (to, state2, opts) => router2.navigate(to, {
  5151. state: state2,
  5152. preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
  5153. }),
  5154. replace: (to, state2, opts) => router2.navigate(to, {
  5155. replace: true,
  5156. state: state2,
  5157. preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
  5158. })
  5159. };
  5160. }, [router2]);
  5161. let basename = router2.basename || "/";
  5162. let dataRouterContext = React2.useMemo(() => ({
  5163. router: router2,
  5164. navigator,
  5165. static: false,
  5166. basename
  5167. }), [router2, navigator, basename]);
  5168. return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(DataRouterContext.Provider, {
  5169. value: dataRouterContext
  5170. }, /* @__PURE__ */ React2.createElement(DataRouterStateContext.Provider, {
  5171. value: state
  5172. }, /* @__PURE__ */ React2.createElement(FetchersContext.Provider, {
  5173. value: fetcherData.current
  5174. }, /* @__PURE__ */ React2.createElement(ViewTransitionContext.Provider, {
  5175. value: vtContext
  5176. }, /* @__PURE__ */ React2.createElement(Router, {
  5177. basename,
  5178. location: state.location,
  5179. navigationType: state.historyAction,
  5180. navigator,
  5181. future: {
  5182. v7_relativeSplatPath: router2.future.v7_relativeSplatPath
  5183. }
  5184. }, state.initialized || router2.future.v7_partialHydration ? /* @__PURE__ */ React2.createElement(DataRoutes2, {
  5185. routes: router2.routes,
  5186. future: router2.future,
  5187. state
  5188. }) : fallbackElement))))), null);
  5189. }
  5190. function DataRoutes2(_ref3) {
  5191. let {
  5192. routes,
  5193. future,
  5194. state
  5195. } = _ref3;
  5196. return useRoutesImpl(routes, void 0, state, future);
  5197. }
  5198. function BrowserRouter(_ref4) {
  5199. let {
  5200. basename,
  5201. children,
  5202. future,
  5203. window: window2
  5204. } = _ref4;
  5205. let historyRef = React2.useRef();
  5206. if (historyRef.current == null) {
  5207. historyRef.current = createBrowserHistory({
  5208. window: window2,
  5209. v5Compat: true
  5210. });
  5211. }
  5212. let history = historyRef.current;
  5213. let [state, setStateImpl] = React2.useState({
  5214. action: history.action,
  5215. location: history.location
  5216. });
  5217. let {
  5218. v7_startTransition
  5219. } = future || {};
  5220. let setState = React2.useCallback((newState) => {
  5221. v7_startTransition && startTransitionImpl2 ? startTransitionImpl2(() => setStateImpl(newState)) : setStateImpl(newState);
  5222. }, [setStateImpl, v7_startTransition]);
  5223. React2.useLayoutEffect(() => history.listen(setState), [history, setState]);
  5224. return /* @__PURE__ */ React2.createElement(Router, {
  5225. basename,
  5226. children,
  5227. location: state.location,
  5228. navigationType: state.action,
  5229. navigator: history,
  5230. future
  5231. });
  5232. }
  5233. function HashRouter(_ref5) {
  5234. let {
  5235. basename,
  5236. children,
  5237. future,
  5238. window: window2
  5239. } = _ref5;
  5240. let historyRef = React2.useRef();
  5241. if (historyRef.current == null) {
  5242. historyRef.current = createHashHistory({
  5243. window: window2,
  5244. v5Compat: true
  5245. });
  5246. }
  5247. let history = historyRef.current;
  5248. let [state, setStateImpl] = React2.useState({
  5249. action: history.action,
  5250. location: history.location
  5251. });
  5252. let {
  5253. v7_startTransition
  5254. } = future || {};
  5255. let setState = React2.useCallback((newState) => {
  5256. v7_startTransition && startTransitionImpl2 ? startTransitionImpl2(() => setStateImpl(newState)) : setStateImpl(newState);
  5257. }, [setStateImpl, v7_startTransition]);
  5258. React2.useLayoutEffect(() => history.listen(setState), [history, setState]);
  5259. return /* @__PURE__ */ React2.createElement(Router, {
  5260. basename,
  5261. children,
  5262. location: state.location,
  5263. navigationType: state.action,
  5264. navigator: history,
  5265. future
  5266. });
  5267. }
  5268. function HistoryRouter(_ref6) {
  5269. let {
  5270. basename,
  5271. children,
  5272. future,
  5273. history
  5274. } = _ref6;
  5275. let [state, setStateImpl] = React2.useState({
  5276. action: history.action,
  5277. location: history.location
  5278. });
  5279. let {
  5280. v7_startTransition
  5281. } = future || {};
  5282. let setState = React2.useCallback((newState) => {
  5283. v7_startTransition && startTransitionImpl2 ? startTransitionImpl2(() => setStateImpl(newState)) : setStateImpl(newState);
  5284. }, [setStateImpl, v7_startTransition]);
  5285. React2.useLayoutEffect(() => history.listen(setState), [history, setState]);
  5286. return /* @__PURE__ */ React2.createElement(Router, {
  5287. basename,
  5288. children,
  5289. location: state.location,
  5290. navigationType: state.action,
  5291. navigator: history,
  5292. future
  5293. });
  5294. }
  5295. function ScrollRestoration(_ref10) {
  5296. let {
  5297. getKey,
  5298. storageKey
  5299. } = _ref10;
  5300. useScrollRestoration({
  5301. getKey,
  5302. storageKey
  5303. });
  5304. return null;
  5305. }
  5306. function getDataRouterConsoleError2(hookName) {
  5307. return hookName + " must be used within a data router. See https://reactrouter.com/routers/picking-a-router.";
  5308. }
  5309. function useDataRouterContext2(hookName) {
  5310. let ctx = React2.useContext(DataRouterContext);
  5311. !ctx ? true ? invariant(false, getDataRouterConsoleError2(hookName)) : invariant(false) : void 0;
  5312. return ctx;
  5313. }
  5314. function useDataRouterState2(hookName) {
  5315. let state = React2.useContext(DataRouterStateContext);
  5316. !state ? true ? invariant(false, getDataRouterConsoleError2(hookName)) : invariant(false) : void 0;
  5317. return state;
  5318. }
  5319. function useLinkClickHandler(to, _temp) {
  5320. let {
  5321. target,
  5322. replace: replaceProp,
  5323. state,
  5324. preventScrollReset,
  5325. relative,
  5326. unstable_viewTransition
  5327. } = _temp === void 0 ? {} : _temp;
  5328. let navigate = useNavigate();
  5329. let location = useLocation();
  5330. let path = useResolvedPath(to, {
  5331. relative
  5332. });
  5333. return React2.useCallback((event) => {
  5334. if (shouldProcessLinkClick(event, target)) {
  5335. event.preventDefault();
  5336. let replace = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
  5337. navigate(to, {
  5338. replace,
  5339. state,
  5340. preventScrollReset,
  5341. relative,
  5342. unstable_viewTransition
  5343. });
  5344. }
  5345. }, [location, navigate, path, replaceProp, state, target, to, preventScrollReset, relative, unstable_viewTransition]);
  5346. }
  5347. function useSearchParams(defaultInit) {
  5348. true ? warning(typeof URLSearchParams !== "undefined", "You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params\n\nIf you're unsure how to load polyfills, we recommend you check out https://polyfill.io/v3/ which provides some recommendations about how to load polyfills only for users that need them, instead of for every user.") : void 0;
  5349. let defaultSearchParamsRef = React2.useRef(createSearchParams(defaultInit));
  5350. let hasSetSearchParamsRef = React2.useRef(false);
  5351. let location = useLocation();
  5352. let searchParams = React2.useMemo(() => (
  5353. // Only merge in the defaults if we haven't yet called setSearchParams.
  5354. // Once we call that we want those to take precedence, otherwise you can't
  5355. // remove a param with setSearchParams({}) if it has an initial value
  5356. getSearchParamsForLocation(location.search, hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current)
  5357. ), [location.search]);
  5358. let navigate = useNavigate();
  5359. let setSearchParams = React2.useCallback((nextInit, navigateOptions) => {
  5360. const newSearchParams = createSearchParams(typeof nextInit === "function" ? nextInit(searchParams) : nextInit);
  5361. hasSetSearchParamsRef.current = true;
  5362. navigate("?" + newSearchParams, navigateOptions);
  5363. }, [navigate, searchParams]);
  5364. return [searchParams, setSearchParams];
  5365. }
  5366. function validateClientSideSubmission() {
  5367. if (typeof document === "undefined") {
  5368. throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.");
  5369. }
  5370. }
  5371. function useSubmit() {
  5372. let {
  5373. router: router2
  5374. } = useDataRouterContext2(DataRouterHook2.UseSubmit);
  5375. let {
  5376. basename
  5377. } = React2.useContext(NavigationContext);
  5378. let currentRouteId = useRouteId();
  5379. return React2.useCallback(function(target, options) {
  5380. if (options === void 0) {
  5381. options = {};
  5382. }
  5383. validateClientSideSubmission();
  5384. let {
  5385. action,
  5386. method,
  5387. encType,
  5388. formData,
  5389. body
  5390. } = getFormSubmissionInfo(target, basename);
  5391. if (options.navigate === false) {
  5392. let key = options.fetcherKey || getUniqueFetcherId();
  5393. router2.fetch(key, currentRouteId, options.action || action, {
  5394. preventScrollReset: options.preventScrollReset,
  5395. formData,
  5396. body,
  5397. formMethod: options.method || method,
  5398. formEncType: options.encType || encType,
  5399. unstable_flushSync: options.unstable_flushSync
  5400. });
  5401. } else {
  5402. router2.navigate(options.action || action, {
  5403. preventScrollReset: options.preventScrollReset,
  5404. formData,
  5405. body,
  5406. formMethod: options.method || method,
  5407. formEncType: options.encType || encType,
  5408. replace: options.replace,
  5409. state: options.state,
  5410. fromRouteId: currentRouteId,
  5411. unstable_flushSync: options.unstable_flushSync,
  5412. unstable_viewTransition: options.unstable_viewTransition
  5413. });
  5414. }
  5415. }, [router2, basename, currentRouteId]);
  5416. }
  5417. function useFormAction(action, _temp2) {
  5418. let {
  5419. relative
  5420. } = _temp2 === void 0 ? {} : _temp2;
  5421. let {
  5422. basename
  5423. } = React2.useContext(NavigationContext);
  5424. let routeContext = React2.useContext(RouteContext);
  5425. !routeContext ? true ? invariant(false, "useFormAction must be used inside a RouteContext") : invariant(false) : void 0;
  5426. let [match] = routeContext.matches.slice(-1);
  5427. let path = _extends3({}, useResolvedPath(action ? action : ".", {
  5428. relative
  5429. }));
  5430. let location = useLocation();
  5431. if (action == null) {
  5432. path.search = location.search;
  5433. let params = new URLSearchParams(path.search);
  5434. if (params.has("index") && params.get("index") === "") {
  5435. params.delete("index");
  5436. path.search = params.toString() ? "?" + params.toString() : "";
  5437. }
  5438. }
  5439. if ((!action || action === ".") && match.route.index) {
  5440. path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
  5441. }
  5442. if (basename !== "/") {
  5443. path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
  5444. }
  5445. return createPath(path);
  5446. }
  5447. function useFetcher(_temp3) {
  5448. var _route$matches;
  5449. let {
  5450. key
  5451. } = _temp3 === void 0 ? {} : _temp3;
  5452. let {
  5453. router: router2
  5454. } = useDataRouterContext2(DataRouterHook2.UseFetcher);
  5455. let state = useDataRouterState2(DataRouterStateHook2.UseFetcher);
  5456. let fetcherData = React2.useContext(FetchersContext);
  5457. let route = React2.useContext(RouteContext);
  5458. let routeId = (_route$matches = route.matches[route.matches.length - 1]) == null ? void 0 : _route$matches.route.id;
  5459. !fetcherData ? true ? invariant(false, "useFetcher must be used inside a FetchersContext") : invariant(false) : void 0;
  5460. !route ? true ? invariant(false, "useFetcher must be used inside a RouteContext") : invariant(false) : void 0;
  5461. !(routeId != null) ? true ? invariant(false, 'useFetcher can only be used on routes that contain a unique "id"') : invariant(false) : void 0;
  5462. let defaultKey = useIdImpl ? useIdImpl() : "";
  5463. let [fetcherKey, setFetcherKey] = React2.useState(key || defaultKey);
  5464. if (key && key !== fetcherKey) {
  5465. setFetcherKey(key);
  5466. } else if (!fetcherKey) {
  5467. setFetcherKey(getUniqueFetcherId());
  5468. }
  5469. React2.useEffect(() => {
  5470. router2.getFetcher(fetcherKey);
  5471. return () => {
  5472. router2.deleteFetcher(fetcherKey);
  5473. };
  5474. }, [router2, fetcherKey]);
  5475. let load = React2.useCallback((href, opts) => {
  5476. !routeId ? true ? invariant(false, "No routeId available for fetcher.load()") : invariant(false) : void 0;
  5477. router2.fetch(fetcherKey, routeId, href, opts);
  5478. }, [fetcherKey, routeId, router2]);
  5479. let submitImpl = useSubmit();
  5480. let submit = React2.useCallback((target, opts) => {
  5481. submitImpl(target, _extends3({}, opts, {
  5482. navigate: false,
  5483. fetcherKey
  5484. }));
  5485. }, [fetcherKey, submitImpl]);
  5486. let FetcherForm = React2.useMemo(() => {
  5487. let FetcherForm2 = /* @__PURE__ */ React2.forwardRef((props, ref) => {
  5488. return /* @__PURE__ */ React2.createElement(Form, _extends3({}, props, {
  5489. navigate: false,
  5490. fetcherKey,
  5491. ref
  5492. }));
  5493. });
  5494. if (true) {
  5495. FetcherForm2.displayName = "fetcher.Form";
  5496. }
  5497. return FetcherForm2;
  5498. }, [fetcherKey]);
  5499. let fetcher = state.fetchers.get(fetcherKey) || IDLE_FETCHER;
  5500. let data = fetcherData.get(fetcherKey);
  5501. let fetcherWithComponents = React2.useMemo(() => _extends3({
  5502. Form: FetcherForm,
  5503. submit,
  5504. load
  5505. }, fetcher, {
  5506. data
  5507. }), [FetcherForm, submit, load, fetcher, data]);
  5508. return fetcherWithComponents;
  5509. }
  5510. function useFetchers() {
  5511. let state = useDataRouterState2(DataRouterStateHook2.UseFetchers);
  5512. return Array.from(state.fetchers.entries()).map((_ref11) => {
  5513. let [key, fetcher] = _ref11;
  5514. return _extends3({}, fetcher, {
  5515. key
  5516. });
  5517. });
  5518. }
  5519. function useScrollRestoration(_temp4) {
  5520. let {
  5521. getKey,
  5522. storageKey
  5523. } = _temp4 === void 0 ? {} : _temp4;
  5524. let {
  5525. router: router2
  5526. } = useDataRouterContext2(DataRouterHook2.UseScrollRestoration);
  5527. let {
  5528. restoreScrollPosition,
  5529. preventScrollReset
  5530. } = useDataRouterState2(DataRouterStateHook2.UseScrollRestoration);
  5531. let {
  5532. basename
  5533. } = React2.useContext(NavigationContext);
  5534. let location = useLocation();
  5535. let matches = useMatches();
  5536. let navigation = useNavigation();
  5537. React2.useEffect(() => {
  5538. window.history.scrollRestoration = "manual";
  5539. return () => {
  5540. window.history.scrollRestoration = "auto";
  5541. };
  5542. }, []);
  5543. usePageHide(React2.useCallback(() => {
  5544. if (navigation.state === "idle") {
  5545. let key = (getKey ? getKey(location, matches) : null) || location.key;
  5546. savedScrollPositions[key] = window.scrollY;
  5547. }
  5548. try {
  5549. sessionStorage.setItem(storageKey || SCROLL_RESTORATION_STORAGE_KEY, JSON.stringify(savedScrollPositions));
  5550. } catch (error) {
  5551. true ? warning(false, "Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (" + error + ").") : void 0;
  5552. }
  5553. window.history.scrollRestoration = "auto";
  5554. }, [storageKey, getKey, navigation.state, location, matches]));
  5555. if (typeof document !== "undefined") {
  5556. React2.useLayoutEffect(() => {
  5557. try {
  5558. let sessionPositions = sessionStorage.getItem(storageKey || SCROLL_RESTORATION_STORAGE_KEY);
  5559. if (sessionPositions) {
  5560. savedScrollPositions = JSON.parse(sessionPositions);
  5561. }
  5562. } catch (e) {
  5563. }
  5564. }, [storageKey]);
  5565. React2.useLayoutEffect(() => {
  5566. let getKeyWithoutBasename = getKey && basename !== "/" ? (location2, matches2) => getKey(
  5567. // Strip the basename to match useLocation()
  5568. _extends3({}, location2, {
  5569. pathname: stripBasename(location2.pathname, basename) || location2.pathname
  5570. }),
  5571. matches2
  5572. ) : getKey;
  5573. let disableScrollRestoration = router2 == null ? void 0 : router2.enableScrollRestoration(savedScrollPositions, () => window.scrollY, getKeyWithoutBasename);
  5574. return () => disableScrollRestoration && disableScrollRestoration();
  5575. }, [router2, basename, getKey]);
  5576. React2.useLayoutEffect(() => {
  5577. if (restoreScrollPosition === false) {
  5578. return;
  5579. }
  5580. if (typeof restoreScrollPosition === "number") {
  5581. window.scrollTo(0, restoreScrollPosition);
  5582. return;
  5583. }
  5584. if (location.hash) {
  5585. let el = document.getElementById(decodeURIComponent(location.hash.slice(1)));
  5586. if (el) {
  5587. el.scrollIntoView();
  5588. return;
  5589. }
  5590. }
  5591. if (preventScrollReset === true) {
  5592. return;
  5593. }
  5594. window.scrollTo(0, 0);
  5595. }, [location, restoreScrollPosition, preventScrollReset]);
  5596. }
  5597. }
  5598. function useBeforeUnload(callback, options) {
  5599. let {
  5600. capture
  5601. } = options || {};
  5602. React2.useEffect(() => {
  5603. let opts = capture != null ? {
  5604. capture
  5605. } : void 0;
  5606. window.addEventListener("beforeunload", callback, opts);
  5607. return () => {
  5608. window.removeEventListener("beforeunload", callback, opts);
  5609. };
  5610. }, [callback, capture]);
  5611. }
  5612. function usePageHide(callback, options) {
  5613. let {
  5614. capture
  5615. } = options || {};
  5616. React2.useEffect(() => {
  5617. let opts = capture != null ? {
  5618. capture
  5619. } : void 0;
  5620. window.addEventListener("pagehide", callback, opts);
  5621. return () => {
  5622. window.removeEventListener("pagehide", callback, opts);
  5623. };
  5624. }, [callback, capture]);
  5625. }
  5626. function usePrompt(_ref12) {
  5627. let {
  5628. when,
  5629. message
  5630. } = _ref12;
  5631. let blocker = useBlocker(when);
  5632. React2.useEffect(() => {
  5633. if (blocker.state === "blocked") {
  5634. let proceed = window.confirm(message);
  5635. if (proceed) {
  5636. setTimeout(blocker.proceed, 0);
  5637. } else {
  5638. blocker.reset();
  5639. }
  5640. }
  5641. }, [blocker, message]);
  5642. React2.useEffect(() => {
  5643. if (blocker.state === "blocked" && !when) {
  5644. blocker.reset();
  5645. }
  5646. }, [blocker, when]);
  5647. }
  5648. function useViewTransitionState(to, opts) {
  5649. if (opts === void 0) {
  5650. opts = {};
  5651. }
  5652. let vtContext = React2.useContext(ViewTransitionContext);
  5653. !(vtContext != null) ? true ? invariant(false, "`unstable_useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?") : invariant(false) : void 0;
  5654. let {
  5655. basename
  5656. } = useDataRouterContext2(DataRouterHook2.useViewTransitionState);
  5657. let path = useResolvedPath(to, {
  5658. relative: opts.relative
  5659. });
  5660. if (!vtContext.isTransitioning) {
  5661. return false;
  5662. }
  5663. let currentPath = stripBasename(vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
  5664. let nextPath = stripBasename(vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
  5665. return matchPath(path.pathname, nextPath) != null || matchPath(path.pathname, currentPath) != null;
  5666. }
  5667. var React2, ReactDOM, defaultMethod, defaultEncType, _formDataSupportsSubmitter, supportedFormEncTypes, _excluded, _excluded2, _excluded3, REACT_ROUTER_VERSION, ViewTransitionContext, FetchersContext, START_TRANSITION2, startTransitionImpl2, FLUSH_SYNC, flushSyncImpl, USE_ID, useIdImpl, Deferred, isBrowser, ABSOLUTE_URL_REGEX2, Link, NavLink, Form, DataRouterHook2, DataRouterStateHook2, fetcherId, getUniqueFetcherId, SCROLL_RESTORATION_STORAGE_KEY, savedScrollPositions;
  5668. var init_dist2 = __esm({
  5669. "node_modules/react-router-dom/dist/index.js"() {
  5670. React2 = __toESM(require_react());
  5671. ReactDOM = __toESM(require_react_dom());
  5672. init_dist();
  5673. init_dist();
  5674. init_router();
  5675. defaultMethod = "get";
  5676. defaultEncType = "application/x-www-form-urlencoded";
  5677. _formDataSupportsSubmitter = null;
  5678. supportedFormEncTypes = /* @__PURE__ */ new Set(["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"]);
  5679. _excluded = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset", "unstable_viewTransition"];
  5680. _excluded2 = ["aria-current", "caseSensitive", "className", "end", "style", "to", "unstable_viewTransition", "children"];
  5681. _excluded3 = ["fetcherKey", "navigate", "reloadDocument", "replace", "state", "method", "action", "onSubmit", "relative", "preventScrollReset", "unstable_viewTransition"];
  5682. REACT_ROUTER_VERSION = "6";
  5683. try {
  5684. window.__reactRouterVersion = REACT_ROUTER_VERSION;
  5685. } catch (e) {
  5686. }
  5687. ViewTransitionContext = /* @__PURE__ */ React2.createContext({
  5688. isTransitioning: false
  5689. });
  5690. if (true) {
  5691. ViewTransitionContext.displayName = "ViewTransition";
  5692. }
  5693. FetchersContext = /* @__PURE__ */ React2.createContext(/* @__PURE__ */ new Map());
  5694. if (true) {
  5695. FetchersContext.displayName = "Fetchers";
  5696. }
  5697. START_TRANSITION2 = "startTransition";
  5698. startTransitionImpl2 = React2[START_TRANSITION2];
  5699. FLUSH_SYNC = "flushSync";
  5700. flushSyncImpl = ReactDOM[FLUSH_SYNC];
  5701. USE_ID = "useId";
  5702. useIdImpl = React2[USE_ID];
  5703. Deferred = class {
  5704. constructor() {
  5705. this.status = "pending";
  5706. this.promise = new Promise((resolve, reject) => {
  5707. this.resolve = (value) => {
  5708. if (this.status === "pending") {
  5709. this.status = "resolved";
  5710. resolve(value);
  5711. }
  5712. };
  5713. this.reject = (reason) => {
  5714. if (this.status === "pending") {
  5715. this.status = "rejected";
  5716. reject(reason);
  5717. }
  5718. };
  5719. });
  5720. }
  5721. };
  5722. if (true) {
  5723. HistoryRouter.displayName = "unstable_HistoryRouter";
  5724. }
  5725. isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
  5726. ABSOLUTE_URL_REGEX2 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
  5727. Link = /* @__PURE__ */ React2.forwardRef(function LinkWithRef(_ref7, ref) {
  5728. let {
  5729. onClick,
  5730. relative,
  5731. reloadDocument,
  5732. replace,
  5733. state,
  5734. target,
  5735. to,
  5736. preventScrollReset,
  5737. unstable_viewTransition
  5738. } = _ref7, rest = _objectWithoutPropertiesLoose(_ref7, _excluded);
  5739. let {
  5740. basename
  5741. } = React2.useContext(NavigationContext);
  5742. let absoluteHref;
  5743. let isExternal = false;
  5744. if (typeof to === "string" && ABSOLUTE_URL_REGEX2.test(to)) {
  5745. absoluteHref = to;
  5746. if (isBrowser) {
  5747. try {
  5748. let currentUrl = new URL(window.location.href);
  5749. let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
  5750. let path = stripBasename(targetUrl.pathname, basename);
  5751. if (targetUrl.origin === currentUrl.origin && path != null) {
  5752. to = path + targetUrl.search + targetUrl.hash;
  5753. } else {
  5754. isExternal = true;
  5755. }
  5756. } catch (e) {
  5757. true ? warning(false, '<Link to="' + to + '"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.') : void 0;
  5758. }
  5759. }
  5760. }
  5761. let href = useHref(to, {
  5762. relative
  5763. });
  5764. let internalOnClick = useLinkClickHandler(to, {
  5765. replace,
  5766. state,
  5767. target,
  5768. preventScrollReset,
  5769. relative,
  5770. unstable_viewTransition
  5771. });
  5772. function handleClick(event) {
  5773. if (onClick)
  5774. onClick(event);
  5775. if (!event.defaultPrevented) {
  5776. internalOnClick(event);
  5777. }
  5778. }
  5779. return (
  5780. // eslint-disable-next-line jsx-a11y/anchor-has-content
  5781. /* @__PURE__ */ React2.createElement("a", _extends3({}, rest, {
  5782. href: absoluteHref || href,
  5783. onClick: isExternal || reloadDocument ? onClick : handleClick,
  5784. ref,
  5785. target
  5786. }))
  5787. );
  5788. });
  5789. if (true) {
  5790. Link.displayName = "Link";
  5791. }
  5792. NavLink = /* @__PURE__ */ React2.forwardRef(function NavLinkWithRef(_ref8, ref) {
  5793. let {
  5794. "aria-current": ariaCurrentProp = "page",
  5795. caseSensitive = false,
  5796. className: classNameProp = "",
  5797. end = false,
  5798. style: styleProp,
  5799. to,
  5800. unstable_viewTransition,
  5801. children
  5802. } = _ref8, rest = _objectWithoutPropertiesLoose(_ref8, _excluded2);
  5803. let path = useResolvedPath(to, {
  5804. relative: rest.relative
  5805. });
  5806. let location = useLocation();
  5807. let routerState = React2.useContext(DataRouterStateContext);
  5808. let {
  5809. navigator,
  5810. basename
  5811. } = React2.useContext(NavigationContext);
  5812. let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
  5813. // eslint-disable-next-line react-hooks/rules-of-hooks
  5814. useViewTransitionState(path) && unstable_viewTransition === true;
  5815. let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
  5816. let locationPathname = location.pathname;
  5817. let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
  5818. if (!caseSensitive) {
  5819. locationPathname = locationPathname.toLowerCase();
  5820. nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
  5821. toPathname = toPathname.toLowerCase();
  5822. }
  5823. if (nextLocationPathname && basename) {
  5824. nextLocationPathname = stripBasename(nextLocationPathname, basename) || nextLocationPathname;
  5825. }
  5826. const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
  5827. let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
  5828. let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
  5829. let renderProps = {
  5830. isActive,
  5831. isPending,
  5832. isTransitioning
  5833. };
  5834. let ariaCurrent = isActive ? ariaCurrentProp : void 0;
  5835. let className;
  5836. if (typeof classNameProp === "function") {
  5837. className = classNameProp(renderProps);
  5838. } else {
  5839. className = [classNameProp, isActive ? "active" : null, isPending ? "pending" : null, isTransitioning ? "transitioning" : null].filter(Boolean).join(" ");
  5840. }
  5841. let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
  5842. return /* @__PURE__ */ React2.createElement(Link, _extends3({}, rest, {
  5843. "aria-current": ariaCurrent,
  5844. className,
  5845. ref,
  5846. style,
  5847. to,
  5848. unstable_viewTransition
  5849. }), typeof children === "function" ? children(renderProps) : children);
  5850. });
  5851. if (true) {
  5852. NavLink.displayName = "NavLink";
  5853. }
  5854. Form = /* @__PURE__ */ React2.forwardRef((_ref9, forwardedRef) => {
  5855. let {
  5856. fetcherKey,
  5857. navigate,
  5858. reloadDocument,
  5859. replace,
  5860. state,
  5861. method = defaultMethod,
  5862. action,
  5863. onSubmit,
  5864. relative,
  5865. preventScrollReset,
  5866. unstable_viewTransition
  5867. } = _ref9, props = _objectWithoutPropertiesLoose(_ref9, _excluded3);
  5868. let submit = useSubmit();
  5869. let formAction = useFormAction(action, {
  5870. relative
  5871. });
  5872. let formMethod = method.toLowerCase() === "get" ? "get" : "post";
  5873. let submitHandler = (event) => {
  5874. onSubmit && onSubmit(event);
  5875. if (event.defaultPrevented)
  5876. return;
  5877. event.preventDefault();
  5878. let submitter = event.nativeEvent.submitter;
  5879. let submitMethod = (submitter == null ? void 0 : submitter.getAttribute("formmethod")) || method;
  5880. submit(submitter || event.currentTarget, {
  5881. fetcherKey,
  5882. method: submitMethod,
  5883. navigate,
  5884. replace,
  5885. state,
  5886. relative,
  5887. preventScrollReset,
  5888. unstable_viewTransition
  5889. });
  5890. };
  5891. return /* @__PURE__ */ React2.createElement("form", _extends3({
  5892. ref: forwardedRef,
  5893. method: formMethod,
  5894. action: formAction,
  5895. onSubmit: reloadDocument ? onSubmit : submitHandler
  5896. }, props));
  5897. });
  5898. if (true) {
  5899. Form.displayName = "Form";
  5900. }
  5901. if (true) {
  5902. ScrollRestoration.displayName = "ScrollRestoration";
  5903. }
  5904. (function(DataRouterHook3) {
  5905. DataRouterHook3["UseScrollRestoration"] = "useScrollRestoration";
  5906. DataRouterHook3["UseSubmit"] = "useSubmit";
  5907. DataRouterHook3["UseSubmitFetcher"] = "useSubmitFetcher";
  5908. DataRouterHook3["UseFetcher"] = "useFetcher";
  5909. DataRouterHook3["useViewTransitionState"] = "useViewTransitionState";
  5910. })(DataRouterHook2 || (DataRouterHook2 = {}));
  5911. (function(DataRouterStateHook3) {
  5912. DataRouterStateHook3["UseFetcher"] = "useFetcher";
  5913. DataRouterStateHook3["UseFetchers"] = "useFetchers";
  5914. DataRouterStateHook3["UseScrollRestoration"] = "useScrollRestoration";
  5915. })(DataRouterStateHook2 || (DataRouterStateHook2 = {}));
  5916. fetcherId = 0;
  5917. getUniqueFetcherId = () => "__" + String(++fetcherId) + "__";
  5918. SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
  5919. savedScrollPositions = {};
  5920. }
  5921. });
  5922. // node_modules/react-router-dom/server.js
  5923. var require_server = __commonJS({
  5924. "node_modules/react-router-dom/server.js"(exports) {
  5925. "use strict";
  5926. Object.defineProperty(exports, "__esModule", { value: true });
  5927. var React10 = require_react();
  5928. var router2 = (init_router(), __toCommonJS(router_exports));
  5929. var reactRouter = (init_dist(), __toCommonJS(dist_exports));
  5930. var reactRouterDom = (init_dist2(), __toCommonJS(dist_exports2));
  5931. function _interopNamespace(e) {
  5932. if (e && e.__esModule)
  5933. return e;
  5934. var n = /* @__PURE__ */ Object.create(null);
  5935. if (e) {
  5936. Object.keys(e).forEach(function(k) {
  5937. if (k !== "default") {
  5938. var d = Object.getOwnPropertyDescriptor(e, k);
  5939. Object.defineProperty(n, k, d.get ? d : {
  5940. enumerable: true,
  5941. get: function() {
  5942. return e[k];
  5943. }
  5944. });
  5945. }
  5946. });
  5947. }
  5948. n["default"] = e;
  5949. return Object.freeze(n);
  5950. }
  5951. var React__namespace = /* @__PURE__ */ _interopNamespace(React10);
  5952. function StaticRouter({
  5953. basename,
  5954. children,
  5955. location: locationProp = "/",
  5956. future
  5957. }) {
  5958. if (typeof locationProp === "string") {
  5959. locationProp = reactRouterDom.parsePath(locationProp);
  5960. }
  5961. let action = router2.Action.Pop;
  5962. let location = {
  5963. pathname: locationProp.pathname || "/",
  5964. search: locationProp.search || "",
  5965. hash: locationProp.hash || "",
  5966. state: locationProp.state || null,
  5967. key: locationProp.key || "default"
  5968. };
  5969. let staticNavigator = getStatelessNavigator();
  5970. return /* @__PURE__ */ React__namespace.createElement(reactRouterDom.Router, {
  5971. basename,
  5972. children,
  5973. location,
  5974. navigationType: action,
  5975. navigator: staticNavigator,
  5976. future,
  5977. static: true
  5978. });
  5979. }
  5980. function StaticRouterProvider2({
  5981. context,
  5982. router: router$1,
  5983. hydrate = true,
  5984. nonce
  5985. }) {
  5986. !(router$1 && context) ? true ? router2.UNSAFE_invariant(false, "You must provide `router` and `context` to <StaticRouterProvider>") : router2.UNSAFE_invariant(false) : void 0;
  5987. let dataRouterContext = {
  5988. router: router$1,
  5989. navigator: getStatelessNavigator(),
  5990. static: true,
  5991. staticContext: context,
  5992. basename: context.basename || "/"
  5993. };
  5994. let fetchersContext = /* @__PURE__ */ new Map();
  5995. let hydrateScript = "";
  5996. if (hydrate !== false) {
  5997. let data = {
  5998. loaderData: context.loaderData,
  5999. actionData: context.actionData,
  6000. errors: serializeErrors(context.errors)
  6001. };
  6002. let json4 = htmlEscape(JSON.stringify(JSON.stringify(data)));
  6003. hydrateScript = `window.__staticRouterHydrationData = JSON.parse(${json4});`;
  6004. }
  6005. let {
  6006. state
  6007. } = dataRouterContext.router;
  6008. return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement(reactRouterDom.UNSAFE_DataRouterContext.Provider, {
  6009. value: dataRouterContext
  6010. }, /* @__PURE__ */ React__namespace.createElement(reactRouterDom.UNSAFE_DataRouterStateContext.Provider, {
  6011. value: state
  6012. }, /* @__PURE__ */ React__namespace.createElement(reactRouterDom.UNSAFE_FetchersContext.Provider, {
  6013. value: fetchersContext
  6014. }, /* @__PURE__ */ React__namespace.createElement(reactRouterDom.UNSAFE_ViewTransitionContext.Provider, {
  6015. value: {
  6016. isTransitioning: false
  6017. }
  6018. }, /* @__PURE__ */ React__namespace.createElement(reactRouterDom.Router, {
  6019. basename: dataRouterContext.basename,
  6020. location: state.location,
  6021. navigationType: state.historyAction,
  6022. navigator: dataRouterContext.navigator,
  6023. static: dataRouterContext.static,
  6024. future: {
  6025. v7_relativeSplatPath: router$1.future.v7_relativeSplatPath
  6026. }
  6027. }, /* @__PURE__ */ React__namespace.createElement(DataRoutes3, {
  6028. routes: router$1.routes,
  6029. future: router$1.future,
  6030. state
  6031. })))))), hydrateScript ? /* @__PURE__ */ React__namespace.createElement("script", {
  6032. suppressHydrationWarning: true,
  6033. nonce,
  6034. dangerouslySetInnerHTML: {
  6035. __html: hydrateScript
  6036. }
  6037. }) : null);
  6038. }
  6039. function DataRoutes3({
  6040. routes,
  6041. future,
  6042. state
  6043. }) {
  6044. return reactRouter.UNSAFE_useRoutesImpl(routes, void 0, state, future);
  6045. }
  6046. function serializeErrors(errors) {
  6047. if (!errors)
  6048. return null;
  6049. let entries = Object.entries(errors);
  6050. let serialized = {};
  6051. for (let [key, val] of entries) {
  6052. if (router2.isRouteErrorResponse(val)) {
  6053. serialized[key] = {
  6054. ...val,
  6055. __type: "RouteErrorResponse"
  6056. };
  6057. } else if (val instanceof Error) {
  6058. serialized[key] = {
  6059. message: val.message,
  6060. __type: "Error",
  6061. // If this is a subclass (i.e., ReferenceError), send up the type so we
  6062. // can re-create the same type during hydration.
  6063. ...val.name !== "Error" ? {
  6064. __subType: val.name
  6065. } : {}
  6066. };
  6067. } else {
  6068. serialized[key] = val;
  6069. }
  6070. }
  6071. return serialized;
  6072. }
  6073. function getStatelessNavigator() {
  6074. return {
  6075. createHref,
  6076. encodeLocation,
  6077. push(to) {
  6078. throw new Error(`You cannot use navigator.push() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${JSON.stringify(to)})\` somewhere in your app.`);
  6079. },
  6080. replace(to) {
  6081. throw new Error(`You cannot use navigator.replace() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${JSON.stringify(to)}, { replace: true })\` somewhere in your app.`);
  6082. },
  6083. go(delta) {
  6084. throw new Error(`You cannot use navigator.go() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${delta})\` somewhere in your app.`);
  6085. },
  6086. back() {
  6087. throw new Error(`You cannot use navigator.back() on the server because it is a stateless environment.`);
  6088. },
  6089. forward() {
  6090. throw new Error(`You cannot use navigator.forward() on the server because it is a stateless environment.`);
  6091. }
  6092. };
  6093. }
  6094. function createStaticHandler2(routes, opts) {
  6095. return router2.createStaticHandler(routes, {
  6096. ...opts,
  6097. mapRouteProperties: reactRouter.UNSAFE_mapRouteProperties
  6098. });
  6099. }
  6100. function createStaticRouter2(routes, context, opts = {}) {
  6101. let manifest = {};
  6102. let dataRoutes = router2.UNSAFE_convertRoutesToDataRoutes(routes, reactRouter.UNSAFE_mapRouteProperties, void 0, manifest);
  6103. let matches = context.matches.map((match) => {
  6104. let route = manifest[match.route.id] || match.route;
  6105. return {
  6106. ...match,
  6107. route
  6108. };
  6109. });
  6110. let msg = (method) => `You cannot use router.${method}() on the server because it is a stateless environment`;
  6111. return {
  6112. get basename() {
  6113. return context.basename;
  6114. },
  6115. get future() {
  6116. return {
  6117. v7_fetcherPersist: false,
  6118. v7_normalizeFormMethod: false,
  6119. v7_partialHydration: opts.future?.v7_partialHydration === true,
  6120. v7_prependBasename: false,
  6121. v7_relativeSplatPath: opts.future?.v7_relativeSplatPath === true
  6122. };
  6123. },
  6124. get state() {
  6125. return {
  6126. historyAction: router2.Action.Pop,
  6127. location: context.location,
  6128. matches,
  6129. loaderData: context.loaderData,
  6130. actionData: context.actionData,
  6131. errors: context.errors,
  6132. initialized: true,
  6133. navigation: router2.IDLE_NAVIGATION,
  6134. restoreScrollPosition: null,
  6135. preventScrollReset: false,
  6136. revalidation: "idle",
  6137. fetchers: /* @__PURE__ */ new Map(),
  6138. blockers: /* @__PURE__ */ new Map()
  6139. };
  6140. },
  6141. get routes() {
  6142. return dataRoutes;
  6143. },
  6144. get window() {
  6145. return void 0;
  6146. },
  6147. initialize() {
  6148. throw msg("initialize");
  6149. },
  6150. subscribe() {
  6151. throw msg("subscribe");
  6152. },
  6153. enableScrollRestoration() {
  6154. throw msg("enableScrollRestoration");
  6155. },
  6156. navigate() {
  6157. throw msg("navigate");
  6158. },
  6159. fetch() {
  6160. throw msg("fetch");
  6161. },
  6162. revalidate() {
  6163. throw msg("revalidate");
  6164. },
  6165. createHref,
  6166. encodeLocation,
  6167. getFetcher() {
  6168. return router2.IDLE_FETCHER;
  6169. },
  6170. deleteFetcher() {
  6171. throw msg("deleteFetcher");
  6172. },
  6173. dispose() {
  6174. throw msg("dispose");
  6175. },
  6176. getBlocker() {
  6177. return router2.IDLE_BLOCKER;
  6178. },
  6179. deleteBlocker() {
  6180. throw msg("deleteBlocker");
  6181. },
  6182. _internalFetchControllers: /* @__PURE__ */ new Map(),
  6183. _internalActiveDeferreds: /* @__PURE__ */ new Map(),
  6184. _internalSetRoutes() {
  6185. throw msg("_internalSetRoutes");
  6186. }
  6187. };
  6188. }
  6189. function createHref(to) {
  6190. return typeof to === "string" ? to : reactRouterDom.createPath(to);
  6191. }
  6192. function encodeLocation(to) {
  6193. let href = typeof to === "string" ? to : reactRouterDom.createPath(to);
  6194. let encoded = ABSOLUTE_URL_REGEX4.test(href) ? new URL(href) : new URL(href, "http://localhost");
  6195. return {
  6196. pathname: encoded.pathname,
  6197. search: encoded.search,
  6198. hash: encoded.hash
  6199. };
  6200. }
  6201. var ABSOLUTE_URL_REGEX4 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
  6202. var ESCAPE_LOOKUP2 = {
  6203. "&": "\\u0026",
  6204. ">": "\\u003e",
  6205. "<": "\\u003c",
  6206. "\u2028": "\\u2028",
  6207. "\u2029": "\\u2029"
  6208. };
  6209. var ESCAPE_REGEX2 = /[&><\u2028\u2029]/g;
  6210. function htmlEscape(str) {
  6211. return str.replace(ESCAPE_REGEX2, (match) => ESCAPE_LOOKUP2[match]);
  6212. }
  6213. exports.StaticRouter = StaticRouter;
  6214. exports.StaticRouterProvider = StaticRouterProvider2;
  6215. exports.createStaticHandler = createStaticHandler2;
  6216. exports.createStaticRouter = createStaticRouter2;
  6217. }
  6218. });
  6219. // node_modules/@remix-run/react/dist/esm/index.js
  6220. init_dist2();
  6221. // node_modules/@remix-run/server-runtime/dist/esm/responses.js
  6222. init_router();
  6223. var json3 = (data, init = {}) => {
  6224. return json(data, init);
  6225. };
  6226. var defer3 = (data, init = {}) => {
  6227. return defer(data, init);
  6228. };
  6229. var redirect3 = (url, init = 302) => {
  6230. return redirect(url, init);
  6231. };
  6232. var redirectDocument2 = (url, init = 302) => {
  6233. return redirectDocument(url, init);
  6234. };
  6235. // node_modules/@remix-run/react/dist/esm/browser.js
  6236. init_router();
  6237. var React7 = __toESM(require_react());
  6238. init_dist();
  6239. init_dist2();
  6240. // node_modules/@remix-run/react/dist/esm/_virtual/_rollupPluginBabelHelpers.js
  6241. function _extends4() {
  6242. _extends4 = Object.assign ? Object.assign.bind() : function(target) {
  6243. for (var i = 1; i < arguments.length; i++) {
  6244. var source = arguments[i];
  6245. for (var key in source) {
  6246. if (Object.prototype.hasOwnProperty.call(source, key)) {
  6247. target[key] = source[key];
  6248. }
  6249. }
  6250. }
  6251. return target;
  6252. };
  6253. return _extends4.apply(this, arguments);
  6254. }
  6255. // node_modules/@remix-run/react/dist/esm/components.js
  6256. var React3 = __toESM(require_react());
  6257. init_dist2();
  6258. // node_modules/@remix-run/react/dist/esm/invariant.js
  6259. function invariant2(value, message) {
  6260. if (value === false || value === null || typeof value === "undefined") {
  6261. throw new Error(message);
  6262. }
  6263. }
  6264. // node_modules/@remix-run/react/dist/esm/links.js
  6265. init_dist2();
  6266. // node_modules/@remix-run/react/dist/esm/routeModules.js
  6267. async function loadRouteModule(route, routeModulesCache) {
  6268. if (route.id in routeModulesCache) {
  6269. return routeModulesCache[route.id];
  6270. }
  6271. try {
  6272. let routeModule = await import(
  6273. /* webpackIgnore: true */
  6274. route.module
  6275. );
  6276. routeModulesCache[route.id] = routeModule;
  6277. return routeModule;
  6278. } catch (error) {
  6279. if (window.__remixContext.isSpaMode && // @ts-expect-error
  6280. typeof import.meta.hot !== "undefined") {
  6281. console.error(`Error loading route module \`${route.module}\`:`, error);
  6282. throw error;
  6283. }
  6284. window.location.reload();
  6285. return new Promise(() => {
  6286. });
  6287. }
  6288. }
  6289. // node_modules/@remix-run/react/dist/esm/links.js
  6290. function getKeyedLinksForMatches(matches, routeModules, manifest) {
  6291. let descriptors = matches.map((match) => {
  6292. var _module$links;
  6293. let module = routeModules[match.route.id];
  6294. let route = manifest.routes[match.route.id];
  6295. return [route.css ? route.css.map((href) => ({
  6296. rel: "stylesheet",
  6297. href
  6298. })) : [], (module === null || module === void 0 ? void 0 : (_module$links = module.links) === null || _module$links === void 0 ? void 0 : _module$links.call(module)) || []];
  6299. }).flat(2);
  6300. let preloads = getCurrentPageModulePreloadHrefs(matches, manifest);
  6301. return dedupeLinkDescriptors(descriptors, preloads);
  6302. }
  6303. async function prefetchStyleLinks(route, routeModule) {
  6304. var _route$css, _routeModule$links;
  6305. if (!route.css && !routeModule.links || !isPreloadSupported())
  6306. return;
  6307. let descriptors = [((_route$css = route.css) === null || _route$css === void 0 ? void 0 : _route$css.map((href) => ({
  6308. rel: "stylesheet",
  6309. href
  6310. }))) ?? [], ((_routeModule$links = routeModule.links) === null || _routeModule$links === void 0 ? void 0 : _routeModule$links.call(routeModule)) ?? []].flat(1);
  6311. if (descriptors.length === 0)
  6312. return;
  6313. let styleLinks = [];
  6314. for (let descriptor of descriptors) {
  6315. if (!isPageLinkDescriptor(descriptor) && descriptor.rel === "stylesheet") {
  6316. styleLinks.push({
  6317. ...descriptor,
  6318. rel: "preload",
  6319. as: "style"
  6320. });
  6321. }
  6322. }
  6323. let matchingLinks = styleLinks.filter((link) => (!link.media || window.matchMedia(link.media).matches) && !document.querySelector(`link[rel="stylesheet"][href="${link.href}"]`));
  6324. await Promise.all(matchingLinks.map(prefetchStyleLink));
  6325. }
  6326. async function prefetchStyleLink(descriptor) {
  6327. return new Promise((resolve) => {
  6328. let link = document.createElement("link");
  6329. Object.assign(link, descriptor);
  6330. function removeLink() {
  6331. if (document.head.contains(link)) {
  6332. document.head.removeChild(link);
  6333. }
  6334. }
  6335. link.onload = () => {
  6336. removeLink();
  6337. resolve();
  6338. };
  6339. link.onerror = () => {
  6340. removeLink();
  6341. resolve();
  6342. };
  6343. document.head.appendChild(link);
  6344. });
  6345. }
  6346. function isPageLinkDescriptor(object) {
  6347. return object != null && typeof object.page === "string";
  6348. }
  6349. function isHtmlLinkDescriptor(object) {
  6350. if (object == null) {
  6351. return false;
  6352. }
  6353. if (object.href == null) {
  6354. return object.rel === "preload" && typeof object.imageSrcSet === "string" && typeof object.imageSizes === "string";
  6355. }
  6356. return typeof object.rel === "string" && typeof object.href === "string";
  6357. }
  6358. async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
  6359. let links = await Promise.all(matches.map(async (match) => {
  6360. let mod = await loadRouteModule(manifest.routes[match.route.id], routeModules);
  6361. return mod.links ? mod.links() : [];
  6362. }));
  6363. return dedupeLinkDescriptors(links.flat(1).filter(isHtmlLinkDescriptor).filter((link) => link.rel === "stylesheet" || link.rel === "preload").map((link) => link.rel === "stylesheet" ? {
  6364. ...link,
  6365. rel: "prefetch",
  6366. as: "style"
  6367. } : {
  6368. ...link,
  6369. rel: "prefetch"
  6370. }));
  6371. }
  6372. function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location, mode) {
  6373. let path = parsePathPatch(page);
  6374. let isNew = (match, index) => {
  6375. if (!currentMatches[index])
  6376. return true;
  6377. return match.route.id !== currentMatches[index].route.id;
  6378. };
  6379. let matchPathChanged = (match, index) => {
  6380. var _currentMatches$index;
  6381. return (
  6382. // param change, /users/123 -> /users/456
  6383. currentMatches[index].pathname !== match.pathname || // splat param changed, which is not present in match.path
  6384. // e.g. /files/images/avatar.jpg -> files/finances.xls
  6385. ((_currentMatches$index = currentMatches[index].route.path) === null || _currentMatches$index === void 0 ? void 0 : _currentMatches$index.endsWith("*")) && currentMatches[index].params["*"] !== match.params["*"]
  6386. );
  6387. };
  6388. let newMatches = mode === "data" && location.search !== path.search ? (
  6389. // this is really similar to stuff in transition.ts, maybe somebody smarter
  6390. // than me (or in less of a hurry) can share some of it. You're the best.
  6391. nextMatches.filter((match, index) => {
  6392. let manifestRoute = manifest.routes[match.route.id];
  6393. if (!manifestRoute.hasLoader) {
  6394. return false;
  6395. }
  6396. if (isNew(match, index) || matchPathChanged(match, index)) {
  6397. return true;
  6398. }
  6399. if (match.route.shouldRevalidate) {
  6400. var _currentMatches$;
  6401. let routeChoice = match.route.shouldRevalidate({
  6402. currentUrl: new URL(location.pathname + location.search + location.hash, window.origin),
  6403. currentParams: ((_currentMatches$ = currentMatches[0]) === null || _currentMatches$ === void 0 ? void 0 : _currentMatches$.params) || {},
  6404. nextUrl: new URL(page, window.origin),
  6405. nextParams: match.params,
  6406. defaultShouldRevalidate: true
  6407. });
  6408. if (typeof routeChoice === "boolean") {
  6409. return routeChoice;
  6410. }
  6411. }
  6412. return true;
  6413. })
  6414. ) : nextMatches.filter((match, index) => {
  6415. let manifestRoute = manifest.routes[match.route.id];
  6416. return (mode === "assets" || manifestRoute.hasLoader) && (isNew(match, index) || matchPathChanged(match, index));
  6417. });
  6418. return newMatches;
  6419. }
  6420. function getDataLinkHrefs(page, matches, manifest) {
  6421. let path = parsePathPatch(page);
  6422. return dedupeHrefs(matches.filter((match) => manifest.routes[match.route.id].hasLoader).map((match) => {
  6423. let {
  6424. pathname,
  6425. search
  6426. } = path;
  6427. let searchParams = new URLSearchParams(search);
  6428. searchParams.set("_data", match.route.id);
  6429. return `${pathname}?${searchParams}`;
  6430. }));
  6431. }
  6432. function getModuleLinkHrefs(matches, manifestPatch) {
  6433. return dedupeHrefs(matches.map((match) => {
  6434. let route = manifestPatch.routes[match.route.id];
  6435. let hrefs = [route.module];
  6436. if (route.imports) {
  6437. hrefs = hrefs.concat(route.imports);
  6438. }
  6439. return hrefs;
  6440. }).flat(1));
  6441. }
  6442. function getCurrentPageModulePreloadHrefs(matches, manifest) {
  6443. return dedupeHrefs(matches.map((match) => {
  6444. let route = manifest.routes[match.route.id];
  6445. let hrefs = [route.module];
  6446. if (route.imports) {
  6447. hrefs = hrefs.concat(route.imports);
  6448. }
  6449. return hrefs;
  6450. }).flat(1));
  6451. }
  6452. function dedupeHrefs(hrefs) {
  6453. return [...new Set(hrefs)];
  6454. }
  6455. function sortKeys(obj) {
  6456. let sorted = {};
  6457. let keys = Object.keys(obj).sort();
  6458. for (let key of keys) {
  6459. sorted[key] = obj[key];
  6460. }
  6461. return sorted;
  6462. }
  6463. function dedupeLinkDescriptors(descriptors, preloads) {
  6464. let set = /* @__PURE__ */ new Set();
  6465. let preloadsSet = new Set(preloads);
  6466. return descriptors.reduce((deduped, descriptor) => {
  6467. let alreadyModulePreload = preloads && !isPageLinkDescriptor(descriptor) && descriptor.as === "script" && descriptor.href && preloadsSet.has(descriptor.href);
  6468. if (alreadyModulePreload) {
  6469. return deduped;
  6470. }
  6471. let key = JSON.stringify(sortKeys(descriptor));
  6472. if (!set.has(key)) {
  6473. set.add(key);
  6474. deduped.push({
  6475. key,
  6476. link: descriptor
  6477. });
  6478. }
  6479. return deduped;
  6480. }, []);
  6481. }
  6482. function parsePathPatch(href) {
  6483. let path = parsePath(href);
  6484. if (path.search === void 0)
  6485. path.search = "";
  6486. return path;
  6487. }
  6488. var _isPreloadSupported;
  6489. function isPreloadSupported() {
  6490. if (_isPreloadSupported !== void 0) {
  6491. return _isPreloadSupported;
  6492. }
  6493. let el = document.createElement("link");
  6494. _isPreloadSupported = el.relList.supports("preload");
  6495. el = null;
  6496. return _isPreloadSupported;
  6497. }
  6498. // node_modules/@remix-run/react/dist/esm/markup.js
  6499. var ESCAPE_LOOKUP = {
  6500. "&": "\\u0026",
  6501. ">": "\\u003e",
  6502. "<": "\\u003c",
  6503. "\u2028": "\\u2028",
  6504. "\u2029": "\\u2029"
  6505. };
  6506. var ESCAPE_REGEX = /[&><\u2028\u2029]/g;
  6507. function escapeHtml(html) {
  6508. return html.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]);
  6509. }
  6510. function createHtml(html) {
  6511. return {
  6512. __html: html
  6513. };
  6514. }
  6515. // node_modules/@remix-run/react/dist/esm/components.js
  6516. function useDataRouterContext3() {
  6517. let context = React3.useContext(DataRouterContext);
  6518. invariant2(context, "You must render this element inside a <DataRouterContext.Provider> element");
  6519. return context;
  6520. }
  6521. function useDataRouterStateContext() {
  6522. let context = React3.useContext(DataRouterStateContext);
  6523. invariant2(context, "You must render this element inside a <DataRouterStateContext.Provider> element");
  6524. return context;
  6525. }
  6526. var RemixContext = /* @__PURE__ */ React3.createContext(void 0);
  6527. RemixContext.displayName = "Remix";
  6528. function useRemixContext() {
  6529. let context = React3.useContext(RemixContext);
  6530. invariant2(context, "You must render this element inside a <Remix> element");
  6531. return context;
  6532. }
  6533. function usePrefetchBehavior(prefetch, theirElementProps) {
  6534. let [maybePrefetch, setMaybePrefetch] = React3.useState(false);
  6535. let [shouldPrefetch, setShouldPrefetch] = React3.useState(false);
  6536. let {
  6537. onFocus,
  6538. onBlur,
  6539. onMouseEnter,
  6540. onMouseLeave,
  6541. onTouchStart
  6542. } = theirElementProps;
  6543. let ref = React3.useRef(null);
  6544. React3.useEffect(() => {
  6545. if (prefetch === "render") {
  6546. setShouldPrefetch(true);
  6547. }
  6548. if (prefetch === "viewport") {
  6549. let callback = (entries) => {
  6550. entries.forEach((entry) => {
  6551. setShouldPrefetch(entry.isIntersecting);
  6552. });
  6553. };
  6554. let observer = new IntersectionObserver(callback, {
  6555. threshold: 0.5
  6556. });
  6557. if (ref.current)
  6558. observer.observe(ref.current);
  6559. return () => {
  6560. observer.disconnect();
  6561. };
  6562. }
  6563. }, [prefetch]);
  6564. let setIntent = () => {
  6565. if (prefetch === "intent") {
  6566. setMaybePrefetch(true);
  6567. }
  6568. };
  6569. let cancelIntent = () => {
  6570. if (prefetch === "intent") {
  6571. setMaybePrefetch(false);
  6572. setShouldPrefetch(false);
  6573. }
  6574. };
  6575. React3.useEffect(() => {
  6576. if (maybePrefetch) {
  6577. let id = setTimeout(() => {
  6578. setShouldPrefetch(true);
  6579. }, 100);
  6580. return () => {
  6581. clearTimeout(id);
  6582. };
  6583. }
  6584. }, [maybePrefetch]);
  6585. return [shouldPrefetch, ref, {
  6586. onFocus: composeEventHandlers(onFocus, setIntent),
  6587. onBlur: composeEventHandlers(onBlur, cancelIntent),
  6588. onMouseEnter: composeEventHandlers(onMouseEnter, setIntent),
  6589. onMouseLeave: composeEventHandlers(onMouseLeave, cancelIntent),
  6590. onTouchStart: composeEventHandlers(onTouchStart, setIntent)
  6591. }];
  6592. }
  6593. var ABSOLUTE_URL_REGEX3 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
  6594. var NavLink2 = /* @__PURE__ */ React3.forwardRef(({
  6595. to,
  6596. prefetch = "none",
  6597. ...props
  6598. }, forwardedRef) => {
  6599. let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX3.test(to);
  6600. let href = useHref(to);
  6601. let [shouldPrefetch, ref, prefetchHandlers] = usePrefetchBehavior(prefetch, props);
  6602. return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(NavLink, _extends4({}, props, prefetchHandlers, {
  6603. ref: mergeRefs(forwardedRef, ref),
  6604. to
  6605. })), shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React3.createElement(PrefetchPageLinks, {
  6606. page: href
  6607. }) : null);
  6608. });
  6609. NavLink2.displayName = "NavLink";
  6610. var Link2 = /* @__PURE__ */ React3.forwardRef(({
  6611. to,
  6612. prefetch = "none",
  6613. ...props
  6614. }, forwardedRef) => {
  6615. let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX3.test(to);
  6616. let href = useHref(to);
  6617. let [shouldPrefetch, ref, prefetchHandlers] = usePrefetchBehavior(prefetch, props);
  6618. return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(Link, _extends4({}, props, prefetchHandlers, {
  6619. ref: mergeRefs(forwardedRef, ref),
  6620. to
  6621. })), shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React3.createElement(PrefetchPageLinks, {
  6622. page: href
  6623. }) : null);
  6624. });
  6625. Link2.displayName = "Link";
  6626. function composeEventHandlers(theirHandler, ourHandler) {
  6627. return (event) => {
  6628. theirHandler && theirHandler(event);
  6629. if (!event.defaultPrevented) {
  6630. ourHandler(event);
  6631. }
  6632. };
  6633. }
  6634. function getActiveMatches(matches, errors, isSpaMode) {
  6635. if (isSpaMode && !isHydrated) {
  6636. return [matches[0]];
  6637. }
  6638. if (errors) {
  6639. let errorIdx = matches.findIndex((m) => errors[m.route.id]);
  6640. return matches.slice(0, errorIdx + 1);
  6641. }
  6642. return matches;
  6643. }
  6644. function Links() {
  6645. let {
  6646. isSpaMode,
  6647. manifest,
  6648. routeModules,
  6649. criticalCss
  6650. } = useRemixContext();
  6651. let {
  6652. errors,
  6653. matches: routerMatches
  6654. } = useDataRouterStateContext();
  6655. let matches = getActiveMatches(routerMatches, errors, isSpaMode);
  6656. let keyedLinks = React3.useMemo(() => getKeyedLinksForMatches(matches, routeModules, manifest), [matches, routeModules, manifest]);
  6657. return /* @__PURE__ */ React3.createElement(React3.Fragment, null, criticalCss ? /* @__PURE__ */ React3.createElement("style", {
  6658. dangerouslySetInnerHTML: {
  6659. __html: criticalCss
  6660. }
  6661. }) : null, keyedLinks.map(({
  6662. key,
  6663. link
  6664. }) => isPageLinkDescriptor(link) ? /* @__PURE__ */ React3.createElement(PrefetchPageLinks, _extends4({
  6665. key
  6666. }, link)) : /* @__PURE__ */ React3.createElement("link", _extends4({
  6667. key
  6668. }, link))));
  6669. }
  6670. function PrefetchPageLinks({
  6671. page,
  6672. ...dataLinkProps
  6673. }) {
  6674. let {
  6675. router: router2
  6676. } = useDataRouterContext3();
  6677. let matches = React3.useMemo(() => matchRoutes(router2.routes, page), [router2.routes, page]);
  6678. if (!matches) {
  6679. console.warn(`Tried to prefetch ${page} but no routes matched.`);
  6680. return null;
  6681. }
  6682. return /* @__PURE__ */ React3.createElement(PrefetchPageLinksImpl, _extends4({
  6683. page,
  6684. matches
  6685. }, dataLinkProps));
  6686. }
  6687. function useKeyedPrefetchLinks(matches) {
  6688. let {
  6689. manifest,
  6690. routeModules
  6691. } = useRemixContext();
  6692. let [keyedPrefetchLinks, setKeyedPrefetchLinks] = React3.useState([]);
  6693. React3.useEffect(() => {
  6694. let interrupted = false;
  6695. void getKeyedPrefetchLinks(matches, manifest, routeModules).then((links) => {
  6696. if (!interrupted) {
  6697. setKeyedPrefetchLinks(links);
  6698. }
  6699. });
  6700. return () => {
  6701. interrupted = true;
  6702. };
  6703. }, [matches, manifest, routeModules]);
  6704. return keyedPrefetchLinks;
  6705. }
  6706. function PrefetchPageLinksImpl({
  6707. page,
  6708. matches: nextMatches,
  6709. ...linkProps
  6710. }) {
  6711. let location = useLocation();
  6712. let {
  6713. manifest
  6714. } = useRemixContext();
  6715. let {
  6716. matches
  6717. } = useDataRouterStateContext();
  6718. let newMatchesForData = React3.useMemo(() => getNewMatchesForLinks(page, nextMatches, matches, manifest, location, "data"), [page, nextMatches, matches, manifest, location]);
  6719. let newMatchesForAssets = React3.useMemo(() => getNewMatchesForLinks(page, nextMatches, matches, manifest, location, "assets"), [page, nextMatches, matches, manifest, location]);
  6720. let dataHrefs = React3.useMemo(() => getDataLinkHrefs(page, newMatchesForData, manifest), [newMatchesForData, page, manifest]);
  6721. let moduleHrefs = React3.useMemo(() => getModuleLinkHrefs(newMatchesForAssets, manifest), [newMatchesForAssets, manifest]);
  6722. let keyedPrefetchLinks = useKeyedPrefetchLinks(newMatchesForAssets);
  6723. return /* @__PURE__ */ React3.createElement(React3.Fragment, null, dataHrefs.map((href) => /* @__PURE__ */ React3.createElement("link", _extends4({
  6724. key: href,
  6725. rel: "prefetch",
  6726. as: "fetch",
  6727. href
  6728. }, linkProps))), moduleHrefs.map((href) => /* @__PURE__ */ React3.createElement("link", _extends4({
  6729. key: href,
  6730. rel: "modulepreload",
  6731. href
  6732. }, linkProps))), keyedPrefetchLinks.map(({
  6733. key,
  6734. link
  6735. }) => (
  6736. // these don't spread `linkProps` because they are full link descriptors
  6737. // already with their own props
  6738. /* @__PURE__ */ React3.createElement("link", _extends4({
  6739. key
  6740. }, link))
  6741. )));
  6742. }
  6743. function Meta() {
  6744. let {
  6745. isSpaMode,
  6746. routeModules
  6747. } = useRemixContext();
  6748. let {
  6749. errors,
  6750. matches: routerMatches,
  6751. loaderData
  6752. } = useDataRouterStateContext();
  6753. let location = useLocation();
  6754. let _matches = getActiveMatches(routerMatches, errors, isSpaMode);
  6755. let error = null;
  6756. if (errors) {
  6757. error = errors[_matches[_matches.length - 1].route.id];
  6758. }
  6759. let meta = [];
  6760. let leafMeta = null;
  6761. let matches = [];
  6762. for (let i = 0; i < _matches.length; i++) {
  6763. let _match = _matches[i];
  6764. let routeId = _match.route.id;
  6765. let data = loaderData[routeId];
  6766. let params = _match.params;
  6767. let routeModule = routeModules[routeId];
  6768. let routeMeta = [];
  6769. let match = {
  6770. id: routeId,
  6771. data,
  6772. meta: [],
  6773. params: _match.params,
  6774. pathname: _match.pathname,
  6775. handle: _match.route.handle,
  6776. error
  6777. };
  6778. matches[i] = match;
  6779. if (routeModule !== null && routeModule !== void 0 && routeModule.meta) {
  6780. routeMeta = typeof routeModule.meta === "function" ? routeModule.meta({
  6781. data,
  6782. params,
  6783. location,
  6784. matches,
  6785. error
  6786. }) : Array.isArray(routeModule.meta) ? [...routeModule.meta] : routeModule.meta;
  6787. } else if (leafMeta) {
  6788. routeMeta = [...leafMeta];
  6789. }
  6790. routeMeta = routeMeta || [];
  6791. if (!Array.isArray(routeMeta)) {
  6792. throw new Error("The route at " + _match.route.path + " returns an invalid value. All route meta functions must return an array of meta objects.\n\nTo reference the meta function API, see https://remix.run/route/meta");
  6793. }
  6794. match.meta = routeMeta;
  6795. matches[i] = match;
  6796. meta = [...routeMeta];
  6797. leafMeta = meta;
  6798. }
  6799. return /* @__PURE__ */ React3.createElement(React3.Fragment, null, meta.flat().map((metaProps) => {
  6800. if (!metaProps) {
  6801. return null;
  6802. }
  6803. if ("tagName" in metaProps) {
  6804. let {
  6805. tagName,
  6806. ...rest
  6807. } = metaProps;
  6808. if (!isValidMetaTag(tagName)) {
  6809. console.warn(`A meta object uses an invalid tagName: ${tagName}. Expected either 'link' or 'meta'`);
  6810. return null;
  6811. }
  6812. let Comp = tagName;
  6813. return /* @__PURE__ */ React3.createElement(Comp, _extends4({
  6814. key: JSON.stringify(rest)
  6815. }, rest));
  6816. }
  6817. if ("title" in metaProps) {
  6818. return /* @__PURE__ */ React3.createElement("title", {
  6819. key: "title"
  6820. }, String(metaProps.title));
  6821. }
  6822. if ("charset" in metaProps) {
  6823. metaProps.charSet ??= metaProps.charset;
  6824. delete metaProps.charset;
  6825. }
  6826. if ("charSet" in metaProps && metaProps.charSet != null) {
  6827. return typeof metaProps.charSet === "string" ? /* @__PURE__ */ React3.createElement("meta", {
  6828. key: "charSet",
  6829. charSet: metaProps.charSet
  6830. }) : null;
  6831. }
  6832. if ("script:ld+json" in metaProps) {
  6833. try {
  6834. let json4 = JSON.stringify(metaProps["script:ld+json"]);
  6835. return /* @__PURE__ */ React3.createElement("script", {
  6836. key: `script:ld+json:${json4}`,
  6837. type: "application/ld+json",
  6838. dangerouslySetInnerHTML: {
  6839. __html: json4
  6840. }
  6841. });
  6842. } catch (err) {
  6843. return null;
  6844. }
  6845. }
  6846. return /* @__PURE__ */ React3.createElement("meta", _extends4({
  6847. key: JSON.stringify(metaProps)
  6848. }, metaProps));
  6849. }));
  6850. }
  6851. function isValidMetaTag(tagName) {
  6852. return typeof tagName === "string" && /^(meta|link)$/.test(tagName);
  6853. }
  6854. function Await2(props) {
  6855. return /* @__PURE__ */ React3.createElement(Await, props);
  6856. }
  6857. var isHydrated = false;
  6858. function Scripts(props) {
  6859. let {
  6860. manifest,
  6861. serverHandoffString,
  6862. abortDelay,
  6863. serializeError,
  6864. isSpaMode
  6865. } = useRemixContext();
  6866. let {
  6867. router: router2,
  6868. static: isStatic,
  6869. staticContext
  6870. } = useDataRouterContext3();
  6871. let {
  6872. matches: routerMatches
  6873. } = useDataRouterStateContext();
  6874. let navigation = useNavigation();
  6875. let matches = getActiveMatches(routerMatches, null, isSpaMode);
  6876. React3.useEffect(() => {
  6877. isHydrated = true;
  6878. }, []);
  6879. let serializePreResolvedErrorImp = (key, error) => {
  6880. let toSerialize;
  6881. if (serializeError && error instanceof Error) {
  6882. toSerialize = serializeError(error);
  6883. } else {
  6884. toSerialize = error;
  6885. }
  6886. return `${JSON.stringify(key)}:__remixContext.p(!1, ${escapeHtml(JSON.stringify(toSerialize))})`;
  6887. };
  6888. let serializePreresolvedDataImp = (routeId, key, data) => {
  6889. let serializedData;
  6890. try {
  6891. serializedData = JSON.stringify(data);
  6892. } catch (error) {
  6893. return serializePreResolvedErrorImp(key, error);
  6894. }
  6895. return `${JSON.stringify(key)}:__remixContext.p(${escapeHtml(serializedData)})`;
  6896. };
  6897. let serializeErrorImp = (routeId, key, error) => {
  6898. let toSerialize;
  6899. if (serializeError && error instanceof Error) {
  6900. toSerialize = serializeError(error);
  6901. } else {
  6902. toSerialize = error;
  6903. }
  6904. return `__remixContext.r(${JSON.stringify(routeId)}, ${JSON.stringify(key)}, !1, ${escapeHtml(JSON.stringify(toSerialize))})`;
  6905. };
  6906. let serializeDataImp = (routeId, key, data) => {
  6907. let serializedData;
  6908. try {
  6909. serializedData = JSON.stringify(data);
  6910. } catch (error) {
  6911. return serializeErrorImp(routeId, key, error);
  6912. }
  6913. return `__remixContext.r(${JSON.stringify(routeId)}, ${JSON.stringify(key)}, ${escapeHtml(serializedData)})`;
  6914. };
  6915. let deferredScripts = [];
  6916. let initialScripts = React3.useMemo(() => {
  6917. var _manifest$hmr;
  6918. let contextScript = staticContext ? `window.__remixContext = ${serverHandoffString};` : " ";
  6919. let activeDeferreds = staticContext === null || staticContext === void 0 ? void 0 : staticContext.activeDeferreds;
  6920. contextScript += !activeDeferreds ? "" : ["__remixContext.p = function(v,e,p,x) {", " if (typeof e !== 'undefined') {", true ? " x=new Error(e.message);\n x.stack=e.stack;" : ' x=new Error("Unexpected Server Error");\n x.stack=undefined;', " p=Promise.reject(x);", " } else {", " p=Promise.resolve(v);", " }", " return p;", "};", "__remixContext.n = function(i,k) {", " __remixContext.t = __remixContext.t || {};", " __remixContext.t[i] = __remixContext.t[i] || {};", " let p = new Promise((r, e) => {__remixContext.t[i][k] = {r:(v)=>{r(v);},e:(v)=>{e(v);}};});", typeof abortDelay === "number" ? `setTimeout(() => {if(typeof p._error !== "undefined" || typeof p._data !== "undefined"){return;} __remixContext.t[i][k].e(new Error("Server timeout."))}, ${abortDelay});` : "", " return p;", "};", "__remixContext.r = function(i,k,v,e,p,x) {", " p = __remixContext.t[i][k];", " if (typeof e !== 'undefined') {", true ? " x=new Error(e.message);\n x.stack=e.stack;" : ' x=new Error("Unexpected Server Error");\n x.stack=undefined;', " p.e(x);", " } else {", " p.r(v);", " }", "};"].join("\n") + Object.entries(activeDeferreds).map(([routeId, deferredData]) => {
  6921. let pendingKeys = new Set(deferredData.pendingKeys);
  6922. let promiseKeyValues = deferredData.deferredKeys.map((key) => {
  6923. if (pendingKeys.has(key)) {
  6924. deferredScripts.push(/* @__PURE__ */ React3.createElement(DeferredHydrationScript, {
  6925. key: `${routeId} | ${key}`,
  6926. deferredData,
  6927. routeId,
  6928. dataKey: key,
  6929. scriptProps: props,
  6930. serializeData: serializeDataImp,
  6931. serializeError: serializeErrorImp
  6932. }));
  6933. return `${JSON.stringify(key)}:__remixContext.n(${JSON.stringify(routeId)}, ${JSON.stringify(key)})`;
  6934. } else {
  6935. let trackedPromise = deferredData.data[key];
  6936. if (typeof trackedPromise._error !== "undefined") {
  6937. return serializePreResolvedErrorImp(key, trackedPromise._error);
  6938. } else {
  6939. return serializePreresolvedDataImp(routeId, key, trackedPromise._data);
  6940. }
  6941. }
  6942. }).join(",\n");
  6943. return `Object.assign(__remixContext.state.loaderData[${JSON.stringify(routeId)}], {${promiseKeyValues}});`;
  6944. }).join("\n") + (deferredScripts.length > 0 ? `__remixContext.a=${deferredScripts.length};` : "");
  6945. let routeModulesScript = !isStatic ? " " : `${(_manifest$hmr = manifest.hmr) !== null && _manifest$hmr !== void 0 && _manifest$hmr.runtime ? `import ${JSON.stringify(manifest.hmr.runtime)};` : ""}import ${JSON.stringify(manifest.url)};
  6946. ${matches.map((match, index) => `import * as route${index} from ${JSON.stringify(manifest.routes[match.route.id].module)};`).join("\n")}
  6947. window.__remixRouteModules = {${matches.map((match, index) => `${JSON.stringify(match.route.id)}:route${index}`).join(",")}};
  6948. import(${JSON.stringify(manifest.entry.module)});`;
  6949. return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("script", _extends4({}, props, {
  6950. suppressHydrationWarning: true,
  6951. dangerouslySetInnerHTML: createHtml(contextScript),
  6952. type: void 0
  6953. })), /* @__PURE__ */ React3.createElement("script", _extends4({}, props, {
  6954. suppressHydrationWarning: true,
  6955. dangerouslySetInnerHTML: createHtml(routeModulesScript),
  6956. type: "module",
  6957. async: true
  6958. })));
  6959. }, []);
  6960. if (!isStatic && typeof __remixContext === "object" && __remixContext.a) {
  6961. for (let i = 0; i < __remixContext.a; i++) {
  6962. deferredScripts.push(/* @__PURE__ */ React3.createElement(DeferredHydrationScript, {
  6963. key: i,
  6964. scriptProps: props,
  6965. serializeData: serializeDataImp,
  6966. serializeError: serializeErrorImp
  6967. }));
  6968. }
  6969. }
  6970. let nextMatches = React3.useMemo(() => {
  6971. if (navigation.location) {
  6972. let matches2 = matchRoutes(router2.routes, navigation.location);
  6973. invariant2(matches2, `No routes match path "${navigation.location.pathname}"`);
  6974. return matches2;
  6975. }
  6976. return [];
  6977. }, [navigation.location, router2.routes]);
  6978. let routePreloads = matches.concat(nextMatches).map((match) => {
  6979. let route = manifest.routes[match.route.id];
  6980. return (route.imports || []).concat([route.module]);
  6981. }).flat(1);
  6982. let preloads = isHydrated ? [] : manifest.entry.imports.concat(routePreloads);
  6983. return isHydrated ? null : /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("link", {
  6984. rel: "modulepreload",
  6985. href: manifest.url,
  6986. crossOrigin: props.crossOrigin
  6987. }), /* @__PURE__ */ React3.createElement("link", {
  6988. rel: "modulepreload",
  6989. href: manifest.entry.module,
  6990. crossOrigin: props.crossOrigin
  6991. }), dedupe(preloads).map((path) => /* @__PURE__ */ React3.createElement("link", {
  6992. key: path,
  6993. rel: "modulepreload",
  6994. href: path,
  6995. crossOrigin: props.crossOrigin
  6996. })), initialScripts, deferredScripts);
  6997. }
  6998. function DeferredHydrationScript({
  6999. dataKey,
  7000. deferredData,
  7001. routeId,
  7002. scriptProps,
  7003. serializeData,
  7004. serializeError
  7005. }) {
  7006. if (typeof document === "undefined" && deferredData && dataKey && routeId) {
  7007. invariant2(deferredData.pendingKeys.includes(dataKey), `Deferred data for route ${routeId} with key ${dataKey} was not pending but tried to render a script for it.`);
  7008. }
  7009. return /* @__PURE__ */ React3.createElement(React3.Suspense, {
  7010. fallback: (
  7011. // This makes absolutely no sense. The server renders null as a fallback,
  7012. // but when hydrating, we need to render a script tag to avoid a hydration issue.
  7013. // To reproduce a hydration mismatch, just render null as a fallback.
  7014. typeof document === "undefined" && deferredData && dataKey && routeId ? null : /* @__PURE__ */ React3.createElement("script", _extends4({}, scriptProps, {
  7015. async: true,
  7016. suppressHydrationWarning: true,
  7017. dangerouslySetInnerHTML: {
  7018. __html: " "
  7019. }
  7020. }))
  7021. )
  7022. }, typeof document === "undefined" && deferredData && dataKey && routeId ? /* @__PURE__ */ React3.createElement(Await2, {
  7023. resolve: deferredData.data[dataKey],
  7024. errorElement: /* @__PURE__ */ React3.createElement(ErrorDeferredHydrationScript, {
  7025. dataKey,
  7026. routeId,
  7027. scriptProps,
  7028. serializeError
  7029. }),
  7030. children: (data) => {
  7031. return /* @__PURE__ */ React3.createElement("script", _extends4({}, scriptProps, {
  7032. async: true,
  7033. suppressHydrationWarning: true,
  7034. dangerouslySetInnerHTML: {
  7035. __html: serializeData(routeId, dataKey, data)
  7036. }
  7037. }));
  7038. }
  7039. }) : /* @__PURE__ */ React3.createElement("script", _extends4({}, scriptProps, {
  7040. async: true,
  7041. suppressHydrationWarning: true,
  7042. dangerouslySetInnerHTML: {
  7043. __html: " "
  7044. }
  7045. })));
  7046. }
  7047. function ErrorDeferredHydrationScript({
  7048. dataKey,
  7049. routeId,
  7050. scriptProps,
  7051. serializeError
  7052. }) {
  7053. let error = useAsyncError();
  7054. return /* @__PURE__ */ React3.createElement("script", _extends4({}, scriptProps, {
  7055. suppressHydrationWarning: true,
  7056. dangerouslySetInnerHTML: {
  7057. __html: serializeError(routeId, dataKey, error)
  7058. }
  7059. }));
  7060. }
  7061. function dedupe(array) {
  7062. return [...new Set(array)];
  7063. }
  7064. function useMatches2() {
  7065. return useMatches();
  7066. }
  7067. function useLoaderData2() {
  7068. return useLoaderData();
  7069. }
  7070. function useRouteLoaderData2(routeId) {
  7071. return useRouteLoaderData(routeId);
  7072. }
  7073. function useActionData2() {
  7074. return useActionData();
  7075. }
  7076. function useFetcher2(opts = {}) {
  7077. return useFetcher(opts);
  7078. }
  7079. var LiveReload = (
  7080. // Dead Code Elimination magic for production builds.
  7081. // This way devs don't have to worry about doing the NODE_ENV check themselves.
  7082. false ? () => null : function LiveReload2({
  7083. origin,
  7084. port,
  7085. timeoutMs = 1e3,
  7086. nonce = void 0
  7087. }) {
  7088. let isViteClient = import.meta && import.meta.env !== void 0;
  7089. if (isViteClient) {
  7090. console.warn(["`<LiveReload />` is obsolete when using Vite and can conflict with Vite's built-in HMR runtime.", "", "Remove `<LiveReload />` from your code and instead only use `<Scripts />`.", "Then refresh the page to remove lingering scripts from `<LiveReload />`."].join("\n"));
  7091. return null;
  7092. }
  7093. origin ??= "http://localhost:3001/";
  7094. let js = String.raw;
  7095. return /* @__PURE__ */ React3.createElement("script", {
  7096. nonce,
  7097. suppressHydrationWarning: true,
  7098. dangerouslySetInnerHTML: {
  7099. __html: js`
  7100. function remixLiveReloadConnect(config) {
  7101. let LIVE_RELOAD_ORIGIN = ${JSON.stringify(origin)};
  7102. let protocol =
  7103. LIVE_RELOAD_ORIGIN ? new URL(LIVE_RELOAD_ORIGIN).protocol.replace(/^http/, "ws") :
  7104. location.protocol === "https:" ? "wss:" : "ws:"; // remove in v2?
  7105. let hostname = LIVE_RELOAD_ORIGIN ? new URL(LIVE_RELOAD_ORIGIN).hostname : location.hostname;
  7106. let url = new URL(protocol + "//" + hostname + "/socket");
  7107. url.port =
  7108. ${port} ||
  7109. (LIVE_RELOAD_ORIGIN ? new URL(LIVE_RELOAD_ORIGIN).port : 8002);
  7110. let ws = new WebSocket(url.href);
  7111. ws.onmessage = async (message) => {
  7112. let event = JSON.parse(message.data);
  7113. if (event.type === "LOG") {
  7114. console.log(event.message);
  7115. }
  7116. if (event.type === "RELOAD") {
  7117. console.log("💿 Reloading window ...");
  7118. window.location.reload();
  7119. }
  7120. if (event.type === "HMR") {
  7121. if (!window.__hmr__ || !window.__hmr__.contexts) {
  7122. console.log("💿 [HMR] No HMR context, reloading window ...");
  7123. window.location.reload();
  7124. return;
  7125. }
  7126. if (!event.updates || !event.updates.length) return;
  7127. let updateAccepted = false;
  7128. let needsRevalidation = new Set();
  7129. for (let update of event.updates) {
  7130. console.log("[HMR] " + update.reason + " [" + update.id +"]")
  7131. if (update.revalidate) {
  7132. needsRevalidation.add(update.routeId);
  7133. console.log("[HMR] Revalidating [" + update.routeId + "]");
  7134. }
  7135. let imported = await import(update.url + '?t=' + event.assetsManifest.hmr.timestamp);
  7136. if (window.__hmr__.contexts[update.id]) {
  7137. let accepted = window.__hmr__.contexts[update.id].emit(
  7138. imported
  7139. );
  7140. if (accepted) {
  7141. console.log("[HMR] Update accepted by", update.id);
  7142. updateAccepted = true;
  7143. }
  7144. }
  7145. }
  7146. if (event.assetsManifest && window.__hmr__.contexts["remix:manifest"]) {
  7147. let accepted = window.__hmr__.contexts["remix:manifest"].emit(
  7148. { needsRevalidation, assetsManifest: event.assetsManifest }
  7149. );
  7150. if (accepted) {
  7151. console.log("[HMR] Update accepted by", "remix:manifest");
  7152. updateAccepted = true;
  7153. }
  7154. }
  7155. if (!updateAccepted) {
  7156. console.log("[HMR] Update rejected, reloading...");
  7157. window.location.reload();
  7158. }
  7159. }
  7160. };
  7161. ws.onopen = () => {
  7162. if (config && typeof config.onOpen === "function") {
  7163. config.onOpen();
  7164. }
  7165. };
  7166. ws.onclose = (event) => {
  7167. if (event.code === 1006) {
  7168. console.log("Remix dev asset server web socket closed. Reconnecting...");
  7169. setTimeout(
  7170. () =>
  7171. remixLiveReloadConnect({
  7172. onOpen: () => window.location.reload(),
  7173. }),
  7174. ${String(timeoutMs)}
  7175. );
  7176. }
  7177. };
  7178. ws.onerror = (error) => {
  7179. console.log("Remix dev asset server web socket error:");
  7180. console.error(error);
  7181. };
  7182. }
  7183. remixLiveReloadConnect();
  7184. `
  7185. }
  7186. });
  7187. }
  7188. );
  7189. function mergeRefs(...refs) {
  7190. return (value) => {
  7191. refs.forEach((ref) => {
  7192. if (typeof ref === "function") {
  7193. ref(value);
  7194. } else if (ref != null) {
  7195. ref.current = value;
  7196. }
  7197. });
  7198. };
  7199. }
  7200. // node_modules/@remix-run/react/dist/esm/errorBoundaries.js
  7201. var React4 = __toESM(require_react());
  7202. init_dist2();
  7203. var RemixErrorBoundary = class extends React4.Component {
  7204. constructor(props) {
  7205. super(props);
  7206. this.state = {
  7207. error: props.error || null,
  7208. location: props.location
  7209. };
  7210. }
  7211. static getDerivedStateFromError(error) {
  7212. return {
  7213. error
  7214. };
  7215. }
  7216. static getDerivedStateFromProps(props, state) {
  7217. if (state.location !== props.location) {
  7218. return {
  7219. error: props.error || null,
  7220. location: props.location
  7221. };
  7222. }
  7223. return {
  7224. error: props.error || state.error,
  7225. location: state.location
  7226. };
  7227. }
  7228. render() {
  7229. if (this.state.error) {
  7230. return /* @__PURE__ */ React4.createElement(RemixRootDefaultErrorBoundary, {
  7231. error: this.state.error
  7232. });
  7233. } else {
  7234. return this.props.children;
  7235. }
  7236. }
  7237. };
  7238. function RemixRootDefaultErrorBoundary({
  7239. error
  7240. }) {
  7241. console.error(error);
  7242. if (isRouteErrorResponse(error)) {
  7243. return /* @__PURE__ */ React4.createElement(BoundaryShell, {
  7244. title: "Unhandled Thrown Response!"
  7245. }, /* @__PURE__ */ React4.createElement("h1", {
  7246. style: {
  7247. fontFamily: "system-ui, sans-serif",
  7248. padding: "2rem"
  7249. }
  7250. }, error.status, " ", error.statusText));
  7251. }
  7252. let errorInstance;
  7253. if (error instanceof Error) {
  7254. errorInstance = error;
  7255. } else {
  7256. let errorString = error == null ? "Unknown Error" : typeof error === "object" && "toString" in error ? error.toString() : JSON.stringify(error);
  7257. errorInstance = new Error(errorString);
  7258. }
  7259. return /* @__PURE__ */ React4.createElement(BoundaryShell, {
  7260. title: "Application Error!"
  7261. }, /* @__PURE__ */ React4.createElement("main", {
  7262. style: {
  7263. fontFamily: "system-ui, sans-serif",
  7264. padding: "2rem"
  7265. }
  7266. }, /* @__PURE__ */ React4.createElement("h1", {
  7267. style: {
  7268. fontSize: "24px"
  7269. }
  7270. }, "Application Error"), /* @__PURE__ */ React4.createElement("pre", {
  7271. style: {
  7272. padding: "2rem",
  7273. background: "hsla(10, 50%, 50%, 0.1)",
  7274. color: "red",
  7275. overflow: "auto"
  7276. }
  7277. }, errorInstance.stack)));
  7278. }
  7279. function BoundaryShell({
  7280. title,
  7281. children
  7282. }) {
  7283. return /* @__PURE__ */ React4.createElement("html", {
  7284. lang: "en"
  7285. }, /* @__PURE__ */ React4.createElement("head", null, /* @__PURE__ */ React4.createElement("meta", {
  7286. charSet: "utf-8"
  7287. }), /* @__PURE__ */ React4.createElement("meta", {
  7288. name: "viewport",
  7289. content: "width=device-width,initial-scale=1,viewport-fit=cover"
  7290. }), /* @__PURE__ */ React4.createElement("title", null, title)), /* @__PURE__ */ React4.createElement("body", null, children, /* @__PURE__ */ React4.createElement("script", {
  7291. dangerouslySetInnerHTML: {
  7292. __html: `
  7293. console.log(
  7294. "\u{1F4BF} Hey developer \u{1F44B}. You can provide a way better UX than this when your app throws errors. Check out https://remix.run/guides/errors for more information."
  7295. );
  7296. `
  7297. }
  7298. })));
  7299. }
  7300. // node_modules/@remix-run/react/dist/esm/errors.js
  7301. init_router();
  7302. function deserializeErrors2(errors) {
  7303. if (!errors)
  7304. return null;
  7305. let entries = Object.entries(errors);
  7306. let serialized = {};
  7307. for (let [key, val] of entries) {
  7308. if (val && val.__type === "RouteErrorResponse") {
  7309. serialized[key] = new ErrorResponseImpl(val.status, val.statusText, val.data, val.internal === true);
  7310. } else if (val && val.__type === "Error") {
  7311. if (val.__subType) {
  7312. let ErrorConstructor = window[val.__subType];
  7313. if (typeof ErrorConstructor === "function") {
  7314. try {
  7315. let error = new ErrorConstructor(val.message);
  7316. error.stack = val.stack;
  7317. serialized[key] = error;
  7318. } catch (e) {
  7319. }
  7320. }
  7321. }
  7322. if (serialized[key] == null) {
  7323. let error = new Error(val.message);
  7324. error.stack = val.stack;
  7325. serialized[key] = error;
  7326. }
  7327. } else {
  7328. serialized[key] = val;
  7329. }
  7330. }
  7331. return serialized;
  7332. }
  7333. // node_modules/@remix-run/react/dist/esm/routes.js
  7334. var React6 = __toESM(require_react());
  7335. init_router();
  7336. init_dist2();
  7337. // node_modules/@remix-run/react/dist/esm/data.js
  7338. init_router();
  7339. function isCatchResponse(response) {
  7340. return response.headers.get("X-Remix-Catch") != null;
  7341. }
  7342. function isErrorResponse(response) {
  7343. return response.headers.get("X-Remix-Error") != null;
  7344. }
  7345. function isNetworkErrorResponse(response) {
  7346. return isResponse2(response) && response.status >= 400 && response.headers.get("X-Remix-Error") == null && response.headers.get("X-Remix-Catch") == null && response.headers.get("X-Remix-Response") == null;
  7347. }
  7348. function isRedirectResponse2(response) {
  7349. return response.headers.get("X-Remix-Redirect") != null;
  7350. }
  7351. function isDeferredResponse(response) {
  7352. var _response$headers$get;
  7353. return !!((_response$headers$get = response.headers.get("Content-Type")) !== null && _response$headers$get !== void 0 && _response$headers$get.match(/text\/remix-deferred/));
  7354. }
  7355. function isResponse2(value) {
  7356. return value != null && typeof value.status === "number" && typeof value.statusText === "string" && typeof value.headers === "object" && typeof value.body !== "undefined";
  7357. }
  7358. function isDeferredData2(value) {
  7359. let deferred = value;
  7360. return deferred && typeof deferred === "object" && typeof deferred.data === "object" && typeof deferred.subscribe === "function" && typeof deferred.cancel === "function" && typeof deferred.resolveData === "function";
  7361. }
  7362. async function fetchData(request, routeId, retry = 0) {
  7363. let url = new URL(request.url);
  7364. url.searchParams.set("_data", routeId);
  7365. let init = {
  7366. signal: request.signal
  7367. };
  7368. if (request.method !== "GET") {
  7369. init.method = request.method;
  7370. let contentType = request.headers.get("Content-Type");
  7371. if (contentType && /\bapplication\/json\b/.test(contentType)) {
  7372. init.headers = {
  7373. "Content-Type": contentType
  7374. };
  7375. init.body = JSON.stringify(await request.json());
  7376. } else if (contentType && /\btext\/plain\b/.test(contentType)) {
  7377. init.headers = {
  7378. "Content-Type": contentType
  7379. };
  7380. init.body = await request.text();
  7381. } else if (contentType && /\bapplication\/x-www-form-urlencoded\b/.test(contentType)) {
  7382. init.body = new URLSearchParams(await request.text());
  7383. } else {
  7384. init.body = await request.formData();
  7385. }
  7386. }
  7387. if (retry > 0) {
  7388. await new Promise((resolve) => setTimeout(resolve, 5 ** retry * 10));
  7389. }
  7390. let revalidation = window.__remixRevalidation;
  7391. let response = await fetch(url.href, init).catch((error) => {
  7392. if (typeof revalidation === "number" && revalidation === window.__remixRevalidation && (error === null || error === void 0 ? void 0 : error.name) === "TypeError" && retry < 3) {
  7393. return fetchData(request, routeId, retry + 1);
  7394. }
  7395. throw error;
  7396. });
  7397. if (isErrorResponse(response)) {
  7398. let data = await response.json();
  7399. let error = new Error(data.message);
  7400. error.stack = data.stack;
  7401. return error;
  7402. }
  7403. if (isNetworkErrorResponse(response)) {
  7404. let text = await response.text();
  7405. let error = new Error(text);
  7406. error.stack = void 0;
  7407. return error;
  7408. }
  7409. return response;
  7410. }
  7411. var DEFERRED_VALUE_PLACEHOLDER_PREFIX = "__deferred_promise:";
  7412. async function parseDeferredReadableStream(stream) {
  7413. if (!stream) {
  7414. throw new Error("parseDeferredReadableStream requires stream argument");
  7415. }
  7416. let deferredData;
  7417. let deferredResolvers = {};
  7418. try {
  7419. let sectionReader = readStreamSections(stream);
  7420. let initialSectionResult = await sectionReader.next();
  7421. let initialSection = initialSectionResult.value;
  7422. if (!initialSection)
  7423. throw new Error("no critical data");
  7424. let criticalData = JSON.parse(initialSection);
  7425. if (typeof criticalData === "object" && criticalData !== null) {
  7426. for (let [eventKey, value] of Object.entries(criticalData)) {
  7427. if (typeof value !== "string" || !value.startsWith(DEFERRED_VALUE_PLACEHOLDER_PREFIX)) {
  7428. continue;
  7429. }
  7430. deferredData = deferredData || {};
  7431. deferredData[eventKey] = new Promise((resolve, reject) => {
  7432. deferredResolvers[eventKey] = {
  7433. resolve: (value2) => {
  7434. resolve(value2);
  7435. delete deferredResolvers[eventKey];
  7436. },
  7437. reject: (error) => {
  7438. reject(error);
  7439. delete deferredResolvers[eventKey];
  7440. }
  7441. };
  7442. });
  7443. }
  7444. }
  7445. void (async () => {
  7446. try {
  7447. for await (let section of sectionReader) {
  7448. let [event, ...sectionDataStrings] = section.split(":");
  7449. let sectionDataString = sectionDataStrings.join(":");
  7450. let data = JSON.parse(sectionDataString);
  7451. if (event === "data") {
  7452. for (let [key, value] of Object.entries(data)) {
  7453. if (deferredResolvers[key]) {
  7454. deferredResolvers[key].resolve(value);
  7455. }
  7456. }
  7457. } else if (event === "error") {
  7458. for (let [key, value] of Object.entries(data)) {
  7459. let err = new Error(value.message);
  7460. err.stack = value.stack;
  7461. if (deferredResolvers[key]) {
  7462. deferredResolvers[key].reject(err);
  7463. }
  7464. }
  7465. }
  7466. }
  7467. for (let [key, resolver] of Object.entries(deferredResolvers)) {
  7468. resolver.reject(new AbortedDeferredError(`Deferred ${key} will never be resolved`));
  7469. }
  7470. } catch (error) {
  7471. for (let resolver of Object.values(deferredResolvers)) {
  7472. resolver.reject(error);
  7473. }
  7474. }
  7475. })();
  7476. return new DeferredData({
  7477. ...criticalData,
  7478. ...deferredData
  7479. });
  7480. } catch (error) {
  7481. for (let resolver of Object.values(deferredResolvers)) {
  7482. resolver.reject(error);
  7483. }
  7484. throw error;
  7485. }
  7486. }
  7487. async function* readStreamSections(stream) {
  7488. let reader = stream.getReader();
  7489. let buffer = [];
  7490. let sections = [];
  7491. let closed = false;
  7492. let encoder = new TextEncoder();
  7493. let decoder = new TextDecoder();
  7494. let readStreamSection = async () => {
  7495. if (sections.length > 0)
  7496. return sections.shift();
  7497. while (!closed && sections.length === 0) {
  7498. let chunk = await reader.read();
  7499. if (chunk.done) {
  7500. closed = true;
  7501. break;
  7502. }
  7503. buffer.push(chunk.value);
  7504. try {
  7505. let bufferedString = decoder.decode(mergeArrays(...buffer));
  7506. let splitSections = bufferedString.split("\n\n");
  7507. if (splitSections.length >= 2) {
  7508. sections.push(...splitSections.slice(0, -1));
  7509. buffer = [encoder.encode(splitSections.slice(-1).join("\n\n"))];
  7510. }
  7511. if (sections.length > 0) {
  7512. break;
  7513. }
  7514. } catch {
  7515. continue;
  7516. }
  7517. }
  7518. if (sections.length > 0) {
  7519. return sections.shift();
  7520. }
  7521. if (buffer.length > 0) {
  7522. let bufferedString = decoder.decode(mergeArrays(...buffer));
  7523. sections = bufferedString.split("\n\n").filter((s) => s);
  7524. buffer = [];
  7525. }
  7526. return sections.shift();
  7527. };
  7528. let section = await readStreamSection();
  7529. while (section) {
  7530. yield section;
  7531. section = await readStreamSection();
  7532. }
  7533. }
  7534. function mergeArrays(...arrays) {
  7535. let out = new Uint8Array(arrays.reduce((total, arr) => total + arr.length, 0));
  7536. let offset = 0;
  7537. for (let arr of arrays) {
  7538. out.set(arr, offset);
  7539. offset += arr.length;
  7540. }
  7541. return out;
  7542. }
  7543. // node_modules/@remix-run/react/dist/esm/fallback.js
  7544. var React5 = __toESM(require_react());
  7545. function RemixRootDefaultHydrateFallback() {
  7546. return /* @__PURE__ */ React5.createElement("html", {
  7547. lang: "en"
  7548. }, /* @__PURE__ */ React5.createElement("head", null, /* @__PURE__ */ React5.createElement("meta", {
  7549. charSet: "utf-8"
  7550. }), /* @__PURE__ */ React5.createElement("meta", {
  7551. name: "viewport",
  7552. content: "width=device-width,initial-scale=1,viewport-fit=cover"
  7553. })), /* @__PURE__ */ React5.createElement("body", null, /* @__PURE__ */ React5.createElement(Scripts, null), /* @__PURE__ */ React5.createElement("script", {
  7554. dangerouslySetInnerHTML: {
  7555. __html: `
  7556. console.log(
  7557. "\u{1F4BF} Hey developer \u{1F44B}. You can provide a way better UX than this " +
  7558. "when your app is running \`clientLoader\` functions on hydration. " +
  7559. "Check out https://remix.run/route/hydrate-fallback for more information."
  7560. );
  7561. `
  7562. }
  7563. }), " "));
  7564. }
  7565. // node_modules/@remix-run/react/dist/esm/routes.js
  7566. function groupRoutesByParentId(manifest) {
  7567. let routes = {};
  7568. Object.values(manifest).forEach((route) => {
  7569. let parentId = route.parentId || "";
  7570. if (!routes[parentId]) {
  7571. routes[parentId] = [];
  7572. }
  7573. routes[parentId].push(route);
  7574. });
  7575. return routes;
  7576. }
  7577. function createServerRoutes(manifest, routeModules, future, isSpaMode, parentId = "", routesByParentId = groupRoutesByParentId(manifest), spaModeLazyPromise = Promise.resolve({
  7578. Component: () => null
  7579. })) {
  7580. return (routesByParentId[parentId] || []).map((route) => {
  7581. let routeModule = routeModules[route.id];
  7582. invariant2(routeModule, "No `routeModule` available to create server routes");
  7583. let dataRoute = {
  7584. caseSensitive: route.caseSensitive,
  7585. Component: getRouteModuleComponent(routeModule),
  7586. // HydrateFallback can only exist on the root route in SPA Mode
  7587. HydrateFallback: routeModule.HydrateFallback && (!isSpaMode || route.id === "root") ? routeModule.HydrateFallback : route.id === "root" ? RemixRootDefaultHydrateFallback : void 0,
  7588. ErrorBoundary: routeModule.ErrorBoundary ? routeModule.ErrorBoundary : route.id === "root" ? () => /* @__PURE__ */ React6.createElement(RemixRootDefaultErrorBoundary, {
  7589. error: useRouteError()
  7590. }) : void 0,
  7591. id: route.id,
  7592. index: route.index,
  7593. path: route.path,
  7594. handle: routeModule.handle,
  7595. // For SPA Mode, all routes are lazy except root. We don't need a full
  7596. // implementation here though - just need a `lazy` prop to tell the RR
  7597. // rendering where to stop
  7598. lazy: isSpaMode && route.id !== "root" ? () => spaModeLazyPromise : void 0,
  7599. // For partial hydration rendering, we need to indicate when the route
  7600. // has a loader/clientLoader, but it won't ever be called during the static
  7601. // render, so just give it a no-op function so we can render down to the
  7602. // proper fallback
  7603. loader: route.hasLoader || route.hasClientLoader ? () => null : void 0
  7604. // We don't need action/shouldRevalidate on these routes since they're
  7605. // for a static render
  7606. };
  7607. let children = createServerRoutes(manifest, routeModules, future, isSpaMode, route.id, routesByParentId, spaModeLazyPromise);
  7608. if (children.length > 0)
  7609. dataRoute.children = children;
  7610. return dataRoute;
  7611. });
  7612. }
  7613. function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest, routeModulesCache, initialState, future, isSpaMode) {
  7614. return createClientRoutes(manifest, routeModulesCache, initialState, future, isSpaMode, "", groupRoutesByParentId(manifest), needsRevalidation);
  7615. }
  7616. function preventInvalidServerHandlerCall(type, route, isSpaMode) {
  7617. if (isSpaMode) {
  7618. let fn2 = type === "action" ? "serverAction()" : "serverLoader()";
  7619. let msg2 = `You cannot call ${fn2} in SPA Mode (routeId: "${route.id}")`;
  7620. console.error(msg2);
  7621. throw new ErrorResponseImpl(400, "Bad Request", new Error(msg2), true);
  7622. }
  7623. let fn = type === "action" ? "serverAction()" : "serverLoader()";
  7624. let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${route.id}")`;
  7625. if (type === "loader" && !route.hasLoader || type === "action" && !route.hasAction) {
  7626. console.error(msg);
  7627. throw new ErrorResponseImpl(400, "Bad Request", new Error(msg), true);
  7628. }
  7629. }
  7630. function noActionDefinedError(type, routeId) {
  7631. let article = type === "clientAction" ? "a" : "an";
  7632. let msg = `Route "${routeId}" does not have ${article} ${type}, but you are trying to submit to it. To fix this, please add ${article} \`${type}\` function to the route`;
  7633. console.error(msg);
  7634. throw new ErrorResponseImpl(405, "Method Not Allowed", new Error(msg), true);
  7635. }
  7636. function createClientRoutes(manifest, routeModulesCache, initialState, future, isSpaMode, parentId = "", routesByParentId = groupRoutesByParentId(manifest), needsRevalidation) {
  7637. return (routesByParentId[parentId] || []).map((route) => {
  7638. let routeModule = routeModulesCache[route.id];
  7639. async function fetchServerLoader(request) {
  7640. if (!route.hasLoader)
  7641. return null;
  7642. return fetchServerHandler(request, route);
  7643. }
  7644. async function fetchServerAction(request) {
  7645. if (!route.hasAction) {
  7646. throw noActionDefinedError("action", route.id);
  7647. }
  7648. return fetchServerHandler(request, route);
  7649. }
  7650. async function prefetchStylesAndCallHandler(handler) {
  7651. let cachedModule = routeModulesCache[route.id];
  7652. let linkPrefetchPromise = cachedModule ? prefetchStyleLinks(route, cachedModule) : Promise.resolve();
  7653. try {
  7654. return handler();
  7655. } finally {
  7656. await linkPrefetchPromise;
  7657. }
  7658. }
  7659. let dataRoute = {
  7660. id: route.id,
  7661. index: route.index,
  7662. path: route.path
  7663. };
  7664. if (routeModule) {
  7665. var _initialState$loaderD, _initialState$errors, _routeModule$clientLo;
  7666. Object.assign(dataRoute, {
  7667. ...dataRoute,
  7668. Component: getRouteModuleComponent(routeModule),
  7669. // HydrateFallback can only exist on the root route in SPA Mode
  7670. HydrateFallback: routeModule.HydrateFallback && (!isSpaMode || route.id === "root") ? routeModule.HydrateFallback : route.id === "root" ? RemixRootDefaultHydrateFallback : void 0,
  7671. ErrorBoundary: routeModule.ErrorBoundary ? routeModule.ErrorBoundary : route.id === "root" ? () => /* @__PURE__ */ React6.createElement(RemixRootDefaultErrorBoundary, {
  7672. error: useRouteError()
  7673. }) : void 0,
  7674. handle: routeModule.handle,
  7675. shouldRevalidate: needsRevalidation ? wrapShouldRevalidateForHdr(route.id, routeModule.shouldRevalidate, needsRevalidation) : routeModule.shouldRevalidate
  7676. });
  7677. let initialData = initialState === null || initialState === void 0 ? void 0 : (_initialState$loaderD = initialState.loaderData) === null || _initialState$loaderD === void 0 ? void 0 : _initialState$loaderD[route.id];
  7678. let initialError = initialState === null || initialState === void 0 ? void 0 : (_initialState$errors = initialState.errors) === null || _initialState$errors === void 0 ? void 0 : _initialState$errors[route.id];
  7679. let isHydrationRequest = needsRevalidation == null && (((_routeModule$clientLo = routeModule.clientLoader) === null || _routeModule$clientLo === void 0 ? void 0 : _routeModule$clientLo.hydrate) === true || !route.hasLoader);
  7680. dataRoute.loader = async ({
  7681. request,
  7682. params
  7683. }) => {
  7684. try {
  7685. let result = await prefetchStylesAndCallHandler(async () => {
  7686. invariant2(routeModule, "No `routeModule` available for critical-route loader");
  7687. if (!routeModule.clientLoader) {
  7688. if (isSpaMode)
  7689. return null;
  7690. return fetchServerLoader(request);
  7691. }
  7692. return routeModule.clientLoader({
  7693. request,
  7694. params,
  7695. async serverLoader() {
  7696. preventInvalidServerHandlerCall("loader", route, isSpaMode);
  7697. if (isHydrationRequest) {
  7698. if (initialError !== void 0) {
  7699. throw initialError;
  7700. }
  7701. return initialData;
  7702. }
  7703. let result2 = await fetchServerLoader(request);
  7704. let unwrapped = await unwrapServerResponse(result2);
  7705. return unwrapped;
  7706. }
  7707. });
  7708. });
  7709. return result;
  7710. } finally {
  7711. isHydrationRequest = false;
  7712. }
  7713. };
  7714. dataRoute.loader.hydrate = shouldHydrateRouteLoader(route, routeModule, isSpaMode);
  7715. dataRoute.action = ({
  7716. request,
  7717. params
  7718. }) => {
  7719. return prefetchStylesAndCallHandler(async () => {
  7720. invariant2(routeModule, "No `routeModule` available for critical-route action");
  7721. if (!routeModule.clientAction) {
  7722. if (isSpaMode) {
  7723. throw noActionDefinedError("clientAction", route.id);
  7724. }
  7725. return fetchServerAction(request);
  7726. }
  7727. return routeModule.clientAction({
  7728. request,
  7729. params,
  7730. async serverAction() {
  7731. preventInvalidServerHandlerCall("action", route, isSpaMode);
  7732. let result = await fetchServerAction(request);
  7733. let unwrapped = await unwrapServerResponse(result);
  7734. return unwrapped;
  7735. }
  7736. });
  7737. });
  7738. };
  7739. } else {
  7740. if (!route.hasClientLoader) {
  7741. dataRoute.loader = ({
  7742. request
  7743. }) => prefetchStylesAndCallHandler(() => {
  7744. if (isSpaMode)
  7745. return Promise.resolve(null);
  7746. return fetchServerLoader(request);
  7747. });
  7748. }
  7749. if (!route.hasClientAction) {
  7750. dataRoute.action = ({
  7751. request
  7752. }) => prefetchStylesAndCallHandler(() => {
  7753. if (isSpaMode) {
  7754. throw noActionDefinedError("clientAction", route.id);
  7755. }
  7756. return fetchServerAction(request);
  7757. });
  7758. }
  7759. dataRoute.lazy = async () => {
  7760. let mod = await loadRouteModuleWithBlockingLinks(route, routeModulesCache);
  7761. let lazyRoute = {
  7762. ...mod
  7763. };
  7764. if (mod.clientLoader) {
  7765. let clientLoader = mod.clientLoader;
  7766. lazyRoute.loader = (args) => clientLoader({
  7767. ...args,
  7768. async serverLoader() {
  7769. preventInvalidServerHandlerCall("loader", route, isSpaMode);
  7770. let response = await fetchServerLoader(args.request);
  7771. let result = await unwrapServerResponse(response);
  7772. return result;
  7773. }
  7774. });
  7775. }
  7776. if (mod.clientAction) {
  7777. let clientAction = mod.clientAction;
  7778. lazyRoute.action = (args) => clientAction({
  7779. ...args,
  7780. async serverAction() {
  7781. preventInvalidServerHandlerCall("action", route, isSpaMode);
  7782. let response = await fetchServerAction(args.request);
  7783. let result = await unwrapServerResponse(response);
  7784. return result;
  7785. }
  7786. });
  7787. }
  7788. if (needsRevalidation) {
  7789. lazyRoute.shouldRevalidate = wrapShouldRevalidateForHdr(route.id, mod.shouldRevalidate, needsRevalidation);
  7790. }
  7791. return {
  7792. ...lazyRoute.loader ? {
  7793. loader: lazyRoute.loader
  7794. } : {},
  7795. ...lazyRoute.action ? {
  7796. action: lazyRoute.action
  7797. } : {},
  7798. hasErrorBoundary: lazyRoute.hasErrorBoundary,
  7799. shouldRevalidate: lazyRoute.shouldRevalidate,
  7800. handle: lazyRoute.handle,
  7801. Component: lazyRoute.Component,
  7802. ErrorBoundary: lazyRoute.ErrorBoundary
  7803. };
  7804. };
  7805. }
  7806. let children = createClientRoutes(manifest, routeModulesCache, initialState, future, isSpaMode, route.id, routesByParentId, needsRevalidation);
  7807. if (children.length > 0)
  7808. dataRoute.children = children;
  7809. return dataRoute;
  7810. });
  7811. }
  7812. function wrapShouldRevalidateForHdr(routeId, routeShouldRevalidate, needsRevalidation) {
  7813. let handledRevalidation = false;
  7814. return (arg) => {
  7815. if (!handledRevalidation) {
  7816. handledRevalidation = true;
  7817. return needsRevalidation.has(routeId);
  7818. }
  7819. return routeShouldRevalidate ? routeShouldRevalidate(arg) : arg.defaultShouldRevalidate;
  7820. };
  7821. }
  7822. async function loadRouteModuleWithBlockingLinks(route, routeModules) {
  7823. let routeModule = await loadRouteModule(route, routeModules);
  7824. await prefetchStyleLinks(route, routeModule);
  7825. return {
  7826. Component: getRouteModuleComponent(routeModule),
  7827. ErrorBoundary: routeModule.ErrorBoundary,
  7828. clientAction: routeModule.clientAction,
  7829. clientLoader: routeModule.clientLoader,
  7830. handle: routeModule.handle,
  7831. links: routeModule.links,
  7832. meta: routeModule.meta,
  7833. shouldRevalidate: routeModule.shouldRevalidate
  7834. };
  7835. }
  7836. async function fetchServerHandler(request, route) {
  7837. let result = await fetchData(request, route.id);
  7838. if (result instanceof Error) {
  7839. throw result;
  7840. }
  7841. if (isRedirectResponse2(result)) {
  7842. throw getRedirect(result);
  7843. }
  7844. if (isCatchResponse(result)) {
  7845. throw result;
  7846. }
  7847. if (isDeferredResponse(result) && result.body) {
  7848. return await parseDeferredReadableStream(result.body);
  7849. }
  7850. return result;
  7851. }
  7852. function unwrapServerResponse(result) {
  7853. if (isDeferredData2(result)) {
  7854. return result.data;
  7855. }
  7856. if (isResponse2(result)) {
  7857. let contentType = result.headers.get("Content-Type");
  7858. if (contentType && /\bapplication\/json\b/.test(contentType)) {
  7859. return result.json();
  7860. } else {
  7861. return result.text();
  7862. }
  7863. }
  7864. return result;
  7865. }
  7866. function getRedirect(response) {
  7867. let status = parseInt(response.headers.get("X-Remix-Status"), 10) || 302;
  7868. let url = response.headers.get("X-Remix-Redirect");
  7869. let headers = {};
  7870. let revalidate = response.headers.get("X-Remix-Revalidate");
  7871. if (revalidate) {
  7872. headers["X-Remix-Revalidate"] = revalidate;
  7873. }
  7874. let reloadDocument = response.headers.get("X-Remix-Reload-Document");
  7875. if (reloadDocument) {
  7876. headers["X-Remix-Reload-Document"] = reloadDocument;
  7877. }
  7878. return redirect(url, {
  7879. status,
  7880. headers
  7881. });
  7882. }
  7883. function getRouteModuleComponent(routeModule) {
  7884. if (routeModule.default == null)
  7885. return void 0;
  7886. let isEmptyObject = typeof routeModule.default === "object" && Object.keys(routeModule.default).length === 0;
  7887. if (!isEmptyObject) {
  7888. return routeModule.default;
  7889. }
  7890. }
  7891. function shouldHydrateRouteLoader(route, routeModule, isSpaMode) {
  7892. return isSpaMode && route.id !== "root" || routeModule.clientLoader != null && (routeModule.clientLoader.hydrate === true || route.hasLoader !== true);
  7893. }
  7894. // node_modules/@remix-run/react/dist/esm/browser.js
  7895. if (!window.$RefreshReg$ || !window.$RefreshSig$ || !window.$RefreshRuntime$) {
  7896. console.warn("remix:hmr: React Fast Refresh only works when the Remix compiler is running in development mode.");
  7897. } else {
  7898. prevRefreshReg = window.$RefreshReg$;
  7899. prevRefreshSig = window.$RefreshSig$;
  7900. window.$RefreshReg$ = (type, id) => {
  7901. window.$RefreshRuntime$.register(type, '"node_modules/@remix-run/react/dist/esm/browser.js"' + id);
  7902. };
  7903. window.$RefreshSig$ = window.$RefreshRuntime$.createSignatureFunctionForTransform;
  7904. }
  7905. var prevRefreshReg;
  7906. var prevRefreshSig;
  7907. var _s = $RefreshSig$();
  7908. if (import.meta) {
  7909. import.meta.hot = createHotContext(
  7910. //@ts-expect-error
  7911. "node_modules/@remix-run/react/dist/esm/browser.js"
  7912. );
  7913. }
  7914. var router;
  7915. var routerInitialized = false;
  7916. var hmrAbortController;
  7917. var hmrRouterReadyResolve;
  7918. var hmrRouterReadyPromise = new Promise((resolve) => {
  7919. hmrRouterReadyResolve = resolve;
  7920. }).catch(() => {
  7921. return void 0;
  7922. });
  7923. var criticalCssReducer = () => void 0;
  7924. if (import.meta && import.meta.hot) {
  7925. import.meta.hot.accept("remix:manifest", async ({
  7926. assetsManifest,
  7927. needsRevalidation
  7928. }) => {
  7929. let router2 = await hmrRouterReadyPromise;
  7930. if (!router2) {
  7931. console.error("Failed to accept HMR update because the router was not ready.");
  7932. return;
  7933. }
  7934. let routeIds = [...new Set(router2.state.matches.map((m) => m.route.id).concat(Object.keys(window.__remixRouteModules)))];
  7935. if (hmrAbortController) {
  7936. hmrAbortController.abort();
  7937. }
  7938. hmrAbortController = new AbortController();
  7939. let signal = hmrAbortController.signal;
  7940. let newRouteModules = Object.assign({}, window.__remixRouteModules, Object.fromEntries((await Promise.all(routeIds.map(async (id) => {
  7941. var _assetsManifest$hmr, _window$__remixRouteM, _window$__remixRouteM2, _window$__remixRouteM3;
  7942. if (!assetsManifest.routes[id]) {
  7943. return null;
  7944. }
  7945. let imported = await import(assetsManifest.routes[id].module + `?t=${(_assetsManifest$hmr = assetsManifest.hmr) === null || _assetsManifest$hmr === void 0 ? void 0 : _assetsManifest$hmr.timestamp}`);
  7946. return [id, {
  7947. ...imported,
  7948. // react-refresh takes care of updating these in-place,
  7949. // if we don't preserve existing values we'll loose state.
  7950. default: imported.default ? ((_window$__remixRouteM = window.__remixRouteModules[id]) === null || _window$__remixRouteM === void 0 ? void 0 : _window$__remixRouteM.default) ?? imported.default : imported.default,
  7951. ErrorBoundary: imported.ErrorBoundary ? ((_window$__remixRouteM2 = window.__remixRouteModules[id]) === null || _window$__remixRouteM2 === void 0 ? void 0 : _window$__remixRouteM2.ErrorBoundary) ?? imported.ErrorBoundary : imported.ErrorBoundary,
  7952. HydrateFallback: imported.HydrateFallback ? ((_window$__remixRouteM3 = window.__remixRouteModules[id]) === null || _window$__remixRouteM3 === void 0 ? void 0 : _window$__remixRouteM3.HydrateFallback) ?? imported.HydrateFallback : imported.HydrateFallback
  7953. }];
  7954. }))).filter(Boolean)));
  7955. Object.assign(window.__remixRouteModules, newRouteModules);
  7956. let routes = createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, assetsManifest.routes, window.__remixRouteModules, window.__remixContext.state, window.__remixContext.future, window.__remixContext.isSpaMode);
  7957. router2._internalSetRoutes(routes);
  7958. let unsub = router2.subscribe((state) => {
  7959. if (state.revalidation === "idle") {
  7960. unsub();
  7961. if (signal.aborted)
  7962. return;
  7963. setTimeout(() => {
  7964. Object.assign(window.__remixManifest, assetsManifest);
  7965. window.$RefreshRuntime$.performReactRefresh();
  7966. }, 1);
  7967. }
  7968. });
  7969. window.__remixRevalidation = (window.__remixRevalidation || 0) + 1;
  7970. router2.revalidate();
  7971. });
  7972. }
  7973. function RemixBrowser(_props) {
  7974. _s();
  7975. if (!router) {
  7976. let initialPathname = window.__remixContext.url;
  7977. let hydratedPathname = window.location.pathname;
  7978. if (initialPathname !== hydratedPathname && !window.__remixContext.isSpaMode) {
  7979. let errorMsg = `Initial URL (${initialPathname}) does not match URL at time of hydration (${hydratedPathname}), reloading page...`;
  7980. console.error(errorMsg);
  7981. window.location.reload();
  7982. return /* @__PURE__ */ React7.createElement(React7.Fragment, null);
  7983. }
  7984. let routes = createClientRoutes(window.__remixManifest.routes, window.__remixRouteModules, window.__remixContext.state, window.__remixContext.future, window.__remixContext.isSpaMode);
  7985. let hydrationData = void 0;
  7986. if (!window.__remixContext.isSpaMode) {
  7987. hydrationData = {
  7988. ...window.__remixContext.state,
  7989. loaderData: {
  7990. ...window.__remixContext.state.loaderData
  7991. }
  7992. };
  7993. let initialMatches = matchRoutes(routes, window.location);
  7994. if (initialMatches) {
  7995. for (let match of initialMatches) {
  7996. let routeId = match.route.id;
  7997. let route = window.__remixRouteModules[routeId];
  7998. let manifestRoute = window.__remixManifest.routes[routeId];
  7999. if (route && shouldHydrateRouteLoader(manifestRoute, route, window.__remixContext.isSpaMode) && (route.HydrateFallback || !manifestRoute.hasLoader)) {
  8000. hydrationData.loaderData[routeId] = void 0;
  8001. } else if (manifestRoute && !manifestRoute.hasLoader) {
  8002. hydrationData.loaderData[routeId] = null;
  8003. }
  8004. }
  8005. }
  8006. if (hydrationData && hydrationData.errors) {
  8007. hydrationData.errors = deserializeErrors2(hydrationData.errors);
  8008. }
  8009. }
  8010. router = createRouter({
  8011. routes,
  8012. history: createBrowserHistory(),
  8013. future: {
  8014. v7_normalizeFormMethod: true,
  8015. v7_fetcherPersist: window.__remixContext.future.v3_fetcherPersist,
  8016. v7_partialHydration: true,
  8017. v7_prependBasename: true,
  8018. v7_relativeSplatPath: window.__remixContext.future.v3_relativeSplatPath
  8019. },
  8020. hydrationData,
  8021. mapRouteProperties
  8022. });
  8023. if (router.state.initialized) {
  8024. routerInitialized = true;
  8025. router.initialize();
  8026. }
  8027. router.createRoutesForHMR = createClientRoutesWithHMRRevalidationOptOut;
  8028. window.__remixRouter = router;
  8029. if (hmrRouterReadyResolve) {
  8030. hmrRouterReadyResolve(router);
  8031. }
  8032. }
  8033. let [criticalCss, clearCriticalCss] = React7.useReducer(criticalCssReducer, window.__remixContext.criticalCss);
  8034. window.__remixClearCriticalCss = clearCriticalCss;
  8035. let [location, setLocation] = React7.useState(router.state.location);
  8036. React7.useLayoutEffect(() => {
  8037. if (!routerInitialized) {
  8038. routerInitialized = true;
  8039. router.initialize();
  8040. }
  8041. }, []);
  8042. React7.useLayoutEffect(() => {
  8043. return router.subscribe((newState) => {
  8044. if (newState.location !== location) {
  8045. setLocation(newState.location);
  8046. }
  8047. });
  8048. }, [location]);
  8049. return /* @__PURE__ */ React7.createElement(RemixContext.Provider, {
  8050. value: {
  8051. manifest: window.__remixManifest,
  8052. routeModules: window.__remixRouteModules,
  8053. future: window.__remixContext.future,
  8054. criticalCss,
  8055. isSpaMode: window.__remixContext.isSpaMode
  8056. }
  8057. }, /* @__PURE__ */ React7.createElement(RemixErrorBoundary, {
  8058. location
  8059. }, /* @__PURE__ */ React7.createElement(RouterProvider2, {
  8060. router,
  8061. fallbackElement: null,
  8062. future: {
  8063. v7_startTransition: true
  8064. }
  8065. })));
  8066. }
  8067. _s(RemixBrowser, "dNY/ZcXj2W8K0mGOaHLSDzAVXYE=");
  8068. _c = RemixBrowser;
  8069. var _c;
  8070. $RefreshReg$(_c, "RemixBrowser");
  8071. window.$RefreshReg$ = prevRefreshReg;
  8072. window.$RefreshSig$ = prevRefreshSig;
  8073. // node_modules/@remix-run/react/dist/esm/scroll-restoration.js
  8074. var React8 = __toESM(require_react());
  8075. init_dist2();
  8076. var STORAGE_KEY = "positions";
  8077. function ScrollRestoration2({
  8078. getKey,
  8079. ...props
  8080. }) {
  8081. let {
  8082. isSpaMode
  8083. } = useRemixContext();
  8084. let location = useLocation();
  8085. let matches = useMatches();
  8086. useScrollRestoration({
  8087. getKey,
  8088. storageKey: STORAGE_KEY
  8089. });
  8090. let key = React8.useMemo(
  8091. () => {
  8092. if (!getKey)
  8093. return null;
  8094. let userKey = getKey(location, matches);
  8095. return userKey !== location.key ? userKey : null;
  8096. },
  8097. // Nah, we only need this the first time for the SSR render
  8098. // eslint-disable-next-line react-hooks/exhaustive-deps
  8099. []
  8100. );
  8101. if (isSpaMode) {
  8102. return null;
  8103. }
  8104. let restoreScroll = ((STORAGE_KEY2, restoreKey) => {
  8105. if (!window.history.state || !window.history.state.key) {
  8106. let key2 = Math.random().toString(32).slice(2);
  8107. window.history.replaceState({
  8108. key: key2
  8109. }, "");
  8110. }
  8111. try {
  8112. let positions = JSON.parse(sessionStorage.getItem(STORAGE_KEY2) || "{}");
  8113. let storedY = positions[restoreKey || window.history.state.key];
  8114. if (typeof storedY === "number") {
  8115. window.scrollTo(0, storedY);
  8116. }
  8117. } catch (error) {
  8118. console.error(error);
  8119. sessionStorage.removeItem(STORAGE_KEY2);
  8120. }
  8121. }).toString();
  8122. return /* @__PURE__ */ React8.createElement("script", _extends4({}, props, {
  8123. suppressHydrationWarning: true,
  8124. dangerouslySetInnerHTML: {
  8125. __html: `(${restoreScroll})(${JSON.stringify(STORAGE_KEY)}, ${JSON.stringify(key)})`
  8126. }
  8127. }));
  8128. }
  8129. // node_modules/@remix-run/react/dist/esm/server.js
  8130. var React9 = __toESM(require_react());
  8131. var import_server = __toESM(require_server());
  8132. function RemixServer({
  8133. context,
  8134. url,
  8135. abortDelay
  8136. }) {
  8137. if (typeof url === "string") {
  8138. url = new URL(url);
  8139. }
  8140. let {
  8141. manifest,
  8142. routeModules,
  8143. criticalCss,
  8144. serverHandoffString
  8145. } = context;
  8146. let routes = createServerRoutes(manifest.routes, routeModules, context.future, context.isSpaMode);
  8147. context.staticHandlerContext.loaderData = {
  8148. ...context.staticHandlerContext.loaderData
  8149. };
  8150. for (let match of context.staticHandlerContext.matches) {
  8151. let routeId = match.route.id;
  8152. let route = routeModules[routeId];
  8153. let manifestRoute = context.manifest.routes[routeId];
  8154. if (route && shouldHydrateRouteLoader(manifestRoute, route, context.isSpaMode) && (route.HydrateFallback || !manifestRoute.hasLoader)) {
  8155. context.staticHandlerContext.loaderData[routeId] = void 0;
  8156. }
  8157. }
  8158. let router2 = (0, import_server.createStaticRouter)(routes, context.staticHandlerContext, {
  8159. future: {
  8160. v7_partialHydration: true,
  8161. v7_relativeSplatPath: context.future.v3_relativeSplatPath
  8162. }
  8163. });
  8164. return /* @__PURE__ */ React9.createElement(RemixContext.Provider, {
  8165. value: {
  8166. manifest,
  8167. routeModules,
  8168. criticalCss,
  8169. serverHandoffString,
  8170. future: context.future,
  8171. isSpaMode: context.isSpaMode,
  8172. serializeError: context.serializeError,
  8173. abortDelay
  8174. }
  8175. }, /* @__PURE__ */ React9.createElement(RemixErrorBoundary, {
  8176. location: router2.state.location
  8177. }, /* @__PURE__ */ React9.createElement(import_server.StaticRouterProvider, {
  8178. router: router2,
  8179. context: context.staticHandlerContext,
  8180. hydrate: false
  8181. })));
  8182. }
  8183. export {
  8184. createPath,
  8185. parsePath,
  8186. matchRoutes,
  8187. generatePath,
  8188. matchPath,
  8189. resolvePath,
  8190. isRouteErrorResponse,
  8191. useHref,
  8192. useLocation,
  8193. useNavigationType,
  8194. useMatch,
  8195. useNavigate,
  8196. useOutletContext,
  8197. useOutlet,
  8198. useParams,
  8199. useResolvedPath,
  8200. useNavigation,
  8201. useRevalidator,
  8202. useRouteError,
  8203. useAsyncValue,
  8204. useAsyncError,
  8205. useBlocker,
  8206. Outlet,
  8207. Form,
  8208. useSearchParams,
  8209. useSubmit,
  8210. useFormAction,
  8211. useFetchers,
  8212. useBeforeUnload,
  8213. usePrompt,
  8214. useViewTransitionState,
  8215. json3 as json,
  8216. defer3 as defer,
  8217. redirect3 as redirect,
  8218. redirectDocument2 as redirectDocument,
  8219. RemixContext,
  8220. NavLink2 as NavLink,
  8221. Link2 as Link,
  8222. Links,
  8223. PrefetchPageLinks,
  8224. Meta,
  8225. Await2 as Await,
  8226. Scripts,
  8227. useMatches2 as useMatches,
  8228. useLoaderData2 as useLoaderData,
  8229. useRouteLoaderData2 as useRouteLoaderData,
  8230. useActionData2 as useActionData,
  8231. useFetcher2 as useFetcher,
  8232. LiveReload,
  8233. RemixBrowser,
  8234. ScrollRestoration2 as ScrollRestoration,
  8235. RemixServer
  8236. };
  8237. /*! Bundled license information:
  8238. @remix-run/router/dist/router.js:
  8239. (**
  8240. * @remix-run/router v1.15.0
  8241. *
  8242. * Copyright (c) Remix Software Inc.
  8243. *
  8244. * This source code is licensed under the MIT license found in the
  8245. * LICENSE.md file in the root directory of this source tree.
  8246. *
  8247. * @license MIT
  8248. *)
  8249. react-router/dist/index.js:
  8250. (**
  8251. * React Router v6.22.0
  8252. *
  8253. * Copyright (c) Remix Software Inc.
  8254. *
  8255. * This source code is licensed under the MIT license found in the
  8256. * LICENSE.md file in the root directory of this source tree.
  8257. *
  8258. * @license MIT
  8259. *)
  8260. react-router-dom/dist/index.js:
  8261. (**
  8262. * React Router DOM v6.22.0
  8263. *
  8264. * Copyright (c) Remix Software Inc.
  8265. *
  8266. * This source code is licensed under the MIT license found in the
  8267. * LICENSE.md file in the root directory of this source tree.
  8268. *
  8269. * @license MIT
  8270. *)
  8271. @remix-run/server-runtime/dist/esm/responses.js:
  8272. (**
  8273. * @remix-run/server-runtime v2.6.0
  8274. *
  8275. * Copyright (c) Remix Software Inc.
  8276. *
  8277. * This source code is licensed under the MIT license found in the
  8278. * LICENSE.md file in the root directory of this source tree.
  8279. *
  8280. * @license MIT
  8281. *)
  8282. @remix-run/server-runtime/dist/esm/index.js:
  8283. (**
  8284. * @remix-run/server-runtime v2.6.0
  8285. *
  8286. * Copyright (c) Remix Software Inc.
  8287. *
  8288. * This source code is licensed under the MIT license found in the
  8289. * LICENSE.md file in the root directory of this source tree.
  8290. *
  8291. * @license MIT
  8292. *)
  8293. @remix-run/react/dist/esm/_virtual/_rollupPluginBabelHelpers.js:
  8294. (**
  8295. * @remix-run/react v2.6.0
  8296. *
  8297. * Copyright (c) Remix Software Inc.
  8298. *
  8299. * This source code is licensed under the MIT license found in the
  8300. * LICENSE.md file in the root directory of this source tree.
  8301. *
  8302. * @license MIT
  8303. *)
  8304. @remix-run/react/dist/esm/invariant.js:
  8305. (**
  8306. * @remix-run/react v2.6.0
  8307. *
  8308. * Copyright (c) Remix Software Inc.
  8309. *
  8310. * This source code is licensed under the MIT license found in the
  8311. * LICENSE.md file in the root directory of this source tree.
  8312. *
  8313. * @license MIT
  8314. *)
  8315. @remix-run/react/dist/esm/routeModules.js:
  8316. (**
  8317. * @remix-run/react v2.6.0
  8318. *
  8319. * Copyright (c) Remix Software Inc.
  8320. *
  8321. * This source code is licensed under the MIT license found in the
  8322. * LICENSE.md file in the root directory of this source tree.
  8323. *
  8324. * @license MIT
  8325. *)
  8326. @remix-run/react/dist/esm/links.js:
  8327. (**
  8328. * @remix-run/react v2.6.0
  8329. *
  8330. * Copyright (c) Remix Software Inc.
  8331. *
  8332. * This source code is licensed under the MIT license found in the
  8333. * LICENSE.md file in the root directory of this source tree.
  8334. *
  8335. * @license MIT
  8336. *)
  8337. @remix-run/react/dist/esm/markup.js:
  8338. (**
  8339. * @remix-run/react v2.6.0
  8340. *
  8341. * Copyright (c) Remix Software Inc.
  8342. *
  8343. * This source code is licensed under the MIT license found in the
  8344. * LICENSE.md file in the root directory of this source tree.
  8345. *
  8346. * @license MIT
  8347. *)
  8348. @remix-run/react/dist/esm/components.js:
  8349. (**
  8350. * @remix-run/react v2.6.0
  8351. *
  8352. * Copyright (c) Remix Software Inc.
  8353. *
  8354. * This source code is licensed under the MIT license found in the
  8355. * LICENSE.md file in the root directory of this source tree.
  8356. *
  8357. * @license MIT
  8358. *)
  8359. @remix-run/react/dist/esm/errorBoundaries.js:
  8360. (**
  8361. * @remix-run/react v2.6.0
  8362. *
  8363. * Copyright (c) Remix Software Inc.
  8364. *
  8365. * This source code is licensed under the MIT license found in the
  8366. * LICENSE.md file in the root directory of this source tree.
  8367. *
  8368. * @license MIT
  8369. *)
  8370. @remix-run/react/dist/esm/errors.js:
  8371. (**
  8372. * @remix-run/react v2.6.0
  8373. *
  8374. * Copyright (c) Remix Software Inc.
  8375. *
  8376. * This source code is licensed under the MIT license found in the
  8377. * LICENSE.md file in the root directory of this source tree.
  8378. *
  8379. * @license MIT
  8380. *)
  8381. @remix-run/react/dist/esm/data.js:
  8382. (**
  8383. * @remix-run/react v2.6.0
  8384. *
  8385. * Copyright (c) Remix Software Inc.
  8386. *
  8387. * This source code is licensed under the MIT license found in the
  8388. * LICENSE.md file in the root directory of this source tree.
  8389. *
  8390. * @license MIT
  8391. *)
  8392. @remix-run/react/dist/esm/fallback.js:
  8393. (**
  8394. * @remix-run/react v2.6.0
  8395. *
  8396. * Copyright (c) Remix Software Inc.
  8397. *
  8398. * This source code is licensed under the MIT license found in the
  8399. * LICENSE.md file in the root directory of this source tree.
  8400. *
  8401. * @license MIT
  8402. *)
  8403. @remix-run/react/dist/esm/routes.js:
  8404. (**
  8405. * @remix-run/react v2.6.0
  8406. *
  8407. * Copyright (c) Remix Software Inc.
  8408. *
  8409. * This source code is licensed under the MIT license found in the
  8410. * LICENSE.md file in the root directory of this source tree.
  8411. *
  8412. * @license MIT
  8413. *)
  8414. @remix-run/react/dist/esm/browser.js:
  8415. (**
  8416. * @remix-run/react v2.6.0
  8417. *
  8418. * Copyright (c) Remix Software Inc.
  8419. *
  8420. * This source code is licensed under the MIT license found in the
  8421. * LICENSE.md file in the root directory of this source tree.
  8422. *
  8423. * @license MIT
  8424. *)
  8425. @remix-run/react/dist/esm/scroll-restoration.js:
  8426. (**
  8427. * @remix-run/react v2.6.0
  8428. *
  8429. * Copyright (c) Remix Software Inc.
  8430. *
  8431. * This source code is licensed under the MIT license found in the
  8432. * LICENSE.md file in the root directory of this source tree.
  8433. *
  8434. * @license MIT
  8435. *)
  8436. @remix-run/react/dist/esm/server.js:
  8437. (**
  8438. * @remix-run/react v2.6.0
  8439. *
  8440. * Copyright (c) Remix Software Inc.
  8441. *
  8442. * This source code is licensed under the MIT license found in the
  8443. * LICENSE.md file in the root directory of this source tree.
  8444. *
  8445. * @license MIT
  8446. *)
  8447. @remix-run/react/dist/esm/index.js:
  8448. (**
  8449. * @remix-run/react v2.6.0
  8450. *
  8451. * Copyright (c) Remix Software Inc.
  8452. *
  8453. * This source code is licensed under the MIT license found in the
  8454. * LICENSE.md file in the root directory of this source tree.
  8455. *
  8456. * @license MIT
  8457. *)
  8458. */
  8459. //# sourceMappingURL=/build/_shared/chunk-KFYUZA3E.js.map