vue.esm-browser.js 435 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377
  1. function makeMap(str, expectsLowerCase) {
  2. const map = /* @__PURE__ */ Object.create(null);
  3. const list = str.split(",");
  4. for (let i = 0; i < list.length; i++) {
  5. map[list[i]] = true;
  6. }
  7. return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
  8. }
  9. const EMPTY_OBJ = Object.freeze({}) ;
  10. const EMPTY_ARR = Object.freeze([]) ;
  11. const NOOP = () => {
  12. };
  13. const NO = () => false;
  14. const onRE = /^on[^a-z]/;
  15. const isOn = (key) => onRE.test(key);
  16. const isModelListener = (key) => key.startsWith("onUpdate:");
  17. const extend = Object.assign;
  18. const remove = (arr, el) => {
  19. const i = arr.indexOf(el);
  20. if (i > -1) {
  21. arr.splice(i, 1);
  22. }
  23. };
  24. const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  25. const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
  26. const isArray = Array.isArray;
  27. const isMap = (val) => toTypeString(val) === "[object Map]";
  28. const isSet = (val) => toTypeString(val) === "[object Set]";
  29. const isDate = (val) => toTypeString(val) === "[object Date]";
  30. const isRegExp = (val) => toTypeString(val) === "[object RegExp]";
  31. const isFunction = (val) => typeof val === "function";
  32. const isString = (val) => typeof val === "string";
  33. const isSymbol = (val) => typeof val === "symbol";
  34. const isObject = (val) => val !== null && typeof val === "object";
  35. const isPromise = (val) => {
  36. return isObject(val) && isFunction(val.then) && isFunction(val.catch);
  37. };
  38. const objectToString = Object.prototype.toString;
  39. const toTypeString = (value) => objectToString.call(value);
  40. const toRawType = (value) => {
  41. return toTypeString(value).slice(8, -1);
  42. };
  43. const isPlainObject = (val) => toTypeString(val) === "[object Object]";
  44. const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
  45. const isReservedProp = /* @__PURE__ */ makeMap(
  46. // the leading comma is intentional so empty string "" is also included
  47. ",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
  48. );
  49. const isBuiltInDirective = /* @__PURE__ */ makeMap(
  50. "bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
  51. );
  52. const cacheStringFunction = (fn) => {
  53. const cache = /* @__PURE__ */ Object.create(null);
  54. return (str) => {
  55. const hit = cache[str];
  56. return hit || (cache[str] = fn(str));
  57. };
  58. };
  59. const camelizeRE = /-(\w)/g;
  60. const camelize = cacheStringFunction((str) => {
  61. return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
  62. });
  63. const hyphenateRE = /\B([A-Z])/g;
  64. const hyphenate = cacheStringFunction(
  65. (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
  66. );
  67. const capitalize = cacheStringFunction(
  68. (str) => str.charAt(0).toUpperCase() + str.slice(1)
  69. );
  70. const toHandlerKey = cacheStringFunction(
  71. (str) => str ? `on${capitalize(str)}` : ``
  72. );
  73. const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
  74. const invokeArrayFns = (fns, arg) => {
  75. for (let i = 0; i < fns.length; i++) {
  76. fns[i](arg);
  77. }
  78. };
  79. const def = (obj, key, value) => {
  80. Object.defineProperty(obj, key, {
  81. configurable: true,
  82. enumerable: false,
  83. value
  84. });
  85. };
  86. const looseToNumber = (val) => {
  87. const n = parseFloat(val);
  88. return isNaN(n) ? val : n;
  89. };
  90. const toNumber = (val) => {
  91. const n = isString(val) ? Number(val) : NaN;
  92. return isNaN(n) ? val : n;
  93. };
  94. let _globalThis;
  95. const getGlobalThis = () => {
  96. return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
  97. };
  98. const PatchFlagNames = {
  99. [1]: `TEXT`,
  100. [2]: `CLASS`,
  101. [4]: `STYLE`,
  102. [8]: `PROPS`,
  103. [16]: `FULL_PROPS`,
  104. [32]: `HYDRATE_EVENTS`,
  105. [64]: `STABLE_FRAGMENT`,
  106. [128]: `KEYED_FRAGMENT`,
  107. [256]: `UNKEYED_FRAGMENT`,
  108. [512]: `NEED_PATCH`,
  109. [1024]: `DYNAMIC_SLOTS`,
  110. [2048]: `DEV_ROOT_FRAGMENT`,
  111. [-1]: `HOISTED`,
  112. [-2]: `BAIL`
  113. };
  114. const slotFlagsText = {
  115. [1]: "STABLE",
  116. [2]: "DYNAMIC",
  117. [3]: "FORWARDED"
  118. };
  119. const GLOBALS_WHITE_LISTED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console";
  120. const isGloballyWhitelisted = /* @__PURE__ */ makeMap(GLOBALS_WHITE_LISTED);
  121. const range = 2;
  122. function generateCodeFrame(source, start = 0, end = source.length) {
  123. let lines = source.split(/(\r?\n)/);
  124. const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
  125. lines = lines.filter((_, idx) => idx % 2 === 0);
  126. let count = 0;
  127. const res = [];
  128. for (let i = 0; i < lines.length; i++) {
  129. count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
  130. if (count >= start) {
  131. for (let j = i - range; j <= i + range || end > count; j++) {
  132. if (j < 0 || j >= lines.length)
  133. continue;
  134. const line = j + 1;
  135. res.push(
  136. `${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
  137. );
  138. const lineLength = lines[j].length;
  139. const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
  140. if (j === i) {
  141. const pad = start - (count - (lineLength + newLineSeqLength));
  142. const length = Math.max(
  143. 1,
  144. end > count ? lineLength - pad : end - start
  145. );
  146. res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
  147. } else if (j > i) {
  148. if (end > count) {
  149. const length = Math.max(Math.min(end - count, lineLength), 1);
  150. res.push(` | ` + "^".repeat(length));
  151. }
  152. count += lineLength + newLineSeqLength;
  153. }
  154. }
  155. break;
  156. }
  157. }
  158. return res.join("\n");
  159. }
  160. function normalizeStyle(value) {
  161. if (isArray(value)) {
  162. const res = {};
  163. for (let i = 0; i < value.length; i++) {
  164. const item = value[i];
  165. const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
  166. if (normalized) {
  167. for (const key in normalized) {
  168. res[key] = normalized[key];
  169. }
  170. }
  171. }
  172. return res;
  173. } else if (isString(value)) {
  174. return value;
  175. } else if (isObject(value)) {
  176. return value;
  177. }
  178. }
  179. const listDelimiterRE = /;(?![^(]*\))/g;
  180. const propertyDelimiterRE = /:([^]+)/;
  181. const styleCommentRE = /\/\*[^]*?\*\//g;
  182. function parseStringStyle(cssText) {
  183. const ret = {};
  184. cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
  185. if (item) {
  186. const tmp = item.split(propertyDelimiterRE);
  187. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  188. }
  189. });
  190. return ret;
  191. }
  192. function normalizeClass(value) {
  193. let res = "";
  194. if (isString(value)) {
  195. res = value;
  196. } else if (isArray(value)) {
  197. for (let i = 0; i < value.length; i++) {
  198. const normalized = normalizeClass(value[i]);
  199. if (normalized) {
  200. res += normalized + " ";
  201. }
  202. }
  203. } else if (isObject(value)) {
  204. for (const name in value) {
  205. if (value[name]) {
  206. res += name + " ";
  207. }
  208. }
  209. }
  210. return res.trim();
  211. }
  212. function normalizeProps(props) {
  213. if (!props)
  214. return null;
  215. let { class: klass, style } = props;
  216. if (klass && !isString(klass)) {
  217. props.class = normalizeClass(klass);
  218. }
  219. if (style) {
  220. props.style = normalizeStyle(style);
  221. }
  222. return props;
  223. }
  224. const HTML_TAGS = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot";
  225. const SVG_TAGS = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view";
  226. const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
  227. const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
  228. const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
  229. const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
  230. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  231. const isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs);
  232. function includeBooleanAttr(value) {
  233. return !!value || value === "";
  234. }
  235. function looseCompareArrays(a, b) {
  236. if (a.length !== b.length)
  237. return false;
  238. let equal = true;
  239. for (let i = 0; equal && i < a.length; i++) {
  240. equal = looseEqual(a[i], b[i]);
  241. }
  242. return equal;
  243. }
  244. function looseEqual(a, b) {
  245. if (a === b)
  246. return true;
  247. let aValidType = isDate(a);
  248. let bValidType = isDate(b);
  249. if (aValidType || bValidType) {
  250. return aValidType && bValidType ? a.getTime() === b.getTime() : false;
  251. }
  252. aValidType = isSymbol(a);
  253. bValidType = isSymbol(b);
  254. if (aValidType || bValidType) {
  255. return a === b;
  256. }
  257. aValidType = isArray(a);
  258. bValidType = isArray(b);
  259. if (aValidType || bValidType) {
  260. return aValidType && bValidType ? looseCompareArrays(a, b) : false;
  261. }
  262. aValidType = isObject(a);
  263. bValidType = isObject(b);
  264. if (aValidType || bValidType) {
  265. if (!aValidType || !bValidType) {
  266. return false;
  267. }
  268. const aKeysCount = Object.keys(a).length;
  269. const bKeysCount = Object.keys(b).length;
  270. if (aKeysCount !== bKeysCount) {
  271. return false;
  272. }
  273. for (const key in a) {
  274. const aHasKey = a.hasOwnProperty(key);
  275. const bHasKey = b.hasOwnProperty(key);
  276. if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) {
  277. return false;
  278. }
  279. }
  280. }
  281. return String(a) === String(b);
  282. }
  283. function looseIndexOf(arr, val) {
  284. return arr.findIndex((item) => looseEqual(item, val));
  285. }
  286. const toDisplayString = (val) => {
  287. return isString(val) ? val : val == null ? "" : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val);
  288. };
  289. const replacer = (_key, val) => {
  290. if (val && val.__v_isRef) {
  291. return replacer(_key, val.value);
  292. } else if (isMap(val)) {
  293. return {
  294. [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val2]) => {
  295. entries[`${key} =>`] = val2;
  296. return entries;
  297. }, {})
  298. };
  299. } else if (isSet(val)) {
  300. return {
  301. [`Set(${val.size})`]: [...val.values()]
  302. };
  303. } else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
  304. return String(val);
  305. }
  306. return val;
  307. };
  308. function warn$1(msg, ...args) {
  309. console.warn(`[Vue warn] ${msg}`, ...args);
  310. }
  311. let activeEffectScope;
  312. class EffectScope {
  313. constructor(detached = false) {
  314. this.detached = detached;
  315. /**
  316. * @internal
  317. */
  318. this._active = true;
  319. /**
  320. * @internal
  321. */
  322. this.effects = [];
  323. /**
  324. * @internal
  325. */
  326. this.cleanups = [];
  327. this.parent = activeEffectScope;
  328. if (!detached && activeEffectScope) {
  329. this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
  330. this
  331. ) - 1;
  332. }
  333. }
  334. get active() {
  335. return this._active;
  336. }
  337. run(fn) {
  338. if (this._active) {
  339. const currentEffectScope = activeEffectScope;
  340. try {
  341. activeEffectScope = this;
  342. return fn();
  343. } finally {
  344. activeEffectScope = currentEffectScope;
  345. }
  346. } else {
  347. warn$1(`cannot run an inactive effect scope.`);
  348. }
  349. }
  350. /**
  351. * This should only be called on non-detached scopes
  352. * @internal
  353. */
  354. on() {
  355. activeEffectScope = this;
  356. }
  357. /**
  358. * This should only be called on non-detached scopes
  359. * @internal
  360. */
  361. off() {
  362. activeEffectScope = this.parent;
  363. }
  364. stop(fromParent) {
  365. if (this._active) {
  366. let i, l;
  367. for (i = 0, l = this.effects.length; i < l; i++) {
  368. this.effects[i].stop();
  369. }
  370. for (i = 0, l = this.cleanups.length; i < l; i++) {
  371. this.cleanups[i]();
  372. }
  373. if (this.scopes) {
  374. for (i = 0, l = this.scopes.length; i < l; i++) {
  375. this.scopes[i].stop(true);
  376. }
  377. }
  378. if (!this.detached && this.parent && !fromParent) {
  379. const last = this.parent.scopes.pop();
  380. if (last && last !== this) {
  381. this.parent.scopes[this.index] = last;
  382. last.index = this.index;
  383. }
  384. }
  385. this.parent = void 0;
  386. this._active = false;
  387. }
  388. }
  389. }
  390. function effectScope(detached) {
  391. return new EffectScope(detached);
  392. }
  393. function recordEffectScope(effect, scope = activeEffectScope) {
  394. if (scope && scope.active) {
  395. scope.effects.push(effect);
  396. }
  397. }
  398. function getCurrentScope() {
  399. return activeEffectScope;
  400. }
  401. function onScopeDispose(fn) {
  402. if (activeEffectScope) {
  403. activeEffectScope.cleanups.push(fn);
  404. } else {
  405. warn$1(
  406. `onScopeDispose() is called when there is no active effect scope to be associated with.`
  407. );
  408. }
  409. }
  410. const createDep = (effects) => {
  411. const dep = new Set(effects);
  412. dep.w = 0;
  413. dep.n = 0;
  414. return dep;
  415. };
  416. const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
  417. const newTracked = (dep) => (dep.n & trackOpBit) > 0;
  418. const initDepMarkers = ({ deps }) => {
  419. if (deps.length) {
  420. for (let i = 0; i < deps.length; i++) {
  421. deps[i].w |= trackOpBit;
  422. }
  423. }
  424. };
  425. const finalizeDepMarkers = (effect) => {
  426. const { deps } = effect;
  427. if (deps.length) {
  428. let ptr = 0;
  429. for (let i = 0; i < deps.length; i++) {
  430. const dep = deps[i];
  431. if (wasTracked(dep) && !newTracked(dep)) {
  432. dep.delete(effect);
  433. } else {
  434. deps[ptr++] = dep;
  435. }
  436. dep.w &= ~trackOpBit;
  437. dep.n &= ~trackOpBit;
  438. }
  439. deps.length = ptr;
  440. }
  441. };
  442. const targetMap = /* @__PURE__ */ new WeakMap();
  443. let effectTrackDepth = 0;
  444. let trackOpBit = 1;
  445. const maxMarkerBits = 30;
  446. let activeEffect;
  447. const ITERATE_KEY = Symbol("iterate" );
  448. const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate" );
  449. class ReactiveEffect {
  450. constructor(fn, scheduler = null, scope) {
  451. this.fn = fn;
  452. this.scheduler = scheduler;
  453. this.active = true;
  454. this.deps = [];
  455. this.parent = void 0;
  456. recordEffectScope(this, scope);
  457. }
  458. run() {
  459. if (!this.active) {
  460. return this.fn();
  461. }
  462. let parent = activeEffect;
  463. let lastShouldTrack = shouldTrack;
  464. while (parent) {
  465. if (parent === this) {
  466. return;
  467. }
  468. parent = parent.parent;
  469. }
  470. try {
  471. this.parent = activeEffect;
  472. activeEffect = this;
  473. shouldTrack = true;
  474. trackOpBit = 1 << ++effectTrackDepth;
  475. if (effectTrackDepth <= maxMarkerBits) {
  476. initDepMarkers(this);
  477. } else {
  478. cleanupEffect(this);
  479. }
  480. return this.fn();
  481. } finally {
  482. if (effectTrackDepth <= maxMarkerBits) {
  483. finalizeDepMarkers(this);
  484. }
  485. trackOpBit = 1 << --effectTrackDepth;
  486. activeEffect = this.parent;
  487. shouldTrack = lastShouldTrack;
  488. this.parent = void 0;
  489. if (this.deferStop) {
  490. this.stop();
  491. }
  492. }
  493. }
  494. stop() {
  495. if (activeEffect === this) {
  496. this.deferStop = true;
  497. } else if (this.active) {
  498. cleanupEffect(this);
  499. if (this.onStop) {
  500. this.onStop();
  501. }
  502. this.active = false;
  503. }
  504. }
  505. }
  506. function cleanupEffect(effect2) {
  507. const { deps } = effect2;
  508. if (deps.length) {
  509. for (let i = 0; i < deps.length; i++) {
  510. deps[i].delete(effect2);
  511. }
  512. deps.length = 0;
  513. }
  514. }
  515. function effect(fn, options) {
  516. if (fn.effect) {
  517. fn = fn.effect.fn;
  518. }
  519. const _effect = new ReactiveEffect(fn);
  520. if (options) {
  521. extend(_effect, options);
  522. if (options.scope)
  523. recordEffectScope(_effect, options.scope);
  524. }
  525. if (!options || !options.lazy) {
  526. _effect.run();
  527. }
  528. const runner = _effect.run.bind(_effect);
  529. runner.effect = _effect;
  530. return runner;
  531. }
  532. function stop(runner) {
  533. runner.effect.stop();
  534. }
  535. let shouldTrack = true;
  536. const trackStack = [];
  537. function pauseTracking() {
  538. trackStack.push(shouldTrack);
  539. shouldTrack = false;
  540. }
  541. function resetTracking() {
  542. const last = trackStack.pop();
  543. shouldTrack = last === void 0 ? true : last;
  544. }
  545. function track(target, type, key) {
  546. if (shouldTrack && activeEffect) {
  547. let depsMap = targetMap.get(target);
  548. if (!depsMap) {
  549. targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
  550. }
  551. let dep = depsMap.get(key);
  552. if (!dep) {
  553. depsMap.set(key, dep = createDep());
  554. }
  555. const eventInfo = { effect: activeEffect, target, type, key } ;
  556. trackEffects(dep, eventInfo);
  557. }
  558. }
  559. function trackEffects(dep, debuggerEventExtraInfo) {
  560. let shouldTrack2 = false;
  561. if (effectTrackDepth <= maxMarkerBits) {
  562. if (!newTracked(dep)) {
  563. dep.n |= trackOpBit;
  564. shouldTrack2 = !wasTracked(dep);
  565. }
  566. } else {
  567. shouldTrack2 = !dep.has(activeEffect);
  568. }
  569. if (shouldTrack2) {
  570. dep.add(activeEffect);
  571. activeEffect.deps.push(dep);
  572. if (activeEffect.onTrack) {
  573. activeEffect.onTrack(
  574. extend(
  575. {
  576. effect: activeEffect
  577. },
  578. debuggerEventExtraInfo
  579. )
  580. );
  581. }
  582. }
  583. }
  584. function trigger(target, type, key, newValue, oldValue, oldTarget) {
  585. const depsMap = targetMap.get(target);
  586. if (!depsMap) {
  587. return;
  588. }
  589. let deps = [];
  590. if (type === "clear") {
  591. deps = [...depsMap.values()];
  592. } else if (key === "length" && isArray(target)) {
  593. const newLength = Number(newValue);
  594. depsMap.forEach((dep, key2) => {
  595. if (key2 === "length" || key2 >= newLength) {
  596. deps.push(dep);
  597. }
  598. });
  599. } else {
  600. if (key !== void 0) {
  601. deps.push(depsMap.get(key));
  602. }
  603. switch (type) {
  604. case "add":
  605. if (!isArray(target)) {
  606. deps.push(depsMap.get(ITERATE_KEY));
  607. if (isMap(target)) {
  608. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
  609. }
  610. } else if (isIntegerKey(key)) {
  611. deps.push(depsMap.get("length"));
  612. }
  613. break;
  614. case "delete":
  615. if (!isArray(target)) {
  616. deps.push(depsMap.get(ITERATE_KEY));
  617. if (isMap(target)) {
  618. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
  619. }
  620. }
  621. break;
  622. case "set":
  623. if (isMap(target)) {
  624. deps.push(depsMap.get(ITERATE_KEY));
  625. }
  626. break;
  627. }
  628. }
  629. const eventInfo = { target, type, key, newValue, oldValue, oldTarget } ;
  630. if (deps.length === 1) {
  631. if (deps[0]) {
  632. {
  633. triggerEffects(deps[0], eventInfo);
  634. }
  635. }
  636. } else {
  637. const effects = [];
  638. for (const dep of deps) {
  639. if (dep) {
  640. effects.push(...dep);
  641. }
  642. }
  643. {
  644. triggerEffects(createDep(effects), eventInfo);
  645. }
  646. }
  647. }
  648. function triggerEffects(dep, debuggerEventExtraInfo) {
  649. const effects = isArray(dep) ? dep : [...dep];
  650. for (const effect2 of effects) {
  651. if (effect2.computed) {
  652. triggerEffect(effect2, debuggerEventExtraInfo);
  653. }
  654. }
  655. for (const effect2 of effects) {
  656. if (!effect2.computed) {
  657. triggerEffect(effect2, debuggerEventExtraInfo);
  658. }
  659. }
  660. }
  661. function triggerEffect(effect2, debuggerEventExtraInfo) {
  662. if (effect2 !== activeEffect || effect2.allowRecurse) {
  663. if (effect2.onTrigger) {
  664. effect2.onTrigger(extend({ effect: effect2 }, debuggerEventExtraInfo));
  665. }
  666. if (effect2.scheduler) {
  667. effect2.scheduler();
  668. } else {
  669. effect2.run();
  670. }
  671. }
  672. }
  673. function getDepFromReactive(object, key) {
  674. var _a;
  675. return (_a = targetMap.get(object)) == null ? void 0 : _a.get(key);
  676. }
  677. const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
  678. const builtInSymbols = new Set(
  679. /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
  680. );
  681. const get$1 = /* @__PURE__ */ createGetter();
  682. const shallowGet = /* @__PURE__ */ createGetter(false, true);
  683. const readonlyGet = /* @__PURE__ */ createGetter(true);
  684. const shallowReadonlyGet = /* @__PURE__ */ createGetter(true, true);
  685. const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
  686. function createArrayInstrumentations() {
  687. const instrumentations = {};
  688. ["includes", "indexOf", "lastIndexOf"].forEach((key) => {
  689. instrumentations[key] = function(...args) {
  690. const arr = toRaw(this);
  691. for (let i = 0, l = this.length; i < l; i++) {
  692. track(arr, "get", i + "");
  693. }
  694. const res = arr[key](...args);
  695. if (res === -1 || res === false) {
  696. return arr[key](...args.map(toRaw));
  697. } else {
  698. return res;
  699. }
  700. };
  701. });
  702. ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
  703. instrumentations[key] = function(...args) {
  704. pauseTracking();
  705. const res = toRaw(this)[key].apply(this, args);
  706. resetTracking();
  707. return res;
  708. };
  709. });
  710. return instrumentations;
  711. }
  712. function hasOwnProperty(key) {
  713. const obj = toRaw(this);
  714. track(obj, "has", key);
  715. return obj.hasOwnProperty(key);
  716. }
  717. function createGetter(isReadonly2 = false, shallow = false) {
  718. return function get2(target, key, receiver) {
  719. if (key === "__v_isReactive") {
  720. return !isReadonly2;
  721. } else if (key === "__v_isReadonly") {
  722. return isReadonly2;
  723. } else if (key === "__v_isShallow") {
  724. return shallow;
  725. } else if (key === "__v_raw" && receiver === (isReadonly2 ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) {
  726. return target;
  727. }
  728. const targetIsArray = isArray(target);
  729. if (!isReadonly2) {
  730. if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
  731. return Reflect.get(arrayInstrumentations, key, receiver);
  732. }
  733. if (key === "hasOwnProperty") {
  734. return hasOwnProperty;
  735. }
  736. }
  737. const res = Reflect.get(target, key, receiver);
  738. if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
  739. return res;
  740. }
  741. if (!isReadonly2) {
  742. track(target, "get", key);
  743. }
  744. if (shallow) {
  745. return res;
  746. }
  747. if (isRef(res)) {
  748. return targetIsArray && isIntegerKey(key) ? res : res.value;
  749. }
  750. if (isObject(res)) {
  751. return isReadonly2 ? readonly(res) : reactive(res);
  752. }
  753. return res;
  754. };
  755. }
  756. const set$1 = /* @__PURE__ */ createSetter();
  757. const shallowSet = /* @__PURE__ */ createSetter(true);
  758. function createSetter(shallow = false) {
  759. return function set2(target, key, value, receiver) {
  760. let oldValue = target[key];
  761. if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
  762. return false;
  763. }
  764. if (!shallow) {
  765. if (!isShallow(value) && !isReadonly(value)) {
  766. oldValue = toRaw(oldValue);
  767. value = toRaw(value);
  768. }
  769. if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
  770. oldValue.value = value;
  771. return true;
  772. }
  773. }
  774. const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
  775. const result = Reflect.set(target, key, value, receiver);
  776. if (target === toRaw(receiver)) {
  777. if (!hadKey) {
  778. trigger(target, "add", key, value);
  779. } else if (hasChanged(value, oldValue)) {
  780. trigger(target, "set", key, value, oldValue);
  781. }
  782. }
  783. return result;
  784. };
  785. }
  786. function deleteProperty(target, key) {
  787. const hadKey = hasOwn(target, key);
  788. const oldValue = target[key];
  789. const result = Reflect.deleteProperty(target, key);
  790. if (result && hadKey) {
  791. trigger(target, "delete", key, void 0, oldValue);
  792. }
  793. return result;
  794. }
  795. function has$1(target, key) {
  796. const result = Reflect.has(target, key);
  797. if (!isSymbol(key) || !builtInSymbols.has(key)) {
  798. track(target, "has", key);
  799. }
  800. return result;
  801. }
  802. function ownKeys(target) {
  803. track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
  804. return Reflect.ownKeys(target);
  805. }
  806. const mutableHandlers = {
  807. get: get$1,
  808. set: set$1,
  809. deleteProperty,
  810. has: has$1,
  811. ownKeys
  812. };
  813. const readonlyHandlers = {
  814. get: readonlyGet,
  815. set(target, key) {
  816. {
  817. warn$1(
  818. `Set operation on key "${String(key)}" failed: target is readonly.`,
  819. target
  820. );
  821. }
  822. return true;
  823. },
  824. deleteProperty(target, key) {
  825. {
  826. warn$1(
  827. `Delete operation on key "${String(key)}" failed: target is readonly.`,
  828. target
  829. );
  830. }
  831. return true;
  832. }
  833. };
  834. const shallowReactiveHandlers = /* @__PURE__ */ extend(
  835. {},
  836. mutableHandlers,
  837. {
  838. get: shallowGet,
  839. set: shallowSet
  840. }
  841. );
  842. const shallowReadonlyHandlers = /* @__PURE__ */ extend(
  843. {},
  844. readonlyHandlers,
  845. {
  846. get: shallowReadonlyGet
  847. }
  848. );
  849. const toShallow = (value) => value;
  850. const getProto = (v) => Reflect.getPrototypeOf(v);
  851. function get(target, key, isReadonly = false, isShallow = false) {
  852. target = target["__v_raw"];
  853. const rawTarget = toRaw(target);
  854. const rawKey = toRaw(key);
  855. if (!isReadonly) {
  856. if (key !== rawKey) {
  857. track(rawTarget, "get", key);
  858. }
  859. track(rawTarget, "get", rawKey);
  860. }
  861. const { has: has2 } = getProto(rawTarget);
  862. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  863. if (has2.call(rawTarget, key)) {
  864. return wrap(target.get(key));
  865. } else if (has2.call(rawTarget, rawKey)) {
  866. return wrap(target.get(rawKey));
  867. } else if (target !== rawTarget) {
  868. target.get(key);
  869. }
  870. }
  871. function has(key, isReadonly = false) {
  872. const target = this["__v_raw"];
  873. const rawTarget = toRaw(target);
  874. const rawKey = toRaw(key);
  875. if (!isReadonly) {
  876. if (key !== rawKey) {
  877. track(rawTarget, "has", key);
  878. }
  879. track(rawTarget, "has", rawKey);
  880. }
  881. return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
  882. }
  883. function size(target, isReadonly = false) {
  884. target = target["__v_raw"];
  885. !isReadonly && track(toRaw(target), "iterate", ITERATE_KEY);
  886. return Reflect.get(target, "size", target);
  887. }
  888. function add(value) {
  889. value = toRaw(value);
  890. const target = toRaw(this);
  891. const proto = getProto(target);
  892. const hadKey = proto.has.call(target, value);
  893. if (!hadKey) {
  894. target.add(value);
  895. trigger(target, "add", value, value);
  896. }
  897. return this;
  898. }
  899. function set(key, value) {
  900. value = toRaw(value);
  901. const target = toRaw(this);
  902. const { has: has2, get: get2 } = getProto(target);
  903. let hadKey = has2.call(target, key);
  904. if (!hadKey) {
  905. key = toRaw(key);
  906. hadKey = has2.call(target, key);
  907. } else {
  908. checkIdentityKeys(target, has2, key);
  909. }
  910. const oldValue = get2.call(target, key);
  911. target.set(key, value);
  912. if (!hadKey) {
  913. trigger(target, "add", key, value);
  914. } else if (hasChanged(value, oldValue)) {
  915. trigger(target, "set", key, value, oldValue);
  916. }
  917. return this;
  918. }
  919. function deleteEntry(key) {
  920. const target = toRaw(this);
  921. const { has: has2, get: get2 } = getProto(target);
  922. let hadKey = has2.call(target, key);
  923. if (!hadKey) {
  924. key = toRaw(key);
  925. hadKey = has2.call(target, key);
  926. } else {
  927. checkIdentityKeys(target, has2, key);
  928. }
  929. const oldValue = get2 ? get2.call(target, key) : void 0;
  930. const result = target.delete(key);
  931. if (hadKey) {
  932. trigger(target, "delete", key, void 0, oldValue);
  933. }
  934. return result;
  935. }
  936. function clear() {
  937. const target = toRaw(this);
  938. const hadItems = target.size !== 0;
  939. const oldTarget = isMap(target) ? new Map(target) : new Set(target) ;
  940. const result = target.clear();
  941. if (hadItems) {
  942. trigger(target, "clear", void 0, void 0, oldTarget);
  943. }
  944. return result;
  945. }
  946. function createForEach(isReadonly, isShallow) {
  947. return function forEach(callback, thisArg) {
  948. const observed = this;
  949. const target = observed["__v_raw"];
  950. const rawTarget = toRaw(target);
  951. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  952. !isReadonly && track(rawTarget, "iterate", ITERATE_KEY);
  953. return target.forEach((value, key) => {
  954. return callback.call(thisArg, wrap(value), wrap(key), observed);
  955. });
  956. };
  957. }
  958. function createIterableMethod(method, isReadonly, isShallow) {
  959. return function(...args) {
  960. const target = this["__v_raw"];
  961. const rawTarget = toRaw(target);
  962. const targetIsMap = isMap(rawTarget);
  963. const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
  964. const isKeyOnly = method === "keys" && targetIsMap;
  965. const innerIterator = target[method](...args);
  966. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  967. !isReadonly && track(
  968. rawTarget,
  969. "iterate",
  970. isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
  971. );
  972. return {
  973. // iterator protocol
  974. next() {
  975. const { value, done } = innerIterator.next();
  976. return done ? { value, done } : {
  977. value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
  978. done
  979. };
  980. },
  981. // iterable protocol
  982. [Symbol.iterator]() {
  983. return this;
  984. }
  985. };
  986. };
  987. }
  988. function createReadonlyMethod(type) {
  989. return function(...args) {
  990. {
  991. const key = args[0] ? `on key "${args[0]}" ` : ``;
  992. console.warn(
  993. `${capitalize(type)} operation ${key}failed: target is readonly.`,
  994. toRaw(this)
  995. );
  996. }
  997. return type === "delete" ? false : this;
  998. };
  999. }
  1000. function createInstrumentations() {
  1001. const mutableInstrumentations2 = {
  1002. get(key) {
  1003. return get(this, key);
  1004. },
  1005. get size() {
  1006. return size(this);
  1007. },
  1008. has,
  1009. add,
  1010. set,
  1011. delete: deleteEntry,
  1012. clear,
  1013. forEach: createForEach(false, false)
  1014. };
  1015. const shallowInstrumentations2 = {
  1016. get(key) {
  1017. return get(this, key, false, true);
  1018. },
  1019. get size() {
  1020. return size(this);
  1021. },
  1022. has,
  1023. add,
  1024. set,
  1025. delete: deleteEntry,
  1026. clear,
  1027. forEach: createForEach(false, true)
  1028. };
  1029. const readonlyInstrumentations2 = {
  1030. get(key) {
  1031. return get(this, key, true);
  1032. },
  1033. get size() {
  1034. return size(this, true);
  1035. },
  1036. has(key) {
  1037. return has.call(this, key, true);
  1038. },
  1039. add: createReadonlyMethod("add"),
  1040. set: createReadonlyMethod("set"),
  1041. delete: createReadonlyMethod("delete"),
  1042. clear: createReadonlyMethod("clear"),
  1043. forEach: createForEach(true, false)
  1044. };
  1045. const shallowReadonlyInstrumentations2 = {
  1046. get(key) {
  1047. return get(this, key, true, true);
  1048. },
  1049. get size() {
  1050. return size(this, true);
  1051. },
  1052. has(key) {
  1053. return has.call(this, key, true);
  1054. },
  1055. add: createReadonlyMethod("add"),
  1056. set: createReadonlyMethod("set"),
  1057. delete: createReadonlyMethod("delete"),
  1058. clear: createReadonlyMethod("clear"),
  1059. forEach: createForEach(true, true)
  1060. };
  1061. const iteratorMethods = ["keys", "values", "entries", Symbol.iterator];
  1062. iteratorMethods.forEach((method) => {
  1063. mutableInstrumentations2[method] = createIterableMethod(
  1064. method,
  1065. false,
  1066. false
  1067. );
  1068. readonlyInstrumentations2[method] = createIterableMethod(
  1069. method,
  1070. true,
  1071. false
  1072. );
  1073. shallowInstrumentations2[method] = createIterableMethod(
  1074. method,
  1075. false,
  1076. true
  1077. );
  1078. shallowReadonlyInstrumentations2[method] = createIterableMethod(
  1079. method,
  1080. true,
  1081. true
  1082. );
  1083. });
  1084. return [
  1085. mutableInstrumentations2,
  1086. readonlyInstrumentations2,
  1087. shallowInstrumentations2,
  1088. shallowReadonlyInstrumentations2
  1089. ];
  1090. }
  1091. const [
  1092. mutableInstrumentations,
  1093. readonlyInstrumentations,
  1094. shallowInstrumentations,
  1095. shallowReadonlyInstrumentations
  1096. ] = /* @__PURE__ */ createInstrumentations();
  1097. function createInstrumentationGetter(isReadonly, shallow) {
  1098. const instrumentations = shallow ? isReadonly ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations;
  1099. return (target, key, receiver) => {
  1100. if (key === "__v_isReactive") {
  1101. return !isReadonly;
  1102. } else if (key === "__v_isReadonly") {
  1103. return isReadonly;
  1104. } else if (key === "__v_raw") {
  1105. return target;
  1106. }
  1107. return Reflect.get(
  1108. hasOwn(instrumentations, key) && key in target ? instrumentations : target,
  1109. key,
  1110. receiver
  1111. );
  1112. };
  1113. }
  1114. const mutableCollectionHandlers = {
  1115. get: /* @__PURE__ */ createInstrumentationGetter(false, false)
  1116. };
  1117. const shallowCollectionHandlers = {
  1118. get: /* @__PURE__ */ createInstrumentationGetter(false, true)
  1119. };
  1120. const readonlyCollectionHandlers = {
  1121. get: /* @__PURE__ */ createInstrumentationGetter(true, false)
  1122. };
  1123. const shallowReadonlyCollectionHandlers = {
  1124. get: /* @__PURE__ */ createInstrumentationGetter(true, true)
  1125. };
  1126. function checkIdentityKeys(target, has2, key) {
  1127. const rawKey = toRaw(key);
  1128. if (rawKey !== key && has2.call(target, rawKey)) {
  1129. const type = toRawType(target);
  1130. console.warn(
  1131. `Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`
  1132. );
  1133. }
  1134. }
  1135. const reactiveMap = /* @__PURE__ */ new WeakMap();
  1136. const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
  1137. const readonlyMap = /* @__PURE__ */ new WeakMap();
  1138. const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
  1139. function targetTypeMap(rawType) {
  1140. switch (rawType) {
  1141. case "Object":
  1142. case "Array":
  1143. return 1 /* COMMON */;
  1144. case "Map":
  1145. case "Set":
  1146. case "WeakMap":
  1147. case "WeakSet":
  1148. return 2 /* COLLECTION */;
  1149. default:
  1150. return 0 /* INVALID */;
  1151. }
  1152. }
  1153. function getTargetType(value) {
  1154. return value["__v_skip"] || !Object.isExtensible(value) ? 0 /* INVALID */ : targetTypeMap(toRawType(value));
  1155. }
  1156. function reactive(target) {
  1157. if (isReadonly(target)) {
  1158. return target;
  1159. }
  1160. return createReactiveObject(
  1161. target,
  1162. false,
  1163. mutableHandlers,
  1164. mutableCollectionHandlers,
  1165. reactiveMap
  1166. );
  1167. }
  1168. function shallowReactive(target) {
  1169. return createReactiveObject(
  1170. target,
  1171. false,
  1172. shallowReactiveHandlers,
  1173. shallowCollectionHandlers,
  1174. shallowReactiveMap
  1175. );
  1176. }
  1177. function readonly(target) {
  1178. return createReactiveObject(
  1179. target,
  1180. true,
  1181. readonlyHandlers,
  1182. readonlyCollectionHandlers,
  1183. readonlyMap
  1184. );
  1185. }
  1186. function shallowReadonly(target) {
  1187. return createReactiveObject(
  1188. target,
  1189. true,
  1190. shallowReadonlyHandlers,
  1191. shallowReadonlyCollectionHandlers,
  1192. shallowReadonlyMap
  1193. );
  1194. }
  1195. function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
  1196. if (!isObject(target)) {
  1197. {
  1198. console.warn(`value cannot be made reactive: ${String(target)}`);
  1199. }
  1200. return target;
  1201. }
  1202. if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
  1203. return target;
  1204. }
  1205. const existingProxy = proxyMap.get(target);
  1206. if (existingProxy) {
  1207. return existingProxy;
  1208. }
  1209. const targetType = getTargetType(target);
  1210. if (targetType === 0 /* INVALID */) {
  1211. return target;
  1212. }
  1213. const proxy = new Proxy(
  1214. target,
  1215. targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers
  1216. );
  1217. proxyMap.set(target, proxy);
  1218. return proxy;
  1219. }
  1220. function isReactive(value) {
  1221. if (isReadonly(value)) {
  1222. return isReactive(value["__v_raw"]);
  1223. }
  1224. return !!(value && value["__v_isReactive"]);
  1225. }
  1226. function isReadonly(value) {
  1227. return !!(value && value["__v_isReadonly"]);
  1228. }
  1229. function isShallow(value) {
  1230. return !!(value && value["__v_isShallow"]);
  1231. }
  1232. function isProxy(value) {
  1233. return isReactive(value) || isReadonly(value);
  1234. }
  1235. function toRaw(observed) {
  1236. const raw = observed && observed["__v_raw"];
  1237. return raw ? toRaw(raw) : observed;
  1238. }
  1239. function markRaw(value) {
  1240. def(value, "__v_skip", true);
  1241. return value;
  1242. }
  1243. const toReactive = (value) => isObject(value) ? reactive(value) : value;
  1244. const toReadonly = (value) => isObject(value) ? readonly(value) : value;
  1245. function trackRefValue(ref2) {
  1246. if (shouldTrack && activeEffect) {
  1247. ref2 = toRaw(ref2);
  1248. {
  1249. trackEffects(ref2.dep || (ref2.dep = createDep()), {
  1250. target: ref2,
  1251. type: "get",
  1252. key: "value"
  1253. });
  1254. }
  1255. }
  1256. }
  1257. function triggerRefValue(ref2, newVal) {
  1258. ref2 = toRaw(ref2);
  1259. const dep = ref2.dep;
  1260. if (dep) {
  1261. {
  1262. triggerEffects(dep, {
  1263. target: ref2,
  1264. type: "set",
  1265. key: "value",
  1266. newValue: newVal
  1267. });
  1268. }
  1269. }
  1270. }
  1271. function isRef(r) {
  1272. return !!(r && r.__v_isRef === true);
  1273. }
  1274. function ref(value) {
  1275. return createRef(value, false);
  1276. }
  1277. function shallowRef(value) {
  1278. return createRef(value, true);
  1279. }
  1280. function createRef(rawValue, shallow) {
  1281. if (isRef(rawValue)) {
  1282. return rawValue;
  1283. }
  1284. return new RefImpl(rawValue, shallow);
  1285. }
  1286. class RefImpl {
  1287. constructor(value, __v_isShallow) {
  1288. this.__v_isShallow = __v_isShallow;
  1289. this.dep = void 0;
  1290. this.__v_isRef = true;
  1291. this._rawValue = __v_isShallow ? value : toRaw(value);
  1292. this._value = __v_isShallow ? value : toReactive(value);
  1293. }
  1294. get value() {
  1295. trackRefValue(this);
  1296. return this._value;
  1297. }
  1298. set value(newVal) {
  1299. const useDirectValue = this.__v_isShallow || isShallow(newVal) || isReadonly(newVal);
  1300. newVal = useDirectValue ? newVal : toRaw(newVal);
  1301. if (hasChanged(newVal, this._rawValue)) {
  1302. this._rawValue = newVal;
  1303. this._value = useDirectValue ? newVal : toReactive(newVal);
  1304. triggerRefValue(this, newVal);
  1305. }
  1306. }
  1307. }
  1308. function triggerRef(ref2) {
  1309. triggerRefValue(ref2, ref2.value );
  1310. }
  1311. function unref(ref2) {
  1312. return isRef(ref2) ? ref2.value : ref2;
  1313. }
  1314. function toValue(source) {
  1315. return isFunction(source) ? source() : unref(source);
  1316. }
  1317. const shallowUnwrapHandlers = {
  1318. get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
  1319. set: (target, key, value, receiver) => {
  1320. const oldValue = target[key];
  1321. if (isRef(oldValue) && !isRef(value)) {
  1322. oldValue.value = value;
  1323. return true;
  1324. } else {
  1325. return Reflect.set(target, key, value, receiver);
  1326. }
  1327. }
  1328. };
  1329. function proxyRefs(objectWithRefs) {
  1330. return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
  1331. }
  1332. class CustomRefImpl {
  1333. constructor(factory) {
  1334. this.dep = void 0;
  1335. this.__v_isRef = true;
  1336. const { get, set } = factory(
  1337. () => trackRefValue(this),
  1338. () => triggerRefValue(this)
  1339. );
  1340. this._get = get;
  1341. this._set = set;
  1342. }
  1343. get value() {
  1344. return this._get();
  1345. }
  1346. set value(newVal) {
  1347. this._set(newVal);
  1348. }
  1349. }
  1350. function customRef(factory) {
  1351. return new CustomRefImpl(factory);
  1352. }
  1353. function toRefs(object) {
  1354. if (!isProxy(object)) {
  1355. console.warn(`toRefs() expects a reactive object but received a plain one.`);
  1356. }
  1357. const ret = isArray(object) ? new Array(object.length) : {};
  1358. for (const key in object) {
  1359. ret[key] = propertyToRef(object, key);
  1360. }
  1361. return ret;
  1362. }
  1363. class ObjectRefImpl {
  1364. constructor(_object, _key, _defaultValue) {
  1365. this._object = _object;
  1366. this._key = _key;
  1367. this._defaultValue = _defaultValue;
  1368. this.__v_isRef = true;
  1369. }
  1370. get value() {
  1371. const val = this._object[this._key];
  1372. return val === void 0 ? this._defaultValue : val;
  1373. }
  1374. set value(newVal) {
  1375. this._object[this._key] = newVal;
  1376. }
  1377. get dep() {
  1378. return getDepFromReactive(toRaw(this._object), this._key);
  1379. }
  1380. }
  1381. class GetterRefImpl {
  1382. constructor(_getter) {
  1383. this._getter = _getter;
  1384. this.__v_isRef = true;
  1385. this.__v_isReadonly = true;
  1386. }
  1387. get value() {
  1388. return this._getter();
  1389. }
  1390. }
  1391. function toRef(source, key, defaultValue) {
  1392. if (isRef(source)) {
  1393. return source;
  1394. } else if (isFunction(source)) {
  1395. return new GetterRefImpl(source);
  1396. } else if (isObject(source) && arguments.length > 1) {
  1397. return propertyToRef(source, key, defaultValue);
  1398. } else {
  1399. return ref(source);
  1400. }
  1401. }
  1402. function propertyToRef(source, key, defaultValue) {
  1403. const val = source[key];
  1404. return isRef(val) ? val : new ObjectRefImpl(
  1405. source,
  1406. key,
  1407. defaultValue
  1408. );
  1409. }
  1410. class ComputedRefImpl {
  1411. constructor(getter, _setter, isReadonly, isSSR) {
  1412. this._setter = _setter;
  1413. this.dep = void 0;
  1414. this.__v_isRef = true;
  1415. this["__v_isReadonly"] = false;
  1416. this._dirty = true;
  1417. this.effect = new ReactiveEffect(getter, () => {
  1418. if (!this._dirty) {
  1419. this._dirty = true;
  1420. triggerRefValue(this);
  1421. }
  1422. });
  1423. this.effect.computed = this;
  1424. this.effect.active = this._cacheable = !isSSR;
  1425. this["__v_isReadonly"] = isReadonly;
  1426. }
  1427. get value() {
  1428. const self = toRaw(this);
  1429. trackRefValue(self);
  1430. if (self._dirty || !self._cacheable) {
  1431. self._dirty = false;
  1432. self._value = self.effect.run();
  1433. }
  1434. return self._value;
  1435. }
  1436. set value(newValue) {
  1437. this._setter(newValue);
  1438. }
  1439. }
  1440. function computed$1(getterOrOptions, debugOptions, isSSR = false) {
  1441. let getter;
  1442. let setter;
  1443. const onlyGetter = isFunction(getterOrOptions);
  1444. if (onlyGetter) {
  1445. getter = getterOrOptions;
  1446. setter = () => {
  1447. console.warn("Write operation failed: computed value is readonly");
  1448. } ;
  1449. } else {
  1450. getter = getterOrOptions.get;
  1451. setter = getterOrOptions.set;
  1452. }
  1453. const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
  1454. if (debugOptions && !isSSR) {
  1455. cRef.effect.onTrack = debugOptions.onTrack;
  1456. cRef.effect.onTrigger = debugOptions.onTrigger;
  1457. }
  1458. return cRef;
  1459. }
  1460. const stack = [];
  1461. function pushWarningContext(vnode) {
  1462. stack.push(vnode);
  1463. }
  1464. function popWarningContext() {
  1465. stack.pop();
  1466. }
  1467. function warn(msg, ...args) {
  1468. pauseTracking();
  1469. const instance = stack.length ? stack[stack.length - 1].component : null;
  1470. const appWarnHandler = instance && instance.appContext.config.warnHandler;
  1471. const trace = getComponentTrace();
  1472. if (appWarnHandler) {
  1473. callWithErrorHandling(
  1474. appWarnHandler,
  1475. instance,
  1476. 11,
  1477. [
  1478. msg + args.join(""),
  1479. instance && instance.proxy,
  1480. trace.map(
  1481. ({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`
  1482. ).join("\n"),
  1483. trace
  1484. ]
  1485. );
  1486. } else {
  1487. const warnArgs = [`[Vue warn]: ${msg}`, ...args];
  1488. if (trace.length && // avoid spamming console during tests
  1489. true) {
  1490. warnArgs.push(`
  1491. `, ...formatTrace(trace));
  1492. }
  1493. console.warn(...warnArgs);
  1494. }
  1495. resetTracking();
  1496. }
  1497. function getComponentTrace() {
  1498. let currentVNode = stack[stack.length - 1];
  1499. if (!currentVNode) {
  1500. return [];
  1501. }
  1502. const normalizedStack = [];
  1503. while (currentVNode) {
  1504. const last = normalizedStack[0];
  1505. if (last && last.vnode === currentVNode) {
  1506. last.recurseCount++;
  1507. } else {
  1508. normalizedStack.push({
  1509. vnode: currentVNode,
  1510. recurseCount: 0
  1511. });
  1512. }
  1513. const parentInstance = currentVNode.component && currentVNode.component.parent;
  1514. currentVNode = parentInstance && parentInstance.vnode;
  1515. }
  1516. return normalizedStack;
  1517. }
  1518. function formatTrace(trace) {
  1519. const logs = [];
  1520. trace.forEach((entry, i) => {
  1521. logs.push(...i === 0 ? [] : [`
  1522. `], ...formatTraceEntry(entry));
  1523. });
  1524. return logs;
  1525. }
  1526. function formatTraceEntry({ vnode, recurseCount }) {
  1527. const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
  1528. const isRoot = vnode.component ? vnode.component.parent == null : false;
  1529. const open = ` at <${formatComponentName(
  1530. vnode.component,
  1531. vnode.type,
  1532. isRoot
  1533. )}`;
  1534. const close = `>` + postfix;
  1535. return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close];
  1536. }
  1537. function formatProps(props) {
  1538. const res = [];
  1539. const keys = Object.keys(props);
  1540. keys.slice(0, 3).forEach((key) => {
  1541. res.push(...formatProp(key, props[key]));
  1542. });
  1543. if (keys.length > 3) {
  1544. res.push(` ...`);
  1545. }
  1546. return res;
  1547. }
  1548. function formatProp(key, value, raw) {
  1549. if (isString(value)) {
  1550. value = JSON.stringify(value);
  1551. return raw ? value : [`${key}=${value}`];
  1552. } else if (typeof value === "number" || typeof value === "boolean" || value == null) {
  1553. return raw ? value : [`${key}=${value}`];
  1554. } else if (isRef(value)) {
  1555. value = formatProp(key, toRaw(value.value), true);
  1556. return raw ? value : [`${key}=Ref<`, value, `>`];
  1557. } else if (isFunction(value)) {
  1558. return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
  1559. } else {
  1560. value = toRaw(value);
  1561. return raw ? value : [`${key}=`, value];
  1562. }
  1563. }
  1564. function assertNumber(val, type) {
  1565. if (val === void 0) {
  1566. return;
  1567. } else if (typeof val !== "number") {
  1568. warn(`${type} is not a valid number - got ${JSON.stringify(val)}.`);
  1569. } else if (isNaN(val)) {
  1570. warn(`${type} is NaN - the duration expression might be incorrect.`);
  1571. }
  1572. }
  1573. const ErrorTypeStrings = {
  1574. ["sp"]: "serverPrefetch hook",
  1575. ["bc"]: "beforeCreate hook",
  1576. ["c"]: "created hook",
  1577. ["bm"]: "beforeMount hook",
  1578. ["m"]: "mounted hook",
  1579. ["bu"]: "beforeUpdate hook",
  1580. ["u"]: "updated",
  1581. ["bum"]: "beforeUnmount hook",
  1582. ["um"]: "unmounted hook",
  1583. ["a"]: "activated hook",
  1584. ["da"]: "deactivated hook",
  1585. ["ec"]: "errorCaptured hook",
  1586. ["rtc"]: "renderTracked hook",
  1587. ["rtg"]: "renderTriggered hook",
  1588. [0]: "setup function",
  1589. [1]: "render function",
  1590. [2]: "watcher getter",
  1591. [3]: "watcher callback",
  1592. [4]: "watcher cleanup function",
  1593. [5]: "native event handler",
  1594. [6]: "component event handler",
  1595. [7]: "vnode hook",
  1596. [8]: "directive hook",
  1597. [9]: "transition hook",
  1598. [10]: "app errorHandler",
  1599. [11]: "app warnHandler",
  1600. [12]: "ref function",
  1601. [13]: "async component loader",
  1602. [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core"
  1603. };
  1604. function callWithErrorHandling(fn, instance, type, args) {
  1605. let res;
  1606. try {
  1607. res = args ? fn(...args) : fn();
  1608. } catch (err) {
  1609. handleError(err, instance, type);
  1610. }
  1611. return res;
  1612. }
  1613. function callWithAsyncErrorHandling(fn, instance, type, args) {
  1614. if (isFunction(fn)) {
  1615. const res = callWithErrorHandling(fn, instance, type, args);
  1616. if (res && isPromise(res)) {
  1617. res.catch((err) => {
  1618. handleError(err, instance, type);
  1619. });
  1620. }
  1621. return res;
  1622. }
  1623. const values = [];
  1624. for (let i = 0; i < fn.length; i++) {
  1625. values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
  1626. }
  1627. return values;
  1628. }
  1629. function handleError(err, instance, type, throwInDev = true) {
  1630. const contextVNode = instance ? instance.vnode : null;
  1631. if (instance) {
  1632. let cur = instance.parent;
  1633. const exposedInstance = instance.proxy;
  1634. const errorInfo = ErrorTypeStrings[type] ;
  1635. while (cur) {
  1636. const errorCapturedHooks = cur.ec;
  1637. if (errorCapturedHooks) {
  1638. for (let i = 0; i < errorCapturedHooks.length; i++) {
  1639. if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
  1640. return;
  1641. }
  1642. }
  1643. }
  1644. cur = cur.parent;
  1645. }
  1646. const appErrorHandler = instance.appContext.config.errorHandler;
  1647. if (appErrorHandler) {
  1648. callWithErrorHandling(
  1649. appErrorHandler,
  1650. null,
  1651. 10,
  1652. [err, exposedInstance, errorInfo]
  1653. );
  1654. return;
  1655. }
  1656. }
  1657. logError(err, type, contextVNode, throwInDev);
  1658. }
  1659. function logError(err, type, contextVNode, throwInDev = true) {
  1660. {
  1661. const info = ErrorTypeStrings[type];
  1662. if (contextVNode) {
  1663. pushWarningContext(contextVNode);
  1664. }
  1665. warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
  1666. if (contextVNode) {
  1667. popWarningContext();
  1668. }
  1669. if (throwInDev) {
  1670. throw err;
  1671. } else {
  1672. console.error(err);
  1673. }
  1674. }
  1675. }
  1676. let isFlushing = false;
  1677. let isFlushPending = false;
  1678. const queue = [];
  1679. let flushIndex = 0;
  1680. const pendingPostFlushCbs = [];
  1681. let activePostFlushCbs = null;
  1682. let postFlushIndex = 0;
  1683. const resolvedPromise = /* @__PURE__ */ Promise.resolve();
  1684. let currentFlushPromise = null;
  1685. const RECURSION_LIMIT = 100;
  1686. function nextTick(fn) {
  1687. const p = currentFlushPromise || resolvedPromise;
  1688. return fn ? p.then(this ? fn.bind(this) : fn) : p;
  1689. }
  1690. function findInsertionIndex(id) {
  1691. let start = flushIndex + 1;
  1692. let end = queue.length;
  1693. while (start < end) {
  1694. const middle = start + end >>> 1;
  1695. const middleJobId = getId(queue[middle]);
  1696. middleJobId < id ? start = middle + 1 : end = middle;
  1697. }
  1698. return start;
  1699. }
  1700. function queueJob(job) {
  1701. if (!queue.length || !queue.includes(
  1702. job,
  1703. isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
  1704. )) {
  1705. if (job.id == null) {
  1706. queue.push(job);
  1707. } else {
  1708. queue.splice(findInsertionIndex(job.id), 0, job);
  1709. }
  1710. queueFlush();
  1711. }
  1712. }
  1713. function queueFlush() {
  1714. if (!isFlushing && !isFlushPending) {
  1715. isFlushPending = true;
  1716. currentFlushPromise = resolvedPromise.then(flushJobs);
  1717. }
  1718. }
  1719. function invalidateJob(job) {
  1720. const i = queue.indexOf(job);
  1721. if (i > flushIndex) {
  1722. queue.splice(i, 1);
  1723. }
  1724. }
  1725. function queuePostFlushCb(cb) {
  1726. if (!isArray(cb)) {
  1727. if (!activePostFlushCbs || !activePostFlushCbs.includes(
  1728. cb,
  1729. cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
  1730. )) {
  1731. pendingPostFlushCbs.push(cb);
  1732. }
  1733. } else {
  1734. pendingPostFlushCbs.push(...cb);
  1735. }
  1736. queueFlush();
  1737. }
  1738. function flushPreFlushCbs(seen, i = isFlushing ? flushIndex + 1 : 0) {
  1739. {
  1740. seen = seen || /* @__PURE__ */ new Map();
  1741. }
  1742. for (; i < queue.length; i++) {
  1743. const cb = queue[i];
  1744. if (cb && cb.pre) {
  1745. if (checkRecursiveUpdates(seen, cb)) {
  1746. continue;
  1747. }
  1748. queue.splice(i, 1);
  1749. i--;
  1750. cb();
  1751. }
  1752. }
  1753. }
  1754. function flushPostFlushCbs(seen) {
  1755. if (pendingPostFlushCbs.length) {
  1756. const deduped = [...new Set(pendingPostFlushCbs)];
  1757. pendingPostFlushCbs.length = 0;
  1758. if (activePostFlushCbs) {
  1759. activePostFlushCbs.push(...deduped);
  1760. return;
  1761. }
  1762. activePostFlushCbs = deduped;
  1763. {
  1764. seen = seen || /* @__PURE__ */ new Map();
  1765. }
  1766. activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
  1767. for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
  1768. if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
  1769. continue;
  1770. }
  1771. activePostFlushCbs[postFlushIndex]();
  1772. }
  1773. activePostFlushCbs = null;
  1774. postFlushIndex = 0;
  1775. }
  1776. }
  1777. const getId = (job) => job.id == null ? Infinity : job.id;
  1778. const comparator = (a, b) => {
  1779. const diff = getId(a) - getId(b);
  1780. if (diff === 0) {
  1781. if (a.pre && !b.pre)
  1782. return -1;
  1783. if (b.pre && !a.pre)
  1784. return 1;
  1785. }
  1786. return diff;
  1787. };
  1788. function flushJobs(seen) {
  1789. isFlushPending = false;
  1790. isFlushing = true;
  1791. {
  1792. seen = seen || /* @__PURE__ */ new Map();
  1793. }
  1794. queue.sort(comparator);
  1795. const check = (job) => checkRecursiveUpdates(seen, job) ;
  1796. try {
  1797. for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
  1798. const job = queue[flushIndex];
  1799. if (job && job.active !== false) {
  1800. if (check(job)) {
  1801. continue;
  1802. }
  1803. callWithErrorHandling(job, null, 14);
  1804. }
  1805. }
  1806. } finally {
  1807. flushIndex = 0;
  1808. queue.length = 0;
  1809. flushPostFlushCbs(seen);
  1810. isFlushing = false;
  1811. currentFlushPromise = null;
  1812. if (queue.length || pendingPostFlushCbs.length) {
  1813. flushJobs(seen);
  1814. }
  1815. }
  1816. }
  1817. function checkRecursiveUpdates(seen, fn) {
  1818. if (!seen.has(fn)) {
  1819. seen.set(fn, 1);
  1820. } else {
  1821. const count = seen.get(fn);
  1822. if (count > RECURSION_LIMIT) {
  1823. const instance = fn.ownerInstance;
  1824. const componentName = instance && getComponentName(instance.type);
  1825. warn(
  1826. `Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`
  1827. );
  1828. return true;
  1829. } else {
  1830. seen.set(fn, count + 1);
  1831. }
  1832. }
  1833. }
  1834. let isHmrUpdating = false;
  1835. const hmrDirtyComponents = /* @__PURE__ */ new Set();
  1836. {
  1837. getGlobalThis().__VUE_HMR_RUNTIME__ = {
  1838. createRecord: tryWrap(createRecord),
  1839. rerender: tryWrap(rerender),
  1840. reload: tryWrap(reload)
  1841. };
  1842. }
  1843. const map = /* @__PURE__ */ new Map();
  1844. function registerHMR(instance) {
  1845. const id = instance.type.__hmrId;
  1846. let record = map.get(id);
  1847. if (!record) {
  1848. createRecord(id, instance.type);
  1849. record = map.get(id);
  1850. }
  1851. record.instances.add(instance);
  1852. }
  1853. function unregisterHMR(instance) {
  1854. map.get(instance.type.__hmrId).instances.delete(instance);
  1855. }
  1856. function createRecord(id, initialDef) {
  1857. if (map.has(id)) {
  1858. return false;
  1859. }
  1860. map.set(id, {
  1861. initialDef: normalizeClassComponent(initialDef),
  1862. instances: /* @__PURE__ */ new Set()
  1863. });
  1864. return true;
  1865. }
  1866. function normalizeClassComponent(component) {
  1867. return isClassComponent(component) ? component.__vccOpts : component;
  1868. }
  1869. function rerender(id, newRender) {
  1870. const record = map.get(id);
  1871. if (!record) {
  1872. return;
  1873. }
  1874. record.initialDef.render = newRender;
  1875. [...record.instances].forEach((instance) => {
  1876. if (newRender) {
  1877. instance.render = newRender;
  1878. normalizeClassComponent(instance.type).render = newRender;
  1879. }
  1880. instance.renderCache = [];
  1881. isHmrUpdating = true;
  1882. instance.update();
  1883. isHmrUpdating = false;
  1884. });
  1885. }
  1886. function reload(id, newComp) {
  1887. const record = map.get(id);
  1888. if (!record)
  1889. return;
  1890. newComp = normalizeClassComponent(newComp);
  1891. updateComponentDef(record.initialDef, newComp);
  1892. const instances = [...record.instances];
  1893. for (const instance of instances) {
  1894. const oldComp = normalizeClassComponent(instance.type);
  1895. if (!hmrDirtyComponents.has(oldComp)) {
  1896. if (oldComp !== record.initialDef) {
  1897. updateComponentDef(oldComp, newComp);
  1898. }
  1899. hmrDirtyComponents.add(oldComp);
  1900. }
  1901. instance.appContext.propsCache.delete(instance.type);
  1902. instance.appContext.emitsCache.delete(instance.type);
  1903. instance.appContext.optionsCache.delete(instance.type);
  1904. if (instance.ceReload) {
  1905. hmrDirtyComponents.add(oldComp);
  1906. instance.ceReload(newComp.styles);
  1907. hmrDirtyComponents.delete(oldComp);
  1908. } else if (instance.parent) {
  1909. queueJob(instance.parent.update);
  1910. } else if (instance.appContext.reload) {
  1911. instance.appContext.reload();
  1912. } else if (typeof window !== "undefined") {
  1913. window.location.reload();
  1914. } else {
  1915. console.warn(
  1916. "[HMR] Root or manually mounted instance modified. Full reload required."
  1917. );
  1918. }
  1919. }
  1920. queuePostFlushCb(() => {
  1921. for (const instance of instances) {
  1922. hmrDirtyComponents.delete(
  1923. normalizeClassComponent(instance.type)
  1924. );
  1925. }
  1926. });
  1927. }
  1928. function updateComponentDef(oldComp, newComp) {
  1929. extend(oldComp, newComp);
  1930. for (const key in oldComp) {
  1931. if (key !== "__file" && !(key in newComp)) {
  1932. delete oldComp[key];
  1933. }
  1934. }
  1935. }
  1936. function tryWrap(fn) {
  1937. return (id, arg) => {
  1938. try {
  1939. return fn(id, arg);
  1940. } catch (e) {
  1941. console.error(e);
  1942. console.warn(
  1943. `[HMR] Something went wrong during Vue component hot-reload. Full reload required.`
  1944. );
  1945. }
  1946. };
  1947. }
  1948. let devtools;
  1949. let buffer = [];
  1950. let devtoolsNotInstalled = false;
  1951. function emit$1(event, ...args) {
  1952. if (devtools) {
  1953. devtools.emit(event, ...args);
  1954. } else if (!devtoolsNotInstalled) {
  1955. buffer.push({ event, args });
  1956. }
  1957. }
  1958. function setDevtoolsHook(hook, target) {
  1959. var _a, _b;
  1960. devtools = hook;
  1961. if (devtools) {
  1962. devtools.enabled = true;
  1963. buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
  1964. buffer = [];
  1965. } else if (
  1966. // handle late devtools injection - only do this if we are in an actual
  1967. // browser environment to avoid the timer handle stalling test runner exit
  1968. // (#4815)
  1969. typeof window !== "undefined" && // some envs mock window but not fully
  1970. window.HTMLElement && // also exclude jsdom
  1971. !((_b = (_a = window.navigator) == null ? void 0 : _a.userAgent) == null ? void 0 : _b.includes("jsdom"))
  1972. ) {
  1973. const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || [];
  1974. replay.push((newHook) => {
  1975. setDevtoolsHook(newHook, target);
  1976. });
  1977. setTimeout(() => {
  1978. if (!devtools) {
  1979. target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
  1980. devtoolsNotInstalled = true;
  1981. buffer = [];
  1982. }
  1983. }, 3e3);
  1984. } else {
  1985. devtoolsNotInstalled = true;
  1986. buffer = [];
  1987. }
  1988. }
  1989. function devtoolsInitApp(app, version) {
  1990. emit$1("app:init" /* APP_INIT */, app, version, {
  1991. Fragment,
  1992. Text,
  1993. Comment,
  1994. Static
  1995. });
  1996. }
  1997. function devtoolsUnmountApp(app) {
  1998. emit$1("app:unmount" /* APP_UNMOUNT */, app);
  1999. }
  2000. const devtoolsComponentAdded = /* @__PURE__ */ createDevtoolsComponentHook(
  2001. "component:added" /* COMPONENT_ADDED */
  2002. );
  2003. const devtoolsComponentUpdated = /* @__PURE__ */ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */);
  2004. const _devtoolsComponentRemoved = /* @__PURE__ */ createDevtoolsComponentHook(
  2005. "component:removed" /* COMPONENT_REMOVED */
  2006. );
  2007. const devtoolsComponentRemoved = (component) => {
  2008. if (devtools && typeof devtools.cleanupBuffer === "function" && // remove the component if it wasn't buffered
  2009. !devtools.cleanupBuffer(component)) {
  2010. _devtoolsComponentRemoved(component);
  2011. }
  2012. };
  2013. function createDevtoolsComponentHook(hook) {
  2014. return (component) => {
  2015. emit$1(
  2016. hook,
  2017. component.appContext.app,
  2018. component.uid,
  2019. component.parent ? component.parent.uid : void 0,
  2020. component
  2021. );
  2022. };
  2023. }
  2024. const devtoolsPerfStart = /* @__PURE__ */ createDevtoolsPerformanceHook(
  2025. "perf:start" /* PERFORMANCE_START */
  2026. );
  2027. const devtoolsPerfEnd = /* @__PURE__ */ createDevtoolsPerformanceHook(
  2028. "perf:end" /* PERFORMANCE_END */
  2029. );
  2030. function createDevtoolsPerformanceHook(hook) {
  2031. return (component, type, time) => {
  2032. emit$1(hook, component.appContext.app, component.uid, component, type, time);
  2033. };
  2034. }
  2035. function devtoolsComponentEmit(component, event, params) {
  2036. emit$1(
  2037. "component:emit" /* COMPONENT_EMIT */,
  2038. component.appContext.app,
  2039. component,
  2040. event,
  2041. params
  2042. );
  2043. }
  2044. function emit(instance, event, ...rawArgs) {
  2045. if (instance.isUnmounted)
  2046. return;
  2047. const props = instance.vnode.props || EMPTY_OBJ;
  2048. {
  2049. const {
  2050. emitsOptions,
  2051. propsOptions: [propsOptions]
  2052. } = instance;
  2053. if (emitsOptions) {
  2054. if (!(event in emitsOptions) && true) {
  2055. if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
  2056. warn(
  2057. `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${toHandlerKey(event)}" prop.`
  2058. );
  2059. }
  2060. } else {
  2061. const validator = emitsOptions[event];
  2062. if (isFunction(validator)) {
  2063. const isValid = validator(...rawArgs);
  2064. if (!isValid) {
  2065. warn(
  2066. `Invalid event arguments: event validation failed for event "${event}".`
  2067. );
  2068. }
  2069. }
  2070. }
  2071. }
  2072. }
  2073. let args = rawArgs;
  2074. const isModelListener = event.startsWith("update:");
  2075. const modelArg = isModelListener && event.slice(7);
  2076. if (modelArg && modelArg in props) {
  2077. const modifiersKey = `${modelArg === "modelValue" ? "model" : modelArg}Modifiers`;
  2078. const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
  2079. if (trim) {
  2080. args = rawArgs.map((a) => isString(a) ? a.trim() : a);
  2081. }
  2082. if (number) {
  2083. args = rawArgs.map(looseToNumber);
  2084. }
  2085. }
  2086. {
  2087. devtoolsComponentEmit(instance, event, args);
  2088. }
  2089. {
  2090. const lowerCaseEvent = event.toLowerCase();
  2091. if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
  2092. warn(
  2093. `Event "${lowerCaseEvent}" is emitted in component ${formatComponentName(
  2094. instance,
  2095. instance.type
  2096. )} but the handler is registered for "${event}". Note that HTML attributes are case-insensitive and you cannot use v-on to listen to camelCase events when using in-DOM templates. You should probably use "${hyphenate(event)}" instead of "${event}".`
  2097. );
  2098. }
  2099. }
  2100. let handlerName;
  2101. let handler = props[handlerName = toHandlerKey(event)] || // also try camelCase event handler (#2249)
  2102. props[handlerName = toHandlerKey(camelize(event))];
  2103. if (!handler && isModelListener) {
  2104. handler = props[handlerName = toHandlerKey(hyphenate(event))];
  2105. }
  2106. if (handler) {
  2107. callWithAsyncErrorHandling(
  2108. handler,
  2109. instance,
  2110. 6,
  2111. args
  2112. );
  2113. }
  2114. const onceHandler = props[handlerName + `Once`];
  2115. if (onceHandler) {
  2116. if (!instance.emitted) {
  2117. instance.emitted = {};
  2118. } else if (instance.emitted[handlerName]) {
  2119. return;
  2120. }
  2121. instance.emitted[handlerName] = true;
  2122. callWithAsyncErrorHandling(
  2123. onceHandler,
  2124. instance,
  2125. 6,
  2126. args
  2127. );
  2128. }
  2129. }
  2130. function normalizeEmitsOptions(comp, appContext, asMixin = false) {
  2131. const cache = appContext.emitsCache;
  2132. const cached = cache.get(comp);
  2133. if (cached !== void 0) {
  2134. return cached;
  2135. }
  2136. const raw = comp.emits;
  2137. let normalized = {};
  2138. let hasExtends = false;
  2139. if (!isFunction(comp)) {
  2140. const extendEmits = (raw2) => {
  2141. const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
  2142. if (normalizedFromExtend) {
  2143. hasExtends = true;
  2144. extend(normalized, normalizedFromExtend);
  2145. }
  2146. };
  2147. if (!asMixin && appContext.mixins.length) {
  2148. appContext.mixins.forEach(extendEmits);
  2149. }
  2150. if (comp.extends) {
  2151. extendEmits(comp.extends);
  2152. }
  2153. if (comp.mixins) {
  2154. comp.mixins.forEach(extendEmits);
  2155. }
  2156. }
  2157. if (!raw && !hasExtends) {
  2158. if (isObject(comp)) {
  2159. cache.set(comp, null);
  2160. }
  2161. return null;
  2162. }
  2163. if (isArray(raw)) {
  2164. raw.forEach((key) => normalized[key] = null);
  2165. } else {
  2166. extend(normalized, raw);
  2167. }
  2168. if (isObject(comp)) {
  2169. cache.set(comp, normalized);
  2170. }
  2171. return normalized;
  2172. }
  2173. function isEmitListener(options, key) {
  2174. if (!options || !isOn(key)) {
  2175. return false;
  2176. }
  2177. key = key.slice(2).replace(/Once$/, "");
  2178. return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
  2179. }
  2180. let currentRenderingInstance = null;
  2181. let currentScopeId = null;
  2182. function setCurrentRenderingInstance(instance) {
  2183. const prev = currentRenderingInstance;
  2184. currentRenderingInstance = instance;
  2185. currentScopeId = instance && instance.type.__scopeId || null;
  2186. return prev;
  2187. }
  2188. function pushScopeId(id) {
  2189. currentScopeId = id;
  2190. }
  2191. function popScopeId() {
  2192. currentScopeId = null;
  2193. }
  2194. const withScopeId = (_id) => withCtx;
  2195. function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {
  2196. if (!ctx)
  2197. return fn;
  2198. if (fn._n) {
  2199. return fn;
  2200. }
  2201. const renderFnWithContext = (...args) => {
  2202. if (renderFnWithContext._d) {
  2203. setBlockTracking(-1);
  2204. }
  2205. const prevInstance = setCurrentRenderingInstance(ctx);
  2206. let res;
  2207. try {
  2208. res = fn(...args);
  2209. } finally {
  2210. setCurrentRenderingInstance(prevInstance);
  2211. if (renderFnWithContext._d) {
  2212. setBlockTracking(1);
  2213. }
  2214. }
  2215. {
  2216. devtoolsComponentUpdated(ctx);
  2217. }
  2218. return res;
  2219. };
  2220. renderFnWithContext._n = true;
  2221. renderFnWithContext._c = true;
  2222. renderFnWithContext._d = true;
  2223. return renderFnWithContext;
  2224. }
  2225. let accessedAttrs = false;
  2226. function markAttrsAccessed() {
  2227. accessedAttrs = true;
  2228. }
  2229. function renderComponentRoot(instance) {
  2230. const {
  2231. type: Component,
  2232. vnode,
  2233. proxy,
  2234. withProxy,
  2235. props,
  2236. propsOptions: [propsOptions],
  2237. slots,
  2238. attrs,
  2239. emit,
  2240. render,
  2241. renderCache,
  2242. data,
  2243. setupState,
  2244. ctx,
  2245. inheritAttrs
  2246. } = instance;
  2247. let result;
  2248. let fallthroughAttrs;
  2249. const prev = setCurrentRenderingInstance(instance);
  2250. {
  2251. accessedAttrs = false;
  2252. }
  2253. try {
  2254. if (vnode.shapeFlag & 4) {
  2255. const proxyToUse = withProxy || proxy;
  2256. result = normalizeVNode(
  2257. render.call(
  2258. proxyToUse,
  2259. proxyToUse,
  2260. renderCache,
  2261. props,
  2262. setupState,
  2263. data,
  2264. ctx
  2265. )
  2266. );
  2267. fallthroughAttrs = attrs;
  2268. } else {
  2269. const render2 = Component;
  2270. if (attrs === props) {
  2271. markAttrsAccessed();
  2272. }
  2273. result = normalizeVNode(
  2274. render2.length > 1 ? render2(
  2275. props,
  2276. true ? {
  2277. get attrs() {
  2278. markAttrsAccessed();
  2279. return attrs;
  2280. },
  2281. slots,
  2282. emit
  2283. } : { attrs, slots, emit }
  2284. ) : render2(
  2285. props,
  2286. null
  2287. /* we know it doesn't need it */
  2288. )
  2289. );
  2290. fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
  2291. }
  2292. } catch (err) {
  2293. blockStack.length = 0;
  2294. handleError(err, instance, 1);
  2295. result = createVNode(Comment);
  2296. }
  2297. let root = result;
  2298. let setRoot = void 0;
  2299. if (result.patchFlag > 0 && result.patchFlag & 2048) {
  2300. [root, setRoot] = getChildRoot(result);
  2301. }
  2302. if (fallthroughAttrs && inheritAttrs !== false) {
  2303. const keys = Object.keys(fallthroughAttrs);
  2304. const { shapeFlag } = root;
  2305. if (keys.length) {
  2306. if (shapeFlag & (1 | 6)) {
  2307. if (propsOptions && keys.some(isModelListener)) {
  2308. fallthroughAttrs = filterModelListeners(
  2309. fallthroughAttrs,
  2310. propsOptions
  2311. );
  2312. }
  2313. root = cloneVNode(root, fallthroughAttrs);
  2314. } else if (!accessedAttrs && root.type !== Comment) {
  2315. const allAttrs = Object.keys(attrs);
  2316. const eventAttrs = [];
  2317. const extraAttrs = [];
  2318. for (let i = 0, l = allAttrs.length; i < l; i++) {
  2319. const key = allAttrs[i];
  2320. if (isOn(key)) {
  2321. if (!isModelListener(key)) {
  2322. eventAttrs.push(key[2].toLowerCase() + key.slice(3));
  2323. }
  2324. } else {
  2325. extraAttrs.push(key);
  2326. }
  2327. }
  2328. if (extraAttrs.length) {
  2329. warn(
  2330. `Extraneous non-props attributes (${extraAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.`
  2331. );
  2332. }
  2333. if (eventAttrs.length) {
  2334. warn(
  2335. `Extraneous non-emits event listeners (${eventAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. If the listener is intended to be a component custom event listener only, declare it using the "emits" option.`
  2336. );
  2337. }
  2338. }
  2339. }
  2340. }
  2341. if (vnode.dirs) {
  2342. if (!isElementRoot(root)) {
  2343. warn(
  2344. `Runtime directive used on component with non-element root node. The directives will not function as intended.`
  2345. );
  2346. }
  2347. root = cloneVNode(root);
  2348. root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
  2349. }
  2350. if (vnode.transition) {
  2351. if (!isElementRoot(root)) {
  2352. warn(
  2353. `Component inside <Transition> renders non-element root node that cannot be animated.`
  2354. );
  2355. }
  2356. root.transition = vnode.transition;
  2357. }
  2358. if (setRoot) {
  2359. setRoot(root);
  2360. } else {
  2361. result = root;
  2362. }
  2363. setCurrentRenderingInstance(prev);
  2364. return result;
  2365. }
  2366. const getChildRoot = (vnode) => {
  2367. const rawChildren = vnode.children;
  2368. const dynamicChildren = vnode.dynamicChildren;
  2369. const childRoot = filterSingleRoot(rawChildren);
  2370. if (!childRoot) {
  2371. return [vnode, void 0];
  2372. }
  2373. const index = rawChildren.indexOf(childRoot);
  2374. const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
  2375. const setRoot = (updatedRoot) => {
  2376. rawChildren[index] = updatedRoot;
  2377. if (dynamicChildren) {
  2378. if (dynamicIndex > -1) {
  2379. dynamicChildren[dynamicIndex] = updatedRoot;
  2380. } else if (updatedRoot.patchFlag > 0) {
  2381. vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
  2382. }
  2383. }
  2384. };
  2385. return [normalizeVNode(childRoot), setRoot];
  2386. };
  2387. function filterSingleRoot(children) {
  2388. let singleRoot;
  2389. for (let i = 0; i < children.length; i++) {
  2390. const child = children[i];
  2391. if (isVNode(child)) {
  2392. if (child.type !== Comment || child.children === "v-if") {
  2393. if (singleRoot) {
  2394. return;
  2395. } else {
  2396. singleRoot = child;
  2397. }
  2398. }
  2399. } else {
  2400. return;
  2401. }
  2402. }
  2403. return singleRoot;
  2404. }
  2405. const getFunctionalFallthrough = (attrs) => {
  2406. let res;
  2407. for (const key in attrs) {
  2408. if (key === "class" || key === "style" || isOn(key)) {
  2409. (res || (res = {}))[key] = attrs[key];
  2410. }
  2411. }
  2412. return res;
  2413. };
  2414. const filterModelListeners = (attrs, props) => {
  2415. const res = {};
  2416. for (const key in attrs) {
  2417. if (!isModelListener(key) || !(key.slice(9) in props)) {
  2418. res[key] = attrs[key];
  2419. }
  2420. }
  2421. return res;
  2422. };
  2423. const isElementRoot = (vnode) => {
  2424. return vnode.shapeFlag & (6 | 1) || vnode.type === Comment;
  2425. };
  2426. function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
  2427. const { props: prevProps, children: prevChildren, component } = prevVNode;
  2428. const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
  2429. const emits = component.emitsOptions;
  2430. if ((prevChildren || nextChildren) && isHmrUpdating) {
  2431. return true;
  2432. }
  2433. if (nextVNode.dirs || nextVNode.transition) {
  2434. return true;
  2435. }
  2436. if (optimized && patchFlag >= 0) {
  2437. if (patchFlag & 1024) {
  2438. return true;
  2439. }
  2440. if (patchFlag & 16) {
  2441. if (!prevProps) {
  2442. return !!nextProps;
  2443. }
  2444. return hasPropsChanged(prevProps, nextProps, emits);
  2445. } else if (patchFlag & 8) {
  2446. const dynamicProps = nextVNode.dynamicProps;
  2447. for (let i = 0; i < dynamicProps.length; i++) {
  2448. const key = dynamicProps[i];
  2449. if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
  2450. return true;
  2451. }
  2452. }
  2453. }
  2454. } else {
  2455. if (prevChildren || nextChildren) {
  2456. if (!nextChildren || !nextChildren.$stable) {
  2457. return true;
  2458. }
  2459. }
  2460. if (prevProps === nextProps) {
  2461. return false;
  2462. }
  2463. if (!prevProps) {
  2464. return !!nextProps;
  2465. }
  2466. if (!nextProps) {
  2467. return true;
  2468. }
  2469. return hasPropsChanged(prevProps, nextProps, emits);
  2470. }
  2471. return false;
  2472. }
  2473. function hasPropsChanged(prevProps, nextProps, emitsOptions) {
  2474. const nextKeys = Object.keys(nextProps);
  2475. if (nextKeys.length !== Object.keys(prevProps).length) {
  2476. return true;
  2477. }
  2478. for (let i = 0; i < nextKeys.length; i++) {
  2479. const key = nextKeys[i];
  2480. if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
  2481. return true;
  2482. }
  2483. }
  2484. return false;
  2485. }
  2486. function updateHOCHostEl({ vnode, parent }, el) {
  2487. while (parent && parent.subTree === vnode) {
  2488. (vnode = parent.vnode).el = el;
  2489. parent = parent.parent;
  2490. }
  2491. }
  2492. const isSuspense = (type) => type.__isSuspense;
  2493. const SuspenseImpl = {
  2494. name: "Suspense",
  2495. // In order to make Suspense tree-shakable, we need to avoid importing it
  2496. // directly in the renderer. The renderer checks for the __isSuspense flag
  2497. // on a vnode's type and calls the `process` method, passing in renderer
  2498. // internals.
  2499. __isSuspense: true,
  2500. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
  2501. if (n1 == null) {
  2502. mountSuspense(
  2503. n2,
  2504. container,
  2505. anchor,
  2506. parentComponent,
  2507. parentSuspense,
  2508. isSVG,
  2509. slotScopeIds,
  2510. optimized,
  2511. rendererInternals
  2512. );
  2513. } else {
  2514. patchSuspense(
  2515. n1,
  2516. n2,
  2517. container,
  2518. anchor,
  2519. parentComponent,
  2520. isSVG,
  2521. slotScopeIds,
  2522. optimized,
  2523. rendererInternals
  2524. );
  2525. }
  2526. },
  2527. hydrate: hydrateSuspense,
  2528. create: createSuspenseBoundary,
  2529. normalize: normalizeSuspenseChildren
  2530. };
  2531. const Suspense = SuspenseImpl ;
  2532. function triggerEvent(vnode, name) {
  2533. const eventListener = vnode.props && vnode.props[name];
  2534. if (isFunction(eventListener)) {
  2535. eventListener();
  2536. }
  2537. }
  2538. function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
  2539. const {
  2540. p: patch,
  2541. o: { createElement }
  2542. } = rendererInternals;
  2543. const hiddenContainer = createElement("div");
  2544. const suspense = vnode.suspense = createSuspenseBoundary(
  2545. vnode,
  2546. parentSuspense,
  2547. parentComponent,
  2548. container,
  2549. hiddenContainer,
  2550. anchor,
  2551. isSVG,
  2552. slotScopeIds,
  2553. optimized,
  2554. rendererInternals
  2555. );
  2556. patch(
  2557. null,
  2558. suspense.pendingBranch = vnode.ssContent,
  2559. hiddenContainer,
  2560. null,
  2561. parentComponent,
  2562. suspense,
  2563. isSVG,
  2564. slotScopeIds
  2565. );
  2566. if (suspense.deps > 0) {
  2567. triggerEvent(vnode, "onPending");
  2568. triggerEvent(vnode, "onFallback");
  2569. patch(
  2570. null,
  2571. vnode.ssFallback,
  2572. container,
  2573. anchor,
  2574. parentComponent,
  2575. null,
  2576. // fallback tree will not have suspense context
  2577. isSVG,
  2578. slotScopeIds
  2579. );
  2580. setActiveBranch(suspense, vnode.ssFallback);
  2581. } else {
  2582. suspense.resolve(false, true);
  2583. }
  2584. }
  2585. function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
  2586. const suspense = n2.suspense = n1.suspense;
  2587. suspense.vnode = n2;
  2588. n2.el = n1.el;
  2589. const newBranch = n2.ssContent;
  2590. const newFallback = n2.ssFallback;
  2591. const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
  2592. if (pendingBranch) {
  2593. suspense.pendingBranch = newBranch;
  2594. if (isSameVNodeType(newBranch, pendingBranch)) {
  2595. patch(
  2596. pendingBranch,
  2597. newBranch,
  2598. suspense.hiddenContainer,
  2599. null,
  2600. parentComponent,
  2601. suspense,
  2602. isSVG,
  2603. slotScopeIds,
  2604. optimized
  2605. );
  2606. if (suspense.deps <= 0) {
  2607. suspense.resolve();
  2608. } else if (isInFallback) {
  2609. patch(
  2610. activeBranch,
  2611. newFallback,
  2612. container,
  2613. anchor,
  2614. parentComponent,
  2615. null,
  2616. // fallback tree will not have suspense context
  2617. isSVG,
  2618. slotScopeIds,
  2619. optimized
  2620. );
  2621. setActiveBranch(suspense, newFallback);
  2622. }
  2623. } else {
  2624. suspense.pendingId++;
  2625. if (isHydrating) {
  2626. suspense.isHydrating = false;
  2627. suspense.activeBranch = pendingBranch;
  2628. } else {
  2629. unmount(pendingBranch, parentComponent, suspense);
  2630. }
  2631. suspense.deps = 0;
  2632. suspense.effects.length = 0;
  2633. suspense.hiddenContainer = createElement("div");
  2634. if (isInFallback) {
  2635. patch(
  2636. null,
  2637. newBranch,
  2638. suspense.hiddenContainer,
  2639. null,
  2640. parentComponent,
  2641. suspense,
  2642. isSVG,
  2643. slotScopeIds,
  2644. optimized
  2645. );
  2646. if (suspense.deps <= 0) {
  2647. suspense.resolve();
  2648. } else {
  2649. patch(
  2650. activeBranch,
  2651. newFallback,
  2652. container,
  2653. anchor,
  2654. parentComponent,
  2655. null,
  2656. // fallback tree will not have suspense context
  2657. isSVG,
  2658. slotScopeIds,
  2659. optimized
  2660. );
  2661. setActiveBranch(suspense, newFallback);
  2662. }
  2663. } else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2664. patch(
  2665. activeBranch,
  2666. newBranch,
  2667. container,
  2668. anchor,
  2669. parentComponent,
  2670. suspense,
  2671. isSVG,
  2672. slotScopeIds,
  2673. optimized
  2674. );
  2675. suspense.resolve(true);
  2676. } else {
  2677. patch(
  2678. null,
  2679. newBranch,
  2680. suspense.hiddenContainer,
  2681. null,
  2682. parentComponent,
  2683. suspense,
  2684. isSVG,
  2685. slotScopeIds,
  2686. optimized
  2687. );
  2688. if (suspense.deps <= 0) {
  2689. suspense.resolve();
  2690. }
  2691. }
  2692. }
  2693. } else {
  2694. if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2695. patch(
  2696. activeBranch,
  2697. newBranch,
  2698. container,
  2699. anchor,
  2700. parentComponent,
  2701. suspense,
  2702. isSVG,
  2703. slotScopeIds,
  2704. optimized
  2705. );
  2706. setActiveBranch(suspense, newBranch);
  2707. } else {
  2708. triggerEvent(n2, "onPending");
  2709. suspense.pendingBranch = newBranch;
  2710. suspense.pendingId++;
  2711. patch(
  2712. null,
  2713. newBranch,
  2714. suspense.hiddenContainer,
  2715. null,
  2716. parentComponent,
  2717. suspense,
  2718. isSVG,
  2719. slotScopeIds,
  2720. optimized
  2721. );
  2722. if (suspense.deps <= 0) {
  2723. suspense.resolve();
  2724. } else {
  2725. const { timeout, pendingId } = suspense;
  2726. if (timeout > 0) {
  2727. setTimeout(() => {
  2728. if (suspense.pendingId === pendingId) {
  2729. suspense.fallback(newFallback);
  2730. }
  2731. }, timeout);
  2732. } else if (timeout === 0) {
  2733. suspense.fallback(newFallback);
  2734. }
  2735. }
  2736. }
  2737. }
  2738. }
  2739. let hasWarned = false;
  2740. function createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
  2741. if (!hasWarned) {
  2742. hasWarned = true;
  2743. console[console.info ? "info" : "log"](
  2744. `<Suspense> is an experimental feature and its API will likely change.`
  2745. );
  2746. }
  2747. const {
  2748. p: patch,
  2749. m: move,
  2750. um: unmount,
  2751. n: next,
  2752. o: { parentNode, remove }
  2753. } = rendererInternals;
  2754. let parentSuspenseId;
  2755. const isSuspensible = isVNodeSuspensible(vnode);
  2756. if (isSuspensible) {
  2757. if (parentSuspense == null ? void 0 : parentSuspense.pendingBranch) {
  2758. parentSuspenseId = parentSuspense.pendingId;
  2759. parentSuspense.deps++;
  2760. }
  2761. }
  2762. const timeout = vnode.props ? toNumber(vnode.props.timeout) : void 0;
  2763. {
  2764. assertNumber(timeout, `Suspense timeout`);
  2765. }
  2766. const suspense = {
  2767. vnode,
  2768. parent: parentSuspense,
  2769. parentComponent,
  2770. isSVG,
  2771. container,
  2772. hiddenContainer,
  2773. anchor,
  2774. deps: 0,
  2775. pendingId: 0,
  2776. timeout: typeof timeout === "number" ? timeout : -1,
  2777. activeBranch: null,
  2778. pendingBranch: null,
  2779. isInFallback: true,
  2780. isHydrating,
  2781. isUnmounted: false,
  2782. effects: [],
  2783. resolve(resume = false, sync = false) {
  2784. {
  2785. if (!resume && !suspense.pendingBranch) {
  2786. throw new Error(
  2787. `suspense.resolve() is called without a pending branch.`
  2788. );
  2789. }
  2790. if (suspense.isUnmounted) {
  2791. throw new Error(
  2792. `suspense.resolve() is called on an already unmounted suspense boundary.`
  2793. );
  2794. }
  2795. }
  2796. const {
  2797. vnode: vnode2,
  2798. activeBranch,
  2799. pendingBranch,
  2800. pendingId,
  2801. effects,
  2802. parentComponent: parentComponent2,
  2803. container: container2
  2804. } = suspense;
  2805. if (suspense.isHydrating) {
  2806. suspense.isHydrating = false;
  2807. } else if (!resume) {
  2808. const delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
  2809. if (delayEnter) {
  2810. activeBranch.transition.afterLeave = () => {
  2811. if (pendingId === suspense.pendingId) {
  2812. move(pendingBranch, container2, anchor2, 0);
  2813. }
  2814. };
  2815. }
  2816. let { anchor: anchor2 } = suspense;
  2817. if (activeBranch) {
  2818. anchor2 = next(activeBranch);
  2819. unmount(activeBranch, parentComponent2, suspense, true);
  2820. }
  2821. if (!delayEnter) {
  2822. move(pendingBranch, container2, anchor2, 0);
  2823. }
  2824. }
  2825. setActiveBranch(suspense, pendingBranch);
  2826. suspense.pendingBranch = null;
  2827. suspense.isInFallback = false;
  2828. let parent = suspense.parent;
  2829. let hasUnresolvedAncestor = false;
  2830. while (parent) {
  2831. if (parent.pendingBranch) {
  2832. parent.effects.push(...effects);
  2833. hasUnresolvedAncestor = true;
  2834. break;
  2835. }
  2836. parent = parent.parent;
  2837. }
  2838. if (!hasUnresolvedAncestor) {
  2839. queuePostFlushCb(effects);
  2840. }
  2841. suspense.effects = [];
  2842. if (isSuspensible) {
  2843. if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
  2844. parentSuspense.deps--;
  2845. if (parentSuspense.deps === 0 && !sync) {
  2846. parentSuspense.resolve();
  2847. }
  2848. }
  2849. }
  2850. triggerEvent(vnode2, "onResolve");
  2851. },
  2852. fallback(fallbackVNode) {
  2853. if (!suspense.pendingBranch) {
  2854. return;
  2855. }
  2856. const { vnode: vnode2, activeBranch, parentComponent: parentComponent2, container: container2, isSVG: isSVG2 } = suspense;
  2857. triggerEvent(vnode2, "onFallback");
  2858. const anchor2 = next(activeBranch);
  2859. const mountFallback = () => {
  2860. if (!suspense.isInFallback) {
  2861. return;
  2862. }
  2863. patch(
  2864. null,
  2865. fallbackVNode,
  2866. container2,
  2867. anchor2,
  2868. parentComponent2,
  2869. null,
  2870. // fallback tree will not have suspense context
  2871. isSVG2,
  2872. slotScopeIds,
  2873. optimized
  2874. );
  2875. setActiveBranch(suspense, fallbackVNode);
  2876. };
  2877. const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === "out-in";
  2878. if (delayEnter) {
  2879. activeBranch.transition.afterLeave = mountFallback;
  2880. }
  2881. suspense.isInFallback = true;
  2882. unmount(
  2883. activeBranch,
  2884. parentComponent2,
  2885. null,
  2886. // no suspense so unmount hooks fire now
  2887. true
  2888. // shouldRemove
  2889. );
  2890. if (!delayEnter) {
  2891. mountFallback();
  2892. }
  2893. },
  2894. move(container2, anchor2, type) {
  2895. suspense.activeBranch && move(suspense.activeBranch, container2, anchor2, type);
  2896. suspense.container = container2;
  2897. },
  2898. next() {
  2899. return suspense.activeBranch && next(suspense.activeBranch);
  2900. },
  2901. registerDep(instance, setupRenderEffect) {
  2902. const isInPendingSuspense = !!suspense.pendingBranch;
  2903. if (isInPendingSuspense) {
  2904. suspense.deps++;
  2905. }
  2906. const hydratedEl = instance.vnode.el;
  2907. instance.asyncDep.catch((err) => {
  2908. handleError(err, instance, 0);
  2909. }).then((asyncSetupResult) => {
  2910. if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) {
  2911. return;
  2912. }
  2913. instance.asyncResolved = true;
  2914. const { vnode: vnode2 } = instance;
  2915. {
  2916. pushWarningContext(vnode2);
  2917. }
  2918. handleSetupResult(instance, asyncSetupResult, false);
  2919. if (hydratedEl) {
  2920. vnode2.el = hydratedEl;
  2921. }
  2922. const placeholder = !hydratedEl && instance.subTree.el;
  2923. setupRenderEffect(
  2924. instance,
  2925. vnode2,
  2926. // component may have been moved before resolve.
  2927. // if this is not a hydration, instance.subTree will be the comment
  2928. // placeholder.
  2929. parentNode(hydratedEl || instance.subTree.el),
  2930. // anchor will not be used if this is hydration, so only need to
  2931. // consider the comment placeholder case.
  2932. hydratedEl ? null : next(instance.subTree),
  2933. suspense,
  2934. isSVG,
  2935. optimized
  2936. );
  2937. if (placeholder) {
  2938. remove(placeholder);
  2939. }
  2940. updateHOCHostEl(instance, vnode2.el);
  2941. {
  2942. popWarningContext();
  2943. }
  2944. if (isInPendingSuspense && --suspense.deps === 0) {
  2945. suspense.resolve();
  2946. }
  2947. });
  2948. },
  2949. unmount(parentSuspense2, doRemove) {
  2950. suspense.isUnmounted = true;
  2951. if (suspense.activeBranch) {
  2952. unmount(
  2953. suspense.activeBranch,
  2954. parentComponent,
  2955. parentSuspense2,
  2956. doRemove
  2957. );
  2958. }
  2959. if (suspense.pendingBranch) {
  2960. unmount(
  2961. suspense.pendingBranch,
  2962. parentComponent,
  2963. parentSuspense2,
  2964. doRemove
  2965. );
  2966. }
  2967. }
  2968. };
  2969. return suspense;
  2970. }
  2971. function hydrateSuspense(node, vnode, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals, hydrateNode) {
  2972. const suspense = vnode.suspense = createSuspenseBoundary(
  2973. vnode,
  2974. parentSuspense,
  2975. parentComponent,
  2976. node.parentNode,
  2977. document.createElement("div"),
  2978. null,
  2979. isSVG,
  2980. slotScopeIds,
  2981. optimized,
  2982. rendererInternals,
  2983. true
  2984. /* hydrating */
  2985. );
  2986. const result = hydrateNode(
  2987. node,
  2988. suspense.pendingBranch = vnode.ssContent,
  2989. parentComponent,
  2990. suspense,
  2991. slotScopeIds,
  2992. optimized
  2993. );
  2994. if (suspense.deps === 0) {
  2995. suspense.resolve(false, true);
  2996. }
  2997. return result;
  2998. }
  2999. function normalizeSuspenseChildren(vnode) {
  3000. const { shapeFlag, children } = vnode;
  3001. const isSlotChildren = shapeFlag & 32;
  3002. vnode.ssContent = normalizeSuspenseSlot(
  3003. isSlotChildren ? children.default : children
  3004. );
  3005. vnode.ssFallback = isSlotChildren ? normalizeSuspenseSlot(children.fallback) : createVNode(Comment);
  3006. }
  3007. function normalizeSuspenseSlot(s) {
  3008. let block;
  3009. if (isFunction(s)) {
  3010. const trackBlock = isBlockTreeEnabled && s._c;
  3011. if (trackBlock) {
  3012. s._d = false;
  3013. openBlock();
  3014. }
  3015. s = s();
  3016. if (trackBlock) {
  3017. s._d = true;
  3018. block = currentBlock;
  3019. closeBlock();
  3020. }
  3021. }
  3022. if (isArray(s)) {
  3023. const singleChild = filterSingleRoot(s);
  3024. if (!singleChild) {
  3025. warn(`<Suspense> slots expect a single root node.`);
  3026. }
  3027. s = singleChild;
  3028. }
  3029. s = normalizeVNode(s);
  3030. if (block && !s.dynamicChildren) {
  3031. s.dynamicChildren = block.filter((c) => c !== s);
  3032. }
  3033. return s;
  3034. }
  3035. function queueEffectWithSuspense(fn, suspense) {
  3036. if (suspense && suspense.pendingBranch) {
  3037. if (isArray(fn)) {
  3038. suspense.effects.push(...fn);
  3039. } else {
  3040. suspense.effects.push(fn);
  3041. }
  3042. } else {
  3043. queuePostFlushCb(fn);
  3044. }
  3045. }
  3046. function setActiveBranch(suspense, branch) {
  3047. suspense.activeBranch = branch;
  3048. const { vnode, parentComponent } = suspense;
  3049. const el = vnode.el = branch.el;
  3050. if (parentComponent && parentComponent.subTree === vnode) {
  3051. parentComponent.vnode.el = el;
  3052. updateHOCHostEl(parentComponent, el);
  3053. }
  3054. }
  3055. function isVNodeSuspensible(vnode) {
  3056. var _a;
  3057. return ((_a = vnode.props) == null ? void 0 : _a.suspensible) != null && vnode.props.suspensible !== false;
  3058. }
  3059. function watchEffect(effect, options) {
  3060. return doWatch(effect, null, options);
  3061. }
  3062. function watchPostEffect(effect, options) {
  3063. return doWatch(
  3064. effect,
  3065. null,
  3066. extend({}, options, { flush: "post" })
  3067. );
  3068. }
  3069. function watchSyncEffect(effect, options) {
  3070. return doWatch(
  3071. effect,
  3072. null,
  3073. extend({}, options, { flush: "sync" })
  3074. );
  3075. }
  3076. const INITIAL_WATCHER_VALUE = {};
  3077. function watch(source, cb, options) {
  3078. if (!isFunction(cb)) {
  3079. warn(
  3080. `\`watch(fn, options?)\` signature has been moved to a separate API. Use \`watchEffect(fn, options?)\` instead. \`watch\` now only supports \`watch(source, cb, options?) signature.`
  3081. );
  3082. }
  3083. return doWatch(source, cb, options);
  3084. }
  3085. function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
  3086. var _a;
  3087. if (!cb) {
  3088. if (immediate !== void 0) {
  3089. warn(
  3090. `watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`
  3091. );
  3092. }
  3093. if (deep !== void 0) {
  3094. warn(
  3095. `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
  3096. );
  3097. }
  3098. }
  3099. const warnInvalidSource = (s) => {
  3100. warn(
  3101. `Invalid watch source: `,
  3102. s,
  3103. `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
  3104. );
  3105. };
  3106. const instance = getCurrentScope() === ((_a = currentInstance) == null ? void 0 : _a.scope) ? currentInstance : null;
  3107. let getter;
  3108. let forceTrigger = false;
  3109. let isMultiSource = false;
  3110. if (isRef(source)) {
  3111. getter = () => source.value;
  3112. forceTrigger = isShallow(source);
  3113. } else if (isReactive(source)) {
  3114. getter = () => source;
  3115. deep = true;
  3116. } else if (isArray(source)) {
  3117. isMultiSource = true;
  3118. forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
  3119. getter = () => source.map((s) => {
  3120. if (isRef(s)) {
  3121. return s.value;
  3122. } else if (isReactive(s)) {
  3123. return traverse(s);
  3124. } else if (isFunction(s)) {
  3125. return callWithErrorHandling(s, instance, 2);
  3126. } else {
  3127. warnInvalidSource(s);
  3128. }
  3129. });
  3130. } else if (isFunction(source)) {
  3131. if (cb) {
  3132. getter = () => callWithErrorHandling(source, instance, 2);
  3133. } else {
  3134. getter = () => {
  3135. if (instance && instance.isUnmounted) {
  3136. return;
  3137. }
  3138. if (cleanup) {
  3139. cleanup();
  3140. }
  3141. return callWithAsyncErrorHandling(
  3142. source,
  3143. instance,
  3144. 3,
  3145. [onCleanup]
  3146. );
  3147. };
  3148. }
  3149. } else {
  3150. getter = NOOP;
  3151. warnInvalidSource(source);
  3152. }
  3153. if (cb && deep) {
  3154. const baseGetter = getter;
  3155. getter = () => traverse(baseGetter());
  3156. }
  3157. let cleanup;
  3158. let onCleanup = (fn) => {
  3159. cleanup = effect.onStop = () => {
  3160. callWithErrorHandling(fn, instance, 4);
  3161. };
  3162. };
  3163. let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
  3164. const job = () => {
  3165. if (!effect.active) {
  3166. return;
  3167. }
  3168. if (cb) {
  3169. const newValue = effect.run();
  3170. if (deep || forceTrigger || (isMultiSource ? newValue.some(
  3171. (v, i) => hasChanged(v, oldValue[i])
  3172. ) : hasChanged(newValue, oldValue)) || false) {
  3173. if (cleanup) {
  3174. cleanup();
  3175. }
  3176. callWithAsyncErrorHandling(cb, instance, 3, [
  3177. newValue,
  3178. // pass undefined as the old value when it's changed for the first time
  3179. oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
  3180. onCleanup
  3181. ]);
  3182. oldValue = newValue;
  3183. }
  3184. } else {
  3185. effect.run();
  3186. }
  3187. };
  3188. job.allowRecurse = !!cb;
  3189. let scheduler;
  3190. if (flush === "sync") {
  3191. scheduler = job;
  3192. } else if (flush === "post") {
  3193. scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
  3194. } else {
  3195. job.pre = true;
  3196. if (instance)
  3197. job.id = instance.uid;
  3198. scheduler = () => queueJob(job);
  3199. }
  3200. const effect = new ReactiveEffect(getter, scheduler);
  3201. {
  3202. effect.onTrack = onTrack;
  3203. effect.onTrigger = onTrigger;
  3204. }
  3205. if (cb) {
  3206. if (immediate) {
  3207. job();
  3208. } else {
  3209. oldValue = effect.run();
  3210. }
  3211. } else if (flush === "post") {
  3212. queuePostRenderEffect(
  3213. effect.run.bind(effect),
  3214. instance && instance.suspense
  3215. );
  3216. } else {
  3217. effect.run();
  3218. }
  3219. const unwatch = () => {
  3220. effect.stop();
  3221. if (instance && instance.scope) {
  3222. remove(instance.scope.effects, effect);
  3223. }
  3224. };
  3225. return unwatch;
  3226. }
  3227. function instanceWatch(source, value, options) {
  3228. const publicThis = this.proxy;
  3229. const getter = isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
  3230. let cb;
  3231. if (isFunction(value)) {
  3232. cb = value;
  3233. } else {
  3234. cb = value.handler;
  3235. options = value;
  3236. }
  3237. const cur = currentInstance;
  3238. setCurrentInstance(this);
  3239. const res = doWatch(getter, cb.bind(publicThis), options);
  3240. if (cur) {
  3241. setCurrentInstance(cur);
  3242. } else {
  3243. unsetCurrentInstance();
  3244. }
  3245. return res;
  3246. }
  3247. function createPathGetter(ctx, path) {
  3248. const segments = path.split(".");
  3249. return () => {
  3250. let cur = ctx;
  3251. for (let i = 0; i < segments.length && cur; i++) {
  3252. cur = cur[segments[i]];
  3253. }
  3254. return cur;
  3255. };
  3256. }
  3257. function traverse(value, seen) {
  3258. if (!isObject(value) || value["__v_skip"]) {
  3259. return value;
  3260. }
  3261. seen = seen || /* @__PURE__ */ new Set();
  3262. if (seen.has(value)) {
  3263. return value;
  3264. }
  3265. seen.add(value);
  3266. if (isRef(value)) {
  3267. traverse(value.value, seen);
  3268. } else if (isArray(value)) {
  3269. for (let i = 0; i < value.length; i++) {
  3270. traverse(value[i], seen);
  3271. }
  3272. } else if (isSet(value) || isMap(value)) {
  3273. value.forEach((v) => {
  3274. traverse(v, seen);
  3275. });
  3276. } else if (isPlainObject(value)) {
  3277. for (const key in value) {
  3278. traverse(value[key], seen);
  3279. }
  3280. }
  3281. return value;
  3282. }
  3283. function validateDirectiveName(name) {
  3284. if (isBuiltInDirective(name)) {
  3285. warn("Do not use built-in directive ids as custom directive id: " + name);
  3286. }
  3287. }
  3288. function withDirectives(vnode, directives) {
  3289. const internalInstance = currentRenderingInstance;
  3290. if (internalInstance === null) {
  3291. warn(`withDirectives can only be used inside render functions.`);
  3292. return vnode;
  3293. }
  3294. const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
  3295. const bindings = vnode.dirs || (vnode.dirs = []);
  3296. for (let i = 0; i < directives.length; i++) {
  3297. let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
  3298. if (dir) {
  3299. if (isFunction(dir)) {
  3300. dir = {
  3301. mounted: dir,
  3302. updated: dir
  3303. };
  3304. }
  3305. if (dir.deep) {
  3306. traverse(value);
  3307. }
  3308. bindings.push({
  3309. dir,
  3310. instance,
  3311. value,
  3312. oldValue: void 0,
  3313. arg,
  3314. modifiers
  3315. });
  3316. }
  3317. }
  3318. return vnode;
  3319. }
  3320. function invokeDirectiveHook(vnode, prevVNode, instance, name) {
  3321. const bindings = vnode.dirs;
  3322. const oldBindings = prevVNode && prevVNode.dirs;
  3323. for (let i = 0; i < bindings.length; i++) {
  3324. const binding = bindings[i];
  3325. if (oldBindings) {
  3326. binding.oldValue = oldBindings[i].value;
  3327. }
  3328. let hook = binding.dir[name];
  3329. if (hook) {
  3330. pauseTracking();
  3331. callWithAsyncErrorHandling(hook, instance, 8, [
  3332. vnode.el,
  3333. binding,
  3334. vnode,
  3335. prevVNode
  3336. ]);
  3337. resetTracking();
  3338. }
  3339. }
  3340. }
  3341. function useTransitionState() {
  3342. const state = {
  3343. isMounted: false,
  3344. isLeaving: false,
  3345. isUnmounting: false,
  3346. leavingVNodes: /* @__PURE__ */ new Map()
  3347. };
  3348. onMounted(() => {
  3349. state.isMounted = true;
  3350. });
  3351. onBeforeUnmount(() => {
  3352. state.isUnmounting = true;
  3353. });
  3354. return state;
  3355. }
  3356. const TransitionHookValidator = [Function, Array];
  3357. const BaseTransitionPropsValidators = {
  3358. mode: String,
  3359. appear: Boolean,
  3360. persisted: Boolean,
  3361. // enter
  3362. onBeforeEnter: TransitionHookValidator,
  3363. onEnter: TransitionHookValidator,
  3364. onAfterEnter: TransitionHookValidator,
  3365. onEnterCancelled: TransitionHookValidator,
  3366. // leave
  3367. onBeforeLeave: TransitionHookValidator,
  3368. onLeave: TransitionHookValidator,
  3369. onAfterLeave: TransitionHookValidator,
  3370. onLeaveCancelled: TransitionHookValidator,
  3371. // appear
  3372. onBeforeAppear: TransitionHookValidator,
  3373. onAppear: TransitionHookValidator,
  3374. onAfterAppear: TransitionHookValidator,
  3375. onAppearCancelled: TransitionHookValidator
  3376. };
  3377. const BaseTransitionImpl = {
  3378. name: `BaseTransition`,
  3379. props: BaseTransitionPropsValidators,
  3380. setup(props, { slots }) {
  3381. const instance = getCurrentInstance();
  3382. const state = useTransitionState();
  3383. let prevTransitionKey;
  3384. return () => {
  3385. const children = slots.default && getTransitionRawChildren(slots.default(), true);
  3386. if (!children || !children.length) {
  3387. return;
  3388. }
  3389. let child = children[0];
  3390. if (children.length > 1) {
  3391. let hasFound = false;
  3392. for (const c of children) {
  3393. if (c.type !== Comment) {
  3394. if (hasFound) {
  3395. warn(
  3396. "<transition> can only be used on a single element or component. Use <transition-group> for lists."
  3397. );
  3398. break;
  3399. }
  3400. child = c;
  3401. hasFound = true;
  3402. }
  3403. }
  3404. }
  3405. const rawProps = toRaw(props);
  3406. const { mode } = rawProps;
  3407. if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
  3408. warn(`invalid <transition> mode: ${mode}`);
  3409. }
  3410. if (state.isLeaving) {
  3411. return emptyPlaceholder(child);
  3412. }
  3413. const innerChild = getKeepAliveChild(child);
  3414. if (!innerChild) {
  3415. return emptyPlaceholder(child);
  3416. }
  3417. const enterHooks = resolveTransitionHooks(
  3418. innerChild,
  3419. rawProps,
  3420. state,
  3421. instance
  3422. );
  3423. setTransitionHooks(innerChild, enterHooks);
  3424. const oldChild = instance.subTree;
  3425. const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
  3426. let transitionKeyChanged = false;
  3427. const { getTransitionKey } = innerChild.type;
  3428. if (getTransitionKey) {
  3429. const key = getTransitionKey();
  3430. if (prevTransitionKey === void 0) {
  3431. prevTransitionKey = key;
  3432. } else if (key !== prevTransitionKey) {
  3433. prevTransitionKey = key;
  3434. transitionKeyChanged = true;
  3435. }
  3436. }
  3437. if (oldInnerChild && oldInnerChild.type !== Comment && (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
  3438. const leavingHooks = resolveTransitionHooks(
  3439. oldInnerChild,
  3440. rawProps,
  3441. state,
  3442. instance
  3443. );
  3444. setTransitionHooks(oldInnerChild, leavingHooks);
  3445. if (mode === "out-in") {
  3446. state.isLeaving = true;
  3447. leavingHooks.afterLeave = () => {
  3448. state.isLeaving = false;
  3449. if (instance.update.active !== false) {
  3450. instance.update();
  3451. }
  3452. };
  3453. return emptyPlaceholder(child);
  3454. } else if (mode === "in-out" && innerChild.type !== Comment) {
  3455. leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
  3456. const leavingVNodesCache = getLeavingNodesForType(
  3457. state,
  3458. oldInnerChild
  3459. );
  3460. leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
  3461. el._leaveCb = () => {
  3462. earlyRemove();
  3463. el._leaveCb = void 0;
  3464. delete enterHooks.delayedLeave;
  3465. };
  3466. enterHooks.delayedLeave = delayedLeave;
  3467. };
  3468. }
  3469. }
  3470. return child;
  3471. };
  3472. }
  3473. };
  3474. const BaseTransition = BaseTransitionImpl;
  3475. function getLeavingNodesForType(state, vnode) {
  3476. const { leavingVNodes } = state;
  3477. let leavingVNodesCache = leavingVNodes.get(vnode.type);
  3478. if (!leavingVNodesCache) {
  3479. leavingVNodesCache = /* @__PURE__ */ Object.create(null);
  3480. leavingVNodes.set(vnode.type, leavingVNodesCache);
  3481. }
  3482. return leavingVNodesCache;
  3483. }
  3484. function resolveTransitionHooks(vnode, props, state, instance) {
  3485. const {
  3486. appear,
  3487. mode,
  3488. persisted = false,
  3489. onBeforeEnter,
  3490. onEnter,
  3491. onAfterEnter,
  3492. onEnterCancelled,
  3493. onBeforeLeave,
  3494. onLeave,
  3495. onAfterLeave,
  3496. onLeaveCancelled,
  3497. onBeforeAppear,
  3498. onAppear,
  3499. onAfterAppear,
  3500. onAppearCancelled
  3501. } = props;
  3502. const key = String(vnode.key);
  3503. const leavingVNodesCache = getLeavingNodesForType(state, vnode);
  3504. const callHook = (hook, args) => {
  3505. hook && callWithAsyncErrorHandling(
  3506. hook,
  3507. instance,
  3508. 9,
  3509. args
  3510. );
  3511. };
  3512. const callAsyncHook = (hook, args) => {
  3513. const done = args[1];
  3514. callHook(hook, args);
  3515. if (isArray(hook)) {
  3516. if (hook.every((hook2) => hook2.length <= 1))
  3517. done();
  3518. } else if (hook.length <= 1) {
  3519. done();
  3520. }
  3521. };
  3522. const hooks = {
  3523. mode,
  3524. persisted,
  3525. beforeEnter(el) {
  3526. let hook = onBeforeEnter;
  3527. if (!state.isMounted) {
  3528. if (appear) {
  3529. hook = onBeforeAppear || onBeforeEnter;
  3530. } else {
  3531. return;
  3532. }
  3533. }
  3534. if (el._leaveCb) {
  3535. el._leaveCb(
  3536. true
  3537. /* cancelled */
  3538. );
  3539. }
  3540. const leavingVNode = leavingVNodesCache[key];
  3541. if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el._leaveCb) {
  3542. leavingVNode.el._leaveCb();
  3543. }
  3544. callHook(hook, [el]);
  3545. },
  3546. enter(el) {
  3547. let hook = onEnter;
  3548. let afterHook = onAfterEnter;
  3549. let cancelHook = onEnterCancelled;
  3550. if (!state.isMounted) {
  3551. if (appear) {
  3552. hook = onAppear || onEnter;
  3553. afterHook = onAfterAppear || onAfterEnter;
  3554. cancelHook = onAppearCancelled || onEnterCancelled;
  3555. } else {
  3556. return;
  3557. }
  3558. }
  3559. let called = false;
  3560. const done = el._enterCb = (cancelled) => {
  3561. if (called)
  3562. return;
  3563. called = true;
  3564. if (cancelled) {
  3565. callHook(cancelHook, [el]);
  3566. } else {
  3567. callHook(afterHook, [el]);
  3568. }
  3569. if (hooks.delayedLeave) {
  3570. hooks.delayedLeave();
  3571. }
  3572. el._enterCb = void 0;
  3573. };
  3574. if (hook) {
  3575. callAsyncHook(hook, [el, done]);
  3576. } else {
  3577. done();
  3578. }
  3579. },
  3580. leave(el, remove) {
  3581. const key2 = String(vnode.key);
  3582. if (el._enterCb) {
  3583. el._enterCb(
  3584. true
  3585. /* cancelled */
  3586. );
  3587. }
  3588. if (state.isUnmounting) {
  3589. return remove();
  3590. }
  3591. callHook(onBeforeLeave, [el]);
  3592. let called = false;
  3593. const done = el._leaveCb = (cancelled) => {
  3594. if (called)
  3595. return;
  3596. called = true;
  3597. remove();
  3598. if (cancelled) {
  3599. callHook(onLeaveCancelled, [el]);
  3600. } else {
  3601. callHook(onAfterLeave, [el]);
  3602. }
  3603. el._leaveCb = void 0;
  3604. if (leavingVNodesCache[key2] === vnode) {
  3605. delete leavingVNodesCache[key2];
  3606. }
  3607. };
  3608. leavingVNodesCache[key2] = vnode;
  3609. if (onLeave) {
  3610. callAsyncHook(onLeave, [el, done]);
  3611. } else {
  3612. done();
  3613. }
  3614. },
  3615. clone(vnode2) {
  3616. return resolveTransitionHooks(vnode2, props, state, instance);
  3617. }
  3618. };
  3619. return hooks;
  3620. }
  3621. function emptyPlaceholder(vnode) {
  3622. if (isKeepAlive(vnode)) {
  3623. vnode = cloneVNode(vnode);
  3624. vnode.children = null;
  3625. return vnode;
  3626. }
  3627. }
  3628. function getKeepAliveChild(vnode) {
  3629. return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : void 0 : vnode;
  3630. }
  3631. function setTransitionHooks(vnode, hooks) {
  3632. if (vnode.shapeFlag & 6 && vnode.component) {
  3633. setTransitionHooks(vnode.component.subTree, hooks);
  3634. } else if (vnode.shapeFlag & 128) {
  3635. vnode.ssContent.transition = hooks.clone(vnode.ssContent);
  3636. vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
  3637. } else {
  3638. vnode.transition = hooks;
  3639. }
  3640. }
  3641. function getTransitionRawChildren(children, keepComment = false, parentKey) {
  3642. let ret = [];
  3643. let keyedFragmentCount = 0;
  3644. for (let i = 0; i < children.length; i++) {
  3645. let child = children[i];
  3646. const key = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i);
  3647. if (child.type === Fragment) {
  3648. if (child.patchFlag & 128)
  3649. keyedFragmentCount++;
  3650. ret = ret.concat(
  3651. getTransitionRawChildren(child.children, keepComment, key)
  3652. );
  3653. } else if (keepComment || child.type !== Comment) {
  3654. ret.push(key != null ? cloneVNode(child, { key }) : child);
  3655. }
  3656. }
  3657. if (keyedFragmentCount > 1) {
  3658. for (let i = 0; i < ret.length; i++) {
  3659. ret[i].patchFlag = -2;
  3660. }
  3661. }
  3662. return ret;
  3663. }
  3664. function defineComponent(options, extraOptions) {
  3665. return isFunction(options) ? (
  3666. // #8326: extend call and options.name access are considered side-effects
  3667. // by Rollup, so we have to wrap it in a pure-annotated IIFE.
  3668. /* @__PURE__ */ (() => extend({ name: options.name }, extraOptions, { setup: options }))()
  3669. ) : options;
  3670. }
  3671. const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
  3672. function defineAsyncComponent(source) {
  3673. if (isFunction(source)) {
  3674. source = { loader: source };
  3675. }
  3676. const {
  3677. loader,
  3678. loadingComponent,
  3679. errorComponent,
  3680. delay = 200,
  3681. timeout,
  3682. // undefined = never times out
  3683. suspensible = true,
  3684. onError: userOnError
  3685. } = source;
  3686. let pendingRequest = null;
  3687. let resolvedComp;
  3688. let retries = 0;
  3689. const retry = () => {
  3690. retries++;
  3691. pendingRequest = null;
  3692. return load();
  3693. };
  3694. const load = () => {
  3695. let thisRequest;
  3696. return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
  3697. err = err instanceof Error ? err : new Error(String(err));
  3698. if (userOnError) {
  3699. return new Promise((resolve, reject) => {
  3700. const userRetry = () => resolve(retry());
  3701. const userFail = () => reject(err);
  3702. userOnError(err, userRetry, userFail, retries + 1);
  3703. });
  3704. } else {
  3705. throw err;
  3706. }
  3707. }).then((comp) => {
  3708. if (thisRequest !== pendingRequest && pendingRequest) {
  3709. return pendingRequest;
  3710. }
  3711. if (!comp) {
  3712. warn(
  3713. `Async component loader resolved to undefined. If you are using retry(), make sure to return its return value.`
  3714. );
  3715. }
  3716. if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
  3717. comp = comp.default;
  3718. }
  3719. if (comp && !isObject(comp) && !isFunction(comp)) {
  3720. throw new Error(`Invalid async component load result: ${comp}`);
  3721. }
  3722. resolvedComp = comp;
  3723. return comp;
  3724. }));
  3725. };
  3726. return defineComponent({
  3727. name: "AsyncComponentWrapper",
  3728. __asyncLoader: load,
  3729. get __asyncResolved() {
  3730. return resolvedComp;
  3731. },
  3732. setup() {
  3733. const instance = currentInstance;
  3734. if (resolvedComp) {
  3735. return () => createInnerComp(resolvedComp, instance);
  3736. }
  3737. const onError = (err) => {
  3738. pendingRequest = null;
  3739. handleError(
  3740. err,
  3741. instance,
  3742. 13,
  3743. !errorComponent
  3744. /* do not throw in dev if user provided error component */
  3745. );
  3746. };
  3747. if (suspensible && instance.suspense || false) {
  3748. return load().then((comp) => {
  3749. return () => createInnerComp(comp, instance);
  3750. }).catch((err) => {
  3751. onError(err);
  3752. return () => errorComponent ? createVNode(errorComponent, {
  3753. error: err
  3754. }) : null;
  3755. });
  3756. }
  3757. const loaded = ref(false);
  3758. const error = ref();
  3759. const delayed = ref(!!delay);
  3760. if (delay) {
  3761. setTimeout(() => {
  3762. delayed.value = false;
  3763. }, delay);
  3764. }
  3765. if (timeout != null) {
  3766. setTimeout(() => {
  3767. if (!loaded.value && !error.value) {
  3768. const err = new Error(
  3769. `Async component timed out after ${timeout}ms.`
  3770. );
  3771. onError(err);
  3772. error.value = err;
  3773. }
  3774. }, timeout);
  3775. }
  3776. load().then(() => {
  3777. loaded.value = true;
  3778. if (instance.parent && isKeepAlive(instance.parent.vnode)) {
  3779. queueJob(instance.parent.update);
  3780. }
  3781. }).catch((err) => {
  3782. onError(err);
  3783. error.value = err;
  3784. });
  3785. return () => {
  3786. if (loaded.value && resolvedComp) {
  3787. return createInnerComp(resolvedComp, instance);
  3788. } else if (error.value && errorComponent) {
  3789. return createVNode(errorComponent, {
  3790. error: error.value
  3791. });
  3792. } else if (loadingComponent && !delayed.value) {
  3793. return createVNode(loadingComponent);
  3794. }
  3795. };
  3796. }
  3797. });
  3798. }
  3799. function createInnerComp(comp, parent) {
  3800. const { ref: ref2, props, children, ce } = parent.vnode;
  3801. const vnode = createVNode(comp, props, children);
  3802. vnode.ref = ref2;
  3803. vnode.ce = ce;
  3804. delete parent.vnode.ce;
  3805. return vnode;
  3806. }
  3807. const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
  3808. const KeepAliveImpl = {
  3809. name: `KeepAlive`,
  3810. // Marker for special handling inside the renderer. We are not using a ===
  3811. // check directly on KeepAlive in the renderer, because importing it directly
  3812. // would prevent it from being tree-shaken.
  3813. __isKeepAlive: true,
  3814. props: {
  3815. include: [String, RegExp, Array],
  3816. exclude: [String, RegExp, Array],
  3817. max: [String, Number]
  3818. },
  3819. setup(props, { slots }) {
  3820. const instance = getCurrentInstance();
  3821. const sharedContext = instance.ctx;
  3822. const cache = /* @__PURE__ */ new Map();
  3823. const keys = /* @__PURE__ */ new Set();
  3824. let current = null;
  3825. {
  3826. instance.__v_cache = cache;
  3827. }
  3828. const parentSuspense = instance.suspense;
  3829. const {
  3830. renderer: {
  3831. p: patch,
  3832. m: move,
  3833. um: _unmount,
  3834. o: { createElement }
  3835. }
  3836. } = sharedContext;
  3837. const storageContainer = createElement("div");
  3838. sharedContext.activate = (vnode, container, anchor, isSVG, optimized) => {
  3839. const instance2 = vnode.component;
  3840. move(vnode, container, anchor, 0, parentSuspense);
  3841. patch(
  3842. instance2.vnode,
  3843. vnode,
  3844. container,
  3845. anchor,
  3846. instance2,
  3847. parentSuspense,
  3848. isSVG,
  3849. vnode.slotScopeIds,
  3850. optimized
  3851. );
  3852. queuePostRenderEffect(() => {
  3853. instance2.isDeactivated = false;
  3854. if (instance2.a) {
  3855. invokeArrayFns(instance2.a);
  3856. }
  3857. const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
  3858. if (vnodeHook) {
  3859. invokeVNodeHook(vnodeHook, instance2.parent, vnode);
  3860. }
  3861. }, parentSuspense);
  3862. {
  3863. devtoolsComponentAdded(instance2);
  3864. }
  3865. };
  3866. sharedContext.deactivate = (vnode) => {
  3867. const instance2 = vnode.component;
  3868. move(vnode, storageContainer, null, 1, parentSuspense);
  3869. queuePostRenderEffect(() => {
  3870. if (instance2.da) {
  3871. invokeArrayFns(instance2.da);
  3872. }
  3873. const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
  3874. if (vnodeHook) {
  3875. invokeVNodeHook(vnodeHook, instance2.parent, vnode);
  3876. }
  3877. instance2.isDeactivated = true;
  3878. }, parentSuspense);
  3879. {
  3880. devtoolsComponentAdded(instance2);
  3881. }
  3882. };
  3883. function unmount(vnode) {
  3884. resetShapeFlag(vnode);
  3885. _unmount(vnode, instance, parentSuspense, true);
  3886. }
  3887. function pruneCache(filter) {
  3888. cache.forEach((vnode, key) => {
  3889. const name = getComponentName(vnode.type);
  3890. if (name && (!filter || !filter(name))) {
  3891. pruneCacheEntry(key);
  3892. }
  3893. });
  3894. }
  3895. function pruneCacheEntry(key) {
  3896. const cached = cache.get(key);
  3897. if (!current || !isSameVNodeType(cached, current)) {
  3898. unmount(cached);
  3899. } else if (current) {
  3900. resetShapeFlag(current);
  3901. }
  3902. cache.delete(key);
  3903. keys.delete(key);
  3904. }
  3905. watch(
  3906. () => [props.include, props.exclude],
  3907. ([include, exclude]) => {
  3908. include && pruneCache((name) => matches(include, name));
  3909. exclude && pruneCache((name) => !matches(exclude, name));
  3910. },
  3911. // prune post-render after `current` has been updated
  3912. { flush: "post", deep: true }
  3913. );
  3914. let pendingCacheKey = null;
  3915. const cacheSubtree = () => {
  3916. if (pendingCacheKey != null) {
  3917. cache.set(pendingCacheKey, getInnerChild(instance.subTree));
  3918. }
  3919. };
  3920. onMounted(cacheSubtree);
  3921. onUpdated(cacheSubtree);
  3922. onBeforeUnmount(() => {
  3923. cache.forEach((cached) => {
  3924. const { subTree, suspense } = instance;
  3925. const vnode = getInnerChild(subTree);
  3926. if (cached.type === vnode.type && cached.key === vnode.key) {
  3927. resetShapeFlag(vnode);
  3928. const da = vnode.component.da;
  3929. da && queuePostRenderEffect(da, suspense);
  3930. return;
  3931. }
  3932. unmount(cached);
  3933. });
  3934. });
  3935. return () => {
  3936. pendingCacheKey = null;
  3937. if (!slots.default) {
  3938. return null;
  3939. }
  3940. const children = slots.default();
  3941. const rawVNode = children[0];
  3942. if (children.length > 1) {
  3943. {
  3944. warn(`KeepAlive should contain exactly one component child.`);
  3945. }
  3946. current = null;
  3947. return children;
  3948. } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) {
  3949. current = null;
  3950. return rawVNode;
  3951. }
  3952. let vnode = getInnerChild(rawVNode);
  3953. const comp = vnode.type;
  3954. const name = getComponentName(
  3955. isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
  3956. );
  3957. const { include, exclude, max } = props;
  3958. if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
  3959. current = vnode;
  3960. return rawVNode;
  3961. }
  3962. const key = vnode.key == null ? comp : vnode.key;
  3963. const cachedVNode = cache.get(key);
  3964. if (vnode.el) {
  3965. vnode = cloneVNode(vnode);
  3966. if (rawVNode.shapeFlag & 128) {
  3967. rawVNode.ssContent = vnode;
  3968. }
  3969. }
  3970. pendingCacheKey = key;
  3971. if (cachedVNode) {
  3972. vnode.el = cachedVNode.el;
  3973. vnode.component = cachedVNode.component;
  3974. if (vnode.transition) {
  3975. setTransitionHooks(vnode, vnode.transition);
  3976. }
  3977. vnode.shapeFlag |= 512;
  3978. keys.delete(key);
  3979. keys.add(key);
  3980. } else {
  3981. keys.add(key);
  3982. if (max && keys.size > parseInt(max, 10)) {
  3983. pruneCacheEntry(keys.values().next().value);
  3984. }
  3985. }
  3986. vnode.shapeFlag |= 256;
  3987. current = vnode;
  3988. return isSuspense(rawVNode.type) ? rawVNode : vnode;
  3989. };
  3990. }
  3991. };
  3992. const KeepAlive = KeepAliveImpl;
  3993. function matches(pattern, name) {
  3994. if (isArray(pattern)) {
  3995. return pattern.some((p) => matches(p, name));
  3996. } else if (isString(pattern)) {
  3997. return pattern.split(",").includes(name);
  3998. } else if (isRegExp(pattern)) {
  3999. return pattern.test(name);
  4000. }
  4001. return false;
  4002. }
  4003. function onActivated(hook, target) {
  4004. registerKeepAliveHook(hook, "a", target);
  4005. }
  4006. function onDeactivated(hook, target) {
  4007. registerKeepAliveHook(hook, "da", target);
  4008. }
  4009. function registerKeepAliveHook(hook, type, target = currentInstance) {
  4010. const wrappedHook = hook.__wdc || (hook.__wdc = () => {
  4011. let current = target;
  4012. while (current) {
  4013. if (current.isDeactivated) {
  4014. return;
  4015. }
  4016. current = current.parent;
  4017. }
  4018. return hook();
  4019. });
  4020. injectHook(type, wrappedHook, target);
  4021. if (target) {
  4022. let current = target.parent;
  4023. while (current && current.parent) {
  4024. if (isKeepAlive(current.parent.vnode)) {
  4025. injectToKeepAliveRoot(wrappedHook, type, target, current);
  4026. }
  4027. current = current.parent;
  4028. }
  4029. }
  4030. }
  4031. function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
  4032. const injected = injectHook(
  4033. type,
  4034. hook,
  4035. keepAliveRoot,
  4036. true
  4037. /* prepend */
  4038. );
  4039. onUnmounted(() => {
  4040. remove(keepAliveRoot[type], injected);
  4041. }, target);
  4042. }
  4043. function resetShapeFlag(vnode) {
  4044. vnode.shapeFlag &= ~256;
  4045. vnode.shapeFlag &= ~512;
  4046. }
  4047. function getInnerChild(vnode) {
  4048. return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
  4049. }
  4050. function injectHook(type, hook, target = currentInstance, prepend = false) {
  4051. if (target) {
  4052. const hooks = target[type] || (target[type] = []);
  4053. const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
  4054. if (target.isUnmounted) {
  4055. return;
  4056. }
  4057. pauseTracking();
  4058. setCurrentInstance(target);
  4059. const res = callWithAsyncErrorHandling(hook, target, type, args);
  4060. unsetCurrentInstance();
  4061. resetTracking();
  4062. return res;
  4063. });
  4064. if (prepend) {
  4065. hooks.unshift(wrappedHook);
  4066. } else {
  4067. hooks.push(wrappedHook);
  4068. }
  4069. return wrappedHook;
  4070. } else {
  4071. const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ""));
  4072. warn(
  4073. `${apiName} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup().` + (` If you are using async setup(), make sure to register lifecycle hooks before the first await statement.` )
  4074. );
  4075. }
  4076. }
  4077. const createHook = (lifecycle) => (hook, target = currentInstance) => (
  4078. // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
  4079. (!isInSSRComponentSetup || lifecycle === "sp") && injectHook(lifecycle, (...args) => hook(...args), target)
  4080. );
  4081. const onBeforeMount = createHook("bm");
  4082. const onMounted = createHook("m");
  4083. const onBeforeUpdate = createHook("bu");
  4084. const onUpdated = createHook("u");
  4085. const onBeforeUnmount = createHook("bum");
  4086. const onUnmounted = createHook("um");
  4087. const onServerPrefetch = createHook("sp");
  4088. const onRenderTriggered = createHook(
  4089. "rtg"
  4090. );
  4091. const onRenderTracked = createHook(
  4092. "rtc"
  4093. );
  4094. function onErrorCaptured(hook, target = currentInstance) {
  4095. injectHook("ec", hook, target);
  4096. }
  4097. const COMPONENTS = "components";
  4098. const DIRECTIVES = "directives";
  4099. function resolveComponent(name, maybeSelfReference) {
  4100. return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
  4101. }
  4102. const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
  4103. function resolveDynamicComponent(component) {
  4104. if (isString(component)) {
  4105. return resolveAsset(COMPONENTS, component, false) || component;
  4106. } else {
  4107. return component || NULL_DYNAMIC_COMPONENT;
  4108. }
  4109. }
  4110. function resolveDirective(name) {
  4111. return resolveAsset(DIRECTIVES, name);
  4112. }
  4113. function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
  4114. const instance = currentRenderingInstance || currentInstance;
  4115. if (instance) {
  4116. const Component = instance.type;
  4117. if (type === COMPONENTS) {
  4118. const selfName = getComponentName(
  4119. Component,
  4120. false
  4121. /* do not include inferred name to avoid breaking existing code */
  4122. );
  4123. if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
  4124. return Component;
  4125. }
  4126. }
  4127. const res = (
  4128. // local registration
  4129. // check instance[type] first which is resolved for options API
  4130. resolve(instance[type] || Component[type], name) || // global registration
  4131. resolve(instance.appContext[type], name)
  4132. );
  4133. if (!res && maybeSelfReference) {
  4134. return Component;
  4135. }
  4136. if (warnMissing && !res) {
  4137. const extra = type === COMPONENTS ? `
  4138. If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
  4139. warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
  4140. }
  4141. return res;
  4142. } else {
  4143. warn(
  4144. `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
  4145. );
  4146. }
  4147. }
  4148. function resolve(registry, name) {
  4149. return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
  4150. }
  4151. function renderList(source, renderItem, cache, index) {
  4152. let ret;
  4153. const cached = cache && cache[index];
  4154. if (isArray(source) || isString(source)) {
  4155. ret = new Array(source.length);
  4156. for (let i = 0, l = source.length; i < l; i++) {
  4157. ret[i] = renderItem(source[i], i, void 0, cached && cached[i]);
  4158. }
  4159. } else if (typeof source === "number") {
  4160. if (!Number.isInteger(source)) {
  4161. warn(`The v-for range expect an integer value but got ${source}.`);
  4162. }
  4163. ret = new Array(source);
  4164. for (let i = 0; i < source; i++) {
  4165. ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
  4166. }
  4167. } else if (isObject(source)) {
  4168. if (source[Symbol.iterator]) {
  4169. ret = Array.from(
  4170. source,
  4171. (item, i) => renderItem(item, i, void 0, cached && cached[i])
  4172. );
  4173. } else {
  4174. const keys = Object.keys(source);
  4175. ret = new Array(keys.length);
  4176. for (let i = 0, l = keys.length; i < l; i++) {
  4177. const key = keys[i];
  4178. ret[i] = renderItem(source[key], key, i, cached && cached[i]);
  4179. }
  4180. }
  4181. } else {
  4182. ret = [];
  4183. }
  4184. if (cache) {
  4185. cache[index] = ret;
  4186. }
  4187. return ret;
  4188. }
  4189. function createSlots(slots, dynamicSlots) {
  4190. for (let i = 0; i < dynamicSlots.length; i++) {
  4191. const slot = dynamicSlots[i];
  4192. if (isArray(slot)) {
  4193. for (let j = 0; j < slot.length; j++) {
  4194. slots[slot[j].name] = slot[j].fn;
  4195. }
  4196. } else if (slot) {
  4197. slots[slot.name] = slot.key ? (...args) => {
  4198. const res = slot.fn(...args);
  4199. if (res)
  4200. res.key = slot.key;
  4201. return res;
  4202. } : slot.fn;
  4203. }
  4204. }
  4205. return slots;
  4206. }
  4207. function renderSlot(slots, name, props = {}, fallback, noSlotted) {
  4208. if (currentRenderingInstance.isCE || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.isCE) {
  4209. if (name !== "default")
  4210. props.name = name;
  4211. return createVNode("slot", props, fallback && fallback());
  4212. }
  4213. let slot = slots[name];
  4214. if (slot && slot.length > 1) {
  4215. warn(
  4216. `SSR-optimized slot function detected in a non-SSR-optimized render function. You need to mark this component with $dynamic-slots in the parent template.`
  4217. );
  4218. slot = () => [];
  4219. }
  4220. if (slot && slot._c) {
  4221. slot._d = false;
  4222. }
  4223. openBlock();
  4224. const validSlotContent = slot && ensureValidVNode(slot(props));
  4225. const rendered = createBlock(
  4226. Fragment,
  4227. {
  4228. key: props.key || // slot content array of a dynamic conditional slot may have a branch
  4229. // key attached in the `createSlots` helper, respect that
  4230. validSlotContent && validSlotContent.key || `_${name}`
  4231. },
  4232. validSlotContent || (fallback ? fallback() : []),
  4233. validSlotContent && slots._ === 1 ? 64 : -2
  4234. );
  4235. if (!noSlotted && rendered.scopeId) {
  4236. rendered.slotScopeIds = [rendered.scopeId + "-s"];
  4237. }
  4238. if (slot && slot._c) {
  4239. slot._d = true;
  4240. }
  4241. return rendered;
  4242. }
  4243. function ensureValidVNode(vnodes) {
  4244. return vnodes.some((child) => {
  4245. if (!isVNode(child))
  4246. return true;
  4247. if (child.type === Comment)
  4248. return false;
  4249. if (child.type === Fragment && !ensureValidVNode(child.children))
  4250. return false;
  4251. return true;
  4252. }) ? vnodes : null;
  4253. }
  4254. function toHandlers(obj, preserveCaseIfNecessary) {
  4255. const ret = {};
  4256. if (!isObject(obj)) {
  4257. warn(`v-on with no argument expects an object value.`);
  4258. return ret;
  4259. }
  4260. for (const key in obj) {
  4261. ret[preserveCaseIfNecessary && /[A-Z]/.test(key) ? `on:${key}` : toHandlerKey(key)] = obj[key];
  4262. }
  4263. return ret;
  4264. }
  4265. const getPublicInstance = (i) => {
  4266. if (!i)
  4267. return null;
  4268. if (isStatefulComponent(i))
  4269. return getExposeProxy(i) || i.proxy;
  4270. return getPublicInstance(i.parent);
  4271. };
  4272. const publicPropertiesMap = (
  4273. // Move PURE marker to new line to workaround compiler discarding it
  4274. // due to type annotation
  4275. /* @__PURE__ */ extend(/* @__PURE__ */ Object.create(null), {
  4276. $: (i) => i,
  4277. $el: (i) => i.vnode.el,
  4278. $data: (i) => i.data,
  4279. $props: (i) => shallowReadonly(i.props) ,
  4280. $attrs: (i) => shallowReadonly(i.attrs) ,
  4281. $slots: (i) => shallowReadonly(i.slots) ,
  4282. $refs: (i) => shallowReadonly(i.refs) ,
  4283. $parent: (i) => getPublicInstance(i.parent),
  4284. $root: (i) => getPublicInstance(i.root),
  4285. $emit: (i) => i.emit,
  4286. $options: (i) => resolveMergedOptions(i) ,
  4287. $forceUpdate: (i) => i.f || (i.f = () => queueJob(i.update)),
  4288. $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
  4289. $watch: (i) => instanceWatch.bind(i)
  4290. })
  4291. );
  4292. const isReservedPrefix = (key) => key === "_" || key === "$";
  4293. const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
  4294. const PublicInstanceProxyHandlers = {
  4295. get({ _: instance }, key) {
  4296. const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
  4297. if (key === "__isVue") {
  4298. return true;
  4299. }
  4300. let normalizedProps;
  4301. if (key[0] !== "$") {
  4302. const n = accessCache[key];
  4303. if (n !== void 0) {
  4304. switch (n) {
  4305. case 1 /* SETUP */:
  4306. return setupState[key];
  4307. case 2 /* DATA */:
  4308. return data[key];
  4309. case 4 /* CONTEXT */:
  4310. return ctx[key];
  4311. case 3 /* PROPS */:
  4312. return props[key];
  4313. }
  4314. } else if (hasSetupBinding(setupState, key)) {
  4315. accessCache[key] = 1 /* SETUP */;
  4316. return setupState[key];
  4317. } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  4318. accessCache[key] = 2 /* DATA */;
  4319. return data[key];
  4320. } else if (
  4321. // only cache other properties when instance has declared (thus stable)
  4322. // props
  4323. (normalizedProps = instance.propsOptions[0]) && hasOwn(normalizedProps, key)
  4324. ) {
  4325. accessCache[key] = 3 /* PROPS */;
  4326. return props[key];
  4327. } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  4328. accessCache[key] = 4 /* CONTEXT */;
  4329. return ctx[key];
  4330. } else if (shouldCacheAccess) {
  4331. accessCache[key] = 0 /* OTHER */;
  4332. }
  4333. }
  4334. const publicGetter = publicPropertiesMap[key];
  4335. let cssModule, globalProperties;
  4336. if (publicGetter) {
  4337. if (key === "$attrs") {
  4338. track(instance, "get", key);
  4339. markAttrsAccessed();
  4340. } else if (key === "$slots") {
  4341. track(instance, "get", key);
  4342. }
  4343. return publicGetter(instance);
  4344. } else if (
  4345. // css module (injected by vue-loader)
  4346. (cssModule = type.__cssModules) && (cssModule = cssModule[key])
  4347. ) {
  4348. return cssModule;
  4349. } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  4350. accessCache[key] = 4 /* CONTEXT */;
  4351. return ctx[key];
  4352. } else if (
  4353. // global properties
  4354. globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)
  4355. ) {
  4356. {
  4357. return globalProperties[key];
  4358. }
  4359. } else if (currentRenderingInstance && (!isString(key) || // #1091 avoid internal isRef/isVNode checks on component instance leading
  4360. // to infinite warning loop
  4361. key.indexOf("__v") !== 0)) {
  4362. if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
  4363. warn(
  4364. `Property ${JSON.stringify(
  4365. key
  4366. )} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`
  4367. );
  4368. } else if (instance === currentRenderingInstance) {
  4369. warn(
  4370. `Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.`
  4371. );
  4372. }
  4373. }
  4374. },
  4375. set({ _: instance }, key, value) {
  4376. const { data, setupState, ctx } = instance;
  4377. if (hasSetupBinding(setupState, key)) {
  4378. setupState[key] = value;
  4379. return true;
  4380. } else if (setupState.__isScriptSetup && hasOwn(setupState, key)) {
  4381. warn(`Cannot mutate <script setup> binding "${key}" from Options API.`);
  4382. return false;
  4383. } else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  4384. data[key] = value;
  4385. return true;
  4386. } else if (hasOwn(instance.props, key)) {
  4387. warn(`Attempting to mutate prop "${key}". Props are readonly.`);
  4388. return false;
  4389. }
  4390. if (key[0] === "$" && key.slice(1) in instance) {
  4391. warn(
  4392. `Attempting to mutate public property "${key}". Properties starting with $ are reserved and readonly.`
  4393. );
  4394. return false;
  4395. } else {
  4396. if (key in instance.appContext.config.globalProperties) {
  4397. Object.defineProperty(ctx, key, {
  4398. enumerable: true,
  4399. configurable: true,
  4400. value
  4401. });
  4402. } else {
  4403. ctx[key] = value;
  4404. }
  4405. }
  4406. return true;
  4407. },
  4408. has({
  4409. _: { data, setupState, accessCache, ctx, appContext, propsOptions }
  4410. }, key) {
  4411. let normalizedProps;
  4412. return !!accessCache[key] || data !== EMPTY_OBJ && hasOwn(data, key) || hasSetupBinding(setupState, key) || (normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key) || hasOwn(ctx, key) || hasOwn(publicPropertiesMap, key) || hasOwn(appContext.config.globalProperties, key);
  4413. },
  4414. defineProperty(target, key, descriptor) {
  4415. if (descriptor.get != null) {
  4416. target._.accessCache[key] = 0;
  4417. } else if (hasOwn(descriptor, "value")) {
  4418. this.set(target, key, descriptor.value, null);
  4419. }
  4420. return Reflect.defineProperty(target, key, descriptor);
  4421. }
  4422. };
  4423. {
  4424. PublicInstanceProxyHandlers.ownKeys = (target) => {
  4425. warn(
  4426. `Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.`
  4427. );
  4428. return Reflect.ownKeys(target);
  4429. };
  4430. }
  4431. const RuntimeCompiledPublicInstanceProxyHandlers = /* @__PURE__ */ extend(
  4432. {},
  4433. PublicInstanceProxyHandlers,
  4434. {
  4435. get(target, key) {
  4436. if (key === Symbol.unscopables) {
  4437. return;
  4438. }
  4439. return PublicInstanceProxyHandlers.get(target, key, target);
  4440. },
  4441. has(_, key) {
  4442. const has = key[0] !== "_" && !isGloballyWhitelisted(key);
  4443. if (!has && PublicInstanceProxyHandlers.has(_, key)) {
  4444. warn(
  4445. `Property ${JSON.stringify(
  4446. key
  4447. )} should not start with _ which is a reserved prefix for Vue internals.`
  4448. );
  4449. }
  4450. return has;
  4451. }
  4452. }
  4453. );
  4454. function createDevRenderContext(instance) {
  4455. const target = {};
  4456. Object.defineProperty(target, `_`, {
  4457. configurable: true,
  4458. enumerable: false,
  4459. get: () => instance
  4460. });
  4461. Object.keys(publicPropertiesMap).forEach((key) => {
  4462. Object.defineProperty(target, key, {
  4463. configurable: true,
  4464. enumerable: false,
  4465. get: () => publicPropertiesMap[key](instance),
  4466. // intercepted by the proxy so no need for implementation,
  4467. // but needed to prevent set errors
  4468. set: NOOP
  4469. });
  4470. });
  4471. return target;
  4472. }
  4473. function exposePropsOnRenderContext(instance) {
  4474. const {
  4475. ctx,
  4476. propsOptions: [propsOptions]
  4477. } = instance;
  4478. if (propsOptions) {
  4479. Object.keys(propsOptions).forEach((key) => {
  4480. Object.defineProperty(ctx, key, {
  4481. enumerable: true,
  4482. configurable: true,
  4483. get: () => instance.props[key],
  4484. set: NOOP
  4485. });
  4486. });
  4487. }
  4488. }
  4489. function exposeSetupStateOnRenderContext(instance) {
  4490. const { ctx, setupState } = instance;
  4491. Object.keys(toRaw(setupState)).forEach((key) => {
  4492. if (!setupState.__isScriptSetup) {
  4493. if (isReservedPrefix(key[0])) {
  4494. warn(
  4495. `setup() return property ${JSON.stringify(
  4496. key
  4497. )} should not start with "$" or "_" which are reserved prefixes for Vue internals.`
  4498. );
  4499. return;
  4500. }
  4501. Object.defineProperty(ctx, key, {
  4502. enumerable: true,
  4503. configurable: true,
  4504. get: () => setupState[key],
  4505. set: NOOP
  4506. });
  4507. }
  4508. });
  4509. }
  4510. const warnRuntimeUsage = (method) => warn(
  4511. `${method}() is a compiler-hint helper that is only usable inside <script setup> of a single file component. Its arguments should be compiled away and passing it at runtime has no effect.`
  4512. );
  4513. function defineProps() {
  4514. {
  4515. warnRuntimeUsage(`defineProps`);
  4516. }
  4517. return null;
  4518. }
  4519. function defineEmits() {
  4520. {
  4521. warnRuntimeUsage(`defineEmits`);
  4522. }
  4523. return null;
  4524. }
  4525. function defineExpose(exposed) {
  4526. {
  4527. warnRuntimeUsage(`defineExpose`);
  4528. }
  4529. }
  4530. function defineOptions(options) {
  4531. {
  4532. warnRuntimeUsage(`defineOptions`);
  4533. }
  4534. }
  4535. function defineSlots() {
  4536. {
  4537. warnRuntimeUsage(`defineSlots`);
  4538. }
  4539. return null;
  4540. }
  4541. function defineModel() {
  4542. {
  4543. warnRuntimeUsage("defineModel");
  4544. }
  4545. }
  4546. function withDefaults(props, defaults) {
  4547. {
  4548. warnRuntimeUsage(`withDefaults`);
  4549. }
  4550. return null;
  4551. }
  4552. function useSlots() {
  4553. return getContext().slots;
  4554. }
  4555. function useAttrs() {
  4556. return getContext().attrs;
  4557. }
  4558. function useModel(props, name, options) {
  4559. const i = getCurrentInstance();
  4560. if (!i) {
  4561. warn(`useModel() called without active instance.`);
  4562. return ref();
  4563. }
  4564. if (!i.propsOptions[0][name]) {
  4565. warn(`useModel() called with prop "${name}" which is not declared.`);
  4566. return ref();
  4567. }
  4568. if (options && options.local) {
  4569. const proxy = ref(props[name]);
  4570. watch(
  4571. () => props[name],
  4572. (v) => proxy.value = v
  4573. );
  4574. watch(proxy, (value) => {
  4575. if (value !== props[name]) {
  4576. i.emit(`update:${name}`, value);
  4577. }
  4578. });
  4579. return proxy;
  4580. } else {
  4581. return {
  4582. __v_isRef: true,
  4583. get value() {
  4584. return props[name];
  4585. },
  4586. set value(value) {
  4587. i.emit(`update:${name}`, value);
  4588. }
  4589. };
  4590. }
  4591. }
  4592. function getContext() {
  4593. const i = getCurrentInstance();
  4594. if (!i) {
  4595. warn(`useContext() called without active instance.`);
  4596. }
  4597. return i.setupContext || (i.setupContext = createSetupContext(i));
  4598. }
  4599. function normalizePropsOrEmits(props) {
  4600. return isArray(props) ? props.reduce(
  4601. (normalized, p) => (normalized[p] = null, normalized),
  4602. {}
  4603. ) : props;
  4604. }
  4605. function mergeDefaults(raw, defaults) {
  4606. const props = normalizePropsOrEmits(raw);
  4607. for (const key in defaults) {
  4608. if (key.startsWith("__skip"))
  4609. continue;
  4610. let opt = props[key];
  4611. if (opt) {
  4612. if (isArray(opt) || isFunction(opt)) {
  4613. opt = props[key] = { type: opt, default: defaults[key] };
  4614. } else {
  4615. opt.default = defaults[key];
  4616. }
  4617. } else if (opt === null) {
  4618. opt = props[key] = { default: defaults[key] };
  4619. } else {
  4620. warn(`props default key "${key}" has no corresponding declaration.`);
  4621. }
  4622. if (opt && defaults[`__skip_${key}`]) {
  4623. opt.skipFactory = true;
  4624. }
  4625. }
  4626. return props;
  4627. }
  4628. function mergeModels(a, b) {
  4629. if (!a || !b)
  4630. return a || b;
  4631. if (isArray(a) && isArray(b))
  4632. return a.concat(b);
  4633. return extend({}, normalizePropsOrEmits(a), normalizePropsOrEmits(b));
  4634. }
  4635. function createPropsRestProxy(props, excludedKeys) {
  4636. const ret = {};
  4637. for (const key in props) {
  4638. if (!excludedKeys.includes(key)) {
  4639. Object.defineProperty(ret, key, {
  4640. enumerable: true,
  4641. get: () => props[key]
  4642. });
  4643. }
  4644. }
  4645. return ret;
  4646. }
  4647. function withAsyncContext(getAwaitable) {
  4648. const ctx = getCurrentInstance();
  4649. if (!ctx) {
  4650. warn(
  4651. `withAsyncContext called without active current instance. This is likely a bug.`
  4652. );
  4653. }
  4654. let awaitable = getAwaitable();
  4655. unsetCurrentInstance();
  4656. if (isPromise(awaitable)) {
  4657. awaitable = awaitable.catch((e) => {
  4658. setCurrentInstance(ctx);
  4659. throw e;
  4660. });
  4661. }
  4662. return [awaitable, () => setCurrentInstance(ctx)];
  4663. }
  4664. function createDuplicateChecker() {
  4665. const cache = /* @__PURE__ */ Object.create(null);
  4666. return (type, key) => {
  4667. if (cache[key]) {
  4668. warn(`${type} property "${key}" is already defined in ${cache[key]}.`);
  4669. } else {
  4670. cache[key] = type;
  4671. }
  4672. };
  4673. }
  4674. let shouldCacheAccess = true;
  4675. function applyOptions(instance) {
  4676. const options = resolveMergedOptions(instance);
  4677. const publicThis = instance.proxy;
  4678. const ctx = instance.ctx;
  4679. shouldCacheAccess = false;
  4680. if (options.beforeCreate) {
  4681. callHook$1(options.beforeCreate, instance, "bc");
  4682. }
  4683. const {
  4684. // state
  4685. data: dataOptions,
  4686. computed: computedOptions,
  4687. methods,
  4688. watch: watchOptions,
  4689. provide: provideOptions,
  4690. inject: injectOptions,
  4691. // lifecycle
  4692. created,
  4693. beforeMount,
  4694. mounted,
  4695. beforeUpdate,
  4696. updated,
  4697. activated,
  4698. deactivated,
  4699. beforeDestroy,
  4700. beforeUnmount,
  4701. destroyed,
  4702. unmounted,
  4703. render,
  4704. renderTracked,
  4705. renderTriggered,
  4706. errorCaptured,
  4707. serverPrefetch,
  4708. // public API
  4709. expose,
  4710. inheritAttrs,
  4711. // assets
  4712. components,
  4713. directives,
  4714. filters
  4715. } = options;
  4716. const checkDuplicateProperties = createDuplicateChecker() ;
  4717. {
  4718. const [propsOptions] = instance.propsOptions;
  4719. if (propsOptions) {
  4720. for (const key in propsOptions) {
  4721. checkDuplicateProperties("Props" /* PROPS */, key);
  4722. }
  4723. }
  4724. }
  4725. if (injectOptions) {
  4726. resolveInjections(injectOptions, ctx, checkDuplicateProperties);
  4727. }
  4728. if (methods) {
  4729. for (const key in methods) {
  4730. const methodHandler = methods[key];
  4731. if (isFunction(methodHandler)) {
  4732. {
  4733. Object.defineProperty(ctx, key, {
  4734. value: methodHandler.bind(publicThis),
  4735. configurable: true,
  4736. enumerable: true,
  4737. writable: true
  4738. });
  4739. }
  4740. {
  4741. checkDuplicateProperties("Methods" /* METHODS */, key);
  4742. }
  4743. } else {
  4744. warn(
  4745. `Method "${key}" has type "${typeof methodHandler}" in the component definition. Did you reference the function correctly?`
  4746. );
  4747. }
  4748. }
  4749. }
  4750. if (dataOptions) {
  4751. if (!isFunction(dataOptions)) {
  4752. warn(
  4753. `The data option must be a function. Plain object usage is no longer supported.`
  4754. );
  4755. }
  4756. const data = dataOptions.call(publicThis, publicThis);
  4757. if (isPromise(data)) {
  4758. warn(
  4759. `data() returned a Promise - note data() cannot be async; If you intend to perform data fetching before component renders, use async setup() + <Suspense>.`
  4760. );
  4761. }
  4762. if (!isObject(data)) {
  4763. warn(`data() should return an object.`);
  4764. } else {
  4765. instance.data = reactive(data);
  4766. {
  4767. for (const key in data) {
  4768. checkDuplicateProperties("Data" /* DATA */, key);
  4769. if (!isReservedPrefix(key[0])) {
  4770. Object.defineProperty(ctx, key, {
  4771. configurable: true,
  4772. enumerable: true,
  4773. get: () => data[key],
  4774. set: NOOP
  4775. });
  4776. }
  4777. }
  4778. }
  4779. }
  4780. }
  4781. shouldCacheAccess = true;
  4782. if (computedOptions) {
  4783. for (const key in computedOptions) {
  4784. const opt = computedOptions[key];
  4785. const get = isFunction(opt) ? opt.bind(publicThis, publicThis) : isFunction(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP;
  4786. if (get === NOOP) {
  4787. warn(`Computed property "${key}" has no getter.`);
  4788. }
  4789. const set = !isFunction(opt) && isFunction(opt.set) ? opt.set.bind(publicThis) : () => {
  4790. warn(
  4791. `Write operation failed: computed property "${key}" is readonly.`
  4792. );
  4793. } ;
  4794. const c = computed({
  4795. get,
  4796. set
  4797. });
  4798. Object.defineProperty(ctx, key, {
  4799. enumerable: true,
  4800. configurable: true,
  4801. get: () => c.value,
  4802. set: (v) => c.value = v
  4803. });
  4804. {
  4805. checkDuplicateProperties("Computed" /* COMPUTED */, key);
  4806. }
  4807. }
  4808. }
  4809. if (watchOptions) {
  4810. for (const key in watchOptions) {
  4811. createWatcher(watchOptions[key], ctx, publicThis, key);
  4812. }
  4813. }
  4814. if (provideOptions) {
  4815. const provides = isFunction(provideOptions) ? provideOptions.call(publicThis) : provideOptions;
  4816. Reflect.ownKeys(provides).forEach((key) => {
  4817. provide(key, provides[key]);
  4818. });
  4819. }
  4820. if (created) {
  4821. callHook$1(created, instance, "c");
  4822. }
  4823. function registerLifecycleHook(register, hook) {
  4824. if (isArray(hook)) {
  4825. hook.forEach((_hook) => register(_hook.bind(publicThis)));
  4826. } else if (hook) {
  4827. register(hook.bind(publicThis));
  4828. }
  4829. }
  4830. registerLifecycleHook(onBeforeMount, beforeMount);
  4831. registerLifecycleHook(onMounted, mounted);
  4832. registerLifecycleHook(onBeforeUpdate, beforeUpdate);
  4833. registerLifecycleHook(onUpdated, updated);
  4834. registerLifecycleHook(onActivated, activated);
  4835. registerLifecycleHook(onDeactivated, deactivated);
  4836. registerLifecycleHook(onErrorCaptured, errorCaptured);
  4837. registerLifecycleHook(onRenderTracked, renderTracked);
  4838. registerLifecycleHook(onRenderTriggered, renderTriggered);
  4839. registerLifecycleHook(onBeforeUnmount, beforeUnmount);
  4840. registerLifecycleHook(onUnmounted, unmounted);
  4841. registerLifecycleHook(onServerPrefetch, serverPrefetch);
  4842. if (isArray(expose)) {
  4843. if (expose.length) {
  4844. const exposed = instance.exposed || (instance.exposed = {});
  4845. expose.forEach((key) => {
  4846. Object.defineProperty(exposed, key, {
  4847. get: () => publicThis[key],
  4848. set: (val) => publicThis[key] = val
  4849. });
  4850. });
  4851. } else if (!instance.exposed) {
  4852. instance.exposed = {};
  4853. }
  4854. }
  4855. if (render && instance.render === NOOP) {
  4856. instance.render = render;
  4857. }
  4858. if (inheritAttrs != null) {
  4859. instance.inheritAttrs = inheritAttrs;
  4860. }
  4861. if (components)
  4862. instance.components = components;
  4863. if (directives)
  4864. instance.directives = directives;
  4865. }
  4866. function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP) {
  4867. if (isArray(injectOptions)) {
  4868. injectOptions = normalizeInject(injectOptions);
  4869. }
  4870. for (const key in injectOptions) {
  4871. const opt = injectOptions[key];
  4872. let injected;
  4873. if (isObject(opt)) {
  4874. if ("default" in opt) {
  4875. injected = inject(
  4876. opt.from || key,
  4877. opt.default,
  4878. true
  4879. /* treat default function as factory */
  4880. );
  4881. } else {
  4882. injected = inject(opt.from || key);
  4883. }
  4884. } else {
  4885. injected = inject(opt);
  4886. }
  4887. if (isRef(injected)) {
  4888. Object.defineProperty(ctx, key, {
  4889. enumerable: true,
  4890. configurable: true,
  4891. get: () => injected.value,
  4892. set: (v) => injected.value = v
  4893. });
  4894. } else {
  4895. ctx[key] = injected;
  4896. }
  4897. {
  4898. checkDuplicateProperties("Inject" /* INJECT */, key);
  4899. }
  4900. }
  4901. }
  4902. function callHook$1(hook, instance, type) {
  4903. callWithAsyncErrorHandling(
  4904. isArray(hook) ? hook.map((h) => h.bind(instance.proxy)) : hook.bind(instance.proxy),
  4905. instance,
  4906. type
  4907. );
  4908. }
  4909. function createWatcher(raw, ctx, publicThis, key) {
  4910. const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
  4911. if (isString(raw)) {
  4912. const handler = ctx[raw];
  4913. if (isFunction(handler)) {
  4914. watch(getter, handler);
  4915. } else {
  4916. warn(`Invalid watch handler specified by key "${raw}"`, handler);
  4917. }
  4918. } else if (isFunction(raw)) {
  4919. watch(getter, raw.bind(publicThis));
  4920. } else if (isObject(raw)) {
  4921. if (isArray(raw)) {
  4922. raw.forEach((r) => createWatcher(r, ctx, publicThis, key));
  4923. } else {
  4924. const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
  4925. if (isFunction(handler)) {
  4926. watch(getter, handler, raw);
  4927. } else {
  4928. warn(`Invalid watch handler specified by key "${raw.handler}"`, handler);
  4929. }
  4930. }
  4931. } else {
  4932. warn(`Invalid watch option: "${key}"`, raw);
  4933. }
  4934. }
  4935. function resolveMergedOptions(instance) {
  4936. const base = instance.type;
  4937. const { mixins, extends: extendsOptions } = base;
  4938. const {
  4939. mixins: globalMixins,
  4940. optionsCache: cache,
  4941. config: { optionMergeStrategies }
  4942. } = instance.appContext;
  4943. const cached = cache.get(base);
  4944. let resolved;
  4945. if (cached) {
  4946. resolved = cached;
  4947. } else if (!globalMixins.length && !mixins && !extendsOptions) {
  4948. {
  4949. resolved = base;
  4950. }
  4951. } else {
  4952. resolved = {};
  4953. if (globalMixins.length) {
  4954. globalMixins.forEach(
  4955. (m) => mergeOptions(resolved, m, optionMergeStrategies, true)
  4956. );
  4957. }
  4958. mergeOptions(resolved, base, optionMergeStrategies);
  4959. }
  4960. if (isObject(base)) {
  4961. cache.set(base, resolved);
  4962. }
  4963. return resolved;
  4964. }
  4965. function mergeOptions(to, from, strats, asMixin = false) {
  4966. const { mixins, extends: extendsOptions } = from;
  4967. if (extendsOptions) {
  4968. mergeOptions(to, extendsOptions, strats, true);
  4969. }
  4970. if (mixins) {
  4971. mixins.forEach(
  4972. (m) => mergeOptions(to, m, strats, true)
  4973. );
  4974. }
  4975. for (const key in from) {
  4976. if (asMixin && key === "expose") {
  4977. warn(
  4978. `"expose" option is ignored when declared in mixins or extends. It should only be declared in the base component itself.`
  4979. );
  4980. } else {
  4981. const strat = internalOptionMergeStrats[key] || strats && strats[key];
  4982. to[key] = strat ? strat(to[key], from[key]) : from[key];
  4983. }
  4984. }
  4985. return to;
  4986. }
  4987. const internalOptionMergeStrats = {
  4988. data: mergeDataFn,
  4989. props: mergeEmitsOrPropsOptions,
  4990. emits: mergeEmitsOrPropsOptions,
  4991. // objects
  4992. methods: mergeObjectOptions,
  4993. computed: mergeObjectOptions,
  4994. // lifecycle
  4995. beforeCreate: mergeAsArray$1,
  4996. created: mergeAsArray$1,
  4997. beforeMount: mergeAsArray$1,
  4998. mounted: mergeAsArray$1,
  4999. beforeUpdate: mergeAsArray$1,
  5000. updated: mergeAsArray$1,
  5001. beforeDestroy: mergeAsArray$1,
  5002. beforeUnmount: mergeAsArray$1,
  5003. destroyed: mergeAsArray$1,
  5004. unmounted: mergeAsArray$1,
  5005. activated: mergeAsArray$1,
  5006. deactivated: mergeAsArray$1,
  5007. errorCaptured: mergeAsArray$1,
  5008. serverPrefetch: mergeAsArray$1,
  5009. // assets
  5010. components: mergeObjectOptions,
  5011. directives: mergeObjectOptions,
  5012. // watch
  5013. watch: mergeWatchOptions,
  5014. // provide / inject
  5015. provide: mergeDataFn,
  5016. inject: mergeInject
  5017. };
  5018. function mergeDataFn(to, from) {
  5019. if (!from) {
  5020. return to;
  5021. }
  5022. if (!to) {
  5023. return from;
  5024. }
  5025. return function mergedDataFn() {
  5026. return (extend)(
  5027. isFunction(to) ? to.call(this, this) : to,
  5028. isFunction(from) ? from.call(this, this) : from
  5029. );
  5030. };
  5031. }
  5032. function mergeInject(to, from) {
  5033. return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
  5034. }
  5035. function normalizeInject(raw) {
  5036. if (isArray(raw)) {
  5037. const res = {};
  5038. for (let i = 0; i < raw.length; i++) {
  5039. res[raw[i]] = raw[i];
  5040. }
  5041. return res;
  5042. }
  5043. return raw;
  5044. }
  5045. function mergeAsArray$1(to, from) {
  5046. return to ? [...new Set([].concat(to, from))] : from;
  5047. }
  5048. function mergeObjectOptions(to, from) {
  5049. return to ? extend(/* @__PURE__ */ Object.create(null), to, from) : from;
  5050. }
  5051. function mergeEmitsOrPropsOptions(to, from) {
  5052. if (to) {
  5053. if (isArray(to) && isArray(from)) {
  5054. return [.../* @__PURE__ */ new Set([...to, ...from])];
  5055. }
  5056. return extend(
  5057. /* @__PURE__ */ Object.create(null),
  5058. normalizePropsOrEmits(to),
  5059. normalizePropsOrEmits(from != null ? from : {})
  5060. );
  5061. } else {
  5062. return from;
  5063. }
  5064. }
  5065. function mergeWatchOptions(to, from) {
  5066. if (!to)
  5067. return from;
  5068. if (!from)
  5069. return to;
  5070. const merged = extend(/* @__PURE__ */ Object.create(null), to);
  5071. for (const key in from) {
  5072. merged[key] = mergeAsArray$1(to[key], from[key]);
  5073. }
  5074. return merged;
  5075. }
  5076. function createAppContext() {
  5077. return {
  5078. app: null,
  5079. config: {
  5080. isNativeTag: NO,
  5081. performance: false,
  5082. globalProperties: {},
  5083. optionMergeStrategies: {},
  5084. errorHandler: void 0,
  5085. warnHandler: void 0,
  5086. compilerOptions: {}
  5087. },
  5088. mixins: [],
  5089. components: {},
  5090. directives: {},
  5091. provides: /* @__PURE__ */ Object.create(null),
  5092. optionsCache: /* @__PURE__ */ new WeakMap(),
  5093. propsCache: /* @__PURE__ */ new WeakMap(),
  5094. emitsCache: /* @__PURE__ */ new WeakMap()
  5095. };
  5096. }
  5097. let uid$1 = 0;
  5098. function createAppAPI(render, hydrate) {
  5099. return function createApp(rootComponent, rootProps = null) {
  5100. if (!isFunction(rootComponent)) {
  5101. rootComponent = extend({}, rootComponent);
  5102. }
  5103. if (rootProps != null && !isObject(rootProps)) {
  5104. warn(`root props passed to app.mount() must be an object.`);
  5105. rootProps = null;
  5106. }
  5107. const context = createAppContext();
  5108. {
  5109. Object.defineProperty(context.config, "unwrapInjectedRef", {
  5110. get() {
  5111. return true;
  5112. },
  5113. set() {
  5114. warn(
  5115. `app.config.unwrapInjectedRef has been deprecated. 3.3 now alawys unwraps injected refs in Options API.`
  5116. );
  5117. }
  5118. });
  5119. }
  5120. const installedPlugins = /* @__PURE__ */ new Set();
  5121. let isMounted = false;
  5122. const app = context.app = {
  5123. _uid: uid$1++,
  5124. _component: rootComponent,
  5125. _props: rootProps,
  5126. _container: null,
  5127. _context: context,
  5128. _instance: null,
  5129. version,
  5130. get config() {
  5131. return context.config;
  5132. },
  5133. set config(v) {
  5134. {
  5135. warn(
  5136. `app.config cannot be replaced. Modify individual options instead.`
  5137. );
  5138. }
  5139. },
  5140. use(plugin, ...options) {
  5141. if (installedPlugins.has(plugin)) {
  5142. warn(`Plugin has already been applied to target app.`);
  5143. } else if (plugin && isFunction(plugin.install)) {
  5144. installedPlugins.add(plugin);
  5145. plugin.install(app, ...options);
  5146. } else if (isFunction(plugin)) {
  5147. installedPlugins.add(plugin);
  5148. plugin(app, ...options);
  5149. } else {
  5150. warn(
  5151. `A plugin must either be a function or an object with an "install" function.`
  5152. );
  5153. }
  5154. return app;
  5155. },
  5156. mixin(mixin) {
  5157. {
  5158. if (!context.mixins.includes(mixin)) {
  5159. context.mixins.push(mixin);
  5160. } else {
  5161. warn(
  5162. "Mixin has already been applied to target app" + (mixin.name ? `: ${mixin.name}` : "")
  5163. );
  5164. }
  5165. }
  5166. return app;
  5167. },
  5168. component(name, component) {
  5169. {
  5170. validateComponentName(name, context.config);
  5171. }
  5172. if (!component) {
  5173. return context.components[name];
  5174. }
  5175. if (context.components[name]) {
  5176. warn(`Component "${name}" has already been registered in target app.`);
  5177. }
  5178. context.components[name] = component;
  5179. return app;
  5180. },
  5181. directive(name, directive) {
  5182. {
  5183. validateDirectiveName(name);
  5184. }
  5185. if (!directive) {
  5186. return context.directives[name];
  5187. }
  5188. if (context.directives[name]) {
  5189. warn(`Directive "${name}" has already been registered in target app.`);
  5190. }
  5191. context.directives[name] = directive;
  5192. return app;
  5193. },
  5194. mount(rootContainer, isHydrate, isSVG) {
  5195. if (!isMounted) {
  5196. if (rootContainer.__vue_app__) {
  5197. warn(
  5198. `There is already an app instance mounted on the host container.
  5199. If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
  5200. );
  5201. }
  5202. const vnode = createVNode(
  5203. rootComponent,
  5204. rootProps
  5205. );
  5206. vnode.appContext = context;
  5207. {
  5208. context.reload = () => {
  5209. render(cloneVNode(vnode), rootContainer, isSVG);
  5210. };
  5211. }
  5212. if (isHydrate && hydrate) {
  5213. hydrate(vnode, rootContainer);
  5214. } else {
  5215. render(vnode, rootContainer, isSVG);
  5216. }
  5217. isMounted = true;
  5218. app._container = rootContainer;
  5219. rootContainer.__vue_app__ = app;
  5220. {
  5221. app._instance = vnode.component;
  5222. devtoolsInitApp(app, version);
  5223. }
  5224. return getExposeProxy(vnode.component) || vnode.component.proxy;
  5225. } else {
  5226. warn(
  5227. `App has already been mounted.
  5228. If you want to remount the same app, move your app creation logic into a factory function and create fresh app instances for each mount - e.g. \`const createMyApp = () => createApp(App)\``
  5229. );
  5230. }
  5231. },
  5232. unmount() {
  5233. if (isMounted) {
  5234. render(null, app._container);
  5235. {
  5236. app._instance = null;
  5237. devtoolsUnmountApp(app);
  5238. }
  5239. delete app._container.__vue_app__;
  5240. } else {
  5241. warn(`Cannot unmount an app that is not mounted.`);
  5242. }
  5243. },
  5244. provide(key, value) {
  5245. if (key in context.provides) {
  5246. warn(
  5247. `App already provides property with key "${String(key)}". It will be overwritten with the new value.`
  5248. );
  5249. }
  5250. context.provides[key] = value;
  5251. return app;
  5252. },
  5253. runWithContext(fn) {
  5254. currentApp = app;
  5255. try {
  5256. return fn();
  5257. } finally {
  5258. currentApp = null;
  5259. }
  5260. }
  5261. };
  5262. return app;
  5263. };
  5264. }
  5265. let currentApp = null;
  5266. function provide(key, value) {
  5267. if (!currentInstance) {
  5268. {
  5269. warn(`provide() can only be used inside setup().`);
  5270. }
  5271. } else {
  5272. let provides = currentInstance.provides;
  5273. const parentProvides = currentInstance.parent && currentInstance.parent.provides;
  5274. if (parentProvides === provides) {
  5275. provides = currentInstance.provides = Object.create(parentProvides);
  5276. }
  5277. provides[key] = value;
  5278. }
  5279. }
  5280. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  5281. const instance = currentInstance || currentRenderingInstance;
  5282. if (instance || currentApp) {
  5283. const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides;
  5284. if (provides && key in provides) {
  5285. return provides[key];
  5286. } else if (arguments.length > 1) {
  5287. return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
  5288. } else {
  5289. warn(`injection "${String(key)}" not found.`);
  5290. }
  5291. } else {
  5292. warn(`inject() can only be used inside setup() or functional components.`);
  5293. }
  5294. }
  5295. function hasInjectionContext() {
  5296. return !!(currentInstance || currentRenderingInstance || currentApp);
  5297. }
  5298. function initProps(instance, rawProps, isStateful, isSSR = false) {
  5299. const props = {};
  5300. const attrs = {};
  5301. def(attrs, InternalObjectKey, 1);
  5302. instance.propsDefaults = /* @__PURE__ */ Object.create(null);
  5303. setFullProps(instance, rawProps, props, attrs);
  5304. for (const key in instance.propsOptions[0]) {
  5305. if (!(key in props)) {
  5306. props[key] = void 0;
  5307. }
  5308. }
  5309. {
  5310. validateProps(rawProps || {}, props, instance);
  5311. }
  5312. if (isStateful) {
  5313. instance.props = isSSR ? props : shallowReactive(props);
  5314. } else {
  5315. if (!instance.type.props) {
  5316. instance.props = attrs;
  5317. } else {
  5318. instance.props = props;
  5319. }
  5320. }
  5321. instance.attrs = attrs;
  5322. }
  5323. function isInHmrContext(instance) {
  5324. while (instance) {
  5325. if (instance.type.__hmrId)
  5326. return true;
  5327. instance = instance.parent;
  5328. }
  5329. }
  5330. function updateProps(instance, rawProps, rawPrevProps, optimized) {
  5331. const {
  5332. props,
  5333. attrs,
  5334. vnode: { patchFlag }
  5335. } = instance;
  5336. const rawCurrentProps = toRaw(props);
  5337. const [options] = instance.propsOptions;
  5338. let hasAttrsChanged = false;
  5339. if (
  5340. // always force full diff in dev
  5341. // - #1942 if hmr is enabled with sfc component
  5342. // - vite#872 non-sfc component used by sfc component
  5343. !isInHmrContext(instance) && (optimized || patchFlag > 0) && !(patchFlag & 16)
  5344. ) {
  5345. if (patchFlag & 8) {
  5346. const propsToUpdate = instance.vnode.dynamicProps;
  5347. for (let i = 0; i < propsToUpdate.length; i++) {
  5348. let key = propsToUpdate[i];
  5349. if (isEmitListener(instance.emitsOptions, key)) {
  5350. continue;
  5351. }
  5352. const value = rawProps[key];
  5353. if (options) {
  5354. if (hasOwn(attrs, key)) {
  5355. if (value !== attrs[key]) {
  5356. attrs[key] = value;
  5357. hasAttrsChanged = true;
  5358. }
  5359. } else {
  5360. const camelizedKey = camelize(key);
  5361. props[camelizedKey] = resolvePropValue(
  5362. options,
  5363. rawCurrentProps,
  5364. camelizedKey,
  5365. value,
  5366. instance,
  5367. false
  5368. /* isAbsent */
  5369. );
  5370. }
  5371. } else {
  5372. if (value !== attrs[key]) {
  5373. attrs[key] = value;
  5374. hasAttrsChanged = true;
  5375. }
  5376. }
  5377. }
  5378. }
  5379. } else {
  5380. if (setFullProps(instance, rawProps, props, attrs)) {
  5381. hasAttrsChanged = true;
  5382. }
  5383. let kebabKey;
  5384. for (const key in rawCurrentProps) {
  5385. if (!rawProps || // for camelCase
  5386. !hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
  5387. // and converted to camelCase (#955)
  5388. ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
  5389. if (options) {
  5390. if (rawPrevProps && // for camelCase
  5391. (rawPrevProps[key] !== void 0 || // for kebab-case
  5392. rawPrevProps[kebabKey] !== void 0)) {
  5393. props[key] = resolvePropValue(
  5394. options,
  5395. rawCurrentProps,
  5396. key,
  5397. void 0,
  5398. instance,
  5399. true
  5400. /* isAbsent */
  5401. );
  5402. }
  5403. } else {
  5404. delete props[key];
  5405. }
  5406. }
  5407. }
  5408. if (attrs !== rawCurrentProps) {
  5409. for (const key in attrs) {
  5410. if (!rawProps || !hasOwn(rawProps, key) && true) {
  5411. delete attrs[key];
  5412. hasAttrsChanged = true;
  5413. }
  5414. }
  5415. }
  5416. }
  5417. if (hasAttrsChanged) {
  5418. trigger(instance, "set", "$attrs");
  5419. }
  5420. {
  5421. validateProps(rawProps || {}, props, instance);
  5422. }
  5423. }
  5424. function setFullProps(instance, rawProps, props, attrs) {
  5425. const [options, needCastKeys] = instance.propsOptions;
  5426. let hasAttrsChanged = false;
  5427. let rawCastValues;
  5428. if (rawProps) {
  5429. for (let key in rawProps) {
  5430. if (isReservedProp(key)) {
  5431. continue;
  5432. }
  5433. const value = rawProps[key];
  5434. let camelKey;
  5435. if (options && hasOwn(options, camelKey = camelize(key))) {
  5436. if (!needCastKeys || !needCastKeys.includes(camelKey)) {
  5437. props[camelKey] = value;
  5438. } else {
  5439. (rawCastValues || (rawCastValues = {}))[camelKey] = value;
  5440. }
  5441. } else if (!isEmitListener(instance.emitsOptions, key)) {
  5442. if (!(key in attrs) || value !== attrs[key]) {
  5443. attrs[key] = value;
  5444. hasAttrsChanged = true;
  5445. }
  5446. }
  5447. }
  5448. }
  5449. if (needCastKeys) {
  5450. const rawCurrentProps = toRaw(props);
  5451. const castValues = rawCastValues || EMPTY_OBJ;
  5452. for (let i = 0; i < needCastKeys.length; i++) {
  5453. const key = needCastKeys[i];
  5454. props[key] = resolvePropValue(
  5455. options,
  5456. rawCurrentProps,
  5457. key,
  5458. castValues[key],
  5459. instance,
  5460. !hasOwn(castValues, key)
  5461. );
  5462. }
  5463. }
  5464. return hasAttrsChanged;
  5465. }
  5466. function resolvePropValue(options, props, key, value, instance, isAbsent) {
  5467. const opt = options[key];
  5468. if (opt != null) {
  5469. const hasDefault = hasOwn(opt, "default");
  5470. if (hasDefault && value === void 0) {
  5471. const defaultValue = opt.default;
  5472. if (opt.type !== Function && !opt.skipFactory && isFunction(defaultValue)) {
  5473. const { propsDefaults } = instance;
  5474. if (key in propsDefaults) {
  5475. value = propsDefaults[key];
  5476. } else {
  5477. setCurrentInstance(instance);
  5478. value = propsDefaults[key] = defaultValue.call(
  5479. null,
  5480. props
  5481. );
  5482. unsetCurrentInstance();
  5483. }
  5484. } else {
  5485. value = defaultValue;
  5486. }
  5487. }
  5488. if (opt[0 /* shouldCast */]) {
  5489. if (isAbsent && !hasDefault) {
  5490. value = false;
  5491. } else if (opt[1 /* shouldCastTrue */] && (value === "" || value === hyphenate(key))) {
  5492. value = true;
  5493. }
  5494. }
  5495. }
  5496. return value;
  5497. }
  5498. function normalizePropsOptions(comp, appContext, asMixin = false) {
  5499. const cache = appContext.propsCache;
  5500. const cached = cache.get(comp);
  5501. if (cached) {
  5502. return cached;
  5503. }
  5504. const raw = comp.props;
  5505. const normalized = {};
  5506. const needCastKeys = [];
  5507. let hasExtends = false;
  5508. if (!isFunction(comp)) {
  5509. const extendProps = (raw2) => {
  5510. hasExtends = true;
  5511. const [props, keys] = normalizePropsOptions(raw2, appContext, true);
  5512. extend(normalized, props);
  5513. if (keys)
  5514. needCastKeys.push(...keys);
  5515. };
  5516. if (!asMixin && appContext.mixins.length) {
  5517. appContext.mixins.forEach(extendProps);
  5518. }
  5519. if (comp.extends) {
  5520. extendProps(comp.extends);
  5521. }
  5522. if (comp.mixins) {
  5523. comp.mixins.forEach(extendProps);
  5524. }
  5525. }
  5526. if (!raw && !hasExtends) {
  5527. if (isObject(comp)) {
  5528. cache.set(comp, EMPTY_ARR);
  5529. }
  5530. return EMPTY_ARR;
  5531. }
  5532. if (isArray(raw)) {
  5533. for (let i = 0; i < raw.length; i++) {
  5534. if (!isString(raw[i])) {
  5535. warn(`props must be strings when using array syntax.`, raw[i]);
  5536. }
  5537. const normalizedKey = camelize(raw[i]);
  5538. if (validatePropName(normalizedKey)) {
  5539. normalized[normalizedKey] = EMPTY_OBJ;
  5540. }
  5541. }
  5542. } else if (raw) {
  5543. if (!isObject(raw)) {
  5544. warn(`invalid props options`, raw);
  5545. }
  5546. for (const key in raw) {
  5547. const normalizedKey = camelize(key);
  5548. if (validatePropName(normalizedKey)) {
  5549. const opt = raw[key];
  5550. const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : extend({}, opt);
  5551. if (prop) {
  5552. const booleanIndex = getTypeIndex(Boolean, prop.type);
  5553. const stringIndex = getTypeIndex(String, prop.type);
  5554. prop[0 /* shouldCast */] = booleanIndex > -1;
  5555. prop[1 /* shouldCastTrue */] = stringIndex < 0 || booleanIndex < stringIndex;
  5556. if (booleanIndex > -1 || hasOwn(prop, "default")) {
  5557. needCastKeys.push(normalizedKey);
  5558. }
  5559. }
  5560. }
  5561. }
  5562. }
  5563. const res = [normalized, needCastKeys];
  5564. if (isObject(comp)) {
  5565. cache.set(comp, res);
  5566. }
  5567. return res;
  5568. }
  5569. function validatePropName(key) {
  5570. if (key[0] !== "$") {
  5571. return true;
  5572. } else {
  5573. warn(`Invalid prop name: "${key}" is a reserved property.`);
  5574. }
  5575. return false;
  5576. }
  5577. function getType(ctor) {
  5578. const match = ctor && ctor.toString().match(/^\s*(function|class) (\w+)/);
  5579. return match ? match[2] : ctor === null ? "null" : "";
  5580. }
  5581. function isSameType(a, b) {
  5582. return getType(a) === getType(b);
  5583. }
  5584. function getTypeIndex(type, expectedTypes) {
  5585. if (isArray(expectedTypes)) {
  5586. return expectedTypes.findIndex((t) => isSameType(t, type));
  5587. } else if (isFunction(expectedTypes)) {
  5588. return isSameType(expectedTypes, type) ? 0 : -1;
  5589. }
  5590. return -1;
  5591. }
  5592. function validateProps(rawProps, props, instance) {
  5593. const resolvedValues = toRaw(props);
  5594. const options = instance.propsOptions[0];
  5595. for (const key in options) {
  5596. let opt = options[key];
  5597. if (opt == null)
  5598. continue;
  5599. validateProp(
  5600. key,
  5601. resolvedValues[key],
  5602. opt,
  5603. !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key))
  5604. );
  5605. }
  5606. }
  5607. function validateProp(name, value, prop, isAbsent) {
  5608. const { type, required, validator, skipCheck } = prop;
  5609. if (required && isAbsent) {
  5610. warn('Missing required prop: "' + name + '"');
  5611. return;
  5612. }
  5613. if (value == null && !required) {
  5614. return;
  5615. }
  5616. if (type != null && type !== true && !skipCheck) {
  5617. let isValid = false;
  5618. const types = isArray(type) ? type : [type];
  5619. const expectedTypes = [];
  5620. for (let i = 0; i < types.length && !isValid; i++) {
  5621. const { valid, expectedType } = assertType(value, types[i]);
  5622. expectedTypes.push(expectedType || "");
  5623. isValid = valid;
  5624. }
  5625. if (!isValid) {
  5626. warn(getInvalidTypeMessage(name, value, expectedTypes));
  5627. return;
  5628. }
  5629. }
  5630. if (validator && !validator(value)) {
  5631. warn('Invalid prop: custom validator check failed for prop "' + name + '".');
  5632. }
  5633. }
  5634. const isSimpleType = /* @__PURE__ */ makeMap(
  5635. "String,Number,Boolean,Function,Symbol,BigInt"
  5636. );
  5637. function assertType(value, type) {
  5638. let valid;
  5639. const expectedType = getType(type);
  5640. if (isSimpleType(expectedType)) {
  5641. const t = typeof value;
  5642. valid = t === expectedType.toLowerCase();
  5643. if (!valid && t === "object") {
  5644. valid = value instanceof type;
  5645. }
  5646. } else if (expectedType === "Object") {
  5647. valid = isObject(value);
  5648. } else if (expectedType === "Array") {
  5649. valid = isArray(value);
  5650. } else if (expectedType === "null") {
  5651. valid = value === null;
  5652. } else {
  5653. valid = value instanceof type;
  5654. }
  5655. return {
  5656. valid,
  5657. expectedType
  5658. };
  5659. }
  5660. function getInvalidTypeMessage(name, value, expectedTypes) {
  5661. let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
  5662. const expectedType = expectedTypes[0];
  5663. const receivedType = toRawType(value);
  5664. const expectedValue = styleValue(value, expectedType);
  5665. const receivedValue = styleValue(value, receivedType);
  5666. if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
  5667. message += ` with value ${expectedValue}`;
  5668. }
  5669. message += `, got ${receivedType} `;
  5670. if (isExplicable(receivedType)) {
  5671. message += `with value ${receivedValue}.`;
  5672. }
  5673. return message;
  5674. }
  5675. function styleValue(value, type) {
  5676. if (type === "String") {
  5677. return `"${value}"`;
  5678. } else if (type === "Number") {
  5679. return `${Number(value)}`;
  5680. } else {
  5681. return `${value}`;
  5682. }
  5683. }
  5684. function isExplicable(type) {
  5685. const explicitTypes = ["string", "number", "boolean"];
  5686. return explicitTypes.some((elem) => type.toLowerCase() === elem);
  5687. }
  5688. function isBoolean(...args) {
  5689. return args.some((elem) => elem.toLowerCase() === "boolean");
  5690. }
  5691. const isInternalKey = (key) => key[0] === "_" || key === "$stable";
  5692. const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
  5693. const normalizeSlot = (key, rawSlot, ctx) => {
  5694. if (rawSlot._n) {
  5695. return rawSlot;
  5696. }
  5697. const normalized = withCtx((...args) => {
  5698. if (currentInstance) {
  5699. warn(
  5700. `Slot "${key}" invoked outside of the render function: this will not track dependencies used in the slot. Invoke the slot function inside the render function instead.`
  5701. );
  5702. }
  5703. return normalizeSlotValue(rawSlot(...args));
  5704. }, ctx);
  5705. normalized._c = false;
  5706. return normalized;
  5707. };
  5708. const normalizeObjectSlots = (rawSlots, slots, instance) => {
  5709. const ctx = rawSlots._ctx;
  5710. for (const key in rawSlots) {
  5711. if (isInternalKey(key))
  5712. continue;
  5713. const value = rawSlots[key];
  5714. if (isFunction(value)) {
  5715. slots[key] = normalizeSlot(key, value, ctx);
  5716. } else if (value != null) {
  5717. {
  5718. warn(
  5719. `Non-function value encountered for slot "${key}". Prefer function slots for better performance.`
  5720. );
  5721. }
  5722. const normalized = normalizeSlotValue(value);
  5723. slots[key] = () => normalized;
  5724. }
  5725. }
  5726. };
  5727. const normalizeVNodeSlots = (instance, children) => {
  5728. if (!isKeepAlive(instance.vnode) && true) {
  5729. warn(
  5730. `Non-function value encountered for default slot. Prefer function slots for better performance.`
  5731. );
  5732. }
  5733. const normalized = normalizeSlotValue(children);
  5734. instance.slots.default = () => normalized;
  5735. };
  5736. const initSlots = (instance, children) => {
  5737. if (instance.vnode.shapeFlag & 32) {
  5738. const type = children._;
  5739. if (type) {
  5740. instance.slots = toRaw(children);
  5741. def(children, "_", type);
  5742. } else {
  5743. normalizeObjectSlots(
  5744. children,
  5745. instance.slots = {});
  5746. }
  5747. } else {
  5748. instance.slots = {};
  5749. if (children) {
  5750. normalizeVNodeSlots(instance, children);
  5751. }
  5752. }
  5753. def(instance.slots, InternalObjectKey, 1);
  5754. };
  5755. const updateSlots = (instance, children, optimized) => {
  5756. const { vnode, slots } = instance;
  5757. let needDeletionCheck = true;
  5758. let deletionComparisonTarget = EMPTY_OBJ;
  5759. if (vnode.shapeFlag & 32) {
  5760. const type = children._;
  5761. if (type) {
  5762. if (isHmrUpdating) {
  5763. extend(slots, children);
  5764. trigger(instance, "set", "$slots");
  5765. } else if (optimized && type === 1) {
  5766. needDeletionCheck = false;
  5767. } else {
  5768. extend(slots, children);
  5769. if (!optimized && type === 1) {
  5770. delete slots._;
  5771. }
  5772. }
  5773. } else {
  5774. needDeletionCheck = !children.$stable;
  5775. normalizeObjectSlots(children, slots);
  5776. }
  5777. deletionComparisonTarget = children;
  5778. } else if (children) {
  5779. normalizeVNodeSlots(instance, children);
  5780. deletionComparisonTarget = { default: 1 };
  5781. }
  5782. if (needDeletionCheck) {
  5783. for (const key in slots) {
  5784. if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
  5785. delete slots[key];
  5786. }
  5787. }
  5788. }
  5789. };
  5790. function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
  5791. if (isArray(rawRef)) {
  5792. rawRef.forEach(
  5793. (r, i) => setRef(
  5794. r,
  5795. oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef),
  5796. parentSuspense,
  5797. vnode,
  5798. isUnmount
  5799. )
  5800. );
  5801. return;
  5802. }
  5803. if (isAsyncWrapper(vnode) && !isUnmount) {
  5804. return;
  5805. }
  5806. const refValue = vnode.shapeFlag & 4 ? getExposeProxy(vnode.component) || vnode.component.proxy : vnode.el;
  5807. const value = isUnmount ? null : refValue;
  5808. const { i: owner, r: ref } = rawRef;
  5809. if (!owner) {
  5810. warn(
  5811. `Missing ref owner context. ref cannot be used on hoisted vnodes. A vnode with ref must be created inside the render function.`
  5812. );
  5813. return;
  5814. }
  5815. const oldRef = oldRawRef && oldRawRef.r;
  5816. const refs = owner.refs === EMPTY_OBJ ? owner.refs = {} : owner.refs;
  5817. const setupState = owner.setupState;
  5818. if (oldRef != null && oldRef !== ref) {
  5819. if (isString(oldRef)) {
  5820. refs[oldRef] = null;
  5821. if (hasOwn(setupState, oldRef)) {
  5822. setupState[oldRef] = null;
  5823. }
  5824. } else if (isRef(oldRef)) {
  5825. oldRef.value = null;
  5826. }
  5827. }
  5828. if (isFunction(ref)) {
  5829. callWithErrorHandling(ref, owner, 12, [value, refs]);
  5830. } else {
  5831. const _isString = isString(ref);
  5832. const _isRef = isRef(ref);
  5833. if (_isString || _isRef) {
  5834. const doSet = () => {
  5835. if (rawRef.f) {
  5836. const existing = _isString ? hasOwn(setupState, ref) ? setupState[ref] : refs[ref] : ref.value;
  5837. if (isUnmount) {
  5838. isArray(existing) && remove(existing, refValue);
  5839. } else {
  5840. if (!isArray(existing)) {
  5841. if (_isString) {
  5842. refs[ref] = [refValue];
  5843. if (hasOwn(setupState, ref)) {
  5844. setupState[ref] = refs[ref];
  5845. }
  5846. } else {
  5847. ref.value = [refValue];
  5848. if (rawRef.k)
  5849. refs[rawRef.k] = ref.value;
  5850. }
  5851. } else if (!existing.includes(refValue)) {
  5852. existing.push(refValue);
  5853. }
  5854. }
  5855. } else if (_isString) {
  5856. refs[ref] = value;
  5857. if (hasOwn(setupState, ref)) {
  5858. setupState[ref] = value;
  5859. }
  5860. } else if (_isRef) {
  5861. ref.value = value;
  5862. if (rawRef.k)
  5863. refs[rawRef.k] = value;
  5864. } else {
  5865. warn("Invalid template ref type:", ref, `(${typeof ref})`);
  5866. }
  5867. };
  5868. if (value) {
  5869. doSet.id = -1;
  5870. queuePostRenderEffect(doSet, parentSuspense);
  5871. } else {
  5872. doSet();
  5873. }
  5874. } else {
  5875. warn("Invalid template ref type:", ref, `(${typeof ref})`);
  5876. }
  5877. }
  5878. }
  5879. let hasMismatch = false;
  5880. const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== "foreignObject";
  5881. const isComment = (node) => node.nodeType === 8 /* COMMENT */;
  5882. function createHydrationFunctions(rendererInternals) {
  5883. const {
  5884. mt: mountComponent,
  5885. p: patch,
  5886. o: {
  5887. patchProp,
  5888. createText,
  5889. nextSibling,
  5890. parentNode,
  5891. remove,
  5892. insert,
  5893. createComment
  5894. }
  5895. } = rendererInternals;
  5896. const hydrate = (vnode, container) => {
  5897. if (!container.hasChildNodes()) {
  5898. warn(
  5899. `Attempting to hydrate existing markup but container is empty. Performing full mount instead.`
  5900. );
  5901. patch(null, vnode, container);
  5902. flushPostFlushCbs();
  5903. container._vnode = vnode;
  5904. return;
  5905. }
  5906. hasMismatch = false;
  5907. hydrateNode(container.firstChild, vnode, null, null, null);
  5908. flushPostFlushCbs();
  5909. container._vnode = vnode;
  5910. if (hasMismatch && true) {
  5911. console.error(`Hydration completed but contains mismatches.`);
  5912. }
  5913. };
  5914. const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
  5915. const isFragmentStart = isComment(node) && node.data === "[";
  5916. const onMismatch = () => handleMismatch(
  5917. node,
  5918. vnode,
  5919. parentComponent,
  5920. parentSuspense,
  5921. slotScopeIds,
  5922. isFragmentStart
  5923. );
  5924. const { type, ref, shapeFlag, patchFlag } = vnode;
  5925. let domType = node.nodeType;
  5926. vnode.el = node;
  5927. if (patchFlag === -2) {
  5928. optimized = false;
  5929. vnode.dynamicChildren = null;
  5930. }
  5931. let nextNode = null;
  5932. switch (type) {
  5933. case Text:
  5934. if (domType !== 3 /* TEXT */) {
  5935. if (vnode.children === "") {
  5936. insert(vnode.el = createText(""), parentNode(node), node);
  5937. nextNode = node;
  5938. } else {
  5939. nextNode = onMismatch();
  5940. }
  5941. } else {
  5942. if (node.data !== vnode.children) {
  5943. hasMismatch = true;
  5944. warn(
  5945. `Hydration text mismatch:
  5946. - Client: ${JSON.stringify(node.data)}
  5947. - Server: ${JSON.stringify(vnode.children)}`
  5948. );
  5949. node.data = vnode.children;
  5950. }
  5951. nextNode = nextSibling(node);
  5952. }
  5953. break;
  5954. case Comment:
  5955. if (domType !== 8 /* COMMENT */ || isFragmentStart) {
  5956. nextNode = onMismatch();
  5957. } else {
  5958. nextNode = nextSibling(node);
  5959. }
  5960. break;
  5961. case Static:
  5962. if (isFragmentStart) {
  5963. node = nextSibling(node);
  5964. domType = node.nodeType;
  5965. }
  5966. if (domType === 1 /* ELEMENT */ || domType === 3 /* TEXT */) {
  5967. nextNode = node;
  5968. const needToAdoptContent = !vnode.children.length;
  5969. for (let i = 0; i < vnode.staticCount; i++) {
  5970. if (needToAdoptContent)
  5971. vnode.children += nextNode.nodeType === 1 /* ELEMENT */ ? nextNode.outerHTML : nextNode.data;
  5972. if (i === vnode.staticCount - 1) {
  5973. vnode.anchor = nextNode;
  5974. }
  5975. nextNode = nextSibling(nextNode);
  5976. }
  5977. return isFragmentStart ? nextSibling(nextNode) : nextNode;
  5978. } else {
  5979. onMismatch();
  5980. }
  5981. break;
  5982. case Fragment:
  5983. if (!isFragmentStart) {
  5984. nextNode = onMismatch();
  5985. } else {
  5986. nextNode = hydrateFragment(
  5987. node,
  5988. vnode,
  5989. parentComponent,
  5990. parentSuspense,
  5991. slotScopeIds,
  5992. optimized
  5993. );
  5994. }
  5995. break;
  5996. default:
  5997. if (shapeFlag & 1) {
  5998. if (domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) {
  5999. nextNode = onMismatch();
  6000. } else {
  6001. nextNode = hydrateElement(
  6002. node,
  6003. vnode,
  6004. parentComponent,
  6005. parentSuspense,
  6006. slotScopeIds,
  6007. optimized
  6008. );
  6009. }
  6010. } else if (shapeFlag & 6) {
  6011. vnode.slotScopeIds = slotScopeIds;
  6012. const container = parentNode(node);
  6013. mountComponent(
  6014. vnode,
  6015. container,
  6016. null,
  6017. parentComponent,
  6018. parentSuspense,
  6019. isSVGContainer(container),
  6020. optimized
  6021. );
  6022. nextNode = isFragmentStart ? locateClosingAsyncAnchor(node) : nextSibling(node);
  6023. if (nextNode && isComment(nextNode) && nextNode.data === "teleport end") {
  6024. nextNode = nextSibling(nextNode);
  6025. }
  6026. if (isAsyncWrapper(vnode)) {
  6027. let subTree;
  6028. if (isFragmentStart) {
  6029. subTree = createVNode(Fragment);
  6030. subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
  6031. } else {
  6032. subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
  6033. }
  6034. subTree.el = node;
  6035. vnode.component.subTree = subTree;
  6036. }
  6037. } else if (shapeFlag & 64) {
  6038. if (domType !== 8 /* COMMENT */) {
  6039. nextNode = onMismatch();
  6040. } else {
  6041. nextNode = vnode.type.hydrate(
  6042. node,
  6043. vnode,
  6044. parentComponent,
  6045. parentSuspense,
  6046. slotScopeIds,
  6047. optimized,
  6048. rendererInternals,
  6049. hydrateChildren
  6050. );
  6051. }
  6052. } else if (shapeFlag & 128) {
  6053. nextNode = vnode.type.hydrate(
  6054. node,
  6055. vnode,
  6056. parentComponent,
  6057. parentSuspense,
  6058. isSVGContainer(parentNode(node)),
  6059. slotScopeIds,
  6060. optimized,
  6061. rendererInternals,
  6062. hydrateNode
  6063. );
  6064. } else {
  6065. warn("Invalid HostVNode type:", type, `(${typeof type})`);
  6066. }
  6067. }
  6068. if (ref != null) {
  6069. setRef(ref, null, parentSuspense, vnode);
  6070. }
  6071. return nextNode;
  6072. };
  6073. const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6074. optimized = optimized || !!vnode.dynamicChildren;
  6075. const { type, props, patchFlag, shapeFlag, dirs } = vnode;
  6076. const forcePatchValue = type === "input" && dirs || type === "option";
  6077. {
  6078. if (dirs) {
  6079. invokeDirectiveHook(vnode, null, parentComponent, "created");
  6080. }
  6081. if (props) {
  6082. if (forcePatchValue || !optimized || patchFlag & (16 | 32)) {
  6083. for (const key in props) {
  6084. if (forcePatchValue && key.endsWith("value") || isOn(key) && !isReservedProp(key)) {
  6085. patchProp(
  6086. el,
  6087. key,
  6088. null,
  6089. props[key],
  6090. false,
  6091. void 0,
  6092. parentComponent
  6093. );
  6094. }
  6095. }
  6096. } else if (props.onClick) {
  6097. patchProp(
  6098. el,
  6099. "onClick",
  6100. null,
  6101. props.onClick,
  6102. false,
  6103. void 0,
  6104. parentComponent
  6105. );
  6106. }
  6107. }
  6108. let vnodeHooks;
  6109. if (vnodeHooks = props && props.onVnodeBeforeMount) {
  6110. invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  6111. }
  6112. if (dirs) {
  6113. invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
  6114. }
  6115. if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
  6116. queueEffectWithSuspense(() => {
  6117. vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  6118. dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
  6119. }, parentSuspense);
  6120. }
  6121. if (shapeFlag & 16 && // skip if element has innerHTML / textContent
  6122. !(props && (props.innerHTML || props.textContent))) {
  6123. let next = hydrateChildren(
  6124. el.firstChild,
  6125. vnode,
  6126. el,
  6127. parentComponent,
  6128. parentSuspense,
  6129. slotScopeIds,
  6130. optimized
  6131. );
  6132. let hasWarned = false;
  6133. while (next) {
  6134. hasMismatch = true;
  6135. if (!hasWarned) {
  6136. warn(
  6137. `Hydration children mismatch in <${vnode.type}>: server rendered element contains more child nodes than client vdom.`
  6138. );
  6139. hasWarned = true;
  6140. }
  6141. const cur = next;
  6142. next = next.nextSibling;
  6143. remove(cur);
  6144. }
  6145. } else if (shapeFlag & 8) {
  6146. if (el.textContent !== vnode.children) {
  6147. hasMismatch = true;
  6148. warn(
  6149. `Hydration text content mismatch in <${vnode.type}>:
  6150. - Client: ${el.textContent}
  6151. - Server: ${vnode.children}`
  6152. );
  6153. el.textContent = vnode.children;
  6154. }
  6155. }
  6156. }
  6157. return el.nextSibling;
  6158. };
  6159. const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6160. optimized = optimized || !!parentVNode.dynamicChildren;
  6161. const children = parentVNode.children;
  6162. const l = children.length;
  6163. let hasWarned = false;
  6164. for (let i = 0; i < l; i++) {
  6165. const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]);
  6166. if (node) {
  6167. node = hydrateNode(
  6168. node,
  6169. vnode,
  6170. parentComponent,
  6171. parentSuspense,
  6172. slotScopeIds,
  6173. optimized
  6174. );
  6175. } else if (vnode.type === Text && !vnode.children) {
  6176. continue;
  6177. } else {
  6178. hasMismatch = true;
  6179. if (!hasWarned) {
  6180. warn(
  6181. `Hydration children mismatch in <${container.tagName.toLowerCase()}>: server rendered element contains fewer child nodes than client vdom.`
  6182. );
  6183. hasWarned = true;
  6184. }
  6185. patch(
  6186. null,
  6187. vnode,
  6188. container,
  6189. null,
  6190. parentComponent,
  6191. parentSuspense,
  6192. isSVGContainer(container),
  6193. slotScopeIds
  6194. );
  6195. }
  6196. }
  6197. return node;
  6198. };
  6199. const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6200. const { slotScopeIds: fragmentSlotScopeIds } = vnode;
  6201. if (fragmentSlotScopeIds) {
  6202. slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
  6203. }
  6204. const container = parentNode(node);
  6205. const next = hydrateChildren(
  6206. nextSibling(node),
  6207. vnode,
  6208. container,
  6209. parentComponent,
  6210. parentSuspense,
  6211. slotScopeIds,
  6212. optimized
  6213. );
  6214. if (next && isComment(next) && next.data === "]") {
  6215. return nextSibling(vnode.anchor = next);
  6216. } else {
  6217. hasMismatch = true;
  6218. insert(vnode.anchor = createComment(`]`), container, next);
  6219. return next;
  6220. }
  6221. };
  6222. const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
  6223. hasMismatch = true;
  6224. warn(
  6225. `Hydration node mismatch:
  6226. - Client vnode:`,
  6227. vnode.type,
  6228. `
  6229. - Server rendered DOM:`,
  6230. node,
  6231. node.nodeType === 3 /* TEXT */ ? `(text)` : isComment(node) && node.data === "[" ? `(start of fragment)` : ``
  6232. );
  6233. vnode.el = null;
  6234. if (isFragment) {
  6235. const end = locateClosingAsyncAnchor(node);
  6236. while (true) {
  6237. const next2 = nextSibling(node);
  6238. if (next2 && next2 !== end) {
  6239. remove(next2);
  6240. } else {
  6241. break;
  6242. }
  6243. }
  6244. }
  6245. const next = nextSibling(node);
  6246. const container = parentNode(node);
  6247. remove(node);
  6248. patch(
  6249. null,
  6250. vnode,
  6251. container,
  6252. next,
  6253. parentComponent,
  6254. parentSuspense,
  6255. isSVGContainer(container),
  6256. slotScopeIds
  6257. );
  6258. return next;
  6259. };
  6260. const locateClosingAsyncAnchor = (node) => {
  6261. let match = 0;
  6262. while (node) {
  6263. node = nextSibling(node);
  6264. if (node && isComment(node)) {
  6265. if (node.data === "[")
  6266. match++;
  6267. if (node.data === "]") {
  6268. if (match === 0) {
  6269. return nextSibling(node);
  6270. } else {
  6271. match--;
  6272. }
  6273. }
  6274. }
  6275. }
  6276. return node;
  6277. };
  6278. return [hydrate, hydrateNode];
  6279. }
  6280. let supported;
  6281. let perf;
  6282. function startMeasure(instance, type) {
  6283. if (instance.appContext.config.performance && isSupported()) {
  6284. perf.mark(`vue-${type}-${instance.uid}`);
  6285. }
  6286. {
  6287. devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
  6288. }
  6289. }
  6290. function endMeasure(instance, type) {
  6291. if (instance.appContext.config.performance && isSupported()) {
  6292. const startTag = `vue-${type}-${instance.uid}`;
  6293. const endTag = startTag + `:end`;
  6294. perf.mark(endTag);
  6295. perf.measure(
  6296. `<${formatComponentName(instance, instance.type)}> ${type}`,
  6297. startTag,
  6298. endTag
  6299. );
  6300. perf.clearMarks(startTag);
  6301. perf.clearMarks(endTag);
  6302. }
  6303. {
  6304. devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
  6305. }
  6306. }
  6307. function isSupported() {
  6308. if (supported !== void 0) {
  6309. return supported;
  6310. }
  6311. if (typeof window !== "undefined" && window.performance) {
  6312. supported = true;
  6313. perf = window.performance;
  6314. } else {
  6315. supported = false;
  6316. }
  6317. return supported;
  6318. }
  6319. const queuePostRenderEffect = queueEffectWithSuspense ;
  6320. function createRenderer(options) {
  6321. return baseCreateRenderer(options);
  6322. }
  6323. function createHydrationRenderer(options) {
  6324. return baseCreateRenderer(options, createHydrationFunctions);
  6325. }
  6326. function baseCreateRenderer(options, createHydrationFns) {
  6327. const target = getGlobalThis();
  6328. target.__VUE__ = true;
  6329. {
  6330. setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
  6331. }
  6332. const {
  6333. insert: hostInsert,
  6334. remove: hostRemove,
  6335. patchProp: hostPatchProp,
  6336. createElement: hostCreateElement,
  6337. createText: hostCreateText,
  6338. createComment: hostCreateComment,
  6339. setText: hostSetText,
  6340. setElementText: hostSetElementText,
  6341. parentNode: hostParentNode,
  6342. nextSibling: hostNextSibling,
  6343. setScopeId: hostSetScopeId = NOOP,
  6344. insertStaticContent: hostInsertStaticContent
  6345. } = options;
  6346. const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
  6347. if (n1 === n2) {
  6348. return;
  6349. }
  6350. if (n1 && !isSameVNodeType(n1, n2)) {
  6351. anchor = getNextHostNode(n1);
  6352. unmount(n1, parentComponent, parentSuspense, true);
  6353. n1 = null;
  6354. }
  6355. if (n2.patchFlag === -2) {
  6356. optimized = false;
  6357. n2.dynamicChildren = null;
  6358. }
  6359. const { type, ref, shapeFlag } = n2;
  6360. switch (type) {
  6361. case Text:
  6362. processText(n1, n2, container, anchor);
  6363. break;
  6364. case Comment:
  6365. processCommentNode(n1, n2, container, anchor);
  6366. break;
  6367. case Static:
  6368. if (n1 == null) {
  6369. mountStaticNode(n2, container, anchor, isSVG);
  6370. } else {
  6371. patchStaticNode(n1, n2, container, isSVG);
  6372. }
  6373. break;
  6374. case Fragment:
  6375. processFragment(
  6376. n1,
  6377. n2,
  6378. container,
  6379. anchor,
  6380. parentComponent,
  6381. parentSuspense,
  6382. isSVG,
  6383. slotScopeIds,
  6384. optimized
  6385. );
  6386. break;
  6387. default:
  6388. if (shapeFlag & 1) {
  6389. processElement(
  6390. n1,
  6391. n2,
  6392. container,
  6393. anchor,
  6394. parentComponent,
  6395. parentSuspense,
  6396. isSVG,
  6397. slotScopeIds,
  6398. optimized
  6399. );
  6400. } else if (shapeFlag & 6) {
  6401. processComponent(
  6402. n1,
  6403. n2,
  6404. container,
  6405. anchor,
  6406. parentComponent,
  6407. parentSuspense,
  6408. isSVG,
  6409. slotScopeIds,
  6410. optimized
  6411. );
  6412. } else if (shapeFlag & 64) {
  6413. type.process(
  6414. n1,
  6415. n2,
  6416. container,
  6417. anchor,
  6418. parentComponent,
  6419. parentSuspense,
  6420. isSVG,
  6421. slotScopeIds,
  6422. optimized,
  6423. internals
  6424. );
  6425. } else if (shapeFlag & 128) {
  6426. type.process(
  6427. n1,
  6428. n2,
  6429. container,
  6430. anchor,
  6431. parentComponent,
  6432. parentSuspense,
  6433. isSVG,
  6434. slotScopeIds,
  6435. optimized,
  6436. internals
  6437. );
  6438. } else {
  6439. warn("Invalid VNode type:", type, `(${typeof type})`);
  6440. }
  6441. }
  6442. if (ref != null && parentComponent) {
  6443. setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
  6444. }
  6445. };
  6446. const processText = (n1, n2, container, anchor) => {
  6447. if (n1 == null) {
  6448. hostInsert(
  6449. n2.el = hostCreateText(n2.children),
  6450. container,
  6451. anchor
  6452. );
  6453. } else {
  6454. const el = n2.el = n1.el;
  6455. if (n2.children !== n1.children) {
  6456. hostSetText(el, n2.children);
  6457. }
  6458. }
  6459. };
  6460. const processCommentNode = (n1, n2, container, anchor) => {
  6461. if (n1 == null) {
  6462. hostInsert(
  6463. n2.el = hostCreateComment(n2.children || ""),
  6464. container,
  6465. anchor
  6466. );
  6467. } else {
  6468. n2.el = n1.el;
  6469. }
  6470. };
  6471. const mountStaticNode = (n2, container, anchor, isSVG) => {
  6472. [n2.el, n2.anchor] = hostInsertStaticContent(
  6473. n2.children,
  6474. container,
  6475. anchor,
  6476. isSVG,
  6477. n2.el,
  6478. n2.anchor
  6479. );
  6480. };
  6481. const patchStaticNode = (n1, n2, container, isSVG) => {
  6482. if (n2.children !== n1.children) {
  6483. const anchor = hostNextSibling(n1.anchor);
  6484. removeStaticNode(n1);
  6485. [n2.el, n2.anchor] = hostInsertStaticContent(
  6486. n2.children,
  6487. container,
  6488. anchor,
  6489. isSVG
  6490. );
  6491. } else {
  6492. n2.el = n1.el;
  6493. n2.anchor = n1.anchor;
  6494. }
  6495. };
  6496. const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
  6497. let next;
  6498. while (el && el !== anchor) {
  6499. next = hostNextSibling(el);
  6500. hostInsert(el, container, nextSibling);
  6501. el = next;
  6502. }
  6503. hostInsert(anchor, container, nextSibling);
  6504. };
  6505. const removeStaticNode = ({ el, anchor }) => {
  6506. let next;
  6507. while (el && el !== anchor) {
  6508. next = hostNextSibling(el);
  6509. hostRemove(el);
  6510. el = next;
  6511. }
  6512. hostRemove(anchor);
  6513. };
  6514. const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6515. isSVG = isSVG || n2.type === "svg";
  6516. if (n1 == null) {
  6517. mountElement(
  6518. n2,
  6519. container,
  6520. anchor,
  6521. parentComponent,
  6522. parentSuspense,
  6523. isSVG,
  6524. slotScopeIds,
  6525. optimized
  6526. );
  6527. } else {
  6528. patchElement(
  6529. n1,
  6530. n2,
  6531. parentComponent,
  6532. parentSuspense,
  6533. isSVG,
  6534. slotScopeIds,
  6535. optimized
  6536. );
  6537. }
  6538. };
  6539. const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6540. let el;
  6541. let vnodeHook;
  6542. const { type, props, shapeFlag, transition, dirs } = vnode;
  6543. el = vnode.el = hostCreateElement(
  6544. vnode.type,
  6545. isSVG,
  6546. props && props.is,
  6547. props
  6548. );
  6549. if (shapeFlag & 8) {
  6550. hostSetElementText(el, vnode.children);
  6551. } else if (shapeFlag & 16) {
  6552. mountChildren(
  6553. vnode.children,
  6554. el,
  6555. null,
  6556. parentComponent,
  6557. parentSuspense,
  6558. isSVG && type !== "foreignObject",
  6559. slotScopeIds,
  6560. optimized
  6561. );
  6562. }
  6563. if (dirs) {
  6564. invokeDirectiveHook(vnode, null, parentComponent, "created");
  6565. }
  6566. setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
  6567. if (props) {
  6568. for (const key in props) {
  6569. if (key !== "value" && !isReservedProp(key)) {
  6570. hostPatchProp(
  6571. el,
  6572. key,
  6573. null,
  6574. props[key],
  6575. isSVG,
  6576. vnode.children,
  6577. parentComponent,
  6578. parentSuspense,
  6579. unmountChildren
  6580. );
  6581. }
  6582. }
  6583. if ("value" in props) {
  6584. hostPatchProp(el, "value", null, props.value);
  6585. }
  6586. if (vnodeHook = props.onVnodeBeforeMount) {
  6587. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  6588. }
  6589. }
  6590. {
  6591. Object.defineProperty(el, "__vnode", {
  6592. value: vnode,
  6593. enumerable: false
  6594. });
  6595. Object.defineProperty(el, "__vueParentComponent", {
  6596. value: parentComponent,
  6597. enumerable: false
  6598. });
  6599. }
  6600. if (dirs) {
  6601. invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
  6602. }
  6603. const needCallTransitionHooks = (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
  6604. if (needCallTransitionHooks) {
  6605. transition.beforeEnter(el);
  6606. }
  6607. hostInsert(el, container, anchor);
  6608. if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
  6609. queuePostRenderEffect(() => {
  6610. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  6611. needCallTransitionHooks && transition.enter(el);
  6612. dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
  6613. }, parentSuspense);
  6614. }
  6615. };
  6616. const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
  6617. if (scopeId) {
  6618. hostSetScopeId(el, scopeId);
  6619. }
  6620. if (slotScopeIds) {
  6621. for (let i = 0; i < slotScopeIds.length; i++) {
  6622. hostSetScopeId(el, slotScopeIds[i]);
  6623. }
  6624. }
  6625. if (parentComponent) {
  6626. let subTree = parentComponent.subTree;
  6627. if (subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
  6628. subTree = filterSingleRoot(subTree.children) || subTree;
  6629. }
  6630. if (vnode === subTree) {
  6631. const parentVNode = parentComponent.vnode;
  6632. setScopeId(
  6633. el,
  6634. parentVNode,
  6635. parentVNode.scopeId,
  6636. parentVNode.slotScopeIds,
  6637. parentComponent.parent
  6638. );
  6639. }
  6640. }
  6641. };
  6642. const mountChildren = (children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, start = 0) => {
  6643. for (let i = start; i < children.length; i++) {
  6644. const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]);
  6645. patch(
  6646. null,
  6647. child,
  6648. container,
  6649. anchor,
  6650. parentComponent,
  6651. parentSuspense,
  6652. isSVG,
  6653. slotScopeIds,
  6654. optimized
  6655. );
  6656. }
  6657. };
  6658. const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6659. const el = n2.el = n1.el;
  6660. let { patchFlag, dynamicChildren, dirs } = n2;
  6661. patchFlag |= n1.patchFlag & 16;
  6662. const oldProps = n1.props || EMPTY_OBJ;
  6663. const newProps = n2.props || EMPTY_OBJ;
  6664. let vnodeHook;
  6665. parentComponent && toggleRecurse(parentComponent, false);
  6666. if (vnodeHook = newProps.onVnodeBeforeUpdate) {
  6667. invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  6668. }
  6669. if (dirs) {
  6670. invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
  6671. }
  6672. parentComponent && toggleRecurse(parentComponent, true);
  6673. if (isHmrUpdating) {
  6674. patchFlag = 0;
  6675. optimized = false;
  6676. dynamicChildren = null;
  6677. }
  6678. const areChildrenSVG = isSVG && n2.type !== "foreignObject";
  6679. if (dynamicChildren) {
  6680. patchBlockChildren(
  6681. n1.dynamicChildren,
  6682. dynamicChildren,
  6683. el,
  6684. parentComponent,
  6685. parentSuspense,
  6686. areChildrenSVG,
  6687. slotScopeIds
  6688. );
  6689. {
  6690. traverseStaticChildren(n1, n2);
  6691. }
  6692. } else if (!optimized) {
  6693. patchChildren(
  6694. n1,
  6695. n2,
  6696. el,
  6697. null,
  6698. parentComponent,
  6699. parentSuspense,
  6700. areChildrenSVG,
  6701. slotScopeIds,
  6702. false
  6703. );
  6704. }
  6705. if (patchFlag > 0) {
  6706. if (patchFlag & 16) {
  6707. patchProps(
  6708. el,
  6709. n2,
  6710. oldProps,
  6711. newProps,
  6712. parentComponent,
  6713. parentSuspense,
  6714. isSVG
  6715. );
  6716. } else {
  6717. if (patchFlag & 2) {
  6718. if (oldProps.class !== newProps.class) {
  6719. hostPatchProp(el, "class", null, newProps.class, isSVG);
  6720. }
  6721. }
  6722. if (patchFlag & 4) {
  6723. hostPatchProp(el, "style", oldProps.style, newProps.style, isSVG);
  6724. }
  6725. if (patchFlag & 8) {
  6726. const propsToUpdate = n2.dynamicProps;
  6727. for (let i = 0; i < propsToUpdate.length; i++) {
  6728. const key = propsToUpdate[i];
  6729. const prev = oldProps[key];
  6730. const next = newProps[key];
  6731. if (next !== prev || key === "value") {
  6732. hostPatchProp(
  6733. el,
  6734. key,
  6735. prev,
  6736. next,
  6737. isSVG,
  6738. n1.children,
  6739. parentComponent,
  6740. parentSuspense,
  6741. unmountChildren
  6742. );
  6743. }
  6744. }
  6745. }
  6746. }
  6747. if (patchFlag & 1) {
  6748. if (n1.children !== n2.children) {
  6749. hostSetElementText(el, n2.children);
  6750. }
  6751. }
  6752. } else if (!optimized && dynamicChildren == null) {
  6753. patchProps(
  6754. el,
  6755. n2,
  6756. oldProps,
  6757. newProps,
  6758. parentComponent,
  6759. parentSuspense,
  6760. isSVG
  6761. );
  6762. }
  6763. if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
  6764. queuePostRenderEffect(() => {
  6765. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  6766. dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
  6767. }, parentSuspense);
  6768. }
  6769. };
  6770. const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => {
  6771. for (let i = 0; i < newChildren.length; i++) {
  6772. const oldVNode = oldChildren[i];
  6773. const newVNode = newChildren[i];
  6774. const container = (
  6775. // oldVNode may be an errored async setup() component inside Suspense
  6776. // which will not have a mounted element
  6777. oldVNode.el && // - In the case of a Fragment, we need to provide the actual parent
  6778. // of the Fragment itself so it can move its children.
  6779. (oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
  6780. // which also requires the correct parent container
  6781. !isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything.
  6782. oldVNode.shapeFlag & (6 | 64)) ? hostParentNode(oldVNode.el) : (
  6783. // In other cases, the parent container is not actually used so we
  6784. // just pass the block element here to avoid a DOM parentNode call.
  6785. fallbackContainer
  6786. )
  6787. );
  6788. patch(
  6789. oldVNode,
  6790. newVNode,
  6791. container,
  6792. null,
  6793. parentComponent,
  6794. parentSuspense,
  6795. isSVG,
  6796. slotScopeIds,
  6797. true
  6798. );
  6799. }
  6800. };
  6801. const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
  6802. if (oldProps !== newProps) {
  6803. if (oldProps !== EMPTY_OBJ) {
  6804. for (const key in oldProps) {
  6805. if (!isReservedProp(key) && !(key in newProps)) {
  6806. hostPatchProp(
  6807. el,
  6808. key,
  6809. oldProps[key],
  6810. null,
  6811. isSVG,
  6812. vnode.children,
  6813. parentComponent,
  6814. parentSuspense,
  6815. unmountChildren
  6816. );
  6817. }
  6818. }
  6819. }
  6820. for (const key in newProps) {
  6821. if (isReservedProp(key))
  6822. continue;
  6823. const next = newProps[key];
  6824. const prev = oldProps[key];
  6825. if (next !== prev && key !== "value") {
  6826. hostPatchProp(
  6827. el,
  6828. key,
  6829. prev,
  6830. next,
  6831. isSVG,
  6832. vnode.children,
  6833. parentComponent,
  6834. parentSuspense,
  6835. unmountChildren
  6836. );
  6837. }
  6838. }
  6839. if ("value" in newProps) {
  6840. hostPatchProp(el, "value", oldProps.value, newProps.value);
  6841. }
  6842. }
  6843. };
  6844. const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6845. const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
  6846. const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
  6847. let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
  6848. if (
  6849. // #5523 dev root fragment may inherit directives
  6850. isHmrUpdating || patchFlag & 2048
  6851. ) {
  6852. patchFlag = 0;
  6853. optimized = false;
  6854. dynamicChildren = null;
  6855. }
  6856. if (fragmentSlotScopeIds) {
  6857. slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
  6858. }
  6859. if (n1 == null) {
  6860. hostInsert(fragmentStartAnchor, container, anchor);
  6861. hostInsert(fragmentEndAnchor, container, anchor);
  6862. mountChildren(
  6863. n2.children,
  6864. container,
  6865. fragmentEndAnchor,
  6866. parentComponent,
  6867. parentSuspense,
  6868. isSVG,
  6869. slotScopeIds,
  6870. optimized
  6871. );
  6872. } else {
  6873. if (patchFlag > 0 && patchFlag & 64 && dynamicChildren && // #2715 the previous fragment could've been a BAILed one as a result
  6874. // of renderSlot() with no valid children
  6875. n1.dynamicChildren) {
  6876. patchBlockChildren(
  6877. n1.dynamicChildren,
  6878. dynamicChildren,
  6879. container,
  6880. parentComponent,
  6881. parentSuspense,
  6882. isSVG,
  6883. slotScopeIds
  6884. );
  6885. {
  6886. traverseStaticChildren(n1, n2);
  6887. }
  6888. } else {
  6889. patchChildren(
  6890. n1,
  6891. n2,
  6892. container,
  6893. fragmentEndAnchor,
  6894. parentComponent,
  6895. parentSuspense,
  6896. isSVG,
  6897. slotScopeIds,
  6898. optimized
  6899. );
  6900. }
  6901. }
  6902. };
  6903. const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6904. n2.slotScopeIds = slotScopeIds;
  6905. if (n1 == null) {
  6906. if (n2.shapeFlag & 512) {
  6907. parentComponent.ctx.activate(
  6908. n2,
  6909. container,
  6910. anchor,
  6911. isSVG,
  6912. optimized
  6913. );
  6914. } else {
  6915. mountComponent(
  6916. n2,
  6917. container,
  6918. anchor,
  6919. parentComponent,
  6920. parentSuspense,
  6921. isSVG,
  6922. optimized
  6923. );
  6924. }
  6925. } else {
  6926. updateComponent(n1, n2, optimized);
  6927. }
  6928. };
  6929. const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  6930. const instance = (initialVNode.component = createComponentInstance(
  6931. initialVNode,
  6932. parentComponent,
  6933. parentSuspense
  6934. ));
  6935. if (instance.type.__hmrId) {
  6936. registerHMR(instance);
  6937. }
  6938. {
  6939. pushWarningContext(initialVNode);
  6940. startMeasure(instance, `mount`);
  6941. }
  6942. if (isKeepAlive(initialVNode)) {
  6943. instance.ctx.renderer = internals;
  6944. }
  6945. {
  6946. {
  6947. startMeasure(instance, `init`);
  6948. }
  6949. setupComponent(instance);
  6950. {
  6951. endMeasure(instance, `init`);
  6952. }
  6953. }
  6954. if (instance.asyncDep) {
  6955. parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
  6956. if (!initialVNode.el) {
  6957. const placeholder = instance.subTree = createVNode(Comment);
  6958. processCommentNode(null, placeholder, container, anchor);
  6959. }
  6960. return;
  6961. }
  6962. setupRenderEffect(
  6963. instance,
  6964. initialVNode,
  6965. container,
  6966. anchor,
  6967. parentSuspense,
  6968. isSVG,
  6969. optimized
  6970. );
  6971. {
  6972. popWarningContext();
  6973. endMeasure(instance, `mount`);
  6974. }
  6975. };
  6976. const updateComponent = (n1, n2, optimized) => {
  6977. const instance = n2.component = n1.component;
  6978. if (shouldUpdateComponent(n1, n2, optimized)) {
  6979. if (instance.asyncDep && !instance.asyncResolved) {
  6980. {
  6981. pushWarningContext(n2);
  6982. }
  6983. updateComponentPreRender(instance, n2, optimized);
  6984. {
  6985. popWarningContext();
  6986. }
  6987. return;
  6988. } else {
  6989. instance.next = n2;
  6990. invalidateJob(instance.update);
  6991. instance.update();
  6992. }
  6993. } else {
  6994. n2.el = n1.el;
  6995. instance.vnode = n2;
  6996. }
  6997. };
  6998. const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
  6999. const componentUpdateFn = () => {
  7000. if (!instance.isMounted) {
  7001. let vnodeHook;
  7002. const { el, props } = initialVNode;
  7003. const { bm, m, parent } = instance;
  7004. const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
  7005. toggleRecurse(instance, false);
  7006. if (bm) {
  7007. invokeArrayFns(bm);
  7008. }
  7009. if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
  7010. invokeVNodeHook(vnodeHook, parent, initialVNode);
  7011. }
  7012. toggleRecurse(instance, true);
  7013. if (el && hydrateNode) {
  7014. const hydrateSubTree = () => {
  7015. {
  7016. startMeasure(instance, `render`);
  7017. }
  7018. instance.subTree = renderComponentRoot(instance);
  7019. {
  7020. endMeasure(instance, `render`);
  7021. }
  7022. {
  7023. startMeasure(instance, `hydrate`);
  7024. }
  7025. hydrateNode(
  7026. el,
  7027. instance.subTree,
  7028. instance,
  7029. parentSuspense,
  7030. null
  7031. );
  7032. {
  7033. endMeasure(instance, `hydrate`);
  7034. }
  7035. };
  7036. if (isAsyncWrapperVNode) {
  7037. initialVNode.type.__asyncLoader().then(
  7038. // note: we are moving the render call into an async callback,
  7039. // which means it won't track dependencies - but it's ok because
  7040. // a server-rendered async wrapper is already in resolved state
  7041. // and it will never need to change.
  7042. () => !instance.isUnmounted && hydrateSubTree()
  7043. );
  7044. } else {
  7045. hydrateSubTree();
  7046. }
  7047. } else {
  7048. {
  7049. startMeasure(instance, `render`);
  7050. }
  7051. const subTree = instance.subTree = renderComponentRoot(instance);
  7052. {
  7053. endMeasure(instance, `render`);
  7054. }
  7055. {
  7056. startMeasure(instance, `patch`);
  7057. }
  7058. patch(
  7059. null,
  7060. subTree,
  7061. container,
  7062. anchor,
  7063. instance,
  7064. parentSuspense,
  7065. isSVG
  7066. );
  7067. {
  7068. endMeasure(instance, `patch`);
  7069. }
  7070. initialVNode.el = subTree.el;
  7071. }
  7072. if (m) {
  7073. queuePostRenderEffect(m, parentSuspense);
  7074. }
  7075. if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
  7076. const scopedInitialVNode = initialVNode;
  7077. queuePostRenderEffect(
  7078. () => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode),
  7079. parentSuspense
  7080. );
  7081. }
  7082. if (initialVNode.shapeFlag & 256 || parent && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256) {
  7083. instance.a && queuePostRenderEffect(instance.a, parentSuspense);
  7084. }
  7085. instance.isMounted = true;
  7086. {
  7087. devtoolsComponentAdded(instance);
  7088. }
  7089. initialVNode = container = anchor = null;
  7090. } else {
  7091. let { next, bu, u, parent, vnode } = instance;
  7092. let originNext = next;
  7093. let vnodeHook;
  7094. {
  7095. pushWarningContext(next || instance.vnode);
  7096. }
  7097. toggleRecurse(instance, false);
  7098. if (next) {
  7099. next.el = vnode.el;
  7100. updateComponentPreRender(instance, next, optimized);
  7101. } else {
  7102. next = vnode;
  7103. }
  7104. if (bu) {
  7105. invokeArrayFns(bu);
  7106. }
  7107. if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) {
  7108. invokeVNodeHook(vnodeHook, parent, next, vnode);
  7109. }
  7110. toggleRecurse(instance, true);
  7111. {
  7112. startMeasure(instance, `render`);
  7113. }
  7114. const nextTree = renderComponentRoot(instance);
  7115. {
  7116. endMeasure(instance, `render`);
  7117. }
  7118. const prevTree = instance.subTree;
  7119. instance.subTree = nextTree;
  7120. {
  7121. startMeasure(instance, `patch`);
  7122. }
  7123. patch(
  7124. prevTree,
  7125. nextTree,
  7126. // parent may have changed if it's in a teleport
  7127. hostParentNode(prevTree.el),
  7128. // anchor may have changed if it's in a fragment
  7129. getNextHostNode(prevTree),
  7130. instance,
  7131. parentSuspense,
  7132. isSVG
  7133. );
  7134. {
  7135. endMeasure(instance, `patch`);
  7136. }
  7137. next.el = nextTree.el;
  7138. if (originNext === null) {
  7139. updateHOCHostEl(instance, nextTree.el);
  7140. }
  7141. if (u) {
  7142. queuePostRenderEffect(u, parentSuspense);
  7143. }
  7144. if (vnodeHook = next.props && next.props.onVnodeUpdated) {
  7145. queuePostRenderEffect(
  7146. () => invokeVNodeHook(vnodeHook, parent, next, vnode),
  7147. parentSuspense
  7148. );
  7149. }
  7150. {
  7151. devtoolsComponentUpdated(instance);
  7152. }
  7153. {
  7154. popWarningContext();
  7155. }
  7156. }
  7157. };
  7158. const effect = instance.effect = new ReactiveEffect(
  7159. componentUpdateFn,
  7160. () => queueJob(update),
  7161. instance.scope
  7162. // track it in component's effect scope
  7163. );
  7164. const update = instance.update = () => effect.run();
  7165. update.id = instance.uid;
  7166. toggleRecurse(instance, true);
  7167. {
  7168. effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
  7169. effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
  7170. update.ownerInstance = instance;
  7171. }
  7172. update();
  7173. };
  7174. const updateComponentPreRender = (instance, nextVNode, optimized) => {
  7175. nextVNode.component = instance;
  7176. const prevProps = instance.vnode.props;
  7177. instance.vnode = nextVNode;
  7178. instance.next = null;
  7179. updateProps(instance, nextVNode.props, prevProps, optimized);
  7180. updateSlots(instance, nextVNode.children, optimized);
  7181. pauseTracking();
  7182. flushPreFlushCbs();
  7183. resetTracking();
  7184. };
  7185. const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized = false) => {
  7186. const c1 = n1 && n1.children;
  7187. const prevShapeFlag = n1 ? n1.shapeFlag : 0;
  7188. const c2 = n2.children;
  7189. const { patchFlag, shapeFlag } = n2;
  7190. if (patchFlag > 0) {
  7191. if (patchFlag & 128) {
  7192. patchKeyedChildren(
  7193. c1,
  7194. c2,
  7195. container,
  7196. anchor,
  7197. parentComponent,
  7198. parentSuspense,
  7199. isSVG,
  7200. slotScopeIds,
  7201. optimized
  7202. );
  7203. return;
  7204. } else if (patchFlag & 256) {
  7205. patchUnkeyedChildren(
  7206. c1,
  7207. c2,
  7208. container,
  7209. anchor,
  7210. parentComponent,
  7211. parentSuspense,
  7212. isSVG,
  7213. slotScopeIds,
  7214. optimized
  7215. );
  7216. return;
  7217. }
  7218. }
  7219. if (shapeFlag & 8) {
  7220. if (prevShapeFlag & 16) {
  7221. unmountChildren(c1, parentComponent, parentSuspense);
  7222. }
  7223. if (c2 !== c1) {
  7224. hostSetElementText(container, c2);
  7225. }
  7226. } else {
  7227. if (prevShapeFlag & 16) {
  7228. if (shapeFlag & 16) {
  7229. patchKeyedChildren(
  7230. c1,
  7231. c2,
  7232. container,
  7233. anchor,
  7234. parentComponent,
  7235. parentSuspense,
  7236. isSVG,
  7237. slotScopeIds,
  7238. optimized
  7239. );
  7240. } else {
  7241. unmountChildren(c1, parentComponent, parentSuspense, true);
  7242. }
  7243. } else {
  7244. if (prevShapeFlag & 8) {
  7245. hostSetElementText(container, "");
  7246. }
  7247. if (shapeFlag & 16) {
  7248. mountChildren(
  7249. c2,
  7250. container,
  7251. anchor,
  7252. parentComponent,
  7253. parentSuspense,
  7254. isSVG,
  7255. slotScopeIds,
  7256. optimized
  7257. );
  7258. }
  7259. }
  7260. }
  7261. };
  7262. const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  7263. c1 = c1 || EMPTY_ARR;
  7264. c2 = c2 || EMPTY_ARR;
  7265. const oldLength = c1.length;
  7266. const newLength = c2.length;
  7267. const commonLength = Math.min(oldLength, newLength);
  7268. let i;
  7269. for (i = 0; i < commonLength; i++) {
  7270. const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
  7271. patch(
  7272. c1[i],
  7273. nextChild,
  7274. container,
  7275. null,
  7276. parentComponent,
  7277. parentSuspense,
  7278. isSVG,
  7279. slotScopeIds,
  7280. optimized
  7281. );
  7282. }
  7283. if (oldLength > newLength) {
  7284. unmountChildren(
  7285. c1,
  7286. parentComponent,
  7287. parentSuspense,
  7288. true,
  7289. false,
  7290. commonLength
  7291. );
  7292. } else {
  7293. mountChildren(
  7294. c2,
  7295. container,
  7296. anchor,
  7297. parentComponent,
  7298. parentSuspense,
  7299. isSVG,
  7300. slotScopeIds,
  7301. optimized,
  7302. commonLength
  7303. );
  7304. }
  7305. };
  7306. const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  7307. let i = 0;
  7308. const l2 = c2.length;
  7309. let e1 = c1.length - 1;
  7310. let e2 = l2 - 1;
  7311. while (i <= e1 && i <= e2) {
  7312. const n1 = c1[i];
  7313. const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
  7314. if (isSameVNodeType(n1, n2)) {
  7315. patch(
  7316. n1,
  7317. n2,
  7318. container,
  7319. null,
  7320. parentComponent,
  7321. parentSuspense,
  7322. isSVG,
  7323. slotScopeIds,
  7324. optimized
  7325. );
  7326. } else {
  7327. break;
  7328. }
  7329. i++;
  7330. }
  7331. while (i <= e1 && i <= e2) {
  7332. const n1 = c1[e1];
  7333. const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]);
  7334. if (isSameVNodeType(n1, n2)) {
  7335. patch(
  7336. n1,
  7337. n2,
  7338. container,
  7339. null,
  7340. parentComponent,
  7341. parentSuspense,
  7342. isSVG,
  7343. slotScopeIds,
  7344. optimized
  7345. );
  7346. } else {
  7347. break;
  7348. }
  7349. e1--;
  7350. e2--;
  7351. }
  7352. if (i > e1) {
  7353. if (i <= e2) {
  7354. const nextPos = e2 + 1;
  7355. const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
  7356. while (i <= e2) {
  7357. patch(
  7358. null,
  7359. c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]),
  7360. container,
  7361. anchor,
  7362. parentComponent,
  7363. parentSuspense,
  7364. isSVG,
  7365. slotScopeIds,
  7366. optimized
  7367. );
  7368. i++;
  7369. }
  7370. }
  7371. } else if (i > e2) {
  7372. while (i <= e1) {
  7373. unmount(c1[i], parentComponent, parentSuspense, true);
  7374. i++;
  7375. }
  7376. } else {
  7377. const s1 = i;
  7378. const s2 = i;
  7379. const keyToNewIndexMap = /* @__PURE__ */ new Map();
  7380. for (i = s2; i <= e2; i++) {
  7381. const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
  7382. if (nextChild.key != null) {
  7383. if (keyToNewIndexMap.has(nextChild.key)) {
  7384. warn(
  7385. `Duplicate keys found during update:`,
  7386. JSON.stringify(nextChild.key),
  7387. `Make sure keys are unique.`
  7388. );
  7389. }
  7390. keyToNewIndexMap.set(nextChild.key, i);
  7391. }
  7392. }
  7393. let j;
  7394. let patched = 0;
  7395. const toBePatched = e2 - s2 + 1;
  7396. let moved = false;
  7397. let maxNewIndexSoFar = 0;
  7398. const newIndexToOldIndexMap = new Array(toBePatched);
  7399. for (i = 0; i < toBePatched; i++)
  7400. newIndexToOldIndexMap[i] = 0;
  7401. for (i = s1; i <= e1; i++) {
  7402. const prevChild = c1[i];
  7403. if (patched >= toBePatched) {
  7404. unmount(prevChild, parentComponent, parentSuspense, true);
  7405. continue;
  7406. }
  7407. let newIndex;
  7408. if (prevChild.key != null) {
  7409. newIndex = keyToNewIndexMap.get(prevChild.key);
  7410. } else {
  7411. for (j = s2; j <= e2; j++) {
  7412. if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
  7413. newIndex = j;
  7414. break;
  7415. }
  7416. }
  7417. }
  7418. if (newIndex === void 0) {
  7419. unmount(prevChild, parentComponent, parentSuspense, true);
  7420. } else {
  7421. newIndexToOldIndexMap[newIndex - s2] = i + 1;
  7422. if (newIndex >= maxNewIndexSoFar) {
  7423. maxNewIndexSoFar = newIndex;
  7424. } else {
  7425. moved = true;
  7426. }
  7427. patch(
  7428. prevChild,
  7429. c2[newIndex],
  7430. container,
  7431. null,
  7432. parentComponent,
  7433. parentSuspense,
  7434. isSVG,
  7435. slotScopeIds,
  7436. optimized
  7437. );
  7438. patched++;
  7439. }
  7440. }
  7441. const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR;
  7442. j = increasingNewIndexSequence.length - 1;
  7443. for (i = toBePatched - 1; i >= 0; i--) {
  7444. const nextIndex = s2 + i;
  7445. const nextChild = c2[nextIndex];
  7446. const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
  7447. if (newIndexToOldIndexMap[i] === 0) {
  7448. patch(
  7449. null,
  7450. nextChild,
  7451. container,
  7452. anchor,
  7453. parentComponent,
  7454. parentSuspense,
  7455. isSVG,
  7456. slotScopeIds,
  7457. optimized
  7458. );
  7459. } else if (moved) {
  7460. if (j < 0 || i !== increasingNewIndexSequence[j]) {
  7461. move(nextChild, container, anchor, 2);
  7462. } else {
  7463. j--;
  7464. }
  7465. }
  7466. }
  7467. }
  7468. };
  7469. const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
  7470. const { el, type, transition, children, shapeFlag } = vnode;
  7471. if (shapeFlag & 6) {
  7472. move(vnode.component.subTree, container, anchor, moveType);
  7473. return;
  7474. }
  7475. if (shapeFlag & 128) {
  7476. vnode.suspense.move(container, anchor, moveType);
  7477. return;
  7478. }
  7479. if (shapeFlag & 64) {
  7480. type.move(vnode, container, anchor, internals);
  7481. return;
  7482. }
  7483. if (type === Fragment) {
  7484. hostInsert(el, container, anchor);
  7485. for (let i = 0; i < children.length; i++) {
  7486. move(children[i], container, anchor, moveType);
  7487. }
  7488. hostInsert(vnode.anchor, container, anchor);
  7489. return;
  7490. }
  7491. if (type === Static) {
  7492. moveStaticNode(vnode, container, anchor);
  7493. return;
  7494. }
  7495. const needTransition = moveType !== 2 && shapeFlag & 1 && transition;
  7496. if (needTransition) {
  7497. if (moveType === 0) {
  7498. transition.beforeEnter(el);
  7499. hostInsert(el, container, anchor);
  7500. queuePostRenderEffect(() => transition.enter(el), parentSuspense);
  7501. } else {
  7502. const { leave, delayLeave, afterLeave } = transition;
  7503. const remove2 = () => hostInsert(el, container, anchor);
  7504. const performLeave = () => {
  7505. leave(el, () => {
  7506. remove2();
  7507. afterLeave && afterLeave();
  7508. });
  7509. };
  7510. if (delayLeave) {
  7511. delayLeave(el, remove2, performLeave);
  7512. } else {
  7513. performLeave();
  7514. }
  7515. }
  7516. } else {
  7517. hostInsert(el, container, anchor);
  7518. }
  7519. };
  7520. const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
  7521. const {
  7522. type,
  7523. props,
  7524. ref,
  7525. children,
  7526. dynamicChildren,
  7527. shapeFlag,
  7528. patchFlag,
  7529. dirs
  7530. } = vnode;
  7531. if (ref != null) {
  7532. setRef(ref, null, parentSuspense, vnode, true);
  7533. }
  7534. if (shapeFlag & 256) {
  7535. parentComponent.ctx.deactivate(vnode);
  7536. return;
  7537. }
  7538. const shouldInvokeDirs = shapeFlag & 1 && dirs;
  7539. const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
  7540. let vnodeHook;
  7541. if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) {
  7542. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  7543. }
  7544. if (shapeFlag & 6) {
  7545. unmountComponent(vnode.component, parentSuspense, doRemove);
  7546. } else {
  7547. if (shapeFlag & 128) {
  7548. vnode.suspense.unmount(parentSuspense, doRemove);
  7549. return;
  7550. }
  7551. if (shouldInvokeDirs) {
  7552. invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
  7553. }
  7554. if (shapeFlag & 64) {
  7555. vnode.type.remove(
  7556. vnode,
  7557. parentComponent,
  7558. parentSuspense,
  7559. optimized,
  7560. internals,
  7561. doRemove
  7562. );
  7563. } else if (dynamicChildren && // #1153: fast path should not be taken for non-stable (v-for) fragments
  7564. (type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
  7565. unmountChildren(
  7566. dynamicChildren,
  7567. parentComponent,
  7568. parentSuspense,
  7569. false,
  7570. true
  7571. );
  7572. } else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
  7573. unmountChildren(children, parentComponent, parentSuspense);
  7574. }
  7575. if (doRemove) {
  7576. remove(vnode);
  7577. }
  7578. }
  7579. if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
  7580. queuePostRenderEffect(() => {
  7581. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  7582. shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
  7583. }, parentSuspense);
  7584. }
  7585. };
  7586. const remove = (vnode) => {
  7587. const { type, el, anchor, transition } = vnode;
  7588. if (type === Fragment) {
  7589. if (vnode.patchFlag > 0 && vnode.patchFlag & 2048 && transition && !transition.persisted) {
  7590. vnode.children.forEach((child) => {
  7591. if (child.type === Comment) {
  7592. hostRemove(child.el);
  7593. } else {
  7594. remove(child);
  7595. }
  7596. });
  7597. } else {
  7598. removeFragment(el, anchor);
  7599. }
  7600. return;
  7601. }
  7602. if (type === Static) {
  7603. removeStaticNode(vnode);
  7604. return;
  7605. }
  7606. const performRemove = () => {
  7607. hostRemove(el);
  7608. if (transition && !transition.persisted && transition.afterLeave) {
  7609. transition.afterLeave();
  7610. }
  7611. };
  7612. if (vnode.shapeFlag & 1 && transition && !transition.persisted) {
  7613. const { leave, delayLeave } = transition;
  7614. const performLeave = () => leave(el, performRemove);
  7615. if (delayLeave) {
  7616. delayLeave(vnode.el, performRemove, performLeave);
  7617. } else {
  7618. performLeave();
  7619. }
  7620. } else {
  7621. performRemove();
  7622. }
  7623. };
  7624. const removeFragment = (cur, end) => {
  7625. let next;
  7626. while (cur !== end) {
  7627. next = hostNextSibling(cur);
  7628. hostRemove(cur);
  7629. cur = next;
  7630. }
  7631. hostRemove(end);
  7632. };
  7633. const unmountComponent = (instance, parentSuspense, doRemove) => {
  7634. if (instance.type.__hmrId) {
  7635. unregisterHMR(instance);
  7636. }
  7637. const { bum, scope, update, subTree, um } = instance;
  7638. if (bum) {
  7639. invokeArrayFns(bum);
  7640. }
  7641. scope.stop();
  7642. if (update) {
  7643. update.active = false;
  7644. unmount(subTree, instance, parentSuspense, doRemove);
  7645. }
  7646. if (um) {
  7647. queuePostRenderEffect(um, parentSuspense);
  7648. }
  7649. queuePostRenderEffect(() => {
  7650. instance.isUnmounted = true;
  7651. }, parentSuspense);
  7652. if (parentSuspense && parentSuspense.pendingBranch && !parentSuspense.isUnmounted && instance.asyncDep && !instance.asyncResolved && instance.suspenseId === parentSuspense.pendingId) {
  7653. parentSuspense.deps--;
  7654. if (parentSuspense.deps === 0) {
  7655. parentSuspense.resolve();
  7656. }
  7657. }
  7658. {
  7659. devtoolsComponentRemoved(instance);
  7660. }
  7661. };
  7662. const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
  7663. for (let i = start; i < children.length; i++) {
  7664. unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
  7665. }
  7666. };
  7667. const getNextHostNode = (vnode) => {
  7668. if (vnode.shapeFlag & 6) {
  7669. return getNextHostNode(vnode.component.subTree);
  7670. }
  7671. if (vnode.shapeFlag & 128) {
  7672. return vnode.suspense.next();
  7673. }
  7674. return hostNextSibling(vnode.anchor || vnode.el);
  7675. };
  7676. const render = (vnode, container, isSVG) => {
  7677. if (vnode == null) {
  7678. if (container._vnode) {
  7679. unmount(container._vnode, null, null, true);
  7680. }
  7681. } else {
  7682. patch(container._vnode || null, vnode, container, null, null, null, isSVG);
  7683. }
  7684. flushPreFlushCbs();
  7685. flushPostFlushCbs();
  7686. container._vnode = vnode;
  7687. };
  7688. const internals = {
  7689. p: patch,
  7690. um: unmount,
  7691. m: move,
  7692. r: remove,
  7693. mt: mountComponent,
  7694. mc: mountChildren,
  7695. pc: patchChildren,
  7696. pbc: patchBlockChildren,
  7697. n: getNextHostNode,
  7698. o: options
  7699. };
  7700. let hydrate;
  7701. let hydrateNode;
  7702. if (createHydrationFns) {
  7703. [hydrate, hydrateNode] = createHydrationFns(
  7704. internals
  7705. );
  7706. }
  7707. return {
  7708. render,
  7709. hydrate,
  7710. createApp: createAppAPI(render, hydrate)
  7711. };
  7712. }
  7713. function toggleRecurse({ effect, update }, allowed) {
  7714. effect.allowRecurse = update.allowRecurse = allowed;
  7715. }
  7716. function traverseStaticChildren(n1, n2, shallow = false) {
  7717. const ch1 = n1.children;
  7718. const ch2 = n2.children;
  7719. if (isArray(ch1) && isArray(ch2)) {
  7720. for (let i = 0; i < ch1.length; i++) {
  7721. const c1 = ch1[i];
  7722. let c2 = ch2[i];
  7723. if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
  7724. if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
  7725. c2 = ch2[i] = cloneIfMounted(ch2[i]);
  7726. c2.el = c1.el;
  7727. }
  7728. if (!shallow)
  7729. traverseStaticChildren(c1, c2);
  7730. }
  7731. if (c2.type === Text) {
  7732. c2.el = c1.el;
  7733. }
  7734. if (c2.type === Comment && !c2.el) {
  7735. c2.el = c1.el;
  7736. }
  7737. }
  7738. }
  7739. }
  7740. function getSequence(arr) {
  7741. const p = arr.slice();
  7742. const result = [0];
  7743. let i, j, u, v, c;
  7744. const len = arr.length;
  7745. for (i = 0; i < len; i++) {
  7746. const arrI = arr[i];
  7747. if (arrI !== 0) {
  7748. j = result[result.length - 1];
  7749. if (arr[j] < arrI) {
  7750. p[i] = j;
  7751. result.push(i);
  7752. continue;
  7753. }
  7754. u = 0;
  7755. v = result.length - 1;
  7756. while (u < v) {
  7757. c = u + v >> 1;
  7758. if (arr[result[c]] < arrI) {
  7759. u = c + 1;
  7760. } else {
  7761. v = c;
  7762. }
  7763. }
  7764. if (arrI < arr[result[u]]) {
  7765. if (u > 0) {
  7766. p[i] = result[u - 1];
  7767. }
  7768. result[u] = i;
  7769. }
  7770. }
  7771. }
  7772. u = result.length;
  7773. v = result[u - 1];
  7774. while (u-- > 0) {
  7775. result[u] = v;
  7776. v = p[v];
  7777. }
  7778. return result;
  7779. }
  7780. const isTeleport = (type) => type.__isTeleport;
  7781. const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === "");
  7782. const isTargetSVG = (target) => typeof SVGElement !== "undefined" && target instanceof SVGElement;
  7783. const resolveTarget = (props, select) => {
  7784. const targetSelector = props && props.to;
  7785. if (isString(targetSelector)) {
  7786. if (!select) {
  7787. warn(
  7788. `Current renderer does not support string target for Teleports. (missing querySelector renderer option)`
  7789. );
  7790. return null;
  7791. } else {
  7792. const target = select(targetSelector);
  7793. if (!target) {
  7794. warn(
  7795. `Failed to locate Teleport target with selector "${targetSelector}". Note the target element must exist before the component is mounted - i.e. the target cannot be rendered by the component itself, and ideally should be outside of the entire Vue component tree.`
  7796. );
  7797. }
  7798. return target;
  7799. }
  7800. } else {
  7801. if (!targetSelector && !isTeleportDisabled(props)) {
  7802. warn(`Invalid Teleport target: ${targetSelector}`);
  7803. }
  7804. return targetSelector;
  7805. }
  7806. };
  7807. const TeleportImpl = {
  7808. __isTeleport: true,
  7809. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
  7810. const {
  7811. mc: mountChildren,
  7812. pc: patchChildren,
  7813. pbc: patchBlockChildren,
  7814. o: { insert, querySelector, createText, createComment }
  7815. } = internals;
  7816. const disabled = isTeleportDisabled(n2.props);
  7817. let { shapeFlag, children, dynamicChildren } = n2;
  7818. if (isHmrUpdating) {
  7819. optimized = false;
  7820. dynamicChildren = null;
  7821. }
  7822. if (n1 == null) {
  7823. const placeholder = n2.el = createComment("teleport start") ;
  7824. const mainAnchor = n2.anchor = createComment("teleport end") ;
  7825. insert(placeholder, container, anchor);
  7826. insert(mainAnchor, container, anchor);
  7827. const target = n2.target = resolveTarget(n2.props, querySelector);
  7828. const targetAnchor = n2.targetAnchor = createText("");
  7829. if (target) {
  7830. insert(targetAnchor, target);
  7831. isSVG = isSVG || isTargetSVG(target);
  7832. } else if (!disabled) {
  7833. warn("Invalid Teleport target on mount:", target, `(${typeof target})`);
  7834. }
  7835. const mount = (container2, anchor2) => {
  7836. if (shapeFlag & 16) {
  7837. mountChildren(
  7838. children,
  7839. container2,
  7840. anchor2,
  7841. parentComponent,
  7842. parentSuspense,
  7843. isSVG,
  7844. slotScopeIds,
  7845. optimized
  7846. );
  7847. }
  7848. };
  7849. if (disabled) {
  7850. mount(container, mainAnchor);
  7851. } else if (target) {
  7852. mount(target, targetAnchor);
  7853. }
  7854. } else {
  7855. n2.el = n1.el;
  7856. const mainAnchor = n2.anchor = n1.anchor;
  7857. const target = n2.target = n1.target;
  7858. const targetAnchor = n2.targetAnchor = n1.targetAnchor;
  7859. const wasDisabled = isTeleportDisabled(n1.props);
  7860. const currentContainer = wasDisabled ? container : target;
  7861. const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
  7862. isSVG = isSVG || isTargetSVG(target);
  7863. if (dynamicChildren) {
  7864. patchBlockChildren(
  7865. n1.dynamicChildren,
  7866. dynamicChildren,
  7867. currentContainer,
  7868. parentComponent,
  7869. parentSuspense,
  7870. isSVG,
  7871. slotScopeIds
  7872. );
  7873. traverseStaticChildren(n1, n2, true);
  7874. } else if (!optimized) {
  7875. patchChildren(
  7876. n1,
  7877. n2,
  7878. currentContainer,
  7879. currentAnchor,
  7880. parentComponent,
  7881. parentSuspense,
  7882. isSVG,
  7883. slotScopeIds,
  7884. false
  7885. );
  7886. }
  7887. if (disabled) {
  7888. if (!wasDisabled) {
  7889. moveTeleport(
  7890. n2,
  7891. container,
  7892. mainAnchor,
  7893. internals,
  7894. 1
  7895. );
  7896. }
  7897. } else {
  7898. if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
  7899. const nextTarget = n2.target = resolveTarget(
  7900. n2.props,
  7901. querySelector
  7902. );
  7903. if (nextTarget) {
  7904. moveTeleport(
  7905. n2,
  7906. nextTarget,
  7907. null,
  7908. internals,
  7909. 0
  7910. );
  7911. } else {
  7912. warn(
  7913. "Invalid Teleport target on update:",
  7914. target,
  7915. `(${typeof target})`
  7916. );
  7917. }
  7918. } else if (wasDisabled) {
  7919. moveTeleport(
  7920. n2,
  7921. target,
  7922. targetAnchor,
  7923. internals,
  7924. 1
  7925. );
  7926. }
  7927. }
  7928. }
  7929. updateCssVars(n2);
  7930. },
  7931. remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
  7932. const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
  7933. if (target) {
  7934. hostRemove(targetAnchor);
  7935. }
  7936. if (doRemove || !isTeleportDisabled(props)) {
  7937. hostRemove(anchor);
  7938. if (shapeFlag & 16) {
  7939. for (let i = 0; i < children.length; i++) {
  7940. const child = children[i];
  7941. unmount(
  7942. child,
  7943. parentComponent,
  7944. parentSuspense,
  7945. true,
  7946. !!child.dynamicChildren
  7947. );
  7948. }
  7949. }
  7950. }
  7951. },
  7952. move: moveTeleport,
  7953. hydrate: hydrateTeleport
  7954. };
  7955. function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2) {
  7956. if (moveType === 0) {
  7957. insert(vnode.targetAnchor, container, parentAnchor);
  7958. }
  7959. const { el, anchor, shapeFlag, children, props } = vnode;
  7960. const isReorder = moveType === 2;
  7961. if (isReorder) {
  7962. insert(el, container, parentAnchor);
  7963. }
  7964. if (!isReorder || isTeleportDisabled(props)) {
  7965. if (shapeFlag & 16) {
  7966. for (let i = 0; i < children.length; i++) {
  7967. move(
  7968. children[i],
  7969. container,
  7970. parentAnchor,
  7971. 2
  7972. );
  7973. }
  7974. }
  7975. }
  7976. if (isReorder) {
  7977. insert(anchor, container, parentAnchor);
  7978. }
  7979. }
  7980. function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, {
  7981. o: { nextSibling, parentNode, querySelector }
  7982. }, hydrateChildren) {
  7983. const target = vnode.target = resolveTarget(
  7984. vnode.props,
  7985. querySelector
  7986. );
  7987. if (target) {
  7988. const targetNode = target._lpa || target.firstChild;
  7989. if (vnode.shapeFlag & 16) {
  7990. if (isTeleportDisabled(vnode.props)) {
  7991. vnode.anchor = hydrateChildren(
  7992. nextSibling(node),
  7993. vnode,
  7994. parentNode(node),
  7995. parentComponent,
  7996. parentSuspense,
  7997. slotScopeIds,
  7998. optimized
  7999. );
  8000. vnode.targetAnchor = targetNode;
  8001. } else {
  8002. vnode.anchor = nextSibling(node);
  8003. let targetAnchor = targetNode;
  8004. while (targetAnchor) {
  8005. targetAnchor = nextSibling(targetAnchor);
  8006. if (targetAnchor && targetAnchor.nodeType === 8 && targetAnchor.data === "teleport anchor") {
  8007. vnode.targetAnchor = targetAnchor;
  8008. target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor);
  8009. break;
  8010. }
  8011. }
  8012. hydrateChildren(
  8013. targetNode,
  8014. vnode,
  8015. target,
  8016. parentComponent,
  8017. parentSuspense,
  8018. slotScopeIds,
  8019. optimized
  8020. );
  8021. }
  8022. }
  8023. updateCssVars(vnode);
  8024. }
  8025. return vnode.anchor && nextSibling(vnode.anchor);
  8026. }
  8027. const Teleport = TeleportImpl;
  8028. function updateCssVars(vnode) {
  8029. const ctx = vnode.ctx;
  8030. if (ctx && ctx.ut) {
  8031. let node = vnode.children[0].el;
  8032. while (node !== vnode.targetAnchor) {
  8033. if (node.nodeType === 1)
  8034. node.setAttribute("data-v-owner", ctx.uid);
  8035. node = node.nextSibling;
  8036. }
  8037. ctx.ut();
  8038. }
  8039. }
  8040. const Fragment = Symbol.for("v-fgt");
  8041. const Text = Symbol.for("v-txt");
  8042. const Comment = Symbol.for("v-cmt");
  8043. const Static = Symbol.for("v-stc");
  8044. const blockStack = [];
  8045. let currentBlock = null;
  8046. function openBlock(disableTracking = false) {
  8047. blockStack.push(currentBlock = disableTracking ? null : []);
  8048. }
  8049. function closeBlock() {
  8050. blockStack.pop();
  8051. currentBlock = blockStack[blockStack.length - 1] || null;
  8052. }
  8053. let isBlockTreeEnabled = 1;
  8054. function setBlockTracking(value) {
  8055. isBlockTreeEnabled += value;
  8056. }
  8057. function setupBlock(vnode) {
  8058. vnode.dynamicChildren = isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
  8059. closeBlock();
  8060. if (isBlockTreeEnabled > 0 && currentBlock) {
  8061. currentBlock.push(vnode);
  8062. }
  8063. return vnode;
  8064. }
  8065. function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
  8066. return setupBlock(
  8067. createBaseVNode(
  8068. type,
  8069. props,
  8070. children,
  8071. patchFlag,
  8072. dynamicProps,
  8073. shapeFlag,
  8074. true
  8075. /* isBlock */
  8076. )
  8077. );
  8078. }
  8079. function createBlock(type, props, children, patchFlag, dynamicProps) {
  8080. return setupBlock(
  8081. createVNode(
  8082. type,
  8083. props,
  8084. children,
  8085. patchFlag,
  8086. dynamicProps,
  8087. true
  8088. /* isBlock: prevent a block from tracking itself */
  8089. )
  8090. );
  8091. }
  8092. function isVNode(value) {
  8093. return value ? value.__v_isVNode === true : false;
  8094. }
  8095. function isSameVNodeType(n1, n2) {
  8096. if (n2.shapeFlag & 6 && hmrDirtyComponents.has(n2.type)) {
  8097. n1.shapeFlag &= ~256;
  8098. n2.shapeFlag &= ~512;
  8099. return false;
  8100. }
  8101. return n1.type === n2.type && n1.key === n2.key;
  8102. }
  8103. let vnodeArgsTransformer;
  8104. function transformVNodeArgs(transformer) {
  8105. vnodeArgsTransformer = transformer;
  8106. }
  8107. const createVNodeWithArgsTransform = (...args) => {
  8108. return _createVNode(
  8109. ...vnodeArgsTransformer ? vnodeArgsTransformer(args, currentRenderingInstance) : args
  8110. );
  8111. };
  8112. const InternalObjectKey = `__vInternal`;
  8113. const normalizeKey = ({ key }) => key != null ? key : null;
  8114. const normalizeRef = ({
  8115. ref,
  8116. ref_key,
  8117. ref_for
  8118. }) => {
  8119. if (typeof ref === "number") {
  8120. ref = "" + ref;
  8121. }
  8122. return ref != null ? isString(ref) || isRef(ref) || isFunction(ref) ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for } : ref : null;
  8123. };
  8124. function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) {
  8125. const vnode = {
  8126. __v_isVNode: true,
  8127. __v_skip: true,
  8128. type,
  8129. props,
  8130. key: props && normalizeKey(props),
  8131. ref: props && normalizeRef(props),
  8132. scopeId: currentScopeId,
  8133. slotScopeIds: null,
  8134. children,
  8135. component: null,
  8136. suspense: null,
  8137. ssContent: null,
  8138. ssFallback: null,
  8139. dirs: null,
  8140. transition: null,
  8141. el: null,
  8142. anchor: null,
  8143. target: null,
  8144. targetAnchor: null,
  8145. staticCount: 0,
  8146. shapeFlag,
  8147. patchFlag,
  8148. dynamicProps,
  8149. dynamicChildren: null,
  8150. appContext: null,
  8151. ctx: currentRenderingInstance
  8152. };
  8153. if (needFullChildrenNormalization) {
  8154. normalizeChildren(vnode, children);
  8155. if (shapeFlag & 128) {
  8156. type.normalize(vnode);
  8157. }
  8158. } else if (children) {
  8159. vnode.shapeFlag |= isString(children) ? 8 : 16;
  8160. }
  8161. if (vnode.key !== vnode.key) {
  8162. warn(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
  8163. }
  8164. if (isBlockTreeEnabled > 0 && // avoid a block node from tracking itself
  8165. !isBlockNode && // has current parent block
  8166. currentBlock && // presence of a patch flag indicates this node needs patching on updates.
  8167. // component nodes also should always be patched, because even if the
  8168. // component doesn't need to update, it needs to persist the instance on to
  8169. // the next vnode so that it can be properly unmounted later.
  8170. (vnode.patchFlag > 0 || shapeFlag & 6) && // the EVENTS flag is only for hydration and if it is the only flag, the
  8171. // vnode should not be considered dynamic due to handler caching.
  8172. vnode.patchFlag !== 32) {
  8173. currentBlock.push(vnode);
  8174. }
  8175. return vnode;
  8176. }
  8177. const createVNode = createVNodeWithArgsTransform ;
  8178. function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
  8179. if (!type || type === NULL_DYNAMIC_COMPONENT) {
  8180. if (!type) {
  8181. warn(`Invalid vnode type when creating vnode: ${type}.`);
  8182. }
  8183. type = Comment;
  8184. }
  8185. if (isVNode(type)) {
  8186. const cloned = cloneVNode(
  8187. type,
  8188. props,
  8189. true
  8190. /* mergeRef: true */
  8191. );
  8192. if (children) {
  8193. normalizeChildren(cloned, children);
  8194. }
  8195. if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
  8196. if (cloned.shapeFlag & 6) {
  8197. currentBlock[currentBlock.indexOf(type)] = cloned;
  8198. } else {
  8199. currentBlock.push(cloned);
  8200. }
  8201. }
  8202. cloned.patchFlag |= -2;
  8203. return cloned;
  8204. }
  8205. if (isClassComponent(type)) {
  8206. type = type.__vccOpts;
  8207. }
  8208. if (props) {
  8209. props = guardReactiveProps(props);
  8210. let { class: klass, style } = props;
  8211. if (klass && !isString(klass)) {
  8212. props.class = normalizeClass(klass);
  8213. }
  8214. if (isObject(style)) {
  8215. if (isProxy(style) && !isArray(style)) {
  8216. style = extend({}, style);
  8217. }
  8218. props.style = normalizeStyle(style);
  8219. }
  8220. }
  8221. const shapeFlag = isString(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : isObject(type) ? 4 : isFunction(type) ? 2 : 0;
  8222. if (shapeFlag & 4 && isProxy(type)) {
  8223. type = toRaw(type);
  8224. warn(
  8225. `Vue received a Component which was made a reactive object. This can lead to unnecessary performance overhead, and should be avoided by marking the component with \`markRaw\` or using \`shallowRef\` instead of \`ref\`.`,
  8226. `
  8227. Component that was made reactive: `,
  8228. type
  8229. );
  8230. }
  8231. return createBaseVNode(
  8232. type,
  8233. props,
  8234. children,
  8235. patchFlag,
  8236. dynamicProps,
  8237. shapeFlag,
  8238. isBlockNode,
  8239. true
  8240. );
  8241. }
  8242. function guardReactiveProps(props) {
  8243. if (!props)
  8244. return null;
  8245. return isProxy(props) || InternalObjectKey in props ? extend({}, props) : props;
  8246. }
  8247. function cloneVNode(vnode, extraProps, mergeRef = false) {
  8248. const { props, ref, patchFlag, children } = vnode;
  8249. const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
  8250. const cloned = {
  8251. __v_isVNode: true,
  8252. __v_skip: true,
  8253. type: vnode.type,
  8254. props: mergedProps,
  8255. key: mergedProps && normalizeKey(mergedProps),
  8256. ref: extraProps && extraProps.ref ? (
  8257. // #2078 in the case of <component :is="vnode" ref="extra"/>
  8258. // if the vnode itself already has a ref, cloneVNode will need to merge
  8259. // the refs so the single vnode can be set on multiple refs
  8260. mergeRef && ref ? isArray(ref) ? ref.concat(normalizeRef(extraProps)) : [ref, normalizeRef(extraProps)] : normalizeRef(extraProps)
  8261. ) : ref,
  8262. scopeId: vnode.scopeId,
  8263. slotScopeIds: vnode.slotScopeIds,
  8264. children: patchFlag === -1 && isArray(children) ? children.map(deepCloneVNode) : children,
  8265. target: vnode.target,
  8266. targetAnchor: vnode.targetAnchor,
  8267. staticCount: vnode.staticCount,
  8268. shapeFlag: vnode.shapeFlag,
  8269. // if the vnode is cloned with extra props, we can no longer assume its
  8270. // existing patch flag to be reliable and need to add the FULL_PROPS flag.
  8271. // note: preserve flag for fragments since they use the flag for children
  8272. // fast paths only.
  8273. patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag,
  8274. dynamicProps: vnode.dynamicProps,
  8275. dynamicChildren: vnode.dynamicChildren,
  8276. appContext: vnode.appContext,
  8277. dirs: vnode.dirs,
  8278. transition: vnode.transition,
  8279. // These should technically only be non-null on mounted VNodes. However,
  8280. // they *should* be copied for kept-alive vnodes. So we just always copy
  8281. // them since them being non-null during a mount doesn't affect the logic as
  8282. // they will simply be overwritten.
  8283. component: vnode.component,
  8284. suspense: vnode.suspense,
  8285. ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
  8286. ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
  8287. el: vnode.el,
  8288. anchor: vnode.anchor,
  8289. ctx: vnode.ctx,
  8290. ce: vnode.ce
  8291. };
  8292. return cloned;
  8293. }
  8294. function deepCloneVNode(vnode) {
  8295. const cloned = cloneVNode(vnode);
  8296. if (isArray(vnode.children)) {
  8297. cloned.children = vnode.children.map(deepCloneVNode);
  8298. }
  8299. return cloned;
  8300. }
  8301. function createTextVNode(text = " ", flag = 0) {
  8302. return createVNode(Text, null, text, flag);
  8303. }
  8304. function createStaticVNode(content, numberOfNodes) {
  8305. const vnode = createVNode(Static, null, content);
  8306. vnode.staticCount = numberOfNodes;
  8307. return vnode;
  8308. }
  8309. function createCommentVNode(text = "", asBlock = false) {
  8310. return asBlock ? (openBlock(), createBlock(Comment, null, text)) : createVNode(Comment, null, text);
  8311. }
  8312. function normalizeVNode(child) {
  8313. if (child == null || typeof child === "boolean") {
  8314. return createVNode(Comment);
  8315. } else if (isArray(child)) {
  8316. return createVNode(
  8317. Fragment,
  8318. null,
  8319. // #3666, avoid reference pollution when reusing vnode
  8320. child.slice()
  8321. );
  8322. } else if (typeof child === "object") {
  8323. return cloneIfMounted(child);
  8324. } else {
  8325. return createVNode(Text, null, String(child));
  8326. }
  8327. }
  8328. function cloneIfMounted(child) {
  8329. return child.el === null && child.patchFlag !== -1 || child.memo ? child : cloneVNode(child);
  8330. }
  8331. function normalizeChildren(vnode, children) {
  8332. let type = 0;
  8333. const { shapeFlag } = vnode;
  8334. if (children == null) {
  8335. children = null;
  8336. } else if (isArray(children)) {
  8337. type = 16;
  8338. } else if (typeof children === "object") {
  8339. if (shapeFlag & (1 | 64)) {
  8340. const slot = children.default;
  8341. if (slot) {
  8342. slot._c && (slot._d = false);
  8343. normalizeChildren(vnode, slot());
  8344. slot._c && (slot._d = true);
  8345. }
  8346. return;
  8347. } else {
  8348. type = 32;
  8349. const slotFlag = children._;
  8350. if (!slotFlag && !(InternalObjectKey in children)) {
  8351. children._ctx = currentRenderingInstance;
  8352. } else if (slotFlag === 3 && currentRenderingInstance) {
  8353. if (currentRenderingInstance.slots._ === 1) {
  8354. children._ = 1;
  8355. } else {
  8356. children._ = 2;
  8357. vnode.patchFlag |= 1024;
  8358. }
  8359. }
  8360. }
  8361. } else if (isFunction(children)) {
  8362. children = { default: children, _ctx: currentRenderingInstance };
  8363. type = 32;
  8364. } else {
  8365. children = String(children);
  8366. if (shapeFlag & 64) {
  8367. type = 16;
  8368. children = [createTextVNode(children)];
  8369. } else {
  8370. type = 8;
  8371. }
  8372. }
  8373. vnode.children = children;
  8374. vnode.shapeFlag |= type;
  8375. }
  8376. function mergeProps(...args) {
  8377. const ret = {};
  8378. for (let i = 0; i < args.length; i++) {
  8379. const toMerge = args[i];
  8380. for (const key in toMerge) {
  8381. if (key === "class") {
  8382. if (ret.class !== toMerge.class) {
  8383. ret.class = normalizeClass([ret.class, toMerge.class]);
  8384. }
  8385. } else if (key === "style") {
  8386. ret.style = normalizeStyle([ret.style, toMerge.style]);
  8387. } else if (isOn(key)) {
  8388. const existing = ret[key];
  8389. const incoming = toMerge[key];
  8390. if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming))) {
  8391. ret[key] = existing ? [].concat(existing, incoming) : incoming;
  8392. }
  8393. } else if (key !== "") {
  8394. ret[key] = toMerge[key];
  8395. }
  8396. }
  8397. }
  8398. return ret;
  8399. }
  8400. function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
  8401. callWithAsyncErrorHandling(hook, instance, 7, [
  8402. vnode,
  8403. prevVNode
  8404. ]);
  8405. }
  8406. const emptyAppContext = createAppContext();
  8407. let uid = 0;
  8408. function createComponentInstance(vnode, parent, suspense) {
  8409. const type = vnode.type;
  8410. const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
  8411. const instance = {
  8412. uid: uid++,
  8413. vnode,
  8414. type,
  8415. parent,
  8416. appContext,
  8417. root: null,
  8418. // to be immediately set
  8419. next: null,
  8420. subTree: null,
  8421. // will be set synchronously right after creation
  8422. effect: null,
  8423. update: null,
  8424. // will be set synchronously right after creation
  8425. scope: new EffectScope(
  8426. true
  8427. /* detached */
  8428. ),
  8429. render: null,
  8430. proxy: null,
  8431. exposed: null,
  8432. exposeProxy: null,
  8433. withProxy: null,
  8434. provides: parent ? parent.provides : Object.create(appContext.provides),
  8435. accessCache: null,
  8436. renderCache: [],
  8437. // local resolved assets
  8438. components: null,
  8439. directives: null,
  8440. // resolved props and emits options
  8441. propsOptions: normalizePropsOptions(type, appContext),
  8442. emitsOptions: normalizeEmitsOptions(type, appContext),
  8443. // emit
  8444. emit: null,
  8445. // to be set immediately
  8446. emitted: null,
  8447. // props default value
  8448. propsDefaults: EMPTY_OBJ,
  8449. // inheritAttrs
  8450. inheritAttrs: type.inheritAttrs,
  8451. // state
  8452. ctx: EMPTY_OBJ,
  8453. data: EMPTY_OBJ,
  8454. props: EMPTY_OBJ,
  8455. attrs: EMPTY_OBJ,
  8456. slots: EMPTY_OBJ,
  8457. refs: EMPTY_OBJ,
  8458. setupState: EMPTY_OBJ,
  8459. setupContext: null,
  8460. attrsProxy: null,
  8461. slotsProxy: null,
  8462. // suspense related
  8463. suspense,
  8464. suspenseId: suspense ? suspense.pendingId : 0,
  8465. asyncDep: null,
  8466. asyncResolved: false,
  8467. // lifecycle hooks
  8468. // not using enums here because it results in computed properties
  8469. isMounted: false,
  8470. isUnmounted: false,
  8471. isDeactivated: false,
  8472. bc: null,
  8473. c: null,
  8474. bm: null,
  8475. m: null,
  8476. bu: null,
  8477. u: null,
  8478. um: null,
  8479. bum: null,
  8480. da: null,
  8481. a: null,
  8482. rtg: null,
  8483. rtc: null,
  8484. ec: null,
  8485. sp: null
  8486. };
  8487. {
  8488. instance.ctx = createDevRenderContext(instance);
  8489. }
  8490. instance.root = parent ? parent.root : instance;
  8491. instance.emit = emit.bind(null, instance);
  8492. if (vnode.ce) {
  8493. vnode.ce(instance);
  8494. }
  8495. return instance;
  8496. }
  8497. let currentInstance = null;
  8498. const getCurrentInstance = () => currentInstance || currentRenderingInstance;
  8499. let internalSetCurrentInstance;
  8500. {
  8501. internalSetCurrentInstance = (i) => {
  8502. currentInstance = i;
  8503. };
  8504. }
  8505. const setCurrentInstance = (instance) => {
  8506. internalSetCurrentInstance(instance);
  8507. instance.scope.on();
  8508. };
  8509. const unsetCurrentInstance = () => {
  8510. currentInstance && currentInstance.scope.off();
  8511. internalSetCurrentInstance(null);
  8512. };
  8513. const isBuiltInTag = /* @__PURE__ */ makeMap("slot,component");
  8514. function validateComponentName(name, config) {
  8515. const appIsNativeTag = config.isNativeTag || NO;
  8516. if (isBuiltInTag(name) || appIsNativeTag(name)) {
  8517. warn(
  8518. "Do not use built-in or reserved HTML elements as component id: " + name
  8519. );
  8520. }
  8521. }
  8522. function isStatefulComponent(instance) {
  8523. return instance.vnode.shapeFlag & 4;
  8524. }
  8525. let isInSSRComponentSetup = false;
  8526. function setupComponent(instance, isSSR = false) {
  8527. isInSSRComponentSetup = isSSR;
  8528. const { props, children } = instance.vnode;
  8529. const isStateful = isStatefulComponent(instance);
  8530. initProps(instance, props, isStateful, isSSR);
  8531. initSlots(instance, children);
  8532. const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0;
  8533. isInSSRComponentSetup = false;
  8534. return setupResult;
  8535. }
  8536. function setupStatefulComponent(instance, isSSR) {
  8537. var _a;
  8538. const Component = instance.type;
  8539. {
  8540. if (Component.name) {
  8541. validateComponentName(Component.name, instance.appContext.config);
  8542. }
  8543. if (Component.components) {
  8544. const names = Object.keys(Component.components);
  8545. for (let i = 0; i < names.length; i++) {
  8546. validateComponentName(names[i], instance.appContext.config);
  8547. }
  8548. }
  8549. if (Component.directives) {
  8550. const names = Object.keys(Component.directives);
  8551. for (let i = 0; i < names.length; i++) {
  8552. validateDirectiveName(names[i]);
  8553. }
  8554. }
  8555. if (Component.compilerOptions && isRuntimeOnly()) {
  8556. warn(
  8557. `"compilerOptions" is only supported when using a build of Vue that includes the runtime compiler. Since you are using a runtime-only build, the options should be passed via your build tool config instead.`
  8558. );
  8559. }
  8560. }
  8561. instance.accessCache = /* @__PURE__ */ Object.create(null);
  8562. instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
  8563. {
  8564. exposePropsOnRenderContext(instance);
  8565. }
  8566. const { setup } = Component;
  8567. if (setup) {
  8568. const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;
  8569. setCurrentInstance(instance);
  8570. pauseTracking();
  8571. const setupResult = callWithErrorHandling(
  8572. setup,
  8573. instance,
  8574. 0,
  8575. [shallowReadonly(instance.props) , setupContext]
  8576. );
  8577. resetTracking();
  8578. unsetCurrentInstance();
  8579. if (isPromise(setupResult)) {
  8580. setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
  8581. if (isSSR) {
  8582. return setupResult.then((resolvedResult) => {
  8583. handleSetupResult(instance, resolvedResult, isSSR);
  8584. }).catch((e) => {
  8585. handleError(e, instance, 0);
  8586. });
  8587. } else {
  8588. instance.asyncDep = setupResult;
  8589. if (!instance.suspense) {
  8590. const name = (_a = Component.name) != null ? _a : "Anonymous";
  8591. warn(
  8592. `Component <${name}>: setup function returned a promise, but no <Suspense> boundary was found in the parent component tree. A component with async setup() must be nested in a <Suspense> in order to be rendered.`
  8593. );
  8594. }
  8595. }
  8596. } else {
  8597. handleSetupResult(instance, setupResult, isSSR);
  8598. }
  8599. } else {
  8600. finishComponentSetup(instance, isSSR);
  8601. }
  8602. }
  8603. function handleSetupResult(instance, setupResult, isSSR) {
  8604. if (isFunction(setupResult)) {
  8605. {
  8606. instance.render = setupResult;
  8607. }
  8608. } else if (isObject(setupResult)) {
  8609. if (isVNode(setupResult)) {
  8610. warn(
  8611. `setup() should not return VNodes directly - return a render function instead.`
  8612. );
  8613. }
  8614. {
  8615. instance.devtoolsRawSetupState = setupResult;
  8616. }
  8617. instance.setupState = proxyRefs(setupResult);
  8618. {
  8619. exposeSetupStateOnRenderContext(instance);
  8620. }
  8621. } else if (setupResult !== void 0) {
  8622. warn(
  8623. `setup() should return an object. Received: ${setupResult === null ? "null" : typeof setupResult}`
  8624. );
  8625. }
  8626. finishComponentSetup(instance, isSSR);
  8627. }
  8628. let compile$1;
  8629. let installWithProxy;
  8630. function registerRuntimeCompiler(_compile) {
  8631. compile$1 = _compile;
  8632. installWithProxy = (i) => {
  8633. if (i.render._rc) {
  8634. i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
  8635. }
  8636. };
  8637. }
  8638. const isRuntimeOnly = () => !compile$1;
  8639. function finishComponentSetup(instance, isSSR, skipOptions) {
  8640. const Component = instance.type;
  8641. if (!instance.render) {
  8642. if (!isSSR && compile$1 && !Component.render) {
  8643. const template = Component.template || resolveMergedOptions(instance).template;
  8644. if (template) {
  8645. {
  8646. startMeasure(instance, `compile`);
  8647. }
  8648. const { isCustomElement, compilerOptions } = instance.appContext.config;
  8649. const { delimiters, compilerOptions: componentCompilerOptions } = Component;
  8650. const finalCompilerOptions = extend(
  8651. extend(
  8652. {
  8653. isCustomElement,
  8654. delimiters
  8655. },
  8656. compilerOptions
  8657. ),
  8658. componentCompilerOptions
  8659. );
  8660. Component.render = compile$1(template, finalCompilerOptions);
  8661. {
  8662. endMeasure(instance, `compile`);
  8663. }
  8664. }
  8665. }
  8666. instance.render = Component.render || NOOP;
  8667. if (installWithProxy) {
  8668. installWithProxy(instance);
  8669. }
  8670. }
  8671. {
  8672. setCurrentInstance(instance);
  8673. pauseTracking();
  8674. applyOptions(instance);
  8675. resetTracking();
  8676. unsetCurrentInstance();
  8677. }
  8678. if (!Component.render && instance.render === NOOP && !isSSR) {
  8679. if (!compile$1 && Component.template) {
  8680. warn(
  8681. `Component provided template option but runtime compilation is not supported in this build of Vue.` + (` Use "vue.esm-browser.js" instead.` )
  8682. /* should not happen */
  8683. );
  8684. } else {
  8685. warn(`Component is missing template or render function.`);
  8686. }
  8687. }
  8688. }
  8689. function getAttrsProxy(instance) {
  8690. return instance.attrsProxy || (instance.attrsProxy = new Proxy(
  8691. instance.attrs,
  8692. {
  8693. get(target, key) {
  8694. markAttrsAccessed();
  8695. track(instance, "get", "$attrs");
  8696. return target[key];
  8697. },
  8698. set() {
  8699. warn(`setupContext.attrs is readonly.`);
  8700. return false;
  8701. },
  8702. deleteProperty() {
  8703. warn(`setupContext.attrs is readonly.`);
  8704. return false;
  8705. }
  8706. }
  8707. ));
  8708. }
  8709. function getSlotsProxy(instance) {
  8710. return instance.slotsProxy || (instance.slotsProxy = new Proxy(instance.slots, {
  8711. get(target, key) {
  8712. track(instance, "get", "$slots");
  8713. return target[key];
  8714. }
  8715. }));
  8716. }
  8717. function createSetupContext(instance) {
  8718. const expose = (exposed) => {
  8719. {
  8720. if (instance.exposed) {
  8721. warn(`expose() should be called only once per setup().`);
  8722. }
  8723. if (exposed != null) {
  8724. let exposedType = typeof exposed;
  8725. if (exposedType === "object") {
  8726. if (isArray(exposed)) {
  8727. exposedType = "array";
  8728. } else if (isRef(exposed)) {
  8729. exposedType = "ref";
  8730. }
  8731. }
  8732. if (exposedType !== "object") {
  8733. warn(
  8734. `expose() should be passed a plain object, received ${exposedType}.`
  8735. );
  8736. }
  8737. }
  8738. }
  8739. instance.exposed = exposed || {};
  8740. };
  8741. {
  8742. return Object.freeze({
  8743. get attrs() {
  8744. return getAttrsProxy(instance);
  8745. },
  8746. get slots() {
  8747. return getSlotsProxy(instance);
  8748. },
  8749. get emit() {
  8750. return (event, ...args) => instance.emit(event, ...args);
  8751. },
  8752. expose
  8753. });
  8754. }
  8755. }
  8756. function getExposeProxy(instance) {
  8757. if (instance.exposed) {
  8758. return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
  8759. get(target, key) {
  8760. if (key in target) {
  8761. return target[key];
  8762. } else if (key in publicPropertiesMap) {
  8763. return publicPropertiesMap[key](instance);
  8764. }
  8765. },
  8766. has(target, key) {
  8767. return key in target || key in publicPropertiesMap;
  8768. }
  8769. }));
  8770. }
  8771. }
  8772. const classifyRE = /(?:^|[-_])(\w)/g;
  8773. const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
  8774. function getComponentName(Component, includeInferred = true) {
  8775. return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
  8776. }
  8777. function formatComponentName(instance, Component, isRoot = false) {
  8778. let name = getComponentName(Component);
  8779. if (!name && Component.__file) {
  8780. const match = Component.__file.match(/([^/\\]+)\.\w+$/);
  8781. if (match) {
  8782. name = match[1];
  8783. }
  8784. }
  8785. if (!name && instance && instance.parent) {
  8786. const inferFromRegistry = (registry) => {
  8787. for (const key in registry) {
  8788. if (registry[key] === Component) {
  8789. return key;
  8790. }
  8791. }
  8792. };
  8793. name = inferFromRegistry(
  8794. instance.components || instance.parent.type.components
  8795. ) || inferFromRegistry(instance.appContext.components);
  8796. }
  8797. return name ? classify(name) : isRoot ? `App` : `Anonymous`;
  8798. }
  8799. function isClassComponent(value) {
  8800. return isFunction(value) && "__vccOpts" in value;
  8801. }
  8802. const computed = (getterOrOptions, debugOptions) => {
  8803. return computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
  8804. };
  8805. function h(type, propsOrChildren, children) {
  8806. const l = arguments.length;
  8807. if (l === 2) {
  8808. if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
  8809. if (isVNode(propsOrChildren)) {
  8810. return createVNode(type, null, [propsOrChildren]);
  8811. }
  8812. return createVNode(type, propsOrChildren);
  8813. } else {
  8814. return createVNode(type, null, propsOrChildren);
  8815. }
  8816. } else {
  8817. if (l > 3) {
  8818. children = Array.prototype.slice.call(arguments, 2);
  8819. } else if (l === 3 && isVNode(children)) {
  8820. children = [children];
  8821. }
  8822. return createVNode(type, propsOrChildren, children);
  8823. }
  8824. }
  8825. const ssrContextKey = Symbol.for("v-scx");
  8826. const useSSRContext = () => {
  8827. {
  8828. const ctx = inject(ssrContextKey);
  8829. if (!ctx) {
  8830. warn(
  8831. `Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.`
  8832. );
  8833. }
  8834. return ctx;
  8835. }
  8836. };
  8837. function initCustomFormatter() {
  8838. if (typeof window === "undefined") {
  8839. return;
  8840. }
  8841. const vueStyle = { style: "color:#3ba776" };
  8842. const numberStyle = { style: "color:#0b1bc9" };
  8843. const stringStyle = { style: "color:#b62e24" };
  8844. const keywordStyle = { style: "color:#9d288c" };
  8845. const formatter = {
  8846. header(obj) {
  8847. if (!isObject(obj)) {
  8848. return null;
  8849. }
  8850. if (obj.__isVue) {
  8851. return ["div", vueStyle, `VueInstance`];
  8852. } else if (isRef(obj)) {
  8853. return [
  8854. "div",
  8855. {},
  8856. ["span", vueStyle, genRefFlag(obj)],
  8857. "<",
  8858. formatValue(obj.value),
  8859. `>`
  8860. ];
  8861. } else if (isReactive(obj)) {
  8862. return [
  8863. "div",
  8864. {},
  8865. ["span", vueStyle, isShallow(obj) ? "ShallowReactive" : "Reactive"],
  8866. "<",
  8867. formatValue(obj),
  8868. `>${isReadonly(obj) ? ` (readonly)` : ``}`
  8869. ];
  8870. } else if (isReadonly(obj)) {
  8871. return [
  8872. "div",
  8873. {},
  8874. ["span", vueStyle, isShallow(obj) ? "ShallowReadonly" : "Readonly"],
  8875. "<",
  8876. formatValue(obj),
  8877. ">"
  8878. ];
  8879. }
  8880. return null;
  8881. },
  8882. hasBody(obj) {
  8883. return obj && obj.__isVue;
  8884. },
  8885. body(obj) {
  8886. if (obj && obj.__isVue) {
  8887. return [
  8888. "div",
  8889. {},
  8890. ...formatInstance(obj.$)
  8891. ];
  8892. }
  8893. }
  8894. };
  8895. function formatInstance(instance) {
  8896. const blocks = [];
  8897. if (instance.type.props && instance.props) {
  8898. blocks.push(createInstanceBlock("props", toRaw(instance.props)));
  8899. }
  8900. if (instance.setupState !== EMPTY_OBJ) {
  8901. blocks.push(createInstanceBlock("setup", instance.setupState));
  8902. }
  8903. if (instance.data !== EMPTY_OBJ) {
  8904. blocks.push(createInstanceBlock("data", toRaw(instance.data)));
  8905. }
  8906. const computed = extractKeys(instance, "computed");
  8907. if (computed) {
  8908. blocks.push(createInstanceBlock("computed", computed));
  8909. }
  8910. const injected = extractKeys(instance, "inject");
  8911. if (injected) {
  8912. blocks.push(createInstanceBlock("injected", injected));
  8913. }
  8914. blocks.push([
  8915. "div",
  8916. {},
  8917. [
  8918. "span",
  8919. {
  8920. style: keywordStyle.style + ";opacity:0.66"
  8921. },
  8922. "$ (internal): "
  8923. ],
  8924. ["object", { object: instance }]
  8925. ]);
  8926. return blocks;
  8927. }
  8928. function createInstanceBlock(type, target) {
  8929. target = extend({}, target);
  8930. if (!Object.keys(target).length) {
  8931. return ["span", {}];
  8932. }
  8933. return [
  8934. "div",
  8935. { style: "line-height:1.25em;margin-bottom:0.6em" },
  8936. [
  8937. "div",
  8938. {
  8939. style: "color:#476582"
  8940. },
  8941. type
  8942. ],
  8943. [
  8944. "div",
  8945. {
  8946. style: "padding-left:1.25em"
  8947. },
  8948. ...Object.keys(target).map((key) => {
  8949. return [
  8950. "div",
  8951. {},
  8952. ["span", keywordStyle, key + ": "],
  8953. formatValue(target[key], false)
  8954. ];
  8955. })
  8956. ]
  8957. ];
  8958. }
  8959. function formatValue(v, asRaw = true) {
  8960. if (typeof v === "number") {
  8961. return ["span", numberStyle, v];
  8962. } else if (typeof v === "string") {
  8963. return ["span", stringStyle, JSON.stringify(v)];
  8964. } else if (typeof v === "boolean") {
  8965. return ["span", keywordStyle, v];
  8966. } else if (isObject(v)) {
  8967. return ["object", { object: asRaw ? toRaw(v) : v }];
  8968. } else {
  8969. return ["span", stringStyle, String(v)];
  8970. }
  8971. }
  8972. function extractKeys(instance, type) {
  8973. const Comp = instance.type;
  8974. if (isFunction(Comp)) {
  8975. return;
  8976. }
  8977. const extracted = {};
  8978. for (const key in instance.ctx) {
  8979. if (isKeyOfType(Comp, key, type)) {
  8980. extracted[key] = instance.ctx[key];
  8981. }
  8982. }
  8983. return extracted;
  8984. }
  8985. function isKeyOfType(Comp, key, type) {
  8986. const opts = Comp[type];
  8987. if (isArray(opts) && opts.includes(key) || isObject(opts) && key in opts) {
  8988. return true;
  8989. }
  8990. if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
  8991. return true;
  8992. }
  8993. if (Comp.mixins && Comp.mixins.some((m) => isKeyOfType(m, key, type))) {
  8994. return true;
  8995. }
  8996. }
  8997. function genRefFlag(v) {
  8998. if (isShallow(v)) {
  8999. return `ShallowRef`;
  9000. }
  9001. if (v.effect) {
  9002. return `ComputedRef`;
  9003. }
  9004. return `Ref`;
  9005. }
  9006. if (window.devtoolsFormatters) {
  9007. window.devtoolsFormatters.push(formatter);
  9008. } else {
  9009. window.devtoolsFormatters = [formatter];
  9010. }
  9011. }
  9012. function withMemo(memo, render, cache, index) {
  9013. const cached = cache[index];
  9014. if (cached && isMemoSame(cached, memo)) {
  9015. return cached;
  9016. }
  9017. const ret = render();
  9018. ret.memo = memo.slice();
  9019. return cache[index] = ret;
  9020. }
  9021. function isMemoSame(cached, memo) {
  9022. const prev = cached.memo;
  9023. if (prev.length != memo.length) {
  9024. return false;
  9025. }
  9026. for (let i = 0; i < prev.length; i++) {
  9027. if (hasChanged(prev[i], memo[i])) {
  9028. return false;
  9029. }
  9030. }
  9031. if (isBlockTreeEnabled > 0 && currentBlock) {
  9032. currentBlock.push(cached);
  9033. }
  9034. return true;
  9035. }
  9036. const version = "3.3.4";
  9037. const ssrUtils = null;
  9038. const resolveFilter = null;
  9039. const compatUtils = null;
  9040. const svgNS = "http://www.w3.org/2000/svg";
  9041. const doc = typeof document !== "undefined" ? document : null;
  9042. const templateContainer = doc && /* @__PURE__ */ doc.createElement("template");
  9043. const nodeOps = {
  9044. insert: (child, parent, anchor) => {
  9045. parent.insertBefore(child, anchor || null);
  9046. },
  9047. remove: (child) => {
  9048. const parent = child.parentNode;
  9049. if (parent) {
  9050. parent.removeChild(child);
  9051. }
  9052. },
  9053. createElement: (tag, isSVG, is, props) => {
  9054. const el = isSVG ? doc.createElementNS(svgNS, tag) : doc.createElement(tag, is ? { is } : void 0);
  9055. if (tag === "select" && props && props.multiple != null) {
  9056. el.setAttribute("multiple", props.multiple);
  9057. }
  9058. return el;
  9059. },
  9060. createText: (text) => doc.createTextNode(text),
  9061. createComment: (text) => doc.createComment(text),
  9062. setText: (node, text) => {
  9063. node.nodeValue = text;
  9064. },
  9065. setElementText: (el, text) => {
  9066. el.textContent = text;
  9067. },
  9068. parentNode: (node) => node.parentNode,
  9069. nextSibling: (node) => node.nextSibling,
  9070. querySelector: (selector) => doc.querySelector(selector),
  9071. setScopeId(el, id) {
  9072. el.setAttribute(id, "");
  9073. },
  9074. // __UNSAFE__
  9075. // Reason: innerHTML.
  9076. // Static content here can only come from compiled templates.
  9077. // As long as the user only uses trusted templates, this is safe.
  9078. insertStaticContent(content, parent, anchor, isSVG, start, end) {
  9079. const before = anchor ? anchor.previousSibling : parent.lastChild;
  9080. if (start && (start === end || start.nextSibling)) {
  9081. while (true) {
  9082. parent.insertBefore(start.cloneNode(true), anchor);
  9083. if (start === end || !(start = start.nextSibling))
  9084. break;
  9085. }
  9086. } else {
  9087. templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
  9088. const template = templateContainer.content;
  9089. if (isSVG) {
  9090. const wrapper = template.firstChild;
  9091. while (wrapper.firstChild) {
  9092. template.appendChild(wrapper.firstChild);
  9093. }
  9094. template.removeChild(wrapper);
  9095. }
  9096. parent.insertBefore(template, anchor);
  9097. }
  9098. return [
  9099. // first
  9100. before ? before.nextSibling : parent.firstChild,
  9101. // last
  9102. anchor ? anchor.previousSibling : parent.lastChild
  9103. ];
  9104. }
  9105. };
  9106. function patchClass(el, value, isSVG) {
  9107. const transitionClasses = el._vtc;
  9108. if (transitionClasses) {
  9109. value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
  9110. }
  9111. if (value == null) {
  9112. el.removeAttribute("class");
  9113. } else if (isSVG) {
  9114. el.setAttribute("class", value);
  9115. } else {
  9116. el.className = value;
  9117. }
  9118. }
  9119. function patchStyle(el, prev, next) {
  9120. const style = el.style;
  9121. const isCssString = isString(next);
  9122. if (next && !isCssString) {
  9123. if (prev && !isString(prev)) {
  9124. for (const key in prev) {
  9125. if (next[key] == null) {
  9126. setStyle(style, key, "");
  9127. }
  9128. }
  9129. }
  9130. for (const key in next) {
  9131. setStyle(style, key, next[key]);
  9132. }
  9133. } else {
  9134. const currentDisplay = style.display;
  9135. if (isCssString) {
  9136. if (prev !== next) {
  9137. style.cssText = next;
  9138. }
  9139. } else if (prev) {
  9140. el.removeAttribute("style");
  9141. }
  9142. if ("_vod" in el) {
  9143. style.display = currentDisplay;
  9144. }
  9145. }
  9146. }
  9147. const semicolonRE = /[^\\];\s*$/;
  9148. const importantRE = /\s*!important$/;
  9149. function setStyle(style, name, val) {
  9150. if (isArray(val)) {
  9151. val.forEach((v) => setStyle(style, name, v));
  9152. } else {
  9153. if (val == null)
  9154. val = "";
  9155. {
  9156. if (semicolonRE.test(val)) {
  9157. warn(
  9158. `Unexpected semicolon at the end of '${name}' style value: '${val}'`
  9159. );
  9160. }
  9161. }
  9162. if (name.startsWith("--")) {
  9163. style.setProperty(name, val);
  9164. } else {
  9165. const prefixed = autoPrefix(style, name);
  9166. if (importantRE.test(val)) {
  9167. style.setProperty(
  9168. hyphenate(prefixed),
  9169. val.replace(importantRE, ""),
  9170. "important"
  9171. );
  9172. } else {
  9173. style[prefixed] = val;
  9174. }
  9175. }
  9176. }
  9177. }
  9178. const prefixes = ["Webkit", "Moz", "ms"];
  9179. const prefixCache = {};
  9180. function autoPrefix(style, rawName) {
  9181. const cached = prefixCache[rawName];
  9182. if (cached) {
  9183. return cached;
  9184. }
  9185. let name = camelize(rawName);
  9186. if (name !== "filter" && name in style) {
  9187. return prefixCache[rawName] = name;
  9188. }
  9189. name = capitalize(name);
  9190. for (let i = 0; i < prefixes.length; i++) {
  9191. const prefixed = prefixes[i] + name;
  9192. if (prefixed in style) {
  9193. return prefixCache[rawName] = prefixed;
  9194. }
  9195. }
  9196. return rawName;
  9197. }
  9198. const xlinkNS = "http://www.w3.org/1999/xlink";
  9199. function patchAttr(el, key, value, isSVG, instance) {
  9200. if (isSVG && key.startsWith("xlink:")) {
  9201. if (value == null) {
  9202. el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
  9203. } else {
  9204. el.setAttributeNS(xlinkNS, key, value);
  9205. }
  9206. } else {
  9207. const isBoolean = isSpecialBooleanAttr(key);
  9208. if (value == null || isBoolean && !includeBooleanAttr(value)) {
  9209. el.removeAttribute(key);
  9210. } else {
  9211. el.setAttribute(key, isBoolean ? "" : value);
  9212. }
  9213. }
  9214. }
  9215. function patchDOMProp(el, key, value, prevChildren, parentComponent, parentSuspense, unmountChildren) {
  9216. if (key === "innerHTML" || key === "textContent") {
  9217. if (prevChildren) {
  9218. unmountChildren(prevChildren, parentComponent, parentSuspense);
  9219. }
  9220. el[key] = value == null ? "" : value;
  9221. return;
  9222. }
  9223. const tag = el.tagName;
  9224. if (key === "value" && tag !== "PROGRESS" && // custom elements may use _value internally
  9225. !tag.includes("-")) {
  9226. el._value = value;
  9227. const oldValue = tag === "OPTION" ? el.getAttribute("value") : el.value;
  9228. const newValue = value == null ? "" : value;
  9229. if (oldValue !== newValue) {
  9230. el.value = newValue;
  9231. }
  9232. if (value == null) {
  9233. el.removeAttribute(key);
  9234. }
  9235. return;
  9236. }
  9237. let needRemove = false;
  9238. if (value === "" || value == null) {
  9239. const type = typeof el[key];
  9240. if (type === "boolean") {
  9241. value = includeBooleanAttr(value);
  9242. } else if (value == null && type === "string") {
  9243. value = "";
  9244. needRemove = true;
  9245. } else if (type === "number") {
  9246. value = 0;
  9247. needRemove = true;
  9248. }
  9249. }
  9250. try {
  9251. el[key] = value;
  9252. } catch (e) {
  9253. if (!needRemove) {
  9254. warn(
  9255. `Failed setting prop "${key}" on <${tag.toLowerCase()}>: value ${value} is invalid.`,
  9256. e
  9257. );
  9258. }
  9259. }
  9260. needRemove && el.removeAttribute(key);
  9261. }
  9262. function addEventListener(el, event, handler, options) {
  9263. el.addEventListener(event, handler, options);
  9264. }
  9265. function removeEventListener(el, event, handler, options) {
  9266. el.removeEventListener(event, handler, options);
  9267. }
  9268. function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
  9269. const invokers = el._vei || (el._vei = {});
  9270. const existingInvoker = invokers[rawName];
  9271. if (nextValue && existingInvoker) {
  9272. existingInvoker.value = nextValue;
  9273. } else {
  9274. const [name, options] = parseName(rawName);
  9275. if (nextValue) {
  9276. const invoker = invokers[rawName] = createInvoker(nextValue, instance);
  9277. addEventListener(el, name, invoker, options);
  9278. } else if (existingInvoker) {
  9279. removeEventListener(el, name, existingInvoker, options);
  9280. invokers[rawName] = void 0;
  9281. }
  9282. }
  9283. }
  9284. const optionsModifierRE = /(?:Once|Passive|Capture)$/;
  9285. function parseName(name) {
  9286. let options;
  9287. if (optionsModifierRE.test(name)) {
  9288. options = {};
  9289. let m;
  9290. while (m = name.match(optionsModifierRE)) {
  9291. name = name.slice(0, name.length - m[0].length);
  9292. options[m[0].toLowerCase()] = true;
  9293. }
  9294. }
  9295. const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
  9296. return [event, options];
  9297. }
  9298. let cachedNow = 0;
  9299. const p = /* @__PURE__ */ Promise.resolve();
  9300. const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
  9301. function createInvoker(initialValue, instance) {
  9302. const invoker = (e) => {
  9303. if (!e._vts) {
  9304. e._vts = Date.now();
  9305. } else if (e._vts <= invoker.attached) {
  9306. return;
  9307. }
  9308. callWithAsyncErrorHandling(
  9309. patchStopImmediatePropagation(e, invoker.value),
  9310. instance,
  9311. 5,
  9312. [e]
  9313. );
  9314. };
  9315. invoker.value = initialValue;
  9316. invoker.attached = getNow();
  9317. return invoker;
  9318. }
  9319. function patchStopImmediatePropagation(e, value) {
  9320. if (isArray(value)) {
  9321. const originalStop = e.stopImmediatePropagation;
  9322. e.stopImmediatePropagation = () => {
  9323. originalStop.call(e);
  9324. e._stopped = true;
  9325. };
  9326. return value.map((fn) => (e2) => !e2._stopped && fn && fn(e2));
  9327. } else {
  9328. return value;
  9329. }
  9330. }
  9331. const nativeOnRE = /^on[a-z]/;
  9332. const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
  9333. if (key === "class") {
  9334. patchClass(el, nextValue, isSVG);
  9335. } else if (key === "style") {
  9336. patchStyle(el, prevValue, nextValue);
  9337. } else if (isOn(key)) {
  9338. if (!isModelListener(key)) {
  9339. patchEvent(el, key, prevValue, nextValue, parentComponent);
  9340. }
  9341. } else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) {
  9342. patchDOMProp(
  9343. el,
  9344. key,
  9345. nextValue,
  9346. prevChildren,
  9347. parentComponent,
  9348. parentSuspense,
  9349. unmountChildren
  9350. );
  9351. } else {
  9352. if (key === "true-value") {
  9353. el._trueValue = nextValue;
  9354. } else if (key === "false-value") {
  9355. el._falseValue = nextValue;
  9356. }
  9357. patchAttr(el, key, nextValue, isSVG);
  9358. }
  9359. };
  9360. function shouldSetAsProp(el, key, value, isSVG) {
  9361. if (isSVG) {
  9362. if (key === "innerHTML" || key === "textContent") {
  9363. return true;
  9364. }
  9365. if (key in el && nativeOnRE.test(key) && isFunction(value)) {
  9366. return true;
  9367. }
  9368. return false;
  9369. }
  9370. if (key === "spellcheck" || key === "draggable" || key === "translate") {
  9371. return false;
  9372. }
  9373. if (key === "form") {
  9374. return false;
  9375. }
  9376. if (key === "list" && el.tagName === "INPUT") {
  9377. return false;
  9378. }
  9379. if (key === "type" && el.tagName === "TEXTAREA") {
  9380. return false;
  9381. }
  9382. if (nativeOnRE.test(key) && isString(value)) {
  9383. return false;
  9384. }
  9385. return key in el;
  9386. }
  9387. function defineCustomElement(options, hydrate2) {
  9388. const Comp = defineComponent(options);
  9389. class VueCustomElement extends VueElement {
  9390. constructor(initialProps) {
  9391. super(Comp, initialProps, hydrate2);
  9392. }
  9393. }
  9394. VueCustomElement.def = Comp;
  9395. return VueCustomElement;
  9396. }
  9397. const defineSSRCustomElement = (options) => {
  9398. return defineCustomElement(options, hydrate);
  9399. };
  9400. const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
  9401. };
  9402. class VueElement extends BaseClass {
  9403. constructor(_def, _props = {}, hydrate2) {
  9404. super();
  9405. this._def = _def;
  9406. this._props = _props;
  9407. /**
  9408. * @internal
  9409. */
  9410. this._instance = null;
  9411. this._connected = false;
  9412. this._resolved = false;
  9413. this._numberProps = null;
  9414. if (this.shadowRoot && hydrate2) {
  9415. hydrate2(this._createVNode(), this.shadowRoot);
  9416. } else {
  9417. if (this.shadowRoot) {
  9418. warn(
  9419. `Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
  9420. );
  9421. }
  9422. this.attachShadow({ mode: "open" });
  9423. if (!this._def.__asyncLoader) {
  9424. this._resolveProps(this._def);
  9425. }
  9426. }
  9427. }
  9428. connectedCallback() {
  9429. this._connected = true;
  9430. if (!this._instance) {
  9431. if (this._resolved) {
  9432. this._update();
  9433. } else {
  9434. this._resolveDef();
  9435. }
  9436. }
  9437. }
  9438. disconnectedCallback() {
  9439. this._connected = false;
  9440. nextTick(() => {
  9441. if (!this._connected) {
  9442. render(null, this.shadowRoot);
  9443. this._instance = null;
  9444. }
  9445. });
  9446. }
  9447. /**
  9448. * resolve inner component definition (handle possible async component)
  9449. */
  9450. _resolveDef() {
  9451. this._resolved = true;
  9452. for (let i = 0; i < this.attributes.length; i++) {
  9453. this._setAttr(this.attributes[i].name);
  9454. }
  9455. new MutationObserver((mutations) => {
  9456. for (const m of mutations) {
  9457. this._setAttr(m.attributeName);
  9458. }
  9459. }).observe(this, { attributes: true });
  9460. const resolve = (def, isAsync = false) => {
  9461. const { props, styles } = def;
  9462. let numberProps;
  9463. if (props && !isArray(props)) {
  9464. for (const key in props) {
  9465. const opt = props[key];
  9466. if (opt === Number || opt && opt.type === Number) {
  9467. if (key in this._props) {
  9468. this._props[key] = toNumber(this._props[key]);
  9469. }
  9470. (numberProps || (numberProps = /* @__PURE__ */ Object.create(null)))[camelize(key)] = true;
  9471. }
  9472. }
  9473. }
  9474. this._numberProps = numberProps;
  9475. if (isAsync) {
  9476. this._resolveProps(def);
  9477. }
  9478. this._applyStyles(styles);
  9479. this._update();
  9480. };
  9481. const asyncDef = this._def.__asyncLoader;
  9482. if (asyncDef) {
  9483. asyncDef().then((def) => resolve(def, true));
  9484. } else {
  9485. resolve(this._def);
  9486. }
  9487. }
  9488. _resolveProps(def) {
  9489. const { props } = def;
  9490. const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
  9491. for (const key of Object.keys(this)) {
  9492. if (key[0] !== "_" && declaredPropKeys.includes(key)) {
  9493. this._setProp(key, this[key], true, false);
  9494. }
  9495. }
  9496. for (const key of declaredPropKeys.map(camelize)) {
  9497. Object.defineProperty(this, key, {
  9498. get() {
  9499. return this._getProp(key);
  9500. },
  9501. set(val) {
  9502. this._setProp(key, val);
  9503. }
  9504. });
  9505. }
  9506. }
  9507. _setAttr(key) {
  9508. let value = this.getAttribute(key);
  9509. const camelKey = camelize(key);
  9510. if (this._numberProps && this._numberProps[camelKey]) {
  9511. value = toNumber(value);
  9512. }
  9513. this._setProp(camelKey, value, false);
  9514. }
  9515. /**
  9516. * @internal
  9517. */
  9518. _getProp(key) {
  9519. return this._props[key];
  9520. }
  9521. /**
  9522. * @internal
  9523. */
  9524. _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
  9525. if (val !== this._props[key]) {
  9526. this._props[key] = val;
  9527. if (shouldUpdate && this._instance) {
  9528. this._update();
  9529. }
  9530. if (shouldReflect) {
  9531. if (val === true) {
  9532. this.setAttribute(hyphenate(key), "");
  9533. } else if (typeof val === "string" || typeof val === "number") {
  9534. this.setAttribute(hyphenate(key), val + "");
  9535. } else if (!val) {
  9536. this.removeAttribute(hyphenate(key));
  9537. }
  9538. }
  9539. }
  9540. }
  9541. _update() {
  9542. render(this._createVNode(), this.shadowRoot);
  9543. }
  9544. _createVNode() {
  9545. const vnode = createVNode(this._def, extend({}, this._props));
  9546. if (!this._instance) {
  9547. vnode.ce = (instance) => {
  9548. this._instance = instance;
  9549. instance.isCE = true;
  9550. {
  9551. instance.ceReload = (newStyles) => {
  9552. if (this._styles) {
  9553. this._styles.forEach((s) => this.shadowRoot.removeChild(s));
  9554. this._styles.length = 0;
  9555. }
  9556. this._applyStyles(newStyles);
  9557. this._instance = null;
  9558. this._update();
  9559. };
  9560. }
  9561. const dispatch = (event, args) => {
  9562. this.dispatchEvent(
  9563. new CustomEvent(event, {
  9564. detail: args
  9565. })
  9566. );
  9567. };
  9568. instance.emit = (event, ...args) => {
  9569. dispatch(event, args);
  9570. if (hyphenate(event) !== event) {
  9571. dispatch(hyphenate(event), args);
  9572. }
  9573. };
  9574. let parent = this;
  9575. while (parent = parent && (parent.parentNode || parent.host)) {
  9576. if (parent instanceof VueElement) {
  9577. instance.parent = parent._instance;
  9578. instance.provides = parent._instance.provides;
  9579. break;
  9580. }
  9581. }
  9582. };
  9583. }
  9584. return vnode;
  9585. }
  9586. _applyStyles(styles) {
  9587. if (styles) {
  9588. styles.forEach((css) => {
  9589. const s = document.createElement("style");
  9590. s.textContent = css;
  9591. this.shadowRoot.appendChild(s);
  9592. {
  9593. (this._styles || (this._styles = [])).push(s);
  9594. }
  9595. });
  9596. }
  9597. }
  9598. }
  9599. function useCssModule(name = "$style") {
  9600. {
  9601. const instance = getCurrentInstance();
  9602. if (!instance) {
  9603. warn(`useCssModule must be called inside setup()`);
  9604. return EMPTY_OBJ;
  9605. }
  9606. const modules = instance.type.__cssModules;
  9607. if (!modules) {
  9608. warn(`Current instance does not have CSS modules injected.`);
  9609. return EMPTY_OBJ;
  9610. }
  9611. const mod = modules[name];
  9612. if (!mod) {
  9613. warn(`Current instance does not have CSS module named "${name}".`);
  9614. return EMPTY_OBJ;
  9615. }
  9616. return mod;
  9617. }
  9618. }
  9619. function useCssVars(getter) {
  9620. const instance = getCurrentInstance();
  9621. if (!instance) {
  9622. warn(`useCssVars is called without current active component instance.`);
  9623. return;
  9624. }
  9625. const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
  9626. Array.from(
  9627. document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
  9628. ).forEach((node) => setVarsOnNode(node, vars));
  9629. };
  9630. const setVars = () => {
  9631. const vars = getter(instance.proxy);
  9632. setVarsOnVNode(instance.subTree, vars);
  9633. updateTeleports(vars);
  9634. };
  9635. watchPostEffect(setVars);
  9636. onMounted(() => {
  9637. const ob = new MutationObserver(setVars);
  9638. ob.observe(instance.subTree.el.parentNode, { childList: true });
  9639. onUnmounted(() => ob.disconnect());
  9640. });
  9641. }
  9642. function setVarsOnVNode(vnode, vars) {
  9643. if (vnode.shapeFlag & 128) {
  9644. const suspense = vnode.suspense;
  9645. vnode = suspense.activeBranch;
  9646. if (suspense.pendingBranch && !suspense.isHydrating) {
  9647. suspense.effects.push(() => {
  9648. setVarsOnVNode(suspense.activeBranch, vars);
  9649. });
  9650. }
  9651. }
  9652. while (vnode.component) {
  9653. vnode = vnode.component.subTree;
  9654. }
  9655. if (vnode.shapeFlag & 1 && vnode.el) {
  9656. setVarsOnNode(vnode.el, vars);
  9657. } else if (vnode.type === Fragment) {
  9658. vnode.children.forEach((c) => setVarsOnVNode(c, vars));
  9659. } else if (vnode.type === Static) {
  9660. let { el, anchor } = vnode;
  9661. while (el) {
  9662. setVarsOnNode(el, vars);
  9663. if (el === anchor)
  9664. break;
  9665. el = el.nextSibling;
  9666. }
  9667. }
  9668. }
  9669. function setVarsOnNode(el, vars) {
  9670. if (el.nodeType === 1) {
  9671. const style = el.style;
  9672. for (const key in vars) {
  9673. style.setProperty(`--${key}`, vars[key]);
  9674. }
  9675. }
  9676. }
  9677. const TRANSITION$1 = "transition";
  9678. const ANIMATION = "animation";
  9679. const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
  9680. Transition.displayName = "Transition";
  9681. const DOMTransitionPropsValidators = {
  9682. name: String,
  9683. type: String,
  9684. css: {
  9685. type: Boolean,
  9686. default: true
  9687. },
  9688. duration: [String, Number, Object],
  9689. enterFromClass: String,
  9690. enterActiveClass: String,
  9691. enterToClass: String,
  9692. appearFromClass: String,
  9693. appearActiveClass: String,
  9694. appearToClass: String,
  9695. leaveFromClass: String,
  9696. leaveActiveClass: String,
  9697. leaveToClass: String
  9698. };
  9699. const TransitionPropsValidators = Transition.props = /* @__PURE__ */ extend(
  9700. {},
  9701. BaseTransitionPropsValidators,
  9702. DOMTransitionPropsValidators
  9703. );
  9704. const callHook = (hook, args = []) => {
  9705. if (isArray(hook)) {
  9706. hook.forEach((h2) => h2(...args));
  9707. } else if (hook) {
  9708. hook(...args);
  9709. }
  9710. };
  9711. const hasExplicitCallback = (hook) => {
  9712. return hook ? isArray(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
  9713. };
  9714. function resolveTransitionProps(rawProps) {
  9715. const baseProps = {};
  9716. for (const key in rawProps) {
  9717. if (!(key in DOMTransitionPropsValidators)) {
  9718. baseProps[key] = rawProps[key];
  9719. }
  9720. }
  9721. if (rawProps.css === false) {
  9722. return baseProps;
  9723. }
  9724. const {
  9725. name = "v",
  9726. type,
  9727. duration,
  9728. enterFromClass = `${name}-enter-from`,
  9729. enterActiveClass = `${name}-enter-active`,
  9730. enterToClass = `${name}-enter-to`,
  9731. appearFromClass = enterFromClass,
  9732. appearActiveClass = enterActiveClass,
  9733. appearToClass = enterToClass,
  9734. leaveFromClass = `${name}-leave-from`,
  9735. leaveActiveClass = `${name}-leave-active`,
  9736. leaveToClass = `${name}-leave-to`
  9737. } = rawProps;
  9738. const durations = normalizeDuration(duration);
  9739. const enterDuration = durations && durations[0];
  9740. const leaveDuration = durations && durations[1];
  9741. const {
  9742. onBeforeEnter,
  9743. onEnter,
  9744. onEnterCancelled,
  9745. onLeave,
  9746. onLeaveCancelled,
  9747. onBeforeAppear = onBeforeEnter,
  9748. onAppear = onEnter,
  9749. onAppearCancelled = onEnterCancelled
  9750. } = baseProps;
  9751. const finishEnter = (el, isAppear, done) => {
  9752. removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
  9753. removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
  9754. done && done();
  9755. };
  9756. const finishLeave = (el, done) => {
  9757. el._isLeaving = false;
  9758. removeTransitionClass(el, leaveFromClass);
  9759. removeTransitionClass(el, leaveToClass);
  9760. removeTransitionClass(el, leaveActiveClass);
  9761. done && done();
  9762. };
  9763. const makeEnterHook = (isAppear) => {
  9764. return (el, done) => {
  9765. const hook = isAppear ? onAppear : onEnter;
  9766. const resolve = () => finishEnter(el, isAppear, done);
  9767. callHook(hook, [el, resolve]);
  9768. nextFrame(() => {
  9769. removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
  9770. addTransitionClass(el, isAppear ? appearToClass : enterToClass);
  9771. if (!hasExplicitCallback(hook)) {
  9772. whenTransitionEnds(el, type, enterDuration, resolve);
  9773. }
  9774. });
  9775. };
  9776. };
  9777. return extend(baseProps, {
  9778. onBeforeEnter(el) {
  9779. callHook(onBeforeEnter, [el]);
  9780. addTransitionClass(el, enterFromClass);
  9781. addTransitionClass(el, enterActiveClass);
  9782. },
  9783. onBeforeAppear(el) {
  9784. callHook(onBeforeAppear, [el]);
  9785. addTransitionClass(el, appearFromClass);
  9786. addTransitionClass(el, appearActiveClass);
  9787. },
  9788. onEnter: makeEnterHook(false),
  9789. onAppear: makeEnterHook(true),
  9790. onLeave(el, done) {
  9791. el._isLeaving = true;
  9792. const resolve = () => finishLeave(el, done);
  9793. addTransitionClass(el, leaveFromClass);
  9794. forceReflow();
  9795. addTransitionClass(el, leaveActiveClass);
  9796. nextFrame(() => {
  9797. if (!el._isLeaving) {
  9798. return;
  9799. }
  9800. removeTransitionClass(el, leaveFromClass);
  9801. addTransitionClass(el, leaveToClass);
  9802. if (!hasExplicitCallback(onLeave)) {
  9803. whenTransitionEnds(el, type, leaveDuration, resolve);
  9804. }
  9805. });
  9806. callHook(onLeave, [el, resolve]);
  9807. },
  9808. onEnterCancelled(el) {
  9809. finishEnter(el, false);
  9810. callHook(onEnterCancelled, [el]);
  9811. },
  9812. onAppearCancelled(el) {
  9813. finishEnter(el, true);
  9814. callHook(onAppearCancelled, [el]);
  9815. },
  9816. onLeaveCancelled(el) {
  9817. finishLeave(el);
  9818. callHook(onLeaveCancelled, [el]);
  9819. }
  9820. });
  9821. }
  9822. function normalizeDuration(duration) {
  9823. if (duration == null) {
  9824. return null;
  9825. } else if (isObject(duration)) {
  9826. return [NumberOf(duration.enter), NumberOf(duration.leave)];
  9827. } else {
  9828. const n = NumberOf(duration);
  9829. return [n, n];
  9830. }
  9831. }
  9832. function NumberOf(val) {
  9833. const res = toNumber(val);
  9834. {
  9835. assertNumber(res, "<transition> explicit duration");
  9836. }
  9837. return res;
  9838. }
  9839. function addTransitionClass(el, cls) {
  9840. cls.split(/\s+/).forEach((c) => c && el.classList.add(c));
  9841. (el._vtc || (el._vtc = /* @__PURE__ */ new Set())).add(cls);
  9842. }
  9843. function removeTransitionClass(el, cls) {
  9844. cls.split(/\s+/).forEach((c) => c && el.classList.remove(c));
  9845. const { _vtc } = el;
  9846. if (_vtc) {
  9847. _vtc.delete(cls);
  9848. if (!_vtc.size) {
  9849. el._vtc = void 0;
  9850. }
  9851. }
  9852. }
  9853. function nextFrame(cb) {
  9854. requestAnimationFrame(() => {
  9855. requestAnimationFrame(cb);
  9856. });
  9857. }
  9858. let endId = 0;
  9859. function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
  9860. const id = el._endId = ++endId;
  9861. const resolveIfNotStale = () => {
  9862. if (id === el._endId) {
  9863. resolve();
  9864. }
  9865. };
  9866. if (explicitTimeout) {
  9867. return setTimeout(resolveIfNotStale, explicitTimeout);
  9868. }
  9869. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  9870. if (!type) {
  9871. return resolve();
  9872. }
  9873. const endEvent = type + "end";
  9874. let ended = 0;
  9875. const end = () => {
  9876. el.removeEventListener(endEvent, onEnd);
  9877. resolveIfNotStale();
  9878. };
  9879. const onEnd = (e) => {
  9880. if (e.target === el && ++ended >= propCount) {
  9881. end();
  9882. }
  9883. };
  9884. setTimeout(() => {
  9885. if (ended < propCount) {
  9886. end();
  9887. }
  9888. }, timeout + 1);
  9889. el.addEventListener(endEvent, onEnd);
  9890. }
  9891. function getTransitionInfo(el, expectedType) {
  9892. const styles = window.getComputedStyle(el);
  9893. const getStyleProperties = (key) => (styles[key] || "").split(", ");
  9894. const transitionDelays = getStyleProperties(`${TRANSITION$1}Delay`);
  9895. const transitionDurations = getStyleProperties(`${TRANSITION$1}Duration`);
  9896. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  9897. const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
  9898. const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
  9899. const animationTimeout = getTimeout(animationDelays, animationDurations);
  9900. let type = null;
  9901. let timeout = 0;
  9902. let propCount = 0;
  9903. if (expectedType === TRANSITION$1) {
  9904. if (transitionTimeout > 0) {
  9905. type = TRANSITION$1;
  9906. timeout = transitionTimeout;
  9907. propCount = transitionDurations.length;
  9908. }
  9909. } else if (expectedType === ANIMATION) {
  9910. if (animationTimeout > 0) {
  9911. type = ANIMATION;
  9912. timeout = animationTimeout;
  9913. propCount = animationDurations.length;
  9914. }
  9915. } else {
  9916. timeout = Math.max(transitionTimeout, animationTimeout);
  9917. type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION$1 : ANIMATION : null;
  9918. propCount = type ? type === TRANSITION$1 ? transitionDurations.length : animationDurations.length : 0;
  9919. }
  9920. const hasTransform = type === TRANSITION$1 && /\b(transform|all)(,|$)/.test(
  9921. getStyleProperties(`${TRANSITION$1}Property`).toString()
  9922. );
  9923. return {
  9924. type,
  9925. timeout,
  9926. propCount,
  9927. hasTransform
  9928. };
  9929. }
  9930. function getTimeout(delays, durations) {
  9931. while (delays.length < durations.length) {
  9932. delays = delays.concat(delays);
  9933. }
  9934. return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
  9935. }
  9936. function toMs(s) {
  9937. return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
  9938. }
  9939. function forceReflow() {
  9940. return document.body.offsetHeight;
  9941. }
  9942. const positionMap = /* @__PURE__ */ new WeakMap();
  9943. const newPositionMap = /* @__PURE__ */ new WeakMap();
  9944. const TransitionGroupImpl = {
  9945. name: "TransitionGroup",
  9946. props: /* @__PURE__ */ extend({}, TransitionPropsValidators, {
  9947. tag: String,
  9948. moveClass: String
  9949. }),
  9950. setup(props, { slots }) {
  9951. const instance = getCurrentInstance();
  9952. const state = useTransitionState();
  9953. let prevChildren;
  9954. let children;
  9955. onUpdated(() => {
  9956. if (!prevChildren.length) {
  9957. return;
  9958. }
  9959. const moveClass = props.moveClass || `${props.name || "v"}-move`;
  9960. if (!hasCSSTransform(
  9961. prevChildren[0].el,
  9962. instance.vnode.el,
  9963. moveClass
  9964. )) {
  9965. return;
  9966. }
  9967. prevChildren.forEach(callPendingCbs);
  9968. prevChildren.forEach(recordPosition);
  9969. const movedChildren = prevChildren.filter(applyTranslation);
  9970. forceReflow();
  9971. movedChildren.forEach((c) => {
  9972. const el = c.el;
  9973. const style = el.style;
  9974. addTransitionClass(el, moveClass);
  9975. style.transform = style.webkitTransform = style.transitionDuration = "";
  9976. const cb = el._moveCb = (e) => {
  9977. if (e && e.target !== el) {
  9978. return;
  9979. }
  9980. if (!e || /transform$/.test(e.propertyName)) {
  9981. el.removeEventListener("transitionend", cb);
  9982. el._moveCb = null;
  9983. removeTransitionClass(el, moveClass);
  9984. }
  9985. };
  9986. el.addEventListener("transitionend", cb);
  9987. });
  9988. });
  9989. return () => {
  9990. const rawProps = toRaw(props);
  9991. const cssTransitionProps = resolveTransitionProps(rawProps);
  9992. let tag = rawProps.tag || Fragment;
  9993. prevChildren = children;
  9994. children = slots.default ? getTransitionRawChildren(slots.default()) : [];
  9995. for (let i = 0; i < children.length; i++) {
  9996. const child = children[i];
  9997. if (child.key != null) {
  9998. setTransitionHooks(
  9999. child,
  10000. resolveTransitionHooks(child, cssTransitionProps, state, instance)
  10001. );
  10002. } else {
  10003. warn(`<TransitionGroup> children must be keyed.`);
  10004. }
  10005. }
  10006. if (prevChildren) {
  10007. for (let i = 0; i < prevChildren.length; i++) {
  10008. const child = prevChildren[i];
  10009. setTransitionHooks(
  10010. child,
  10011. resolveTransitionHooks(child, cssTransitionProps, state, instance)
  10012. );
  10013. positionMap.set(child, child.el.getBoundingClientRect());
  10014. }
  10015. }
  10016. return createVNode(tag, null, children);
  10017. };
  10018. }
  10019. };
  10020. const removeMode = (props) => delete props.mode;
  10021. /* @__PURE__ */ removeMode(TransitionGroupImpl.props);
  10022. const TransitionGroup = TransitionGroupImpl;
  10023. function callPendingCbs(c) {
  10024. const el = c.el;
  10025. if (el._moveCb) {
  10026. el._moveCb();
  10027. }
  10028. if (el._enterCb) {
  10029. el._enterCb();
  10030. }
  10031. }
  10032. function recordPosition(c) {
  10033. newPositionMap.set(c, c.el.getBoundingClientRect());
  10034. }
  10035. function applyTranslation(c) {
  10036. const oldPos = positionMap.get(c);
  10037. const newPos = newPositionMap.get(c);
  10038. const dx = oldPos.left - newPos.left;
  10039. const dy = oldPos.top - newPos.top;
  10040. if (dx || dy) {
  10041. const s = c.el.style;
  10042. s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
  10043. s.transitionDuration = "0s";
  10044. return c;
  10045. }
  10046. }
  10047. function hasCSSTransform(el, root, moveClass) {
  10048. const clone = el.cloneNode();
  10049. if (el._vtc) {
  10050. el._vtc.forEach((cls) => {
  10051. cls.split(/\s+/).forEach((c) => c && clone.classList.remove(c));
  10052. });
  10053. }
  10054. moveClass.split(/\s+/).forEach((c) => c && clone.classList.add(c));
  10055. clone.style.display = "none";
  10056. const container = root.nodeType === 1 ? root : root.parentNode;
  10057. container.appendChild(clone);
  10058. const { hasTransform } = getTransitionInfo(clone);
  10059. container.removeChild(clone);
  10060. return hasTransform;
  10061. }
  10062. const getModelAssigner = (vnode) => {
  10063. const fn = vnode.props["onUpdate:modelValue"] || false;
  10064. return isArray(fn) ? (value) => invokeArrayFns(fn, value) : fn;
  10065. };
  10066. function onCompositionStart(e) {
  10067. e.target.composing = true;
  10068. }
  10069. function onCompositionEnd(e) {
  10070. const target = e.target;
  10071. if (target.composing) {
  10072. target.composing = false;
  10073. target.dispatchEvent(new Event("input"));
  10074. }
  10075. }
  10076. const vModelText = {
  10077. created(el, { modifiers: { lazy, trim, number } }, vnode) {
  10078. el._assign = getModelAssigner(vnode);
  10079. const castToNumber = number || vnode.props && vnode.props.type === "number";
  10080. addEventListener(el, lazy ? "change" : "input", (e) => {
  10081. if (e.target.composing)
  10082. return;
  10083. let domValue = el.value;
  10084. if (trim) {
  10085. domValue = domValue.trim();
  10086. }
  10087. if (castToNumber) {
  10088. domValue = looseToNumber(domValue);
  10089. }
  10090. el._assign(domValue);
  10091. });
  10092. if (trim) {
  10093. addEventListener(el, "change", () => {
  10094. el.value = el.value.trim();
  10095. });
  10096. }
  10097. if (!lazy) {
  10098. addEventListener(el, "compositionstart", onCompositionStart);
  10099. addEventListener(el, "compositionend", onCompositionEnd);
  10100. addEventListener(el, "change", onCompositionEnd);
  10101. }
  10102. },
  10103. // set value on mounted so it's after min/max for type="range"
  10104. mounted(el, { value }) {
  10105. el.value = value == null ? "" : value;
  10106. },
  10107. beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
  10108. el._assign = getModelAssigner(vnode);
  10109. if (el.composing)
  10110. return;
  10111. if (document.activeElement === el && el.type !== "range") {
  10112. if (lazy) {
  10113. return;
  10114. }
  10115. if (trim && el.value.trim() === value) {
  10116. return;
  10117. }
  10118. if ((number || el.type === "number") && looseToNumber(el.value) === value) {
  10119. return;
  10120. }
  10121. }
  10122. const newValue = value == null ? "" : value;
  10123. if (el.value !== newValue) {
  10124. el.value = newValue;
  10125. }
  10126. }
  10127. };
  10128. const vModelCheckbox = {
  10129. // #4096 array checkboxes need to be deep traversed
  10130. deep: true,
  10131. created(el, _, vnode) {
  10132. el._assign = getModelAssigner(vnode);
  10133. addEventListener(el, "change", () => {
  10134. const modelValue = el._modelValue;
  10135. const elementValue = getValue(el);
  10136. const checked = el.checked;
  10137. const assign = el._assign;
  10138. if (isArray(modelValue)) {
  10139. const index = looseIndexOf(modelValue, elementValue);
  10140. const found = index !== -1;
  10141. if (checked && !found) {
  10142. assign(modelValue.concat(elementValue));
  10143. } else if (!checked && found) {
  10144. const filtered = [...modelValue];
  10145. filtered.splice(index, 1);
  10146. assign(filtered);
  10147. }
  10148. } else if (isSet(modelValue)) {
  10149. const cloned = new Set(modelValue);
  10150. if (checked) {
  10151. cloned.add(elementValue);
  10152. } else {
  10153. cloned.delete(elementValue);
  10154. }
  10155. assign(cloned);
  10156. } else {
  10157. assign(getCheckboxValue(el, checked));
  10158. }
  10159. });
  10160. },
  10161. // set initial checked on mount to wait for true-value/false-value
  10162. mounted: setChecked,
  10163. beforeUpdate(el, binding, vnode) {
  10164. el._assign = getModelAssigner(vnode);
  10165. setChecked(el, binding, vnode);
  10166. }
  10167. };
  10168. function setChecked(el, { value, oldValue }, vnode) {
  10169. el._modelValue = value;
  10170. if (isArray(value)) {
  10171. el.checked = looseIndexOf(value, vnode.props.value) > -1;
  10172. } else if (isSet(value)) {
  10173. el.checked = value.has(vnode.props.value);
  10174. } else if (value !== oldValue) {
  10175. el.checked = looseEqual(value, getCheckboxValue(el, true));
  10176. }
  10177. }
  10178. const vModelRadio = {
  10179. created(el, { value }, vnode) {
  10180. el.checked = looseEqual(value, vnode.props.value);
  10181. el._assign = getModelAssigner(vnode);
  10182. addEventListener(el, "change", () => {
  10183. el._assign(getValue(el));
  10184. });
  10185. },
  10186. beforeUpdate(el, { value, oldValue }, vnode) {
  10187. el._assign = getModelAssigner(vnode);
  10188. if (value !== oldValue) {
  10189. el.checked = looseEqual(value, vnode.props.value);
  10190. }
  10191. }
  10192. };
  10193. const vModelSelect = {
  10194. // <select multiple> value need to be deep traversed
  10195. deep: true,
  10196. created(el, { value, modifiers: { number } }, vnode) {
  10197. const isSetModel = isSet(value);
  10198. addEventListener(el, "change", () => {
  10199. const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
  10200. (o) => number ? looseToNumber(getValue(o)) : getValue(o)
  10201. );
  10202. el._assign(
  10203. el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
  10204. );
  10205. });
  10206. el._assign = getModelAssigner(vnode);
  10207. },
  10208. // set value in mounted & updated because <select> relies on its children
  10209. // <option>s.
  10210. mounted(el, { value }) {
  10211. setSelected(el, value);
  10212. },
  10213. beforeUpdate(el, _binding, vnode) {
  10214. el._assign = getModelAssigner(vnode);
  10215. },
  10216. updated(el, { value }) {
  10217. setSelected(el, value);
  10218. }
  10219. };
  10220. function setSelected(el, value) {
  10221. const isMultiple = el.multiple;
  10222. if (isMultiple && !isArray(value) && !isSet(value)) {
  10223. warn(
  10224. `<select multiple v-model> expects an Array or Set value for its binding, but got ${Object.prototype.toString.call(value).slice(8, -1)}.`
  10225. );
  10226. return;
  10227. }
  10228. for (let i = 0, l = el.options.length; i < l; i++) {
  10229. const option = el.options[i];
  10230. const optionValue = getValue(option);
  10231. if (isMultiple) {
  10232. if (isArray(value)) {
  10233. option.selected = looseIndexOf(value, optionValue) > -1;
  10234. } else {
  10235. option.selected = value.has(optionValue);
  10236. }
  10237. } else {
  10238. if (looseEqual(getValue(option), value)) {
  10239. if (el.selectedIndex !== i)
  10240. el.selectedIndex = i;
  10241. return;
  10242. }
  10243. }
  10244. }
  10245. if (!isMultiple && el.selectedIndex !== -1) {
  10246. el.selectedIndex = -1;
  10247. }
  10248. }
  10249. function getValue(el) {
  10250. return "_value" in el ? el._value : el.value;
  10251. }
  10252. function getCheckboxValue(el, checked) {
  10253. const key = checked ? "_trueValue" : "_falseValue";
  10254. return key in el ? el[key] : checked;
  10255. }
  10256. const vModelDynamic = {
  10257. created(el, binding, vnode) {
  10258. callModelHook(el, binding, vnode, null, "created");
  10259. },
  10260. mounted(el, binding, vnode) {
  10261. callModelHook(el, binding, vnode, null, "mounted");
  10262. },
  10263. beforeUpdate(el, binding, vnode, prevVNode) {
  10264. callModelHook(el, binding, vnode, prevVNode, "beforeUpdate");
  10265. },
  10266. updated(el, binding, vnode, prevVNode) {
  10267. callModelHook(el, binding, vnode, prevVNode, "updated");
  10268. }
  10269. };
  10270. function resolveDynamicModel(tagName, type) {
  10271. switch (tagName) {
  10272. case "SELECT":
  10273. return vModelSelect;
  10274. case "TEXTAREA":
  10275. return vModelText;
  10276. default:
  10277. switch (type) {
  10278. case "checkbox":
  10279. return vModelCheckbox;
  10280. case "radio":
  10281. return vModelRadio;
  10282. default:
  10283. return vModelText;
  10284. }
  10285. }
  10286. }
  10287. function callModelHook(el, binding, vnode, prevVNode, hook) {
  10288. const modelToUse = resolveDynamicModel(
  10289. el.tagName,
  10290. vnode.props && vnode.props.type
  10291. );
  10292. const fn = modelToUse[hook];
  10293. fn && fn(el, binding, vnode, prevVNode);
  10294. }
  10295. const systemModifiers = ["ctrl", "shift", "alt", "meta"];
  10296. const modifierGuards = {
  10297. stop: (e) => e.stopPropagation(),
  10298. prevent: (e) => e.preventDefault(),
  10299. self: (e) => e.target !== e.currentTarget,
  10300. ctrl: (e) => !e.ctrlKey,
  10301. shift: (e) => !e.shiftKey,
  10302. alt: (e) => !e.altKey,
  10303. meta: (e) => !e.metaKey,
  10304. left: (e) => "button" in e && e.button !== 0,
  10305. middle: (e) => "button" in e && e.button !== 1,
  10306. right: (e) => "button" in e && e.button !== 2,
  10307. exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
  10308. };
  10309. const withModifiers = (fn, modifiers) => {
  10310. return (event, ...args) => {
  10311. for (let i = 0; i < modifiers.length; i++) {
  10312. const guard = modifierGuards[modifiers[i]];
  10313. if (guard && guard(event, modifiers))
  10314. return;
  10315. }
  10316. return fn(event, ...args);
  10317. };
  10318. };
  10319. const keyNames = {
  10320. esc: "escape",
  10321. space: " ",
  10322. up: "arrow-up",
  10323. left: "arrow-left",
  10324. right: "arrow-right",
  10325. down: "arrow-down",
  10326. delete: "backspace"
  10327. };
  10328. const withKeys = (fn, modifiers) => {
  10329. return (event) => {
  10330. if (!("key" in event)) {
  10331. return;
  10332. }
  10333. const eventKey = hyphenate(event.key);
  10334. if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
  10335. return fn(event);
  10336. }
  10337. };
  10338. };
  10339. const vShow = {
  10340. beforeMount(el, { value }, { transition }) {
  10341. el._vod = el.style.display === "none" ? "" : el.style.display;
  10342. if (transition && value) {
  10343. transition.beforeEnter(el);
  10344. } else {
  10345. setDisplay(el, value);
  10346. }
  10347. },
  10348. mounted(el, { value }, { transition }) {
  10349. if (transition && value) {
  10350. transition.enter(el);
  10351. }
  10352. },
  10353. updated(el, { value, oldValue }, { transition }) {
  10354. if (!value === !oldValue)
  10355. return;
  10356. if (transition) {
  10357. if (value) {
  10358. transition.beforeEnter(el);
  10359. setDisplay(el, true);
  10360. transition.enter(el);
  10361. } else {
  10362. transition.leave(el, () => {
  10363. setDisplay(el, false);
  10364. });
  10365. }
  10366. } else {
  10367. setDisplay(el, value);
  10368. }
  10369. },
  10370. beforeUnmount(el, { value }) {
  10371. setDisplay(el, value);
  10372. }
  10373. };
  10374. function setDisplay(el, value) {
  10375. el.style.display = value ? el._vod : "none";
  10376. }
  10377. const rendererOptions = /* @__PURE__ */ extend({ patchProp }, nodeOps);
  10378. let renderer;
  10379. let enabledHydration = false;
  10380. function ensureRenderer() {
  10381. return renderer || (renderer = createRenderer(rendererOptions));
  10382. }
  10383. function ensureHydrationRenderer() {
  10384. renderer = enabledHydration ? renderer : createHydrationRenderer(rendererOptions);
  10385. enabledHydration = true;
  10386. return renderer;
  10387. }
  10388. const render = (...args) => {
  10389. ensureRenderer().render(...args);
  10390. };
  10391. const hydrate = (...args) => {
  10392. ensureHydrationRenderer().hydrate(...args);
  10393. };
  10394. const createApp = (...args) => {
  10395. const app = ensureRenderer().createApp(...args);
  10396. {
  10397. injectNativeTagCheck(app);
  10398. injectCompilerOptionsCheck(app);
  10399. }
  10400. const { mount } = app;
  10401. app.mount = (containerOrSelector) => {
  10402. const container = normalizeContainer(containerOrSelector);
  10403. if (!container)
  10404. return;
  10405. const component = app._component;
  10406. if (!isFunction(component) && !component.render && !component.template) {
  10407. component.template = container.innerHTML;
  10408. }
  10409. container.innerHTML = "";
  10410. const proxy = mount(container, false, container instanceof SVGElement);
  10411. if (container instanceof Element) {
  10412. container.removeAttribute("v-cloak");
  10413. container.setAttribute("data-v-app", "");
  10414. }
  10415. return proxy;
  10416. };
  10417. return app;
  10418. };
  10419. const createSSRApp = (...args) => {
  10420. const app = ensureHydrationRenderer().createApp(...args);
  10421. {
  10422. injectNativeTagCheck(app);
  10423. injectCompilerOptionsCheck(app);
  10424. }
  10425. const { mount } = app;
  10426. app.mount = (containerOrSelector) => {
  10427. const container = normalizeContainer(containerOrSelector);
  10428. if (container) {
  10429. return mount(container, true, container instanceof SVGElement);
  10430. }
  10431. };
  10432. return app;
  10433. };
  10434. function injectNativeTagCheck(app) {
  10435. Object.defineProperty(app.config, "isNativeTag", {
  10436. value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
  10437. writable: false
  10438. });
  10439. }
  10440. function injectCompilerOptionsCheck(app) {
  10441. if (isRuntimeOnly()) {
  10442. const isCustomElement = app.config.isCustomElement;
  10443. Object.defineProperty(app.config, "isCustomElement", {
  10444. get() {
  10445. return isCustomElement;
  10446. },
  10447. set() {
  10448. warn(
  10449. `The \`isCustomElement\` config option is deprecated. Use \`compilerOptions.isCustomElement\` instead.`
  10450. );
  10451. }
  10452. });
  10453. const compilerOptions = app.config.compilerOptions;
  10454. const msg = `The \`compilerOptions\` config option is only respected when using a build of Vue.js that includes the runtime compiler (aka "full build"). Since you are using the runtime-only build, \`compilerOptions\` must be passed to \`@vue/compiler-dom\` in the build setup instead.
  10455. - For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.
  10456. - For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader
  10457. - For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-sfc`;
  10458. Object.defineProperty(app.config, "compilerOptions", {
  10459. get() {
  10460. warn(msg);
  10461. return compilerOptions;
  10462. },
  10463. set() {
  10464. warn(msg);
  10465. }
  10466. });
  10467. }
  10468. }
  10469. function normalizeContainer(container) {
  10470. if (isString(container)) {
  10471. const res = document.querySelector(container);
  10472. if (!res) {
  10473. warn(
  10474. `Failed to mount app: mount target selector "${container}" returned null.`
  10475. );
  10476. }
  10477. return res;
  10478. }
  10479. if (window.ShadowRoot && container instanceof window.ShadowRoot && container.mode === "closed") {
  10480. warn(
  10481. `mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`
  10482. );
  10483. }
  10484. return container;
  10485. }
  10486. const initDirectivesForSSR = NOOP;
  10487. var runtimeDom = /*#__PURE__*/Object.freeze({
  10488. __proto__: null,
  10489. BaseTransition: BaseTransition,
  10490. BaseTransitionPropsValidators: BaseTransitionPropsValidators,
  10491. Comment: Comment,
  10492. EffectScope: EffectScope,
  10493. Fragment: Fragment,
  10494. KeepAlive: KeepAlive,
  10495. ReactiveEffect: ReactiveEffect,
  10496. Static: Static,
  10497. Suspense: Suspense,
  10498. Teleport: Teleport,
  10499. Text: Text,
  10500. Transition: Transition,
  10501. TransitionGroup: TransitionGroup,
  10502. VueElement: VueElement,
  10503. assertNumber: assertNumber,
  10504. callWithAsyncErrorHandling: callWithAsyncErrorHandling,
  10505. callWithErrorHandling: callWithErrorHandling,
  10506. camelize: camelize,
  10507. capitalize: capitalize,
  10508. cloneVNode: cloneVNode,
  10509. compatUtils: compatUtils,
  10510. computed: computed,
  10511. createApp: createApp,
  10512. createBlock: createBlock,
  10513. createCommentVNode: createCommentVNode,
  10514. createElementBlock: createElementBlock,
  10515. createElementVNode: createBaseVNode,
  10516. createHydrationRenderer: createHydrationRenderer,
  10517. createPropsRestProxy: createPropsRestProxy,
  10518. createRenderer: createRenderer,
  10519. createSSRApp: createSSRApp,
  10520. createSlots: createSlots,
  10521. createStaticVNode: createStaticVNode,
  10522. createTextVNode: createTextVNode,
  10523. createVNode: createVNode,
  10524. customRef: customRef,
  10525. defineAsyncComponent: defineAsyncComponent,
  10526. defineComponent: defineComponent,
  10527. defineCustomElement: defineCustomElement,
  10528. defineEmits: defineEmits,
  10529. defineExpose: defineExpose,
  10530. defineModel: defineModel,
  10531. defineOptions: defineOptions,
  10532. defineProps: defineProps,
  10533. defineSSRCustomElement: defineSSRCustomElement,
  10534. defineSlots: defineSlots,
  10535. get devtools () { return devtools; },
  10536. effect: effect,
  10537. effectScope: effectScope,
  10538. getCurrentInstance: getCurrentInstance,
  10539. getCurrentScope: getCurrentScope,
  10540. getTransitionRawChildren: getTransitionRawChildren,
  10541. guardReactiveProps: guardReactiveProps,
  10542. h: h,
  10543. handleError: handleError,
  10544. hasInjectionContext: hasInjectionContext,
  10545. hydrate: hydrate,
  10546. initCustomFormatter: initCustomFormatter,
  10547. initDirectivesForSSR: initDirectivesForSSR,
  10548. inject: inject,
  10549. isMemoSame: isMemoSame,
  10550. isProxy: isProxy,
  10551. isReactive: isReactive,
  10552. isReadonly: isReadonly,
  10553. isRef: isRef,
  10554. isRuntimeOnly: isRuntimeOnly,
  10555. isShallow: isShallow,
  10556. isVNode: isVNode,
  10557. markRaw: markRaw,
  10558. mergeDefaults: mergeDefaults,
  10559. mergeModels: mergeModels,
  10560. mergeProps: mergeProps,
  10561. nextTick: nextTick,
  10562. normalizeClass: normalizeClass,
  10563. normalizeProps: normalizeProps,
  10564. normalizeStyle: normalizeStyle,
  10565. onActivated: onActivated,
  10566. onBeforeMount: onBeforeMount,
  10567. onBeforeUnmount: onBeforeUnmount,
  10568. onBeforeUpdate: onBeforeUpdate,
  10569. onDeactivated: onDeactivated,
  10570. onErrorCaptured: onErrorCaptured,
  10571. onMounted: onMounted,
  10572. onRenderTracked: onRenderTracked,
  10573. onRenderTriggered: onRenderTriggered,
  10574. onScopeDispose: onScopeDispose,
  10575. onServerPrefetch: onServerPrefetch,
  10576. onUnmounted: onUnmounted,
  10577. onUpdated: onUpdated,
  10578. openBlock: openBlock,
  10579. popScopeId: popScopeId,
  10580. provide: provide,
  10581. proxyRefs: proxyRefs,
  10582. pushScopeId: pushScopeId,
  10583. queuePostFlushCb: queuePostFlushCb,
  10584. reactive: reactive,
  10585. readonly: readonly,
  10586. ref: ref,
  10587. registerRuntimeCompiler: registerRuntimeCompiler,
  10588. render: render,
  10589. renderList: renderList,
  10590. renderSlot: renderSlot,
  10591. resolveComponent: resolveComponent,
  10592. resolveDirective: resolveDirective,
  10593. resolveDynamicComponent: resolveDynamicComponent,
  10594. resolveFilter: resolveFilter,
  10595. resolveTransitionHooks: resolveTransitionHooks,
  10596. setBlockTracking: setBlockTracking,
  10597. setDevtoolsHook: setDevtoolsHook,
  10598. setTransitionHooks: setTransitionHooks,
  10599. shallowReactive: shallowReactive,
  10600. shallowReadonly: shallowReadonly,
  10601. shallowRef: shallowRef,
  10602. ssrContextKey: ssrContextKey,
  10603. ssrUtils: ssrUtils,
  10604. stop: stop,
  10605. toDisplayString: toDisplayString,
  10606. toHandlerKey: toHandlerKey,
  10607. toHandlers: toHandlers,
  10608. toRaw: toRaw,
  10609. toRef: toRef,
  10610. toRefs: toRefs,
  10611. toValue: toValue,
  10612. transformVNodeArgs: transformVNodeArgs,
  10613. triggerRef: triggerRef,
  10614. unref: unref,
  10615. useAttrs: useAttrs,
  10616. useCssModule: useCssModule,
  10617. useCssVars: useCssVars,
  10618. useModel: useModel,
  10619. useSSRContext: useSSRContext,
  10620. useSlots: useSlots,
  10621. useTransitionState: useTransitionState,
  10622. vModelCheckbox: vModelCheckbox,
  10623. vModelDynamic: vModelDynamic,
  10624. vModelRadio: vModelRadio,
  10625. vModelSelect: vModelSelect,
  10626. vModelText: vModelText,
  10627. vShow: vShow,
  10628. version: version,
  10629. warn: warn,
  10630. watch: watch,
  10631. watchEffect: watchEffect,
  10632. watchPostEffect: watchPostEffect,
  10633. watchSyncEffect: watchSyncEffect,
  10634. withAsyncContext: withAsyncContext,
  10635. withCtx: withCtx,
  10636. withDefaults: withDefaults,
  10637. withDirectives: withDirectives,
  10638. withKeys: withKeys,
  10639. withMemo: withMemo,
  10640. withModifiers: withModifiers,
  10641. withScopeId: withScopeId
  10642. });
  10643. function initDev() {
  10644. {
  10645. {
  10646. console.info(
  10647. `You are running a development build of Vue.
  10648. Make sure to use the production build (*.prod.js) when deploying for production.`
  10649. );
  10650. }
  10651. initCustomFormatter();
  10652. }
  10653. }
  10654. function defaultOnError(error) {
  10655. throw error;
  10656. }
  10657. function defaultOnWarn(msg) {
  10658. console.warn(`[Vue warn] ${msg.message}`);
  10659. }
  10660. function createCompilerError(code, loc, messages, additionalMessage) {
  10661. const msg = (messages || errorMessages)[code] + (additionalMessage || ``) ;
  10662. const error = new SyntaxError(String(msg));
  10663. error.code = code;
  10664. error.loc = loc;
  10665. return error;
  10666. }
  10667. const errorMessages = {
  10668. // parse errors
  10669. [0]: "Illegal comment.",
  10670. [1]: "CDATA section is allowed only in XML context.",
  10671. [2]: "Duplicate attribute.",
  10672. [3]: "End tag cannot have attributes.",
  10673. [4]: "Illegal '/' in tags.",
  10674. [5]: "Unexpected EOF in tag.",
  10675. [6]: "Unexpected EOF in CDATA section.",
  10676. [7]: "Unexpected EOF in comment.",
  10677. [8]: "Unexpected EOF in script.",
  10678. [9]: "Unexpected EOF in tag.",
  10679. [10]: "Incorrectly closed comment.",
  10680. [11]: "Incorrectly opened comment.",
  10681. [12]: "Illegal tag name. Use '&lt;' to print '<'.",
  10682. [13]: "Attribute value was expected.",
  10683. [14]: "End tag name was expected.",
  10684. [15]: "Whitespace was expected.",
  10685. [16]: "Unexpected '<!--' in comment.",
  10686. [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
  10687. [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
  10688. [19]: "Attribute name cannot start with '='.",
  10689. [21]: "'<?' is allowed only in XML context.",
  10690. [20]: `Unexpected null character.`,
  10691. [22]: "Illegal '/' in tags.",
  10692. // Vue-specific parse errors
  10693. [23]: "Invalid end tag.",
  10694. [24]: "Element is missing end tag.",
  10695. [25]: "Interpolation end sign was not found.",
  10696. [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
  10697. [26]: "Legal directive name was expected.",
  10698. // transform errors
  10699. [28]: `v-if/v-else-if is missing expression.`,
  10700. [29]: `v-if/else branches must use unique keys.`,
  10701. [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
  10702. [31]: `v-for is missing expression.`,
  10703. [32]: `v-for has invalid expression.`,
  10704. [33]: `<template v-for> key should be placed on the <template> tag.`,
  10705. [34]: `v-bind is missing expression.`,
  10706. [35]: `v-on is missing expression.`,
  10707. [36]: `Unexpected custom directive on <slot> outlet.`,
  10708. [37]: `Mixed v-slot usage on both the component and nested <template>. When there are multiple named slots, all slots should use <template> syntax to avoid scope ambiguity.`,
  10709. [38]: `Duplicate slot names found. `,
  10710. [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
  10711. [40]: `v-slot can only be used on components or <template> tags.`,
  10712. [41]: `v-model is missing expression.`,
  10713. [42]: `v-model value must be a valid JavaScript member expression.`,
  10714. [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
  10715. [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
  10716. Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
  10717. [45]: `Error parsing JavaScript expression: `,
  10718. [46]: `<KeepAlive> expects exactly one child component.`,
  10719. // generic errors
  10720. [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
  10721. [48]: `ES module mode is not supported in this build of compiler.`,
  10722. [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
  10723. [50]: `"scopeId" option is only supported in module mode.`,
  10724. // deprecations
  10725. [51]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
  10726. [52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
  10727. // just to fulfill types
  10728. [53]: ``
  10729. };
  10730. const FRAGMENT = Symbol(`Fragment` );
  10731. const TELEPORT = Symbol(`Teleport` );
  10732. const SUSPENSE = Symbol(`Suspense` );
  10733. const KEEP_ALIVE = Symbol(`KeepAlive` );
  10734. const BASE_TRANSITION = Symbol(`BaseTransition` );
  10735. const OPEN_BLOCK = Symbol(`openBlock` );
  10736. const CREATE_BLOCK = Symbol(`createBlock` );
  10737. const CREATE_ELEMENT_BLOCK = Symbol(`createElementBlock` );
  10738. const CREATE_VNODE = Symbol(`createVNode` );
  10739. const CREATE_ELEMENT_VNODE = Symbol(`createElementVNode` );
  10740. const CREATE_COMMENT = Symbol(`createCommentVNode` );
  10741. const CREATE_TEXT = Symbol(`createTextVNode` );
  10742. const CREATE_STATIC = Symbol(`createStaticVNode` );
  10743. const RESOLVE_COMPONENT = Symbol(`resolveComponent` );
  10744. const RESOLVE_DYNAMIC_COMPONENT = Symbol(
  10745. `resolveDynamicComponent`
  10746. );
  10747. const RESOLVE_DIRECTIVE = Symbol(`resolveDirective` );
  10748. const RESOLVE_FILTER = Symbol(`resolveFilter` );
  10749. const WITH_DIRECTIVES = Symbol(`withDirectives` );
  10750. const RENDER_LIST = Symbol(`renderList` );
  10751. const RENDER_SLOT = Symbol(`renderSlot` );
  10752. const CREATE_SLOTS = Symbol(`createSlots` );
  10753. const TO_DISPLAY_STRING = Symbol(`toDisplayString` );
  10754. const MERGE_PROPS = Symbol(`mergeProps` );
  10755. const NORMALIZE_CLASS = Symbol(`normalizeClass` );
  10756. const NORMALIZE_STYLE = Symbol(`normalizeStyle` );
  10757. const NORMALIZE_PROPS = Symbol(`normalizeProps` );
  10758. const GUARD_REACTIVE_PROPS = Symbol(`guardReactiveProps` );
  10759. const TO_HANDLERS = Symbol(`toHandlers` );
  10760. const CAMELIZE = Symbol(`camelize` );
  10761. const CAPITALIZE = Symbol(`capitalize` );
  10762. const TO_HANDLER_KEY = Symbol(`toHandlerKey` );
  10763. const SET_BLOCK_TRACKING = Symbol(`setBlockTracking` );
  10764. const PUSH_SCOPE_ID = Symbol(`pushScopeId` );
  10765. const POP_SCOPE_ID = Symbol(`popScopeId` );
  10766. const WITH_CTX = Symbol(`withCtx` );
  10767. const UNREF = Symbol(`unref` );
  10768. const IS_REF = Symbol(`isRef` );
  10769. const WITH_MEMO = Symbol(`withMemo` );
  10770. const IS_MEMO_SAME = Symbol(`isMemoSame` );
  10771. const helperNameMap = {
  10772. [FRAGMENT]: `Fragment`,
  10773. [TELEPORT]: `Teleport`,
  10774. [SUSPENSE]: `Suspense`,
  10775. [KEEP_ALIVE]: `KeepAlive`,
  10776. [BASE_TRANSITION]: `BaseTransition`,
  10777. [OPEN_BLOCK]: `openBlock`,
  10778. [CREATE_BLOCK]: `createBlock`,
  10779. [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
  10780. [CREATE_VNODE]: `createVNode`,
  10781. [CREATE_ELEMENT_VNODE]: `createElementVNode`,
  10782. [CREATE_COMMENT]: `createCommentVNode`,
  10783. [CREATE_TEXT]: `createTextVNode`,
  10784. [CREATE_STATIC]: `createStaticVNode`,
  10785. [RESOLVE_COMPONENT]: `resolveComponent`,
  10786. [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
  10787. [RESOLVE_DIRECTIVE]: `resolveDirective`,
  10788. [RESOLVE_FILTER]: `resolveFilter`,
  10789. [WITH_DIRECTIVES]: `withDirectives`,
  10790. [RENDER_LIST]: `renderList`,
  10791. [RENDER_SLOT]: `renderSlot`,
  10792. [CREATE_SLOTS]: `createSlots`,
  10793. [TO_DISPLAY_STRING]: `toDisplayString`,
  10794. [MERGE_PROPS]: `mergeProps`,
  10795. [NORMALIZE_CLASS]: `normalizeClass`,
  10796. [NORMALIZE_STYLE]: `normalizeStyle`,
  10797. [NORMALIZE_PROPS]: `normalizeProps`,
  10798. [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
  10799. [TO_HANDLERS]: `toHandlers`,
  10800. [CAMELIZE]: `camelize`,
  10801. [CAPITALIZE]: `capitalize`,
  10802. [TO_HANDLER_KEY]: `toHandlerKey`,
  10803. [SET_BLOCK_TRACKING]: `setBlockTracking`,
  10804. [PUSH_SCOPE_ID]: `pushScopeId`,
  10805. [POP_SCOPE_ID]: `popScopeId`,
  10806. [WITH_CTX]: `withCtx`,
  10807. [UNREF]: `unref`,
  10808. [IS_REF]: `isRef`,
  10809. [WITH_MEMO]: `withMemo`,
  10810. [IS_MEMO_SAME]: `isMemoSame`
  10811. };
  10812. function registerRuntimeHelpers(helpers) {
  10813. Object.getOwnPropertySymbols(helpers).forEach((s) => {
  10814. helperNameMap[s] = helpers[s];
  10815. });
  10816. }
  10817. const locStub = {
  10818. source: "",
  10819. start: { line: 1, column: 1, offset: 0 },
  10820. end: { line: 1, column: 1, offset: 0 }
  10821. };
  10822. function createRoot(children, loc = locStub) {
  10823. return {
  10824. type: 0,
  10825. children,
  10826. helpers: /* @__PURE__ */ new Set(),
  10827. components: [],
  10828. directives: [],
  10829. hoists: [],
  10830. imports: [],
  10831. cached: 0,
  10832. temps: 0,
  10833. codegenNode: void 0,
  10834. loc
  10835. };
  10836. }
  10837. function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
  10838. if (context) {
  10839. if (isBlock) {
  10840. context.helper(OPEN_BLOCK);
  10841. context.helper(getVNodeBlockHelper(context.inSSR, isComponent));
  10842. } else {
  10843. context.helper(getVNodeHelper(context.inSSR, isComponent));
  10844. }
  10845. if (directives) {
  10846. context.helper(WITH_DIRECTIVES);
  10847. }
  10848. }
  10849. return {
  10850. type: 13,
  10851. tag,
  10852. props,
  10853. children,
  10854. patchFlag,
  10855. dynamicProps,
  10856. directives,
  10857. isBlock,
  10858. disableTracking,
  10859. isComponent,
  10860. loc
  10861. };
  10862. }
  10863. function createArrayExpression(elements, loc = locStub) {
  10864. return {
  10865. type: 17,
  10866. loc,
  10867. elements
  10868. };
  10869. }
  10870. function createObjectExpression(properties, loc = locStub) {
  10871. return {
  10872. type: 15,
  10873. loc,
  10874. properties
  10875. };
  10876. }
  10877. function createObjectProperty(key, value) {
  10878. return {
  10879. type: 16,
  10880. loc: locStub,
  10881. key: isString(key) ? createSimpleExpression(key, true) : key,
  10882. value
  10883. };
  10884. }
  10885. function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0) {
  10886. return {
  10887. type: 4,
  10888. loc,
  10889. content,
  10890. isStatic,
  10891. constType: isStatic ? 3 : constType
  10892. };
  10893. }
  10894. function createCompoundExpression(children, loc = locStub) {
  10895. return {
  10896. type: 8,
  10897. loc,
  10898. children
  10899. };
  10900. }
  10901. function createCallExpression(callee, args = [], loc = locStub) {
  10902. return {
  10903. type: 14,
  10904. loc,
  10905. callee,
  10906. arguments: args
  10907. };
  10908. }
  10909. function createFunctionExpression(params, returns = void 0, newline = false, isSlot = false, loc = locStub) {
  10910. return {
  10911. type: 18,
  10912. params,
  10913. returns,
  10914. newline,
  10915. isSlot,
  10916. loc
  10917. };
  10918. }
  10919. function createConditionalExpression(test, consequent, alternate, newline = true) {
  10920. return {
  10921. type: 19,
  10922. test,
  10923. consequent,
  10924. alternate,
  10925. newline,
  10926. loc: locStub
  10927. };
  10928. }
  10929. function createCacheExpression(index, value, isVNode = false) {
  10930. return {
  10931. type: 20,
  10932. index,
  10933. value,
  10934. isVNode,
  10935. loc: locStub
  10936. };
  10937. }
  10938. function createBlockStatement(body) {
  10939. return {
  10940. type: 21,
  10941. body,
  10942. loc: locStub
  10943. };
  10944. }
  10945. function getVNodeHelper(ssr, isComponent) {
  10946. return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
  10947. }
  10948. function getVNodeBlockHelper(ssr, isComponent) {
  10949. return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
  10950. }
  10951. function convertToBlock(node, { helper, removeHelper, inSSR }) {
  10952. if (!node.isBlock) {
  10953. node.isBlock = true;
  10954. removeHelper(getVNodeHelper(inSSR, node.isComponent));
  10955. helper(OPEN_BLOCK);
  10956. helper(getVNodeBlockHelper(inSSR, node.isComponent));
  10957. }
  10958. }
  10959. const isStaticExp = (p) => p.type === 4 && p.isStatic;
  10960. const isBuiltInType = (tag, expected) => tag === expected || tag === hyphenate(expected);
  10961. function isCoreComponent(tag) {
  10962. if (isBuiltInType(tag, "Teleport")) {
  10963. return TELEPORT;
  10964. } else if (isBuiltInType(tag, "Suspense")) {
  10965. return SUSPENSE;
  10966. } else if (isBuiltInType(tag, "KeepAlive")) {
  10967. return KEEP_ALIVE;
  10968. } else if (isBuiltInType(tag, "BaseTransition")) {
  10969. return BASE_TRANSITION;
  10970. }
  10971. }
  10972. const nonIdentifierRE = /^\d|[^\$\w]/;
  10973. const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
  10974. const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
  10975. const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
  10976. const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
  10977. const isMemberExpressionBrowser = (path) => {
  10978. path = path.trim().replace(whitespaceRE, (s) => s.trim());
  10979. let state = 0 /* inMemberExp */;
  10980. let stateStack = [];
  10981. let currentOpenBracketCount = 0;
  10982. let currentOpenParensCount = 0;
  10983. let currentStringType = null;
  10984. for (let i = 0; i < path.length; i++) {
  10985. const char = path.charAt(i);
  10986. switch (state) {
  10987. case 0 /* inMemberExp */:
  10988. if (char === "[") {
  10989. stateStack.push(state);
  10990. state = 1 /* inBrackets */;
  10991. currentOpenBracketCount++;
  10992. } else if (char === "(") {
  10993. stateStack.push(state);
  10994. state = 2 /* inParens */;
  10995. currentOpenParensCount++;
  10996. } else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
  10997. return false;
  10998. }
  10999. break;
  11000. case 1 /* inBrackets */:
  11001. if (char === `'` || char === `"` || char === "`") {
  11002. stateStack.push(state);
  11003. state = 3 /* inString */;
  11004. currentStringType = char;
  11005. } else if (char === `[`) {
  11006. currentOpenBracketCount++;
  11007. } else if (char === `]`) {
  11008. if (!--currentOpenBracketCount) {
  11009. state = stateStack.pop();
  11010. }
  11011. }
  11012. break;
  11013. case 2 /* inParens */:
  11014. if (char === `'` || char === `"` || char === "`") {
  11015. stateStack.push(state);
  11016. state = 3 /* inString */;
  11017. currentStringType = char;
  11018. } else if (char === `(`) {
  11019. currentOpenParensCount++;
  11020. } else if (char === `)`) {
  11021. if (i === path.length - 1) {
  11022. return false;
  11023. }
  11024. if (!--currentOpenParensCount) {
  11025. state = stateStack.pop();
  11026. }
  11027. }
  11028. break;
  11029. case 3 /* inString */:
  11030. if (char === currentStringType) {
  11031. state = stateStack.pop();
  11032. currentStringType = null;
  11033. }
  11034. break;
  11035. }
  11036. }
  11037. return !currentOpenBracketCount && !currentOpenParensCount;
  11038. };
  11039. const isMemberExpression = isMemberExpressionBrowser ;
  11040. function getInnerRange(loc, offset, length) {
  11041. const source = loc.source.slice(offset, offset + length);
  11042. const newLoc = {
  11043. source,
  11044. start: advancePositionWithClone(loc.start, loc.source, offset),
  11045. end: loc.end
  11046. };
  11047. if (length != null) {
  11048. newLoc.end = advancePositionWithClone(
  11049. loc.start,
  11050. loc.source,
  11051. offset + length
  11052. );
  11053. }
  11054. return newLoc;
  11055. }
  11056. function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
  11057. return advancePositionWithMutation(
  11058. extend({}, pos),
  11059. source,
  11060. numberOfCharacters
  11061. );
  11062. }
  11063. function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
  11064. let linesCount = 0;
  11065. let lastNewLinePos = -1;
  11066. for (let i = 0; i < numberOfCharacters; i++) {
  11067. if (source.charCodeAt(i) === 10) {
  11068. linesCount++;
  11069. lastNewLinePos = i;
  11070. }
  11071. }
  11072. pos.offset += numberOfCharacters;
  11073. pos.line += linesCount;
  11074. pos.column = lastNewLinePos === -1 ? pos.column + numberOfCharacters : numberOfCharacters - lastNewLinePos;
  11075. return pos;
  11076. }
  11077. function assert(condition, msg) {
  11078. if (!condition) {
  11079. throw new Error(msg || `unexpected compiler condition`);
  11080. }
  11081. }
  11082. function findDir(node, name, allowEmpty = false) {
  11083. for (let i = 0; i < node.props.length; i++) {
  11084. const p = node.props[i];
  11085. if (p.type === 7 && (allowEmpty || p.exp) && (isString(name) ? p.name === name : name.test(p.name))) {
  11086. return p;
  11087. }
  11088. }
  11089. }
  11090. function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
  11091. for (let i = 0; i < node.props.length; i++) {
  11092. const p = node.props[i];
  11093. if (p.type === 6) {
  11094. if (dynamicOnly)
  11095. continue;
  11096. if (p.name === name && (p.value || allowEmpty)) {
  11097. return p;
  11098. }
  11099. } else if (p.name === "bind" && (p.exp || allowEmpty) && isStaticArgOf(p.arg, name)) {
  11100. return p;
  11101. }
  11102. }
  11103. }
  11104. function isStaticArgOf(arg, name) {
  11105. return !!(arg && isStaticExp(arg) && arg.content === name);
  11106. }
  11107. function hasDynamicKeyVBind(node) {
  11108. return node.props.some(
  11109. (p) => p.type === 7 && p.name === "bind" && (!p.arg || // v-bind="obj"
  11110. p.arg.type !== 4 || // v-bind:[_ctx.foo]
  11111. !p.arg.isStatic)
  11112. // v-bind:[foo]
  11113. );
  11114. }
  11115. function isText$1(node) {
  11116. return node.type === 5 || node.type === 2;
  11117. }
  11118. function isVSlot(p) {
  11119. return p.type === 7 && p.name === "slot";
  11120. }
  11121. function isTemplateNode(node) {
  11122. return node.type === 1 && node.tagType === 3;
  11123. }
  11124. function isSlotOutlet(node) {
  11125. return node.type === 1 && node.tagType === 2;
  11126. }
  11127. const propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
  11128. function getUnnormalizedProps(props, callPath = []) {
  11129. if (props && !isString(props) && props.type === 14) {
  11130. const callee = props.callee;
  11131. if (!isString(callee) && propsHelperSet.has(callee)) {
  11132. return getUnnormalizedProps(
  11133. props.arguments[0],
  11134. callPath.concat(props)
  11135. );
  11136. }
  11137. }
  11138. return [props, callPath];
  11139. }
  11140. function injectProp(node, prop, context) {
  11141. let propsWithInjection;
  11142. let props = node.type === 13 ? node.props : node.arguments[2];
  11143. let callPath = [];
  11144. let parentCall;
  11145. if (props && !isString(props) && props.type === 14) {
  11146. const ret = getUnnormalizedProps(props);
  11147. props = ret[0];
  11148. callPath = ret[1];
  11149. parentCall = callPath[callPath.length - 1];
  11150. }
  11151. if (props == null || isString(props)) {
  11152. propsWithInjection = createObjectExpression([prop]);
  11153. } else if (props.type === 14) {
  11154. const first = props.arguments[0];
  11155. if (!isString(first) && first.type === 15) {
  11156. if (!hasProp(prop, first)) {
  11157. first.properties.unshift(prop);
  11158. }
  11159. } else {
  11160. if (props.callee === TO_HANDLERS) {
  11161. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  11162. createObjectExpression([prop]),
  11163. props
  11164. ]);
  11165. } else {
  11166. props.arguments.unshift(createObjectExpression([prop]));
  11167. }
  11168. }
  11169. !propsWithInjection && (propsWithInjection = props);
  11170. } else if (props.type === 15) {
  11171. if (!hasProp(prop, props)) {
  11172. props.properties.unshift(prop);
  11173. }
  11174. propsWithInjection = props;
  11175. } else {
  11176. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  11177. createObjectExpression([prop]),
  11178. props
  11179. ]);
  11180. if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
  11181. parentCall = callPath[callPath.length - 2];
  11182. }
  11183. }
  11184. if (node.type === 13) {
  11185. if (parentCall) {
  11186. parentCall.arguments[0] = propsWithInjection;
  11187. } else {
  11188. node.props = propsWithInjection;
  11189. }
  11190. } else {
  11191. if (parentCall) {
  11192. parentCall.arguments[0] = propsWithInjection;
  11193. } else {
  11194. node.arguments[2] = propsWithInjection;
  11195. }
  11196. }
  11197. }
  11198. function hasProp(prop, props) {
  11199. let result = false;
  11200. if (prop.key.type === 4) {
  11201. const propKeyName = prop.key.content;
  11202. result = props.properties.some(
  11203. (p) => p.key.type === 4 && p.key.content === propKeyName
  11204. );
  11205. }
  11206. return result;
  11207. }
  11208. function toValidAssetId(name, type) {
  11209. return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
  11210. return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
  11211. })}`;
  11212. }
  11213. function getMemoedVNodeCall(node) {
  11214. if (node.type === 14 && node.callee === WITH_MEMO) {
  11215. return node.arguments[1].returns;
  11216. } else {
  11217. return node;
  11218. }
  11219. }
  11220. const decodeRE = /&(gt|lt|amp|apos|quot);/g;
  11221. const decodeMap = {
  11222. gt: ">",
  11223. lt: "<",
  11224. amp: "&",
  11225. apos: "'",
  11226. quot: '"'
  11227. };
  11228. const defaultParserOptions = {
  11229. delimiters: [`{{`, `}}`],
  11230. getNamespace: () => 0,
  11231. getTextMode: () => 0,
  11232. isVoidTag: NO,
  11233. isPreTag: NO,
  11234. isCustomElement: NO,
  11235. decodeEntities: (rawText) => rawText.replace(decodeRE, (_, p1) => decodeMap[p1]),
  11236. onError: defaultOnError,
  11237. onWarn: defaultOnWarn,
  11238. comments: true
  11239. };
  11240. function baseParse(content, options = {}) {
  11241. const context = createParserContext(content, options);
  11242. const start = getCursor(context);
  11243. return createRoot(
  11244. parseChildren(context, 0, []),
  11245. getSelection(context, start)
  11246. );
  11247. }
  11248. function createParserContext(content, rawOptions) {
  11249. const options = extend({}, defaultParserOptions);
  11250. let key;
  11251. for (key in rawOptions) {
  11252. options[key] = rawOptions[key] === void 0 ? defaultParserOptions[key] : rawOptions[key];
  11253. }
  11254. return {
  11255. options,
  11256. column: 1,
  11257. line: 1,
  11258. offset: 0,
  11259. originalSource: content,
  11260. source: content,
  11261. inPre: false,
  11262. inVPre: false,
  11263. onWarn: options.onWarn
  11264. };
  11265. }
  11266. function parseChildren(context, mode, ancestors) {
  11267. const parent = last(ancestors);
  11268. const ns = parent ? parent.ns : 0;
  11269. const nodes = [];
  11270. while (!isEnd(context, mode, ancestors)) {
  11271. const s = context.source;
  11272. let node = void 0;
  11273. if (mode === 0 || mode === 1) {
  11274. if (!context.inVPre && startsWith(s, context.options.delimiters[0])) {
  11275. node = parseInterpolation(context, mode);
  11276. } else if (mode === 0 && s[0] === "<") {
  11277. if (s.length === 1) {
  11278. emitError(context, 5, 1);
  11279. } else if (s[1] === "!") {
  11280. if (startsWith(s, "<!--")) {
  11281. node = parseComment(context);
  11282. } else if (startsWith(s, "<!DOCTYPE")) {
  11283. node = parseBogusComment(context);
  11284. } else if (startsWith(s, "<![CDATA[")) {
  11285. if (ns !== 0) {
  11286. node = parseCDATA(context, ancestors);
  11287. } else {
  11288. emitError(context, 1);
  11289. node = parseBogusComment(context);
  11290. }
  11291. } else {
  11292. emitError(context, 11);
  11293. node = parseBogusComment(context);
  11294. }
  11295. } else if (s[1] === "/") {
  11296. if (s.length === 2) {
  11297. emitError(context, 5, 2);
  11298. } else if (s[2] === ">") {
  11299. emitError(context, 14, 2);
  11300. advanceBy(context, 3);
  11301. continue;
  11302. } else if (/[a-z]/i.test(s[2])) {
  11303. emitError(context, 23);
  11304. parseTag(context, TagType.End, parent);
  11305. continue;
  11306. } else {
  11307. emitError(
  11308. context,
  11309. 12,
  11310. 2
  11311. );
  11312. node = parseBogusComment(context);
  11313. }
  11314. } else if (/[a-z]/i.test(s[1])) {
  11315. node = parseElement(context, ancestors);
  11316. } else if (s[1] === "?") {
  11317. emitError(
  11318. context,
  11319. 21,
  11320. 1
  11321. );
  11322. node = parseBogusComment(context);
  11323. } else {
  11324. emitError(context, 12, 1);
  11325. }
  11326. }
  11327. }
  11328. if (!node) {
  11329. node = parseText(context, mode);
  11330. }
  11331. if (isArray(node)) {
  11332. for (let i = 0; i < node.length; i++) {
  11333. pushNode(nodes, node[i]);
  11334. }
  11335. } else {
  11336. pushNode(nodes, node);
  11337. }
  11338. }
  11339. let removedWhitespace = false;
  11340. if (mode !== 2 && mode !== 1) {
  11341. const shouldCondense = context.options.whitespace !== "preserve";
  11342. for (let i = 0; i < nodes.length; i++) {
  11343. const node = nodes[i];
  11344. if (node.type === 2) {
  11345. if (!context.inPre) {
  11346. if (!/[^\t\r\n\f ]/.test(node.content)) {
  11347. const prev = nodes[i - 1];
  11348. const next = nodes[i + 1];
  11349. if (!prev || !next || shouldCondense && (prev.type === 3 && next.type === 3 || prev.type === 3 && next.type === 1 || prev.type === 1 && next.type === 3 || prev.type === 1 && next.type === 1 && /[\r\n]/.test(node.content))) {
  11350. removedWhitespace = true;
  11351. nodes[i] = null;
  11352. } else {
  11353. node.content = " ";
  11354. }
  11355. } else if (shouldCondense) {
  11356. node.content = node.content.replace(/[\t\r\n\f ]+/g, " ");
  11357. }
  11358. } else {
  11359. node.content = node.content.replace(/\r\n/g, "\n");
  11360. }
  11361. } else if (node.type === 3 && !context.options.comments) {
  11362. removedWhitespace = true;
  11363. nodes[i] = null;
  11364. }
  11365. }
  11366. if (context.inPre && parent && context.options.isPreTag(parent.tag)) {
  11367. const first = nodes[0];
  11368. if (first && first.type === 2) {
  11369. first.content = first.content.replace(/^\r?\n/, "");
  11370. }
  11371. }
  11372. }
  11373. return removedWhitespace ? nodes.filter(Boolean) : nodes;
  11374. }
  11375. function pushNode(nodes, node) {
  11376. if (node.type === 2) {
  11377. const prev = last(nodes);
  11378. if (prev && prev.type === 2 && prev.loc.end.offset === node.loc.start.offset) {
  11379. prev.content += node.content;
  11380. prev.loc.end = node.loc.end;
  11381. prev.loc.source += node.loc.source;
  11382. return;
  11383. }
  11384. }
  11385. nodes.push(node);
  11386. }
  11387. function parseCDATA(context, ancestors) {
  11388. advanceBy(context, 9);
  11389. const nodes = parseChildren(context, 3, ancestors);
  11390. if (context.source.length === 0) {
  11391. emitError(context, 6);
  11392. } else {
  11393. advanceBy(context, 3);
  11394. }
  11395. return nodes;
  11396. }
  11397. function parseComment(context) {
  11398. const start = getCursor(context);
  11399. let content;
  11400. const match = /--(\!)?>/.exec(context.source);
  11401. if (!match) {
  11402. content = context.source.slice(4);
  11403. advanceBy(context, context.source.length);
  11404. emitError(context, 7);
  11405. } else {
  11406. if (match.index <= 3) {
  11407. emitError(context, 0);
  11408. }
  11409. if (match[1]) {
  11410. emitError(context, 10);
  11411. }
  11412. content = context.source.slice(4, match.index);
  11413. const s = context.source.slice(0, match.index);
  11414. let prevIndex = 1, nestedIndex = 0;
  11415. while ((nestedIndex = s.indexOf("<!--", prevIndex)) !== -1) {
  11416. advanceBy(context, nestedIndex - prevIndex + 1);
  11417. if (nestedIndex + 4 < s.length) {
  11418. emitError(context, 16);
  11419. }
  11420. prevIndex = nestedIndex + 1;
  11421. }
  11422. advanceBy(context, match.index + match[0].length - prevIndex + 1);
  11423. }
  11424. return {
  11425. type: 3,
  11426. content,
  11427. loc: getSelection(context, start)
  11428. };
  11429. }
  11430. function parseBogusComment(context) {
  11431. const start = getCursor(context);
  11432. const contentStart = context.source[1] === "?" ? 1 : 2;
  11433. let content;
  11434. const closeIndex = context.source.indexOf(">");
  11435. if (closeIndex === -1) {
  11436. content = context.source.slice(contentStart);
  11437. advanceBy(context, context.source.length);
  11438. } else {
  11439. content = context.source.slice(contentStart, closeIndex);
  11440. advanceBy(context, closeIndex + 1);
  11441. }
  11442. return {
  11443. type: 3,
  11444. content,
  11445. loc: getSelection(context, start)
  11446. };
  11447. }
  11448. function parseElement(context, ancestors) {
  11449. const wasInPre = context.inPre;
  11450. const wasInVPre = context.inVPre;
  11451. const parent = last(ancestors);
  11452. const element = parseTag(context, TagType.Start, parent);
  11453. const isPreBoundary = context.inPre && !wasInPre;
  11454. const isVPreBoundary = context.inVPre && !wasInVPre;
  11455. if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
  11456. if (isPreBoundary) {
  11457. context.inPre = false;
  11458. }
  11459. if (isVPreBoundary) {
  11460. context.inVPre = false;
  11461. }
  11462. return element;
  11463. }
  11464. ancestors.push(element);
  11465. const mode = context.options.getTextMode(element, parent);
  11466. const children = parseChildren(context, mode, ancestors);
  11467. ancestors.pop();
  11468. element.children = children;
  11469. if (startsWithEndTagOpen(context.source, element.tag)) {
  11470. parseTag(context, TagType.End, parent);
  11471. } else {
  11472. emitError(context, 24, 0, element.loc.start);
  11473. if (context.source.length === 0 && element.tag.toLowerCase() === "script") {
  11474. const first = children[0];
  11475. if (first && startsWith(first.loc.source, "<!--")) {
  11476. emitError(context, 8);
  11477. }
  11478. }
  11479. }
  11480. element.loc = getSelection(context, element.loc.start);
  11481. if (isPreBoundary) {
  11482. context.inPre = false;
  11483. }
  11484. if (isVPreBoundary) {
  11485. context.inVPre = false;
  11486. }
  11487. return element;
  11488. }
  11489. var TagType = /* @__PURE__ */ ((TagType2) => {
  11490. TagType2[TagType2["Start"] = 0] = "Start";
  11491. TagType2[TagType2["End"] = 1] = "End";
  11492. return TagType2;
  11493. })(TagType || {});
  11494. const isSpecialTemplateDirective = /* @__PURE__ */ makeMap(
  11495. `if,else,else-if,for,slot`
  11496. );
  11497. function parseTag(context, type, parent) {
  11498. const start = getCursor(context);
  11499. const match = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(context.source);
  11500. const tag = match[1];
  11501. const ns = context.options.getNamespace(tag, parent);
  11502. advanceBy(context, match[0].length);
  11503. advanceSpaces(context);
  11504. const cursor = getCursor(context);
  11505. const currentSource = context.source;
  11506. if (context.options.isPreTag(tag)) {
  11507. context.inPre = true;
  11508. }
  11509. let props = parseAttributes(context, type);
  11510. if (type === 0 /* Start */ && !context.inVPre && props.some((p) => p.type === 7 && p.name === "pre")) {
  11511. context.inVPre = true;
  11512. extend(context, cursor);
  11513. context.source = currentSource;
  11514. props = parseAttributes(context, type).filter((p) => p.name !== "v-pre");
  11515. }
  11516. let isSelfClosing = false;
  11517. if (context.source.length === 0) {
  11518. emitError(context, 9);
  11519. } else {
  11520. isSelfClosing = startsWith(context.source, "/>");
  11521. if (type === 1 /* End */ && isSelfClosing) {
  11522. emitError(context, 4);
  11523. }
  11524. advanceBy(context, isSelfClosing ? 2 : 1);
  11525. }
  11526. if (type === 1 /* End */) {
  11527. return;
  11528. }
  11529. let tagType = 0;
  11530. if (!context.inVPre) {
  11531. if (tag === "slot") {
  11532. tagType = 2;
  11533. } else if (tag === "template") {
  11534. if (props.some(
  11535. (p) => p.type === 7 && isSpecialTemplateDirective(p.name)
  11536. )) {
  11537. tagType = 3;
  11538. }
  11539. } else if (isComponent(tag, props, context)) {
  11540. tagType = 1;
  11541. }
  11542. }
  11543. return {
  11544. type: 1,
  11545. ns,
  11546. tag,
  11547. tagType,
  11548. props,
  11549. isSelfClosing,
  11550. children: [],
  11551. loc: getSelection(context, start),
  11552. codegenNode: void 0
  11553. // to be created during transform phase
  11554. };
  11555. }
  11556. function isComponent(tag, props, context) {
  11557. const options = context.options;
  11558. if (options.isCustomElement(tag)) {
  11559. return false;
  11560. }
  11561. if (tag === "component" || /^[A-Z]/.test(tag) || isCoreComponent(tag) || options.isBuiltInComponent && options.isBuiltInComponent(tag) || options.isNativeTag && !options.isNativeTag(tag)) {
  11562. return true;
  11563. }
  11564. for (let i = 0; i < props.length; i++) {
  11565. const p = props[i];
  11566. if (p.type === 6) {
  11567. if (p.name === "is" && p.value) {
  11568. if (p.value.content.startsWith("vue:")) {
  11569. return true;
  11570. }
  11571. }
  11572. } else {
  11573. if (p.name === "is") {
  11574. return true;
  11575. } else if (
  11576. // :is on plain element - only treat as component in compat mode
  11577. p.name === "bind" && isStaticArgOf(p.arg, "is") && false
  11578. ) {
  11579. return true;
  11580. }
  11581. }
  11582. }
  11583. }
  11584. function parseAttributes(context, type) {
  11585. const props = [];
  11586. const attributeNames = /* @__PURE__ */ new Set();
  11587. while (context.source.length > 0 && !startsWith(context.source, ">") && !startsWith(context.source, "/>")) {
  11588. if (startsWith(context.source, "/")) {
  11589. emitError(context, 22);
  11590. advanceBy(context, 1);
  11591. advanceSpaces(context);
  11592. continue;
  11593. }
  11594. if (type === 1 /* End */) {
  11595. emitError(context, 3);
  11596. }
  11597. const attr = parseAttribute(context, attributeNames);
  11598. if (attr.type === 6 && attr.value && attr.name === "class") {
  11599. attr.value.content = attr.value.content.replace(/\s+/g, " ").trim();
  11600. }
  11601. if (type === 0 /* Start */) {
  11602. props.push(attr);
  11603. }
  11604. if (/^[^\t\r\n\f />]/.test(context.source)) {
  11605. emitError(context, 15);
  11606. }
  11607. advanceSpaces(context);
  11608. }
  11609. return props;
  11610. }
  11611. function parseAttribute(context, nameSet) {
  11612. var _a;
  11613. const start = getCursor(context);
  11614. const match = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(context.source);
  11615. const name = match[0];
  11616. if (nameSet.has(name)) {
  11617. emitError(context, 2);
  11618. }
  11619. nameSet.add(name);
  11620. if (name[0] === "=") {
  11621. emitError(context, 19);
  11622. }
  11623. {
  11624. const pattern = /["'<]/g;
  11625. let m;
  11626. while (m = pattern.exec(name)) {
  11627. emitError(
  11628. context,
  11629. 17,
  11630. m.index
  11631. );
  11632. }
  11633. }
  11634. advanceBy(context, name.length);
  11635. let value = void 0;
  11636. if (/^[\t\r\n\f ]*=/.test(context.source)) {
  11637. advanceSpaces(context);
  11638. advanceBy(context, 1);
  11639. advanceSpaces(context);
  11640. value = parseAttributeValue(context);
  11641. if (!value) {
  11642. emitError(context, 13);
  11643. }
  11644. }
  11645. const loc = getSelection(context, start);
  11646. if (!context.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(name)) {
  11647. const match2 = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(
  11648. name
  11649. );
  11650. let isPropShorthand = startsWith(name, ".");
  11651. let dirName = match2[1] || (isPropShorthand || startsWith(name, ":") ? "bind" : startsWith(name, "@") ? "on" : "slot");
  11652. let arg;
  11653. if (match2[2]) {
  11654. const isSlot = dirName === "slot";
  11655. const startOffset = name.lastIndexOf(
  11656. match2[2],
  11657. name.length - (((_a = match2[3]) == null ? void 0 : _a.length) || 0)
  11658. );
  11659. const loc2 = getSelection(
  11660. context,
  11661. getNewPosition(context, start, startOffset),
  11662. getNewPosition(
  11663. context,
  11664. start,
  11665. startOffset + match2[2].length + (isSlot && match2[3] || "").length
  11666. )
  11667. );
  11668. let content = match2[2];
  11669. let isStatic = true;
  11670. if (content.startsWith("[")) {
  11671. isStatic = false;
  11672. if (!content.endsWith("]")) {
  11673. emitError(
  11674. context,
  11675. 27
  11676. );
  11677. content = content.slice(1);
  11678. } else {
  11679. content = content.slice(1, content.length - 1);
  11680. }
  11681. } else if (isSlot) {
  11682. content += match2[3] || "";
  11683. }
  11684. arg = {
  11685. type: 4,
  11686. content,
  11687. isStatic,
  11688. constType: isStatic ? 3 : 0,
  11689. loc: loc2
  11690. };
  11691. }
  11692. if (value && value.isQuoted) {
  11693. const valueLoc = value.loc;
  11694. valueLoc.start.offset++;
  11695. valueLoc.start.column++;
  11696. valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
  11697. valueLoc.source = valueLoc.source.slice(1, -1);
  11698. }
  11699. const modifiers = match2[3] ? match2[3].slice(1).split(".") : [];
  11700. if (isPropShorthand)
  11701. modifiers.push("prop");
  11702. return {
  11703. type: 7,
  11704. name: dirName,
  11705. exp: value && {
  11706. type: 4,
  11707. content: value.content,
  11708. isStatic: false,
  11709. // Treat as non-constant by default. This can be potentially set to
  11710. // other values by `transformExpression` to make it eligible for hoisting.
  11711. constType: 0,
  11712. loc: value.loc
  11713. },
  11714. arg,
  11715. modifiers,
  11716. loc
  11717. };
  11718. }
  11719. if (!context.inVPre && startsWith(name, "v-")) {
  11720. emitError(context, 26);
  11721. }
  11722. return {
  11723. type: 6,
  11724. name,
  11725. value: value && {
  11726. type: 2,
  11727. content: value.content,
  11728. loc: value.loc
  11729. },
  11730. loc
  11731. };
  11732. }
  11733. function parseAttributeValue(context) {
  11734. const start = getCursor(context);
  11735. let content;
  11736. const quote = context.source[0];
  11737. const isQuoted = quote === `"` || quote === `'`;
  11738. if (isQuoted) {
  11739. advanceBy(context, 1);
  11740. const endIndex = context.source.indexOf(quote);
  11741. if (endIndex === -1) {
  11742. content = parseTextData(
  11743. context,
  11744. context.source.length,
  11745. 4
  11746. );
  11747. } else {
  11748. content = parseTextData(context, endIndex, 4);
  11749. advanceBy(context, 1);
  11750. }
  11751. } else {
  11752. const match = /^[^\t\r\n\f >]+/.exec(context.source);
  11753. if (!match) {
  11754. return void 0;
  11755. }
  11756. const unexpectedChars = /["'<=`]/g;
  11757. let m;
  11758. while (m = unexpectedChars.exec(match[0])) {
  11759. emitError(
  11760. context,
  11761. 18,
  11762. m.index
  11763. );
  11764. }
  11765. content = parseTextData(context, match[0].length, 4);
  11766. }
  11767. return { content, isQuoted, loc: getSelection(context, start) };
  11768. }
  11769. function parseInterpolation(context, mode) {
  11770. const [open, close] = context.options.delimiters;
  11771. const closeIndex = context.source.indexOf(close, open.length);
  11772. if (closeIndex === -1) {
  11773. emitError(context, 25);
  11774. return void 0;
  11775. }
  11776. const start = getCursor(context);
  11777. advanceBy(context, open.length);
  11778. const innerStart = getCursor(context);
  11779. const innerEnd = getCursor(context);
  11780. const rawContentLength = closeIndex - open.length;
  11781. const rawContent = context.source.slice(0, rawContentLength);
  11782. const preTrimContent = parseTextData(context, rawContentLength, mode);
  11783. const content = preTrimContent.trim();
  11784. const startOffset = preTrimContent.indexOf(content);
  11785. if (startOffset > 0) {
  11786. advancePositionWithMutation(innerStart, rawContent, startOffset);
  11787. }
  11788. const endOffset = rawContentLength - (preTrimContent.length - content.length - startOffset);
  11789. advancePositionWithMutation(innerEnd, rawContent, endOffset);
  11790. advanceBy(context, close.length);
  11791. return {
  11792. type: 5,
  11793. content: {
  11794. type: 4,
  11795. isStatic: false,
  11796. // Set `isConstant` to false by default and will decide in transformExpression
  11797. constType: 0,
  11798. content,
  11799. loc: getSelection(context, innerStart, innerEnd)
  11800. },
  11801. loc: getSelection(context, start)
  11802. };
  11803. }
  11804. function parseText(context, mode) {
  11805. const endTokens = mode === 3 ? ["]]>"] : ["<", context.options.delimiters[0]];
  11806. let endIndex = context.source.length;
  11807. for (let i = 0; i < endTokens.length; i++) {
  11808. const index = context.source.indexOf(endTokens[i], 1);
  11809. if (index !== -1 && endIndex > index) {
  11810. endIndex = index;
  11811. }
  11812. }
  11813. const start = getCursor(context);
  11814. const content = parseTextData(context, endIndex, mode);
  11815. return {
  11816. type: 2,
  11817. content,
  11818. loc: getSelection(context, start)
  11819. };
  11820. }
  11821. function parseTextData(context, length, mode) {
  11822. const rawText = context.source.slice(0, length);
  11823. advanceBy(context, length);
  11824. if (mode === 2 || mode === 3 || !rawText.includes("&")) {
  11825. return rawText;
  11826. } else {
  11827. return context.options.decodeEntities(
  11828. rawText,
  11829. mode === 4
  11830. );
  11831. }
  11832. }
  11833. function getCursor(context) {
  11834. const { column, line, offset } = context;
  11835. return { column, line, offset };
  11836. }
  11837. function getSelection(context, start, end) {
  11838. end = end || getCursor(context);
  11839. return {
  11840. start,
  11841. end,
  11842. source: context.originalSource.slice(start.offset, end.offset)
  11843. };
  11844. }
  11845. function last(xs) {
  11846. return xs[xs.length - 1];
  11847. }
  11848. function startsWith(source, searchString) {
  11849. return source.startsWith(searchString);
  11850. }
  11851. function advanceBy(context, numberOfCharacters) {
  11852. const { source } = context;
  11853. advancePositionWithMutation(context, source, numberOfCharacters);
  11854. context.source = source.slice(numberOfCharacters);
  11855. }
  11856. function advanceSpaces(context) {
  11857. const match = /^[\t\r\n\f ]+/.exec(context.source);
  11858. if (match) {
  11859. advanceBy(context, match[0].length);
  11860. }
  11861. }
  11862. function getNewPosition(context, start, numberOfCharacters) {
  11863. return advancePositionWithClone(
  11864. start,
  11865. context.originalSource.slice(start.offset, numberOfCharacters),
  11866. numberOfCharacters
  11867. );
  11868. }
  11869. function emitError(context, code, offset, loc = getCursor(context)) {
  11870. if (offset) {
  11871. loc.offset += offset;
  11872. loc.column += offset;
  11873. }
  11874. context.options.onError(
  11875. createCompilerError(code, {
  11876. start: loc,
  11877. end: loc,
  11878. source: ""
  11879. })
  11880. );
  11881. }
  11882. function isEnd(context, mode, ancestors) {
  11883. const s = context.source;
  11884. switch (mode) {
  11885. case 0:
  11886. if (startsWith(s, "</")) {
  11887. for (let i = ancestors.length - 1; i >= 0; --i) {
  11888. if (startsWithEndTagOpen(s, ancestors[i].tag)) {
  11889. return true;
  11890. }
  11891. }
  11892. }
  11893. break;
  11894. case 1:
  11895. case 2: {
  11896. const parent = last(ancestors);
  11897. if (parent && startsWithEndTagOpen(s, parent.tag)) {
  11898. return true;
  11899. }
  11900. break;
  11901. }
  11902. case 3:
  11903. if (startsWith(s, "]]>")) {
  11904. return true;
  11905. }
  11906. break;
  11907. }
  11908. return !s;
  11909. }
  11910. function startsWithEndTagOpen(source, tag) {
  11911. return startsWith(source, "</") && source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() && /[\t\r\n\f />]/.test(source[2 + tag.length] || ">");
  11912. }
  11913. function hoistStatic(root, context) {
  11914. walk(
  11915. root,
  11916. context,
  11917. // Root node is unfortunately non-hoistable due to potential parent
  11918. // fallthrough attributes.
  11919. isSingleElementRoot(root, root.children[0])
  11920. );
  11921. }
  11922. function isSingleElementRoot(root, child) {
  11923. const { children } = root;
  11924. return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
  11925. }
  11926. function walk(node, context, doNotHoistNode = false) {
  11927. const { children } = node;
  11928. const originalCount = children.length;
  11929. let hoistedCount = 0;
  11930. for (let i = 0; i < children.length; i++) {
  11931. const child = children[i];
  11932. if (child.type === 1 && child.tagType === 0) {
  11933. const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
  11934. if (constantType > 0) {
  11935. if (constantType >= 2) {
  11936. child.codegenNode.patchFlag = -1 + (` /* HOISTED */` );
  11937. child.codegenNode = context.hoist(child.codegenNode);
  11938. hoistedCount++;
  11939. continue;
  11940. }
  11941. } else {
  11942. const codegenNode = child.codegenNode;
  11943. if (codegenNode.type === 13) {
  11944. const flag = getPatchFlag(codegenNode);
  11945. if ((!flag || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
  11946. const props = getNodeProps(child);
  11947. if (props) {
  11948. codegenNode.props = context.hoist(props);
  11949. }
  11950. }
  11951. if (codegenNode.dynamicProps) {
  11952. codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
  11953. }
  11954. }
  11955. }
  11956. }
  11957. if (child.type === 1) {
  11958. const isComponent = child.tagType === 1;
  11959. if (isComponent) {
  11960. context.scopes.vSlot++;
  11961. }
  11962. walk(child, context);
  11963. if (isComponent) {
  11964. context.scopes.vSlot--;
  11965. }
  11966. } else if (child.type === 11) {
  11967. walk(child, context, child.children.length === 1);
  11968. } else if (child.type === 9) {
  11969. for (let i2 = 0; i2 < child.branches.length; i2++) {
  11970. walk(
  11971. child.branches[i2],
  11972. context,
  11973. child.branches[i2].children.length === 1
  11974. );
  11975. }
  11976. }
  11977. }
  11978. if (hoistedCount && context.transformHoist) {
  11979. context.transformHoist(children, context, node);
  11980. }
  11981. if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
  11982. node.codegenNode.children = context.hoist(
  11983. createArrayExpression(node.codegenNode.children)
  11984. );
  11985. }
  11986. }
  11987. function getConstantType(node, context) {
  11988. const { constantCache } = context;
  11989. switch (node.type) {
  11990. case 1:
  11991. if (node.tagType !== 0) {
  11992. return 0;
  11993. }
  11994. const cached = constantCache.get(node);
  11995. if (cached !== void 0) {
  11996. return cached;
  11997. }
  11998. const codegenNode = node.codegenNode;
  11999. if (codegenNode.type !== 13) {
  12000. return 0;
  12001. }
  12002. if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject") {
  12003. return 0;
  12004. }
  12005. const flag = getPatchFlag(codegenNode);
  12006. if (!flag) {
  12007. let returnType2 = 3;
  12008. const generatedPropsType = getGeneratedPropsConstantType(node, context);
  12009. if (generatedPropsType === 0) {
  12010. constantCache.set(node, 0);
  12011. return 0;
  12012. }
  12013. if (generatedPropsType < returnType2) {
  12014. returnType2 = generatedPropsType;
  12015. }
  12016. for (let i = 0; i < node.children.length; i++) {
  12017. const childType = getConstantType(node.children[i], context);
  12018. if (childType === 0) {
  12019. constantCache.set(node, 0);
  12020. return 0;
  12021. }
  12022. if (childType < returnType2) {
  12023. returnType2 = childType;
  12024. }
  12025. }
  12026. if (returnType2 > 1) {
  12027. for (let i = 0; i < node.props.length; i++) {
  12028. const p = node.props[i];
  12029. if (p.type === 7 && p.name === "bind" && p.exp) {
  12030. const expType = getConstantType(p.exp, context);
  12031. if (expType === 0) {
  12032. constantCache.set(node, 0);
  12033. return 0;
  12034. }
  12035. if (expType < returnType2) {
  12036. returnType2 = expType;
  12037. }
  12038. }
  12039. }
  12040. }
  12041. if (codegenNode.isBlock) {
  12042. for (let i = 0; i < node.props.length; i++) {
  12043. const p = node.props[i];
  12044. if (p.type === 7) {
  12045. constantCache.set(node, 0);
  12046. return 0;
  12047. }
  12048. }
  12049. context.removeHelper(OPEN_BLOCK);
  12050. context.removeHelper(
  12051. getVNodeBlockHelper(context.inSSR, codegenNode.isComponent)
  12052. );
  12053. codegenNode.isBlock = false;
  12054. context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
  12055. }
  12056. constantCache.set(node, returnType2);
  12057. return returnType2;
  12058. } else {
  12059. constantCache.set(node, 0);
  12060. return 0;
  12061. }
  12062. case 2:
  12063. case 3:
  12064. return 3;
  12065. case 9:
  12066. case 11:
  12067. case 10:
  12068. return 0;
  12069. case 5:
  12070. case 12:
  12071. return getConstantType(node.content, context);
  12072. case 4:
  12073. return node.constType;
  12074. case 8:
  12075. let returnType = 3;
  12076. for (let i = 0; i < node.children.length; i++) {
  12077. const child = node.children[i];
  12078. if (isString(child) || isSymbol(child)) {
  12079. continue;
  12080. }
  12081. const childType = getConstantType(child, context);
  12082. if (childType === 0) {
  12083. return 0;
  12084. } else if (childType < returnType) {
  12085. returnType = childType;
  12086. }
  12087. }
  12088. return returnType;
  12089. default:
  12090. return 0;
  12091. }
  12092. }
  12093. const allowHoistedHelperSet = /* @__PURE__ */ new Set([
  12094. NORMALIZE_CLASS,
  12095. NORMALIZE_STYLE,
  12096. NORMALIZE_PROPS,
  12097. GUARD_REACTIVE_PROPS
  12098. ]);
  12099. function getConstantTypeOfHelperCall(value, context) {
  12100. if (value.type === 14 && !isString(value.callee) && allowHoistedHelperSet.has(value.callee)) {
  12101. const arg = value.arguments[0];
  12102. if (arg.type === 4) {
  12103. return getConstantType(arg, context);
  12104. } else if (arg.type === 14) {
  12105. return getConstantTypeOfHelperCall(arg, context);
  12106. }
  12107. }
  12108. return 0;
  12109. }
  12110. function getGeneratedPropsConstantType(node, context) {
  12111. let returnType = 3;
  12112. const props = getNodeProps(node);
  12113. if (props && props.type === 15) {
  12114. const { properties } = props;
  12115. for (let i = 0; i < properties.length; i++) {
  12116. const { key, value } = properties[i];
  12117. const keyType = getConstantType(key, context);
  12118. if (keyType === 0) {
  12119. return keyType;
  12120. }
  12121. if (keyType < returnType) {
  12122. returnType = keyType;
  12123. }
  12124. let valueType;
  12125. if (value.type === 4) {
  12126. valueType = getConstantType(value, context);
  12127. } else if (value.type === 14) {
  12128. valueType = getConstantTypeOfHelperCall(value, context);
  12129. } else {
  12130. valueType = 0;
  12131. }
  12132. if (valueType === 0) {
  12133. return valueType;
  12134. }
  12135. if (valueType < returnType) {
  12136. returnType = valueType;
  12137. }
  12138. }
  12139. }
  12140. return returnType;
  12141. }
  12142. function getNodeProps(node) {
  12143. const codegenNode = node.codegenNode;
  12144. if (codegenNode.type === 13) {
  12145. return codegenNode.props;
  12146. }
  12147. }
  12148. function getPatchFlag(node) {
  12149. const flag = node.patchFlag;
  12150. return flag ? parseInt(flag, 10) : void 0;
  12151. }
  12152. function createTransformContext(root, {
  12153. filename = "",
  12154. prefixIdentifiers = false,
  12155. hoistStatic: hoistStatic2 = false,
  12156. cacheHandlers = false,
  12157. nodeTransforms = [],
  12158. directiveTransforms = {},
  12159. transformHoist = null,
  12160. isBuiltInComponent = NOOP,
  12161. isCustomElement = NOOP,
  12162. expressionPlugins = [],
  12163. scopeId = null,
  12164. slotted = true,
  12165. ssr = false,
  12166. inSSR = false,
  12167. ssrCssVars = ``,
  12168. bindingMetadata = EMPTY_OBJ,
  12169. inline = false,
  12170. isTS = false,
  12171. onError = defaultOnError,
  12172. onWarn = defaultOnWarn,
  12173. compatConfig
  12174. }) {
  12175. const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
  12176. const context = {
  12177. // options
  12178. selfName: nameMatch && capitalize(camelize(nameMatch[1])),
  12179. prefixIdentifiers,
  12180. hoistStatic: hoistStatic2,
  12181. cacheHandlers,
  12182. nodeTransforms,
  12183. directiveTransforms,
  12184. transformHoist,
  12185. isBuiltInComponent,
  12186. isCustomElement,
  12187. expressionPlugins,
  12188. scopeId,
  12189. slotted,
  12190. ssr,
  12191. inSSR,
  12192. ssrCssVars,
  12193. bindingMetadata,
  12194. inline,
  12195. isTS,
  12196. onError,
  12197. onWarn,
  12198. compatConfig,
  12199. // state
  12200. root,
  12201. helpers: /* @__PURE__ */ new Map(),
  12202. components: /* @__PURE__ */ new Set(),
  12203. directives: /* @__PURE__ */ new Set(),
  12204. hoists: [],
  12205. imports: [],
  12206. constantCache: /* @__PURE__ */ new Map(),
  12207. temps: 0,
  12208. cached: 0,
  12209. identifiers: /* @__PURE__ */ Object.create(null),
  12210. scopes: {
  12211. vFor: 0,
  12212. vSlot: 0,
  12213. vPre: 0,
  12214. vOnce: 0
  12215. },
  12216. parent: null,
  12217. currentNode: root,
  12218. childIndex: 0,
  12219. inVOnce: false,
  12220. // methods
  12221. helper(name) {
  12222. const count = context.helpers.get(name) || 0;
  12223. context.helpers.set(name, count + 1);
  12224. return name;
  12225. },
  12226. removeHelper(name) {
  12227. const count = context.helpers.get(name);
  12228. if (count) {
  12229. const currentCount = count - 1;
  12230. if (!currentCount) {
  12231. context.helpers.delete(name);
  12232. } else {
  12233. context.helpers.set(name, currentCount);
  12234. }
  12235. }
  12236. },
  12237. helperString(name) {
  12238. return `_${helperNameMap[context.helper(name)]}`;
  12239. },
  12240. replaceNode(node) {
  12241. {
  12242. if (!context.currentNode) {
  12243. throw new Error(`Node being replaced is already removed.`);
  12244. }
  12245. if (!context.parent) {
  12246. throw new Error(`Cannot replace root node.`);
  12247. }
  12248. }
  12249. context.parent.children[context.childIndex] = context.currentNode = node;
  12250. },
  12251. removeNode(node) {
  12252. if (!context.parent) {
  12253. throw new Error(`Cannot remove root node.`);
  12254. }
  12255. const list = context.parent.children;
  12256. const removalIndex = node ? list.indexOf(node) : context.currentNode ? context.childIndex : -1;
  12257. if (removalIndex < 0) {
  12258. throw new Error(`node being removed is not a child of current parent`);
  12259. }
  12260. if (!node || node === context.currentNode) {
  12261. context.currentNode = null;
  12262. context.onNodeRemoved();
  12263. } else {
  12264. if (context.childIndex > removalIndex) {
  12265. context.childIndex--;
  12266. context.onNodeRemoved();
  12267. }
  12268. }
  12269. context.parent.children.splice(removalIndex, 1);
  12270. },
  12271. onNodeRemoved: () => {
  12272. },
  12273. addIdentifiers(exp) {
  12274. },
  12275. removeIdentifiers(exp) {
  12276. },
  12277. hoist(exp) {
  12278. if (isString(exp))
  12279. exp = createSimpleExpression(exp);
  12280. context.hoists.push(exp);
  12281. const identifier = createSimpleExpression(
  12282. `_hoisted_${context.hoists.length}`,
  12283. false,
  12284. exp.loc,
  12285. 2
  12286. );
  12287. identifier.hoisted = exp;
  12288. return identifier;
  12289. },
  12290. cache(exp, isVNode = false) {
  12291. return createCacheExpression(context.cached++, exp, isVNode);
  12292. }
  12293. };
  12294. return context;
  12295. }
  12296. function transform(root, options) {
  12297. const context = createTransformContext(root, options);
  12298. traverseNode(root, context);
  12299. if (options.hoistStatic) {
  12300. hoistStatic(root, context);
  12301. }
  12302. if (!options.ssr) {
  12303. createRootCodegen(root, context);
  12304. }
  12305. root.helpers = /* @__PURE__ */ new Set([...context.helpers.keys()]);
  12306. root.components = [...context.components];
  12307. root.directives = [...context.directives];
  12308. root.imports = context.imports;
  12309. root.hoists = context.hoists;
  12310. root.temps = context.temps;
  12311. root.cached = context.cached;
  12312. }
  12313. function createRootCodegen(root, context) {
  12314. const { helper } = context;
  12315. const { children } = root;
  12316. if (children.length === 1) {
  12317. const child = children[0];
  12318. if (isSingleElementRoot(root, child) && child.codegenNode) {
  12319. const codegenNode = child.codegenNode;
  12320. if (codegenNode.type === 13) {
  12321. convertToBlock(codegenNode, context);
  12322. }
  12323. root.codegenNode = codegenNode;
  12324. } else {
  12325. root.codegenNode = child;
  12326. }
  12327. } else if (children.length > 1) {
  12328. let patchFlag = 64;
  12329. let patchFlagText = PatchFlagNames[64];
  12330. if (children.filter((c) => c.type !== 3).length === 1) {
  12331. patchFlag |= 2048;
  12332. patchFlagText += `, ${PatchFlagNames[2048]}`;
  12333. }
  12334. root.codegenNode = createVNodeCall(
  12335. context,
  12336. helper(FRAGMENT),
  12337. void 0,
  12338. root.children,
  12339. patchFlag + (` /* ${patchFlagText} */` ),
  12340. void 0,
  12341. void 0,
  12342. true,
  12343. void 0,
  12344. false
  12345. /* isComponent */
  12346. );
  12347. } else ;
  12348. }
  12349. function traverseChildren(parent, context) {
  12350. let i = 0;
  12351. const nodeRemoved = () => {
  12352. i--;
  12353. };
  12354. for (; i < parent.children.length; i++) {
  12355. const child = parent.children[i];
  12356. if (isString(child))
  12357. continue;
  12358. context.parent = parent;
  12359. context.childIndex = i;
  12360. context.onNodeRemoved = nodeRemoved;
  12361. traverseNode(child, context);
  12362. }
  12363. }
  12364. function traverseNode(node, context) {
  12365. context.currentNode = node;
  12366. const { nodeTransforms } = context;
  12367. const exitFns = [];
  12368. for (let i2 = 0; i2 < nodeTransforms.length; i2++) {
  12369. const onExit = nodeTransforms[i2](node, context);
  12370. if (onExit) {
  12371. if (isArray(onExit)) {
  12372. exitFns.push(...onExit);
  12373. } else {
  12374. exitFns.push(onExit);
  12375. }
  12376. }
  12377. if (!context.currentNode) {
  12378. return;
  12379. } else {
  12380. node = context.currentNode;
  12381. }
  12382. }
  12383. switch (node.type) {
  12384. case 3:
  12385. if (!context.ssr) {
  12386. context.helper(CREATE_COMMENT);
  12387. }
  12388. break;
  12389. case 5:
  12390. if (!context.ssr) {
  12391. context.helper(TO_DISPLAY_STRING);
  12392. }
  12393. break;
  12394. case 9:
  12395. for (let i2 = 0; i2 < node.branches.length; i2++) {
  12396. traverseNode(node.branches[i2], context);
  12397. }
  12398. break;
  12399. case 10:
  12400. case 11:
  12401. case 1:
  12402. case 0:
  12403. traverseChildren(node, context);
  12404. break;
  12405. }
  12406. context.currentNode = node;
  12407. let i = exitFns.length;
  12408. while (i--) {
  12409. exitFns[i]();
  12410. }
  12411. }
  12412. function createStructuralDirectiveTransform(name, fn) {
  12413. const matches = isString(name) ? (n) => n === name : (n) => name.test(n);
  12414. return (node, context) => {
  12415. if (node.type === 1) {
  12416. const { props } = node;
  12417. if (node.tagType === 3 && props.some(isVSlot)) {
  12418. return;
  12419. }
  12420. const exitFns = [];
  12421. for (let i = 0; i < props.length; i++) {
  12422. const prop = props[i];
  12423. if (prop.type === 7 && matches(prop.name)) {
  12424. props.splice(i, 1);
  12425. i--;
  12426. const onExit = fn(node, prop, context);
  12427. if (onExit)
  12428. exitFns.push(onExit);
  12429. }
  12430. }
  12431. return exitFns;
  12432. }
  12433. };
  12434. }
  12435. const PURE_ANNOTATION = `/*#__PURE__*/`;
  12436. const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
  12437. function createCodegenContext(ast, {
  12438. mode = "function",
  12439. prefixIdentifiers = mode === "module",
  12440. sourceMap = false,
  12441. filename = `template.vue.html`,
  12442. scopeId = null,
  12443. optimizeImports = false,
  12444. runtimeGlobalName = `Vue`,
  12445. runtimeModuleName = `vue`,
  12446. ssrRuntimeModuleName = "vue/server-renderer",
  12447. ssr = false,
  12448. isTS = false,
  12449. inSSR = false
  12450. }) {
  12451. const context = {
  12452. mode,
  12453. prefixIdentifiers,
  12454. sourceMap,
  12455. filename,
  12456. scopeId,
  12457. optimizeImports,
  12458. runtimeGlobalName,
  12459. runtimeModuleName,
  12460. ssrRuntimeModuleName,
  12461. ssr,
  12462. isTS,
  12463. inSSR,
  12464. source: ast.loc.source,
  12465. code: ``,
  12466. column: 1,
  12467. line: 1,
  12468. offset: 0,
  12469. indentLevel: 0,
  12470. pure: false,
  12471. map: void 0,
  12472. helper(key) {
  12473. return `_${helperNameMap[key]}`;
  12474. },
  12475. push(code, node) {
  12476. context.code += code;
  12477. },
  12478. indent() {
  12479. newline(++context.indentLevel);
  12480. },
  12481. deindent(withoutNewLine = false) {
  12482. if (withoutNewLine) {
  12483. --context.indentLevel;
  12484. } else {
  12485. newline(--context.indentLevel);
  12486. }
  12487. },
  12488. newline() {
  12489. newline(context.indentLevel);
  12490. }
  12491. };
  12492. function newline(n) {
  12493. context.push("\n" + ` `.repeat(n));
  12494. }
  12495. return context;
  12496. }
  12497. function generate(ast, options = {}) {
  12498. const context = createCodegenContext(ast, options);
  12499. if (options.onContextCreated)
  12500. options.onContextCreated(context);
  12501. const {
  12502. mode,
  12503. push,
  12504. prefixIdentifiers,
  12505. indent,
  12506. deindent,
  12507. newline,
  12508. scopeId,
  12509. ssr
  12510. } = context;
  12511. const helpers = Array.from(ast.helpers);
  12512. const hasHelpers = helpers.length > 0;
  12513. const useWithBlock = !prefixIdentifiers && mode !== "module";
  12514. const isSetupInlined = false;
  12515. const preambleContext = isSetupInlined ? createCodegenContext(ast, options) : context;
  12516. {
  12517. genFunctionPreamble(ast, preambleContext);
  12518. }
  12519. const functionName = ssr ? `ssrRender` : `render`;
  12520. const args = ssr ? ["_ctx", "_push", "_parent", "_attrs"] : ["_ctx", "_cache"];
  12521. const signature = args.join(", ");
  12522. {
  12523. push(`function ${functionName}(${signature}) {`);
  12524. }
  12525. indent();
  12526. if (useWithBlock) {
  12527. push(`with (_ctx) {`);
  12528. indent();
  12529. if (hasHelpers) {
  12530. push(`const { ${helpers.map(aliasHelper).join(", ")} } = _Vue`);
  12531. push(`
  12532. `);
  12533. newline();
  12534. }
  12535. }
  12536. if (ast.components.length) {
  12537. genAssets(ast.components, "component", context);
  12538. if (ast.directives.length || ast.temps > 0) {
  12539. newline();
  12540. }
  12541. }
  12542. if (ast.directives.length) {
  12543. genAssets(ast.directives, "directive", context);
  12544. if (ast.temps > 0) {
  12545. newline();
  12546. }
  12547. }
  12548. if (ast.temps > 0) {
  12549. push(`let `);
  12550. for (let i = 0; i < ast.temps; i++) {
  12551. push(`${i > 0 ? `, ` : ``}_temp${i}`);
  12552. }
  12553. }
  12554. if (ast.components.length || ast.directives.length || ast.temps) {
  12555. push(`
  12556. `);
  12557. newline();
  12558. }
  12559. if (!ssr) {
  12560. push(`return `);
  12561. }
  12562. if (ast.codegenNode) {
  12563. genNode(ast.codegenNode, context);
  12564. } else {
  12565. push(`null`);
  12566. }
  12567. if (useWithBlock) {
  12568. deindent();
  12569. push(`}`);
  12570. }
  12571. deindent();
  12572. push(`}`);
  12573. return {
  12574. ast,
  12575. code: context.code,
  12576. preamble: isSetupInlined ? preambleContext.code : ``,
  12577. // SourceMapGenerator does have toJSON() method but it's not in the types
  12578. map: context.map ? context.map.toJSON() : void 0
  12579. };
  12580. }
  12581. function genFunctionPreamble(ast, context) {
  12582. const {
  12583. ssr,
  12584. prefixIdentifiers,
  12585. push,
  12586. newline,
  12587. runtimeModuleName,
  12588. runtimeGlobalName,
  12589. ssrRuntimeModuleName
  12590. } = context;
  12591. const VueBinding = runtimeGlobalName;
  12592. const helpers = Array.from(ast.helpers);
  12593. if (helpers.length > 0) {
  12594. {
  12595. push(`const _Vue = ${VueBinding}
  12596. `);
  12597. if (ast.hoists.length) {
  12598. const staticHelpers = [
  12599. CREATE_VNODE,
  12600. CREATE_ELEMENT_VNODE,
  12601. CREATE_COMMENT,
  12602. CREATE_TEXT,
  12603. CREATE_STATIC
  12604. ].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
  12605. push(`const { ${staticHelpers} } = _Vue
  12606. `);
  12607. }
  12608. }
  12609. }
  12610. genHoists(ast.hoists, context);
  12611. newline();
  12612. push(`return `);
  12613. }
  12614. function genAssets(assets, type, { helper, push, newline, isTS }) {
  12615. const resolver = helper(
  12616. type === "component" ? RESOLVE_COMPONENT : RESOLVE_DIRECTIVE
  12617. );
  12618. for (let i = 0; i < assets.length; i++) {
  12619. let id = assets[i];
  12620. const maybeSelfReference = id.endsWith("__self");
  12621. if (maybeSelfReference) {
  12622. id = id.slice(0, -6);
  12623. }
  12624. push(
  12625. `const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`
  12626. );
  12627. if (i < assets.length - 1) {
  12628. newline();
  12629. }
  12630. }
  12631. }
  12632. function genHoists(hoists, context) {
  12633. if (!hoists.length) {
  12634. return;
  12635. }
  12636. context.pure = true;
  12637. const { push, newline, helper, scopeId, mode } = context;
  12638. newline();
  12639. for (let i = 0; i < hoists.length; i++) {
  12640. const exp = hoists[i];
  12641. if (exp) {
  12642. push(
  12643. `const _hoisted_${i + 1} = ${``}`
  12644. );
  12645. genNode(exp, context);
  12646. newline();
  12647. }
  12648. }
  12649. context.pure = false;
  12650. }
  12651. function isText(n) {
  12652. return isString(n) || n.type === 4 || n.type === 2 || n.type === 5 || n.type === 8;
  12653. }
  12654. function genNodeListAsArray(nodes, context) {
  12655. const multilines = nodes.length > 3 || nodes.some((n) => isArray(n) || !isText(n));
  12656. context.push(`[`);
  12657. multilines && context.indent();
  12658. genNodeList(nodes, context, multilines);
  12659. multilines && context.deindent();
  12660. context.push(`]`);
  12661. }
  12662. function genNodeList(nodes, context, multilines = false, comma = true) {
  12663. const { push, newline } = context;
  12664. for (let i = 0; i < nodes.length; i++) {
  12665. const node = nodes[i];
  12666. if (isString(node)) {
  12667. push(node);
  12668. } else if (isArray(node)) {
  12669. genNodeListAsArray(node, context);
  12670. } else {
  12671. genNode(node, context);
  12672. }
  12673. if (i < nodes.length - 1) {
  12674. if (multilines) {
  12675. comma && push(",");
  12676. newline();
  12677. } else {
  12678. comma && push(", ");
  12679. }
  12680. }
  12681. }
  12682. }
  12683. function genNode(node, context) {
  12684. if (isString(node)) {
  12685. context.push(node);
  12686. return;
  12687. }
  12688. if (isSymbol(node)) {
  12689. context.push(context.helper(node));
  12690. return;
  12691. }
  12692. switch (node.type) {
  12693. case 1:
  12694. case 9:
  12695. case 11:
  12696. assert(
  12697. node.codegenNode != null,
  12698. `Codegen node is missing for element/if/for node. Apply appropriate transforms first.`
  12699. );
  12700. genNode(node.codegenNode, context);
  12701. break;
  12702. case 2:
  12703. genText(node, context);
  12704. break;
  12705. case 4:
  12706. genExpression(node, context);
  12707. break;
  12708. case 5:
  12709. genInterpolation(node, context);
  12710. break;
  12711. case 12:
  12712. genNode(node.codegenNode, context);
  12713. break;
  12714. case 8:
  12715. genCompoundExpression(node, context);
  12716. break;
  12717. case 3:
  12718. genComment(node, context);
  12719. break;
  12720. case 13:
  12721. genVNodeCall(node, context);
  12722. break;
  12723. case 14:
  12724. genCallExpression(node, context);
  12725. break;
  12726. case 15:
  12727. genObjectExpression(node, context);
  12728. break;
  12729. case 17:
  12730. genArrayExpression(node, context);
  12731. break;
  12732. case 18:
  12733. genFunctionExpression(node, context);
  12734. break;
  12735. case 19:
  12736. genConditionalExpression(node, context);
  12737. break;
  12738. case 20:
  12739. genCacheExpression(node, context);
  12740. break;
  12741. case 21:
  12742. genNodeList(node.body, context, true, false);
  12743. break;
  12744. case 22:
  12745. break;
  12746. case 23:
  12747. break;
  12748. case 24:
  12749. break;
  12750. case 25:
  12751. break;
  12752. case 26:
  12753. break;
  12754. case 10:
  12755. break;
  12756. default:
  12757. {
  12758. assert(false, `unhandled codegen node type: ${node.type}`);
  12759. const exhaustiveCheck = node;
  12760. return exhaustiveCheck;
  12761. }
  12762. }
  12763. }
  12764. function genText(node, context) {
  12765. context.push(JSON.stringify(node.content), node);
  12766. }
  12767. function genExpression(node, context) {
  12768. const { content, isStatic } = node;
  12769. context.push(isStatic ? JSON.stringify(content) : content, node);
  12770. }
  12771. function genInterpolation(node, context) {
  12772. const { push, helper, pure } = context;
  12773. if (pure)
  12774. push(PURE_ANNOTATION);
  12775. push(`${helper(TO_DISPLAY_STRING)}(`);
  12776. genNode(node.content, context);
  12777. push(`)`);
  12778. }
  12779. function genCompoundExpression(node, context) {
  12780. for (let i = 0; i < node.children.length; i++) {
  12781. const child = node.children[i];
  12782. if (isString(child)) {
  12783. context.push(child);
  12784. } else {
  12785. genNode(child, context);
  12786. }
  12787. }
  12788. }
  12789. function genExpressionAsPropertyKey(node, context) {
  12790. const { push } = context;
  12791. if (node.type === 8) {
  12792. push(`[`);
  12793. genCompoundExpression(node, context);
  12794. push(`]`);
  12795. } else if (node.isStatic) {
  12796. const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
  12797. push(text, node);
  12798. } else {
  12799. push(`[${node.content}]`, node);
  12800. }
  12801. }
  12802. function genComment(node, context) {
  12803. const { push, helper, pure } = context;
  12804. if (pure) {
  12805. push(PURE_ANNOTATION);
  12806. }
  12807. push(`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`, node);
  12808. }
  12809. function genVNodeCall(node, context) {
  12810. const { push, helper, pure } = context;
  12811. const {
  12812. tag,
  12813. props,
  12814. children,
  12815. patchFlag,
  12816. dynamicProps,
  12817. directives,
  12818. isBlock,
  12819. disableTracking,
  12820. isComponent
  12821. } = node;
  12822. if (directives) {
  12823. push(helper(WITH_DIRECTIVES) + `(`);
  12824. }
  12825. if (isBlock) {
  12826. push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
  12827. }
  12828. if (pure) {
  12829. push(PURE_ANNOTATION);
  12830. }
  12831. const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
  12832. push(helper(callHelper) + `(`, node);
  12833. genNodeList(
  12834. genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
  12835. context
  12836. );
  12837. push(`)`);
  12838. if (isBlock) {
  12839. push(`)`);
  12840. }
  12841. if (directives) {
  12842. push(`, `);
  12843. genNode(directives, context);
  12844. push(`)`);
  12845. }
  12846. }
  12847. function genNullableArgs(args) {
  12848. let i = args.length;
  12849. while (i--) {
  12850. if (args[i] != null)
  12851. break;
  12852. }
  12853. return args.slice(0, i + 1).map((arg) => arg || `null`);
  12854. }
  12855. function genCallExpression(node, context) {
  12856. const { push, helper, pure } = context;
  12857. const callee = isString(node.callee) ? node.callee : helper(node.callee);
  12858. if (pure) {
  12859. push(PURE_ANNOTATION);
  12860. }
  12861. push(callee + `(`, node);
  12862. genNodeList(node.arguments, context);
  12863. push(`)`);
  12864. }
  12865. function genObjectExpression(node, context) {
  12866. const { push, indent, deindent, newline } = context;
  12867. const { properties } = node;
  12868. if (!properties.length) {
  12869. push(`{}`, node);
  12870. return;
  12871. }
  12872. const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
  12873. push(multilines ? `{` : `{ `);
  12874. multilines && indent();
  12875. for (let i = 0; i < properties.length; i++) {
  12876. const { key, value } = properties[i];
  12877. genExpressionAsPropertyKey(key, context);
  12878. push(`: `);
  12879. genNode(value, context);
  12880. if (i < properties.length - 1) {
  12881. push(`,`);
  12882. newline();
  12883. }
  12884. }
  12885. multilines && deindent();
  12886. push(multilines ? `}` : ` }`);
  12887. }
  12888. function genArrayExpression(node, context) {
  12889. genNodeListAsArray(node.elements, context);
  12890. }
  12891. function genFunctionExpression(node, context) {
  12892. const { push, indent, deindent } = context;
  12893. const { params, returns, body, newline, isSlot } = node;
  12894. if (isSlot) {
  12895. push(`_${helperNameMap[WITH_CTX]}(`);
  12896. }
  12897. push(`(`, node);
  12898. if (isArray(params)) {
  12899. genNodeList(params, context);
  12900. } else if (params) {
  12901. genNode(params, context);
  12902. }
  12903. push(`) => `);
  12904. if (newline || body) {
  12905. push(`{`);
  12906. indent();
  12907. }
  12908. if (returns) {
  12909. if (newline) {
  12910. push(`return `);
  12911. }
  12912. if (isArray(returns)) {
  12913. genNodeListAsArray(returns, context);
  12914. } else {
  12915. genNode(returns, context);
  12916. }
  12917. } else if (body) {
  12918. genNode(body, context);
  12919. }
  12920. if (newline || body) {
  12921. deindent();
  12922. push(`}`);
  12923. }
  12924. if (isSlot) {
  12925. push(`)`);
  12926. }
  12927. }
  12928. function genConditionalExpression(node, context) {
  12929. const { test, consequent, alternate, newline: needNewline } = node;
  12930. const { push, indent, deindent, newline } = context;
  12931. if (test.type === 4) {
  12932. const needsParens = !isSimpleIdentifier(test.content);
  12933. needsParens && push(`(`);
  12934. genExpression(test, context);
  12935. needsParens && push(`)`);
  12936. } else {
  12937. push(`(`);
  12938. genNode(test, context);
  12939. push(`)`);
  12940. }
  12941. needNewline && indent();
  12942. context.indentLevel++;
  12943. needNewline || push(` `);
  12944. push(`? `);
  12945. genNode(consequent, context);
  12946. context.indentLevel--;
  12947. needNewline && newline();
  12948. needNewline || push(` `);
  12949. push(`: `);
  12950. const isNested = alternate.type === 19;
  12951. if (!isNested) {
  12952. context.indentLevel++;
  12953. }
  12954. genNode(alternate, context);
  12955. if (!isNested) {
  12956. context.indentLevel--;
  12957. }
  12958. needNewline && deindent(
  12959. true
  12960. /* without newline */
  12961. );
  12962. }
  12963. function genCacheExpression(node, context) {
  12964. const { push, helper, indent, deindent, newline } = context;
  12965. push(`_cache[${node.index}] || (`);
  12966. if (node.isVNode) {
  12967. indent();
  12968. push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
  12969. newline();
  12970. }
  12971. push(`_cache[${node.index}] = `);
  12972. genNode(node.value, context);
  12973. if (node.isVNode) {
  12974. push(`,`);
  12975. newline();
  12976. push(`${helper(SET_BLOCK_TRACKING)}(1),`);
  12977. newline();
  12978. push(`_cache[${node.index}]`);
  12979. deindent();
  12980. }
  12981. push(`)`);
  12982. }
  12983. const prohibitedKeywordRE = new RegExp(
  12984. "\\b" + "arguments,await,break,case,catch,class,const,continue,debugger,default,delete,do,else,export,extends,finally,for,function,if,import,let,new,return,super,switch,throw,try,var,void,while,with,yield".split(",").join("\\b|\\b") + "\\b"
  12985. );
  12986. const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  12987. function validateBrowserExpression(node, context, asParams = false, asRawStatements = false) {
  12988. const exp = node.content;
  12989. if (!exp.trim()) {
  12990. return;
  12991. }
  12992. try {
  12993. new Function(
  12994. asRawStatements ? ` ${exp} ` : `return ${asParams ? `(${exp}) => {}` : `(${exp})`}`
  12995. );
  12996. } catch (e) {
  12997. let message = e.message;
  12998. const keywordMatch = exp.replace(stripStringRE, "").match(prohibitedKeywordRE);
  12999. if (keywordMatch) {
  13000. message = `avoid using JavaScript keyword as property name: "${keywordMatch[0]}"`;
  13001. }
  13002. context.onError(
  13003. createCompilerError(
  13004. 45,
  13005. node.loc,
  13006. void 0,
  13007. message
  13008. )
  13009. );
  13010. }
  13011. }
  13012. const transformExpression = (node, context) => {
  13013. if (node.type === 5) {
  13014. node.content = processExpression(
  13015. node.content,
  13016. context
  13017. );
  13018. } else if (node.type === 1) {
  13019. for (let i = 0; i < node.props.length; i++) {
  13020. const dir = node.props[i];
  13021. if (dir.type === 7 && dir.name !== "for") {
  13022. const exp = dir.exp;
  13023. const arg = dir.arg;
  13024. if (exp && exp.type === 4 && !(dir.name === "on" && arg)) {
  13025. dir.exp = processExpression(
  13026. exp,
  13027. context,
  13028. // slot args must be processed as function params
  13029. dir.name === "slot"
  13030. );
  13031. }
  13032. if (arg && arg.type === 4 && !arg.isStatic) {
  13033. dir.arg = processExpression(arg, context);
  13034. }
  13035. }
  13036. }
  13037. }
  13038. };
  13039. function processExpression(node, context, asParams = false, asRawStatements = false, localVars = Object.create(context.identifiers)) {
  13040. {
  13041. {
  13042. validateBrowserExpression(node, context, asParams, asRawStatements);
  13043. }
  13044. return node;
  13045. }
  13046. }
  13047. const transformIf = createStructuralDirectiveTransform(
  13048. /^(if|else|else-if)$/,
  13049. (node, dir, context) => {
  13050. return processIf(node, dir, context, (ifNode, branch, isRoot) => {
  13051. const siblings = context.parent.children;
  13052. let i = siblings.indexOf(ifNode);
  13053. let key = 0;
  13054. while (i-- >= 0) {
  13055. const sibling = siblings[i];
  13056. if (sibling && sibling.type === 9) {
  13057. key += sibling.branches.length;
  13058. }
  13059. }
  13060. return () => {
  13061. if (isRoot) {
  13062. ifNode.codegenNode = createCodegenNodeForBranch(
  13063. branch,
  13064. key,
  13065. context
  13066. );
  13067. } else {
  13068. const parentCondition = getParentCondition(ifNode.codegenNode);
  13069. parentCondition.alternate = createCodegenNodeForBranch(
  13070. branch,
  13071. key + ifNode.branches.length - 1,
  13072. context
  13073. );
  13074. }
  13075. };
  13076. });
  13077. }
  13078. );
  13079. function processIf(node, dir, context, processCodegen) {
  13080. if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
  13081. const loc = dir.exp ? dir.exp.loc : node.loc;
  13082. context.onError(
  13083. createCompilerError(28, dir.loc)
  13084. );
  13085. dir.exp = createSimpleExpression(`true`, false, loc);
  13086. }
  13087. if (dir.exp) {
  13088. validateBrowserExpression(dir.exp, context);
  13089. }
  13090. if (dir.name === "if") {
  13091. const branch = createIfBranch(node, dir);
  13092. const ifNode = {
  13093. type: 9,
  13094. loc: node.loc,
  13095. branches: [branch]
  13096. };
  13097. context.replaceNode(ifNode);
  13098. if (processCodegen) {
  13099. return processCodegen(ifNode, branch, true);
  13100. }
  13101. } else {
  13102. const siblings = context.parent.children;
  13103. const comments = [];
  13104. let i = siblings.indexOf(node);
  13105. while (i-- >= -1) {
  13106. const sibling = siblings[i];
  13107. if (sibling && sibling.type === 3) {
  13108. context.removeNode(sibling);
  13109. comments.unshift(sibling);
  13110. continue;
  13111. }
  13112. if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
  13113. context.removeNode(sibling);
  13114. continue;
  13115. }
  13116. if (sibling && sibling.type === 9) {
  13117. if (dir.name === "else-if" && sibling.branches[sibling.branches.length - 1].condition === void 0) {
  13118. context.onError(
  13119. createCompilerError(30, node.loc)
  13120. );
  13121. }
  13122. context.removeNode();
  13123. const branch = createIfBranch(node, dir);
  13124. if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
  13125. !(context.parent && context.parent.type === 1 && isBuiltInType(context.parent.tag, "transition"))) {
  13126. branch.children = [...comments, ...branch.children];
  13127. }
  13128. {
  13129. const key = branch.userKey;
  13130. if (key) {
  13131. sibling.branches.forEach(({ userKey }) => {
  13132. if (isSameKey(userKey, key)) {
  13133. context.onError(
  13134. createCompilerError(
  13135. 29,
  13136. branch.userKey.loc
  13137. )
  13138. );
  13139. }
  13140. });
  13141. }
  13142. }
  13143. sibling.branches.push(branch);
  13144. const onExit = processCodegen && processCodegen(sibling, branch, false);
  13145. traverseNode(branch, context);
  13146. if (onExit)
  13147. onExit();
  13148. context.currentNode = null;
  13149. } else {
  13150. context.onError(
  13151. createCompilerError(30, node.loc)
  13152. );
  13153. }
  13154. break;
  13155. }
  13156. }
  13157. }
  13158. function createIfBranch(node, dir) {
  13159. const isTemplateIf = node.tagType === 3;
  13160. return {
  13161. type: 10,
  13162. loc: node.loc,
  13163. condition: dir.name === "else" ? void 0 : dir.exp,
  13164. children: isTemplateIf && !findDir(node, "for") ? node.children : [node],
  13165. userKey: findProp(node, `key`),
  13166. isTemplateIf
  13167. };
  13168. }
  13169. function createCodegenNodeForBranch(branch, keyIndex, context) {
  13170. if (branch.condition) {
  13171. return createConditionalExpression(
  13172. branch.condition,
  13173. createChildrenCodegenNode(branch, keyIndex, context),
  13174. // make sure to pass in asBlock: true so that the comment node call
  13175. // closes the current block.
  13176. createCallExpression(context.helper(CREATE_COMMENT), [
  13177. '"v-if"' ,
  13178. "true"
  13179. ])
  13180. );
  13181. } else {
  13182. return createChildrenCodegenNode(branch, keyIndex, context);
  13183. }
  13184. }
  13185. function createChildrenCodegenNode(branch, keyIndex, context) {
  13186. const { helper } = context;
  13187. const keyProperty = createObjectProperty(
  13188. `key`,
  13189. createSimpleExpression(
  13190. `${keyIndex}`,
  13191. false,
  13192. locStub,
  13193. 2
  13194. )
  13195. );
  13196. const { children } = branch;
  13197. const firstChild = children[0];
  13198. const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1;
  13199. if (needFragmentWrapper) {
  13200. if (children.length === 1 && firstChild.type === 11) {
  13201. const vnodeCall = firstChild.codegenNode;
  13202. injectProp(vnodeCall, keyProperty, context);
  13203. return vnodeCall;
  13204. } else {
  13205. let patchFlag = 64;
  13206. let patchFlagText = PatchFlagNames[64];
  13207. if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) {
  13208. patchFlag |= 2048;
  13209. patchFlagText += `, ${PatchFlagNames[2048]}`;
  13210. }
  13211. return createVNodeCall(
  13212. context,
  13213. helper(FRAGMENT),
  13214. createObjectExpression([keyProperty]),
  13215. children,
  13216. patchFlag + (` /* ${patchFlagText} */` ),
  13217. void 0,
  13218. void 0,
  13219. true,
  13220. false,
  13221. false,
  13222. branch.loc
  13223. );
  13224. }
  13225. } else {
  13226. const ret = firstChild.codegenNode;
  13227. const vnodeCall = getMemoedVNodeCall(ret);
  13228. if (vnodeCall.type === 13) {
  13229. convertToBlock(vnodeCall, context);
  13230. }
  13231. injectProp(vnodeCall, keyProperty, context);
  13232. return ret;
  13233. }
  13234. }
  13235. function isSameKey(a, b) {
  13236. if (!a || a.type !== b.type) {
  13237. return false;
  13238. }
  13239. if (a.type === 6) {
  13240. if (a.value.content !== b.value.content) {
  13241. return false;
  13242. }
  13243. } else {
  13244. const exp = a.exp;
  13245. const branchExp = b.exp;
  13246. if (exp.type !== branchExp.type) {
  13247. return false;
  13248. }
  13249. if (exp.type !== 4 || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) {
  13250. return false;
  13251. }
  13252. }
  13253. return true;
  13254. }
  13255. function getParentCondition(node) {
  13256. while (true) {
  13257. if (node.type === 19) {
  13258. if (node.alternate.type === 19) {
  13259. node = node.alternate;
  13260. } else {
  13261. return node;
  13262. }
  13263. } else if (node.type === 20) {
  13264. node = node.value;
  13265. }
  13266. }
  13267. }
  13268. const transformFor = createStructuralDirectiveTransform(
  13269. "for",
  13270. (node, dir, context) => {
  13271. const { helper, removeHelper } = context;
  13272. return processFor(node, dir, context, (forNode) => {
  13273. const renderExp = createCallExpression(helper(RENDER_LIST), [
  13274. forNode.source
  13275. ]);
  13276. const isTemplate = isTemplateNode(node);
  13277. const memo = findDir(node, "memo");
  13278. const keyProp = findProp(node, `key`);
  13279. const keyExp = keyProp && (keyProp.type === 6 ? createSimpleExpression(keyProp.value.content, true) : keyProp.exp);
  13280. const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
  13281. const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
  13282. const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
  13283. forNode.codegenNode = createVNodeCall(
  13284. context,
  13285. helper(FRAGMENT),
  13286. void 0,
  13287. renderExp,
  13288. fragmentFlag + (` /* ${PatchFlagNames[fragmentFlag]} */` ),
  13289. void 0,
  13290. void 0,
  13291. true,
  13292. !isStableFragment,
  13293. false,
  13294. node.loc
  13295. );
  13296. return () => {
  13297. let childBlock;
  13298. const { children } = forNode;
  13299. if (isTemplate) {
  13300. node.children.some((c) => {
  13301. if (c.type === 1) {
  13302. const key = findProp(c, "key");
  13303. if (key) {
  13304. context.onError(
  13305. createCompilerError(
  13306. 33,
  13307. key.loc
  13308. )
  13309. );
  13310. return true;
  13311. }
  13312. }
  13313. });
  13314. }
  13315. const needFragmentWrapper = children.length !== 1 || children[0].type !== 1;
  13316. const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
  13317. if (slotOutlet) {
  13318. childBlock = slotOutlet.codegenNode;
  13319. if (isTemplate && keyProperty) {
  13320. injectProp(childBlock, keyProperty, context);
  13321. }
  13322. } else if (needFragmentWrapper) {
  13323. childBlock = createVNodeCall(
  13324. context,
  13325. helper(FRAGMENT),
  13326. keyProperty ? createObjectExpression([keyProperty]) : void 0,
  13327. node.children,
  13328. 64 + (` /* ${PatchFlagNames[64]} */` ),
  13329. void 0,
  13330. void 0,
  13331. true,
  13332. void 0,
  13333. false
  13334. /* isComponent */
  13335. );
  13336. } else {
  13337. childBlock = children[0].codegenNode;
  13338. if (isTemplate && keyProperty) {
  13339. injectProp(childBlock, keyProperty, context);
  13340. }
  13341. if (childBlock.isBlock !== !isStableFragment) {
  13342. if (childBlock.isBlock) {
  13343. removeHelper(OPEN_BLOCK);
  13344. removeHelper(
  13345. getVNodeBlockHelper(context.inSSR, childBlock.isComponent)
  13346. );
  13347. } else {
  13348. removeHelper(
  13349. getVNodeHelper(context.inSSR, childBlock.isComponent)
  13350. );
  13351. }
  13352. }
  13353. childBlock.isBlock = !isStableFragment;
  13354. if (childBlock.isBlock) {
  13355. helper(OPEN_BLOCK);
  13356. helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
  13357. } else {
  13358. helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
  13359. }
  13360. }
  13361. if (memo) {
  13362. const loop = createFunctionExpression(
  13363. createForLoopParams(forNode.parseResult, [
  13364. createSimpleExpression(`_cached`)
  13365. ])
  13366. );
  13367. loop.body = createBlockStatement([
  13368. createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
  13369. createCompoundExpression([
  13370. `if (_cached`,
  13371. ...keyExp ? [` && _cached.key === `, keyExp] : [],
  13372. ` && ${context.helperString(
  13373. IS_MEMO_SAME
  13374. )}(_cached, _memo)) return _cached`
  13375. ]),
  13376. createCompoundExpression([`const _item = `, childBlock]),
  13377. createSimpleExpression(`_item.memo = _memo`),
  13378. createSimpleExpression(`return _item`)
  13379. ]);
  13380. renderExp.arguments.push(
  13381. loop,
  13382. createSimpleExpression(`_cache`),
  13383. createSimpleExpression(String(context.cached++))
  13384. );
  13385. } else {
  13386. renderExp.arguments.push(
  13387. createFunctionExpression(
  13388. createForLoopParams(forNode.parseResult),
  13389. childBlock,
  13390. true
  13391. /* force newline */
  13392. )
  13393. );
  13394. }
  13395. };
  13396. });
  13397. }
  13398. );
  13399. function processFor(node, dir, context, processCodegen) {
  13400. if (!dir.exp) {
  13401. context.onError(
  13402. createCompilerError(31, dir.loc)
  13403. );
  13404. return;
  13405. }
  13406. const parseResult = parseForExpression(
  13407. // can only be simple expression because vFor transform is applied
  13408. // before expression transform.
  13409. dir.exp,
  13410. context
  13411. );
  13412. if (!parseResult) {
  13413. context.onError(
  13414. createCompilerError(32, dir.loc)
  13415. );
  13416. return;
  13417. }
  13418. const { addIdentifiers, removeIdentifiers, scopes } = context;
  13419. const { source, value, key, index } = parseResult;
  13420. const forNode = {
  13421. type: 11,
  13422. loc: dir.loc,
  13423. source,
  13424. valueAlias: value,
  13425. keyAlias: key,
  13426. objectIndexAlias: index,
  13427. parseResult,
  13428. children: isTemplateNode(node) ? node.children : [node]
  13429. };
  13430. context.replaceNode(forNode);
  13431. scopes.vFor++;
  13432. const onExit = processCodegen && processCodegen(forNode);
  13433. return () => {
  13434. scopes.vFor--;
  13435. if (onExit)
  13436. onExit();
  13437. };
  13438. }
  13439. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  13440. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  13441. const stripParensRE = /^\(|\)$/g;
  13442. function parseForExpression(input, context) {
  13443. const loc = input.loc;
  13444. const exp = input.content;
  13445. const inMatch = exp.match(forAliasRE);
  13446. if (!inMatch)
  13447. return;
  13448. const [, LHS, RHS] = inMatch;
  13449. const result = {
  13450. source: createAliasExpression(
  13451. loc,
  13452. RHS.trim(),
  13453. exp.indexOf(RHS, LHS.length)
  13454. ),
  13455. value: void 0,
  13456. key: void 0,
  13457. index: void 0
  13458. };
  13459. {
  13460. validateBrowserExpression(result.source, context);
  13461. }
  13462. let valueContent = LHS.trim().replace(stripParensRE, "").trim();
  13463. const trimmedOffset = LHS.indexOf(valueContent);
  13464. const iteratorMatch = valueContent.match(forIteratorRE);
  13465. if (iteratorMatch) {
  13466. valueContent = valueContent.replace(forIteratorRE, "").trim();
  13467. const keyContent = iteratorMatch[1].trim();
  13468. let keyOffset;
  13469. if (keyContent) {
  13470. keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
  13471. result.key = createAliasExpression(loc, keyContent, keyOffset);
  13472. {
  13473. validateBrowserExpression(
  13474. result.key,
  13475. context,
  13476. true
  13477. );
  13478. }
  13479. }
  13480. if (iteratorMatch[2]) {
  13481. const indexContent = iteratorMatch[2].trim();
  13482. if (indexContent) {
  13483. result.index = createAliasExpression(
  13484. loc,
  13485. indexContent,
  13486. exp.indexOf(
  13487. indexContent,
  13488. result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
  13489. )
  13490. );
  13491. {
  13492. validateBrowserExpression(
  13493. result.index,
  13494. context,
  13495. true
  13496. );
  13497. }
  13498. }
  13499. }
  13500. }
  13501. if (valueContent) {
  13502. result.value = createAliasExpression(loc, valueContent, trimmedOffset);
  13503. {
  13504. validateBrowserExpression(
  13505. result.value,
  13506. context,
  13507. true
  13508. );
  13509. }
  13510. }
  13511. return result;
  13512. }
  13513. function createAliasExpression(range, content, offset) {
  13514. return createSimpleExpression(
  13515. content,
  13516. false,
  13517. getInnerRange(range, offset, content.length)
  13518. );
  13519. }
  13520. function createForLoopParams({ value, key, index }, memoArgs = []) {
  13521. return createParamsList([value, key, index, ...memoArgs]);
  13522. }
  13523. function createParamsList(args) {
  13524. let i = args.length;
  13525. while (i--) {
  13526. if (args[i])
  13527. break;
  13528. }
  13529. return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
  13530. }
  13531. const defaultFallback = createSimpleExpression(`undefined`, false);
  13532. const trackSlotScopes = (node, context) => {
  13533. if (node.type === 1 && (node.tagType === 1 || node.tagType === 3)) {
  13534. const vSlot = findDir(node, "slot");
  13535. if (vSlot) {
  13536. vSlot.exp;
  13537. context.scopes.vSlot++;
  13538. return () => {
  13539. context.scopes.vSlot--;
  13540. };
  13541. }
  13542. }
  13543. };
  13544. const buildClientSlotFn = (props, children, loc) => createFunctionExpression(
  13545. props,
  13546. children,
  13547. false,
  13548. true,
  13549. children.length ? children[0].loc : loc
  13550. );
  13551. function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
  13552. context.helper(WITH_CTX);
  13553. const { children, loc } = node;
  13554. const slotsProperties = [];
  13555. const dynamicSlots = [];
  13556. let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
  13557. const onComponentSlot = findDir(node, "slot", true);
  13558. if (onComponentSlot) {
  13559. const { arg, exp } = onComponentSlot;
  13560. if (arg && !isStaticExp(arg)) {
  13561. hasDynamicSlots = true;
  13562. }
  13563. slotsProperties.push(
  13564. createObjectProperty(
  13565. arg || createSimpleExpression("default", true),
  13566. buildSlotFn(exp, children, loc)
  13567. )
  13568. );
  13569. }
  13570. let hasTemplateSlots = false;
  13571. let hasNamedDefaultSlot = false;
  13572. const implicitDefaultChildren = [];
  13573. const seenSlotNames = /* @__PURE__ */ new Set();
  13574. let conditionalBranchIndex = 0;
  13575. for (let i = 0; i < children.length; i++) {
  13576. const slotElement = children[i];
  13577. let slotDir;
  13578. if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
  13579. if (slotElement.type !== 3) {
  13580. implicitDefaultChildren.push(slotElement);
  13581. }
  13582. continue;
  13583. }
  13584. if (onComponentSlot) {
  13585. context.onError(
  13586. createCompilerError(37, slotDir.loc)
  13587. );
  13588. break;
  13589. }
  13590. hasTemplateSlots = true;
  13591. const { children: slotChildren, loc: slotLoc } = slotElement;
  13592. const {
  13593. arg: slotName = createSimpleExpression(`default`, true),
  13594. exp: slotProps,
  13595. loc: dirLoc
  13596. } = slotDir;
  13597. let staticSlotName;
  13598. if (isStaticExp(slotName)) {
  13599. staticSlotName = slotName ? slotName.content : `default`;
  13600. } else {
  13601. hasDynamicSlots = true;
  13602. }
  13603. const slotFunction = buildSlotFn(slotProps, slotChildren, slotLoc);
  13604. let vIf;
  13605. let vElse;
  13606. let vFor;
  13607. if (vIf = findDir(slotElement, "if")) {
  13608. hasDynamicSlots = true;
  13609. dynamicSlots.push(
  13610. createConditionalExpression(
  13611. vIf.exp,
  13612. buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++),
  13613. defaultFallback
  13614. )
  13615. );
  13616. } else if (vElse = findDir(
  13617. slotElement,
  13618. /^else(-if)?$/,
  13619. true
  13620. /* allowEmpty */
  13621. )) {
  13622. let j = i;
  13623. let prev;
  13624. while (j--) {
  13625. prev = children[j];
  13626. if (prev.type !== 3) {
  13627. break;
  13628. }
  13629. }
  13630. if (prev && isTemplateNode(prev) && findDir(prev, "if")) {
  13631. children.splice(i, 1);
  13632. i--;
  13633. let conditional = dynamicSlots[dynamicSlots.length - 1];
  13634. while (conditional.alternate.type === 19) {
  13635. conditional = conditional.alternate;
  13636. }
  13637. conditional.alternate = vElse.exp ? createConditionalExpression(
  13638. vElse.exp,
  13639. buildDynamicSlot(
  13640. slotName,
  13641. slotFunction,
  13642. conditionalBranchIndex++
  13643. ),
  13644. defaultFallback
  13645. ) : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
  13646. } else {
  13647. context.onError(
  13648. createCompilerError(30, vElse.loc)
  13649. );
  13650. }
  13651. } else if (vFor = findDir(slotElement, "for")) {
  13652. hasDynamicSlots = true;
  13653. const parseResult = vFor.parseResult || parseForExpression(vFor.exp, context);
  13654. if (parseResult) {
  13655. dynamicSlots.push(
  13656. createCallExpression(context.helper(RENDER_LIST), [
  13657. parseResult.source,
  13658. createFunctionExpression(
  13659. createForLoopParams(parseResult),
  13660. buildDynamicSlot(slotName, slotFunction),
  13661. true
  13662. /* force newline */
  13663. )
  13664. ])
  13665. );
  13666. } else {
  13667. context.onError(
  13668. createCompilerError(32, vFor.loc)
  13669. );
  13670. }
  13671. } else {
  13672. if (staticSlotName) {
  13673. if (seenSlotNames.has(staticSlotName)) {
  13674. context.onError(
  13675. createCompilerError(
  13676. 38,
  13677. dirLoc
  13678. )
  13679. );
  13680. continue;
  13681. }
  13682. seenSlotNames.add(staticSlotName);
  13683. if (staticSlotName === "default") {
  13684. hasNamedDefaultSlot = true;
  13685. }
  13686. }
  13687. slotsProperties.push(createObjectProperty(slotName, slotFunction));
  13688. }
  13689. }
  13690. if (!onComponentSlot) {
  13691. const buildDefaultSlotProperty = (props, children2) => {
  13692. const fn = buildSlotFn(props, children2, loc);
  13693. return createObjectProperty(`default`, fn);
  13694. };
  13695. if (!hasTemplateSlots) {
  13696. slotsProperties.push(buildDefaultSlotProperty(void 0, children));
  13697. } else if (implicitDefaultChildren.length && // #3766
  13698. // with whitespace: 'preserve', whitespaces between slots will end up in
  13699. // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
  13700. implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
  13701. if (hasNamedDefaultSlot) {
  13702. context.onError(
  13703. createCompilerError(
  13704. 39,
  13705. implicitDefaultChildren[0].loc
  13706. )
  13707. );
  13708. } else {
  13709. slotsProperties.push(
  13710. buildDefaultSlotProperty(void 0, implicitDefaultChildren)
  13711. );
  13712. }
  13713. }
  13714. }
  13715. const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
  13716. let slots = createObjectExpression(
  13717. slotsProperties.concat(
  13718. createObjectProperty(
  13719. `_`,
  13720. // 2 = compiled but dynamic = can skip normalization, but must run diff
  13721. // 1 = compiled and static = can skip normalization AND diff as optimized
  13722. createSimpleExpression(
  13723. slotFlag + (` /* ${slotFlagsText[slotFlag]} */` ),
  13724. false
  13725. )
  13726. )
  13727. ),
  13728. loc
  13729. );
  13730. if (dynamicSlots.length) {
  13731. slots = createCallExpression(context.helper(CREATE_SLOTS), [
  13732. slots,
  13733. createArrayExpression(dynamicSlots)
  13734. ]);
  13735. }
  13736. return {
  13737. slots,
  13738. hasDynamicSlots
  13739. };
  13740. }
  13741. function buildDynamicSlot(name, fn, index) {
  13742. const props = [
  13743. createObjectProperty(`name`, name),
  13744. createObjectProperty(`fn`, fn)
  13745. ];
  13746. if (index != null) {
  13747. props.push(
  13748. createObjectProperty(`key`, createSimpleExpression(String(index), true))
  13749. );
  13750. }
  13751. return createObjectExpression(props);
  13752. }
  13753. function hasForwardedSlots(children) {
  13754. for (let i = 0; i < children.length; i++) {
  13755. const child = children[i];
  13756. switch (child.type) {
  13757. case 1:
  13758. if (child.tagType === 2 || hasForwardedSlots(child.children)) {
  13759. return true;
  13760. }
  13761. break;
  13762. case 9:
  13763. if (hasForwardedSlots(child.branches))
  13764. return true;
  13765. break;
  13766. case 10:
  13767. case 11:
  13768. if (hasForwardedSlots(child.children))
  13769. return true;
  13770. break;
  13771. }
  13772. }
  13773. return false;
  13774. }
  13775. function isNonWhitespaceContent(node) {
  13776. if (node.type !== 2 && node.type !== 12)
  13777. return true;
  13778. return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
  13779. }
  13780. const directiveImportMap = /* @__PURE__ */ new WeakMap();
  13781. const transformElement = (node, context) => {
  13782. return function postTransformElement() {
  13783. node = context.currentNode;
  13784. if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1))) {
  13785. return;
  13786. }
  13787. const { tag, props } = node;
  13788. const isComponent = node.tagType === 1;
  13789. let vnodeTag = isComponent ? resolveComponentType(node, context) : `"${tag}"`;
  13790. const isDynamicComponent = isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
  13791. let vnodeProps;
  13792. let vnodeChildren;
  13793. let vnodePatchFlag;
  13794. let patchFlag = 0;
  13795. let vnodeDynamicProps;
  13796. let dynamicPropNames;
  13797. let vnodeDirectives;
  13798. let shouldUseBlock = (
  13799. // dynamic component may resolve to plain elements
  13800. isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && // <svg> and <foreignObject> must be forced into blocks so that block
  13801. // updates inside get proper isSVG flag at runtime. (#639, #643)
  13802. // This is technically web-specific, but splitting the logic out of core
  13803. // leads to too much unnecessary complexity.
  13804. (tag === "svg" || tag === "foreignObject")
  13805. );
  13806. if (props.length > 0) {
  13807. const propsBuildResult = buildProps(
  13808. node,
  13809. context,
  13810. void 0,
  13811. isComponent,
  13812. isDynamicComponent
  13813. );
  13814. vnodeProps = propsBuildResult.props;
  13815. patchFlag = propsBuildResult.patchFlag;
  13816. dynamicPropNames = propsBuildResult.dynamicPropNames;
  13817. const directives = propsBuildResult.directives;
  13818. vnodeDirectives = directives && directives.length ? createArrayExpression(
  13819. directives.map((dir) => buildDirectiveArgs(dir, context))
  13820. ) : void 0;
  13821. if (propsBuildResult.shouldUseBlock) {
  13822. shouldUseBlock = true;
  13823. }
  13824. }
  13825. if (node.children.length > 0) {
  13826. if (vnodeTag === KEEP_ALIVE) {
  13827. shouldUseBlock = true;
  13828. patchFlag |= 1024;
  13829. if (node.children.length > 1) {
  13830. context.onError(
  13831. createCompilerError(46, {
  13832. start: node.children[0].loc.start,
  13833. end: node.children[node.children.length - 1].loc.end,
  13834. source: ""
  13835. })
  13836. );
  13837. }
  13838. }
  13839. const shouldBuildAsSlots = isComponent && // Teleport is not a real component and has dedicated runtime handling
  13840. vnodeTag !== TELEPORT && // explained above.
  13841. vnodeTag !== KEEP_ALIVE;
  13842. if (shouldBuildAsSlots) {
  13843. const { slots, hasDynamicSlots } = buildSlots(node, context);
  13844. vnodeChildren = slots;
  13845. if (hasDynamicSlots) {
  13846. patchFlag |= 1024;
  13847. }
  13848. } else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
  13849. const child = node.children[0];
  13850. const type = child.type;
  13851. const hasDynamicTextChild = type === 5 || type === 8;
  13852. if (hasDynamicTextChild && getConstantType(child, context) === 0) {
  13853. patchFlag |= 1;
  13854. }
  13855. if (hasDynamicTextChild || type === 2) {
  13856. vnodeChildren = child;
  13857. } else {
  13858. vnodeChildren = node.children;
  13859. }
  13860. } else {
  13861. vnodeChildren = node.children;
  13862. }
  13863. }
  13864. if (patchFlag !== 0) {
  13865. {
  13866. if (patchFlag < 0) {
  13867. vnodePatchFlag = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
  13868. } else {
  13869. const flagNames = Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `);
  13870. vnodePatchFlag = patchFlag + ` /* ${flagNames} */`;
  13871. }
  13872. }
  13873. if (dynamicPropNames && dynamicPropNames.length) {
  13874. vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
  13875. }
  13876. }
  13877. node.codegenNode = createVNodeCall(
  13878. context,
  13879. vnodeTag,
  13880. vnodeProps,
  13881. vnodeChildren,
  13882. vnodePatchFlag,
  13883. vnodeDynamicProps,
  13884. vnodeDirectives,
  13885. !!shouldUseBlock,
  13886. false,
  13887. isComponent,
  13888. node.loc
  13889. );
  13890. };
  13891. };
  13892. function resolveComponentType(node, context, ssr = false) {
  13893. let { tag } = node;
  13894. const isExplicitDynamic = isComponentTag(tag);
  13895. const isProp = findProp(node, "is");
  13896. if (isProp) {
  13897. if (isExplicitDynamic || false) {
  13898. const exp = isProp.type === 6 ? isProp.value && createSimpleExpression(isProp.value.content, true) : isProp.exp;
  13899. if (exp) {
  13900. return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
  13901. exp
  13902. ]);
  13903. }
  13904. } else if (isProp.type === 6 && isProp.value.content.startsWith("vue:")) {
  13905. tag = isProp.value.content.slice(4);
  13906. }
  13907. }
  13908. const isDir = !isExplicitDynamic && findDir(node, "is");
  13909. if (isDir && isDir.exp) {
  13910. {
  13911. context.onWarn(
  13912. createCompilerError(52, isDir.loc)
  13913. );
  13914. }
  13915. return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
  13916. isDir.exp
  13917. ]);
  13918. }
  13919. const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
  13920. if (builtIn) {
  13921. if (!ssr)
  13922. context.helper(builtIn);
  13923. return builtIn;
  13924. }
  13925. context.helper(RESOLVE_COMPONENT);
  13926. context.components.add(tag);
  13927. return toValidAssetId(tag, `component`);
  13928. }
  13929. function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
  13930. const { tag, loc: elementLoc, children } = node;
  13931. let properties = [];
  13932. const mergeArgs = [];
  13933. const runtimeDirectives = [];
  13934. const hasChildren = children.length > 0;
  13935. let shouldUseBlock = false;
  13936. let patchFlag = 0;
  13937. let hasRef = false;
  13938. let hasClassBinding = false;
  13939. let hasStyleBinding = false;
  13940. let hasHydrationEventBinding = false;
  13941. let hasDynamicKeys = false;
  13942. let hasVnodeHook = false;
  13943. const dynamicPropNames = [];
  13944. const pushMergeArg = (arg) => {
  13945. if (properties.length) {
  13946. mergeArgs.push(
  13947. createObjectExpression(dedupeProperties(properties), elementLoc)
  13948. );
  13949. properties = [];
  13950. }
  13951. if (arg)
  13952. mergeArgs.push(arg);
  13953. };
  13954. const analyzePatchFlag = ({ key, value }) => {
  13955. if (isStaticExp(key)) {
  13956. const name = key.content;
  13957. const isEventHandler = isOn(name);
  13958. if (isEventHandler && (!isComponent || isDynamicComponent) && // omit the flag for click handlers because hydration gives click
  13959. // dedicated fast path.
  13960. name.toLowerCase() !== "onclick" && // omit v-model handlers
  13961. name !== "onUpdate:modelValue" && // omit onVnodeXXX hooks
  13962. !isReservedProp(name)) {
  13963. hasHydrationEventBinding = true;
  13964. }
  13965. if (isEventHandler && isReservedProp(name)) {
  13966. hasVnodeHook = true;
  13967. }
  13968. if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
  13969. return;
  13970. }
  13971. if (name === "ref") {
  13972. hasRef = true;
  13973. } else if (name === "class") {
  13974. hasClassBinding = true;
  13975. } else if (name === "style") {
  13976. hasStyleBinding = true;
  13977. } else if (name !== "key" && !dynamicPropNames.includes(name)) {
  13978. dynamicPropNames.push(name);
  13979. }
  13980. if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) {
  13981. dynamicPropNames.push(name);
  13982. }
  13983. } else {
  13984. hasDynamicKeys = true;
  13985. }
  13986. };
  13987. for (let i = 0; i < props.length; i++) {
  13988. const prop = props[i];
  13989. if (prop.type === 6) {
  13990. const { loc, name, value } = prop;
  13991. let isStatic = true;
  13992. if (name === "ref") {
  13993. hasRef = true;
  13994. if (context.scopes.vFor > 0) {
  13995. properties.push(
  13996. createObjectProperty(
  13997. createSimpleExpression("ref_for", true),
  13998. createSimpleExpression("true")
  13999. )
  14000. );
  14001. }
  14002. }
  14003. if (name === "is" && (isComponentTag(tag) || value && value.content.startsWith("vue:") || false)) {
  14004. continue;
  14005. }
  14006. properties.push(
  14007. createObjectProperty(
  14008. createSimpleExpression(
  14009. name,
  14010. true,
  14011. getInnerRange(loc, 0, name.length)
  14012. ),
  14013. createSimpleExpression(
  14014. value ? value.content : "",
  14015. isStatic,
  14016. value ? value.loc : loc
  14017. )
  14018. )
  14019. );
  14020. } else {
  14021. const { name, arg, exp, loc } = prop;
  14022. const isVBind = name === "bind";
  14023. const isVOn = name === "on";
  14024. if (name === "slot") {
  14025. if (!isComponent) {
  14026. context.onError(
  14027. createCompilerError(40, loc)
  14028. );
  14029. }
  14030. continue;
  14031. }
  14032. if (name === "once" || name === "memo") {
  14033. continue;
  14034. }
  14035. if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || false)) {
  14036. continue;
  14037. }
  14038. if (isVOn && ssr) {
  14039. continue;
  14040. }
  14041. if (
  14042. // #938: elements with dynamic keys should be forced into blocks
  14043. isVBind && isStaticArgOf(arg, "key") || // inline before-update hooks need to force block so that it is invoked
  14044. // before children
  14045. isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")
  14046. ) {
  14047. shouldUseBlock = true;
  14048. }
  14049. if (isVBind && isStaticArgOf(arg, "ref") && context.scopes.vFor > 0) {
  14050. properties.push(
  14051. createObjectProperty(
  14052. createSimpleExpression("ref_for", true),
  14053. createSimpleExpression("true")
  14054. )
  14055. );
  14056. }
  14057. if (!arg && (isVBind || isVOn)) {
  14058. hasDynamicKeys = true;
  14059. if (exp) {
  14060. if (isVBind) {
  14061. pushMergeArg();
  14062. mergeArgs.push(exp);
  14063. } else {
  14064. pushMergeArg({
  14065. type: 14,
  14066. loc,
  14067. callee: context.helper(TO_HANDLERS),
  14068. arguments: isComponent ? [exp] : [exp, `true`]
  14069. });
  14070. }
  14071. } else {
  14072. context.onError(
  14073. createCompilerError(
  14074. isVBind ? 34 : 35,
  14075. loc
  14076. )
  14077. );
  14078. }
  14079. continue;
  14080. }
  14081. const directiveTransform = context.directiveTransforms[name];
  14082. if (directiveTransform) {
  14083. const { props: props2, needRuntime } = directiveTransform(prop, node, context);
  14084. !ssr && props2.forEach(analyzePatchFlag);
  14085. if (isVOn && arg && !isStaticExp(arg)) {
  14086. pushMergeArg(createObjectExpression(props2, elementLoc));
  14087. } else {
  14088. properties.push(...props2);
  14089. }
  14090. if (needRuntime) {
  14091. runtimeDirectives.push(prop);
  14092. if (isSymbol(needRuntime)) {
  14093. directiveImportMap.set(prop, needRuntime);
  14094. }
  14095. }
  14096. } else if (!isBuiltInDirective(name)) {
  14097. runtimeDirectives.push(prop);
  14098. if (hasChildren) {
  14099. shouldUseBlock = true;
  14100. }
  14101. }
  14102. }
  14103. }
  14104. let propsExpression = void 0;
  14105. if (mergeArgs.length) {
  14106. pushMergeArg();
  14107. if (mergeArgs.length > 1) {
  14108. propsExpression = createCallExpression(
  14109. context.helper(MERGE_PROPS),
  14110. mergeArgs,
  14111. elementLoc
  14112. );
  14113. } else {
  14114. propsExpression = mergeArgs[0];
  14115. }
  14116. } else if (properties.length) {
  14117. propsExpression = createObjectExpression(
  14118. dedupeProperties(properties),
  14119. elementLoc
  14120. );
  14121. }
  14122. if (hasDynamicKeys) {
  14123. patchFlag |= 16;
  14124. } else {
  14125. if (hasClassBinding && !isComponent) {
  14126. patchFlag |= 2;
  14127. }
  14128. if (hasStyleBinding && !isComponent) {
  14129. patchFlag |= 4;
  14130. }
  14131. if (dynamicPropNames.length) {
  14132. patchFlag |= 8;
  14133. }
  14134. if (hasHydrationEventBinding) {
  14135. patchFlag |= 32;
  14136. }
  14137. }
  14138. if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
  14139. patchFlag |= 512;
  14140. }
  14141. if (!context.inSSR && propsExpression) {
  14142. switch (propsExpression.type) {
  14143. case 15:
  14144. let classKeyIndex = -1;
  14145. let styleKeyIndex = -1;
  14146. let hasDynamicKey = false;
  14147. for (let i = 0; i < propsExpression.properties.length; i++) {
  14148. const key = propsExpression.properties[i].key;
  14149. if (isStaticExp(key)) {
  14150. if (key.content === "class") {
  14151. classKeyIndex = i;
  14152. } else if (key.content === "style") {
  14153. styleKeyIndex = i;
  14154. }
  14155. } else if (!key.isHandlerKey) {
  14156. hasDynamicKey = true;
  14157. }
  14158. }
  14159. const classProp = propsExpression.properties[classKeyIndex];
  14160. const styleProp = propsExpression.properties[styleKeyIndex];
  14161. if (!hasDynamicKey) {
  14162. if (classProp && !isStaticExp(classProp.value)) {
  14163. classProp.value = createCallExpression(
  14164. context.helper(NORMALIZE_CLASS),
  14165. [classProp.value]
  14166. );
  14167. }
  14168. if (styleProp && // the static style is compiled into an object,
  14169. // so use `hasStyleBinding` to ensure that it is a dynamic style binding
  14170. (hasStyleBinding || styleProp.value.type === 4 && styleProp.value.content.trim()[0] === `[` || // v-bind:style and style both exist,
  14171. // v-bind:style with static literal object
  14172. styleProp.value.type === 17)) {
  14173. styleProp.value = createCallExpression(
  14174. context.helper(NORMALIZE_STYLE),
  14175. [styleProp.value]
  14176. );
  14177. }
  14178. } else {
  14179. propsExpression = createCallExpression(
  14180. context.helper(NORMALIZE_PROPS),
  14181. [propsExpression]
  14182. );
  14183. }
  14184. break;
  14185. case 14:
  14186. break;
  14187. default:
  14188. propsExpression = createCallExpression(
  14189. context.helper(NORMALIZE_PROPS),
  14190. [
  14191. createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
  14192. propsExpression
  14193. ])
  14194. ]
  14195. );
  14196. break;
  14197. }
  14198. }
  14199. return {
  14200. props: propsExpression,
  14201. directives: runtimeDirectives,
  14202. patchFlag,
  14203. dynamicPropNames,
  14204. shouldUseBlock
  14205. };
  14206. }
  14207. function dedupeProperties(properties) {
  14208. const knownProps = /* @__PURE__ */ new Map();
  14209. const deduped = [];
  14210. for (let i = 0; i < properties.length; i++) {
  14211. const prop = properties[i];
  14212. if (prop.key.type === 8 || !prop.key.isStatic) {
  14213. deduped.push(prop);
  14214. continue;
  14215. }
  14216. const name = prop.key.content;
  14217. const existing = knownProps.get(name);
  14218. if (existing) {
  14219. if (name === "style" || name === "class" || isOn(name)) {
  14220. mergeAsArray(existing, prop);
  14221. }
  14222. } else {
  14223. knownProps.set(name, prop);
  14224. deduped.push(prop);
  14225. }
  14226. }
  14227. return deduped;
  14228. }
  14229. function mergeAsArray(existing, incoming) {
  14230. if (existing.value.type === 17) {
  14231. existing.value.elements.push(incoming.value);
  14232. } else {
  14233. existing.value = createArrayExpression(
  14234. [existing.value, incoming.value],
  14235. existing.loc
  14236. );
  14237. }
  14238. }
  14239. function buildDirectiveArgs(dir, context) {
  14240. const dirArgs = [];
  14241. const runtime = directiveImportMap.get(dir);
  14242. if (runtime) {
  14243. dirArgs.push(context.helperString(runtime));
  14244. } else {
  14245. {
  14246. context.helper(RESOLVE_DIRECTIVE);
  14247. context.directives.add(dir.name);
  14248. dirArgs.push(toValidAssetId(dir.name, `directive`));
  14249. }
  14250. }
  14251. const { loc } = dir;
  14252. if (dir.exp)
  14253. dirArgs.push(dir.exp);
  14254. if (dir.arg) {
  14255. if (!dir.exp) {
  14256. dirArgs.push(`void 0`);
  14257. }
  14258. dirArgs.push(dir.arg);
  14259. }
  14260. if (Object.keys(dir.modifiers).length) {
  14261. if (!dir.arg) {
  14262. if (!dir.exp) {
  14263. dirArgs.push(`void 0`);
  14264. }
  14265. dirArgs.push(`void 0`);
  14266. }
  14267. const trueExpression = createSimpleExpression(`true`, false, loc);
  14268. dirArgs.push(
  14269. createObjectExpression(
  14270. dir.modifiers.map(
  14271. (modifier) => createObjectProperty(modifier, trueExpression)
  14272. ),
  14273. loc
  14274. )
  14275. );
  14276. }
  14277. return createArrayExpression(dirArgs, dir.loc);
  14278. }
  14279. function stringifyDynamicPropNames(props) {
  14280. let propsNamesString = `[`;
  14281. for (let i = 0, l = props.length; i < l; i++) {
  14282. propsNamesString += JSON.stringify(props[i]);
  14283. if (i < l - 1)
  14284. propsNamesString += ", ";
  14285. }
  14286. return propsNamesString + `]`;
  14287. }
  14288. function isComponentTag(tag) {
  14289. return tag === "component" || tag === "Component";
  14290. }
  14291. const transformSlotOutlet = (node, context) => {
  14292. if (isSlotOutlet(node)) {
  14293. const { children, loc } = node;
  14294. const { slotName, slotProps } = processSlotOutlet(node, context);
  14295. const slotArgs = [
  14296. context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
  14297. slotName,
  14298. "{}",
  14299. "undefined",
  14300. "true"
  14301. ];
  14302. let expectedLen = 2;
  14303. if (slotProps) {
  14304. slotArgs[2] = slotProps;
  14305. expectedLen = 3;
  14306. }
  14307. if (children.length) {
  14308. slotArgs[3] = createFunctionExpression([], children, false, false, loc);
  14309. expectedLen = 4;
  14310. }
  14311. if (context.scopeId && !context.slotted) {
  14312. expectedLen = 5;
  14313. }
  14314. slotArgs.splice(expectedLen);
  14315. node.codegenNode = createCallExpression(
  14316. context.helper(RENDER_SLOT),
  14317. slotArgs,
  14318. loc
  14319. );
  14320. }
  14321. };
  14322. function processSlotOutlet(node, context) {
  14323. let slotName = `"default"`;
  14324. let slotProps = void 0;
  14325. const nonNameProps = [];
  14326. for (let i = 0; i < node.props.length; i++) {
  14327. const p = node.props[i];
  14328. if (p.type === 6) {
  14329. if (p.value) {
  14330. if (p.name === "name") {
  14331. slotName = JSON.stringify(p.value.content);
  14332. } else {
  14333. p.name = camelize(p.name);
  14334. nonNameProps.push(p);
  14335. }
  14336. }
  14337. } else {
  14338. if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
  14339. if (p.exp)
  14340. slotName = p.exp;
  14341. } else {
  14342. if (p.name === "bind" && p.arg && isStaticExp(p.arg)) {
  14343. p.arg.content = camelize(p.arg.content);
  14344. }
  14345. nonNameProps.push(p);
  14346. }
  14347. }
  14348. }
  14349. if (nonNameProps.length > 0) {
  14350. const { props, directives } = buildProps(
  14351. node,
  14352. context,
  14353. nonNameProps,
  14354. false,
  14355. false
  14356. );
  14357. slotProps = props;
  14358. if (directives.length) {
  14359. context.onError(
  14360. createCompilerError(
  14361. 36,
  14362. directives[0].loc
  14363. )
  14364. );
  14365. }
  14366. }
  14367. return {
  14368. slotName,
  14369. slotProps
  14370. };
  14371. }
  14372. const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
  14373. const transformOn$1 = (dir, node, context, augmentor) => {
  14374. const { loc, modifiers, arg } = dir;
  14375. if (!dir.exp && !modifiers.length) {
  14376. context.onError(createCompilerError(35, loc));
  14377. }
  14378. let eventName;
  14379. if (arg.type === 4) {
  14380. if (arg.isStatic) {
  14381. let rawName = arg.content;
  14382. if (rawName.startsWith("vnode")) {
  14383. context.onWarn(
  14384. createCompilerError(51, arg.loc)
  14385. );
  14386. }
  14387. if (rawName.startsWith("vue:")) {
  14388. rawName = `vnode-${rawName.slice(4)}`;
  14389. }
  14390. const eventString = node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? (
  14391. // for non-element and vnode lifecycle event listeners, auto convert
  14392. // it to camelCase. See issue #2249
  14393. toHandlerKey(camelize(rawName))
  14394. ) : (
  14395. // preserve case for plain element listeners that have uppercase
  14396. // letters, as these may be custom elements' custom events
  14397. `on:${rawName}`
  14398. );
  14399. eventName = createSimpleExpression(eventString, true, arg.loc);
  14400. } else {
  14401. eventName = createCompoundExpression([
  14402. `${context.helperString(TO_HANDLER_KEY)}(`,
  14403. arg,
  14404. `)`
  14405. ]);
  14406. }
  14407. } else {
  14408. eventName = arg;
  14409. eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
  14410. eventName.children.push(`)`);
  14411. }
  14412. let exp = dir.exp;
  14413. if (exp && !exp.content.trim()) {
  14414. exp = void 0;
  14415. }
  14416. let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
  14417. if (exp) {
  14418. const isMemberExp = isMemberExpression(exp.content);
  14419. const isInlineStatement = !(isMemberExp || fnExpRE.test(exp.content));
  14420. const hasMultipleStatements = exp.content.includes(`;`);
  14421. {
  14422. validateBrowserExpression(
  14423. exp,
  14424. context,
  14425. false,
  14426. hasMultipleStatements
  14427. );
  14428. }
  14429. if (isInlineStatement || shouldCache && isMemberExp) {
  14430. exp = createCompoundExpression([
  14431. `${isInlineStatement ? `$event` : `${``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
  14432. exp,
  14433. hasMultipleStatements ? `}` : `)`
  14434. ]);
  14435. }
  14436. }
  14437. let ret = {
  14438. props: [
  14439. createObjectProperty(
  14440. eventName,
  14441. exp || createSimpleExpression(`() => {}`, false, loc)
  14442. )
  14443. ]
  14444. };
  14445. if (augmentor) {
  14446. ret = augmentor(ret);
  14447. }
  14448. if (shouldCache) {
  14449. ret.props[0].value = context.cache(ret.props[0].value);
  14450. }
  14451. ret.props.forEach((p) => p.key.isHandlerKey = true);
  14452. return ret;
  14453. };
  14454. const transformBind = (dir, _node, context) => {
  14455. const { exp, modifiers, loc } = dir;
  14456. const arg = dir.arg;
  14457. if (arg.type !== 4) {
  14458. arg.children.unshift(`(`);
  14459. arg.children.push(`) || ""`);
  14460. } else if (!arg.isStatic) {
  14461. arg.content = `${arg.content} || ""`;
  14462. }
  14463. if (modifiers.includes("camel")) {
  14464. if (arg.type === 4) {
  14465. if (arg.isStatic) {
  14466. arg.content = camelize(arg.content);
  14467. } else {
  14468. arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
  14469. }
  14470. } else {
  14471. arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
  14472. arg.children.push(`)`);
  14473. }
  14474. }
  14475. if (!context.inSSR) {
  14476. if (modifiers.includes("prop")) {
  14477. injectPrefix(arg, ".");
  14478. }
  14479. if (modifiers.includes("attr")) {
  14480. injectPrefix(arg, "^");
  14481. }
  14482. }
  14483. if (!exp || exp.type === 4 && !exp.content.trim()) {
  14484. context.onError(createCompilerError(34, loc));
  14485. return {
  14486. props: [createObjectProperty(arg, createSimpleExpression("", true, loc))]
  14487. };
  14488. }
  14489. return {
  14490. props: [createObjectProperty(arg, exp)]
  14491. };
  14492. };
  14493. const injectPrefix = (arg, prefix) => {
  14494. if (arg.type === 4) {
  14495. if (arg.isStatic) {
  14496. arg.content = prefix + arg.content;
  14497. } else {
  14498. arg.content = `\`${prefix}\${${arg.content}}\``;
  14499. }
  14500. } else {
  14501. arg.children.unshift(`'${prefix}' + (`);
  14502. arg.children.push(`)`);
  14503. }
  14504. };
  14505. const transformText = (node, context) => {
  14506. if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
  14507. return () => {
  14508. const children = node.children;
  14509. let currentContainer = void 0;
  14510. let hasText = false;
  14511. for (let i = 0; i < children.length; i++) {
  14512. const child = children[i];
  14513. if (isText$1(child)) {
  14514. hasText = true;
  14515. for (let j = i + 1; j < children.length; j++) {
  14516. const next = children[j];
  14517. if (isText$1(next)) {
  14518. if (!currentContainer) {
  14519. currentContainer = children[i] = createCompoundExpression(
  14520. [child],
  14521. child.loc
  14522. );
  14523. }
  14524. currentContainer.children.push(` + `, next);
  14525. children.splice(j, 1);
  14526. j--;
  14527. } else {
  14528. currentContainer = void 0;
  14529. break;
  14530. }
  14531. }
  14532. }
  14533. }
  14534. if (!hasText || // if this is a plain element with a single text child, leave it
  14535. // as-is since the runtime has dedicated fast path for this by directly
  14536. // setting textContent of the element.
  14537. // for component root it's always normalized anyway.
  14538. children.length === 1 && (node.type === 0 || node.type === 1 && node.tagType === 0 && // #3756
  14539. // custom directives can potentially add DOM elements arbitrarily,
  14540. // we need to avoid setting textContent of the element at runtime
  14541. // to avoid accidentally overwriting the DOM elements added
  14542. // by the user through custom directives.
  14543. !node.props.find(
  14544. (p) => p.type === 7 && !context.directiveTransforms[p.name]
  14545. ) && // in compat mode, <template> tags with no special directives
  14546. // will be rendered as a fragment so its children must be
  14547. // converted into vnodes.
  14548. true)) {
  14549. return;
  14550. }
  14551. for (let i = 0; i < children.length; i++) {
  14552. const child = children[i];
  14553. if (isText$1(child) || child.type === 8) {
  14554. const callArgs = [];
  14555. if (child.type !== 2 || child.content !== " ") {
  14556. callArgs.push(child);
  14557. }
  14558. if (!context.ssr && getConstantType(child, context) === 0) {
  14559. callArgs.push(
  14560. 1 + (` /* ${PatchFlagNames[1]} */` )
  14561. );
  14562. }
  14563. children[i] = {
  14564. type: 12,
  14565. content: child,
  14566. loc: child.loc,
  14567. codegenNode: createCallExpression(
  14568. context.helper(CREATE_TEXT),
  14569. callArgs
  14570. )
  14571. };
  14572. }
  14573. }
  14574. };
  14575. }
  14576. };
  14577. const seen$1 = /* @__PURE__ */ new WeakSet();
  14578. const transformOnce = (node, context) => {
  14579. if (node.type === 1 && findDir(node, "once", true)) {
  14580. if (seen$1.has(node) || context.inVOnce || context.inSSR) {
  14581. return;
  14582. }
  14583. seen$1.add(node);
  14584. context.inVOnce = true;
  14585. context.helper(SET_BLOCK_TRACKING);
  14586. return () => {
  14587. context.inVOnce = false;
  14588. const cur = context.currentNode;
  14589. if (cur.codegenNode) {
  14590. cur.codegenNode = context.cache(
  14591. cur.codegenNode,
  14592. true
  14593. /* isVNode */
  14594. );
  14595. }
  14596. };
  14597. }
  14598. };
  14599. const transformModel$1 = (dir, node, context) => {
  14600. const { exp, arg } = dir;
  14601. if (!exp) {
  14602. context.onError(
  14603. createCompilerError(41, dir.loc)
  14604. );
  14605. return createTransformProps();
  14606. }
  14607. const rawExp = exp.loc.source;
  14608. const expString = exp.type === 4 ? exp.content : rawExp;
  14609. const bindingType = context.bindingMetadata[rawExp];
  14610. if (bindingType === "props" || bindingType === "props-aliased") {
  14611. context.onError(createCompilerError(44, exp.loc));
  14612. return createTransformProps();
  14613. }
  14614. const maybeRef = false;
  14615. if (!expString.trim() || !isMemberExpression(expString) && !maybeRef) {
  14616. context.onError(
  14617. createCompilerError(42, exp.loc)
  14618. );
  14619. return createTransformProps();
  14620. }
  14621. const propName = arg ? arg : createSimpleExpression("modelValue", true);
  14622. const eventName = arg ? isStaticExp(arg) ? `onUpdate:${camelize(arg.content)}` : createCompoundExpression(['"onUpdate:" + ', arg]) : `onUpdate:modelValue`;
  14623. let assignmentExp;
  14624. const eventArg = context.isTS ? `($event: any)` : `$event`;
  14625. {
  14626. assignmentExp = createCompoundExpression([
  14627. `${eventArg} => ((`,
  14628. exp,
  14629. `) = $event)`
  14630. ]);
  14631. }
  14632. const props = [
  14633. // modelValue: foo
  14634. createObjectProperty(propName, dir.exp),
  14635. // "onUpdate:modelValue": $event => (foo = $event)
  14636. createObjectProperty(eventName, assignmentExp)
  14637. ];
  14638. if (dir.modifiers.length && node.tagType === 1) {
  14639. const modifiers = dir.modifiers.map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
  14640. const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
  14641. props.push(
  14642. createObjectProperty(
  14643. modifiersKey,
  14644. createSimpleExpression(
  14645. `{ ${modifiers} }`,
  14646. false,
  14647. dir.loc,
  14648. 2
  14649. )
  14650. )
  14651. );
  14652. }
  14653. return createTransformProps(props);
  14654. };
  14655. function createTransformProps(props = []) {
  14656. return { props };
  14657. }
  14658. const seen = /* @__PURE__ */ new WeakSet();
  14659. const transformMemo = (node, context) => {
  14660. if (node.type === 1) {
  14661. const dir = findDir(node, "memo");
  14662. if (!dir || seen.has(node)) {
  14663. return;
  14664. }
  14665. seen.add(node);
  14666. return () => {
  14667. const codegenNode = node.codegenNode || context.currentNode.codegenNode;
  14668. if (codegenNode && codegenNode.type === 13) {
  14669. if (node.tagType !== 1) {
  14670. convertToBlock(codegenNode, context);
  14671. }
  14672. node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
  14673. dir.exp,
  14674. createFunctionExpression(void 0, codegenNode),
  14675. `_cache`,
  14676. String(context.cached++)
  14677. ]);
  14678. }
  14679. };
  14680. }
  14681. };
  14682. function getBaseTransformPreset(prefixIdentifiers) {
  14683. return [
  14684. [
  14685. transformOnce,
  14686. transformIf,
  14687. transformMemo,
  14688. transformFor,
  14689. ...[],
  14690. ...[transformExpression] ,
  14691. transformSlotOutlet,
  14692. transformElement,
  14693. trackSlotScopes,
  14694. transformText
  14695. ],
  14696. {
  14697. on: transformOn$1,
  14698. bind: transformBind,
  14699. model: transformModel$1
  14700. }
  14701. ];
  14702. }
  14703. function baseCompile(template, options = {}) {
  14704. const onError = options.onError || defaultOnError;
  14705. const isModuleMode = options.mode === "module";
  14706. {
  14707. if (options.prefixIdentifiers === true) {
  14708. onError(createCompilerError(47));
  14709. } else if (isModuleMode) {
  14710. onError(createCompilerError(48));
  14711. }
  14712. }
  14713. const prefixIdentifiers = false;
  14714. if (options.cacheHandlers) {
  14715. onError(createCompilerError(49));
  14716. }
  14717. if (options.scopeId && !isModuleMode) {
  14718. onError(createCompilerError(50));
  14719. }
  14720. const ast = isString(template) ? baseParse(template, options) : template;
  14721. const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
  14722. transform(
  14723. ast,
  14724. extend({}, options, {
  14725. prefixIdentifiers,
  14726. nodeTransforms: [
  14727. ...nodeTransforms,
  14728. ...options.nodeTransforms || []
  14729. // user transforms
  14730. ],
  14731. directiveTransforms: extend(
  14732. {},
  14733. directiveTransforms,
  14734. options.directiveTransforms || {}
  14735. // user transforms
  14736. )
  14737. })
  14738. );
  14739. return generate(
  14740. ast,
  14741. extend({}, options, {
  14742. prefixIdentifiers
  14743. })
  14744. );
  14745. }
  14746. const noopDirectiveTransform = () => ({ props: [] });
  14747. const V_MODEL_RADIO = Symbol(`vModelRadio` );
  14748. const V_MODEL_CHECKBOX = Symbol(`vModelCheckbox` );
  14749. const V_MODEL_TEXT = Symbol(`vModelText` );
  14750. const V_MODEL_SELECT = Symbol(`vModelSelect` );
  14751. const V_MODEL_DYNAMIC = Symbol(`vModelDynamic` );
  14752. const V_ON_WITH_MODIFIERS = Symbol(`vOnModifiersGuard` );
  14753. const V_ON_WITH_KEYS = Symbol(`vOnKeysGuard` );
  14754. const V_SHOW = Symbol(`vShow` );
  14755. const TRANSITION = Symbol(`Transition` );
  14756. const TRANSITION_GROUP = Symbol(`TransitionGroup` );
  14757. registerRuntimeHelpers({
  14758. [V_MODEL_RADIO]: `vModelRadio`,
  14759. [V_MODEL_CHECKBOX]: `vModelCheckbox`,
  14760. [V_MODEL_TEXT]: `vModelText`,
  14761. [V_MODEL_SELECT]: `vModelSelect`,
  14762. [V_MODEL_DYNAMIC]: `vModelDynamic`,
  14763. [V_ON_WITH_MODIFIERS]: `withModifiers`,
  14764. [V_ON_WITH_KEYS]: `withKeys`,
  14765. [V_SHOW]: `vShow`,
  14766. [TRANSITION]: `Transition`,
  14767. [TRANSITION_GROUP]: `TransitionGroup`
  14768. });
  14769. let decoder;
  14770. function decodeHtmlBrowser(raw, asAttr = false) {
  14771. if (!decoder) {
  14772. decoder = document.createElement("div");
  14773. }
  14774. if (asAttr) {
  14775. decoder.innerHTML = `<div foo="${raw.replace(/"/g, "&quot;")}">`;
  14776. return decoder.children[0].getAttribute("foo");
  14777. } else {
  14778. decoder.innerHTML = raw;
  14779. return decoder.textContent;
  14780. }
  14781. }
  14782. const isRawTextContainer = /* @__PURE__ */ makeMap(
  14783. "style,iframe,script,noscript",
  14784. true
  14785. );
  14786. const parserOptions = {
  14787. isVoidTag,
  14788. isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag),
  14789. isPreTag: (tag) => tag === "pre",
  14790. decodeEntities: decodeHtmlBrowser ,
  14791. isBuiltInComponent: (tag) => {
  14792. if (isBuiltInType(tag, `Transition`)) {
  14793. return TRANSITION;
  14794. } else if (isBuiltInType(tag, `TransitionGroup`)) {
  14795. return TRANSITION_GROUP;
  14796. }
  14797. },
  14798. // https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
  14799. getNamespace(tag, parent) {
  14800. let ns = parent ? parent.ns : 0;
  14801. if (parent && ns === 2) {
  14802. if (parent.tag === "annotation-xml") {
  14803. if (tag === "svg") {
  14804. return 1;
  14805. }
  14806. if (parent.props.some(
  14807. (a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
  14808. )) {
  14809. ns = 0;
  14810. }
  14811. } else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
  14812. ns = 0;
  14813. }
  14814. } else if (parent && ns === 1) {
  14815. if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
  14816. ns = 0;
  14817. }
  14818. }
  14819. if (ns === 0) {
  14820. if (tag === "svg") {
  14821. return 1;
  14822. }
  14823. if (tag === "math") {
  14824. return 2;
  14825. }
  14826. }
  14827. return ns;
  14828. },
  14829. // https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments
  14830. getTextMode({ tag, ns }) {
  14831. if (ns === 0) {
  14832. if (tag === "textarea" || tag === "title") {
  14833. return 1;
  14834. }
  14835. if (isRawTextContainer(tag)) {
  14836. return 2;
  14837. }
  14838. }
  14839. return 0;
  14840. }
  14841. };
  14842. const transformStyle = (node) => {
  14843. if (node.type === 1) {
  14844. node.props.forEach((p, i) => {
  14845. if (p.type === 6 && p.name === "style" && p.value) {
  14846. node.props[i] = {
  14847. type: 7,
  14848. name: `bind`,
  14849. arg: createSimpleExpression(`style`, true, p.loc),
  14850. exp: parseInlineCSS(p.value.content, p.loc),
  14851. modifiers: [],
  14852. loc: p.loc
  14853. };
  14854. }
  14855. });
  14856. }
  14857. };
  14858. const parseInlineCSS = (cssText, loc) => {
  14859. const normalized = parseStringStyle(cssText);
  14860. return createSimpleExpression(
  14861. JSON.stringify(normalized),
  14862. false,
  14863. loc,
  14864. 3
  14865. );
  14866. };
  14867. function createDOMCompilerError(code, loc) {
  14868. return createCompilerError(
  14869. code,
  14870. loc,
  14871. DOMErrorMessages
  14872. );
  14873. }
  14874. const DOMErrorMessages = {
  14875. [53]: `v-html is missing expression.`,
  14876. [54]: `v-html will override element children.`,
  14877. [55]: `v-text is missing expression.`,
  14878. [56]: `v-text will override element children.`,
  14879. [57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
  14880. [58]: `v-model argument is not supported on plain elements.`,
  14881. [59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
  14882. [60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
  14883. [61]: `v-show is missing expression.`,
  14884. [62]: `<Transition> expects exactly one child element or component.`,
  14885. [63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
  14886. };
  14887. const transformVHtml = (dir, node, context) => {
  14888. const { exp, loc } = dir;
  14889. if (!exp) {
  14890. context.onError(
  14891. createDOMCompilerError(53, loc)
  14892. );
  14893. }
  14894. if (node.children.length) {
  14895. context.onError(
  14896. createDOMCompilerError(54, loc)
  14897. );
  14898. node.children.length = 0;
  14899. }
  14900. return {
  14901. props: [
  14902. createObjectProperty(
  14903. createSimpleExpression(`innerHTML`, true, loc),
  14904. exp || createSimpleExpression("", true)
  14905. )
  14906. ]
  14907. };
  14908. };
  14909. const transformVText = (dir, node, context) => {
  14910. const { exp, loc } = dir;
  14911. if (!exp) {
  14912. context.onError(
  14913. createDOMCompilerError(55, loc)
  14914. );
  14915. }
  14916. if (node.children.length) {
  14917. context.onError(
  14918. createDOMCompilerError(56, loc)
  14919. );
  14920. node.children.length = 0;
  14921. }
  14922. return {
  14923. props: [
  14924. createObjectProperty(
  14925. createSimpleExpression(`textContent`, true),
  14926. exp ? getConstantType(exp, context) > 0 ? exp : createCallExpression(
  14927. context.helperString(TO_DISPLAY_STRING),
  14928. [exp],
  14929. loc
  14930. ) : createSimpleExpression("", true)
  14931. )
  14932. ]
  14933. };
  14934. };
  14935. const transformModel = (dir, node, context) => {
  14936. const baseResult = transformModel$1(dir, node, context);
  14937. if (!baseResult.props.length || node.tagType === 1) {
  14938. return baseResult;
  14939. }
  14940. if (dir.arg) {
  14941. context.onError(
  14942. createDOMCompilerError(
  14943. 58,
  14944. dir.arg.loc
  14945. )
  14946. );
  14947. }
  14948. function checkDuplicatedValue() {
  14949. const value = findProp(node, "value");
  14950. if (value) {
  14951. context.onError(
  14952. createDOMCompilerError(
  14953. 60,
  14954. value.loc
  14955. )
  14956. );
  14957. }
  14958. }
  14959. const { tag } = node;
  14960. const isCustomElement = context.isCustomElement(tag);
  14961. if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
  14962. let directiveToUse = V_MODEL_TEXT;
  14963. let isInvalidType = false;
  14964. if (tag === "input" || isCustomElement) {
  14965. const type = findProp(node, `type`);
  14966. if (type) {
  14967. if (type.type === 7) {
  14968. directiveToUse = V_MODEL_DYNAMIC;
  14969. } else if (type.value) {
  14970. switch (type.value.content) {
  14971. case "radio":
  14972. directiveToUse = V_MODEL_RADIO;
  14973. break;
  14974. case "checkbox":
  14975. directiveToUse = V_MODEL_CHECKBOX;
  14976. break;
  14977. case "file":
  14978. isInvalidType = true;
  14979. context.onError(
  14980. createDOMCompilerError(
  14981. 59,
  14982. dir.loc
  14983. )
  14984. );
  14985. break;
  14986. default:
  14987. checkDuplicatedValue();
  14988. break;
  14989. }
  14990. }
  14991. } else if (hasDynamicKeyVBind(node)) {
  14992. directiveToUse = V_MODEL_DYNAMIC;
  14993. } else {
  14994. checkDuplicatedValue();
  14995. }
  14996. } else if (tag === "select") {
  14997. directiveToUse = V_MODEL_SELECT;
  14998. } else {
  14999. checkDuplicatedValue();
  15000. }
  15001. if (!isInvalidType) {
  15002. baseResult.needRuntime = context.helper(directiveToUse);
  15003. }
  15004. } else {
  15005. context.onError(
  15006. createDOMCompilerError(
  15007. 57,
  15008. dir.loc
  15009. )
  15010. );
  15011. }
  15012. baseResult.props = baseResult.props.filter(
  15013. (p) => !(p.key.type === 4 && p.key.content === "modelValue")
  15014. );
  15015. return baseResult;
  15016. };
  15017. const isEventOptionModifier = /* @__PURE__ */ makeMap(`passive,once,capture`);
  15018. const isNonKeyModifier = /* @__PURE__ */ makeMap(
  15019. // event propagation management
  15020. `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
  15021. );
  15022. const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
  15023. const isKeyboardEvent = /* @__PURE__ */ makeMap(
  15024. `onkeyup,onkeydown,onkeypress`,
  15025. true
  15026. );
  15027. const resolveModifiers = (key, modifiers, context, loc) => {
  15028. const keyModifiers = [];
  15029. const nonKeyModifiers = [];
  15030. const eventOptionModifiers = [];
  15031. for (let i = 0; i < modifiers.length; i++) {
  15032. const modifier = modifiers[i];
  15033. if (isEventOptionModifier(modifier)) {
  15034. eventOptionModifiers.push(modifier);
  15035. } else {
  15036. if (maybeKeyModifier(modifier)) {
  15037. if (isStaticExp(key)) {
  15038. if (isKeyboardEvent(key.content)) {
  15039. keyModifiers.push(modifier);
  15040. } else {
  15041. nonKeyModifiers.push(modifier);
  15042. }
  15043. } else {
  15044. keyModifiers.push(modifier);
  15045. nonKeyModifiers.push(modifier);
  15046. }
  15047. } else {
  15048. if (isNonKeyModifier(modifier)) {
  15049. nonKeyModifiers.push(modifier);
  15050. } else {
  15051. keyModifiers.push(modifier);
  15052. }
  15053. }
  15054. }
  15055. }
  15056. return {
  15057. keyModifiers,
  15058. nonKeyModifiers,
  15059. eventOptionModifiers
  15060. };
  15061. };
  15062. const transformClick = (key, event) => {
  15063. const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === "onclick";
  15064. return isStaticClick ? createSimpleExpression(event, true) : key.type !== 4 ? createCompoundExpression([
  15065. `(`,
  15066. key,
  15067. `) === "onClick" ? "${event}" : (`,
  15068. key,
  15069. `)`
  15070. ]) : key;
  15071. };
  15072. const transformOn = (dir, node, context) => {
  15073. return transformOn$1(dir, node, context, (baseResult) => {
  15074. const { modifiers } = dir;
  15075. if (!modifiers.length)
  15076. return baseResult;
  15077. let { key, value: handlerExp } = baseResult.props[0];
  15078. const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
  15079. if (nonKeyModifiers.includes("right")) {
  15080. key = transformClick(key, `onContextmenu`);
  15081. }
  15082. if (nonKeyModifiers.includes("middle")) {
  15083. key = transformClick(key, `onMouseup`);
  15084. }
  15085. if (nonKeyModifiers.length) {
  15086. handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
  15087. handlerExp,
  15088. JSON.stringify(nonKeyModifiers)
  15089. ]);
  15090. }
  15091. if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
  15092. (!isStaticExp(key) || isKeyboardEvent(key.content))) {
  15093. handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
  15094. handlerExp,
  15095. JSON.stringify(keyModifiers)
  15096. ]);
  15097. }
  15098. if (eventOptionModifiers.length) {
  15099. const modifierPostfix = eventOptionModifiers.map(capitalize).join("");
  15100. key = isStaticExp(key) ? createSimpleExpression(`${key.content}${modifierPostfix}`, true) : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
  15101. }
  15102. return {
  15103. props: [createObjectProperty(key, handlerExp)]
  15104. };
  15105. });
  15106. };
  15107. const transformShow = (dir, node, context) => {
  15108. const { exp, loc } = dir;
  15109. if (!exp) {
  15110. context.onError(
  15111. createDOMCompilerError(61, loc)
  15112. );
  15113. }
  15114. return {
  15115. props: [],
  15116. needRuntime: context.helper(V_SHOW)
  15117. };
  15118. };
  15119. const transformTransition = (node, context) => {
  15120. if (node.type === 1 && node.tagType === 1) {
  15121. const component = context.isBuiltInComponent(node.tag);
  15122. if (component === TRANSITION) {
  15123. return () => {
  15124. if (!node.children.length) {
  15125. return;
  15126. }
  15127. if (hasMultipleChildren(node)) {
  15128. context.onError(
  15129. createDOMCompilerError(
  15130. 62,
  15131. {
  15132. start: node.children[0].loc.start,
  15133. end: node.children[node.children.length - 1].loc.end,
  15134. source: ""
  15135. }
  15136. )
  15137. );
  15138. }
  15139. const child = node.children[0];
  15140. if (child.type === 1) {
  15141. for (const p of child.props) {
  15142. if (p.type === 7 && p.name === "show") {
  15143. node.props.push({
  15144. type: 6,
  15145. name: "persisted",
  15146. value: void 0,
  15147. loc: node.loc
  15148. });
  15149. }
  15150. }
  15151. }
  15152. };
  15153. }
  15154. }
  15155. };
  15156. function hasMultipleChildren(node) {
  15157. const children = node.children = node.children.filter(
  15158. (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
  15159. );
  15160. const child = children[0];
  15161. return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
  15162. }
  15163. const ignoreSideEffectTags = (node, context) => {
  15164. if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
  15165. context.onError(
  15166. createDOMCompilerError(
  15167. 63,
  15168. node.loc
  15169. )
  15170. );
  15171. context.removeNode();
  15172. }
  15173. };
  15174. const DOMNodeTransforms = [
  15175. transformStyle,
  15176. ...[transformTransition]
  15177. ];
  15178. const DOMDirectiveTransforms = {
  15179. cloak: noopDirectiveTransform,
  15180. html: transformVHtml,
  15181. text: transformVText,
  15182. model: transformModel,
  15183. // override compiler-core
  15184. on: transformOn,
  15185. // override compiler-core
  15186. show: transformShow
  15187. };
  15188. function compile(template, options = {}) {
  15189. return baseCompile(
  15190. template,
  15191. extend({}, parserOptions, options, {
  15192. nodeTransforms: [
  15193. // ignore <script> and <tag>
  15194. // this is not put inside DOMNodeTransforms because that list is used
  15195. // by compiler-ssr to generate vnode fallback branches
  15196. ignoreSideEffectTags,
  15197. ...DOMNodeTransforms,
  15198. ...options.nodeTransforms || []
  15199. ],
  15200. directiveTransforms: extend(
  15201. {},
  15202. DOMDirectiveTransforms,
  15203. options.directiveTransforms || {}
  15204. ),
  15205. transformHoist: null
  15206. })
  15207. );
  15208. }
  15209. {
  15210. initDev();
  15211. }
  15212. const compileCache = /* @__PURE__ */ Object.create(null);
  15213. function compileToFunction(template, options) {
  15214. if (!isString(template)) {
  15215. if (template.nodeType) {
  15216. template = template.innerHTML;
  15217. } else {
  15218. warn(`invalid template option: `, template);
  15219. return NOOP;
  15220. }
  15221. }
  15222. const key = template;
  15223. const cached = compileCache[key];
  15224. if (cached) {
  15225. return cached;
  15226. }
  15227. if (template[0] === "#") {
  15228. const el = document.querySelector(template);
  15229. if (!el) {
  15230. warn(`Template element not found or is empty: ${template}`);
  15231. }
  15232. template = el ? el.innerHTML : ``;
  15233. }
  15234. const opts = extend(
  15235. {
  15236. hoistStatic: true,
  15237. onError: onError ,
  15238. onWarn: (e) => onError(e, true)
  15239. },
  15240. options
  15241. );
  15242. if (!opts.isCustomElement && typeof customElements !== "undefined") {
  15243. opts.isCustomElement = (tag) => !!customElements.get(tag);
  15244. }
  15245. const { code } = compile(template, opts);
  15246. function onError(err, asWarning = false) {
  15247. const message = asWarning ? err.message : `Template compilation error: ${err.message}`;
  15248. const codeFrame = err.loc && generateCodeFrame(
  15249. template,
  15250. err.loc.start.offset,
  15251. err.loc.end.offset
  15252. );
  15253. warn(codeFrame ? `${message}
  15254. ${codeFrame}` : message);
  15255. }
  15256. const render = new Function("Vue", code)(runtimeDom);
  15257. render._rc = true;
  15258. return compileCache[key] = render;
  15259. }
  15260. registerRuntimeCompiler(compileToFunction);
  15261. export { BaseTransition, BaseTransitionPropsValidators, Comment, EffectScope, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, Transition, TransitionGroup, VueElement, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, compileToFunction as compile, computed, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineModel, defineOptions, defineProps, defineSSRCustomElement, defineSlots, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getTransitionRawChildren, guardReactiveProps, h, handleError, hasInjectionContext, hydrate, initCustomFormatter, initDirectivesForSSR, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isShallow, isVNode, markRaw, mergeDefaults, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, toValue, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useModel, useSSRContext, useSlots, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };