chunk-IND6KQVK.js 197 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507
  1. import {
  2. init_runtime_dom_esm_bundler,
  3. runtime_dom_esm_bundler_exports
  4. } from "./chunk-S6VK5PVK.js";
  5. import {
  6. EMPTY_OBJ,
  7. NO,
  8. NOOP,
  9. PatchFlagNames,
  10. camelize,
  11. capitalize,
  12. extend,
  13. generateCodeFrame,
  14. init_shared_esm_bundler,
  15. isArray,
  16. isBuiltInDirective,
  17. isHTMLTag,
  18. isMathMLTag,
  19. isObject,
  20. isOn,
  21. isReservedProp,
  22. isSVGTag,
  23. isString,
  24. isSymbol,
  25. isVoidTag,
  26. makeMap,
  27. parseStringStyle,
  28. shared_esm_bundler_exports,
  29. slotFlagsText,
  30. toHandlerKey
  31. } from "./chunk-VNBICN6T.js";
  32. import {
  33. __commonJS,
  34. __esm,
  35. __export,
  36. __toCommonJS
  37. } from "./chunk-2LSFTFF7.js";
  38. // node_modules/.pnpm/@vue+compiler-core@3.4.27/node_modules/@vue/compiler-core/dist/compiler-core.esm-bundler.js
  39. function registerRuntimeHelpers(helpers) {
  40. Object.getOwnPropertySymbols(helpers).forEach((s) => {
  41. helperNameMap[s] = helpers[s];
  42. });
  43. }
  44. function createRoot(children, source = "") {
  45. return {
  46. type: 0,
  47. source,
  48. children,
  49. helpers: /* @__PURE__ */ new Set(),
  50. components: [],
  51. directives: [],
  52. hoists: [],
  53. imports: [],
  54. cached: 0,
  55. temps: 0,
  56. codegenNode: void 0,
  57. loc: locStub
  58. };
  59. }
  60. function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent2 = false, loc = locStub) {
  61. if (context) {
  62. if (isBlock) {
  63. context.helper(OPEN_BLOCK);
  64. context.helper(getVNodeBlockHelper(context.inSSR, isComponent2));
  65. } else {
  66. context.helper(getVNodeHelper(context.inSSR, isComponent2));
  67. }
  68. if (directives) {
  69. context.helper(WITH_DIRECTIVES);
  70. }
  71. }
  72. return {
  73. type: 13,
  74. tag,
  75. props,
  76. children,
  77. patchFlag,
  78. dynamicProps,
  79. directives,
  80. isBlock,
  81. disableTracking,
  82. isComponent: isComponent2,
  83. loc
  84. };
  85. }
  86. function createArrayExpression(elements, loc = locStub) {
  87. return {
  88. type: 17,
  89. loc,
  90. elements
  91. };
  92. }
  93. function createObjectExpression(properties, loc = locStub) {
  94. return {
  95. type: 15,
  96. loc,
  97. properties
  98. };
  99. }
  100. function createObjectProperty(key, value) {
  101. return {
  102. type: 16,
  103. loc: locStub,
  104. key: isString(key) ? createSimpleExpression(key, true) : key,
  105. value
  106. };
  107. }
  108. function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0) {
  109. return {
  110. type: 4,
  111. loc,
  112. content,
  113. isStatic,
  114. constType: isStatic ? 3 : constType
  115. };
  116. }
  117. function createInterpolation(content, loc) {
  118. return {
  119. type: 5,
  120. loc,
  121. content: isString(content) ? createSimpleExpression(content, false, loc) : content
  122. };
  123. }
  124. function createCompoundExpression(children, loc = locStub) {
  125. return {
  126. type: 8,
  127. loc,
  128. children
  129. };
  130. }
  131. function createCallExpression(callee, args = [], loc = locStub) {
  132. return {
  133. type: 14,
  134. loc,
  135. callee,
  136. arguments: args
  137. };
  138. }
  139. function createFunctionExpression(params, returns = void 0, newline = false, isSlot = false, loc = locStub) {
  140. return {
  141. type: 18,
  142. params,
  143. returns,
  144. newline,
  145. isSlot,
  146. loc
  147. };
  148. }
  149. function createConditionalExpression(test, consequent, alternate, newline = true) {
  150. return {
  151. type: 19,
  152. test,
  153. consequent,
  154. alternate,
  155. newline,
  156. loc: locStub
  157. };
  158. }
  159. function createCacheExpression(index, value, isVNode = false) {
  160. return {
  161. type: 20,
  162. index,
  163. value,
  164. isVNode,
  165. loc: locStub
  166. };
  167. }
  168. function createBlockStatement(body) {
  169. return {
  170. type: 21,
  171. body,
  172. loc: locStub
  173. };
  174. }
  175. function createTemplateLiteral(elements) {
  176. return {
  177. type: 22,
  178. elements,
  179. loc: locStub
  180. };
  181. }
  182. function createIfStatement(test, consequent, alternate) {
  183. return {
  184. type: 23,
  185. test,
  186. consequent,
  187. alternate,
  188. loc: locStub
  189. };
  190. }
  191. function createAssignmentExpression(left, right) {
  192. return {
  193. type: 24,
  194. left,
  195. right,
  196. loc: locStub
  197. };
  198. }
  199. function createSequenceExpression(expressions) {
  200. return {
  201. type: 25,
  202. expressions,
  203. loc: locStub
  204. };
  205. }
  206. function createReturnStatement(returns) {
  207. return {
  208. type: 26,
  209. returns,
  210. loc: locStub
  211. };
  212. }
  213. function getVNodeHelper(ssr, isComponent2) {
  214. return ssr || isComponent2 ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
  215. }
  216. function getVNodeBlockHelper(ssr, isComponent2) {
  217. return ssr || isComponent2 ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
  218. }
  219. function convertToBlock(node, { helper, removeHelper, inSSR }) {
  220. if (!node.isBlock) {
  221. node.isBlock = true;
  222. removeHelper(getVNodeHelper(inSSR, node.isComponent));
  223. helper(OPEN_BLOCK);
  224. helper(getVNodeBlockHelper(inSSR, node.isComponent));
  225. }
  226. }
  227. function isTagStartChar(c) {
  228. return c >= 97 && c <= 122 || c >= 65 && c <= 90;
  229. }
  230. function isWhitespace(c) {
  231. return c === 32 || c === 10 || c === 9 || c === 12 || c === 13;
  232. }
  233. function isEndOfTagSection(c) {
  234. return c === 47 || c === 62 || isWhitespace(c);
  235. }
  236. function toCharCodes(str) {
  237. const ret = new Uint8Array(str.length);
  238. for (let i = 0; i < str.length; i++) {
  239. ret[i] = str.charCodeAt(i);
  240. }
  241. return ret;
  242. }
  243. function getCompatValue(key, { compatConfig }) {
  244. const value = compatConfig && compatConfig[key];
  245. if (key === "MODE") {
  246. return value || 3;
  247. } else {
  248. return value;
  249. }
  250. }
  251. function isCompatEnabled(key, context) {
  252. const mode = getCompatValue("MODE", context);
  253. const value = getCompatValue(key, context);
  254. return mode === 3 ? value === true : value !== false;
  255. }
  256. function checkCompatEnabled(key, context, loc, ...args) {
  257. const enabled = isCompatEnabled(key, context);
  258. if (enabled) {
  259. warnDeprecation(key, context, loc, ...args);
  260. }
  261. return enabled;
  262. }
  263. function warnDeprecation(key, context, loc, ...args) {
  264. const val = getCompatValue(key, context);
  265. if (val === "suppress-warning") {
  266. return;
  267. }
  268. const { message, link } = deprecationData[key];
  269. const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
  270. Details: ${link}` : ``}`;
  271. const err = new SyntaxError(msg);
  272. err.code = key;
  273. if (loc)
  274. err.loc = loc;
  275. context.onWarn(err);
  276. }
  277. function defaultOnError(error) {
  278. throw error;
  279. }
  280. function defaultOnWarn(msg) {
  281. console.warn(`[Vue warn] ${msg.message}`);
  282. }
  283. function createCompilerError(code, loc, messages, additionalMessage) {
  284. const msg = true ? (messages || errorMessages)[code] + (additionalMessage || ``) : `https://vuejs.org/error-reference/#compiler-${code}`;
  285. const error = new SyntaxError(String(msg));
  286. error.code = code;
  287. error.loc = loc;
  288. return error;
  289. }
  290. function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = /* @__PURE__ */ Object.create(null)) {
  291. {
  292. return;
  293. }
  294. }
  295. function isReferencedIdentifier(id, parent, parentStack) {
  296. {
  297. return false;
  298. }
  299. }
  300. function isInDestructureAssignment(parent, parentStack) {
  301. if (parent && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
  302. let i = parentStack.length;
  303. while (i--) {
  304. const p = parentStack[i];
  305. if (p.type === "AssignmentExpression") {
  306. return true;
  307. } else if (p.type !== "ObjectProperty" && !p.type.endsWith("Pattern")) {
  308. break;
  309. }
  310. }
  311. }
  312. return false;
  313. }
  314. function isInNewExpression(parentStack) {
  315. let i = parentStack.length;
  316. while (i--) {
  317. const p = parentStack[i];
  318. if (p.type === "NewExpression") {
  319. return true;
  320. } else if (p.type !== "MemberExpression") {
  321. break;
  322. }
  323. }
  324. return false;
  325. }
  326. function walkFunctionParams(node, onIdent) {
  327. for (const p of node.params) {
  328. for (const id of extractIdentifiers(p)) {
  329. onIdent(id);
  330. }
  331. }
  332. }
  333. function walkBlockDeclarations(block, onIdent) {
  334. for (const stmt of block.body) {
  335. if (stmt.type === "VariableDeclaration") {
  336. if (stmt.declare)
  337. continue;
  338. for (const decl of stmt.declarations) {
  339. for (const id of extractIdentifiers(decl.id)) {
  340. onIdent(id);
  341. }
  342. }
  343. } else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
  344. if (stmt.declare || !stmt.id)
  345. continue;
  346. onIdent(stmt.id);
  347. } else if (stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement") {
  348. const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
  349. if (variable && variable.type === "VariableDeclaration") {
  350. for (const decl of variable.declarations) {
  351. for (const id of extractIdentifiers(decl.id)) {
  352. onIdent(id);
  353. }
  354. }
  355. }
  356. }
  357. }
  358. }
  359. function extractIdentifiers(param, nodes = []) {
  360. switch (param.type) {
  361. case "Identifier":
  362. nodes.push(param);
  363. break;
  364. case "MemberExpression":
  365. let object = param;
  366. while (object.type === "MemberExpression") {
  367. object = object.object;
  368. }
  369. nodes.push(object);
  370. break;
  371. case "ObjectPattern":
  372. for (const prop of param.properties) {
  373. if (prop.type === "RestElement") {
  374. extractIdentifiers(prop.argument, nodes);
  375. } else {
  376. extractIdentifiers(prop.value, nodes);
  377. }
  378. }
  379. break;
  380. case "ArrayPattern":
  381. param.elements.forEach((element) => {
  382. if (element)
  383. extractIdentifiers(element, nodes);
  384. });
  385. break;
  386. case "RestElement":
  387. extractIdentifiers(param.argument, nodes);
  388. break;
  389. case "AssignmentPattern":
  390. extractIdentifiers(param.left, nodes);
  391. break;
  392. }
  393. return nodes;
  394. }
  395. function unwrapTSNode(node) {
  396. if (TS_NODE_TYPES.includes(node.type)) {
  397. return unwrapTSNode(node.expression);
  398. } else {
  399. return node;
  400. }
  401. }
  402. function isCoreComponent(tag) {
  403. switch (tag) {
  404. case "Teleport":
  405. case "teleport":
  406. return TELEPORT;
  407. case "Suspense":
  408. case "suspense":
  409. return SUSPENSE;
  410. case "KeepAlive":
  411. case "keep-alive":
  412. return KEEP_ALIVE;
  413. case "BaseTransition":
  414. case "base-transition":
  415. return BASE_TRANSITION;
  416. }
  417. }
  418. function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
  419. return advancePositionWithMutation(
  420. {
  421. offset: pos.offset,
  422. line: pos.line,
  423. column: pos.column
  424. },
  425. source,
  426. numberOfCharacters
  427. );
  428. }
  429. function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
  430. let linesCount = 0;
  431. let lastNewLinePos = -1;
  432. for (let i = 0; i < numberOfCharacters; i++) {
  433. if (source.charCodeAt(i) === 10) {
  434. linesCount++;
  435. lastNewLinePos = i;
  436. }
  437. }
  438. pos.offset += numberOfCharacters;
  439. pos.line += linesCount;
  440. pos.column = lastNewLinePos === -1 ? pos.column + numberOfCharacters : numberOfCharacters - lastNewLinePos;
  441. return pos;
  442. }
  443. function assert(condition, msg) {
  444. if (!condition) {
  445. throw new Error(msg || `unexpected compiler condition`);
  446. }
  447. }
  448. function findDir(node, name, allowEmpty = false) {
  449. for (let i = 0; i < node.props.length; i++) {
  450. const p = node.props[i];
  451. if (p.type === 7 && (allowEmpty || p.exp) && (isString(name) ? p.name === name : name.test(p.name))) {
  452. return p;
  453. }
  454. }
  455. }
  456. function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
  457. for (let i = 0; i < node.props.length; i++) {
  458. const p = node.props[i];
  459. if (p.type === 6) {
  460. if (dynamicOnly)
  461. continue;
  462. if (p.name === name && (p.value || allowEmpty)) {
  463. return p;
  464. }
  465. } else if (p.name === "bind" && (p.exp || allowEmpty) && isStaticArgOf(p.arg, name)) {
  466. return p;
  467. }
  468. }
  469. }
  470. function isStaticArgOf(arg, name) {
  471. return !!(arg && isStaticExp(arg) && arg.content === name);
  472. }
  473. function hasDynamicKeyVBind(node) {
  474. return node.props.some(
  475. (p) => p.type === 7 && p.name === "bind" && (!p.arg || // v-bind="obj"
  476. p.arg.type !== 4 || // v-bind:[_ctx.foo]
  477. !p.arg.isStatic)
  478. // v-bind:[foo]
  479. );
  480. }
  481. function isText$1(node) {
  482. return node.type === 5 || node.type === 2;
  483. }
  484. function isVSlot(p) {
  485. return p.type === 7 && p.name === "slot";
  486. }
  487. function isTemplateNode(node) {
  488. return node.type === 1 && node.tagType === 3;
  489. }
  490. function isSlotOutlet(node) {
  491. return node.type === 1 && node.tagType === 2;
  492. }
  493. function getUnnormalizedProps(props, callPath = []) {
  494. if (props && !isString(props) && props.type === 14) {
  495. const callee = props.callee;
  496. if (!isString(callee) && propsHelperSet.has(callee)) {
  497. return getUnnormalizedProps(
  498. props.arguments[0],
  499. callPath.concat(props)
  500. );
  501. }
  502. }
  503. return [props, callPath];
  504. }
  505. function injectProp(node, prop, context) {
  506. let propsWithInjection;
  507. let props = node.type === 13 ? node.props : node.arguments[2];
  508. let callPath = [];
  509. let parentCall;
  510. if (props && !isString(props) && props.type === 14) {
  511. const ret = getUnnormalizedProps(props);
  512. props = ret[0];
  513. callPath = ret[1];
  514. parentCall = callPath[callPath.length - 1];
  515. }
  516. if (props == null || isString(props)) {
  517. propsWithInjection = createObjectExpression([prop]);
  518. } else if (props.type === 14) {
  519. const first = props.arguments[0];
  520. if (!isString(first) && first.type === 15) {
  521. if (!hasProp(prop, first)) {
  522. first.properties.unshift(prop);
  523. }
  524. } else {
  525. if (props.callee === TO_HANDLERS) {
  526. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  527. createObjectExpression([prop]),
  528. props
  529. ]);
  530. } else {
  531. props.arguments.unshift(createObjectExpression([prop]));
  532. }
  533. }
  534. !propsWithInjection && (propsWithInjection = props);
  535. } else if (props.type === 15) {
  536. if (!hasProp(prop, props)) {
  537. props.properties.unshift(prop);
  538. }
  539. propsWithInjection = props;
  540. } else {
  541. propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
  542. createObjectExpression([prop]),
  543. props
  544. ]);
  545. if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) {
  546. parentCall = callPath[callPath.length - 2];
  547. }
  548. }
  549. if (node.type === 13) {
  550. if (parentCall) {
  551. parentCall.arguments[0] = propsWithInjection;
  552. } else {
  553. node.props = propsWithInjection;
  554. }
  555. } else {
  556. if (parentCall) {
  557. parentCall.arguments[0] = propsWithInjection;
  558. } else {
  559. node.arguments[2] = propsWithInjection;
  560. }
  561. }
  562. }
  563. function hasProp(prop, props) {
  564. let result = false;
  565. if (prop.key.type === 4) {
  566. const propKeyName = prop.key.content;
  567. result = props.properties.some(
  568. (p) => p.key.type === 4 && p.key.content === propKeyName
  569. );
  570. }
  571. return result;
  572. }
  573. function toValidAssetId(name, type) {
  574. return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
  575. return searchValue === "-" ? "_" : name.charCodeAt(replaceValue).toString();
  576. })}`;
  577. }
  578. function hasScopeRef(node, ids) {
  579. if (!node || Object.keys(ids).length === 0) {
  580. return false;
  581. }
  582. switch (node.type) {
  583. case 1:
  584. for (let i = 0; i < node.props.length; i++) {
  585. const p = node.props[i];
  586. if (p.type === 7 && (hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
  587. return true;
  588. }
  589. }
  590. return node.children.some((c) => hasScopeRef(c, ids));
  591. case 11:
  592. if (hasScopeRef(node.source, ids)) {
  593. return true;
  594. }
  595. return node.children.some((c) => hasScopeRef(c, ids));
  596. case 9:
  597. return node.branches.some((b) => hasScopeRef(b, ids));
  598. case 10:
  599. if (hasScopeRef(node.condition, ids)) {
  600. return true;
  601. }
  602. return node.children.some((c) => hasScopeRef(c, ids));
  603. case 4:
  604. return !node.isStatic && isSimpleIdentifier(node.content) && !!ids[node.content];
  605. case 8:
  606. return node.children.some((c) => isObject(c) && hasScopeRef(c, ids));
  607. case 5:
  608. case 12:
  609. return hasScopeRef(node.content, ids);
  610. case 2:
  611. case 3:
  612. return false;
  613. default:
  614. if (true)
  615. ;
  616. return false;
  617. }
  618. }
  619. function getMemoedVNodeCall(node) {
  620. if (node.type === 14 && node.callee === WITH_MEMO) {
  621. return node.arguments[1].returns;
  622. } else {
  623. return node;
  624. }
  625. }
  626. function parseForExpression(input) {
  627. const loc = input.loc;
  628. const exp = input.content;
  629. const inMatch = exp.match(forAliasRE);
  630. if (!inMatch)
  631. return;
  632. const [, LHS, RHS] = inMatch;
  633. const createAliasExpression = (content, offset, asParam = false) => {
  634. const start = loc.start.offset + offset;
  635. const end = start + content.length;
  636. return createExp(
  637. content,
  638. false,
  639. getLoc(start, end),
  640. 0,
  641. asParam ? 1 : 0
  642. /* Normal */
  643. );
  644. };
  645. const result = {
  646. source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
  647. value: void 0,
  648. key: void 0,
  649. index: void 0,
  650. finalized: false
  651. };
  652. let valueContent = LHS.trim().replace(stripParensRE, "").trim();
  653. const trimmedOffset = LHS.indexOf(valueContent);
  654. const iteratorMatch = valueContent.match(forIteratorRE);
  655. if (iteratorMatch) {
  656. valueContent = valueContent.replace(forIteratorRE, "").trim();
  657. const keyContent = iteratorMatch[1].trim();
  658. let keyOffset;
  659. if (keyContent) {
  660. keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
  661. result.key = createAliasExpression(keyContent, keyOffset, true);
  662. }
  663. if (iteratorMatch[2]) {
  664. const indexContent = iteratorMatch[2].trim();
  665. if (indexContent) {
  666. result.index = createAliasExpression(
  667. indexContent,
  668. exp.indexOf(
  669. indexContent,
  670. result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
  671. ),
  672. true
  673. );
  674. }
  675. }
  676. }
  677. if (valueContent) {
  678. result.value = createAliasExpression(valueContent, trimmedOffset, true);
  679. }
  680. return result;
  681. }
  682. function getSlice(start, end) {
  683. return currentInput.slice(start, end);
  684. }
  685. function endOpenTag(end) {
  686. if (tokenizer.inSFCRoot) {
  687. currentOpenTag.innerLoc = getLoc(end + 1, end + 1);
  688. }
  689. addNode(currentOpenTag);
  690. const { tag, ns } = currentOpenTag;
  691. if (ns === 0 && currentOptions.isPreTag(tag)) {
  692. inPre++;
  693. }
  694. if (currentOptions.isVoidTag(tag)) {
  695. onCloseTag(currentOpenTag, end);
  696. } else {
  697. stack.unshift(currentOpenTag);
  698. if (ns === 1 || ns === 2) {
  699. tokenizer.inXML = true;
  700. }
  701. }
  702. currentOpenTag = null;
  703. }
  704. function onText(content, start, end) {
  705. {
  706. const tag = stack[0] && stack[0].tag;
  707. if (tag !== "script" && tag !== "style" && content.includes("&")) {
  708. content = currentOptions.decodeEntities(content, false);
  709. }
  710. }
  711. const parent = stack[0] || currentRoot;
  712. const lastNode = parent.children[parent.children.length - 1];
  713. if (lastNode && lastNode.type === 2) {
  714. lastNode.content += content;
  715. setLocEnd(lastNode.loc, end);
  716. } else {
  717. parent.children.push({
  718. type: 2,
  719. content,
  720. loc: getLoc(start, end)
  721. });
  722. }
  723. }
  724. function onCloseTag(el, end, isImplied = false) {
  725. if (isImplied) {
  726. setLocEnd(el.loc, backTrack(end, 60));
  727. } else {
  728. setLocEnd(el.loc, lookAhead(end, 62) + 1);
  729. }
  730. if (tokenizer.inSFCRoot) {
  731. if (el.children.length) {
  732. el.innerLoc.end = extend({}, el.children[el.children.length - 1].loc.end);
  733. } else {
  734. el.innerLoc.end = extend({}, el.innerLoc.start);
  735. }
  736. el.innerLoc.source = getSlice(
  737. el.innerLoc.start.offset,
  738. el.innerLoc.end.offset
  739. );
  740. }
  741. const { tag, ns } = el;
  742. if (!inVPre) {
  743. if (tag === "slot") {
  744. el.tagType = 2;
  745. } else if (isFragmentTemplate(el)) {
  746. el.tagType = 3;
  747. } else if (isComponent(el)) {
  748. el.tagType = 1;
  749. }
  750. }
  751. if (!tokenizer.inRCDATA) {
  752. el.children = condenseWhitespace(el.children, el.tag);
  753. }
  754. if (ns === 0 && currentOptions.isPreTag(tag)) {
  755. inPre--;
  756. }
  757. if (currentVPreBoundary === el) {
  758. inVPre = tokenizer.inVPre = false;
  759. currentVPreBoundary = null;
  760. }
  761. if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
  762. tokenizer.inXML = false;
  763. }
  764. {
  765. const props = el.props;
  766. if (isCompatEnabled(
  767. "COMPILER_V_IF_V_FOR_PRECEDENCE",
  768. currentOptions
  769. )) {
  770. let hasIf = false;
  771. let hasFor = false;
  772. for (let i = 0; i < props.length; i++) {
  773. const p = props[i];
  774. if (p.type === 7) {
  775. if (p.name === "if") {
  776. hasIf = true;
  777. } else if (p.name === "for") {
  778. hasFor = true;
  779. }
  780. }
  781. if (hasIf && hasFor) {
  782. warnDeprecation(
  783. "COMPILER_V_IF_V_FOR_PRECEDENCE",
  784. currentOptions,
  785. el.loc
  786. );
  787. break;
  788. }
  789. }
  790. }
  791. if (!tokenizer.inSFCRoot && isCompatEnabled(
  792. "COMPILER_NATIVE_TEMPLATE",
  793. currentOptions
  794. ) && el.tag === "template" && !isFragmentTemplate(el)) {
  795. warnDeprecation(
  796. "COMPILER_NATIVE_TEMPLATE",
  797. currentOptions,
  798. el.loc
  799. );
  800. const parent = stack[0] || currentRoot;
  801. const index = parent.children.indexOf(el);
  802. parent.children.splice(index, 1, ...el.children);
  803. }
  804. const inlineTemplateProp = props.find(
  805. (p) => p.type === 6 && p.name === "inline-template"
  806. );
  807. if (inlineTemplateProp && checkCompatEnabled(
  808. "COMPILER_INLINE_TEMPLATE",
  809. currentOptions,
  810. inlineTemplateProp.loc
  811. ) && el.children.length) {
  812. inlineTemplateProp.value = {
  813. type: 2,
  814. content: getSlice(
  815. el.children[0].loc.start.offset,
  816. el.children[el.children.length - 1].loc.end.offset
  817. ),
  818. loc: inlineTemplateProp.loc
  819. };
  820. }
  821. }
  822. }
  823. function lookAhead(index, c) {
  824. let i = index;
  825. while (currentInput.charCodeAt(i) !== c && i < currentInput.length - 1)
  826. i++;
  827. return i;
  828. }
  829. function backTrack(index, c) {
  830. let i = index;
  831. while (currentInput.charCodeAt(i) !== c && i >= 0)
  832. i--;
  833. return i;
  834. }
  835. function isFragmentTemplate({ tag, props }) {
  836. if (tag === "template") {
  837. for (let i = 0; i < props.length; i++) {
  838. if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
  839. return true;
  840. }
  841. }
  842. }
  843. return false;
  844. }
  845. function isComponent({ tag, props }) {
  846. if (currentOptions.isCustomElement(tag)) {
  847. return false;
  848. }
  849. if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || currentOptions.isBuiltInComponent && currentOptions.isBuiltInComponent(tag) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
  850. return true;
  851. }
  852. for (let i = 0; i < props.length; i++) {
  853. const p = props[i];
  854. if (p.type === 6) {
  855. if (p.name === "is" && p.value) {
  856. if (p.value.content.startsWith("vue:")) {
  857. return true;
  858. } else if (checkCompatEnabled(
  859. "COMPILER_IS_ON_ELEMENT",
  860. currentOptions,
  861. p.loc
  862. )) {
  863. return true;
  864. }
  865. }
  866. } else if (
  867. // :is on plain element - only treat as component in compat mode
  868. p.name === "bind" && isStaticArgOf(p.arg, "is") && checkCompatEnabled(
  869. "COMPILER_IS_ON_ELEMENT",
  870. currentOptions,
  871. p.loc
  872. )
  873. ) {
  874. return true;
  875. }
  876. }
  877. return false;
  878. }
  879. function isUpperCase(c) {
  880. return c > 64 && c < 91;
  881. }
  882. function condenseWhitespace(nodes, tag) {
  883. const shouldCondense = currentOptions.whitespace !== "preserve";
  884. let removedWhitespace = false;
  885. for (let i = 0; i < nodes.length; i++) {
  886. const node = nodes[i];
  887. if (node.type === 2) {
  888. if (!inPre) {
  889. if (isAllWhitespace(node.content)) {
  890. const prev = nodes[i - 1] && nodes[i - 1].type;
  891. const next = nodes[i + 1] && nodes[i + 1].type;
  892. if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
  893. removedWhitespace = true;
  894. nodes[i] = null;
  895. } else {
  896. node.content = " ";
  897. }
  898. } else if (shouldCondense) {
  899. node.content = condense(node.content);
  900. }
  901. } else {
  902. node.content = node.content.replace(windowsNewlineRE, "\n");
  903. }
  904. }
  905. }
  906. if (inPre && tag && currentOptions.isPreTag(tag)) {
  907. const first = nodes[0];
  908. if (first && first.type === 2) {
  909. first.content = first.content.replace(/^\r?\n/, "");
  910. }
  911. }
  912. return removedWhitespace ? nodes.filter(Boolean) : nodes;
  913. }
  914. function isAllWhitespace(str) {
  915. for (let i = 0; i < str.length; i++) {
  916. if (!isWhitespace(str.charCodeAt(i))) {
  917. return false;
  918. }
  919. }
  920. return true;
  921. }
  922. function hasNewlineChar(str) {
  923. for (let i = 0; i < str.length; i++) {
  924. const c = str.charCodeAt(i);
  925. if (c === 10 || c === 13) {
  926. return true;
  927. }
  928. }
  929. return false;
  930. }
  931. function condense(str) {
  932. let ret = "";
  933. let prevCharIsWhitespace = false;
  934. for (let i = 0; i < str.length; i++) {
  935. if (isWhitespace(str.charCodeAt(i))) {
  936. if (!prevCharIsWhitespace) {
  937. ret += " ";
  938. prevCharIsWhitespace = true;
  939. }
  940. } else {
  941. ret += str[i];
  942. prevCharIsWhitespace = false;
  943. }
  944. }
  945. return ret;
  946. }
  947. function addNode(node) {
  948. (stack[0] || currentRoot).children.push(node);
  949. }
  950. function getLoc(start, end) {
  951. return {
  952. start: tokenizer.getPos(start),
  953. // @ts-expect-error allow late attachment
  954. end: end == null ? end : tokenizer.getPos(end),
  955. // @ts-expect-error allow late attachment
  956. source: end == null ? end : getSlice(start, end)
  957. };
  958. }
  959. function setLocEnd(loc, end) {
  960. loc.end = tokenizer.getPos(end);
  961. loc.source = getSlice(loc.start.offset, end);
  962. }
  963. function dirToAttr(dir) {
  964. const attr = {
  965. type: 6,
  966. name: dir.rawName,
  967. nameLoc: getLoc(
  968. dir.loc.start.offset,
  969. dir.loc.start.offset + dir.rawName.length
  970. ),
  971. value: void 0,
  972. loc: dir.loc
  973. };
  974. if (dir.exp) {
  975. const loc = dir.exp.loc;
  976. if (loc.end.offset < dir.loc.end.offset) {
  977. loc.start.offset--;
  978. loc.start.column--;
  979. loc.end.offset++;
  980. loc.end.column++;
  981. }
  982. attr.value = {
  983. type: 2,
  984. content: dir.exp.content,
  985. loc
  986. };
  987. }
  988. return attr;
  989. }
  990. function createExp(content, isStatic = false, loc, constType = 0, parseMode = 0) {
  991. const exp = createSimpleExpression(content, isStatic, loc, constType);
  992. return exp;
  993. }
  994. function emitError(code, index, message) {
  995. currentOptions.onError(
  996. createCompilerError(code, getLoc(index, index), void 0, message)
  997. );
  998. }
  999. function reset() {
  1000. tokenizer.reset();
  1001. currentOpenTag = null;
  1002. currentProp = null;
  1003. currentAttrValue = "";
  1004. currentAttrStartIndex = -1;
  1005. currentAttrEndIndex = -1;
  1006. stack.length = 0;
  1007. }
  1008. function baseParse(input, options) {
  1009. reset();
  1010. currentInput = input;
  1011. currentOptions = extend({}, defaultParserOptions);
  1012. if (options) {
  1013. let key;
  1014. for (key in options) {
  1015. if (options[key] != null) {
  1016. currentOptions[key] = options[key];
  1017. }
  1018. }
  1019. }
  1020. if (true) {
  1021. if (!currentOptions.decodeEntities) {
  1022. throw new Error(
  1023. `[@vue/compiler-core] decodeEntities option is required in browser builds.`
  1024. );
  1025. }
  1026. }
  1027. tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
  1028. tokenizer.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
  1029. const delimiters = options && options.delimiters;
  1030. if (delimiters) {
  1031. tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
  1032. tokenizer.delimiterClose = toCharCodes(delimiters[1]);
  1033. }
  1034. const root = currentRoot = createRoot([], input);
  1035. tokenizer.parse(currentInput);
  1036. root.loc = getLoc(0, input.length);
  1037. root.children = condenseWhitespace(root.children);
  1038. currentRoot = null;
  1039. return root;
  1040. }
  1041. function hoistStatic(root, context) {
  1042. walk(
  1043. root,
  1044. context,
  1045. // Root node is unfortunately non-hoistable due to potential parent
  1046. // fallthrough attributes.
  1047. isSingleElementRoot(root, root.children[0])
  1048. );
  1049. }
  1050. function isSingleElementRoot(root, child) {
  1051. const { children } = root;
  1052. return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
  1053. }
  1054. function walk(node, context, doNotHoistNode = false) {
  1055. const { children } = node;
  1056. const originalCount = children.length;
  1057. let hoistedCount = 0;
  1058. for (let i = 0; i < children.length; i++) {
  1059. const child = children[i];
  1060. if (child.type === 1 && child.tagType === 0) {
  1061. const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
  1062. if (constantType > 0) {
  1063. if (constantType >= 2) {
  1064. child.codegenNode.patchFlag = -1 + (true ? ` /* HOISTED */` : ``);
  1065. child.codegenNode = context.hoist(child.codegenNode);
  1066. hoistedCount++;
  1067. continue;
  1068. }
  1069. } else {
  1070. const codegenNode = child.codegenNode;
  1071. if (codegenNode.type === 13) {
  1072. const flag = getPatchFlag(codegenNode);
  1073. if ((!flag || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
  1074. const props = getNodeProps(child);
  1075. if (props) {
  1076. codegenNode.props = context.hoist(props);
  1077. }
  1078. }
  1079. if (codegenNode.dynamicProps) {
  1080. codegenNode.dynamicProps = context.hoist(codegenNode.dynamicProps);
  1081. }
  1082. }
  1083. }
  1084. }
  1085. if (child.type === 1) {
  1086. const isComponent2 = child.tagType === 1;
  1087. if (isComponent2) {
  1088. context.scopes.vSlot++;
  1089. }
  1090. walk(child, context);
  1091. if (isComponent2) {
  1092. context.scopes.vSlot--;
  1093. }
  1094. } else if (child.type === 11) {
  1095. walk(child, context, child.children.length === 1);
  1096. } else if (child.type === 9) {
  1097. for (let i2 = 0; i2 < child.branches.length; i2++) {
  1098. walk(
  1099. child.branches[i2],
  1100. context,
  1101. child.branches[i2].children.length === 1
  1102. );
  1103. }
  1104. }
  1105. }
  1106. if (hoistedCount && context.transformHoist) {
  1107. context.transformHoist(children, context, node);
  1108. }
  1109. if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
  1110. const hoisted = context.hoist(
  1111. createArrayExpression(node.codegenNode.children)
  1112. );
  1113. if (context.hmr) {
  1114. hoisted.content = `[...${hoisted.content}]`;
  1115. }
  1116. node.codegenNode.children = hoisted;
  1117. }
  1118. }
  1119. function getConstantType(node, context) {
  1120. const { constantCache } = context;
  1121. switch (node.type) {
  1122. case 1:
  1123. if (node.tagType !== 0) {
  1124. return 0;
  1125. }
  1126. const cached = constantCache.get(node);
  1127. if (cached !== void 0) {
  1128. return cached;
  1129. }
  1130. const codegenNode = node.codegenNode;
  1131. if (codegenNode.type !== 13) {
  1132. return 0;
  1133. }
  1134. if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject") {
  1135. return 0;
  1136. }
  1137. const flag = getPatchFlag(codegenNode);
  1138. if (!flag) {
  1139. let returnType2 = 3;
  1140. const generatedPropsType = getGeneratedPropsConstantType(node, context);
  1141. if (generatedPropsType === 0) {
  1142. constantCache.set(node, 0);
  1143. return 0;
  1144. }
  1145. if (generatedPropsType < returnType2) {
  1146. returnType2 = generatedPropsType;
  1147. }
  1148. for (let i = 0; i < node.children.length; i++) {
  1149. const childType = getConstantType(node.children[i], context);
  1150. if (childType === 0) {
  1151. constantCache.set(node, 0);
  1152. return 0;
  1153. }
  1154. if (childType < returnType2) {
  1155. returnType2 = childType;
  1156. }
  1157. }
  1158. if (returnType2 > 1) {
  1159. for (let i = 0; i < node.props.length; i++) {
  1160. const p = node.props[i];
  1161. if (p.type === 7 && p.name === "bind" && p.exp) {
  1162. const expType = getConstantType(p.exp, context);
  1163. if (expType === 0) {
  1164. constantCache.set(node, 0);
  1165. return 0;
  1166. }
  1167. if (expType < returnType2) {
  1168. returnType2 = expType;
  1169. }
  1170. }
  1171. }
  1172. }
  1173. if (codegenNode.isBlock) {
  1174. for (let i = 0; i < node.props.length; i++) {
  1175. const p = node.props[i];
  1176. if (p.type === 7) {
  1177. constantCache.set(node, 0);
  1178. return 0;
  1179. }
  1180. }
  1181. context.removeHelper(OPEN_BLOCK);
  1182. context.removeHelper(
  1183. getVNodeBlockHelper(context.inSSR, codegenNode.isComponent)
  1184. );
  1185. codegenNode.isBlock = false;
  1186. context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent));
  1187. }
  1188. constantCache.set(node, returnType2);
  1189. return returnType2;
  1190. } else {
  1191. constantCache.set(node, 0);
  1192. return 0;
  1193. }
  1194. case 2:
  1195. case 3:
  1196. return 3;
  1197. case 9:
  1198. case 11:
  1199. case 10:
  1200. return 0;
  1201. case 5:
  1202. case 12:
  1203. return getConstantType(node.content, context);
  1204. case 4:
  1205. return node.constType;
  1206. case 8:
  1207. let returnType = 3;
  1208. for (let i = 0; i < node.children.length; i++) {
  1209. const child = node.children[i];
  1210. if (isString(child) || isSymbol(child)) {
  1211. continue;
  1212. }
  1213. const childType = getConstantType(child, context);
  1214. if (childType === 0) {
  1215. return 0;
  1216. } else if (childType < returnType) {
  1217. returnType = childType;
  1218. }
  1219. }
  1220. return returnType;
  1221. default:
  1222. if (true)
  1223. ;
  1224. return 0;
  1225. }
  1226. }
  1227. function getConstantTypeOfHelperCall(value, context) {
  1228. if (value.type === 14 && !isString(value.callee) && allowHoistedHelperSet.has(value.callee)) {
  1229. const arg = value.arguments[0];
  1230. if (arg.type === 4) {
  1231. return getConstantType(arg, context);
  1232. } else if (arg.type === 14) {
  1233. return getConstantTypeOfHelperCall(arg, context);
  1234. }
  1235. }
  1236. return 0;
  1237. }
  1238. function getGeneratedPropsConstantType(node, context) {
  1239. let returnType = 3;
  1240. const props = getNodeProps(node);
  1241. if (props && props.type === 15) {
  1242. const { properties } = props;
  1243. for (let i = 0; i < properties.length; i++) {
  1244. const { key, value } = properties[i];
  1245. const keyType = getConstantType(key, context);
  1246. if (keyType === 0) {
  1247. return keyType;
  1248. }
  1249. if (keyType < returnType) {
  1250. returnType = keyType;
  1251. }
  1252. let valueType;
  1253. if (value.type === 4) {
  1254. valueType = getConstantType(value, context);
  1255. } else if (value.type === 14) {
  1256. valueType = getConstantTypeOfHelperCall(value, context);
  1257. } else {
  1258. valueType = 0;
  1259. }
  1260. if (valueType === 0) {
  1261. return valueType;
  1262. }
  1263. if (valueType < returnType) {
  1264. returnType = valueType;
  1265. }
  1266. }
  1267. }
  1268. return returnType;
  1269. }
  1270. function getNodeProps(node) {
  1271. const codegenNode = node.codegenNode;
  1272. if (codegenNode.type === 13) {
  1273. return codegenNode.props;
  1274. }
  1275. }
  1276. function getPatchFlag(node) {
  1277. const flag = node.patchFlag;
  1278. return flag ? parseInt(flag, 10) : void 0;
  1279. }
  1280. function createTransformContext(root, {
  1281. filename = "",
  1282. prefixIdentifiers = false,
  1283. hoistStatic: hoistStatic2 = false,
  1284. hmr = false,
  1285. cacheHandlers = false,
  1286. nodeTransforms = [],
  1287. directiveTransforms = {},
  1288. transformHoist = null,
  1289. isBuiltInComponent = NOOP,
  1290. isCustomElement = NOOP,
  1291. expressionPlugins = [],
  1292. scopeId = null,
  1293. slotted = true,
  1294. ssr = false,
  1295. inSSR = false,
  1296. ssrCssVars = ``,
  1297. bindingMetadata = EMPTY_OBJ,
  1298. inline = false,
  1299. isTS = false,
  1300. onError = defaultOnError,
  1301. onWarn = defaultOnWarn,
  1302. compatConfig
  1303. }) {
  1304. const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
  1305. const context = {
  1306. // options
  1307. filename,
  1308. selfName: nameMatch && capitalize(camelize(nameMatch[1])),
  1309. prefixIdentifiers,
  1310. hoistStatic: hoistStatic2,
  1311. hmr,
  1312. cacheHandlers,
  1313. nodeTransforms,
  1314. directiveTransforms,
  1315. transformHoist,
  1316. isBuiltInComponent,
  1317. isCustomElement,
  1318. expressionPlugins,
  1319. scopeId,
  1320. slotted,
  1321. ssr,
  1322. inSSR,
  1323. ssrCssVars,
  1324. bindingMetadata,
  1325. inline,
  1326. isTS,
  1327. onError,
  1328. onWarn,
  1329. compatConfig,
  1330. // state
  1331. root,
  1332. helpers: /* @__PURE__ */ new Map(),
  1333. components: /* @__PURE__ */ new Set(),
  1334. directives: /* @__PURE__ */ new Set(),
  1335. hoists: [],
  1336. imports: [],
  1337. constantCache: /* @__PURE__ */ new WeakMap(),
  1338. temps: 0,
  1339. cached: 0,
  1340. identifiers: /* @__PURE__ */ Object.create(null),
  1341. scopes: {
  1342. vFor: 0,
  1343. vSlot: 0,
  1344. vPre: 0,
  1345. vOnce: 0
  1346. },
  1347. parent: null,
  1348. grandParent: null,
  1349. currentNode: root,
  1350. childIndex: 0,
  1351. inVOnce: false,
  1352. // methods
  1353. helper(name) {
  1354. const count = context.helpers.get(name) || 0;
  1355. context.helpers.set(name, count + 1);
  1356. return name;
  1357. },
  1358. removeHelper(name) {
  1359. const count = context.helpers.get(name);
  1360. if (count) {
  1361. const currentCount = count - 1;
  1362. if (!currentCount) {
  1363. context.helpers.delete(name);
  1364. } else {
  1365. context.helpers.set(name, currentCount);
  1366. }
  1367. }
  1368. },
  1369. helperString(name) {
  1370. return `_${helperNameMap[context.helper(name)]}`;
  1371. },
  1372. replaceNode(node) {
  1373. if (true) {
  1374. if (!context.currentNode) {
  1375. throw new Error(`Node being replaced is already removed.`);
  1376. }
  1377. if (!context.parent) {
  1378. throw new Error(`Cannot replace root node.`);
  1379. }
  1380. }
  1381. context.parent.children[context.childIndex] = context.currentNode = node;
  1382. },
  1383. removeNode(node) {
  1384. if (!context.parent) {
  1385. throw new Error(`Cannot remove root node.`);
  1386. }
  1387. const list = context.parent.children;
  1388. const removalIndex = node ? list.indexOf(node) : context.currentNode ? context.childIndex : -1;
  1389. if (removalIndex < 0) {
  1390. throw new Error(`node being removed is not a child of current parent`);
  1391. }
  1392. if (!node || node === context.currentNode) {
  1393. context.currentNode = null;
  1394. context.onNodeRemoved();
  1395. } else {
  1396. if (context.childIndex > removalIndex) {
  1397. context.childIndex--;
  1398. context.onNodeRemoved();
  1399. }
  1400. }
  1401. context.parent.children.splice(removalIndex, 1);
  1402. },
  1403. onNodeRemoved: NOOP,
  1404. addIdentifiers(exp) {
  1405. },
  1406. removeIdentifiers(exp) {
  1407. },
  1408. hoist(exp) {
  1409. if (isString(exp))
  1410. exp = createSimpleExpression(exp);
  1411. context.hoists.push(exp);
  1412. const identifier = createSimpleExpression(
  1413. `_hoisted_${context.hoists.length}`,
  1414. false,
  1415. exp.loc,
  1416. 2
  1417. );
  1418. identifier.hoisted = exp;
  1419. return identifier;
  1420. },
  1421. cache(exp, isVNode = false) {
  1422. return createCacheExpression(context.cached++, exp, isVNode);
  1423. }
  1424. };
  1425. {
  1426. context.filters = /* @__PURE__ */ new Set();
  1427. }
  1428. return context;
  1429. }
  1430. function transform(root, options) {
  1431. const context = createTransformContext(root, options);
  1432. traverseNode(root, context);
  1433. if (options.hoistStatic) {
  1434. hoistStatic(root, context);
  1435. }
  1436. if (!options.ssr) {
  1437. createRootCodegen(root, context);
  1438. }
  1439. root.helpers = /* @__PURE__ */ new Set([...context.helpers.keys()]);
  1440. root.components = [...context.components];
  1441. root.directives = [...context.directives];
  1442. root.imports = context.imports;
  1443. root.hoists = context.hoists;
  1444. root.temps = context.temps;
  1445. root.cached = context.cached;
  1446. root.transformed = true;
  1447. {
  1448. root.filters = [...context.filters];
  1449. }
  1450. }
  1451. function createRootCodegen(root, context) {
  1452. const { helper } = context;
  1453. const { children } = root;
  1454. if (children.length === 1) {
  1455. const child = children[0];
  1456. if (isSingleElementRoot(root, child) && child.codegenNode) {
  1457. const codegenNode = child.codegenNode;
  1458. if (codegenNode.type === 13) {
  1459. convertToBlock(codegenNode, context);
  1460. }
  1461. root.codegenNode = codegenNode;
  1462. } else {
  1463. root.codegenNode = child;
  1464. }
  1465. } else if (children.length > 1) {
  1466. let patchFlag = 64;
  1467. let patchFlagText = PatchFlagNames[64];
  1468. if (children.filter((c) => c.type !== 3).length === 1) {
  1469. patchFlag |= 2048;
  1470. patchFlagText += `, ${PatchFlagNames[2048]}`;
  1471. }
  1472. root.codegenNode = createVNodeCall(
  1473. context,
  1474. helper(FRAGMENT),
  1475. void 0,
  1476. root.children,
  1477. patchFlag + (true ? ` /* ${patchFlagText} */` : ``),
  1478. void 0,
  1479. void 0,
  1480. true,
  1481. void 0,
  1482. false
  1483. );
  1484. } else
  1485. ;
  1486. }
  1487. function traverseChildren(parent, context) {
  1488. let i = 0;
  1489. const nodeRemoved = () => {
  1490. i--;
  1491. };
  1492. for (; i < parent.children.length; i++) {
  1493. const child = parent.children[i];
  1494. if (isString(child))
  1495. continue;
  1496. context.grandParent = context.parent;
  1497. context.parent = parent;
  1498. context.childIndex = i;
  1499. context.onNodeRemoved = nodeRemoved;
  1500. traverseNode(child, context);
  1501. }
  1502. }
  1503. function traverseNode(node, context) {
  1504. context.currentNode = node;
  1505. const { nodeTransforms } = context;
  1506. const exitFns = [];
  1507. for (let i2 = 0; i2 < nodeTransforms.length; i2++) {
  1508. const onExit = nodeTransforms[i2](node, context);
  1509. if (onExit) {
  1510. if (isArray(onExit)) {
  1511. exitFns.push(...onExit);
  1512. } else {
  1513. exitFns.push(onExit);
  1514. }
  1515. }
  1516. if (!context.currentNode) {
  1517. return;
  1518. } else {
  1519. node = context.currentNode;
  1520. }
  1521. }
  1522. switch (node.type) {
  1523. case 3:
  1524. if (!context.ssr) {
  1525. context.helper(CREATE_COMMENT);
  1526. }
  1527. break;
  1528. case 5:
  1529. if (!context.ssr) {
  1530. context.helper(TO_DISPLAY_STRING);
  1531. }
  1532. break;
  1533. case 9:
  1534. for (let i2 = 0; i2 < node.branches.length; i2++) {
  1535. traverseNode(node.branches[i2], context);
  1536. }
  1537. break;
  1538. case 10:
  1539. case 11:
  1540. case 1:
  1541. case 0:
  1542. traverseChildren(node, context);
  1543. break;
  1544. }
  1545. context.currentNode = node;
  1546. let i = exitFns.length;
  1547. while (i--) {
  1548. exitFns[i]();
  1549. }
  1550. }
  1551. function createStructuralDirectiveTransform(name, fn) {
  1552. const matches = isString(name) ? (n) => n === name : (n) => name.test(n);
  1553. return (node, context) => {
  1554. if (node.type === 1) {
  1555. const { props } = node;
  1556. if (node.tagType === 3 && props.some(isVSlot)) {
  1557. return;
  1558. }
  1559. const exitFns = [];
  1560. for (let i = 0; i < props.length; i++) {
  1561. const prop = props[i];
  1562. if (prop.type === 7 && matches(prop.name)) {
  1563. props.splice(i, 1);
  1564. i--;
  1565. const onExit = fn(node, prop, context);
  1566. if (onExit)
  1567. exitFns.push(onExit);
  1568. }
  1569. }
  1570. return exitFns;
  1571. }
  1572. };
  1573. }
  1574. function createCodegenContext(ast, {
  1575. mode = "function",
  1576. prefixIdentifiers = mode === "module",
  1577. sourceMap = false,
  1578. filename = `template.vue.html`,
  1579. scopeId = null,
  1580. optimizeImports = false,
  1581. runtimeGlobalName = `Vue`,
  1582. runtimeModuleName = `vue`,
  1583. ssrRuntimeModuleName = "vue/server-renderer",
  1584. ssr = false,
  1585. isTS = false,
  1586. inSSR = false
  1587. }) {
  1588. const context = {
  1589. mode,
  1590. prefixIdentifiers,
  1591. sourceMap,
  1592. filename,
  1593. scopeId,
  1594. optimizeImports,
  1595. runtimeGlobalName,
  1596. runtimeModuleName,
  1597. ssrRuntimeModuleName,
  1598. ssr,
  1599. isTS,
  1600. inSSR,
  1601. source: ast.source,
  1602. code: ``,
  1603. column: 1,
  1604. line: 1,
  1605. offset: 0,
  1606. indentLevel: 0,
  1607. pure: false,
  1608. map: void 0,
  1609. helper(key) {
  1610. return `_${helperNameMap[key]}`;
  1611. },
  1612. push(code, newlineIndex = -2, node) {
  1613. context.code += code;
  1614. },
  1615. indent() {
  1616. newline(++context.indentLevel);
  1617. },
  1618. deindent(withoutNewLine = false) {
  1619. if (withoutNewLine) {
  1620. --context.indentLevel;
  1621. } else {
  1622. newline(--context.indentLevel);
  1623. }
  1624. },
  1625. newline() {
  1626. newline(context.indentLevel);
  1627. }
  1628. };
  1629. function newline(n) {
  1630. context.push(
  1631. "\n" + ` `.repeat(n),
  1632. 0
  1633. /* Start */
  1634. );
  1635. }
  1636. return context;
  1637. }
  1638. function generate(ast, options = {}) {
  1639. const context = createCodegenContext(ast, options);
  1640. if (options.onContextCreated)
  1641. options.onContextCreated(context);
  1642. const {
  1643. mode,
  1644. push,
  1645. prefixIdentifiers,
  1646. indent,
  1647. deindent,
  1648. newline,
  1649. scopeId,
  1650. ssr
  1651. } = context;
  1652. const helpers = Array.from(ast.helpers);
  1653. const hasHelpers = helpers.length > 0;
  1654. const useWithBlock = !prefixIdentifiers && mode !== "module";
  1655. const preambleContext = context;
  1656. {
  1657. genFunctionPreamble(ast, preambleContext);
  1658. }
  1659. const functionName = ssr ? `ssrRender` : `render`;
  1660. const args = ssr ? ["_ctx", "_push", "_parent", "_attrs"] : ["_ctx", "_cache"];
  1661. const signature = args.join(", ");
  1662. {
  1663. push(`function ${functionName}(${signature}) {`);
  1664. }
  1665. indent();
  1666. if (useWithBlock) {
  1667. push(`with (_ctx) {`);
  1668. indent();
  1669. if (hasHelpers) {
  1670. push(
  1671. `const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
  1672. `,
  1673. -1
  1674. /* End */
  1675. );
  1676. newline();
  1677. }
  1678. }
  1679. if (ast.components.length) {
  1680. genAssets(ast.components, "component", context);
  1681. if (ast.directives.length || ast.temps > 0) {
  1682. newline();
  1683. }
  1684. }
  1685. if (ast.directives.length) {
  1686. genAssets(ast.directives, "directive", context);
  1687. if (ast.temps > 0) {
  1688. newline();
  1689. }
  1690. }
  1691. if (ast.filters && ast.filters.length) {
  1692. newline();
  1693. genAssets(ast.filters, "filter", context);
  1694. newline();
  1695. }
  1696. if (ast.temps > 0) {
  1697. push(`let `);
  1698. for (let i = 0; i < ast.temps; i++) {
  1699. push(`${i > 0 ? `, ` : ``}_temp${i}`);
  1700. }
  1701. }
  1702. if (ast.components.length || ast.directives.length || ast.temps) {
  1703. push(
  1704. `
  1705. `,
  1706. 0
  1707. /* Start */
  1708. );
  1709. newline();
  1710. }
  1711. if (!ssr) {
  1712. push(`return `);
  1713. }
  1714. if (ast.codegenNode) {
  1715. genNode(ast.codegenNode, context);
  1716. } else {
  1717. push(`null`);
  1718. }
  1719. if (useWithBlock) {
  1720. deindent();
  1721. push(`}`);
  1722. }
  1723. deindent();
  1724. push(`}`);
  1725. return {
  1726. ast,
  1727. code: context.code,
  1728. preamble: ``,
  1729. map: context.map ? context.map.toJSON() : void 0
  1730. };
  1731. }
  1732. function genFunctionPreamble(ast, context) {
  1733. const {
  1734. ssr,
  1735. prefixIdentifiers,
  1736. push,
  1737. newline,
  1738. runtimeModuleName,
  1739. runtimeGlobalName,
  1740. ssrRuntimeModuleName
  1741. } = context;
  1742. const VueBinding = runtimeGlobalName;
  1743. const helpers = Array.from(ast.helpers);
  1744. if (helpers.length > 0) {
  1745. {
  1746. push(
  1747. `const _Vue = ${VueBinding}
  1748. `,
  1749. -1
  1750. /* End */
  1751. );
  1752. if (ast.hoists.length) {
  1753. const staticHelpers = [
  1754. CREATE_VNODE,
  1755. CREATE_ELEMENT_VNODE,
  1756. CREATE_COMMENT,
  1757. CREATE_TEXT,
  1758. CREATE_STATIC
  1759. ].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
  1760. push(
  1761. `const { ${staticHelpers} } = _Vue
  1762. `,
  1763. -1
  1764. /* End */
  1765. );
  1766. }
  1767. }
  1768. }
  1769. genHoists(ast.hoists, context);
  1770. newline();
  1771. push(`return `);
  1772. }
  1773. function genAssets(assets, type, { helper, push, newline, isTS }) {
  1774. const resolver = helper(
  1775. type === "filter" ? RESOLVE_FILTER : type === "component" ? RESOLVE_COMPONENT : RESOLVE_DIRECTIVE
  1776. );
  1777. for (let i = 0; i < assets.length; i++) {
  1778. let id = assets[i];
  1779. const maybeSelfReference = id.endsWith("__self");
  1780. if (maybeSelfReference) {
  1781. id = id.slice(0, -6);
  1782. }
  1783. push(
  1784. `const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${maybeSelfReference ? `, true` : ``})${isTS ? `!` : ``}`
  1785. );
  1786. if (i < assets.length - 1) {
  1787. newline();
  1788. }
  1789. }
  1790. }
  1791. function genHoists(hoists, context) {
  1792. if (!hoists.length) {
  1793. return;
  1794. }
  1795. context.pure = true;
  1796. const { push, newline, helper, scopeId, mode } = context;
  1797. newline();
  1798. for (let i = 0; i < hoists.length; i++) {
  1799. const exp = hoists[i];
  1800. if (exp) {
  1801. push(
  1802. `const _hoisted_${i + 1} = ${``}`
  1803. );
  1804. genNode(exp, context);
  1805. newline();
  1806. }
  1807. }
  1808. context.pure = false;
  1809. }
  1810. function isText(n) {
  1811. return isString(n) || n.type === 4 || n.type === 2 || n.type === 5 || n.type === 8;
  1812. }
  1813. function genNodeListAsArray(nodes, context) {
  1814. const multilines = nodes.length > 3 || nodes.some((n) => isArray(n) || !isText(n));
  1815. context.push(`[`);
  1816. multilines && context.indent();
  1817. genNodeList(nodes, context, multilines);
  1818. multilines && context.deindent();
  1819. context.push(`]`);
  1820. }
  1821. function genNodeList(nodes, context, multilines = false, comma = true) {
  1822. const { push, newline } = context;
  1823. for (let i = 0; i < nodes.length; i++) {
  1824. const node = nodes[i];
  1825. if (isString(node)) {
  1826. push(
  1827. node,
  1828. -3
  1829. /* Unknown */
  1830. );
  1831. } else if (isArray(node)) {
  1832. genNodeListAsArray(node, context);
  1833. } else {
  1834. genNode(node, context);
  1835. }
  1836. if (i < nodes.length - 1) {
  1837. if (multilines) {
  1838. comma && push(",");
  1839. newline();
  1840. } else {
  1841. comma && push(", ");
  1842. }
  1843. }
  1844. }
  1845. }
  1846. function genNode(node, context) {
  1847. if (isString(node)) {
  1848. context.push(
  1849. node,
  1850. -3
  1851. /* Unknown */
  1852. );
  1853. return;
  1854. }
  1855. if (isSymbol(node)) {
  1856. context.push(context.helper(node));
  1857. return;
  1858. }
  1859. switch (node.type) {
  1860. case 1:
  1861. case 9:
  1862. case 11:
  1863. assert(
  1864. node.codegenNode != null,
  1865. `Codegen node is missing for element/if/for node. Apply appropriate transforms first.`
  1866. );
  1867. genNode(node.codegenNode, context);
  1868. break;
  1869. case 2:
  1870. genText(node, context);
  1871. break;
  1872. case 4:
  1873. genExpression(node, context);
  1874. break;
  1875. case 5:
  1876. genInterpolation(node, context);
  1877. break;
  1878. case 12:
  1879. genNode(node.codegenNode, context);
  1880. break;
  1881. case 8:
  1882. genCompoundExpression(node, context);
  1883. break;
  1884. case 3:
  1885. genComment(node, context);
  1886. break;
  1887. case 13:
  1888. genVNodeCall(node, context);
  1889. break;
  1890. case 14:
  1891. genCallExpression(node, context);
  1892. break;
  1893. case 15:
  1894. genObjectExpression(node, context);
  1895. break;
  1896. case 17:
  1897. genArrayExpression(node, context);
  1898. break;
  1899. case 18:
  1900. genFunctionExpression(node, context);
  1901. break;
  1902. case 19:
  1903. genConditionalExpression(node, context);
  1904. break;
  1905. case 20:
  1906. genCacheExpression(node, context);
  1907. break;
  1908. case 21:
  1909. genNodeList(node.body, context, true, false);
  1910. break;
  1911. case 22:
  1912. break;
  1913. case 23:
  1914. break;
  1915. case 24:
  1916. break;
  1917. case 25:
  1918. break;
  1919. case 26:
  1920. break;
  1921. case 10:
  1922. break;
  1923. default:
  1924. if (true) {
  1925. assert(false, `unhandled codegen node type: ${node.type}`);
  1926. const exhaustiveCheck = node;
  1927. return exhaustiveCheck;
  1928. }
  1929. }
  1930. }
  1931. function genText(node, context) {
  1932. context.push(JSON.stringify(node.content), -3, node);
  1933. }
  1934. function genExpression(node, context) {
  1935. const { content, isStatic } = node;
  1936. context.push(
  1937. isStatic ? JSON.stringify(content) : content,
  1938. -3,
  1939. node
  1940. );
  1941. }
  1942. function genInterpolation(node, context) {
  1943. const { push, helper, pure } = context;
  1944. if (pure)
  1945. push(PURE_ANNOTATION);
  1946. push(`${helper(TO_DISPLAY_STRING)}(`);
  1947. genNode(node.content, context);
  1948. push(`)`);
  1949. }
  1950. function genCompoundExpression(node, context) {
  1951. for (let i = 0; i < node.children.length; i++) {
  1952. const child = node.children[i];
  1953. if (isString(child)) {
  1954. context.push(
  1955. child,
  1956. -3
  1957. /* Unknown */
  1958. );
  1959. } else {
  1960. genNode(child, context);
  1961. }
  1962. }
  1963. }
  1964. function genExpressionAsPropertyKey(node, context) {
  1965. const { push } = context;
  1966. if (node.type === 8) {
  1967. push(`[`);
  1968. genCompoundExpression(node, context);
  1969. push(`]`);
  1970. } else if (node.isStatic) {
  1971. const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
  1972. push(text, -2, node);
  1973. } else {
  1974. push(`[${node.content}]`, -3, node);
  1975. }
  1976. }
  1977. function genComment(node, context) {
  1978. const { push, helper, pure } = context;
  1979. if (pure) {
  1980. push(PURE_ANNOTATION);
  1981. }
  1982. push(
  1983. `${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
  1984. -3,
  1985. node
  1986. );
  1987. }
  1988. function genVNodeCall(node, context) {
  1989. const { push, helper, pure } = context;
  1990. const {
  1991. tag,
  1992. props,
  1993. children,
  1994. patchFlag,
  1995. dynamicProps,
  1996. directives,
  1997. isBlock,
  1998. disableTracking,
  1999. isComponent: isComponent2
  2000. } = node;
  2001. if (directives) {
  2002. push(helper(WITH_DIRECTIVES) + `(`);
  2003. }
  2004. if (isBlock) {
  2005. push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
  2006. }
  2007. if (pure) {
  2008. push(PURE_ANNOTATION);
  2009. }
  2010. const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent2) : getVNodeHelper(context.inSSR, isComponent2);
  2011. push(helper(callHelper) + `(`, -2, node);
  2012. genNodeList(
  2013. genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
  2014. context
  2015. );
  2016. push(`)`);
  2017. if (isBlock) {
  2018. push(`)`);
  2019. }
  2020. if (directives) {
  2021. push(`, `);
  2022. genNode(directives, context);
  2023. push(`)`);
  2024. }
  2025. }
  2026. function genNullableArgs(args) {
  2027. let i = args.length;
  2028. while (i--) {
  2029. if (args[i] != null)
  2030. break;
  2031. }
  2032. return args.slice(0, i + 1).map((arg) => arg || `null`);
  2033. }
  2034. function genCallExpression(node, context) {
  2035. const { push, helper, pure } = context;
  2036. const callee = isString(node.callee) ? node.callee : helper(node.callee);
  2037. if (pure) {
  2038. push(PURE_ANNOTATION);
  2039. }
  2040. push(callee + `(`, -2, node);
  2041. genNodeList(node.arguments, context);
  2042. push(`)`);
  2043. }
  2044. function genObjectExpression(node, context) {
  2045. const { push, indent, deindent, newline } = context;
  2046. const { properties } = node;
  2047. if (!properties.length) {
  2048. push(`{}`, -2, node);
  2049. return;
  2050. }
  2051. const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
  2052. push(multilines ? `{` : `{ `);
  2053. multilines && indent();
  2054. for (let i = 0; i < properties.length; i++) {
  2055. const { key, value } = properties[i];
  2056. genExpressionAsPropertyKey(key, context);
  2057. push(`: `);
  2058. genNode(value, context);
  2059. if (i < properties.length - 1) {
  2060. push(`,`);
  2061. newline();
  2062. }
  2063. }
  2064. multilines && deindent();
  2065. push(multilines ? `}` : ` }`);
  2066. }
  2067. function genArrayExpression(node, context) {
  2068. genNodeListAsArray(node.elements, context);
  2069. }
  2070. function genFunctionExpression(node, context) {
  2071. const { push, indent, deindent } = context;
  2072. const { params, returns, body, newline, isSlot } = node;
  2073. if (isSlot) {
  2074. push(`_${helperNameMap[WITH_CTX]}(`);
  2075. }
  2076. push(`(`, -2, node);
  2077. if (isArray(params)) {
  2078. genNodeList(params, context);
  2079. } else if (params) {
  2080. genNode(params, context);
  2081. }
  2082. push(`) => `);
  2083. if (newline || body) {
  2084. push(`{`);
  2085. indent();
  2086. }
  2087. if (returns) {
  2088. if (newline) {
  2089. push(`return `);
  2090. }
  2091. if (isArray(returns)) {
  2092. genNodeListAsArray(returns, context);
  2093. } else {
  2094. genNode(returns, context);
  2095. }
  2096. } else if (body) {
  2097. genNode(body, context);
  2098. }
  2099. if (newline || body) {
  2100. deindent();
  2101. push(`}`);
  2102. }
  2103. if (isSlot) {
  2104. if (node.isNonScopedSlot) {
  2105. push(`, undefined, true`);
  2106. }
  2107. push(`)`);
  2108. }
  2109. }
  2110. function genConditionalExpression(node, context) {
  2111. const { test, consequent, alternate, newline: needNewline } = node;
  2112. const { push, indent, deindent, newline } = context;
  2113. if (test.type === 4) {
  2114. const needsParens = !isSimpleIdentifier(test.content);
  2115. needsParens && push(`(`);
  2116. genExpression(test, context);
  2117. needsParens && push(`)`);
  2118. } else {
  2119. push(`(`);
  2120. genNode(test, context);
  2121. push(`)`);
  2122. }
  2123. needNewline && indent();
  2124. context.indentLevel++;
  2125. needNewline || push(` `);
  2126. push(`? `);
  2127. genNode(consequent, context);
  2128. context.indentLevel--;
  2129. needNewline && newline();
  2130. needNewline || push(` `);
  2131. push(`: `);
  2132. const isNested = alternate.type === 19;
  2133. if (!isNested) {
  2134. context.indentLevel++;
  2135. }
  2136. genNode(alternate, context);
  2137. if (!isNested) {
  2138. context.indentLevel--;
  2139. }
  2140. needNewline && deindent(
  2141. true
  2142. /* without newline */
  2143. );
  2144. }
  2145. function genCacheExpression(node, context) {
  2146. const { push, helper, indent, deindent, newline } = context;
  2147. push(`_cache[${node.index}] || (`);
  2148. if (node.isVNode) {
  2149. indent();
  2150. push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
  2151. newline();
  2152. }
  2153. push(`_cache[${node.index}] = `);
  2154. genNode(node.value, context);
  2155. if (node.isVNode) {
  2156. push(`,`);
  2157. newline();
  2158. push(`${helper(SET_BLOCK_TRACKING)}(1),`);
  2159. newline();
  2160. push(`_cache[${node.index}]`);
  2161. deindent();
  2162. }
  2163. push(`)`);
  2164. }
  2165. function validateBrowserExpression(node, context, asParams = false, asRawStatements = false) {
  2166. const exp = node.content;
  2167. if (!exp.trim()) {
  2168. return;
  2169. }
  2170. try {
  2171. new Function(
  2172. asRawStatements ? ` ${exp} ` : `return ${asParams ? `(${exp}) => {}` : `(${exp})`}`
  2173. );
  2174. } catch (e) {
  2175. let message = e.message;
  2176. const keywordMatch = exp.replace(stripStringRE, "").match(prohibitedKeywordRE);
  2177. if (keywordMatch) {
  2178. message = `avoid using JavaScript keyword as property name: "${keywordMatch[0]}"`;
  2179. }
  2180. context.onError(
  2181. createCompilerError(
  2182. 45,
  2183. node.loc,
  2184. void 0,
  2185. message
  2186. )
  2187. );
  2188. }
  2189. }
  2190. function processExpression(node, context, asParams = false, asRawStatements = false, localVars = Object.create(context.identifiers)) {
  2191. {
  2192. if (true) {
  2193. validateBrowserExpression(node, context, asParams, asRawStatements);
  2194. }
  2195. return node;
  2196. }
  2197. }
  2198. function stringifyExpression(exp) {
  2199. if (isString(exp)) {
  2200. return exp;
  2201. } else if (exp.type === 4) {
  2202. return exp.content;
  2203. } else {
  2204. return exp.children.map(stringifyExpression).join("");
  2205. }
  2206. }
  2207. function processIf(node, dir, context, processCodegen) {
  2208. if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
  2209. const loc = dir.exp ? dir.exp.loc : node.loc;
  2210. context.onError(
  2211. createCompilerError(28, dir.loc)
  2212. );
  2213. dir.exp = createSimpleExpression(`true`, false, loc);
  2214. }
  2215. if (dir.exp) {
  2216. validateBrowserExpression(dir.exp, context);
  2217. }
  2218. if (dir.name === "if") {
  2219. const branch = createIfBranch(node, dir);
  2220. const ifNode = {
  2221. type: 9,
  2222. loc: node.loc,
  2223. branches: [branch]
  2224. };
  2225. context.replaceNode(ifNode);
  2226. if (processCodegen) {
  2227. return processCodegen(ifNode, branch, true);
  2228. }
  2229. } else {
  2230. const siblings = context.parent.children;
  2231. const comments = [];
  2232. let i = siblings.indexOf(node);
  2233. while (i-- >= -1) {
  2234. const sibling = siblings[i];
  2235. if (sibling && sibling.type === 3) {
  2236. context.removeNode(sibling);
  2237. comments.unshift(sibling);
  2238. continue;
  2239. }
  2240. if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
  2241. context.removeNode(sibling);
  2242. continue;
  2243. }
  2244. if (sibling && sibling.type === 9) {
  2245. if (dir.name === "else-if" && sibling.branches[sibling.branches.length - 1].condition === void 0) {
  2246. context.onError(
  2247. createCompilerError(30, node.loc)
  2248. );
  2249. }
  2250. context.removeNode();
  2251. const branch = createIfBranch(node, dir);
  2252. if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
  2253. !(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
  2254. branch.children = [...comments, ...branch.children];
  2255. }
  2256. if (true) {
  2257. const key = branch.userKey;
  2258. if (key) {
  2259. sibling.branches.forEach(({ userKey }) => {
  2260. if (isSameKey(userKey, key)) {
  2261. context.onError(
  2262. createCompilerError(
  2263. 29,
  2264. branch.userKey.loc
  2265. )
  2266. );
  2267. }
  2268. });
  2269. }
  2270. }
  2271. sibling.branches.push(branch);
  2272. const onExit = processCodegen && processCodegen(sibling, branch, false);
  2273. traverseNode(branch, context);
  2274. if (onExit)
  2275. onExit();
  2276. context.currentNode = null;
  2277. } else {
  2278. context.onError(
  2279. createCompilerError(30, node.loc)
  2280. );
  2281. }
  2282. break;
  2283. }
  2284. }
  2285. }
  2286. function createIfBranch(node, dir) {
  2287. const isTemplateIf = node.tagType === 3;
  2288. return {
  2289. type: 10,
  2290. loc: node.loc,
  2291. condition: dir.name === "else" ? void 0 : dir.exp,
  2292. children: isTemplateIf && !findDir(node, "for") ? node.children : [node],
  2293. userKey: findProp(node, `key`),
  2294. isTemplateIf
  2295. };
  2296. }
  2297. function createCodegenNodeForBranch(branch, keyIndex, context) {
  2298. if (branch.condition) {
  2299. return createConditionalExpression(
  2300. branch.condition,
  2301. createChildrenCodegenNode(branch, keyIndex, context),
  2302. // make sure to pass in asBlock: true so that the comment node call
  2303. // closes the current block.
  2304. createCallExpression(context.helper(CREATE_COMMENT), [
  2305. true ? '"v-if"' : '""',
  2306. "true"
  2307. ])
  2308. );
  2309. } else {
  2310. return createChildrenCodegenNode(branch, keyIndex, context);
  2311. }
  2312. }
  2313. function createChildrenCodegenNode(branch, keyIndex, context) {
  2314. const { helper } = context;
  2315. const keyProperty = createObjectProperty(
  2316. `key`,
  2317. createSimpleExpression(
  2318. `${keyIndex}`,
  2319. false,
  2320. locStub,
  2321. 2
  2322. )
  2323. );
  2324. const { children } = branch;
  2325. const firstChild = children[0];
  2326. const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1;
  2327. if (needFragmentWrapper) {
  2328. if (children.length === 1 && firstChild.type === 11) {
  2329. const vnodeCall = firstChild.codegenNode;
  2330. injectProp(vnodeCall, keyProperty, context);
  2331. return vnodeCall;
  2332. } else {
  2333. let patchFlag = 64;
  2334. let patchFlagText = PatchFlagNames[64];
  2335. if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) {
  2336. patchFlag |= 2048;
  2337. patchFlagText += `, ${PatchFlagNames[2048]}`;
  2338. }
  2339. return createVNodeCall(
  2340. context,
  2341. helper(FRAGMENT),
  2342. createObjectExpression([keyProperty]),
  2343. children,
  2344. patchFlag + (true ? ` /* ${patchFlagText} */` : ``),
  2345. void 0,
  2346. void 0,
  2347. true,
  2348. false,
  2349. false,
  2350. branch.loc
  2351. );
  2352. }
  2353. } else {
  2354. const ret = firstChild.codegenNode;
  2355. const vnodeCall = getMemoedVNodeCall(ret);
  2356. if (vnodeCall.type === 13) {
  2357. convertToBlock(vnodeCall, context);
  2358. }
  2359. injectProp(vnodeCall, keyProperty, context);
  2360. return ret;
  2361. }
  2362. }
  2363. function isSameKey(a, b) {
  2364. if (!a || a.type !== b.type) {
  2365. return false;
  2366. }
  2367. if (a.type === 6) {
  2368. if (a.value.content !== b.value.content) {
  2369. return false;
  2370. }
  2371. } else {
  2372. const exp = a.exp;
  2373. const branchExp = b.exp;
  2374. if (exp.type !== branchExp.type) {
  2375. return false;
  2376. }
  2377. if (exp.type !== 4 || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) {
  2378. return false;
  2379. }
  2380. }
  2381. return true;
  2382. }
  2383. function getParentCondition(node) {
  2384. while (true) {
  2385. if (node.type === 19) {
  2386. if (node.alternate.type === 19) {
  2387. node = node.alternate;
  2388. } else {
  2389. return node;
  2390. }
  2391. } else if (node.type === 20) {
  2392. node = node.value;
  2393. }
  2394. }
  2395. }
  2396. function processFor(node, dir, context, processCodegen) {
  2397. if (!dir.exp) {
  2398. context.onError(
  2399. createCompilerError(31, dir.loc)
  2400. );
  2401. return;
  2402. }
  2403. const parseResult = dir.forParseResult;
  2404. if (!parseResult) {
  2405. context.onError(
  2406. createCompilerError(32, dir.loc)
  2407. );
  2408. return;
  2409. }
  2410. finalizeForParseResult(parseResult, context);
  2411. const { addIdentifiers, removeIdentifiers, scopes } = context;
  2412. const { source, value, key, index } = parseResult;
  2413. const forNode = {
  2414. type: 11,
  2415. loc: dir.loc,
  2416. source,
  2417. valueAlias: value,
  2418. keyAlias: key,
  2419. objectIndexAlias: index,
  2420. parseResult,
  2421. children: isTemplateNode(node) ? node.children : [node]
  2422. };
  2423. context.replaceNode(forNode);
  2424. scopes.vFor++;
  2425. const onExit = processCodegen && processCodegen(forNode);
  2426. return () => {
  2427. scopes.vFor--;
  2428. if (onExit)
  2429. onExit();
  2430. };
  2431. }
  2432. function finalizeForParseResult(result, context) {
  2433. if (result.finalized)
  2434. return;
  2435. if (true) {
  2436. validateBrowserExpression(result.source, context);
  2437. if (result.key) {
  2438. validateBrowserExpression(
  2439. result.key,
  2440. context,
  2441. true
  2442. );
  2443. }
  2444. if (result.index) {
  2445. validateBrowserExpression(
  2446. result.index,
  2447. context,
  2448. true
  2449. );
  2450. }
  2451. if (result.value) {
  2452. validateBrowserExpression(
  2453. result.value,
  2454. context,
  2455. true
  2456. );
  2457. }
  2458. }
  2459. result.finalized = true;
  2460. }
  2461. function createForLoopParams({ value, key, index }, memoArgs = []) {
  2462. return createParamsList([value, key, index, ...memoArgs]);
  2463. }
  2464. function createParamsList(args) {
  2465. let i = args.length;
  2466. while (i--) {
  2467. if (args[i])
  2468. break;
  2469. }
  2470. return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
  2471. }
  2472. function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
  2473. context.helper(WITH_CTX);
  2474. const { children, loc } = node;
  2475. const slotsProperties = [];
  2476. const dynamicSlots = [];
  2477. let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
  2478. const onComponentSlot = findDir(node, "slot", true);
  2479. if (onComponentSlot) {
  2480. const { arg, exp } = onComponentSlot;
  2481. if (arg && !isStaticExp(arg)) {
  2482. hasDynamicSlots = true;
  2483. }
  2484. slotsProperties.push(
  2485. createObjectProperty(
  2486. arg || createSimpleExpression("default", true),
  2487. buildSlotFn(exp, void 0, children, loc)
  2488. )
  2489. );
  2490. }
  2491. let hasTemplateSlots = false;
  2492. let hasNamedDefaultSlot = false;
  2493. const implicitDefaultChildren = [];
  2494. const seenSlotNames = /* @__PURE__ */ new Set();
  2495. let conditionalBranchIndex = 0;
  2496. for (let i = 0; i < children.length; i++) {
  2497. const slotElement = children[i];
  2498. let slotDir;
  2499. if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
  2500. if (slotElement.type !== 3) {
  2501. implicitDefaultChildren.push(slotElement);
  2502. }
  2503. continue;
  2504. }
  2505. if (onComponentSlot) {
  2506. context.onError(
  2507. createCompilerError(37, slotDir.loc)
  2508. );
  2509. break;
  2510. }
  2511. hasTemplateSlots = true;
  2512. const { children: slotChildren, loc: slotLoc } = slotElement;
  2513. const {
  2514. arg: slotName = createSimpleExpression(`default`, true),
  2515. exp: slotProps,
  2516. loc: dirLoc
  2517. } = slotDir;
  2518. let staticSlotName;
  2519. if (isStaticExp(slotName)) {
  2520. staticSlotName = slotName ? slotName.content : `default`;
  2521. } else {
  2522. hasDynamicSlots = true;
  2523. }
  2524. const vFor = findDir(slotElement, "for");
  2525. const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
  2526. let vIf;
  2527. let vElse;
  2528. if (vIf = findDir(slotElement, "if")) {
  2529. hasDynamicSlots = true;
  2530. dynamicSlots.push(
  2531. createConditionalExpression(
  2532. vIf.exp,
  2533. buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++),
  2534. defaultFallback
  2535. )
  2536. );
  2537. } else if (vElse = findDir(
  2538. slotElement,
  2539. /^else(-if)?$/,
  2540. true
  2541. /* allowEmpty */
  2542. )) {
  2543. let j = i;
  2544. let prev;
  2545. while (j--) {
  2546. prev = children[j];
  2547. if (prev.type !== 3) {
  2548. break;
  2549. }
  2550. }
  2551. if (prev && isTemplateNode(prev) && findDir(prev, "if")) {
  2552. children.splice(i, 1);
  2553. i--;
  2554. let conditional = dynamicSlots[dynamicSlots.length - 1];
  2555. while (conditional.alternate.type === 19) {
  2556. conditional = conditional.alternate;
  2557. }
  2558. conditional.alternate = vElse.exp ? createConditionalExpression(
  2559. vElse.exp,
  2560. buildDynamicSlot(
  2561. slotName,
  2562. slotFunction,
  2563. conditionalBranchIndex++
  2564. ),
  2565. defaultFallback
  2566. ) : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
  2567. } else {
  2568. context.onError(
  2569. createCompilerError(30, vElse.loc)
  2570. );
  2571. }
  2572. } else if (vFor) {
  2573. hasDynamicSlots = true;
  2574. const parseResult = vFor.forParseResult;
  2575. if (parseResult) {
  2576. finalizeForParseResult(parseResult, context);
  2577. dynamicSlots.push(
  2578. createCallExpression(context.helper(RENDER_LIST), [
  2579. parseResult.source,
  2580. createFunctionExpression(
  2581. createForLoopParams(parseResult),
  2582. buildDynamicSlot(slotName, slotFunction),
  2583. true
  2584. )
  2585. ])
  2586. );
  2587. } else {
  2588. context.onError(
  2589. createCompilerError(
  2590. 32,
  2591. vFor.loc
  2592. )
  2593. );
  2594. }
  2595. } else {
  2596. if (staticSlotName) {
  2597. if (seenSlotNames.has(staticSlotName)) {
  2598. context.onError(
  2599. createCompilerError(
  2600. 38,
  2601. dirLoc
  2602. )
  2603. );
  2604. continue;
  2605. }
  2606. seenSlotNames.add(staticSlotName);
  2607. if (staticSlotName === "default") {
  2608. hasNamedDefaultSlot = true;
  2609. }
  2610. }
  2611. slotsProperties.push(createObjectProperty(slotName, slotFunction));
  2612. }
  2613. }
  2614. if (!onComponentSlot) {
  2615. const buildDefaultSlotProperty = (props, children2) => {
  2616. const fn = buildSlotFn(props, void 0, children2, loc);
  2617. if (context.compatConfig) {
  2618. fn.isNonScopedSlot = true;
  2619. }
  2620. return createObjectProperty(`default`, fn);
  2621. };
  2622. if (!hasTemplateSlots) {
  2623. slotsProperties.push(buildDefaultSlotProperty(void 0, children));
  2624. } else if (implicitDefaultChildren.length && // #3766
  2625. // with whitespace: 'preserve', whitespaces between slots will end up in
  2626. // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
  2627. implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
  2628. if (hasNamedDefaultSlot) {
  2629. context.onError(
  2630. createCompilerError(
  2631. 39,
  2632. implicitDefaultChildren[0].loc
  2633. )
  2634. );
  2635. } else {
  2636. slotsProperties.push(
  2637. buildDefaultSlotProperty(void 0, implicitDefaultChildren)
  2638. );
  2639. }
  2640. }
  2641. }
  2642. const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
  2643. let slots = createObjectExpression(
  2644. slotsProperties.concat(
  2645. createObjectProperty(
  2646. `_`,
  2647. // 2 = compiled but dynamic = can skip normalization, but must run diff
  2648. // 1 = compiled and static = can skip normalization AND diff as optimized
  2649. createSimpleExpression(
  2650. slotFlag + (true ? ` /* ${slotFlagsText[slotFlag]} */` : ``),
  2651. false
  2652. )
  2653. )
  2654. ),
  2655. loc
  2656. );
  2657. if (dynamicSlots.length) {
  2658. slots = createCallExpression(context.helper(CREATE_SLOTS), [
  2659. slots,
  2660. createArrayExpression(dynamicSlots)
  2661. ]);
  2662. }
  2663. return {
  2664. slots,
  2665. hasDynamicSlots
  2666. };
  2667. }
  2668. function buildDynamicSlot(name, fn, index) {
  2669. const props = [
  2670. createObjectProperty(`name`, name),
  2671. createObjectProperty(`fn`, fn)
  2672. ];
  2673. if (index != null) {
  2674. props.push(
  2675. createObjectProperty(`key`, createSimpleExpression(String(index), true))
  2676. );
  2677. }
  2678. return createObjectExpression(props);
  2679. }
  2680. function hasForwardedSlots(children) {
  2681. for (let i = 0; i < children.length; i++) {
  2682. const child = children[i];
  2683. switch (child.type) {
  2684. case 1:
  2685. if (child.tagType === 2 || hasForwardedSlots(child.children)) {
  2686. return true;
  2687. }
  2688. break;
  2689. case 9:
  2690. if (hasForwardedSlots(child.branches))
  2691. return true;
  2692. break;
  2693. case 10:
  2694. case 11:
  2695. if (hasForwardedSlots(child.children))
  2696. return true;
  2697. break;
  2698. }
  2699. }
  2700. return false;
  2701. }
  2702. function isNonWhitespaceContent(node) {
  2703. if (node.type !== 2 && node.type !== 12)
  2704. return true;
  2705. return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
  2706. }
  2707. function resolveComponentType(node, context, ssr = false) {
  2708. let { tag } = node;
  2709. const isExplicitDynamic = isComponentTag(tag);
  2710. const isProp = findProp(
  2711. node,
  2712. "is",
  2713. false,
  2714. true
  2715. /* allow empty */
  2716. );
  2717. if (isProp) {
  2718. if (isExplicitDynamic || isCompatEnabled(
  2719. "COMPILER_IS_ON_ELEMENT",
  2720. context
  2721. )) {
  2722. let exp;
  2723. if (isProp.type === 6) {
  2724. exp = isProp.value && createSimpleExpression(isProp.value.content, true);
  2725. } else {
  2726. exp = isProp.exp;
  2727. if (!exp) {
  2728. exp = createSimpleExpression(`is`, false, isProp.loc);
  2729. }
  2730. }
  2731. if (exp) {
  2732. return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
  2733. exp
  2734. ]);
  2735. }
  2736. } else if (isProp.type === 6 && isProp.value.content.startsWith("vue:")) {
  2737. tag = isProp.value.content.slice(4);
  2738. }
  2739. }
  2740. const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
  2741. if (builtIn) {
  2742. if (!ssr)
  2743. context.helper(builtIn);
  2744. return builtIn;
  2745. }
  2746. context.helper(RESOLVE_COMPONENT);
  2747. context.components.add(tag);
  2748. return toValidAssetId(tag, `component`);
  2749. }
  2750. function buildProps(node, context, props = node.props, isComponent2, isDynamicComponent, ssr = false) {
  2751. const { tag, loc: elementLoc, children } = node;
  2752. let properties = [];
  2753. const mergeArgs = [];
  2754. const runtimeDirectives = [];
  2755. const hasChildren = children.length > 0;
  2756. let shouldUseBlock = false;
  2757. let patchFlag = 0;
  2758. let hasRef = false;
  2759. let hasClassBinding = false;
  2760. let hasStyleBinding = false;
  2761. let hasHydrationEventBinding = false;
  2762. let hasDynamicKeys = false;
  2763. let hasVnodeHook = false;
  2764. const dynamicPropNames = [];
  2765. const pushMergeArg = (arg) => {
  2766. if (properties.length) {
  2767. mergeArgs.push(
  2768. createObjectExpression(dedupeProperties(properties), elementLoc)
  2769. );
  2770. properties = [];
  2771. }
  2772. if (arg)
  2773. mergeArgs.push(arg);
  2774. };
  2775. const pushRefVForMarker = () => {
  2776. if (context.scopes.vFor > 0) {
  2777. properties.push(
  2778. createObjectProperty(
  2779. createSimpleExpression("ref_for", true),
  2780. createSimpleExpression("true")
  2781. )
  2782. );
  2783. }
  2784. };
  2785. const analyzePatchFlag = ({ key, value }) => {
  2786. if (isStaticExp(key)) {
  2787. const name = key.content;
  2788. const isEventHandler = isOn(name);
  2789. if (isEventHandler && (!isComponent2 || isDynamicComponent) && // omit the flag for click handlers because hydration gives click
  2790. // dedicated fast path.
  2791. name.toLowerCase() !== "onclick" && // omit v-model handlers
  2792. name !== "onUpdate:modelValue" && // omit onVnodeXXX hooks
  2793. !isReservedProp(name)) {
  2794. hasHydrationEventBinding = true;
  2795. }
  2796. if (isEventHandler && isReservedProp(name)) {
  2797. hasVnodeHook = true;
  2798. }
  2799. if (isEventHandler && value.type === 14) {
  2800. value = value.arguments[0];
  2801. }
  2802. if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
  2803. return;
  2804. }
  2805. if (name === "ref") {
  2806. hasRef = true;
  2807. } else if (name === "class") {
  2808. hasClassBinding = true;
  2809. } else if (name === "style") {
  2810. hasStyleBinding = true;
  2811. } else if (name !== "key" && !dynamicPropNames.includes(name)) {
  2812. dynamicPropNames.push(name);
  2813. }
  2814. if (isComponent2 && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) {
  2815. dynamicPropNames.push(name);
  2816. }
  2817. } else {
  2818. hasDynamicKeys = true;
  2819. }
  2820. };
  2821. for (let i = 0; i < props.length; i++) {
  2822. const prop = props[i];
  2823. if (prop.type === 6) {
  2824. const { loc, name, nameLoc, value } = prop;
  2825. let isStatic = true;
  2826. if (name === "ref") {
  2827. hasRef = true;
  2828. pushRefVForMarker();
  2829. }
  2830. if (name === "is" && (isComponentTag(tag) || value && value.content.startsWith("vue:") || isCompatEnabled(
  2831. "COMPILER_IS_ON_ELEMENT",
  2832. context
  2833. ))) {
  2834. continue;
  2835. }
  2836. properties.push(
  2837. createObjectProperty(
  2838. createSimpleExpression(name, true, nameLoc),
  2839. createSimpleExpression(
  2840. value ? value.content : "",
  2841. isStatic,
  2842. value ? value.loc : loc
  2843. )
  2844. )
  2845. );
  2846. } else {
  2847. const { name, arg, exp, loc, modifiers } = prop;
  2848. const isVBind = name === "bind";
  2849. const isVOn = name === "on";
  2850. if (name === "slot") {
  2851. if (!isComponent2) {
  2852. context.onError(
  2853. createCompilerError(40, loc)
  2854. );
  2855. }
  2856. continue;
  2857. }
  2858. if (name === "once" || name === "memo") {
  2859. continue;
  2860. }
  2861. if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || isCompatEnabled(
  2862. "COMPILER_IS_ON_ELEMENT",
  2863. context
  2864. ))) {
  2865. continue;
  2866. }
  2867. if (isVOn && ssr) {
  2868. continue;
  2869. }
  2870. if (
  2871. // #938: elements with dynamic keys should be forced into blocks
  2872. isVBind && isStaticArgOf(arg, "key") || // inline before-update hooks need to force block so that it is invoked
  2873. // before children
  2874. isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")
  2875. ) {
  2876. shouldUseBlock = true;
  2877. }
  2878. if (isVBind && isStaticArgOf(arg, "ref")) {
  2879. pushRefVForMarker();
  2880. }
  2881. if (!arg && (isVBind || isVOn)) {
  2882. hasDynamicKeys = true;
  2883. if (exp) {
  2884. if (isVBind) {
  2885. pushRefVForMarker();
  2886. pushMergeArg();
  2887. {
  2888. if (true) {
  2889. const hasOverridableKeys = mergeArgs.some((arg2) => {
  2890. if (arg2.type === 15) {
  2891. return arg2.properties.some(({ key }) => {
  2892. if (key.type !== 4 || !key.isStatic) {
  2893. return true;
  2894. }
  2895. return key.content !== "class" && key.content !== "style" && !isOn(key.content);
  2896. });
  2897. } else {
  2898. return true;
  2899. }
  2900. });
  2901. if (hasOverridableKeys) {
  2902. checkCompatEnabled(
  2903. "COMPILER_V_BIND_OBJECT_ORDER",
  2904. context,
  2905. loc
  2906. );
  2907. }
  2908. }
  2909. if (isCompatEnabled(
  2910. "COMPILER_V_BIND_OBJECT_ORDER",
  2911. context
  2912. )) {
  2913. mergeArgs.unshift(exp);
  2914. continue;
  2915. }
  2916. }
  2917. mergeArgs.push(exp);
  2918. } else {
  2919. pushMergeArg({
  2920. type: 14,
  2921. loc,
  2922. callee: context.helper(TO_HANDLERS),
  2923. arguments: isComponent2 ? [exp] : [exp, `true`]
  2924. });
  2925. }
  2926. } else {
  2927. context.onError(
  2928. createCompilerError(
  2929. isVBind ? 34 : 35,
  2930. loc
  2931. )
  2932. );
  2933. }
  2934. continue;
  2935. }
  2936. if (isVBind && modifiers.includes("prop")) {
  2937. patchFlag |= 32;
  2938. }
  2939. const directiveTransform = context.directiveTransforms[name];
  2940. if (directiveTransform) {
  2941. const { props: props2, needRuntime } = directiveTransform(prop, node, context);
  2942. !ssr && props2.forEach(analyzePatchFlag);
  2943. if (isVOn && arg && !isStaticExp(arg)) {
  2944. pushMergeArg(createObjectExpression(props2, elementLoc));
  2945. } else {
  2946. properties.push(...props2);
  2947. }
  2948. if (needRuntime) {
  2949. runtimeDirectives.push(prop);
  2950. if (isSymbol(needRuntime)) {
  2951. directiveImportMap.set(prop, needRuntime);
  2952. }
  2953. }
  2954. } else if (!isBuiltInDirective(name)) {
  2955. runtimeDirectives.push(prop);
  2956. if (hasChildren) {
  2957. shouldUseBlock = true;
  2958. }
  2959. }
  2960. }
  2961. }
  2962. let propsExpression = void 0;
  2963. if (mergeArgs.length) {
  2964. pushMergeArg();
  2965. if (mergeArgs.length > 1) {
  2966. propsExpression = createCallExpression(
  2967. context.helper(MERGE_PROPS),
  2968. mergeArgs,
  2969. elementLoc
  2970. );
  2971. } else {
  2972. propsExpression = mergeArgs[0];
  2973. }
  2974. } else if (properties.length) {
  2975. propsExpression = createObjectExpression(
  2976. dedupeProperties(properties),
  2977. elementLoc
  2978. );
  2979. }
  2980. if (hasDynamicKeys) {
  2981. patchFlag |= 16;
  2982. } else {
  2983. if (hasClassBinding && !isComponent2) {
  2984. patchFlag |= 2;
  2985. }
  2986. if (hasStyleBinding && !isComponent2) {
  2987. patchFlag |= 4;
  2988. }
  2989. if (dynamicPropNames.length) {
  2990. patchFlag |= 8;
  2991. }
  2992. if (hasHydrationEventBinding) {
  2993. patchFlag |= 32;
  2994. }
  2995. }
  2996. if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
  2997. patchFlag |= 512;
  2998. }
  2999. if (!context.inSSR && propsExpression) {
  3000. switch (propsExpression.type) {
  3001. case 15:
  3002. let classKeyIndex = -1;
  3003. let styleKeyIndex = -1;
  3004. let hasDynamicKey = false;
  3005. for (let i = 0; i < propsExpression.properties.length; i++) {
  3006. const key = propsExpression.properties[i].key;
  3007. if (isStaticExp(key)) {
  3008. if (key.content === "class") {
  3009. classKeyIndex = i;
  3010. } else if (key.content === "style") {
  3011. styleKeyIndex = i;
  3012. }
  3013. } else if (!key.isHandlerKey) {
  3014. hasDynamicKey = true;
  3015. }
  3016. }
  3017. const classProp = propsExpression.properties[classKeyIndex];
  3018. const styleProp = propsExpression.properties[styleKeyIndex];
  3019. if (!hasDynamicKey) {
  3020. if (classProp && !isStaticExp(classProp.value)) {
  3021. classProp.value = createCallExpression(
  3022. context.helper(NORMALIZE_CLASS),
  3023. [classProp.value]
  3024. );
  3025. }
  3026. if (styleProp && // the static style is compiled into an object,
  3027. // so use `hasStyleBinding` to ensure that it is a dynamic style binding
  3028. (hasStyleBinding || styleProp.value.type === 4 && styleProp.value.content.trim()[0] === `[` || // v-bind:style and style both exist,
  3029. // v-bind:style with static literal object
  3030. styleProp.value.type === 17)) {
  3031. styleProp.value = createCallExpression(
  3032. context.helper(NORMALIZE_STYLE),
  3033. [styleProp.value]
  3034. );
  3035. }
  3036. } else {
  3037. propsExpression = createCallExpression(
  3038. context.helper(NORMALIZE_PROPS),
  3039. [propsExpression]
  3040. );
  3041. }
  3042. break;
  3043. case 14:
  3044. break;
  3045. default:
  3046. propsExpression = createCallExpression(
  3047. context.helper(NORMALIZE_PROPS),
  3048. [
  3049. createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
  3050. propsExpression
  3051. ])
  3052. ]
  3053. );
  3054. break;
  3055. }
  3056. }
  3057. return {
  3058. props: propsExpression,
  3059. directives: runtimeDirectives,
  3060. patchFlag,
  3061. dynamicPropNames,
  3062. shouldUseBlock
  3063. };
  3064. }
  3065. function dedupeProperties(properties) {
  3066. const knownProps = /* @__PURE__ */ new Map();
  3067. const deduped = [];
  3068. for (let i = 0; i < properties.length; i++) {
  3069. const prop = properties[i];
  3070. if (prop.key.type === 8 || !prop.key.isStatic) {
  3071. deduped.push(prop);
  3072. continue;
  3073. }
  3074. const name = prop.key.content;
  3075. const existing = knownProps.get(name);
  3076. if (existing) {
  3077. if (name === "style" || name === "class" || isOn(name)) {
  3078. mergeAsArray(existing, prop);
  3079. }
  3080. } else {
  3081. knownProps.set(name, prop);
  3082. deduped.push(prop);
  3083. }
  3084. }
  3085. return deduped;
  3086. }
  3087. function mergeAsArray(existing, incoming) {
  3088. if (existing.value.type === 17) {
  3089. existing.value.elements.push(incoming.value);
  3090. } else {
  3091. existing.value = createArrayExpression(
  3092. [existing.value, incoming.value],
  3093. existing.loc
  3094. );
  3095. }
  3096. }
  3097. function buildDirectiveArgs(dir, context) {
  3098. const dirArgs = [];
  3099. const runtime = directiveImportMap.get(dir);
  3100. if (runtime) {
  3101. dirArgs.push(context.helperString(runtime));
  3102. } else {
  3103. {
  3104. context.helper(RESOLVE_DIRECTIVE);
  3105. context.directives.add(dir.name);
  3106. dirArgs.push(toValidAssetId(dir.name, `directive`));
  3107. }
  3108. }
  3109. const { loc } = dir;
  3110. if (dir.exp)
  3111. dirArgs.push(dir.exp);
  3112. if (dir.arg) {
  3113. if (!dir.exp) {
  3114. dirArgs.push(`void 0`);
  3115. }
  3116. dirArgs.push(dir.arg);
  3117. }
  3118. if (Object.keys(dir.modifiers).length) {
  3119. if (!dir.arg) {
  3120. if (!dir.exp) {
  3121. dirArgs.push(`void 0`);
  3122. }
  3123. dirArgs.push(`void 0`);
  3124. }
  3125. const trueExpression = createSimpleExpression(`true`, false, loc);
  3126. dirArgs.push(
  3127. createObjectExpression(
  3128. dir.modifiers.map(
  3129. (modifier) => createObjectProperty(modifier, trueExpression)
  3130. ),
  3131. loc
  3132. )
  3133. );
  3134. }
  3135. return createArrayExpression(dirArgs, dir.loc);
  3136. }
  3137. function stringifyDynamicPropNames(props) {
  3138. let propsNamesString = `[`;
  3139. for (let i = 0, l = props.length; i < l; i++) {
  3140. propsNamesString += JSON.stringify(props[i]);
  3141. if (i < l - 1)
  3142. propsNamesString += ", ";
  3143. }
  3144. return propsNamesString + `]`;
  3145. }
  3146. function isComponentTag(tag) {
  3147. return tag === "component" || tag === "Component";
  3148. }
  3149. function processSlotOutlet(node, context) {
  3150. let slotName = `"default"`;
  3151. let slotProps = void 0;
  3152. const nonNameProps = [];
  3153. for (let i = 0; i < node.props.length; i++) {
  3154. const p = node.props[i];
  3155. if (p.type === 6) {
  3156. if (p.value) {
  3157. if (p.name === "name") {
  3158. slotName = JSON.stringify(p.value.content);
  3159. } else {
  3160. p.name = camelize(p.name);
  3161. nonNameProps.push(p);
  3162. }
  3163. }
  3164. } else {
  3165. if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
  3166. if (p.exp) {
  3167. slotName = p.exp;
  3168. } else if (p.arg && p.arg.type === 4) {
  3169. const name = camelize(p.arg.content);
  3170. slotName = p.exp = createSimpleExpression(name, false, p.arg.loc);
  3171. }
  3172. } else {
  3173. if (p.name === "bind" && p.arg && isStaticExp(p.arg)) {
  3174. p.arg.content = camelize(p.arg.content);
  3175. }
  3176. nonNameProps.push(p);
  3177. }
  3178. }
  3179. }
  3180. if (nonNameProps.length > 0) {
  3181. const { props, directives } = buildProps(
  3182. node,
  3183. context,
  3184. nonNameProps,
  3185. false,
  3186. false
  3187. );
  3188. slotProps = props;
  3189. if (directives.length) {
  3190. context.onError(
  3191. createCompilerError(
  3192. 36,
  3193. directives[0].loc
  3194. )
  3195. );
  3196. }
  3197. }
  3198. return {
  3199. slotName,
  3200. slotProps
  3201. };
  3202. }
  3203. function createTransformProps(props = []) {
  3204. return { props };
  3205. }
  3206. function rewriteFilter(node, context) {
  3207. if (node.type === 4) {
  3208. parseFilter(node, context);
  3209. } else {
  3210. for (let i = 0; i < node.children.length; i++) {
  3211. const child = node.children[i];
  3212. if (typeof child !== "object")
  3213. continue;
  3214. if (child.type === 4) {
  3215. parseFilter(child, context);
  3216. } else if (child.type === 8) {
  3217. rewriteFilter(node, context);
  3218. } else if (child.type === 5) {
  3219. rewriteFilter(child.content, context);
  3220. }
  3221. }
  3222. }
  3223. }
  3224. function parseFilter(node, context) {
  3225. const exp = node.content;
  3226. let inSingle = false;
  3227. let inDouble = false;
  3228. let inTemplateString = false;
  3229. let inRegex = false;
  3230. let curly = 0;
  3231. let square = 0;
  3232. let paren = 0;
  3233. let lastFilterIndex = 0;
  3234. let c, prev, i, expression, filters = [];
  3235. for (i = 0; i < exp.length; i++) {
  3236. prev = c;
  3237. c = exp.charCodeAt(i);
  3238. if (inSingle) {
  3239. if (c === 39 && prev !== 92)
  3240. inSingle = false;
  3241. } else if (inDouble) {
  3242. if (c === 34 && prev !== 92)
  3243. inDouble = false;
  3244. } else if (inTemplateString) {
  3245. if (c === 96 && prev !== 92)
  3246. inTemplateString = false;
  3247. } else if (inRegex) {
  3248. if (c === 47 && prev !== 92)
  3249. inRegex = false;
  3250. } else if (c === 124 && // pipe
  3251. exp.charCodeAt(i + 1) !== 124 && exp.charCodeAt(i - 1) !== 124 && !curly && !square && !paren) {
  3252. if (expression === void 0) {
  3253. lastFilterIndex = i + 1;
  3254. expression = exp.slice(0, i).trim();
  3255. } else {
  3256. pushFilter();
  3257. }
  3258. } else {
  3259. switch (c) {
  3260. case 34:
  3261. inDouble = true;
  3262. break;
  3263. case 39:
  3264. inSingle = true;
  3265. break;
  3266. case 96:
  3267. inTemplateString = true;
  3268. break;
  3269. case 40:
  3270. paren++;
  3271. break;
  3272. case 41:
  3273. paren--;
  3274. break;
  3275. case 91:
  3276. square++;
  3277. break;
  3278. case 93:
  3279. square--;
  3280. break;
  3281. case 123:
  3282. curly++;
  3283. break;
  3284. case 125:
  3285. curly--;
  3286. break;
  3287. }
  3288. if (c === 47) {
  3289. let j = i - 1;
  3290. let p;
  3291. for (; j >= 0; j--) {
  3292. p = exp.charAt(j);
  3293. if (p !== " ")
  3294. break;
  3295. }
  3296. if (!p || !validDivisionCharRE.test(p)) {
  3297. inRegex = true;
  3298. }
  3299. }
  3300. }
  3301. }
  3302. if (expression === void 0) {
  3303. expression = exp.slice(0, i).trim();
  3304. } else if (lastFilterIndex !== 0) {
  3305. pushFilter();
  3306. }
  3307. function pushFilter() {
  3308. filters.push(exp.slice(lastFilterIndex, i).trim());
  3309. lastFilterIndex = i + 1;
  3310. }
  3311. if (filters.length) {
  3312. warnDeprecation(
  3313. "COMPILER_FILTERS",
  3314. context,
  3315. node.loc
  3316. );
  3317. for (i = 0; i < filters.length; i++) {
  3318. expression = wrapFilter(expression, filters[i], context);
  3319. }
  3320. node.content = expression;
  3321. }
  3322. }
  3323. function wrapFilter(exp, filter, context) {
  3324. context.helper(RESOLVE_FILTER);
  3325. const i = filter.indexOf("(");
  3326. if (i < 0) {
  3327. context.filters.add(filter);
  3328. return `${toValidAssetId(filter, "filter")}(${exp})`;
  3329. } else {
  3330. const name = filter.slice(0, i);
  3331. const args = filter.slice(i + 1);
  3332. context.filters.add(name);
  3333. return `${toValidAssetId(name, "filter")}(${exp}${args !== ")" ? "," + args : args}`;
  3334. }
  3335. }
  3336. function getBaseTransformPreset(prefixIdentifiers) {
  3337. return [
  3338. [
  3339. transformOnce,
  3340. transformIf,
  3341. transformMemo,
  3342. transformFor,
  3343. ...[transformFilter],
  3344. ...true ? [transformExpression] : [],
  3345. transformSlotOutlet,
  3346. transformElement,
  3347. trackSlotScopes,
  3348. transformText
  3349. ],
  3350. {
  3351. on: transformOn,
  3352. bind: transformBind,
  3353. model: transformModel
  3354. }
  3355. ];
  3356. }
  3357. function baseCompile(source, options = {}) {
  3358. const onError = options.onError || defaultOnError;
  3359. const isModuleMode = options.mode === "module";
  3360. {
  3361. if (options.prefixIdentifiers === true) {
  3362. onError(createCompilerError(47));
  3363. } else if (isModuleMode) {
  3364. onError(createCompilerError(48));
  3365. }
  3366. }
  3367. const prefixIdentifiers = false;
  3368. if (options.cacheHandlers) {
  3369. onError(createCompilerError(49));
  3370. }
  3371. if (options.scopeId && !isModuleMode) {
  3372. onError(createCompilerError(50));
  3373. }
  3374. const resolvedOptions = extend({}, options, {
  3375. prefixIdentifiers
  3376. });
  3377. const ast = isString(source) ? baseParse(source, resolvedOptions) : source;
  3378. const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
  3379. transform(
  3380. ast,
  3381. extend({}, resolvedOptions, {
  3382. nodeTransforms: [
  3383. ...nodeTransforms,
  3384. ...options.nodeTransforms || []
  3385. // user transforms
  3386. ],
  3387. directiveTransforms: extend(
  3388. {},
  3389. directiveTransforms,
  3390. options.directiveTransforms || {}
  3391. // user transforms
  3392. )
  3393. })
  3394. );
  3395. return generate(ast, resolvedOptions);
  3396. }
  3397. var FRAGMENT, TELEPORT, SUSPENSE, KEEP_ALIVE, BASE_TRANSITION, OPEN_BLOCK, CREATE_BLOCK, CREATE_ELEMENT_BLOCK, CREATE_VNODE, CREATE_ELEMENT_VNODE, CREATE_COMMENT, CREATE_TEXT, CREATE_STATIC, RESOLVE_COMPONENT, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_FILTER, WITH_DIRECTIVES, RENDER_LIST, RENDER_SLOT, CREATE_SLOTS, TO_DISPLAY_STRING, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_STYLE, NORMALIZE_PROPS, GUARD_REACTIVE_PROPS, TO_HANDLERS, CAMELIZE, CAPITALIZE, TO_HANDLER_KEY, SET_BLOCK_TRACKING, PUSH_SCOPE_ID, POP_SCOPE_ID, WITH_CTX, UNREF, IS_REF, WITH_MEMO, IS_MEMO_SAME, helperNameMap, Namespaces, NodeTypes, ElementTypes, ConstantTypes, locStub, defaultDelimitersOpen, defaultDelimitersClose, Sequences, Tokenizer, CompilerDeprecationTypes, deprecationData, ErrorCodes, errorMessages, isFunctionType, isStaticProperty, isStaticPropertyKey, TS_NODE_TYPES, isStaticExp, nonIdentifierRE, isSimpleIdentifier, validFirstIdentCharRE, validIdentCharRE, whitespaceRE, isMemberExpressionBrowser, isMemberExpressionNode, isMemberExpression, propsHelperSet, forAliasRE, defaultParserOptions, currentOptions, currentRoot, currentInput, currentOpenTag, currentProp, currentAttrValue, currentAttrStartIndex, currentAttrEndIndex, inPre, inVPre, currentVPreBoundary, stack, tokenizer, forIteratorRE, stripParensRE, specialTemplateDir, windowsNewlineRE, allowHoistedHelperSet, PURE_ANNOTATION, aliasHelper, prohibitedKeywordRE, stripStringRE, transformExpression, transformIf, transformFor, defaultFallback, trackSlotScopes, trackVForSlotScopes, buildClientSlotFn, directiveImportMap, transformElement, transformSlotOutlet, fnExpRE, transformOn, transformBind, injectPrefix, transformText, seen$1, transformOnce, transformModel, validDivisionCharRE, transformFilter, seen, transformMemo, BindingTypes, noopDirectiveTransform;
  3398. var init_compiler_core_esm_bundler = __esm({
  3399. "node_modules/.pnpm/@vue+compiler-core@3.4.27/node_modules/@vue/compiler-core/dist/compiler-core.esm-bundler.js"() {
  3400. init_shared_esm_bundler();
  3401. init_shared_esm_bundler();
  3402. FRAGMENT = Symbol(true ? `Fragment` : ``);
  3403. TELEPORT = Symbol(true ? `Teleport` : ``);
  3404. SUSPENSE = Symbol(true ? `Suspense` : ``);
  3405. KEEP_ALIVE = Symbol(true ? `KeepAlive` : ``);
  3406. BASE_TRANSITION = Symbol(true ? `BaseTransition` : ``);
  3407. OPEN_BLOCK = Symbol(true ? `openBlock` : ``);
  3408. CREATE_BLOCK = Symbol(true ? `createBlock` : ``);
  3409. CREATE_ELEMENT_BLOCK = Symbol(true ? `createElementBlock` : ``);
  3410. CREATE_VNODE = Symbol(true ? `createVNode` : ``);
  3411. CREATE_ELEMENT_VNODE = Symbol(true ? `createElementVNode` : ``);
  3412. CREATE_COMMENT = Symbol(true ? `createCommentVNode` : ``);
  3413. CREATE_TEXT = Symbol(true ? `createTextVNode` : ``);
  3414. CREATE_STATIC = Symbol(true ? `createStaticVNode` : ``);
  3415. RESOLVE_COMPONENT = Symbol(true ? `resolveComponent` : ``);
  3416. RESOLVE_DYNAMIC_COMPONENT = Symbol(
  3417. true ? `resolveDynamicComponent` : ``
  3418. );
  3419. RESOLVE_DIRECTIVE = Symbol(true ? `resolveDirective` : ``);
  3420. RESOLVE_FILTER = Symbol(true ? `resolveFilter` : ``);
  3421. WITH_DIRECTIVES = Symbol(true ? `withDirectives` : ``);
  3422. RENDER_LIST = Symbol(true ? `renderList` : ``);
  3423. RENDER_SLOT = Symbol(true ? `renderSlot` : ``);
  3424. CREATE_SLOTS = Symbol(true ? `createSlots` : ``);
  3425. TO_DISPLAY_STRING = Symbol(true ? `toDisplayString` : ``);
  3426. MERGE_PROPS = Symbol(true ? `mergeProps` : ``);
  3427. NORMALIZE_CLASS = Symbol(true ? `normalizeClass` : ``);
  3428. NORMALIZE_STYLE = Symbol(true ? `normalizeStyle` : ``);
  3429. NORMALIZE_PROPS = Symbol(true ? `normalizeProps` : ``);
  3430. GUARD_REACTIVE_PROPS = Symbol(true ? `guardReactiveProps` : ``);
  3431. TO_HANDLERS = Symbol(true ? `toHandlers` : ``);
  3432. CAMELIZE = Symbol(true ? `camelize` : ``);
  3433. CAPITALIZE = Symbol(true ? `capitalize` : ``);
  3434. TO_HANDLER_KEY = Symbol(true ? `toHandlerKey` : ``);
  3435. SET_BLOCK_TRACKING = Symbol(true ? `setBlockTracking` : ``);
  3436. PUSH_SCOPE_ID = Symbol(true ? `pushScopeId` : ``);
  3437. POP_SCOPE_ID = Symbol(true ? `popScopeId` : ``);
  3438. WITH_CTX = Symbol(true ? `withCtx` : ``);
  3439. UNREF = Symbol(true ? `unref` : ``);
  3440. IS_REF = Symbol(true ? `isRef` : ``);
  3441. WITH_MEMO = Symbol(true ? `withMemo` : ``);
  3442. IS_MEMO_SAME = Symbol(true ? `isMemoSame` : ``);
  3443. helperNameMap = {
  3444. [FRAGMENT]: `Fragment`,
  3445. [TELEPORT]: `Teleport`,
  3446. [SUSPENSE]: `Suspense`,
  3447. [KEEP_ALIVE]: `KeepAlive`,
  3448. [BASE_TRANSITION]: `BaseTransition`,
  3449. [OPEN_BLOCK]: `openBlock`,
  3450. [CREATE_BLOCK]: `createBlock`,
  3451. [CREATE_ELEMENT_BLOCK]: `createElementBlock`,
  3452. [CREATE_VNODE]: `createVNode`,
  3453. [CREATE_ELEMENT_VNODE]: `createElementVNode`,
  3454. [CREATE_COMMENT]: `createCommentVNode`,
  3455. [CREATE_TEXT]: `createTextVNode`,
  3456. [CREATE_STATIC]: `createStaticVNode`,
  3457. [RESOLVE_COMPONENT]: `resolveComponent`,
  3458. [RESOLVE_DYNAMIC_COMPONENT]: `resolveDynamicComponent`,
  3459. [RESOLVE_DIRECTIVE]: `resolveDirective`,
  3460. [RESOLVE_FILTER]: `resolveFilter`,
  3461. [WITH_DIRECTIVES]: `withDirectives`,
  3462. [RENDER_LIST]: `renderList`,
  3463. [RENDER_SLOT]: `renderSlot`,
  3464. [CREATE_SLOTS]: `createSlots`,
  3465. [TO_DISPLAY_STRING]: `toDisplayString`,
  3466. [MERGE_PROPS]: `mergeProps`,
  3467. [NORMALIZE_CLASS]: `normalizeClass`,
  3468. [NORMALIZE_STYLE]: `normalizeStyle`,
  3469. [NORMALIZE_PROPS]: `normalizeProps`,
  3470. [GUARD_REACTIVE_PROPS]: `guardReactiveProps`,
  3471. [TO_HANDLERS]: `toHandlers`,
  3472. [CAMELIZE]: `camelize`,
  3473. [CAPITALIZE]: `capitalize`,
  3474. [TO_HANDLER_KEY]: `toHandlerKey`,
  3475. [SET_BLOCK_TRACKING]: `setBlockTracking`,
  3476. [PUSH_SCOPE_ID]: `pushScopeId`,
  3477. [POP_SCOPE_ID]: `popScopeId`,
  3478. [WITH_CTX]: `withCtx`,
  3479. [UNREF]: `unref`,
  3480. [IS_REF]: `isRef`,
  3481. [WITH_MEMO]: `withMemo`,
  3482. [IS_MEMO_SAME]: `isMemoSame`
  3483. };
  3484. Namespaces = {
  3485. "HTML": 0,
  3486. "0": "HTML",
  3487. "SVG": 1,
  3488. "1": "SVG",
  3489. "MATH_ML": 2,
  3490. "2": "MATH_ML"
  3491. };
  3492. NodeTypes = {
  3493. "ROOT": 0,
  3494. "0": "ROOT",
  3495. "ELEMENT": 1,
  3496. "1": "ELEMENT",
  3497. "TEXT": 2,
  3498. "2": "TEXT",
  3499. "COMMENT": 3,
  3500. "3": "COMMENT",
  3501. "SIMPLE_EXPRESSION": 4,
  3502. "4": "SIMPLE_EXPRESSION",
  3503. "INTERPOLATION": 5,
  3504. "5": "INTERPOLATION",
  3505. "ATTRIBUTE": 6,
  3506. "6": "ATTRIBUTE",
  3507. "DIRECTIVE": 7,
  3508. "7": "DIRECTIVE",
  3509. "COMPOUND_EXPRESSION": 8,
  3510. "8": "COMPOUND_EXPRESSION",
  3511. "IF": 9,
  3512. "9": "IF",
  3513. "IF_BRANCH": 10,
  3514. "10": "IF_BRANCH",
  3515. "FOR": 11,
  3516. "11": "FOR",
  3517. "TEXT_CALL": 12,
  3518. "12": "TEXT_CALL",
  3519. "VNODE_CALL": 13,
  3520. "13": "VNODE_CALL",
  3521. "JS_CALL_EXPRESSION": 14,
  3522. "14": "JS_CALL_EXPRESSION",
  3523. "JS_OBJECT_EXPRESSION": 15,
  3524. "15": "JS_OBJECT_EXPRESSION",
  3525. "JS_PROPERTY": 16,
  3526. "16": "JS_PROPERTY",
  3527. "JS_ARRAY_EXPRESSION": 17,
  3528. "17": "JS_ARRAY_EXPRESSION",
  3529. "JS_FUNCTION_EXPRESSION": 18,
  3530. "18": "JS_FUNCTION_EXPRESSION",
  3531. "JS_CONDITIONAL_EXPRESSION": 19,
  3532. "19": "JS_CONDITIONAL_EXPRESSION",
  3533. "JS_CACHE_EXPRESSION": 20,
  3534. "20": "JS_CACHE_EXPRESSION",
  3535. "JS_BLOCK_STATEMENT": 21,
  3536. "21": "JS_BLOCK_STATEMENT",
  3537. "JS_TEMPLATE_LITERAL": 22,
  3538. "22": "JS_TEMPLATE_LITERAL",
  3539. "JS_IF_STATEMENT": 23,
  3540. "23": "JS_IF_STATEMENT",
  3541. "JS_ASSIGNMENT_EXPRESSION": 24,
  3542. "24": "JS_ASSIGNMENT_EXPRESSION",
  3543. "JS_SEQUENCE_EXPRESSION": 25,
  3544. "25": "JS_SEQUENCE_EXPRESSION",
  3545. "JS_RETURN_STATEMENT": 26,
  3546. "26": "JS_RETURN_STATEMENT"
  3547. };
  3548. ElementTypes = {
  3549. "ELEMENT": 0,
  3550. "0": "ELEMENT",
  3551. "COMPONENT": 1,
  3552. "1": "COMPONENT",
  3553. "SLOT": 2,
  3554. "2": "SLOT",
  3555. "TEMPLATE": 3,
  3556. "3": "TEMPLATE"
  3557. };
  3558. ConstantTypes = {
  3559. "NOT_CONSTANT": 0,
  3560. "0": "NOT_CONSTANT",
  3561. "CAN_SKIP_PATCH": 1,
  3562. "1": "CAN_SKIP_PATCH",
  3563. "CAN_HOIST": 2,
  3564. "2": "CAN_HOIST",
  3565. "CAN_STRINGIFY": 3,
  3566. "3": "CAN_STRINGIFY"
  3567. };
  3568. locStub = {
  3569. start: { line: 1, column: 1, offset: 0 },
  3570. end: { line: 1, column: 1, offset: 0 },
  3571. source: ""
  3572. };
  3573. defaultDelimitersOpen = new Uint8Array([123, 123]);
  3574. defaultDelimitersClose = new Uint8Array([125, 125]);
  3575. Sequences = {
  3576. Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
  3577. // CDATA[
  3578. CdataEnd: new Uint8Array([93, 93, 62]),
  3579. // ]]>
  3580. CommentEnd: new Uint8Array([45, 45, 62]),
  3581. // `-->`
  3582. ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
  3583. // `<\/script`
  3584. StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
  3585. // `</style`
  3586. TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
  3587. // `</title`
  3588. TextareaEnd: new Uint8Array([
  3589. 60,
  3590. 47,
  3591. 116,
  3592. 101,
  3593. 120,
  3594. 116,
  3595. 97,
  3596. 114,
  3597. 101,
  3598. 97
  3599. ])
  3600. // `</textarea
  3601. };
  3602. Tokenizer = class {
  3603. constructor(stack2, cbs) {
  3604. this.stack = stack2;
  3605. this.cbs = cbs;
  3606. this.state = 1;
  3607. this.buffer = "";
  3608. this.sectionStart = 0;
  3609. this.index = 0;
  3610. this.entityStart = 0;
  3611. this.baseState = 1;
  3612. this.inRCDATA = false;
  3613. this.inXML = false;
  3614. this.inVPre = false;
  3615. this.newlines = [];
  3616. this.mode = 0;
  3617. this.delimiterOpen = defaultDelimitersOpen;
  3618. this.delimiterClose = defaultDelimitersClose;
  3619. this.delimiterIndex = -1;
  3620. this.currentSequence = void 0;
  3621. this.sequenceIndex = 0;
  3622. }
  3623. get inSFCRoot() {
  3624. return this.mode === 2 && this.stack.length === 0;
  3625. }
  3626. reset() {
  3627. this.state = 1;
  3628. this.mode = 0;
  3629. this.buffer = "";
  3630. this.sectionStart = 0;
  3631. this.index = 0;
  3632. this.baseState = 1;
  3633. this.inRCDATA = false;
  3634. this.currentSequence = void 0;
  3635. this.newlines.length = 0;
  3636. this.delimiterOpen = defaultDelimitersOpen;
  3637. this.delimiterClose = defaultDelimitersClose;
  3638. }
  3639. /**
  3640. * Generate Position object with line / column information using recorded
  3641. * newline positions. We know the index is always going to be an already
  3642. * processed index, so all the newlines up to this index should have been
  3643. * recorded.
  3644. */
  3645. getPos(index) {
  3646. let line = 1;
  3647. let column = index + 1;
  3648. for (let i = this.newlines.length - 1; i >= 0; i--) {
  3649. const newlineIndex = this.newlines[i];
  3650. if (index > newlineIndex) {
  3651. line = i + 2;
  3652. column = index - newlineIndex;
  3653. break;
  3654. }
  3655. }
  3656. return {
  3657. column,
  3658. line,
  3659. offset: index
  3660. };
  3661. }
  3662. peek() {
  3663. return this.buffer.charCodeAt(this.index + 1);
  3664. }
  3665. stateText(c) {
  3666. if (c === 60) {
  3667. if (this.index > this.sectionStart) {
  3668. this.cbs.ontext(this.sectionStart, this.index);
  3669. }
  3670. this.state = 5;
  3671. this.sectionStart = this.index;
  3672. } else if (!this.inVPre && c === this.delimiterOpen[0]) {
  3673. this.state = 2;
  3674. this.delimiterIndex = 0;
  3675. this.stateInterpolationOpen(c);
  3676. }
  3677. }
  3678. stateInterpolationOpen(c) {
  3679. if (c === this.delimiterOpen[this.delimiterIndex]) {
  3680. if (this.delimiterIndex === this.delimiterOpen.length - 1) {
  3681. const start = this.index + 1 - this.delimiterOpen.length;
  3682. if (start > this.sectionStart) {
  3683. this.cbs.ontext(this.sectionStart, start);
  3684. }
  3685. this.state = 3;
  3686. this.sectionStart = start;
  3687. } else {
  3688. this.delimiterIndex++;
  3689. }
  3690. } else if (this.inRCDATA) {
  3691. this.state = 32;
  3692. this.stateInRCDATA(c);
  3693. } else {
  3694. this.state = 1;
  3695. this.stateText(c);
  3696. }
  3697. }
  3698. stateInterpolation(c) {
  3699. if (c === this.delimiterClose[0]) {
  3700. this.state = 4;
  3701. this.delimiterIndex = 0;
  3702. this.stateInterpolationClose(c);
  3703. }
  3704. }
  3705. stateInterpolationClose(c) {
  3706. if (c === this.delimiterClose[this.delimiterIndex]) {
  3707. if (this.delimiterIndex === this.delimiterClose.length - 1) {
  3708. this.cbs.oninterpolation(this.sectionStart, this.index + 1);
  3709. if (this.inRCDATA) {
  3710. this.state = 32;
  3711. } else {
  3712. this.state = 1;
  3713. }
  3714. this.sectionStart = this.index + 1;
  3715. } else {
  3716. this.delimiterIndex++;
  3717. }
  3718. } else {
  3719. this.state = 3;
  3720. this.stateInterpolation(c);
  3721. }
  3722. }
  3723. stateSpecialStartSequence(c) {
  3724. const isEnd = this.sequenceIndex === this.currentSequence.length;
  3725. const isMatch = isEnd ? (
  3726. // If we are at the end of the sequence, make sure the tag name has ended
  3727. isEndOfTagSection(c)
  3728. ) : (
  3729. // Otherwise, do a case-insensitive comparison
  3730. (c | 32) === this.currentSequence[this.sequenceIndex]
  3731. );
  3732. if (!isMatch) {
  3733. this.inRCDATA = false;
  3734. } else if (!isEnd) {
  3735. this.sequenceIndex++;
  3736. return;
  3737. }
  3738. this.sequenceIndex = 0;
  3739. this.state = 6;
  3740. this.stateInTagName(c);
  3741. }
  3742. /** Look for an end tag. For <title> and <textarea>, also decode entities. */
  3743. stateInRCDATA(c) {
  3744. if (this.sequenceIndex === this.currentSequence.length) {
  3745. if (c === 62 || isWhitespace(c)) {
  3746. const endOfText = this.index - this.currentSequence.length;
  3747. if (this.sectionStart < endOfText) {
  3748. const actualIndex = this.index;
  3749. this.index = endOfText;
  3750. this.cbs.ontext(this.sectionStart, endOfText);
  3751. this.index = actualIndex;
  3752. }
  3753. this.sectionStart = endOfText + 2;
  3754. this.stateInClosingTagName(c);
  3755. this.inRCDATA = false;
  3756. return;
  3757. }
  3758. this.sequenceIndex = 0;
  3759. }
  3760. if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
  3761. this.sequenceIndex += 1;
  3762. } else if (this.sequenceIndex === 0) {
  3763. if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
  3764. if (c === this.delimiterOpen[0]) {
  3765. this.state = 2;
  3766. this.delimiterIndex = 0;
  3767. this.stateInterpolationOpen(c);
  3768. }
  3769. } else if (this.fastForwardTo(60)) {
  3770. this.sequenceIndex = 1;
  3771. }
  3772. } else {
  3773. this.sequenceIndex = Number(c === 60);
  3774. }
  3775. }
  3776. stateCDATASequence(c) {
  3777. if (c === Sequences.Cdata[this.sequenceIndex]) {
  3778. if (++this.sequenceIndex === Sequences.Cdata.length) {
  3779. this.state = 28;
  3780. this.currentSequence = Sequences.CdataEnd;
  3781. this.sequenceIndex = 0;
  3782. this.sectionStart = this.index + 1;
  3783. }
  3784. } else {
  3785. this.sequenceIndex = 0;
  3786. this.state = 23;
  3787. this.stateInDeclaration(c);
  3788. }
  3789. }
  3790. /**
  3791. * When we wait for one specific character, we can speed things up
  3792. * by skipping through the buffer until we find it.
  3793. *
  3794. * @returns Whether the character was found.
  3795. */
  3796. fastForwardTo(c) {
  3797. while (++this.index < this.buffer.length) {
  3798. const cc = this.buffer.charCodeAt(this.index);
  3799. if (cc === 10) {
  3800. this.newlines.push(this.index);
  3801. }
  3802. if (cc === c) {
  3803. return true;
  3804. }
  3805. }
  3806. this.index = this.buffer.length - 1;
  3807. return false;
  3808. }
  3809. /**
  3810. * Comments and CDATA end with `-->` and `]]>`.
  3811. *
  3812. * Their common qualities are:
  3813. * - Their end sequences have a distinct character they start with.
  3814. * - That character is then repeated, so we have to check multiple repeats.
  3815. * - All characters but the start character of the sequence can be skipped.
  3816. */
  3817. stateInCommentLike(c) {
  3818. if (c === this.currentSequence[this.sequenceIndex]) {
  3819. if (++this.sequenceIndex === this.currentSequence.length) {
  3820. if (this.currentSequence === Sequences.CdataEnd) {
  3821. this.cbs.oncdata(this.sectionStart, this.index - 2);
  3822. } else {
  3823. this.cbs.oncomment(this.sectionStart, this.index - 2);
  3824. }
  3825. this.sequenceIndex = 0;
  3826. this.sectionStart = this.index + 1;
  3827. this.state = 1;
  3828. }
  3829. } else if (this.sequenceIndex === 0) {
  3830. if (this.fastForwardTo(this.currentSequence[0])) {
  3831. this.sequenceIndex = 1;
  3832. }
  3833. } else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
  3834. this.sequenceIndex = 0;
  3835. }
  3836. }
  3837. startSpecial(sequence, offset) {
  3838. this.enterRCDATA(sequence, offset);
  3839. this.state = 31;
  3840. }
  3841. enterRCDATA(sequence, offset) {
  3842. this.inRCDATA = true;
  3843. this.currentSequence = sequence;
  3844. this.sequenceIndex = offset;
  3845. }
  3846. stateBeforeTagName(c) {
  3847. if (c === 33) {
  3848. this.state = 22;
  3849. this.sectionStart = this.index + 1;
  3850. } else if (c === 63) {
  3851. this.state = 24;
  3852. this.sectionStart = this.index + 1;
  3853. } else if (isTagStartChar(c)) {
  3854. this.sectionStart = this.index;
  3855. if (this.mode === 0) {
  3856. this.state = 6;
  3857. } else if (this.inSFCRoot) {
  3858. this.state = 34;
  3859. } else if (!this.inXML) {
  3860. if (c === 116) {
  3861. this.state = 30;
  3862. } else {
  3863. this.state = c === 115 ? 29 : 6;
  3864. }
  3865. } else {
  3866. this.state = 6;
  3867. }
  3868. } else if (c === 47) {
  3869. this.state = 8;
  3870. } else {
  3871. this.state = 1;
  3872. this.stateText(c);
  3873. }
  3874. }
  3875. stateInTagName(c) {
  3876. if (isEndOfTagSection(c)) {
  3877. this.handleTagName(c);
  3878. }
  3879. }
  3880. stateInSFCRootTagName(c) {
  3881. if (isEndOfTagSection(c)) {
  3882. const tag = this.buffer.slice(this.sectionStart, this.index);
  3883. if (tag !== "template") {
  3884. this.enterRCDATA(toCharCodes(`</` + tag), 0);
  3885. }
  3886. this.handleTagName(c);
  3887. }
  3888. }
  3889. handleTagName(c) {
  3890. this.cbs.onopentagname(this.sectionStart, this.index);
  3891. this.sectionStart = -1;
  3892. this.state = 11;
  3893. this.stateBeforeAttrName(c);
  3894. }
  3895. stateBeforeClosingTagName(c) {
  3896. if (isWhitespace(c))
  3897. ;
  3898. else if (c === 62) {
  3899. if (true) {
  3900. this.cbs.onerr(14, this.index);
  3901. }
  3902. this.state = 1;
  3903. this.sectionStart = this.index + 1;
  3904. } else {
  3905. this.state = isTagStartChar(c) ? 9 : 27;
  3906. this.sectionStart = this.index;
  3907. }
  3908. }
  3909. stateInClosingTagName(c) {
  3910. if (c === 62 || isWhitespace(c)) {
  3911. this.cbs.onclosetag(this.sectionStart, this.index);
  3912. this.sectionStart = -1;
  3913. this.state = 10;
  3914. this.stateAfterClosingTagName(c);
  3915. }
  3916. }
  3917. stateAfterClosingTagName(c) {
  3918. if (c === 62) {
  3919. this.state = 1;
  3920. this.sectionStart = this.index + 1;
  3921. }
  3922. }
  3923. stateBeforeAttrName(c) {
  3924. if (c === 62) {
  3925. this.cbs.onopentagend(this.index);
  3926. if (this.inRCDATA) {
  3927. this.state = 32;
  3928. } else {
  3929. this.state = 1;
  3930. }
  3931. this.sectionStart = this.index + 1;
  3932. } else if (c === 47) {
  3933. this.state = 7;
  3934. if (this.peek() !== 62) {
  3935. this.cbs.onerr(22, this.index);
  3936. }
  3937. } else if (c === 60 && this.peek() === 47) {
  3938. this.cbs.onopentagend(this.index);
  3939. this.state = 5;
  3940. this.sectionStart = this.index;
  3941. } else if (!isWhitespace(c)) {
  3942. if (c === 61) {
  3943. this.cbs.onerr(
  3944. 19,
  3945. this.index
  3946. );
  3947. }
  3948. this.handleAttrStart(c);
  3949. }
  3950. }
  3951. handleAttrStart(c) {
  3952. if (c === 118 && this.peek() === 45) {
  3953. this.state = 13;
  3954. this.sectionStart = this.index;
  3955. } else if (c === 46 || c === 58 || c === 64 || c === 35) {
  3956. this.cbs.ondirname(this.index, this.index + 1);
  3957. this.state = 14;
  3958. this.sectionStart = this.index + 1;
  3959. } else {
  3960. this.state = 12;
  3961. this.sectionStart = this.index;
  3962. }
  3963. }
  3964. stateInSelfClosingTag(c) {
  3965. if (c === 62) {
  3966. this.cbs.onselfclosingtag(this.index);
  3967. this.state = 1;
  3968. this.sectionStart = this.index + 1;
  3969. this.inRCDATA = false;
  3970. } else if (!isWhitespace(c)) {
  3971. this.state = 11;
  3972. this.stateBeforeAttrName(c);
  3973. }
  3974. }
  3975. stateInAttrName(c) {
  3976. if (c === 61 || isEndOfTagSection(c)) {
  3977. this.cbs.onattribname(this.sectionStart, this.index);
  3978. this.handleAttrNameEnd(c);
  3979. } else if (c === 34 || c === 39 || c === 60) {
  3980. this.cbs.onerr(
  3981. 17,
  3982. this.index
  3983. );
  3984. }
  3985. }
  3986. stateInDirName(c) {
  3987. if (c === 61 || isEndOfTagSection(c)) {
  3988. this.cbs.ondirname(this.sectionStart, this.index);
  3989. this.handleAttrNameEnd(c);
  3990. } else if (c === 58) {
  3991. this.cbs.ondirname(this.sectionStart, this.index);
  3992. this.state = 14;
  3993. this.sectionStart = this.index + 1;
  3994. } else if (c === 46) {
  3995. this.cbs.ondirname(this.sectionStart, this.index);
  3996. this.state = 16;
  3997. this.sectionStart = this.index + 1;
  3998. }
  3999. }
  4000. stateInDirArg(c) {
  4001. if (c === 61 || isEndOfTagSection(c)) {
  4002. this.cbs.ondirarg(this.sectionStart, this.index);
  4003. this.handleAttrNameEnd(c);
  4004. } else if (c === 91) {
  4005. this.state = 15;
  4006. } else if (c === 46) {
  4007. this.cbs.ondirarg(this.sectionStart, this.index);
  4008. this.state = 16;
  4009. this.sectionStart = this.index + 1;
  4010. }
  4011. }
  4012. stateInDynamicDirArg(c) {
  4013. if (c === 93) {
  4014. this.state = 14;
  4015. } else if (c === 61 || isEndOfTagSection(c)) {
  4016. this.cbs.ondirarg(this.sectionStart, this.index + 1);
  4017. this.handleAttrNameEnd(c);
  4018. if (true) {
  4019. this.cbs.onerr(
  4020. 27,
  4021. this.index
  4022. );
  4023. }
  4024. }
  4025. }
  4026. stateInDirModifier(c) {
  4027. if (c === 61 || isEndOfTagSection(c)) {
  4028. this.cbs.ondirmodifier(this.sectionStart, this.index);
  4029. this.handleAttrNameEnd(c);
  4030. } else if (c === 46) {
  4031. this.cbs.ondirmodifier(this.sectionStart, this.index);
  4032. this.sectionStart = this.index + 1;
  4033. }
  4034. }
  4035. handleAttrNameEnd(c) {
  4036. this.sectionStart = this.index;
  4037. this.state = 17;
  4038. this.cbs.onattribnameend(this.index);
  4039. this.stateAfterAttrName(c);
  4040. }
  4041. stateAfterAttrName(c) {
  4042. if (c === 61) {
  4043. this.state = 18;
  4044. } else if (c === 47 || c === 62) {
  4045. this.cbs.onattribend(0, this.sectionStart);
  4046. this.sectionStart = -1;
  4047. this.state = 11;
  4048. this.stateBeforeAttrName(c);
  4049. } else if (!isWhitespace(c)) {
  4050. this.cbs.onattribend(0, this.sectionStart);
  4051. this.handleAttrStart(c);
  4052. }
  4053. }
  4054. stateBeforeAttrValue(c) {
  4055. if (c === 34) {
  4056. this.state = 19;
  4057. this.sectionStart = this.index + 1;
  4058. } else if (c === 39) {
  4059. this.state = 20;
  4060. this.sectionStart = this.index + 1;
  4061. } else if (!isWhitespace(c)) {
  4062. this.sectionStart = this.index;
  4063. this.state = 21;
  4064. this.stateInAttrValueNoQuotes(c);
  4065. }
  4066. }
  4067. handleInAttrValue(c, quote) {
  4068. if (c === quote || this.fastForwardTo(quote)) {
  4069. this.cbs.onattribdata(this.sectionStart, this.index);
  4070. this.sectionStart = -1;
  4071. this.cbs.onattribend(
  4072. quote === 34 ? 3 : 2,
  4073. this.index + 1
  4074. );
  4075. this.state = 11;
  4076. }
  4077. }
  4078. stateInAttrValueDoubleQuotes(c) {
  4079. this.handleInAttrValue(c, 34);
  4080. }
  4081. stateInAttrValueSingleQuotes(c) {
  4082. this.handleInAttrValue(c, 39);
  4083. }
  4084. stateInAttrValueNoQuotes(c) {
  4085. if (isWhitespace(c) || c === 62) {
  4086. this.cbs.onattribdata(this.sectionStart, this.index);
  4087. this.sectionStart = -1;
  4088. this.cbs.onattribend(1, this.index);
  4089. this.state = 11;
  4090. this.stateBeforeAttrName(c);
  4091. } else if (c === 34 || c === 39 || c === 60 || c === 61 || c === 96) {
  4092. this.cbs.onerr(
  4093. 18,
  4094. this.index
  4095. );
  4096. } else
  4097. ;
  4098. }
  4099. stateBeforeDeclaration(c) {
  4100. if (c === 91) {
  4101. this.state = 26;
  4102. this.sequenceIndex = 0;
  4103. } else {
  4104. this.state = c === 45 ? 25 : 23;
  4105. }
  4106. }
  4107. stateInDeclaration(c) {
  4108. if (c === 62 || this.fastForwardTo(62)) {
  4109. this.state = 1;
  4110. this.sectionStart = this.index + 1;
  4111. }
  4112. }
  4113. stateInProcessingInstruction(c) {
  4114. if (c === 62 || this.fastForwardTo(62)) {
  4115. this.cbs.onprocessinginstruction(this.sectionStart, this.index);
  4116. this.state = 1;
  4117. this.sectionStart = this.index + 1;
  4118. }
  4119. }
  4120. stateBeforeComment(c) {
  4121. if (c === 45) {
  4122. this.state = 28;
  4123. this.currentSequence = Sequences.CommentEnd;
  4124. this.sequenceIndex = 2;
  4125. this.sectionStart = this.index + 1;
  4126. } else {
  4127. this.state = 23;
  4128. }
  4129. }
  4130. stateInSpecialComment(c) {
  4131. if (c === 62 || this.fastForwardTo(62)) {
  4132. this.cbs.oncomment(this.sectionStart, this.index);
  4133. this.state = 1;
  4134. this.sectionStart = this.index + 1;
  4135. }
  4136. }
  4137. stateBeforeSpecialS(c) {
  4138. if (c === Sequences.ScriptEnd[3]) {
  4139. this.startSpecial(Sequences.ScriptEnd, 4);
  4140. } else if (c === Sequences.StyleEnd[3]) {
  4141. this.startSpecial(Sequences.StyleEnd, 4);
  4142. } else {
  4143. this.state = 6;
  4144. this.stateInTagName(c);
  4145. }
  4146. }
  4147. stateBeforeSpecialT(c) {
  4148. if (c === Sequences.TitleEnd[3]) {
  4149. this.startSpecial(Sequences.TitleEnd, 4);
  4150. } else if (c === Sequences.TextareaEnd[3]) {
  4151. this.startSpecial(Sequences.TextareaEnd, 4);
  4152. } else {
  4153. this.state = 6;
  4154. this.stateInTagName(c);
  4155. }
  4156. }
  4157. startEntity() {
  4158. }
  4159. stateInEntity() {
  4160. }
  4161. /**
  4162. * Iterates through the buffer, calling the function corresponding to the current state.
  4163. *
  4164. * States that are more likely to be hit are higher up, as a performance improvement.
  4165. */
  4166. parse(input) {
  4167. this.buffer = input;
  4168. while (this.index < this.buffer.length) {
  4169. const c = this.buffer.charCodeAt(this.index);
  4170. if (c === 10) {
  4171. this.newlines.push(this.index);
  4172. }
  4173. switch (this.state) {
  4174. case 1: {
  4175. this.stateText(c);
  4176. break;
  4177. }
  4178. case 2: {
  4179. this.stateInterpolationOpen(c);
  4180. break;
  4181. }
  4182. case 3: {
  4183. this.stateInterpolation(c);
  4184. break;
  4185. }
  4186. case 4: {
  4187. this.stateInterpolationClose(c);
  4188. break;
  4189. }
  4190. case 31: {
  4191. this.stateSpecialStartSequence(c);
  4192. break;
  4193. }
  4194. case 32: {
  4195. this.stateInRCDATA(c);
  4196. break;
  4197. }
  4198. case 26: {
  4199. this.stateCDATASequence(c);
  4200. break;
  4201. }
  4202. case 19: {
  4203. this.stateInAttrValueDoubleQuotes(c);
  4204. break;
  4205. }
  4206. case 12: {
  4207. this.stateInAttrName(c);
  4208. break;
  4209. }
  4210. case 13: {
  4211. this.stateInDirName(c);
  4212. break;
  4213. }
  4214. case 14: {
  4215. this.stateInDirArg(c);
  4216. break;
  4217. }
  4218. case 15: {
  4219. this.stateInDynamicDirArg(c);
  4220. break;
  4221. }
  4222. case 16: {
  4223. this.stateInDirModifier(c);
  4224. break;
  4225. }
  4226. case 28: {
  4227. this.stateInCommentLike(c);
  4228. break;
  4229. }
  4230. case 27: {
  4231. this.stateInSpecialComment(c);
  4232. break;
  4233. }
  4234. case 11: {
  4235. this.stateBeforeAttrName(c);
  4236. break;
  4237. }
  4238. case 6: {
  4239. this.stateInTagName(c);
  4240. break;
  4241. }
  4242. case 34: {
  4243. this.stateInSFCRootTagName(c);
  4244. break;
  4245. }
  4246. case 9: {
  4247. this.stateInClosingTagName(c);
  4248. break;
  4249. }
  4250. case 5: {
  4251. this.stateBeforeTagName(c);
  4252. break;
  4253. }
  4254. case 17: {
  4255. this.stateAfterAttrName(c);
  4256. break;
  4257. }
  4258. case 20: {
  4259. this.stateInAttrValueSingleQuotes(c);
  4260. break;
  4261. }
  4262. case 18: {
  4263. this.stateBeforeAttrValue(c);
  4264. break;
  4265. }
  4266. case 8: {
  4267. this.stateBeforeClosingTagName(c);
  4268. break;
  4269. }
  4270. case 10: {
  4271. this.stateAfterClosingTagName(c);
  4272. break;
  4273. }
  4274. case 29: {
  4275. this.stateBeforeSpecialS(c);
  4276. break;
  4277. }
  4278. case 30: {
  4279. this.stateBeforeSpecialT(c);
  4280. break;
  4281. }
  4282. case 21: {
  4283. this.stateInAttrValueNoQuotes(c);
  4284. break;
  4285. }
  4286. case 7: {
  4287. this.stateInSelfClosingTag(c);
  4288. break;
  4289. }
  4290. case 23: {
  4291. this.stateInDeclaration(c);
  4292. break;
  4293. }
  4294. case 22: {
  4295. this.stateBeforeDeclaration(c);
  4296. break;
  4297. }
  4298. case 25: {
  4299. this.stateBeforeComment(c);
  4300. break;
  4301. }
  4302. case 24: {
  4303. this.stateInProcessingInstruction(c);
  4304. break;
  4305. }
  4306. case 33: {
  4307. this.stateInEntity();
  4308. break;
  4309. }
  4310. }
  4311. this.index++;
  4312. }
  4313. this.cleanup();
  4314. this.finish();
  4315. }
  4316. /**
  4317. * Remove data that has already been consumed from the buffer.
  4318. */
  4319. cleanup() {
  4320. if (this.sectionStart !== this.index) {
  4321. if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
  4322. this.cbs.ontext(this.sectionStart, this.index);
  4323. this.sectionStart = this.index;
  4324. } else if (this.state === 19 || this.state === 20 || this.state === 21) {
  4325. this.cbs.onattribdata(this.sectionStart, this.index);
  4326. this.sectionStart = this.index;
  4327. }
  4328. }
  4329. }
  4330. finish() {
  4331. this.handleTrailingData();
  4332. this.cbs.onend();
  4333. }
  4334. /** Handle any trailing data. */
  4335. handleTrailingData() {
  4336. const endIndex = this.buffer.length;
  4337. if (this.sectionStart >= endIndex) {
  4338. return;
  4339. }
  4340. if (this.state === 28) {
  4341. if (this.currentSequence === Sequences.CdataEnd) {
  4342. this.cbs.oncdata(this.sectionStart, endIndex);
  4343. } else {
  4344. this.cbs.oncomment(this.sectionStart, endIndex);
  4345. }
  4346. } else if (this.state === 6 || this.state === 11 || this.state === 18 || this.state === 17 || this.state === 12 || this.state === 13 || this.state === 14 || this.state === 15 || this.state === 16 || this.state === 20 || this.state === 19 || this.state === 21 || this.state === 9)
  4347. ;
  4348. else {
  4349. this.cbs.ontext(this.sectionStart, endIndex);
  4350. }
  4351. }
  4352. emitCodePoint(cp, consumed) {
  4353. }
  4354. };
  4355. CompilerDeprecationTypes = {
  4356. "COMPILER_IS_ON_ELEMENT": "COMPILER_IS_ON_ELEMENT",
  4357. "COMPILER_V_BIND_SYNC": "COMPILER_V_BIND_SYNC",
  4358. "COMPILER_V_BIND_OBJECT_ORDER": "COMPILER_V_BIND_OBJECT_ORDER",
  4359. "COMPILER_V_ON_NATIVE": "COMPILER_V_ON_NATIVE",
  4360. "COMPILER_V_IF_V_FOR_PRECEDENCE": "COMPILER_V_IF_V_FOR_PRECEDENCE",
  4361. "COMPILER_NATIVE_TEMPLATE": "COMPILER_NATIVE_TEMPLATE",
  4362. "COMPILER_INLINE_TEMPLATE": "COMPILER_INLINE_TEMPLATE",
  4363. "COMPILER_FILTERS": "COMPILER_FILTERS"
  4364. };
  4365. deprecationData = {
  4366. ["COMPILER_IS_ON_ELEMENT"]: {
  4367. message: `Platform-native elements with "is" prop will no longer be treated as components in Vue 3 unless the "is" value is explicitly prefixed with "vue:".`,
  4368. link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
  4369. },
  4370. ["COMPILER_V_BIND_SYNC"]: {
  4371. message: (key) => `.sync modifier for v-bind has been removed. Use v-model with argument instead. \`v-bind:${key}.sync\` should be changed to \`v-model:${key}\`.`,
  4372. link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
  4373. },
  4374. ["COMPILER_V_BIND_OBJECT_ORDER"]: {
  4375. message: `v-bind="obj" usage is now order sensitive and behaves like JavaScript object spread: it will now overwrite an existing non-mergeable attribute that appears before v-bind in the case of conflict. To retain 2.x behavior, move v-bind to make it the first attribute. You can also suppress this warning if the usage is intended.`,
  4376. link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
  4377. },
  4378. ["COMPILER_V_ON_NATIVE"]: {
  4379. message: `.native modifier for v-on has been removed as is no longer necessary.`,
  4380. link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
  4381. },
  4382. ["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
  4383. message: `v-if / v-for precedence when used on the same element has changed in Vue 3: v-if now takes higher precedence and will no longer have access to v-for scope variables. It is best to avoid the ambiguity with <template> tags or use a computed property that filters v-for data source.`,
  4384. link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
  4385. },
  4386. ["COMPILER_NATIVE_TEMPLATE"]: {
  4387. message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
  4388. },
  4389. ["COMPILER_INLINE_TEMPLATE"]: {
  4390. message: `"inline-template" has been removed in Vue 3.`,
  4391. link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
  4392. },
  4393. ["COMPILER_FILTERS"]: {
  4394. message: `filters have been removed in Vue 3. The "|" symbol will be treated as native JavaScript bitwise OR operator. Use method calls or computed properties instead.`,
  4395. link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
  4396. }
  4397. };
  4398. ErrorCodes = {
  4399. "ABRUPT_CLOSING_OF_EMPTY_COMMENT": 0,
  4400. "0": "ABRUPT_CLOSING_OF_EMPTY_COMMENT",
  4401. "CDATA_IN_HTML_CONTENT": 1,
  4402. "1": "CDATA_IN_HTML_CONTENT",
  4403. "DUPLICATE_ATTRIBUTE": 2,
  4404. "2": "DUPLICATE_ATTRIBUTE",
  4405. "END_TAG_WITH_ATTRIBUTES": 3,
  4406. "3": "END_TAG_WITH_ATTRIBUTES",
  4407. "END_TAG_WITH_TRAILING_SOLIDUS": 4,
  4408. "4": "END_TAG_WITH_TRAILING_SOLIDUS",
  4409. "EOF_BEFORE_TAG_NAME": 5,
  4410. "5": "EOF_BEFORE_TAG_NAME",
  4411. "EOF_IN_CDATA": 6,
  4412. "6": "EOF_IN_CDATA",
  4413. "EOF_IN_COMMENT": 7,
  4414. "7": "EOF_IN_COMMENT",
  4415. "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT": 8,
  4416. "8": "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT",
  4417. "EOF_IN_TAG": 9,
  4418. "9": "EOF_IN_TAG",
  4419. "INCORRECTLY_CLOSED_COMMENT": 10,
  4420. "10": "INCORRECTLY_CLOSED_COMMENT",
  4421. "INCORRECTLY_OPENED_COMMENT": 11,
  4422. "11": "INCORRECTLY_OPENED_COMMENT",
  4423. "INVALID_FIRST_CHARACTER_OF_TAG_NAME": 12,
  4424. "12": "INVALID_FIRST_CHARACTER_OF_TAG_NAME",
  4425. "MISSING_ATTRIBUTE_VALUE": 13,
  4426. "13": "MISSING_ATTRIBUTE_VALUE",
  4427. "MISSING_END_TAG_NAME": 14,
  4428. "14": "MISSING_END_TAG_NAME",
  4429. "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES": 15,
  4430. "15": "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES",
  4431. "NESTED_COMMENT": 16,
  4432. "16": "NESTED_COMMENT",
  4433. "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME": 17,
  4434. "17": "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME",
  4435. "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE": 18,
  4436. "18": "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE",
  4437. "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME": 19,
  4438. "19": "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME",
  4439. "UNEXPECTED_NULL_CHARACTER": 20,
  4440. "20": "UNEXPECTED_NULL_CHARACTER",
  4441. "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME": 21,
  4442. "21": "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME",
  4443. "UNEXPECTED_SOLIDUS_IN_TAG": 22,
  4444. "22": "UNEXPECTED_SOLIDUS_IN_TAG",
  4445. "X_INVALID_END_TAG": 23,
  4446. "23": "X_INVALID_END_TAG",
  4447. "X_MISSING_END_TAG": 24,
  4448. "24": "X_MISSING_END_TAG",
  4449. "X_MISSING_INTERPOLATION_END": 25,
  4450. "25": "X_MISSING_INTERPOLATION_END",
  4451. "X_MISSING_DIRECTIVE_NAME": 26,
  4452. "26": "X_MISSING_DIRECTIVE_NAME",
  4453. "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END": 27,
  4454. "27": "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END",
  4455. "X_V_IF_NO_EXPRESSION": 28,
  4456. "28": "X_V_IF_NO_EXPRESSION",
  4457. "X_V_IF_SAME_KEY": 29,
  4458. "29": "X_V_IF_SAME_KEY",
  4459. "X_V_ELSE_NO_ADJACENT_IF": 30,
  4460. "30": "X_V_ELSE_NO_ADJACENT_IF",
  4461. "X_V_FOR_NO_EXPRESSION": 31,
  4462. "31": "X_V_FOR_NO_EXPRESSION",
  4463. "X_V_FOR_MALFORMED_EXPRESSION": 32,
  4464. "32": "X_V_FOR_MALFORMED_EXPRESSION",
  4465. "X_V_FOR_TEMPLATE_KEY_PLACEMENT": 33,
  4466. "33": "X_V_FOR_TEMPLATE_KEY_PLACEMENT",
  4467. "X_V_BIND_NO_EXPRESSION": 34,
  4468. "34": "X_V_BIND_NO_EXPRESSION",
  4469. "X_V_ON_NO_EXPRESSION": 35,
  4470. "35": "X_V_ON_NO_EXPRESSION",
  4471. "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET": 36,
  4472. "36": "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET",
  4473. "X_V_SLOT_MIXED_SLOT_USAGE": 37,
  4474. "37": "X_V_SLOT_MIXED_SLOT_USAGE",
  4475. "X_V_SLOT_DUPLICATE_SLOT_NAMES": 38,
  4476. "38": "X_V_SLOT_DUPLICATE_SLOT_NAMES",
  4477. "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN": 39,
  4478. "39": "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN",
  4479. "X_V_SLOT_MISPLACED": 40,
  4480. "40": "X_V_SLOT_MISPLACED",
  4481. "X_V_MODEL_NO_EXPRESSION": 41,
  4482. "41": "X_V_MODEL_NO_EXPRESSION",
  4483. "X_V_MODEL_MALFORMED_EXPRESSION": 42,
  4484. "42": "X_V_MODEL_MALFORMED_EXPRESSION",
  4485. "X_V_MODEL_ON_SCOPE_VARIABLE": 43,
  4486. "43": "X_V_MODEL_ON_SCOPE_VARIABLE",
  4487. "X_V_MODEL_ON_PROPS": 44,
  4488. "44": "X_V_MODEL_ON_PROPS",
  4489. "X_INVALID_EXPRESSION": 45,
  4490. "45": "X_INVALID_EXPRESSION",
  4491. "X_KEEP_ALIVE_INVALID_CHILDREN": 46,
  4492. "46": "X_KEEP_ALIVE_INVALID_CHILDREN",
  4493. "X_PREFIX_ID_NOT_SUPPORTED": 47,
  4494. "47": "X_PREFIX_ID_NOT_SUPPORTED",
  4495. "X_MODULE_MODE_NOT_SUPPORTED": 48,
  4496. "48": "X_MODULE_MODE_NOT_SUPPORTED",
  4497. "X_CACHE_HANDLER_NOT_SUPPORTED": 49,
  4498. "49": "X_CACHE_HANDLER_NOT_SUPPORTED",
  4499. "X_SCOPE_ID_NOT_SUPPORTED": 50,
  4500. "50": "X_SCOPE_ID_NOT_SUPPORTED",
  4501. "X_VNODE_HOOKS": 51,
  4502. "51": "X_VNODE_HOOKS",
  4503. "X_V_BIND_INVALID_SAME_NAME_ARGUMENT": 52,
  4504. "52": "X_V_BIND_INVALID_SAME_NAME_ARGUMENT",
  4505. "__EXTEND_POINT__": 53,
  4506. "53": "__EXTEND_POINT__"
  4507. };
  4508. errorMessages = {
  4509. // parse errors
  4510. [0]: "Illegal comment.",
  4511. [1]: "CDATA section is allowed only in XML context.",
  4512. [2]: "Duplicate attribute.",
  4513. [3]: "End tag cannot have attributes.",
  4514. [4]: "Illegal '/' in tags.",
  4515. [5]: "Unexpected EOF in tag.",
  4516. [6]: "Unexpected EOF in CDATA section.",
  4517. [7]: "Unexpected EOF in comment.",
  4518. [8]: "Unexpected EOF in script.",
  4519. [9]: "Unexpected EOF in tag.",
  4520. [10]: "Incorrectly closed comment.",
  4521. [11]: "Incorrectly opened comment.",
  4522. [12]: "Illegal tag name. Use '&lt;' to print '<'.",
  4523. [13]: "Attribute value was expected.",
  4524. [14]: "End tag name was expected.",
  4525. [15]: "Whitespace was expected.",
  4526. [16]: "Unexpected '<!--' in comment.",
  4527. [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
  4528. [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
  4529. [19]: "Attribute name cannot start with '='.",
  4530. [21]: "'<?' is allowed only in XML context.",
  4531. [20]: `Unexpected null character.`,
  4532. [22]: "Illegal '/' in tags.",
  4533. // Vue-specific parse errors
  4534. [23]: "Invalid end tag.",
  4535. [24]: "Element is missing end tag.",
  4536. [25]: "Interpolation end sign was not found.",
  4537. [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
  4538. [26]: "Legal directive name was expected.",
  4539. // transform errors
  4540. [28]: `v-if/v-else-if is missing expression.`,
  4541. [29]: `v-if/else branches must use unique keys.`,
  4542. [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
  4543. [31]: `v-for is missing expression.`,
  4544. [32]: `v-for has invalid expression.`,
  4545. [33]: `<template v-for> key should be placed on the <template> tag.`,
  4546. [34]: `v-bind is missing expression.`,
  4547. [52]: `v-bind with same-name shorthand only allows static argument.`,
  4548. [35]: `v-on is missing expression.`,
  4549. [36]: `Unexpected custom directive on <slot> outlet.`,
  4550. [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.`,
  4551. [38]: `Duplicate slot names found. `,
  4552. [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
  4553. [40]: `v-slot can only be used on components or <template> tags.`,
  4554. [41]: `v-model is missing expression.`,
  4555. [42]: `v-model value must be a valid JavaScript member expression.`,
  4556. [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
  4557. [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
  4558. Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
  4559. [45]: `Error parsing JavaScript expression: `,
  4560. [46]: `<KeepAlive> expects exactly one child component.`,
  4561. [51]: `@vnode-* hooks in templates are no longer supported. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support has been removed in 3.4.`,
  4562. // generic errors
  4563. [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
  4564. [48]: `ES module mode is not supported in this build of compiler.`,
  4565. [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
  4566. [50]: `"scopeId" option is only supported in module mode.`,
  4567. // just to fulfill types
  4568. [53]: ``
  4569. };
  4570. isFunctionType = (node) => {
  4571. return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
  4572. };
  4573. isStaticProperty = (node) => node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
  4574. isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
  4575. TS_NODE_TYPES = [
  4576. "TSAsExpression",
  4577. // foo as number
  4578. "TSTypeAssertion",
  4579. // (<number>foo)
  4580. "TSNonNullExpression",
  4581. // foo!
  4582. "TSInstantiationExpression",
  4583. // foo<string>
  4584. "TSSatisfiesExpression"
  4585. // foo satisfies T
  4586. ];
  4587. isStaticExp = (p) => p.type === 4 && p.isStatic;
  4588. nonIdentifierRE = /^\d|[^\$\w]/;
  4589. isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
  4590. validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
  4591. validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
  4592. whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
  4593. isMemberExpressionBrowser = (path) => {
  4594. path = path.trim().replace(whitespaceRE, (s) => s.trim());
  4595. let state = 0;
  4596. let stateStack = [];
  4597. let currentOpenBracketCount = 0;
  4598. let currentOpenParensCount = 0;
  4599. let currentStringType = null;
  4600. for (let i = 0; i < path.length; i++) {
  4601. const char = path.charAt(i);
  4602. switch (state) {
  4603. case 0:
  4604. if (char === "[") {
  4605. stateStack.push(state);
  4606. state = 1;
  4607. currentOpenBracketCount++;
  4608. } else if (char === "(") {
  4609. stateStack.push(state);
  4610. state = 2;
  4611. currentOpenParensCount++;
  4612. } else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
  4613. return false;
  4614. }
  4615. break;
  4616. case 1:
  4617. if (char === `'` || char === `"` || char === "`") {
  4618. stateStack.push(state);
  4619. state = 3;
  4620. currentStringType = char;
  4621. } else if (char === `[`) {
  4622. currentOpenBracketCount++;
  4623. } else if (char === `]`) {
  4624. if (!--currentOpenBracketCount) {
  4625. state = stateStack.pop();
  4626. }
  4627. }
  4628. break;
  4629. case 2:
  4630. if (char === `'` || char === `"` || char === "`") {
  4631. stateStack.push(state);
  4632. state = 3;
  4633. currentStringType = char;
  4634. } else if (char === `(`) {
  4635. currentOpenParensCount++;
  4636. } else if (char === `)`) {
  4637. if (i === path.length - 1) {
  4638. return false;
  4639. }
  4640. if (!--currentOpenParensCount) {
  4641. state = stateStack.pop();
  4642. }
  4643. }
  4644. break;
  4645. case 3:
  4646. if (char === currentStringType) {
  4647. state = stateStack.pop();
  4648. currentStringType = null;
  4649. }
  4650. break;
  4651. }
  4652. }
  4653. return !currentOpenBracketCount && !currentOpenParensCount;
  4654. };
  4655. isMemberExpressionNode = NOOP;
  4656. isMemberExpression = isMemberExpressionBrowser;
  4657. propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
  4658. forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  4659. defaultParserOptions = {
  4660. parseMode: "base",
  4661. ns: 0,
  4662. delimiters: [`{{`, `}}`],
  4663. getNamespace: () => 0,
  4664. isVoidTag: NO,
  4665. isPreTag: NO,
  4666. isCustomElement: NO,
  4667. onError: defaultOnError,
  4668. onWarn: defaultOnWarn,
  4669. comments: true,
  4670. prefixIdentifiers: false
  4671. };
  4672. currentOptions = defaultParserOptions;
  4673. currentRoot = null;
  4674. currentInput = "";
  4675. currentOpenTag = null;
  4676. currentProp = null;
  4677. currentAttrValue = "";
  4678. currentAttrStartIndex = -1;
  4679. currentAttrEndIndex = -1;
  4680. inPre = 0;
  4681. inVPre = false;
  4682. currentVPreBoundary = null;
  4683. stack = [];
  4684. tokenizer = new Tokenizer(stack, {
  4685. onerr: emitError,
  4686. ontext(start, end) {
  4687. onText(getSlice(start, end), start, end);
  4688. },
  4689. ontextentity(char, start, end) {
  4690. onText(char, start, end);
  4691. },
  4692. oninterpolation(start, end) {
  4693. if (inVPre) {
  4694. return onText(getSlice(start, end), start, end);
  4695. }
  4696. let innerStart = start + tokenizer.delimiterOpen.length;
  4697. let innerEnd = end - tokenizer.delimiterClose.length;
  4698. while (isWhitespace(currentInput.charCodeAt(innerStart))) {
  4699. innerStart++;
  4700. }
  4701. while (isWhitespace(currentInput.charCodeAt(innerEnd - 1))) {
  4702. innerEnd--;
  4703. }
  4704. let exp = getSlice(innerStart, innerEnd);
  4705. if (exp.includes("&")) {
  4706. {
  4707. exp = currentOptions.decodeEntities(exp, false);
  4708. }
  4709. }
  4710. addNode({
  4711. type: 5,
  4712. content: createExp(exp, false, getLoc(innerStart, innerEnd)),
  4713. loc: getLoc(start, end)
  4714. });
  4715. },
  4716. onopentagname(start, end) {
  4717. const name = getSlice(start, end);
  4718. currentOpenTag = {
  4719. type: 1,
  4720. tag: name,
  4721. ns: currentOptions.getNamespace(name, stack[0], currentOptions.ns),
  4722. tagType: 0,
  4723. // will be refined on tag close
  4724. props: [],
  4725. children: [],
  4726. loc: getLoc(start - 1, end),
  4727. codegenNode: void 0
  4728. };
  4729. },
  4730. onopentagend(end) {
  4731. endOpenTag(end);
  4732. },
  4733. onclosetag(start, end) {
  4734. const name = getSlice(start, end);
  4735. if (!currentOptions.isVoidTag(name)) {
  4736. let found = false;
  4737. for (let i = 0; i < stack.length; i++) {
  4738. const e = stack[i];
  4739. if (e.tag.toLowerCase() === name.toLowerCase()) {
  4740. found = true;
  4741. if (i > 0) {
  4742. emitError(24, stack[0].loc.start.offset);
  4743. }
  4744. for (let j = 0; j <= i; j++) {
  4745. const el = stack.shift();
  4746. onCloseTag(el, end, j < i);
  4747. }
  4748. break;
  4749. }
  4750. }
  4751. if (!found) {
  4752. emitError(23, backTrack(start, 60));
  4753. }
  4754. }
  4755. },
  4756. onselfclosingtag(end) {
  4757. const name = currentOpenTag.tag;
  4758. currentOpenTag.isSelfClosing = true;
  4759. endOpenTag(end);
  4760. if (stack[0] && stack[0].tag === name) {
  4761. onCloseTag(stack.shift(), end);
  4762. }
  4763. },
  4764. onattribname(start, end) {
  4765. currentProp = {
  4766. type: 6,
  4767. name: getSlice(start, end),
  4768. nameLoc: getLoc(start, end),
  4769. value: void 0,
  4770. loc: getLoc(start)
  4771. };
  4772. },
  4773. ondirname(start, end) {
  4774. const raw = getSlice(start, end);
  4775. const name = raw === "." || raw === ":" ? "bind" : raw === "@" ? "on" : raw === "#" ? "slot" : raw.slice(2);
  4776. if (!inVPre && name === "") {
  4777. emitError(26, start);
  4778. }
  4779. if (inVPre || name === "") {
  4780. currentProp = {
  4781. type: 6,
  4782. name: raw,
  4783. nameLoc: getLoc(start, end),
  4784. value: void 0,
  4785. loc: getLoc(start)
  4786. };
  4787. } else {
  4788. currentProp = {
  4789. type: 7,
  4790. name,
  4791. rawName: raw,
  4792. exp: void 0,
  4793. arg: void 0,
  4794. modifiers: raw === "." ? ["prop"] : [],
  4795. loc: getLoc(start)
  4796. };
  4797. if (name === "pre") {
  4798. inVPre = tokenizer.inVPre = true;
  4799. currentVPreBoundary = currentOpenTag;
  4800. const props = currentOpenTag.props;
  4801. for (let i = 0; i < props.length; i++) {
  4802. if (props[i].type === 7) {
  4803. props[i] = dirToAttr(props[i]);
  4804. }
  4805. }
  4806. }
  4807. }
  4808. },
  4809. ondirarg(start, end) {
  4810. if (start === end)
  4811. return;
  4812. const arg = getSlice(start, end);
  4813. if (inVPre) {
  4814. currentProp.name += arg;
  4815. setLocEnd(currentProp.nameLoc, end);
  4816. } else {
  4817. const isStatic = arg[0] !== `[`;
  4818. currentProp.arg = createExp(
  4819. isStatic ? arg : arg.slice(1, -1),
  4820. isStatic,
  4821. getLoc(start, end),
  4822. isStatic ? 3 : 0
  4823. );
  4824. }
  4825. },
  4826. ondirmodifier(start, end) {
  4827. const mod = getSlice(start, end);
  4828. if (inVPre) {
  4829. currentProp.name += "." + mod;
  4830. setLocEnd(currentProp.nameLoc, end);
  4831. } else if (currentProp.name === "slot") {
  4832. const arg = currentProp.arg;
  4833. if (arg) {
  4834. arg.content += "." + mod;
  4835. setLocEnd(arg.loc, end);
  4836. }
  4837. } else {
  4838. currentProp.modifiers.push(mod);
  4839. }
  4840. },
  4841. onattribdata(start, end) {
  4842. currentAttrValue += getSlice(start, end);
  4843. if (currentAttrStartIndex < 0)
  4844. currentAttrStartIndex = start;
  4845. currentAttrEndIndex = end;
  4846. },
  4847. onattribentity(char, start, end) {
  4848. currentAttrValue += char;
  4849. if (currentAttrStartIndex < 0)
  4850. currentAttrStartIndex = start;
  4851. currentAttrEndIndex = end;
  4852. },
  4853. onattribnameend(end) {
  4854. const start = currentProp.loc.start.offset;
  4855. const name = getSlice(start, end);
  4856. if (currentProp.type === 7) {
  4857. currentProp.rawName = name;
  4858. }
  4859. if (currentOpenTag.props.some(
  4860. (p) => (p.type === 7 ? p.rawName : p.name) === name
  4861. )) {
  4862. emitError(2, start);
  4863. }
  4864. },
  4865. onattribend(quote, end) {
  4866. if (currentOpenTag && currentProp) {
  4867. setLocEnd(currentProp.loc, end);
  4868. if (quote !== 0) {
  4869. if (currentAttrValue.includes("&")) {
  4870. currentAttrValue = currentOptions.decodeEntities(
  4871. currentAttrValue,
  4872. true
  4873. );
  4874. }
  4875. if (currentProp.type === 6) {
  4876. if (currentProp.name === "class") {
  4877. currentAttrValue = condense(currentAttrValue).trim();
  4878. }
  4879. if (quote === 1 && !currentAttrValue) {
  4880. emitError(13, end);
  4881. }
  4882. currentProp.value = {
  4883. type: 2,
  4884. content: currentAttrValue,
  4885. loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
  4886. };
  4887. if (tokenizer.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
  4888. tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
  4889. }
  4890. } else {
  4891. let expParseMode = 0;
  4892. currentProp.exp = createExp(
  4893. currentAttrValue,
  4894. false,
  4895. getLoc(currentAttrStartIndex, currentAttrEndIndex),
  4896. 0,
  4897. expParseMode
  4898. );
  4899. if (currentProp.name === "for") {
  4900. currentProp.forParseResult = parseForExpression(currentProp.exp);
  4901. }
  4902. let syncIndex = -1;
  4903. if (currentProp.name === "bind" && (syncIndex = currentProp.modifiers.indexOf("sync")) > -1 && checkCompatEnabled(
  4904. "COMPILER_V_BIND_SYNC",
  4905. currentOptions,
  4906. currentProp.loc,
  4907. currentProp.rawName
  4908. )) {
  4909. currentProp.name = "model";
  4910. currentProp.modifiers.splice(syncIndex, 1);
  4911. }
  4912. }
  4913. }
  4914. if (currentProp.type !== 7 || currentProp.name !== "pre") {
  4915. currentOpenTag.props.push(currentProp);
  4916. }
  4917. }
  4918. currentAttrValue = "";
  4919. currentAttrStartIndex = currentAttrEndIndex = -1;
  4920. },
  4921. oncomment(start, end) {
  4922. if (currentOptions.comments) {
  4923. addNode({
  4924. type: 3,
  4925. content: getSlice(start, end),
  4926. loc: getLoc(start - 4, end + 3)
  4927. });
  4928. }
  4929. },
  4930. onend() {
  4931. const end = currentInput.length;
  4932. if (tokenizer.state !== 1) {
  4933. switch (tokenizer.state) {
  4934. case 5:
  4935. case 8:
  4936. emitError(5, end);
  4937. break;
  4938. case 3:
  4939. case 4:
  4940. emitError(
  4941. 25,
  4942. tokenizer.sectionStart
  4943. );
  4944. break;
  4945. case 28:
  4946. if (tokenizer.currentSequence === Sequences.CdataEnd) {
  4947. emitError(6, end);
  4948. } else {
  4949. emitError(7, end);
  4950. }
  4951. break;
  4952. case 6:
  4953. case 7:
  4954. case 9:
  4955. case 11:
  4956. case 12:
  4957. case 13:
  4958. case 14:
  4959. case 15:
  4960. case 16:
  4961. case 17:
  4962. case 18:
  4963. case 19:
  4964. case 20:
  4965. case 21:
  4966. emitError(9, end);
  4967. break;
  4968. }
  4969. }
  4970. for (let index = 0; index < stack.length; index++) {
  4971. onCloseTag(stack[index], end - 1);
  4972. emitError(24, stack[index].loc.start.offset);
  4973. }
  4974. },
  4975. oncdata(start, end) {
  4976. if (stack[0].ns !== 0) {
  4977. onText(getSlice(start, end), start, end);
  4978. } else {
  4979. emitError(1, start - 9);
  4980. }
  4981. },
  4982. onprocessinginstruction(start) {
  4983. if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
  4984. emitError(
  4985. 21,
  4986. start - 1
  4987. );
  4988. }
  4989. }
  4990. });
  4991. forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  4992. stripParensRE = /^\(|\)$/g;
  4993. specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
  4994. windowsNewlineRE = /\r\n/g;
  4995. allowHoistedHelperSet = /* @__PURE__ */ new Set([
  4996. NORMALIZE_CLASS,
  4997. NORMALIZE_STYLE,
  4998. NORMALIZE_PROPS,
  4999. GUARD_REACTIVE_PROPS
  5000. ]);
  5001. PURE_ANNOTATION = `/*#__PURE__*/`;
  5002. aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
  5003. prohibitedKeywordRE = new RegExp(
  5004. "\\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"
  5005. );
  5006. stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  5007. transformExpression = (node, context) => {
  5008. if (node.type === 5) {
  5009. node.content = processExpression(
  5010. node.content,
  5011. context
  5012. );
  5013. } else if (node.type === 1) {
  5014. for (let i = 0; i < node.props.length; i++) {
  5015. const dir = node.props[i];
  5016. if (dir.type === 7 && dir.name !== "for") {
  5017. const exp = dir.exp;
  5018. const arg = dir.arg;
  5019. if (exp && exp.type === 4 && !(dir.name === "on" && arg)) {
  5020. dir.exp = processExpression(
  5021. exp,
  5022. context,
  5023. // slot args must be processed as function params
  5024. dir.name === "slot"
  5025. );
  5026. }
  5027. if (arg && arg.type === 4 && !arg.isStatic) {
  5028. dir.arg = processExpression(arg, context);
  5029. }
  5030. }
  5031. }
  5032. }
  5033. };
  5034. transformIf = createStructuralDirectiveTransform(
  5035. /^(if|else|else-if)$/,
  5036. (node, dir, context) => {
  5037. return processIf(node, dir, context, (ifNode, branch, isRoot) => {
  5038. const siblings = context.parent.children;
  5039. let i = siblings.indexOf(ifNode);
  5040. let key = 0;
  5041. while (i-- >= 0) {
  5042. const sibling = siblings[i];
  5043. if (sibling && sibling.type === 9) {
  5044. key += sibling.branches.length;
  5045. }
  5046. }
  5047. return () => {
  5048. if (isRoot) {
  5049. ifNode.codegenNode = createCodegenNodeForBranch(
  5050. branch,
  5051. key,
  5052. context
  5053. );
  5054. } else {
  5055. const parentCondition = getParentCondition(ifNode.codegenNode);
  5056. parentCondition.alternate = createCodegenNodeForBranch(
  5057. branch,
  5058. key + ifNode.branches.length - 1,
  5059. context
  5060. );
  5061. }
  5062. };
  5063. });
  5064. }
  5065. );
  5066. transformFor = createStructuralDirectiveTransform(
  5067. "for",
  5068. (node, dir, context) => {
  5069. const { helper, removeHelper } = context;
  5070. return processFor(node, dir, context, (forNode) => {
  5071. const renderExp = createCallExpression(helper(RENDER_LIST), [
  5072. forNode.source
  5073. ]);
  5074. const isTemplate = isTemplateNode(node);
  5075. const memo = findDir(node, "memo");
  5076. const keyProp = findProp(node, `key`);
  5077. const keyExp = keyProp && (keyProp.type === 6 ? createSimpleExpression(keyProp.value.content, true) : keyProp.exp);
  5078. const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
  5079. const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
  5080. const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
  5081. forNode.codegenNode = createVNodeCall(
  5082. context,
  5083. helper(FRAGMENT),
  5084. void 0,
  5085. renderExp,
  5086. fragmentFlag + (true ? ` /* ${PatchFlagNames[fragmentFlag]} */` : ``),
  5087. void 0,
  5088. void 0,
  5089. true,
  5090. !isStableFragment,
  5091. false,
  5092. node.loc
  5093. );
  5094. return () => {
  5095. let childBlock;
  5096. const { children } = forNode;
  5097. if (isTemplate) {
  5098. node.children.some((c) => {
  5099. if (c.type === 1) {
  5100. const key = findProp(c, "key");
  5101. if (key) {
  5102. context.onError(
  5103. createCompilerError(
  5104. 33,
  5105. key.loc
  5106. )
  5107. );
  5108. return true;
  5109. }
  5110. }
  5111. });
  5112. }
  5113. const needFragmentWrapper = children.length !== 1 || children[0].type !== 1;
  5114. const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
  5115. if (slotOutlet) {
  5116. childBlock = slotOutlet.codegenNode;
  5117. if (isTemplate && keyProperty) {
  5118. injectProp(childBlock, keyProperty, context);
  5119. }
  5120. } else if (needFragmentWrapper) {
  5121. childBlock = createVNodeCall(
  5122. context,
  5123. helper(FRAGMENT),
  5124. keyProperty ? createObjectExpression([keyProperty]) : void 0,
  5125. node.children,
  5126. 64 + (true ? ` /* ${PatchFlagNames[64]} */` : ``),
  5127. void 0,
  5128. void 0,
  5129. true,
  5130. void 0,
  5131. false
  5132. );
  5133. } else {
  5134. childBlock = children[0].codegenNode;
  5135. if (isTemplate && keyProperty) {
  5136. injectProp(childBlock, keyProperty, context);
  5137. }
  5138. if (childBlock.isBlock !== !isStableFragment) {
  5139. if (childBlock.isBlock) {
  5140. removeHelper(OPEN_BLOCK);
  5141. removeHelper(
  5142. getVNodeBlockHelper(context.inSSR, childBlock.isComponent)
  5143. );
  5144. } else {
  5145. removeHelper(
  5146. getVNodeHelper(context.inSSR, childBlock.isComponent)
  5147. );
  5148. }
  5149. }
  5150. childBlock.isBlock = !isStableFragment;
  5151. if (childBlock.isBlock) {
  5152. helper(OPEN_BLOCK);
  5153. helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
  5154. } else {
  5155. helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
  5156. }
  5157. }
  5158. if (memo) {
  5159. const loop = createFunctionExpression(
  5160. createForLoopParams(forNode.parseResult, [
  5161. createSimpleExpression(`_cached`)
  5162. ])
  5163. );
  5164. loop.body = createBlockStatement([
  5165. createCompoundExpression([`const _memo = (`, memo.exp, `)`]),
  5166. createCompoundExpression([
  5167. `if (_cached`,
  5168. ...keyExp ? [` && _cached.key === `, keyExp] : [],
  5169. ` && ${context.helperString(
  5170. IS_MEMO_SAME
  5171. )}(_cached, _memo)) return _cached`
  5172. ]),
  5173. createCompoundExpression([`const _item = `, childBlock]),
  5174. createSimpleExpression(`_item.memo = _memo`),
  5175. createSimpleExpression(`return _item`)
  5176. ]);
  5177. renderExp.arguments.push(
  5178. loop,
  5179. createSimpleExpression(`_cache`),
  5180. createSimpleExpression(String(context.cached++))
  5181. );
  5182. } else {
  5183. renderExp.arguments.push(
  5184. createFunctionExpression(
  5185. createForLoopParams(forNode.parseResult),
  5186. childBlock,
  5187. true
  5188. )
  5189. );
  5190. }
  5191. };
  5192. });
  5193. }
  5194. );
  5195. defaultFallback = createSimpleExpression(`undefined`, false);
  5196. trackSlotScopes = (node, context) => {
  5197. if (node.type === 1 && (node.tagType === 1 || node.tagType === 3)) {
  5198. const vSlot = findDir(node, "slot");
  5199. if (vSlot) {
  5200. vSlot.exp;
  5201. context.scopes.vSlot++;
  5202. return () => {
  5203. context.scopes.vSlot--;
  5204. };
  5205. }
  5206. }
  5207. };
  5208. trackVForSlotScopes = (node, context) => {
  5209. let vFor;
  5210. if (isTemplateNode(node) && node.props.some(isVSlot) && (vFor = findDir(node, "for"))) {
  5211. const result = vFor.forParseResult;
  5212. if (result) {
  5213. finalizeForParseResult(result, context);
  5214. const { value, key, index } = result;
  5215. const { addIdentifiers, removeIdentifiers } = context;
  5216. value && addIdentifiers(value);
  5217. key && addIdentifiers(key);
  5218. index && addIdentifiers(index);
  5219. return () => {
  5220. value && removeIdentifiers(value);
  5221. key && removeIdentifiers(key);
  5222. index && removeIdentifiers(index);
  5223. };
  5224. }
  5225. }
  5226. };
  5227. buildClientSlotFn = (props, _vForExp, children, loc) => createFunctionExpression(
  5228. props,
  5229. children,
  5230. false,
  5231. true,
  5232. children.length ? children[0].loc : loc
  5233. );
  5234. directiveImportMap = /* @__PURE__ */ new WeakMap();
  5235. transformElement = (node, context) => {
  5236. return function postTransformElement() {
  5237. node = context.currentNode;
  5238. if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1))) {
  5239. return;
  5240. }
  5241. const { tag, props } = node;
  5242. const isComponent2 = node.tagType === 1;
  5243. let vnodeTag = isComponent2 ? resolveComponentType(node, context) : `"${tag}"`;
  5244. const isDynamicComponent = isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
  5245. let vnodeProps;
  5246. let vnodeChildren;
  5247. let vnodePatchFlag;
  5248. let patchFlag = 0;
  5249. let vnodeDynamicProps;
  5250. let dynamicPropNames;
  5251. let vnodeDirectives;
  5252. let shouldUseBlock = (
  5253. // dynamic component may resolve to plain elements
  5254. isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent2 && // <svg> and <foreignObject> must be forced into blocks so that block
  5255. // updates inside get proper isSVG flag at runtime. (#639, #643)
  5256. // This is technically web-specific, but splitting the logic out of core
  5257. // leads to too much unnecessary complexity.
  5258. (tag === "svg" || tag === "foreignObject")
  5259. );
  5260. if (props.length > 0) {
  5261. const propsBuildResult = buildProps(
  5262. node,
  5263. context,
  5264. void 0,
  5265. isComponent2,
  5266. isDynamicComponent
  5267. );
  5268. vnodeProps = propsBuildResult.props;
  5269. patchFlag = propsBuildResult.patchFlag;
  5270. dynamicPropNames = propsBuildResult.dynamicPropNames;
  5271. const directives = propsBuildResult.directives;
  5272. vnodeDirectives = directives && directives.length ? createArrayExpression(
  5273. directives.map((dir) => buildDirectiveArgs(dir, context))
  5274. ) : void 0;
  5275. if (propsBuildResult.shouldUseBlock) {
  5276. shouldUseBlock = true;
  5277. }
  5278. }
  5279. if (node.children.length > 0) {
  5280. if (vnodeTag === KEEP_ALIVE) {
  5281. shouldUseBlock = true;
  5282. patchFlag |= 1024;
  5283. if (node.children.length > 1) {
  5284. context.onError(
  5285. createCompilerError(46, {
  5286. start: node.children[0].loc.start,
  5287. end: node.children[node.children.length - 1].loc.end,
  5288. source: ""
  5289. })
  5290. );
  5291. }
  5292. }
  5293. const shouldBuildAsSlots = isComponent2 && // Teleport is not a real component and has dedicated runtime handling
  5294. vnodeTag !== TELEPORT && // explained above.
  5295. vnodeTag !== KEEP_ALIVE;
  5296. if (shouldBuildAsSlots) {
  5297. const { slots, hasDynamicSlots } = buildSlots(node, context);
  5298. vnodeChildren = slots;
  5299. if (hasDynamicSlots) {
  5300. patchFlag |= 1024;
  5301. }
  5302. } else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
  5303. const child = node.children[0];
  5304. const type = child.type;
  5305. const hasDynamicTextChild = type === 5 || type === 8;
  5306. if (hasDynamicTextChild && getConstantType(child, context) === 0) {
  5307. patchFlag |= 1;
  5308. }
  5309. if (hasDynamicTextChild || type === 2) {
  5310. vnodeChildren = child;
  5311. } else {
  5312. vnodeChildren = node.children;
  5313. }
  5314. } else {
  5315. vnodeChildren = node.children;
  5316. }
  5317. }
  5318. if (patchFlag !== 0) {
  5319. if (true) {
  5320. if (patchFlag < 0) {
  5321. vnodePatchFlag = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
  5322. } else {
  5323. const flagNames = Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `);
  5324. vnodePatchFlag = patchFlag + ` /* ${flagNames} */`;
  5325. }
  5326. } else {
  5327. vnodePatchFlag = String(patchFlag);
  5328. }
  5329. if (dynamicPropNames && dynamicPropNames.length) {
  5330. vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
  5331. }
  5332. }
  5333. node.codegenNode = createVNodeCall(
  5334. context,
  5335. vnodeTag,
  5336. vnodeProps,
  5337. vnodeChildren,
  5338. vnodePatchFlag,
  5339. vnodeDynamicProps,
  5340. vnodeDirectives,
  5341. !!shouldUseBlock,
  5342. false,
  5343. isComponent2,
  5344. node.loc
  5345. );
  5346. };
  5347. };
  5348. transformSlotOutlet = (node, context) => {
  5349. if (isSlotOutlet(node)) {
  5350. const { children, loc } = node;
  5351. const { slotName, slotProps } = processSlotOutlet(node, context);
  5352. const slotArgs = [
  5353. context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
  5354. slotName,
  5355. "{}",
  5356. "undefined",
  5357. "true"
  5358. ];
  5359. let expectedLen = 2;
  5360. if (slotProps) {
  5361. slotArgs[2] = slotProps;
  5362. expectedLen = 3;
  5363. }
  5364. if (children.length) {
  5365. slotArgs[3] = createFunctionExpression([], children, false, false, loc);
  5366. expectedLen = 4;
  5367. }
  5368. if (context.scopeId && !context.slotted) {
  5369. expectedLen = 5;
  5370. }
  5371. slotArgs.splice(expectedLen);
  5372. node.codegenNode = createCallExpression(
  5373. context.helper(RENDER_SLOT),
  5374. slotArgs,
  5375. loc
  5376. );
  5377. }
  5378. };
  5379. fnExpRE = /^\s*(async\s*)?(\([^)]*?\)|[\w$_]+)\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
  5380. transformOn = (dir, node, context, augmentor) => {
  5381. const { loc, modifiers, arg } = dir;
  5382. if (!dir.exp && !modifiers.length) {
  5383. context.onError(createCompilerError(35, loc));
  5384. }
  5385. let eventName;
  5386. if (arg.type === 4) {
  5387. if (arg.isStatic) {
  5388. let rawName = arg.content;
  5389. if (rawName.startsWith("vnode")) {
  5390. context.onError(createCompilerError(51, arg.loc));
  5391. }
  5392. if (rawName.startsWith("vue:")) {
  5393. rawName = `vnode-${rawName.slice(4)}`;
  5394. }
  5395. const eventString = node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? (
  5396. // for non-element and vnode lifecycle event listeners, auto convert
  5397. // it to camelCase. See issue #2249
  5398. toHandlerKey(camelize(rawName))
  5399. ) : (
  5400. // preserve case for plain element listeners that have uppercase
  5401. // letters, as these may be custom elements' custom events
  5402. `on:${rawName}`
  5403. );
  5404. eventName = createSimpleExpression(eventString, true, arg.loc);
  5405. } else {
  5406. eventName = createCompoundExpression([
  5407. `${context.helperString(TO_HANDLER_KEY)}(`,
  5408. arg,
  5409. `)`
  5410. ]);
  5411. }
  5412. } else {
  5413. eventName = arg;
  5414. eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
  5415. eventName.children.push(`)`);
  5416. }
  5417. let exp = dir.exp;
  5418. if (exp && !exp.content.trim()) {
  5419. exp = void 0;
  5420. }
  5421. let shouldCache = context.cacheHandlers && !exp && !context.inVOnce;
  5422. if (exp) {
  5423. const isMemberExp = isMemberExpression(exp.content);
  5424. const isInlineStatement = !(isMemberExp || fnExpRE.test(exp.content));
  5425. const hasMultipleStatements = exp.content.includes(`;`);
  5426. if (true) {
  5427. validateBrowserExpression(
  5428. exp,
  5429. context,
  5430. false,
  5431. hasMultipleStatements
  5432. );
  5433. }
  5434. if (isInlineStatement || shouldCache && isMemberExp) {
  5435. exp = createCompoundExpression([
  5436. `${isInlineStatement ? `$event` : `${``}(...args)`} => ${hasMultipleStatements ? `{` : `(`}`,
  5437. exp,
  5438. hasMultipleStatements ? `}` : `)`
  5439. ]);
  5440. }
  5441. }
  5442. let ret = {
  5443. props: [
  5444. createObjectProperty(
  5445. eventName,
  5446. exp || createSimpleExpression(`() => {}`, false, loc)
  5447. )
  5448. ]
  5449. };
  5450. if (augmentor) {
  5451. ret = augmentor(ret);
  5452. }
  5453. if (shouldCache) {
  5454. ret.props[0].value = context.cache(ret.props[0].value);
  5455. }
  5456. ret.props.forEach((p) => p.key.isHandlerKey = true);
  5457. return ret;
  5458. };
  5459. transformBind = (dir, _node, context) => {
  5460. const { modifiers, loc } = dir;
  5461. const arg = dir.arg;
  5462. let { exp } = dir;
  5463. if (exp && exp.type === 4 && !exp.content.trim()) {
  5464. {
  5465. exp = void 0;
  5466. }
  5467. }
  5468. if (!exp) {
  5469. if (arg.type !== 4 || !arg.isStatic) {
  5470. context.onError(
  5471. createCompilerError(
  5472. 52,
  5473. arg.loc
  5474. )
  5475. );
  5476. return {
  5477. props: [
  5478. createObjectProperty(arg, createSimpleExpression("", true, loc))
  5479. ]
  5480. };
  5481. }
  5482. const propName = camelize(arg.content);
  5483. exp = dir.exp = createSimpleExpression(propName, false, arg.loc);
  5484. }
  5485. if (arg.type !== 4) {
  5486. arg.children.unshift(`(`);
  5487. arg.children.push(`) || ""`);
  5488. } else if (!arg.isStatic) {
  5489. arg.content = `${arg.content} || ""`;
  5490. }
  5491. if (modifiers.includes("camel")) {
  5492. if (arg.type === 4) {
  5493. if (arg.isStatic) {
  5494. arg.content = camelize(arg.content);
  5495. } else {
  5496. arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
  5497. }
  5498. } else {
  5499. arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
  5500. arg.children.push(`)`);
  5501. }
  5502. }
  5503. if (!context.inSSR) {
  5504. if (modifiers.includes("prop")) {
  5505. injectPrefix(arg, ".");
  5506. }
  5507. if (modifiers.includes("attr")) {
  5508. injectPrefix(arg, "^");
  5509. }
  5510. }
  5511. return {
  5512. props: [createObjectProperty(arg, exp)]
  5513. };
  5514. };
  5515. injectPrefix = (arg, prefix) => {
  5516. if (arg.type === 4) {
  5517. if (arg.isStatic) {
  5518. arg.content = prefix + arg.content;
  5519. } else {
  5520. arg.content = `\`${prefix}\${${arg.content}}\``;
  5521. }
  5522. } else {
  5523. arg.children.unshift(`'${prefix}' + (`);
  5524. arg.children.push(`)`);
  5525. }
  5526. };
  5527. transformText = (node, context) => {
  5528. if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
  5529. return () => {
  5530. const children = node.children;
  5531. let currentContainer = void 0;
  5532. let hasText = false;
  5533. for (let i = 0; i < children.length; i++) {
  5534. const child = children[i];
  5535. if (isText$1(child)) {
  5536. hasText = true;
  5537. for (let j = i + 1; j < children.length; j++) {
  5538. const next = children[j];
  5539. if (isText$1(next)) {
  5540. if (!currentContainer) {
  5541. currentContainer = children[i] = createCompoundExpression(
  5542. [child],
  5543. child.loc
  5544. );
  5545. }
  5546. currentContainer.children.push(` + `, next);
  5547. children.splice(j, 1);
  5548. j--;
  5549. } else {
  5550. currentContainer = void 0;
  5551. break;
  5552. }
  5553. }
  5554. }
  5555. }
  5556. if (!hasText || // if this is a plain element with a single text child, leave it
  5557. // as-is since the runtime has dedicated fast path for this by directly
  5558. // setting textContent of the element.
  5559. // for component root it's always normalized anyway.
  5560. children.length === 1 && (node.type === 0 || node.type === 1 && node.tagType === 0 && // #3756
  5561. // custom directives can potentially add DOM elements arbitrarily,
  5562. // we need to avoid setting textContent of the element at runtime
  5563. // to avoid accidentally overwriting the DOM elements added
  5564. // by the user through custom directives.
  5565. !node.props.find(
  5566. (p) => p.type === 7 && !context.directiveTransforms[p.name]
  5567. ) && // in compat mode, <template> tags with no special directives
  5568. // will be rendered as a fragment so its children must be
  5569. // converted into vnodes.
  5570. !(node.tag === "template"))) {
  5571. return;
  5572. }
  5573. for (let i = 0; i < children.length; i++) {
  5574. const child = children[i];
  5575. if (isText$1(child) || child.type === 8) {
  5576. const callArgs = [];
  5577. if (child.type !== 2 || child.content !== " ") {
  5578. callArgs.push(child);
  5579. }
  5580. if (!context.ssr && getConstantType(child, context) === 0) {
  5581. callArgs.push(
  5582. 1 + (true ? ` /* ${PatchFlagNames[1]} */` : ``)
  5583. );
  5584. }
  5585. children[i] = {
  5586. type: 12,
  5587. content: child,
  5588. loc: child.loc,
  5589. codegenNode: createCallExpression(
  5590. context.helper(CREATE_TEXT),
  5591. callArgs
  5592. )
  5593. };
  5594. }
  5595. }
  5596. };
  5597. }
  5598. };
  5599. seen$1 = /* @__PURE__ */ new WeakSet();
  5600. transformOnce = (node, context) => {
  5601. if (node.type === 1 && findDir(node, "once", true)) {
  5602. if (seen$1.has(node) || context.inVOnce || context.inSSR) {
  5603. return;
  5604. }
  5605. seen$1.add(node);
  5606. context.inVOnce = true;
  5607. context.helper(SET_BLOCK_TRACKING);
  5608. return () => {
  5609. context.inVOnce = false;
  5610. const cur = context.currentNode;
  5611. if (cur.codegenNode) {
  5612. cur.codegenNode = context.cache(
  5613. cur.codegenNode,
  5614. true
  5615. /* isVNode */
  5616. );
  5617. }
  5618. };
  5619. }
  5620. };
  5621. transformModel = (dir, node, context) => {
  5622. const { exp, arg } = dir;
  5623. if (!exp) {
  5624. context.onError(
  5625. createCompilerError(41, dir.loc)
  5626. );
  5627. return createTransformProps();
  5628. }
  5629. const rawExp = exp.loc.source;
  5630. const expString = exp.type === 4 ? exp.content : rawExp;
  5631. const bindingType = context.bindingMetadata[rawExp];
  5632. if (bindingType === "props" || bindingType === "props-aliased") {
  5633. context.onError(createCompilerError(44, exp.loc));
  5634. return createTransformProps();
  5635. }
  5636. const maybeRef = false;
  5637. if (!expString.trim() || !isMemberExpression(expString) && !maybeRef) {
  5638. context.onError(
  5639. createCompilerError(42, exp.loc)
  5640. );
  5641. return createTransformProps();
  5642. }
  5643. const propName = arg ? arg : createSimpleExpression("modelValue", true);
  5644. const eventName = arg ? isStaticExp(arg) ? `onUpdate:${camelize(arg.content)}` : createCompoundExpression(['"onUpdate:" + ', arg]) : `onUpdate:modelValue`;
  5645. let assignmentExp;
  5646. const eventArg = context.isTS ? `($event: any)` : `$event`;
  5647. {
  5648. assignmentExp = createCompoundExpression([
  5649. `${eventArg} => ((`,
  5650. exp,
  5651. `) = $event)`
  5652. ]);
  5653. }
  5654. const props = [
  5655. // modelValue: foo
  5656. createObjectProperty(propName, dir.exp),
  5657. // "onUpdate:modelValue": $event => (foo = $event)
  5658. createObjectProperty(eventName, assignmentExp)
  5659. ];
  5660. if (dir.modifiers.length && node.tagType === 1) {
  5661. const modifiers = dir.modifiers.map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
  5662. const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
  5663. props.push(
  5664. createObjectProperty(
  5665. modifiersKey,
  5666. createSimpleExpression(
  5667. `{ ${modifiers} }`,
  5668. false,
  5669. dir.loc,
  5670. 2
  5671. )
  5672. )
  5673. );
  5674. }
  5675. return createTransformProps(props);
  5676. };
  5677. validDivisionCharRE = /[\w).+\-_$\]]/;
  5678. transformFilter = (node, context) => {
  5679. if (!isCompatEnabled("COMPILER_FILTERS", context)) {
  5680. return;
  5681. }
  5682. if (node.type === 5) {
  5683. rewriteFilter(node.content, context);
  5684. }
  5685. if (node.type === 1) {
  5686. node.props.forEach((prop) => {
  5687. if (prop.type === 7 && prop.name !== "for" && prop.exp) {
  5688. rewriteFilter(prop.exp, context);
  5689. }
  5690. });
  5691. }
  5692. };
  5693. seen = /* @__PURE__ */ new WeakSet();
  5694. transformMemo = (node, context) => {
  5695. if (node.type === 1) {
  5696. const dir = findDir(node, "memo");
  5697. if (!dir || seen.has(node)) {
  5698. return;
  5699. }
  5700. seen.add(node);
  5701. return () => {
  5702. const codegenNode = node.codegenNode || context.currentNode.codegenNode;
  5703. if (codegenNode && codegenNode.type === 13) {
  5704. if (node.tagType !== 1) {
  5705. convertToBlock(codegenNode, context);
  5706. }
  5707. node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
  5708. dir.exp,
  5709. createFunctionExpression(void 0, codegenNode),
  5710. `_cache`,
  5711. String(context.cached++)
  5712. ]);
  5713. }
  5714. };
  5715. }
  5716. };
  5717. BindingTypes = {
  5718. "DATA": "data",
  5719. "PROPS": "props",
  5720. "PROPS_ALIASED": "props-aliased",
  5721. "SETUP_LET": "setup-let",
  5722. "SETUP_CONST": "setup-const",
  5723. "SETUP_REACTIVE_CONST": "setup-reactive-const",
  5724. "SETUP_MAYBE_REF": "setup-maybe-ref",
  5725. "SETUP_REF": "setup-ref",
  5726. "OPTIONS": "options",
  5727. "LITERAL_CONST": "literal-const"
  5728. };
  5729. noopDirectiveTransform = () => ({ props: [] });
  5730. }
  5731. });
  5732. // node_modules/.pnpm/@vue+compiler-dom@3.4.27/node_modules/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js
  5733. var compiler_dom_esm_bundler_exports = {};
  5734. __export(compiler_dom_esm_bundler_exports, {
  5735. BASE_TRANSITION: () => BASE_TRANSITION,
  5736. BindingTypes: () => BindingTypes,
  5737. CAMELIZE: () => CAMELIZE,
  5738. CAPITALIZE: () => CAPITALIZE,
  5739. CREATE_BLOCK: () => CREATE_BLOCK,
  5740. CREATE_COMMENT: () => CREATE_COMMENT,
  5741. CREATE_ELEMENT_BLOCK: () => CREATE_ELEMENT_BLOCK,
  5742. CREATE_ELEMENT_VNODE: () => CREATE_ELEMENT_VNODE,
  5743. CREATE_SLOTS: () => CREATE_SLOTS,
  5744. CREATE_STATIC: () => CREATE_STATIC,
  5745. CREATE_TEXT: () => CREATE_TEXT,
  5746. CREATE_VNODE: () => CREATE_VNODE,
  5747. CompilerDeprecationTypes: () => CompilerDeprecationTypes,
  5748. ConstantTypes: () => ConstantTypes,
  5749. DOMDirectiveTransforms: () => DOMDirectiveTransforms,
  5750. DOMErrorCodes: () => DOMErrorCodes,
  5751. DOMErrorMessages: () => DOMErrorMessages,
  5752. DOMNodeTransforms: () => DOMNodeTransforms,
  5753. ElementTypes: () => ElementTypes,
  5754. ErrorCodes: () => ErrorCodes,
  5755. FRAGMENT: () => FRAGMENT,
  5756. GUARD_REACTIVE_PROPS: () => GUARD_REACTIVE_PROPS,
  5757. IS_MEMO_SAME: () => IS_MEMO_SAME,
  5758. IS_REF: () => IS_REF,
  5759. KEEP_ALIVE: () => KEEP_ALIVE,
  5760. MERGE_PROPS: () => MERGE_PROPS,
  5761. NORMALIZE_CLASS: () => NORMALIZE_CLASS,
  5762. NORMALIZE_PROPS: () => NORMALIZE_PROPS,
  5763. NORMALIZE_STYLE: () => NORMALIZE_STYLE,
  5764. Namespaces: () => Namespaces,
  5765. NodeTypes: () => NodeTypes,
  5766. OPEN_BLOCK: () => OPEN_BLOCK,
  5767. POP_SCOPE_ID: () => POP_SCOPE_ID,
  5768. PUSH_SCOPE_ID: () => PUSH_SCOPE_ID,
  5769. RENDER_LIST: () => RENDER_LIST,
  5770. RENDER_SLOT: () => RENDER_SLOT,
  5771. RESOLVE_COMPONENT: () => RESOLVE_COMPONENT,
  5772. RESOLVE_DIRECTIVE: () => RESOLVE_DIRECTIVE,
  5773. RESOLVE_DYNAMIC_COMPONENT: () => RESOLVE_DYNAMIC_COMPONENT,
  5774. RESOLVE_FILTER: () => RESOLVE_FILTER,
  5775. SET_BLOCK_TRACKING: () => SET_BLOCK_TRACKING,
  5776. SUSPENSE: () => SUSPENSE,
  5777. TELEPORT: () => TELEPORT,
  5778. TO_DISPLAY_STRING: () => TO_DISPLAY_STRING,
  5779. TO_HANDLERS: () => TO_HANDLERS,
  5780. TO_HANDLER_KEY: () => TO_HANDLER_KEY,
  5781. TRANSITION: () => TRANSITION,
  5782. TRANSITION_GROUP: () => TRANSITION_GROUP,
  5783. TS_NODE_TYPES: () => TS_NODE_TYPES,
  5784. UNREF: () => UNREF,
  5785. V_MODEL_CHECKBOX: () => V_MODEL_CHECKBOX,
  5786. V_MODEL_DYNAMIC: () => V_MODEL_DYNAMIC,
  5787. V_MODEL_RADIO: () => V_MODEL_RADIO,
  5788. V_MODEL_SELECT: () => V_MODEL_SELECT,
  5789. V_MODEL_TEXT: () => V_MODEL_TEXT,
  5790. V_ON_WITH_KEYS: () => V_ON_WITH_KEYS,
  5791. V_ON_WITH_MODIFIERS: () => V_ON_WITH_MODIFIERS,
  5792. V_SHOW: () => V_SHOW,
  5793. WITH_CTX: () => WITH_CTX,
  5794. WITH_DIRECTIVES: () => WITH_DIRECTIVES,
  5795. WITH_MEMO: () => WITH_MEMO,
  5796. advancePositionWithClone: () => advancePositionWithClone,
  5797. advancePositionWithMutation: () => advancePositionWithMutation,
  5798. assert: () => assert,
  5799. baseCompile: () => baseCompile,
  5800. baseParse: () => baseParse,
  5801. buildDirectiveArgs: () => buildDirectiveArgs,
  5802. buildProps: () => buildProps,
  5803. buildSlots: () => buildSlots,
  5804. checkCompatEnabled: () => checkCompatEnabled,
  5805. compile: () => compile,
  5806. convertToBlock: () => convertToBlock,
  5807. createArrayExpression: () => createArrayExpression,
  5808. createAssignmentExpression: () => createAssignmentExpression,
  5809. createBlockStatement: () => createBlockStatement,
  5810. createCacheExpression: () => createCacheExpression,
  5811. createCallExpression: () => createCallExpression,
  5812. createCompilerError: () => createCompilerError,
  5813. createCompoundExpression: () => createCompoundExpression,
  5814. createConditionalExpression: () => createConditionalExpression,
  5815. createDOMCompilerError: () => createDOMCompilerError,
  5816. createForLoopParams: () => createForLoopParams,
  5817. createFunctionExpression: () => createFunctionExpression,
  5818. createIfStatement: () => createIfStatement,
  5819. createInterpolation: () => createInterpolation,
  5820. createObjectExpression: () => createObjectExpression,
  5821. createObjectProperty: () => createObjectProperty,
  5822. createReturnStatement: () => createReturnStatement,
  5823. createRoot: () => createRoot,
  5824. createSequenceExpression: () => createSequenceExpression,
  5825. createSimpleExpression: () => createSimpleExpression,
  5826. createStructuralDirectiveTransform: () => createStructuralDirectiveTransform,
  5827. createTemplateLiteral: () => createTemplateLiteral,
  5828. createTransformContext: () => createTransformContext,
  5829. createVNodeCall: () => createVNodeCall,
  5830. errorMessages: () => errorMessages,
  5831. extractIdentifiers: () => extractIdentifiers,
  5832. findDir: () => findDir,
  5833. findProp: () => findProp,
  5834. forAliasRE: () => forAliasRE,
  5835. generate: () => generate,
  5836. generateCodeFrame: () => generateCodeFrame,
  5837. getBaseTransformPreset: () => getBaseTransformPreset,
  5838. getConstantType: () => getConstantType,
  5839. getMemoedVNodeCall: () => getMemoedVNodeCall,
  5840. getVNodeBlockHelper: () => getVNodeBlockHelper,
  5841. getVNodeHelper: () => getVNodeHelper,
  5842. hasDynamicKeyVBind: () => hasDynamicKeyVBind,
  5843. hasScopeRef: () => hasScopeRef,
  5844. helperNameMap: () => helperNameMap,
  5845. injectProp: () => injectProp,
  5846. isCoreComponent: () => isCoreComponent,
  5847. isFunctionType: () => isFunctionType,
  5848. isInDestructureAssignment: () => isInDestructureAssignment,
  5849. isInNewExpression: () => isInNewExpression,
  5850. isMemberExpression: () => isMemberExpression,
  5851. isMemberExpressionBrowser: () => isMemberExpressionBrowser,
  5852. isMemberExpressionNode: () => isMemberExpressionNode,
  5853. isReferencedIdentifier: () => isReferencedIdentifier,
  5854. isSimpleIdentifier: () => isSimpleIdentifier,
  5855. isSlotOutlet: () => isSlotOutlet,
  5856. isStaticArgOf: () => isStaticArgOf,
  5857. isStaticExp: () => isStaticExp,
  5858. isStaticProperty: () => isStaticProperty,
  5859. isStaticPropertyKey: () => isStaticPropertyKey,
  5860. isTemplateNode: () => isTemplateNode,
  5861. isText: () => isText$1,
  5862. isVSlot: () => isVSlot,
  5863. locStub: () => locStub,
  5864. noopDirectiveTransform: () => noopDirectiveTransform,
  5865. parse: () => parse,
  5866. parserOptions: () => parserOptions,
  5867. processExpression: () => processExpression,
  5868. processFor: () => processFor,
  5869. processIf: () => processIf,
  5870. processSlotOutlet: () => processSlotOutlet,
  5871. registerRuntimeHelpers: () => registerRuntimeHelpers,
  5872. resolveComponentType: () => resolveComponentType,
  5873. stringifyExpression: () => stringifyExpression,
  5874. toValidAssetId: () => toValidAssetId,
  5875. trackSlotScopes: () => trackSlotScopes,
  5876. trackVForSlotScopes: () => trackVForSlotScopes,
  5877. transform: () => transform,
  5878. transformBind: () => transformBind,
  5879. transformElement: () => transformElement,
  5880. transformExpression: () => transformExpression,
  5881. transformModel: () => transformModel,
  5882. transformOn: () => transformOn,
  5883. transformStyle: () => transformStyle,
  5884. traverseNode: () => traverseNode,
  5885. unwrapTSNode: () => unwrapTSNode,
  5886. walkBlockDeclarations: () => walkBlockDeclarations,
  5887. walkFunctionParams: () => walkFunctionParams,
  5888. walkIdentifiers: () => walkIdentifiers,
  5889. warnDeprecation: () => warnDeprecation
  5890. });
  5891. function decodeHtmlBrowser(raw, asAttr = false) {
  5892. if (!decoder) {
  5893. decoder = document.createElement("div");
  5894. }
  5895. if (asAttr) {
  5896. decoder.innerHTML = `<div foo="${raw.replace(/"/g, "&quot;")}">`;
  5897. return decoder.children[0].getAttribute("foo");
  5898. } else {
  5899. decoder.innerHTML = raw;
  5900. return decoder.textContent;
  5901. }
  5902. }
  5903. function createDOMCompilerError(code, loc) {
  5904. return createCompilerError(
  5905. code,
  5906. loc,
  5907. true ? DOMErrorMessages : void 0
  5908. );
  5909. }
  5910. function hasMultipleChildren(node) {
  5911. const children = node.children = node.children.filter(
  5912. (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
  5913. );
  5914. const child = children[0];
  5915. return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
  5916. }
  5917. function compile(src, options = {}) {
  5918. return baseCompile(
  5919. src,
  5920. extend({}, parserOptions, options, {
  5921. nodeTransforms: [
  5922. // ignore <script> and <tag>
  5923. // this is not put inside DOMNodeTransforms because that list is used
  5924. // by compiler-ssr to generate vnode fallback branches
  5925. ignoreSideEffectTags,
  5926. ...DOMNodeTransforms,
  5927. ...options.nodeTransforms || []
  5928. ],
  5929. directiveTransforms: extend(
  5930. {},
  5931. DOMDirectiveTransforms,
  5932. options.directiveTransforms || {}
  5933. ),
  5934. transformHoist: null
  5935. })
  5936. );
  5937. }
  5938. function parse(template, options = {}) {
  5939. return baseParse(template, extend({}, parserOptions, options));
  5940. }
  5941. var V_MODEL_RADIO, V_MODEL_CHECKBOX, V_MODEL_TEXT, V_MODEL_SELECT, V_MODEL_DYNAMIC, V_ON_WITH_MODIFIERS, V_ON_WITH_KEYS, V_SHOW, TRANSITION, TRANSITION_GROUP, decoder, parserOptions, transformStyle, parseInlineCSS, DOMErrorCodes, DOMErrorMessages, transformVHtml, transformVText, transformModel2, isEventOptionModifier, isNonKeyModifier, maybeKeyModifier, isKeyboardEvent, resolveModifiers, transformClick, transformOn2, transformShow, transformTransition, ignoreSideEffectTags, DOMNodeTransforms, DOMDirectiveTransforms;
  5942. var init_compiler_dom_esm_bundler = __esm({
  5943. "node_modules/.pnpm/@vue+compiler-dom@3.4.27/node_modules/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js"() {
  5944. init_compiler_core_esm_bundler();
  5945. init_compiler_core_esm_bundler();
  5946. init_shared_esm_bundler();
  5947. V_MODEL_RADIO = Symbol(true ? `vModelRadio` : ``);
  5948. V_MODEL_CHECKBOX = Symbol(true ? `vModelCheckbox` : ``);
  5949. V_MODEL_TEXT = Symbol(true ? `vModelText` : ``);
  5950. V_MODEL_SELECT = Symbol(true ? `vModelSelect` : ``);
  5951. V_MODEL_DYNAMIC = Symbol(true ? `vModelDynamic` : ``);
  5952. V_ON_WITH_MODIFIERS = Symbol(true ? `vOnModifiersGuard` : ``);
  5953. V_ON_WITH_KEYS = Symbol(true ? `vOnKeysGuard` : ``);
  5954. V_SHOW = Symbol(true ? `vShow` : ``);
  5955. TRANSITION = Symbol(true ? `Transition` : ``);
  5956. TRANSITION_GROUP = Symbol(true ? `TransitionGroup` : ``);
  5957. registerRuntimeHelpers({
  5958. [V_MODEL_RADIO]: `vModelRadio`,
  5959. [V_MODEL_CHECKBOX]: `vModelCheckbox`,
  5960. [V_MODEL_TEXT]: `vModelText`,
  5961. [V_MODEL_SELECT]: `vModelSelect`,
  5962. [V_MODEL_DYNAMIC]: `vModelDynamic`,
  5963. [V_ON_WITH_MODIFIERS]: `withModifiers`,
  5964. [V_ON_WITH_KEYS]: `withKeys`,
  5965. [V_SHOW]: `vShow`,
  5966. [TRANSITION]: `Transition`,
  5967. [TRANSITION_GROUP]: `TransitionGroup`
  5968. });
  5969. parserOptions = {
  5970. parseMode: "html",
  5971. isVoidTag,
  5972. isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
  5973. isPreTag: (tag) => tag === "pre",
  5974. decodeEntities: decodeHtmlBrowser,
  5975. isBuiltInComponent: (tag) => {
  5976. if (tag === "Transition" || tag === "transition") {
  5977. return TRANSITION;
  5978. } else if (tag === "TransitionGroup" || tag === "transition-group") {
  5979. return TRANSITION_GROUP;
  5980. }
  5981. },
  5982. // https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
  5983. getNamespace(tag, parent, rootNamespace) {
  5984. let ns = parent ? parent.ns : rootNamespace;
  5985. if (parent && ns === 2) {
  5986. if (parent.tag === "annotation-xml") {
  5987. if (tag === "svg") {
  5988. return 1;
  5989. }
  5990. if (parent.props.some(
  5991. (a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
  5992. )) {
  5993. ns = 0;
  5994. }
  5995. } else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
  5996. ns = 0;
  5997. }
  5998. } else if (parent && ns === 1) {
  5999. if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
  6000. ns = 0;
  6001. }
  6002. }
  6003. if (ns === 0) {
  6004. if (tag === "svg") {
  6005. return 1;
  6006. }
  6007. if (tag === "math") {
  6008. return 2;
  6009. }
  6010. }
  6011. return ns;
  6012. }
  6013. };
  6014. transformStyle = (node) => {
  6015. if (node.type === 1) {
  6016. node.props.forEach((p, i) => {
  6017. if (p.type === 6 && p.name === "style" && p.value) {
  6018. node.props[i] = {
  6019. type: 7,
  6020. name: `bind`,
  6021. arg: createSimpleExpression(`style`, true, p.loc),
  6022. exp: parseInlineCSS(p.value.content, p.loc),
  6023. modifiers: [],
  6024. loc: p.loc
  6025. };
  6026. }
  6027. });
  6028. }
  6029. };
  6030. parseInlineCSS = (cssText, loc) => {
  6031. const normalized = parseStringStyle(cssText);
  6032. return createSimpleExpression(
  6033. JSON.stringify(normalized),
  6034. false,
  6035. loc,
  6036. 3
  6037. );
  6038. };
  6039. DOMErrorCodes = {
  6040. "X_V_HTML_NO_EXPRESSION": 53,
  6041. "53": "X_V_HTML_NO_EXPRESSION",
  6042. "X_V_HTML_WITH_CHILDREN": 54,
  6043. "54": "X_V_HTML_WITH_CHILDREN",
  6044. "X_V_TEXT_NO_EXPRESSION": 55,
  6045. "55": "X_V_TEXT_NO_EXPRESSION",
  6046. "X_V_TEXT_WITH_CHILDREN": 56,
  6047. "56": "X_V_TEXT_WITH_CHILDREN",
  6048. "X_V_MODEL_ON_INVALID_ELEMENT": 57,
  6049. "57": "X_V_MODEL_ON_INVALID_ELEMENT",
  6050. "X_V_MODEL_ARG_ON_ELEMENT": 58,
  6051. "58": "X_V_MODEL_ARG_ON_ELEMENT",
  6052. "X_V_MODEL_ON_FILE_INPUT_ELEMENT": 59,
  6053. "59": "X_V_MODEL_ON_FILE_INPUT_ELEMENT",
  6054. "X_V_MODEL_UNNECESSARY_VALUE": 60,
  6055. "60": "X_V_MODEL_UNNECESSARY_VALUE",
  6056. "X_V_SHOW_NO_EXPRESSION": 61,
  6057. "61": "X_V_SHOW_NO_EXPRESSION",
  6058. "X_TRANSITION_INVALID_CHILDREN": 62,
  6059. "62": "X_TRANSITION_INVALID_CHILDREN",
  6060. "X_IGNORED_SIDE_EFFECT_TAG": 63,
  6061. "63": "X_IGNORED_SIDE_EFFECT_TAG",
  6062. "__EXTEND_POINT__": 64,
  6063. "64": "__EXTEND_POINT__"
  6064. };
  6065. DOMErrorMessages = {
  6066. [53]: `v-html is missing expression.`,
  6067. [54]: `v-html will override element children.`,
  6068. [55]: `v-text is missing expression.`,
  6069. [56]: `v-text will override element children.`,
  6070. [57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
  6071. [58]: `v-model argument is not supported on plain elements.`,
  6072. [59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
  6073. [60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
  6074. [61]: `v-show is missing expression.`,
  6075. [62]: `<Transition> expects exactly one child element or component.`,
  6076. [63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
  6077. };
  6078. transformVHtml = (dir, node, context) => {
  6079. const { exp, loc } = dir;
  6080. if (!exp) {
  6081. context.onError(
  6082. createDOMCompilerError(53, loc)
  6083. );
  6084. }
  6085. if (node.children.length) {
  6086. context.onError(
  6087. createDOMCompilerError(54, loc)
  6088. );
  6089. node.children.length = 0;
  6090. }
  6091. return {
  6092. props: [
  6093. createObjectProperty(
  6094. createSimpleExpression(`innerHTML`, true, loc),
  6095. exp || createSimpleExpression("", true)
  6096. )
  6097. ]
  6098. };
  6099. };
  6100. transformVText = (dir, node, context) => {
  6101. const { exp, loc } = dir;
  6102. if (!exp) {
  6103. context.onError(
  6104. createDOMCompilerError(55, loc)
  6105. );
  6106. }
  6107. if (node.children.length) {
  6108. context.onError(
  6109. createDOMCompilerError(56, loc)
  6110. );
  6111. node.children.length = 0;
  6112. }
  6113. return {
  6114. props: [
  6115. createObjectProperty(
  6116. createSimpleExpression(`textContent`, true),
  6117. exp ? getConstantType(exp, context) > 0 ? exp : createCallExpression(
  6118. context.helperString(TO_DISPLAY_STRING),
  6119. [exp],
  6120. loc
  6121. ) : createSimpleExpression("", true)
  6122. )
  6123. ]
  6124. };
  6125. };
  6126. transformModel2 = (dir, node, context) => {
  6127. const baseResult = transformModel(dir, node, context);
  6128. if (!baseResult.props.length || node.tagType === 1) {
  6129. return baseResult;
  6130. }
  6131. if (dir.arg) {
  6132. context.onError(
  6133. createDOMCompilerError(
  6134. 58,
  6135. dir.arg.loc
  6136. )
  6137. );
  6138. }
  6139. function checkDuplicatedValue() {
  6140. const value = findDir(node, "bind");
  6141. if (value && isStaticArgOf(value.arg, "value")) {
  6142. context.onError(
  6143. createDOMCompilerError(
  6144. 60,
  6145. value.loc
  6146. )
  6147. );
  6148. }
  6149. }
  6150. const { tag } = node;
  6151. const isCustomElement = context.isCustomElement(tag);
  6152. if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
  6153. let directiveToUse = V_MODEL_TEXT;
  6154. let isInvalidType = false;
  6155. if (tag === "input" || isCustomElement) {
  6156. const type = findProp(node, `type`);
  6157. if (type) {
  6158. if (type.type === 7) {
  6159. directiveToUse = V_MODEL_DYNAMIC;
  6160. } else if (type.value) {
  6161. switch (type.value.content) {
  6162. case "radio":
  6163. directiveToUse = V_MODEL_RADIO;
  6164. break;
  6165. case "checkbox":
  6166. directiveToUse = V_MODEL_CHECKBOX;
  6167. break;
  6168. case "file":
  6169. isInvalidType = true;
  6170. context.onError(
  6171. createDOMCompilerError(
  6172. 59,
  6173. dir.loc
  6174. )
  6175. );
  6176. break;
  6177. default:
  6178. checkDuplicatedValue();
  6179. break;
  6180. }
  6181. }
  6182. } else if (hasDynamicKeyVBind(node)) {
  6183. directiveToUse = V_MODEL_DYNAMIC;
  6184. } else {
  6185. checkDuplicatedValue();
  6186. }
  6187. } else if (tag === "select") {
  6188. directiveToUse = V_MODEL_SELECT;
  6189. } else {
  6190. checkDuplicatedValue();
  6191. }
  6192. if (!isInvalidType) {
  6193. baseResult.needRuntime = context.helper(directiveToUse);
  6194. }
  6195. } else {
  6196. context.onError(
  6197. createDOMCompilerError(
  6198. 57,
  6199. dir.loc
  6200. )
  6201. );
  6202. }
  6203. baseResult.props = baseResult.props.filter(
  6204. (p) => !(p.key.type === 4 && p.key.content === "modelValue")
  6205. );
  6206. return baseResult;
  6207. };
  6208. isEventOptionModifier = makeMap(`passive,once,capture`);
  6209. isNonKeyModifier = makeMap(
  6210. // event propagation management
  6211. `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
  6212. );
  6213. maybeKeyModifier = makeMap("left,right");
  6214. isKeyboardEvent = makeMap(
  6215. `onkeyup,onkeydown,onkeypress`,
  6216. true
  6217. );
  6218. resolveModifiers = (key, modifiers, context, loc) => {
  6219. const keyModifiers = [];
  6220. const nonKeyModifiers = [];
  6221. const eventOptionModifiers = [];
  6222. for (let i = 0; i < modifiers.length; i++) {
  6223. const modifier = modifiers[i];
  6224. if (modifier === "native" && checkCompatEnabled(
  6225. "COMPILER_V_ON_NATIVE",
  6226. context,
  6227. loc
  6228. )) {
  6229. eventOptionModifiers.push(modifier);
  6230. } else if (isEventOptionModifier(modifier)) {
  6231. eventOptionModifiers.push(modifier);
  6232. } else {
  6233. if (maybeKeyModifier(modifier)) {
  6234. if (isStaticExp(key)) {
  6235. if (isKeyboardEvent(key.content)) {
  6236. keyModifiers.push(modifier);
  6237. } else {
  6238. nonKeyModifiers.push(modifier);
  6239. }
  6240. } else {
  6241. keyModifiers.push(modifier);
  6242. nonKeyModifiers.push(modifier);
  6243. }
  6244. } else {
  6245. if (isNonKeyModifier(modifier)) {
  6246. nonKeyModifiers.push(modifier);
  6247. } else {
  6248. keyModifiers.push(modifier);
  6249. }
  6250. }
  6251. }
  6252. }
  6253. return {
  6254. keyModifiers,
  6255. nonKeyModifiers,
  6256. eventOptionModifiers
  6257. };
  6258. };
  6259. transformClick = (key, event) => {
  6260. const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === "onclick";
  6261. return isStaticClick ? createSimpleExpression(event, true) : key.type !== 4 ? createCompoundExpression([
  6262. `(`,
  6263. key,
  6264. `) === "onClick" ? "${event}" : (`,
  6265. key,
  6266. `)`
  6267. ]) : key;
  6268. };
  6269. transformOn2 = (dir, node, context) => {
  6270. return transformOn(dir, node, context, (baseResult) => {
  6271. const { modifiers } = dir;
  6272. if (!modifiers.length)
  6273. return baseResult;
  6274. let { key, value: handlerExp } = baseResult.props[0];
  6275. const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
  6276. if (nonKeyModifiers.includes("right")) {
  6277. key = transformClick(key, `onContextmenu`);
  6278. }
  6279. if (nonKeyModifiers.includes("middle")) {
  6280. key = transformClick(key, `onMouseup`);
  6281. }
  6282. if (nonKeyModifiers.length) {
  6283. handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
  6284. handlerExp,
  6285. JSON.stringify(nonKeyModifiers)
  6286. ]);
  6287. }
  6288. if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
  6289. (!isStaticExp(key) || isKeyboardEvent(key.content))) {
  6290. handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
  6291. handlerExp,
  6292. JSON.stringify(keyModifiers)
  6293. ]);
  6294. }
  6295. if (eventOptionModifiers.length) {
  6296. const modifierPostfix = eventOptionModifiers.map(capitalize).join("");
  6297. key = isStaticExp(key) ? createSimpleExpression(`${key.content}${modifierPostfix}`, true) : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
  6298. }
  6299. return {
  6300. props: [createObjectProperty(key, handlerExp)]
  6301. };
  6302. });
  6303. };
  6304. transformShow = (dir, node, context) => {
  6305. const { exp, loc } = dir;
  6306. if (!exp) {
  6307. context.onError(
  6308. createDOMCompilerError(61, loc)
  6309. );
  6310. }
  6311. return {
  6312. props: [],
  6313. needRuntime: context.helper(V_SHOW)
  6314. };
  6315. };
  6316. transformTransition = (node, context) => {
  6317. if (node.type === 1 && node.tagType === 1) {
  6318. const component = context.isBuiltInComponent(node.tag);
  6319. if (component === TRANSITION) {
  6320. return () => {
  6321. if (!node.children.length) {
  6322. return;
  6323. }
  6324. if (hasMultipleChildren(node)) {
  6325. context.onError(
  6326. createDOMCompilerError(
  6327. 62,
  6328. {
  6329. start: node.children[0].loc.start,
  6330. end: node.children[node.children.length - 1].loc.end,
  6331. source: ""
  6332. }
  6333. )
  6334. );
  6335. }
  6336. const child = node.children[0];
  6337. if (child.type === 1) {
  6338. for (const p of child.props) {
  6339. if (p.type === 7 && p.name === "show") {
  6340. node.props.push({
  6341. type: 6,
  6342. name: "persisted",
  6343. nameLoc: node.loc,
  6344. value: void 0,
  6345. loc: node.loc
  6346. });
  6347. }
  6348. }
  6349. }
  6350. };
  6351. }
  6352. }
  6353. };
  6354. ignoreSideEffectTags = (node, context) => {
  6355. if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
  6356. context.onError(
  6357. createDOMCompilerError(
  6358. 63,
  6359. node.loc
  6360. )
  6361. );
  6362. context.removeNode();
  6363. }
  6364. };
  6365. DOMNodeTransforms = [
  6366. transformStyle,
  6367. ...true ? [transformTransition] : []
  6368. ];
  6369. DOMDirectiveTransforms = {
  6370. cloak: noopDirectiveTransform,
  6371. html: transformVHtml,
  6372. text: transformVText,
  6373. model: transformModel2,
  6374. // override compiler-core
  6375. on: transformOn2,
  6376. // override compiler-core
  6377. show: transformShow
  6378. };
  6379. }
  6380. });
  6381. // node_modules/.pnpm/vue@3.4.27_typescript@5.4.5/node_modules/vue/dist/vue.cjs.js
  6382. var require_vue_cjs = __commonJS({
  6383. "node_modules/.pnpm/vue@3.4.27_typescript@5.4.5/node_modules/vue/dist/vue.cjs.js"(exports) {
  6384. "use strict";
  6385. Object.defineProperty(exports, "__esModule", { value: true });
  6386. var compilerDom = (init_compiler_dom_esm_bundler(), __toCommonJS(compiler_dom_esm_bundler_exports));
  6387. var runtimeDom = (init_runtime_dom_esm_bundler(), __toCommonJS(runtime_dom_esm_bundler_exports));
  6388. var shared = (init_shared_esm_bundler(), __toCommonJS(shared_esm_bundler_exports));
  6389. function _interopNamespaceDefault(e) {
  6390. var n = /* @__PURE__ */ Object.create(null);
  6391. if (e) {
  6392. for (var k in e) {
  6393. n[k] = e[k];
  6394. }
  6395. }
  6396. n.default = e;
  6397. return Object.freeze(n);
  6398. }
  6399. var runtimeDom__namespace = _interopNamespaceDefault(runtimeDom);
  6400. var compileCache = /* @__PURE__ */ new WeakMap();
  6401. function getCache(options) {
  6402. let c = compileCache.get(options != null ? options : shared.EMPTY_OBJ);
  6403. if (!c) {
  6404. c = /* @__PURE__ */ Object.create(null);
  6405. compileCache.set(options != null ? options : shared.EMPTY_OBJ, c);
  6406. }
  6407. return c;
  6408. }
  6409. function compileToFunction(template, options) {
  6410. if (!shared.isString(template)) {
  6411. if (template.nodeType) {
  6412. template = template.innerHTML;
  6413. } else {
  6414. runtimeDom.warn(`invalid template option: `, template);
  6415. return shared.NOOP;
  6416. }
  6417. }
  6418. const key = template;
  6419. const cache = getCache(options);
  6420. const cached = cache[key];
  6421. if (cached) {
  6422. return cached;
  6423. }
  6424. if (template[0] === "#") {
  6425. const el = document.querySelector(template);
  6426. if (!el) {
  6427. runtimeDom.warn(`Template element not found or is empty: ${template}`);
  6428. }
  6429. template = el ? el.innerHTML : ``;
  6430. }
  6431. const opts = shared.extend(
  6432. {
  6433. hoistStatic: true,
  6434. onError,
  6435. onWarn: (e) => onError(e, true)
  6436. },
  6437. options
  6438. );
  6439. if (!opts.isCustomElement && typeof customElements !== "undefined") {
  6440. opts.isCustomElement = (tag) => !!customElements.get(tag);
  6441. }
  6442. const { code } = compilerDom.compile(template, opts);
  6443. function onError(err, asWarning = false) {
  6444. const message = asWarning ? err.message : `Template compilation error: ${err.message}`;
  6445. const codeFrame = err.loc && shared.generateCodeFrame(
  6446. template,
  6447. err.loc.start.offset,
  6448. err.loc.end.offset
  6449. );
  6450. runtimeDom.warn(codeFrame ? `${message}
  6451. ${codeFrame}` : message);
  6452. }
  6453. const render = new Function("Vue", code)(runtimeDom__namespace);
  6454. render._rc = true;
  6455. return cache[key] = render;
  6456. }
  6457. runtimeDom.registerRuntimeCompiler(compileToFunction);
  6458. exports.compile = compileToFunction;
  6459. Object.keys(runtimeDom).forEach(function(k) {
  6460. if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
  6461. exports[k] = runtimeDom[k];
  6462. });
  6463. }
  6464. });
  6465. // node_modules/.pnpm/vue@3.4.27_typescript@5.4.5/node_modules/vue/index.js
  6466. var require_vue = __commonJS({
  6467. "node_modules/.pnpm/vue@3.4.27_typescript@5.4.5/node_modules/vue/index.js"(exports, module) {
  6468. "use strict";
  6469. if (false) {
  6470. module.exports = null;
  6471. } else {
  6472. module.exports = require_vue_cjs();
  6473. }
  6474. }
  6475. });
  6476. export {
  6477. require_vue
  6478. };
  6479. /*! Bundled license information:
  6480. @vue/compiler-core/dist/compiler-core.esm-bundler.js:
  6481. (**
  6482. * @vue/compiler-core v3.4.27
  6483. * (c) 2018-present Yuxi (Evan) You and Vue contributors
  6484. * @license MIT
  6485. **)
  6486. @vue/compiler-dom/dist/compiler-dom.esm-bundler.js:
  6487. (**
  6488. * @vue/compiler-dom v3.4.27
  6489. * (c) 2018-present Yuxi (Evan) You and Vue contributors
  6490. * @license MIT
  6491. **)
  6492. vue/dist/vue.cjs.js:
  6493. (**
  6494. * vue v3.4.27
  6495. * (c) 2018-present Yuxi (Evan) You and Vue contributors
  6496. * @license MIT
  6497. **)
  6498. */
  6499. //# sourceMappingURL=chunk-IND6KQVK.js.map