vue.runtime.common.dev.js 284 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736
  1. /*!
  2. * Vue.js v2.7.16
  3. * (c) 2014-2023 Evan You
  4. * Released under the MIT License.
  5. */
  6. 'use strict';
  7. const emptyObject = Object.freeze({});
  8. const isArray = Array.isArray;
  9. // These helpers produce better VM code in JS engines due to their
  10. // explicitness and function inlining.
  11. function isUndef(v) {
  12. return v === undefined || v === null;
  13. }
  14. function isDef(v) {
  15. return v !== undefined && v !== null;
  16. }
  17. function isTrue(v) {
  18. return v === true;
  19. }
  20. function isFalse(v) {
  21. return v === false;
  22. }
  23. /**
  24. * Check if value is primitive.
  25. */
  26. function isPrimitive(value) {
  27. return (typeof value === 'string' ||
  28. typeof value === 'number' ||
  29. // $flow-disable-line
  30. typeof value === 'symbol' ||
  31. typeof value === 'boolean');
  32. }
  33. function isFunction(value) {
  34. return typeof value === 'function';
  35. }
  36. /**
  37. * Quick object check - this is primarily used to tell
  38. * objects from primitive values when we know the value
  39. * is a JSON-compliant type.
  40. */
  41. function isObject(obj) {
  42. return obj !== null && typeof obj === 'object';
  43. }
  44. /**
  45. * Get the raw type string of a value, e.g., [object Object].
  46. */
  47. const _toString = Object.prototype.toString;
  48. function toRawType(value) {
  49. return _toString.call(value).slice(8, -1);
  50. }
  51. /**
  52. * Strict object type check. Only returns true
  53. * for plain JavaScript objects.
  54. */
  55. function isPlainObject(obj) {
  56. return _toString.call(obj) === '[object Object]';
  57. }
  58. function isRegExp(v) {
  59. return _toString.call(v) === '[object RegExp]';
  60. }
  61. /**
  62. * Check if val is a valid array index.
  63. */
  64. function isValidArrayIndex(val) {
  65. const n = parseFloat(String(val));
  66. return n >= 0 && Math.floor(n) === n && isFinite(val);
  67. }
  68. function isPromise(val) {
  69. return (isDef(val) &&
  70. typeof val.then === 'function' &&
  71. typeof val.catch === 'function');
  72. }
  73. /**
  74. * Convert a value to a string that is actually rendered.
  75. */
  76. function toString(val) {
  77. return val == null
  78. ? ''
  79. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  80. ? JSON.stringify(val, replacer, 2)
  81. : String(val);
  82. }
  83. function replacer(_key, val) {
  84. // avoid circular deps from v3
  85. if (val && val.__v_isRef) {
  86. return val.value;
  87. }
  88. return val;
  89. }
  90. /**
  91. * Convert an input value to a number for persistence.
  92. * If the conversion fails, return original string.
  93. */
  94. function toNumber(val) {
  95. const n = parseFloat(val);
  96. return isNaN(n) ? val : n;
  97. }
  98. /**
  99. * Make a map and return a function for checking if a key
  100. * is in that map.
  101. */
  102. function makeMap(str, expectsLowerCase) {
  103. const map = Object.create(null);
  104. const list = str.split(',');
  105. for (let i = 0; i < list.length; i++) {
  106. map[list[i]] = true;
  107. }
  108. return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val];
  109. }
  110. /**
  111. * Check if a tag is a built-in tag.
  112. */
  113. const isBuiltInTag = makeMap('slot,component', true);
  114. /**
  115. * Check if an attribute is a reserved attribute.
  116. */
  117. const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  118. /**
  119. * Remove an item from an array.
  120. */
  121. function remove$2(arr, item) {
  122. const len = arr.length;
  123. if (len) {
  124. // fast path for the only / last item
  125. if (item === arr[len - 1]) {
  126. arr.length = len - 1;
  127. return;
  128. }
  129. const index = arr.indexOf(item);
  130. if (index > -1) {
  131. return arr.splice(index, 1);
  132. }
  133. }
  134. }
  135. /**
  136. * Check whether an object has the property.
  137. */
  138. const hasOwnProperty = Object.prototype.hasOwnProperty;
  139. function hasOwn(obj, key) {
  140. return hasOwnProperty.call(obj, key);
  141. }
  142. /**
  143. * Create a cached version of a pure function.
  144. */
  145. function cached(fn) {
  146. const cache = Object.create(null);
  147. return function cachedFn(str) {
  148. const hit = cache[str];
  149. return hit || (cache[str] = fn(str));
  150. };
  151. }
  152. /**
  153. * Camelize a hyphen-delimited string.
  154. */
  155. const camelizeRE = /-(\w)/g;
  156. const camelize = cached((str) => {
  157. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  158. });
  159. /**
  160. * Capitalize a string.
  161. */
  162. const capitalize = cached((str) => {
  163. return str.charAt(0).toUpperCase() + str.slice(1);
  164. });
  165. /**
  166. * Hyphenate a camelCase string.
  167. */
  168. const hyphenateRE = /\B([A-Z])/g;
  169. const hyphenate = cached((str) => {
  170. return str.replace(hyphenateRE, '-$1').toLowerCase();
  171. });
  172. /**
  173. * Simple bind polyfill for environments that do not support it,
  174. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  175. * since native bind is now performant enough in most browsers.
  176. * But removing it would mean breaking code that was able to run in
  177. * PhantomJS 1.x, so this must be kept for backward compatibility.
  178. */
  179. /* istanbul ignore next */
  180. function polyfillBind(fn, ctx) {
  181. function boundFn(a) {
  182. const l = arguments.length;
  183. return l
  184. ? l > 1
  185. ? fn.apply(ctx, arguments)
  186. : fn.call(ctx, a)
  187. : fn.call(ctx);
  188. }
  189. boundFn._length = fn.length;
  190. return boundFn;
  191. }
  192. function nativeBind(fn, ctx) {
  193. return fn.bind(ctx);
  194. }
  195. // @ts-expect-error bind cannot be `undefined`
  196. const bind = Function.prototype.bind ? nativeBind : polyfillBind;
  197. /**
  198. * Convert an Array-like object to a real Array.
  199. */
  200. function toArray(list, start) {
  201. start = start || 0;
  202. let i = list.length - start;
  203. const ret = new Array(i);
  204. while (i--) {
  205. ret[i] = list[i + start];
  206. }
  207. return ret;
  208. }
  209. /**
  210. * Mix properties into target object.
  211. */
  212. function extend(to, _from) {
  213. for (const key in _from) {
  214. to[key] = _from[key];
  215. }
  216. return to;
  217. }
  218. /**
  219. * Merge an Array of Objects into a single Object.
  220. */
  221. function toObject(arr) {
  222. const res = {};
  223. for (let i = 0; i < arr.length; i++) {
  224. if (arr[i]) {
  225. extend(res, arr[i]);
  226. }
  227. }
  228. return res;
  229. }
  230. /* eslint-disable no-unused-vars */
  231. /**
  232. * Perform no operation.
  233. * Stubbing args to make Flow happy without leaving useless transpiled code
  234. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  235. */
  236. function noop(a, b, c) { }
  237. /**
  238. * Always return false.
  239. */
  240. const no = (a, b, c) => false;
  241. /* eslint-enable no-unused-vars */
  242. /**
  243. * Return the same value.
  244. */
  245. const identity = (_) => _;
  246. /**
  247. * Check if two values are loosely equal - that is,
  248. * if they are plain objects, do they have the same shape?
  249. */
  250. function looseEqual(a, b) {
  251. if (a === b)
  252. return true;
  253. const isObjectA = isObject(a);
  254. const isObjectB = isObject(b);
  255. if (isObjectA && isObjectB) {
  256. try {
  257. const isArrayA = Array.isArray(a);
  258. const isArrayB = Array.isArray(b);
  259. if (isArrayA && isArrayB) {
  260. return (a.length === b.length &&
  261. a.every((e, i) => {
  262. return looseEqual(e, b[i]);
  263. }));
  264. }
  265. else if (a instanceof Date && b instanceof Date) {
  266. return a.getTime() === b.getTime();
  267. }
  268. else if (!isArrayA && !isArrayB) {
  269. const keysA = Object.keys(a);
  270. const keysB = Object.keys(b);
  271. return (keysA.length === keysB.length &&
  272. keysA.every(key => {
  273. return looseEqual(a[key], b[key]);
  274. }));
  275. }
  276. else {
  277. /* istanbul ignore next */
  278. return false;
  279. }
  280. }
  281. catch (e) {
  282. /* istanbul ignore next */
  283. return false;
  284. }
  285. }
  286. else if (!isObjectA && !isObjectB) {
  287. return String(a) === String(b);
  288. }
  289. else {
  290. return false;
  291. }
  292. }
  293. /**
  294. * Return the first index at which a loosely equal value can be
  295. * found in the array (if value is a plain object, the array must
  296. * contain an object of the same shape), or -1 if it is not present.
  297. */
  298. function looseIndexOf(arr, val) {
  299. for (let i = 0; i < arr.length; i++) {
  300. if (looseEqual(arr[i], val))
  301. return i;
  302. }
  303. return -1;
  304. }
  305. /**
  306. * Ensure a function is called only once.
  307. */
  308. function once(fn) {
  309. let called = false;
  310. return function () {
  311. if (!called) {
  312. called = true;
  313. fn.apply(this, arguments);
  314. }
  315. };
  316. }
  317. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#polyfill
  318. function hasChanged(x, y) {
  319. if (x === y) {
  320. return x === 0 && 1 / x !== 1 / y;
  321. }
  322. else {
  323. return x === x || y === y;
  324. }
  325. }
  326. const SSR_ATTR = 'data-server-rendered';
  327. const ASSET_TYPES = ['component', 'directive', 'filter'];
  328. const LIFECYCLE_HOOKS = [
  329. 'beforeCreate',
  330. 'created',
  331. 'beforeMount',
  332. 'mounted',
  333. 'beforeUpdate',
  334. 'updated',
  335. 'beforeDestroy',
  336. 'destroyed',
  337. 'activated',
  338. 'deactivated',
  339. 'errorCaptured',
  340. 'serverPrefetch',
  341. 'renderTracked',
  342. 'renderTriggered'
  343. ];
  344. var config = {
  345. /**
  346. * Option merge strategies (used in core/util/options)
  347. */
  348. // $flow-disable-line
  349. optionMergeStrategies: Object.create(null),
  350. /**
  351. * Whether to suppress warnings.
  352. */
  353. silent: false,
  354. /**
  355. * Show production mode tip message on boot?
  356. */
  357. productionTip: true,
  358. /**
  359. * Whether to enable devtools
  360. */
  361. devtools: true,
  362. /**
  363. * Whether to record perf
  364. */
  365. performance: false,
  366. /**
  367. * Error handler for watcher errors
  368. */
  369. errorHandler: null,
  370. /**
  371. * Warn handler for watcher warns
  372. */
  373. warnHandler: null,
  374. /**
  375. * Ignore certain custom elements
  376. */
  377. ignoredElements: [],
  378. /**
  379. * Custom user key aliases for v-on
  380. */
  381. // $flow-disable-line
  382. keyCodes: Object.create(null),
  383. /**
  384. * Check if a tag is reserved so that it cannot be registered as a
  385. * component. This is platform-dependent and may be overwritten.
  386. */
  387. isReservedTag: no,
  388. /**
  389. * Check if an attribute is reserved so that it cannot be used as a component
  390. * prop. This is platform-dependent and may be overwritten.
  391. */
  392. isReservedAttr: no,
  393. /**
  394. * Check if a tag is an unknown element.
  395. * Platform-dependent.
  396. */
  397. isUnknownElement: no,
  398. /**
  399. * Get the namespace of an element
  400. */
  401. getTagNamespace: noop,
  402. /**
  403. * Parse the real tag name for the specific platform.
  404. */
  405. parsePlatformTagName: identity,
  406. /**
  407. * Check if an attribute must be bound using property, e.g. value
  408. * Platform-dependent.
  409. */
  410. mustUseProp: no,
  411. /**
  412. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  413. * This will significantly reduce performance if set to false.
  414. */
  415. async: true,
  416. /**
  417. * Exposed for legacy reasons
  418. */
  419. _lifecycleHooks: LIFECYCLE_HOOKS
  420. };
  421. /**
  422. * unicode letters used for parsing html tags, component names and property paths.
  423. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  424. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  425. */
  426. const unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;
  427. /**
  428. * Check if a string starts with $ or _
  429. */
  430. function isReserved(str) {
  431. const c = (str + '').charCodeAt(0);
  432. return c === 0x24 || c === 0x5f;
  433. }
  434. /**
  435. * Define a property.
  436. */
  437. function def(obj, key, val, enumerable) {
  438. Object.defineProperty(obj, key, {
  439. value: val,
  440. enumerable: !!enumerable,
  441. writable: true,
  442. configurable: true
  443. });
  444. }
  445. /**
  446. * Parse simple path.
  447. */
  448. const bailRE = new RegExp(`[^${unicodeRegExp.source}.$_\\d]`);
  449. function parsePath(path) {
  450. if (bailRE.test(path)) {
  451. return;
  452. }
  453. const segments = path.split('.');
  454. return function (obj) {
  455. for (let i = 0; i < segments.length; i++) {
  456. if (!obj)
  457. return;
  458. obj = obj[segments[i]];
  459. }
  460. return obj;
  461. };
  462. }
  463. // can we use __proto__?
  464. const hasProto = '__proto__' in {};
  465. // Browser environment sniffing
  466. const inBrowser = typeof window !== 'undefined';
  467. const UA = inBrowser && window.navigator.userAgent.toLowerCase();
  468. const isIE = UA && /msie|trident/.test(UA);
  469. const isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  470. const isEdge = UA && UA.indexOf('edge/') > 0;
  471. UA && UA.indexOf('android') > 0;
  472. const isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
  473. UA && /chrome\/\d+/.test(UA) && !isEdge;
  474. UA && /phantomjs/.test(UA);
  475. const isFF = UA && UA.match(/firefox\/(\d+)/);
  476. // Firefox has a "watch" function on Object.prototype...
  477. // @ts-expect-error firebox support
  478. const nativeWatch = {}.watch;
  479. let supportsPassive = false;
  480. if (inBrowser) {
  481. try {
  482. const opts = {};
  483. Object.defineProperty(opts, 'passive', {
  484. get() {
  485. /* istanbul ignore next */
  486. supportsPassive = true;
  487. }
  488. }); // https://github.com/facebook/flow/issues/285
  489. window.addEventListener('test-passive', null, opts);
  490. }
  491. catch (e) { }
  492. }
  493. // this needs to be lazy-evaled because vue may be required before
  494. // vue-server-renderer can set VUE_ENV
  495. let _isServer;
  496. const isServerRendering = () => {
  497. if (_isServer === undefined) {
  498. /* istanbul ignore if */
  499. if (!inBrowser && typeof global !== 'undefined') {
  500. // detect presence of vue-server-renderer and avoid
  501. // Webpack shimming the process
  502. _isServer =
  503. global['process'] && global['process'].env.VUE_ENV === 'server';
  504. }
  505. else {
  506. _isServer = false;
  507. }
  508. }
  509. return _isServer;
  510. };
  511. // detect devtools
  512. const devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  513. /* istanbul ignore next */
  514. function isNative(Ctor) {
  515. return typeof Ctor === 'function' && /native code/.test(Ctor.toString());
  516. }
  517. const hasSymbol = typeof Symbol !== 'undefined' &&
  518. isNative(Symbol) &&
  519. typeof Reflect !== 'undefined' &&
  520. isNative(Reflect.ownKeys);
  521. let _Set; // $flow-disable-line
  522. /* istanbul ignore if */ if (typeof Set !== 'undefined' && isNative(Set)) {
  523. // use native Set when available.
  524. _Set = Set;
  525. }
  526. else {
  527. // a non-standard Set polyfill that only works with primitive keys.
  528. _Set = class Set {
  529. constructor() {
  530. this.set = Object.create(null);
  531. }
  532. has(key) {
  533. return this.set[key] === true;
  534. }
  535. add(key) {
  536. this.set[key] = true;
  537. }
  538. clear() {
  539. this.set = Object.create(null);
  540. }
  541. };
  542. }
  543. let currentInstance = null;
  544. /**
  545. * This is exposed for compatibility with v3 (e.g. some functions in VueUse
  546. * relies on it). Do not use this internally, just use `currentInstance`.
  547. *
  548. * @internal this function needs manual type declaration because it relies
  549. * on previously manually authored types from Vue 2
  550. */
  551. function getCurrentInstance() {
  552. return currentInstance && { proxy: currentInstance };
  553. }
  554. /**
  555. * @internal
  556. */
  557. function setCurrentInstance(vm = null) {
  558. if (!vm)
  559. currentInstance && currentInstance._scope.off();
  560. currentInstance = vm;
  561. vm && vm._scope.on();
  562. }
  563. /**
  564. * @internal
  565. */
  566. class VNode {
  567. constructor(tag, data, children, text, elm, context, componentOptions, asyncFactory) {
  568. this.tag = tag;
  569. this.data = data;
  570. this.children = children;
  571. this.text = text;
  572. this.elm = elm;
  573. this.ns = undefined;
  574. this.context = context;
  575. this.fnContext = undefined;
  576. this.fnOptions = undefined;
  577. this.fnScopeId = undefined;
  578. this.key = data && data.key;
  579. this.componentOptions = componentOptions;
  580. this.componentInstance = undefined;
  581. this.parent = undefined;
  582. this.raw = false;
  583. this.isStatic = false;
  584. this.isRootInsert = true;
  585. this.isComment = false;
  586. this.isCloned = false;
  587. this.isOnce = false;
  588. this.asyncFactory = asyncFactory;
  589. this.asyncMeta = undefined;
  590. this.isAsyncPlaceholder = false;
  591. }
  592. // DEPRECATED: alias for componentInstance for backwards compat.
  593. /* istanbul ignore next */
  594. get child() {
  595. return this.componentInstance;
  596. }
  597. }
  598. const createEmptyVNode = (text = '') => {
  599. const node = new VNode();
  600. node.text = text;
  601. node.isComment = true;
  602. return node;
  603. };
  604. function createTextVNode(val) {
  605. return new VNode(undefined, undefined, undefined, String(val));
  606. }
  607. // optimized shallow clone
  608. // used for static nodes and slot nodes because they may be reused across
  609. // multiple renders, cloning them avoids errors when DOM manipulations rely
  610. // on their elm reference.
  611. function cloneVNode(vnode) {
  612. const cloned = new VNode(vnode.tag, vnode.data,
  613. // #7975
  614. // clone children array to avoid mutating original in case of cloning
  615. // a child.
  616. vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, vnode.componentOptions, vnode.asyncFactory);
  617. cloned.ns = vnode.ns;
  618. cloned.isStatic = vnode.isStatic;
  619. cloned.key = vnode.key;
  620. cloned.isComment = vnode.isComment;
  621. cloned.fnContext = vnode.fnContext;
  622. cloned.fnOptions = vnode.fnOptions;
  623. cloned.fnScopeId = vnode.fnScopeId;
  624. cloned.asyncMeta = vnode.asyncMeta;
  625. cloned.isCloned = true;
  626. return cloned;
  627. }
  628. let uid$2 = 0;
  629. const pendingCleanupDeps = [];
  630. const cleanupDeps = () => {
  631. for (let i = 0; i < pendingCleanupDeps.length; i++) {
  632. const dep = pendingCleanupDeps[i];
  633. dep.subs = dep.subs.filter(s => s);
  634. dep._pending = false;
  635. }
  636. pendingCleanupDeps.length = 0;
  637. };
  638. /**
  639. * A dep is an observable that can have multiple
  640. * directives subscribing to it.
  641. * @internal
  642. */
  643. class Dep {
  644. constructor() {
  645. // pending subs cleanup
  646. this._pending = false;
  647. this.id = uid$2++;
  648. this.subs = [];
  649. }
  650. addSub(sub) {
  651. this.subs.push(sub);
  652. }
  653. removeSub(sub) {
  654. // #12696 deps with massive amount of subscribers are extremely slow to
  655. // clean up in Chromium
  656. // to workaround this, we unset the sub for now, and clear them on
  657. // next scheduler flush.
  658. this.subs[this.subs.indexOf(sub)] = null;
  659. if (!this._pending) {
  660. this._pending = true;
  661. pendingCleanupDeps.push(this);
  662. }
  663. }
  664. depend(info) {
  665. if (Dep.target) {
  666. Dep.target.addDep(this);
  667. if (info && Dep.target.onTrack) {
  668. Dep.target.onTrack(Object.assign({ effect: Dep.target }, info));
  669. }
  670. }
  671. }
  672. notify(info) {
  673. // stabilize the subscriber list first
  674. const subs = this.subs.filter(s => s);
  675. if (!config.async) {
  676. // subs aren't sorted in scheduler if not running async
  677. // we need to sort them now to make sure they fire in correct
  678. // order
  679. subs.sort((a, b) => a.id - b.id);
  680. }
  681. for (let i = 0, l = subs.length; i < l; i++) {
  682. const sub = subs[i];
  683. if (info) {
  684. sub.onTrigger &&
  685. sub.onTrigger(Object.assign({ effect: subs[i] }, info));
  686. }
  687. sub.update();
  688. }
  689. }
  690. }
  691. // The current target watcher being evaluated.
  692. // This is globally unique because only one watcher
  693. // can be evaluated at a time.
  694. Dep.target = null;
  695. const targetStack = [];
  696. function pushTarget(target) {
  697. targetStack.push(target);
  698. Dep.target = target;
  699. }
  700. function popTarget() {
  701. targetStack.pop();
  702. Dep.target = targetStack[targetStack.length - 1];
  703. }
  704. /*
  705. * not type checking this file because flow doesn't play well with
  706. * dynamically accessing methods on Array prototype
  707. */
  708. const arrayProto = Array.prototype;
  709. const arrayMethods = Object.create(arrayProto);
  710. const methodsToPatch = [
  711. 'push',
  712. 'pop',
  713. 'shift',
  714. 'unshift',
  715. 'splice',
  716. 'sort',
  717. 'reverse'
  718. ];
  719. /**
  720. * Intercept mutating methods and emit events
  721. */
  722. methodsToPatch.forEach(function (method) {
  723. // cache original method
  724. const original = arrayProto[method];
  725. def(arrayMethods, method, function mutator(...args) {
  726. const result = original.apply(this, args);
  727. const ob = this.__ob__;
  728. let inserted;
  729. switch (method) {
  730. case 'push':
  731. case 'unshift':
  732. inserted = args;
  733. break;
  734. case 'splice':
  735. inserted = args.slice(2);
  736. break;
  737. }
  738. if (inserted)
  739. ob.observeArray(inserted);
  740. // notify change
  741. {
  742. ob.dep.notify({
  743. type: "array mutation" /* TriggerOpTypes.ARRAY_MUTATION */,
  744. target: this,
  745. key: method
  746. });
  747. }
  748. return result;
  749. });
  750. });
  751. const arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  752. const NO_INITIAL_VALUE = {};
  753. /**
  754. * In some cases we may want to disable observation inside a component's
  755. * update computation.
  756. */
  757. let shouldObserve = true;
  758. function toggleObserving(value) {
  759. shouldObserve = value;
  760. }
  761. // ssr mock dep
  762. const mockDep = {
  763. notify: noop,
  764. depend: noop,
  765. addSub: noop,
  766. removeSub: noop
  767. };
  768. /**
  769. * Observer class that is attached to each observed
  770. * object. Once attached, the observer converts the target
  771. * object's property keys into getter/setters that
  772. * collect dependencies and dispatch updates.
  773. */
  774. class Observer {
  775. constructor(value, shallow = false, mock = false) {
  776. this.value = value;
  777. this.shallow = shallow;
  778. this.mock = mock;
  779. // this.value = value
  780. this.dep = mock ? mockDep : new Dep();
  781. this.vmCount = 0;
  782. def(value, '__ob__', this);
  783. if (isArray(value)) {
  784. if (!mock) {
  785. if (hasProto) {
  786. value.__proto__ = arrayMethods;
  787. /* eslint-enable no-proto */
  788. }
  789. else {
  790. for (let i = 0, l = arrayKeys.length; i < l; i++) {
  791. const key = arrayKeys[i];
  792. def(value, key, arrayMethods[key]);
  793. }
  794. }
  795. }
  796. if (!shallow) {
  797. this.observeArray(value);
  798. }
  799. }
  800. else {
  801. /**
  802. * Walk through all properties and convert them into
  803. * getter/setters. This method should only be called when
  804. * value type is Object.
  805. */
  806. const keys = Object.keys(value);
  807. for (let i = 0; i < keys.length; i++) {
  808. const key = keys[i];
  809. defineReactive(value, key, NO_INITIAL_VALUE, undefined, shallow, mock);
  810. }
  811. }
  812. }
  813. /**
  814. * Observe a list of Array items.
  815. */
  816. observeArray(value) {
  817. for (let i = 0, l = value.length; i < l; i++) {
  818. observe(value[i], false, this.mock);
  819. }
  820. }
  821. }
  822. // helpers
  823. /**
  824. * Attempt to create an observer instance for a value,
  825. * returns the new observer if successfully observed,
  826. * or the existing observer if the value already has one.
  827. */
  828. function observe(value, shallow, ssrMockReactivity) {
  829. if (value && hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  830. return value.__ob__;
  831. }
  832. if (shouldObserve &&
  833. (ssrMockReactivity || !isServerRendering()) &&
  834. (isArray(value) || isPlainObject(value)) &&
  835. Object.isExtensible(value) &&
  836. !value.__v_skip /* ReactiveFlags.SKIP */ &&
  837. !isRef(value) &&
  838. !(value instanceof VNode)) {
  839. return new Observer(value, shallow, ssrMockReactivity);
  840. }
  841. }
  842. /**
  843. * Define a reactive property on an Object.
  844. */
  845. function defineReactive(obj, key, val, customSetter, shallow, mock, observeEvenIfShallow = false) {
  846. const dep = new Dep();
  847. const property = Object.getOwnPropertyDescriptor(obj, key);
  848. if (property && property.configurable === false) {
  849. return;
  850. }
  851. // cater for pre-defined getter/setters
  852. const getter = property && property.get;
  853. const setter = property && property.set;
  854. if ((!getter || setter) &&
  855. (val === NO_INITIAL_VALUE || arguments.length === 2)) {
  856. val = obj[key];
  857. }
  858. let childOb = shallow ? val && val.__ob__ : observe(val, false, mock);
  859. Object.defineProperty(obj, key, {
  860. enumerable: true,
  861. configurable: true,
  862. get: function reactiveGetter() {
  863. const value = getter ? getter.call(obj) : val;
  864. if (Dep.target) {
  865. {
  866. dep.depend({
  867. target: obj,
  868. type: "get" /* TrackOpTypes.GET */,
  869. key
  870. });
  871. }
  872. if (childOb) {
  873. childOb.dep.depend();
  874. if (isArray(value)) {
  875. dependArray(value);
  876. }
  877. }
  878. }
  879. return isRef(value) && !shallow ? value.value : value;
  880. },
  881. set: function reactiveSetter(newVal) {
  882. const value = getter ? getter.call(obj) : val;
  883. if (!hasChanged(value, newVal)) {
  884. return;
  885. }
  886. if (customSetter) {
  887. customSetter();
  888. }
  889. if (setter) {
  890. setter.call(obj, newVal);
  891. }
  892. else if (getter) {
  893. // #7981: for accessor properties without setter
  894. return;
  895. }
  896. else if (!shallow && isRef(value) && !isRef(newVal)) {
  897. value.value = newVal;
  898. return;
  899. }
  900. else {
  901. val = newVal;
  902. }
  903. childOb = shallow ? newVal && newVal.__ob__ : observe(newVal, false, mock);
  904. {
  905. dep.notify({
  906. type: "set" /* TriggerOpTypes.SET */,
  907. target: obj,
  908. key,
  909. newValue: newVal,
  910. oldValue: value
  911. });
  912. }
  913. }
  914. });
  915. return dep;
  916. }
  917. function set(target, key, val) {
  918. if ((isUndef(target) || isPrimitive(target))) {
  919. warn(`Cannot set reactive property on undefined, null, or primitive value: ${target}`);
  920. }
  921. if (isReadonly(target)) {
  922. warn(`Set operation on key "${key}" failed: target is readonly.`);
  923. return;
  924. }
  925. const ob = target.__ob__;
  926. if (isArray(target) && isValidArrayIndex(key)) {
  927. target.length = Math.max(target.length, key);
  928. target.splice(key, 1, val);
  929. // when mocking for SSR, array methods are not hijacked
  930. if (ob && !ob.shallow && ob.mock) {
  931. observe(val, false, true);
  932. }
  933. return val;
  934. }
  935. if (key in target && !(key in Object.prototype)) {
  936. target[key] = val;
  937. return val;
  938. }
  939. if (target._isVue || (ob && ob.vmCount)) {
  940. warn('Avoid adding reactive properties to a Vue instance or its root $data ' +
  941. 'at runtime - declare it upfront in the data option.');
  942. return val;
  943. }
  944. if (!ob) {
  945. target[key] = val;
  946. return val;
  947. }
  948. defineReactive(ob.value, key, val, undefined, ob.shallow, ob.mock);
  949. {
  950. ob.dep.notify({
  951. type: "add" /* TriggerOpTypes.ADD */,
  952. target: target,
  953. key,
  954. newValue: val,
  955. oldValue: undefined
  956. });
  957. }
  958. return val;
  959. }
  960. function del(target, key) {
  961. if ((isUndef(target) || isPrimitive(target))) {
  962. warn(`Cannot delete reactive property on undefined, null, or primitive value: ${target}`);
  963. }
  964. if (isArray(target) && isValidArrayIndex(key)) {
  965. target.splice(key, 1);
  966. return;
  967. }
  968. const ob = target.__ob__;
  969. if (target._isVue || (ob && ob.vmCount)) {
  970. warn('Avoid deleting properties on a Vue instance or its root $data ' +
  971. '- just set it to null.');
  972. return;
  973. }
  974. if (isReadonly(target)) {
  975. warn(`Delete operation on key "${key}" failed: target is readonly.`);
  976. return;
  977. }
  978. if (!hasOwn(target, key)) {
  979. return;
  980. }
  981. delete target[key];
  982. if (!ob) {
  983. return;
  984. }
  985. {
  986. ob.dep.notify({
  987. type: "delete" /* TriggerOpTypes.DELETE */,
  988. target: target,
  989. key
  990. });
  991. }
  992. }
  993. /**
  994. * Collect dependencies on array elements when the array is touched, since
  995. * we cannot intercept array element access like property getters.
  996. */
  997. function dependArray(value) {
  998. for (let e, i = 0, l = value.length; i < l; i++) {
  999. e = value[i];
  1000. if (e && e.__ob__) {
  1001. e.__ob__.dep.depend();
  1002. }
  1003. if (isArray(e)) {
  1004. dependArray(e);
  1005. }
  1006. }
  1007. }
  1008. function reactive(target) {
  1009. makeReactive(target, false);
  1010. return target;
  1011. }
  1012. /**
  1013. * Return a shallowly-reactive copy of the original object, where only the root
  1014. * level properties are reactive. It also does not auto-unwrap refs (even at the
  1015. * root level).
  1016. */
  1017. function shallowReactive(target) {
  1018. makeReactive(target, true);
  1019. def(target, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  1020. return target;
  1021. }
  1022. function makeReactive(target, shallow) {
  1023. // if trying to observe a readonly proxy, return the readonly version.
  1024. if (!isReadonly(target)) {
  1025. {
  1026. if (isArray(target)) {
  1027. warn(`Avoid using Array as root value for ${shallow ? `shallowReactive()` : `reactive()`} as it cannot be tracked in watch() or watchEffect(). Use ${shallow ? `shallowRef()` : `ref()`} instead. This is a Vue-2-only limitation.`);
  1028. }
  1029. const existingOb = target && target.__ob__;
  1030. if (existingOb && existingOb.shallow !== shallow) {
  1031. warn(`Target is already a ${existingOb.shallow ? `` : `non-`}shallow reactive object, and cannot be converted to ${shallow ? `` : `non-`}shallow.`);
  1032. }
  1033. }
  1034. const ob = observe(target, shallow, isServerRendering() /* ssr mock reactivity */);
  1035. if (!ob) {
  1036. if (target == null || isPrimitive(target)) {
  1037. warn(`value cannot be made reactive: ${String(target)}`);
  1038. }
  1039. if (isCollectionType(target)) {
  1040. warn(`Vue 2 does not support reactive collection types such as Map or Set.`);
  1041. }
  1042. }
  1043. }
  1044. }
  1045. function isReactive(value) {
  1046. if (isReadonly(value)) {
  1047. return isReactive(value["__v_raw" /* ReactiveFlags.RAW */]);
  1048. }
  1049. return !!(value && value.__ob__);
  1050. }
  1051. function isShallow(value) {
  1052. return !!(value && value.__v_isShallow);
  1053. }
  1054. function isReadonly(value) {
  1055. return !!(value && value.__v_isReadonly);
  1056. }
  1057. function isProxy(value) {
  1058. return isReactive(value) || isReadonly(value);
  1059. }
  1060. function toRaw(observed) {
  1061. const raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */];
  1062. return raw ? toRaw(raw) : observed;
  1063. }
  1064. function markRaw(value) {
  1065. // non-extensible objects won't be observed anyway
  1066. if (Object.isExtensible(value)) {
  1067. def(value, "__v_skip" /* ReactiveFlags.SKIP */, true);
  1068. }
  1069. return value;
  1070. }
  1071. /**
  1072. * @internal
  1073. */
  1074. function isCollectionType(value) {
  1075. const type = toRawType(value);
  1076. return (type === 'Map' || type === 'WeakMap' || type === 'Set' || type === 'WeakSet');
  1077. }
  1078. /**
  1079. * @internal
  1080. */
  1081. const RefFlag = `__v_isRef`;
  1082. function isRef(r) {
  1083. return !!(r && r.__v_isRef === true);
  1084. }
  1085. function ref$1(value) {
  1086. return createRef(value, false);
  1087. }
  1088. function shallowRef(value) {
  1089. return createRef(value, true);
  1090. }
  1091. function createRef(rawValue, shallow) {
  1092. if (isRef(rawValue)) {
  1093. return rawValue;
  1094. }
  1095. const ref = {};
  1096. def(ref, RefFlag, true);
  1097. def(ref, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, shallow);
  1098. def(ref, 'dep', defineReactive(ref, 'value', rawValue, null, shallow, isServerRendering()));
  1099. return ref;
  1100. }
  1101. function triggerRef(ref) {
  1102. if (!ref.dep) {
  1103. warn(`received object is not a triggerable ref.`);
  1104. }
  1105. {
  1106. ref.dep &&
  1107. ref.dep.notify({
  1108. type: "set" /* TriggerOpTypes.SET */,
  1109. target: ref,
  1110. key: 'value'
  1111. });
  1112. }
  1113. }
  1114. function unref(ref) {
  1115. return isRef(ref) ? ref.value : ref;
  1116. }
  1117. function proxyRefs(objectWithRefs) {
  1118. if (isReactive(objectWithRefs)) {
  1119. return objectWithRefs;
  1120. }
  1121. const proxy = {};
  1122. const keys = Object.keys(objectWithRefs);
  1123. for (let i = 0; i < keys.length; i++) {
  1124. proxyWithRefUnwrap(proxy, objectWithRefs, keys[i]);
  1125. }
  1126. return proxy;
  1127. }
  1128. function proxyWithRefUnwrap(target, source, key) {
  1129. Object.defineProperty(target, key, {
  1130. enumerable: true,
  1131. configurable: true,
  1132. get: () => {
  1133. const val = source[key];
  1134. if (isRef(val)) {
  1135. return val.value;
  1136. }
  1137. else {
  1138. const ob = val && val.__ob__;
  1139. if (ob)
  1140. ob.dep.depend();
  1141. return val;
  1142. }
  1143. },
  1144. set: value => {
  1145. const oldValue = source[key];
  1146. if (isRef(oldValue) && !isRef(value)) {
  1147. oldValue.value = value;
  1148. }
  1149. else {
  1150. source[key] = value;
  1151. }
  1152. }
  1153. });
  1154. }
  1155. function customRef(factory) {
  1156. const dep = new Dep();
  1157. const { get, set } = factory(() => {
  1158. {
  1159. dep.depend({
  1160. target: ref,
  1161. type: "get" /* TrackOpTypes.GET */,
  1162. key: 'value'
  1163. });
  1164. }
  1165. }, () => {
  1166. {
  1167. dep.notify({
  1168. target: ref,
  1169. type: "set" /* TriggerOpTypes.SET */,
  1170. key: 'value'
  1171. });
  1172. }
  1173. });
  1174. const ref = {
  1175. get value() {
  1176. return get();
  1177. },
  1178. set value(newVal) {
  1179. set(newVal);
  1180. }
  1181. };
  1182. def(ref, RefFlag, true);
  1183. return ref;
  1184. }
  1185. function toRefs(object) {
  1186. if (!isReactive(object)) {
  1187. warn(`toRefs() expects a reactive object but received a plain one.`);
  1188. }
  1189. const ret = isArray(object) ? new Array(object.length) : {};
  1190. for (const key in object) {
  1191. ret[key] = toRef(object, key);
  1192. }
  1193. return ret;
  1194. }
  1195. function toRef(object, key, defaultValue) {
  1196. const val = object[key];
  1197. if (isRef(val)) {
  1198. return val;
  1199. }
  1200. const ref = {
  1201. get value() {
  1202. const val = object[key];
  1203. return val === undefined ? defaultValue : val;
  1204. },
  1205. set value(newVal) {
  1206. object[key] = newVal;
  1207. }
  1208. };
  1209. def(ref, RefFlag, true);
  1210. return ref;
  1211. }
  1212. const rawToReadonlyFlag = `__v_rawToReadonly`;
  1213. const rawToShallowReadonlyFlag = `__v_rawToShallowReadonly`;
  1214. function readonly(target) {
  1215. return createReadonly(target, false);
  1216. }
  1217. function createReadonly(target, shallow) {
  1218. if (!isPlainObject(target)) {
  1219. {
  1220. if (isArray(target)) {
  1221. warn(`Vue 2 does not support readonly arrays.`);
  1222. }
  1223. else if (isCollectionType(target)) {
  1224. warn(`Vue 2 does not support readonly collection types such as Map or Set.`);
  1225. }
  1226. else {
  1227. warn(`value cannot be made readonly: ${typeof target}`);
  1228. }
  1229. }
  1230. return target;
  1231. }
  1232. if (!Object.isExtensible(target)) {
  1233. warn(`Vue 2 does not support creating readonly proxy for non-extensible object.`);
  1234. }
  1235. // already a readonly object
  1236. if (isReadonly(target)) {
  1237. return target;
  1238. }
  1239. // already has a readonly proxy
  1240. const existingFlag = shallow ? rawToShallowReadonlyFlag : rawToReadonlyFlag;
  1241. const existingProxy = target[existingFlag];
  1242. if (existingProxy) {
  1243. return existingProxy;
  1244. }
  1245. const proxy = Object.create(Object.getPrototypeOf(target));
  1246. def(target, existingFlag, proxy);
  1247. def(proxy, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, true);
  1248. def(proxy, "__v_raw" /* ReactiveFlags.RAW */, target);
  1249. if (isRef(target)) {
  1250. def(proxy, RefFlag, true);
  1251. }
  1252. if (shallow || isShallow(target)) {
  1253. def(proxy, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
  1254. }
  1255. const keys = Object.keys(target);
  1256. for (let i = 0; i < keys.length; i++) {
  1257. defineReadonlyProperty(proxy, target, keys[i], shallow);
  1258. }
  1259. return proxy;
  1260. }
  1261. function defineReadonlyProperty(proxy, target, key, shallow) {
  1262. Object.defineProperty(proxy, key, {
  1263. enumerable: true,
  1264. configurable: true,
  1265. get() {
  1266. const val = target[key];
  1267. return shallow || !isPlainObject(val) ? val : readonly(val);
  1268. },
  1269. set() {
  1270. warn(`Set operation on key "${key}" failed: target is readonly.`);
  1271. }
  1272. });
  1273. }
  1274. /**
  1275. * Returns a reactive-copy of the original object, where only the root level
  1276. * properties are readonly, and does NOT unwrap refs nor recursively convert
  1277. * returned properties.
  1278. * This is used for creating the props proxy object for stateful components.
  1279. */
  1280. function shallowReadonly(target) {
  1281. return createReadonly(target, true);
  1282. }
  1283. function computed(getterOrOptions, debugOptions) {
  1284. let getter;
  1285. let setter;
  1286. const onlyGetter = isFunction(getterOrOptions);
  1287. if (onlyGetter) {
  1288. getter = getterOrOptions;
  1289. setter = () => {
  1290. warn('Write operation failed: computed value is readonly');
  1291. }
  1292. ;
  1293. }
  1294. else {
  1295. getter = getterOrOptions.get;
  1296. setter = getterOrOptions.set;
  1297. }
  1298. const watcher = isServerRendering()
  1299. ? null
  1300. : new Watcher(currentInstance, getter, noop, { lazy: true });
  1301. if (watcher && debugOptions) {
  1302. watcher.onTrack = debugOptions.onTrack;
  1303. watcher.onTrigger = debugOptions.onTrigger;
  1304. }
  1305. const ref = {
  1306. // some libs rely on the presence effect for checking computed refs
  1307. // from normal refs, but the implementation doesn't matter
  1308. effect: watcher,
  1309. get value() {
  1310. if (watcher) {
  1311. if (watcher.dirty) {
  1312. watcher.evaluate();
  1313. }
  1314. if (Dep.target) {
  1315. if (Dep.target.onTrack) {
  1316. Dep.target.onTrack({
  1317. effect: Dep.target,
  1318. target: ref,
  1319. type: "get" /* TrackOpTypes.GET */,
  1320. key: 'value'
  1321. });
  1322. }
  1323. watcher.depend();
  1324. }
  1325. return watcher.value;
  1326. }
  1327. else {
  1328. return getter();
  1329. }
  1330. },
  1331. set value(newVal) {
  1332. setter(newVal);
  1333. }
  1334. };
  1335. def(ref, RefFlag, true);
  1336. def(ref, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, onlyGetter);
  1337. return ref;
  1338. }
  1339. const WATCHER = `watcher`;
  1340. const WATCHER_CB = `${WATCHER} callback`;
  1341. const WATCHER_GETTER = `${WATCHER} getter`;
  1342. const WATCHER_CLEANUP = `${WATCHER} cleanup`;
  1343. // Simple effect.
  1344. function watchEffect(effect, options) {
  1345. return doWatch(effect, null, options);
  1346. }
  1347. function watchPostEffect(effect, options) {
  1348. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
  1349. }
  1350. function watchSyncEffect(effect, options) {
  1351. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
  1352. }
  1353. // initial value for watchers to trigger on undefined initial values
  1354. const INITIAL_WATCHER_VALUE = {};
  1355. // implementation
  1356. function watch(source, cb, options) {
  1357. if (typeof cb !== 'function') {
  1358. warn(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
  1359. `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
  1360. `supports \`watch(source, cb, options?) signature.`);
  1361. }
  1362. return doWatch(source, cb, options);
  1363. }
  1364. function doWatch(source, cb, { immediate, deep, flush = 'pre', onTrack, onTrigger } = emptyObject) {
  1365. if (!cb) {
  1366. if (immediate !== undefined) {
  1367. warn(`watch() "immediate" option is only respected when using the ` +
  1368. `watch(source, callback, options?) signature.`);
  1369. }
  1370. if (deep !== undefined) {
  1371. warn(`watch() "deep" option is only respected when using the ` +
  1372. `watch(source, callback, options?) signature.`);
  1373. }
  1374. }
  1375. const warnInvalidSource = (s) => {
  1376. warn(`Invalid watch source: ${s}. A watch source can only be a getter/effect ` +
  1377. `function, a ref, a reactive object, or an array of these types.`);
  1378. };
  1379. const instance = currentInstance;
  1380. const call = (fn, type, args = null) => {
  1381. const res = invokeWithErrorHandling(fn, null, args, instance, type);
  1382. if (deep && res && res.__ob__)
  1383. res.__ob__.dep.depend();
  1384. return res;
  1385. };
  1386. let getter;
  1387. let forceTrigger = false;
  1388. let isMultiSource = false;
  1389. if (isRef(source)) {
  1390. getter = () => source.value;
  1391. forceTrigger = isShallow(source);
  1392. }
  1393. else if (isReactive(source)) {
  1394. getter = () => {
  1395. source.__ob__.dep.depend();
  1396. return source;
  1397. };
  1398. deep = true;
  1399. }
  1400. else if (isArray(source)) {
  1401. isMultiSource = true;
  1402. forceTrigger = source.some(s => isReactive(s) || isShallow(s));
  1403. getter = () => source.map(s => {
  1404. if (isRef(s)) {
  1405. return s.value;
  1406. }
  1407. else if (isReactive(s)) {
  1408. s.__ob__.dep.depend();
  1409. return traverse(s);
  1410. }
  1411. else if (isFunction(s)) {
  1412. return call(s, WATCHER_GETTER);
  1413. }
  1414. else {
  1415. warnInvalidSource(s);
  1416. }
  1417. });
  1418. }
  1419. else if (isFunction(source)) {
  1420. if (cb) {
  1421. // getter with cb
  1422. getter = () => call(source, WATCHER_GETTER);
  1423. }
  1424. else {
  1425. // no cb -> simple effect
  1426. getter = () => {
  1427. if (instance && instance._isDestroyed) {
  1428. return;
  1429. }
  1430. if (cleanup) {
  1431. cleanup();
  1432. }
  1433. return call(source, WATCHER, [onCleanup]);
  1434. };
  1435. }
  1436. }
  1437. else {
  1438. getter = noop;
  1439. warnInvalidSource(source);
  1440. }
  1441. if (cb && deep) {
  1442. const baseGetter = getter;
  1443. getter = () => traverse(baseGetter());
  1444. }
  1445. let cleanup;
  1446. let onCleanup = (fn) => {
  1447. cleanup = watcher.onStop = () => {
  1448. call(fn, WATCHER_CLEANUP);
  1449. };
  1450. };
  1451. // in SSR there is no need to setup an actual effect, and it should be noop
  1452. // unless it's eager
  1453. if (isServerRendering()) {
  1454. // we will also not call the invalidate callback (+ runner is not set up)
  1455. onCleanup = noop;
  1456. if (!cb) {
  1457. getter();
  1458. }
  1459. else if (immediate) {
  1460. call(cb, WATCHER_CB, [
  1461. getter(),
  1462. isMultiSource ? [] : undefined,
  1463. onCleanup
  1464. ]);
  1465. }
  1466. return noop;
  1467. }
  1468. const watcher = new Watcher(currentInstance, getter, noop, {
  1469. lazy: true
  1470. });
  1471. watcher.noRecurse = !cb;
  1472. let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
  1473. // overwrite default run
  1474. watcher.run = () => {
  1475. if (!watcher.active) {
  1476. return;
  1477. }
  1478. if (cb) {
  1479. // watch(source, cb)
  1480. const newValue = watcher.get();
  1481. if (deep ||
  1482. forceTrigger ||
  1483. (isMultiSource
  1484. ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
  1485. : hasChanged(newValue, oldValue))) {
  1486. // cleanup before running cb again
  1487. if (cleanup) {
  1488. cleanup();
  1489. }
  1490. call(cb, WATCHER_CB, [
  1491. newValue,
  1492. // pass undefined as the old value when it's changed for the first time
  1493. oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
  1494. onCleanup
  1495. ]);
  1496. oldValue = newValue;
  1497. }
  1498. }
  1499. else {
  1500. // watchEffect
  1501. watcher.get();
  1502. }
  1503. };
  1504. if (flush === 'sync') {
  1505. watcher.update = watcher.run;
  1506. }
  1507. else if (flush === 'post') {
  1508. watcher.post = true;
  1509. watcher.update = () => queueWatcher(watcher);
  1510. }
  1511. else {
  1512. // pre
  1513. watcher.update = () => {
  1514. if (instance && instance === currentInstance && !instance._isMounted) {
  1515. // pre-watcher triggered before
  1516. const buffer = instance._preWatchers || (instance._preWatchers = []);
  1517. if (buffer.indexOf(watcher) < 0)
  1518. buffer.push(watcher);
  1519. }
  1520. else {
  1521. queueWatcher(watcher);
  1522. }
  1523. };
  1524. }
  1525. {
  1526. watcher.onTrack = onTrack;
  1527. watcher.onTrigger = onTrigger;
  1528. }
  1529. // initial run
  1530. if (cb) {
  1531. if (immediate) {
  1532. watcher.run();
  1533. }
  1534. else {
  1535. oldValue = watcher.get();
  1536. }
  1537. }
  1538. else if (flush === 'post' && instance) {
  1539. instance.$once('hook:mounted', () => watcher.get());
  1540. }
  1541. else {
  1542. watcher.get();
  1543. }
  1544. return () => {
  1545. watcher.teardown();
  1546. };
  1547. }
  1548. let activeEffectScope;
  1549. class EffectScope {
  1550. constructor(detached = false) {
  1551. this.detached = detached;
  1552. /**
  1553. * @internal
  1554. */
  1555. this.active = true;
  1556. /**
  1557. * @internal
  1558. */
  1559. this.effects = [];
  1560. /**
  1561. * @internal
  1562. */
  1563. this.cleanups = [];
  1564. this.parent = activeEffectScope;
  1565. if (!detached && activeEffectScope) {
  1566. this.index =
  1567. (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
  1568. }
  1569. }
  1570. run(fn) {
  1571. if (this.active) {
  1572. const currentEffectScope = activeEffectScope;
  1573. try {
  1574. activeEffectScope = this;
  1575. return fn();
  1576. }
  1577. finally {
  1578. activeEffectScope = currentEffectScope;
  1579. }
  1580. }
  1581. else {
  1582. warn(`cannot run an inactive effect scope.`);
  1583. }
  1584. }
  1585. /**
  1586. * This should only be called on non-detached scopes
  1587. * @internal
  1588. */
  1589. on() {
  1590. activeEffectScope = this;
  1591. }
  1592. /**
  1593. * This should only be called on non-detached scopes
  1594. * @internal
  1595. */
  1596. off() {
  1597. activeEffectScope = this.parent;
  1598. }
  1599. stop(fromParent) {
  1600. if (this.active) {
  1601. let i, l;
  1602. for (i = 0, l = this.effects.length; i < l; i++) {
  1603. this.effects[i].teardown();
  1604. }
  1605. for (i = 0, l = this.cleanups.length; i < l; i++) {
  1606. this.cleanups[i]();
  1607. }
  1608. if (this.scopes) {
  1609. for (i = 0, l = this.scopes.length; i < l; i++) {
  1610. this.scopes[i].stop(true);
  1611. }
  1612. }
  1613. // nested scope, dereference from parent to avoid memory leaks
  1614. if (!this.detached && this.parent && !fromParent) {
  1615. // optimized O(1) removal
  1616. const last = this.parent.scopes.pop();
  1617. if (last && last !== this) {
  1618. this.parent.scopes[this.index] = last;
  1619. last.index = this.index;
  1620. }
  1621. }
  1622. this.parent = undefined;
  1623. this.active = false;
  1624. }
  1625. }
  1626. }
  1627. function effectScope(detached) {
  1628. return new EffectScope(detached);
  1629. }
  1630. /**
  1631. * @internal
  1632. */
  1633. function recordEffectScope(effect, scope = activeEffectScope) {
  1634. if (scope && scope.active) {
  1635. scope.effects.push(effect);
  1636. }
  1637. }
  1638. function getCurrentScope() {
  1639. return activeEffectScope;
  1640. }
  1641. function onScopeDispose(fn) {
  1642. if (activeEffectScope) {
  1643. activeEffectScope.cleanups.push(fn);
  1644. }
  1645. else {
  1646. warn(`onScopeDispose() is called when there is no active effect scope` +
  1647. ` to be associated with.`);
  1648. }
  1649. }
  1650. function provide(key, value) {
  1651. if (!currentInstance) {
  1652. {
  1653. warn(`provide() can only be used inside setup().`);
  1654. }
  1655. }
  1656. else {
  1657. // TS doesn't allow symbol as index type
  1658. resolveProvided(currentInstance)[key] = value;
  1659. }
  1660. }
  1661. function resolveProvided(vm) {
  1662. // by default an instance inherits its parent's provides object
  1663. // but when it needs to provide values of its own, it creates its
  1664. // own provides object using parent provides object as prototype.
  1665. // this way in `inject` we can simply look up injections from direct
  1666. // parent and let the prototype chain do the work.
  1667. const existing = vm._provided;
  1668. const parentProvides = vm.$parent && vm.$parent._provided;
  1669. if (parentProvides === existing) {
  1670. return (vm._provided = Object.create(parentProvides));
  1671. }
  1672. else {
  1673. return existing;
  1674. }
  1675. }
  1676. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  1677. // fallback to `currentRenderingInstance` so that this can be called in
  1678. // a functional component
  1679. const instance = currentInstance;
  1680. if (instance) {
  1681. // #2400
  1682. // to support `app.use` plugins,
  1683. // fallback to appContext's `provides` if the instance is at root
  1684. const provides = instance.$parent && instance.$parent._provided;
  1685. if (provides && key in provides) {
  1686. // TS doesn't allow symbol as index type
  1687. return provides[key];
  1688. }
  1689. else if (arguments.length > 1) {
  1690. return treatDefaultAsFactory && isFunction(defaultValue)
  1691. ? defaultValue.call(instance)
  1692. : defaultValue;
  1693. }
  1694. else {
  1695. warn(`injection "${String(key)}" not found.`);
  1696. }
  1697. }
  1698. else {
  1699. warn(`inject() can only be used inside setup() or functional components.`);
  1700. }
  1701. }
  1702. const normalizeEvent = cached((name) => {
  1703. const passive = name.charAt(0) === '&';
  1704. name = passive ? name.slice(1) : name;
  1705. const once = name.charAt(0) === '~'; // Prefixed last, checked first
  1706. name = once ? name.slice(1) : name;
  1707. const capture = name.charAt(0) === '!';
  1708. name = capture ? name.slice(1) : name;
  1709. return {
  1710. name,
  1711. once,
  1712. capture,
  1713. passive
  1714. };
  1715. });
  1716. function createFnInvoker(fns, vm) {
  1717. function invoker() {
  1718. const fns = invoker.fns;
  1719. if (isArray(fns)) {
  1720. const cloned = fns.slice();
  1721. for (let i = 0; i < cloned.length; i++) {
  1722. invokeWithErrorHandling(cloned[i], null, arguments, vm, `v-on handler`);
  1723. }
  1724. }
  1725. else {
  1726. // return handler return value for single handlers
  1727. return invokeWithErrorHandling(fns, null, arguments, vm, `v-on handler`);
  1728. }
  1729. }
  1730. invoker.fns = fns;
  1731. return invoker;
  1732. }
  1733. function updateListeners(on, oldOn, add, remove, createOnceHandler, vm) {
  1734. let name, cur, old, event;
  1735. for (name in on) {
  1736. cur = on[name];
  1737. old = oldOn[name];
  1738. event = normalizeEvent(name);
  1739. if (isUndef(cur)) {
  1740. warn(`Invalid handler for event "${event.name}": got ` + String(cur), vm);
  1741. }
  1742. else if (isUndef(old)) {
  1743. if (isUndef(cur.fns)) {
  1744. cur = on[name] = createFnInvoker(cur, vm);
  1745. }
  1746. if (isTrue(event.once)) {
  1747. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  1748. }
  1749. add(event.name, cur, event.capture, event.passive, event.params);
  1750. }
  1751. else if (cur !== old) {
  1752. old.fns = cur;
  1753. on[name] = old;
  1754. }
  1755. }
  1756. for (name in oldOn) {
  1757. if (isUndef(on[name])) {
  1758. event = normalizeEvent(name);
  1759. remove(event.name, oldOn[name], event.capture);
  1760. }
  1761. }
  1762. }
  1763. function mergeVNodeHook(def, hookKey, hook) {
  1764. if (def instanceof VNode) {
  1765. def = def.data.hook || (def.data.hook = {});
  1766. }
  1767. let invoker;
  1768. const oldHook = def[hookKey];
  1769. function wrappedHook() {
  1770. hook.apply(this, arguments);
  1771. // important: remove merged hook to ensure it's called only once
  1772. // and prevent memory leak
  1773. remove$2(invoker.fns, wrappedHook);
  1774. }
  1775. if (isUndef(oldHook)) {
  1776. // no existing hook
  1777. invoker = createFnInvoker([wrappedHook]);
  1778. }
  1779. else {
  1780. /* istanbul ignore if */
  1781. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  1782. // already a merged invoker
  1783. invoker = oldHook;
  1784. invoker.fns.push(wrappedHook);
  1785. }
  1786. else {
  1787. // existing plain hook
  1788. invoker = createFnInvoker([oldHook, wrappedHook]);
  1789. }
  1790. }
  1791. invoker.merged = true;
  1792. def[hookKey] = invoker;
  1793. }
  1794. function extractPropsFromVNodeData(data, Ctor, tag) {
  1795. // we are only extracting raw values here.
  1796. // validation and default values are handled in the child
  1797. // component itself.
  1798. const propOptions = Ctor.options.props;
  1799. if (isUndef(propOptions)) {
  1800. return;
  1801. }
  1802. const res = {};
  1803. const { attrs, props } = data;
  1804. if (isDef(attrs) || isDef(props)) {
  1805. for (const key in propOptions) {
  1806. const altKey = hyphenate(key);
  1807. {
  1808. const keyInLowerCase = key.toLowerCase();
  1809. if (key !== keyInLowerCase && attrs && hasOwn(attrs, keyInLowerCase)) {
  1810. tip(`Prop "${keyInLowerCase}" is passed to component ` +
  1811. `${formatComponentName(
  1812. // @ts-expect-error tag is string
  1813. tag || Ctor)}, but the declared prop name is` +
  1814. ` "${key}". ` +
  1815. `Note that HTML attributes are case-insensitive and camelCased ` +
  1816. `props need to use their kebab-case equivalents when using in-DOM ` +
  1817. `templates. You should probably use "${altKey}" instead of "${key}".`);
  1818. }
  1819. }
  1820. checkProp(res, props, key, altKey, true) ||
  1821. checkProp(res, attrs, key, altKey, false);
  1822. }
  1823. }
  1824. return res;
  1825. }
  1826. function checkProp(res, hash, key, altKey, preserve) {
  1827. if (isDef(hash)) {
  1828. if (hasOwn(hash, key)) {
  1829. res[key] = hash[key];
  1830. if (!preserve) {
  1831. delete hash[key];
  1832. }
  1833. return true;
  1834. }
  1835. else if (hasOwn(hash, altKey)) {
  1836. res[key] = hash[altKey];
  1837. if (!preserve) {
  1838. delete hash[altKey];
  1839. }
  1840. return true;
  1841. }
  1842. }
  1843. return false;
  1844. }
  1845. // The template compiler attempts to minimize the need for normalization by
  1846. // statically analyzing the template at compile time.
  1847. //
  1848. // For plain HTML markup, normalization can be completely skipped because the
  1849. // generated render function is guaranteed to return Array<VNode>. There are
  1850. // two cases where extra normalization is needed:
  1851. // 1. When the children contains components - because a functional component
  1852. // may return an Array instead of a single root. In this case, just a simple
  1853. // normalization is needed - if any child is an Array, we flatten the whole
  1854. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  1855. // because functional components already normalize their own children.
  1856. function simpleNormalizeChildren(children) {
  1857. for (let i = 0; i < children.length; i++) {
  1858. if (isArray(children[i])) {
  1859. return Array.prototype.concat.apply([], children);
  1860. }
  1861. }
  1862. return children;
  1863. }
  1864. // 2. When the children contains constructs that always generated nested Arrays,
  1865. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  1866. // with hand-written render functions / JSX. In such cases a full normalization
  1867. // is needed to cater to all possible types of children values.
  1868. function normalizeChildren(children) {
  1869. return isPrimitive(children)
  1870. ? [createTextVNode(children)]
  1871. : isArray(children)
  1872. ? normalizeArrayChildren(children)
  1873. : undefined;
  1874. }
  1875. function isTextNode(node) {
  1876. return isDef(node) && isDef(node.text) && isFalse(node.isComment);
  1877. }
  1878. function normalizeArrayChildren(children, nestedIndex) {
  1879. const res = [];
  1880. let i, c, lastIndex, last;
  1881. for (i = 0; i < children.length; i++) {
  1882. c = children[i];
  1883. if (isUndef(c) || typeof c === 'boolean')
  1884. continue;
  1885. lastIndex = res.length - 1;
  1886. last = res[lastIndex];
  1887. // nested
  1888. if (isArray(c)) {
  1889. if (c.length > 0) {
  1890. c = normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`);
  1891. // merge adjacent text nodes
  1892. if (isTextNode(c[0]) && isTextNode(last)) {
  1893. res[lastIndex] = createTextVNode(last.text + c[0].text);
  1894. c.shift();
  1895. }
  1896. res.push.apply(res, c);
  1897. }
  1898. }
  1899. else if (isPrimitive(c)) {
  1900. if (isTextNode(last)) {
  1901. // merge adjacent text nodes
  1902. // this is necessary for SSR hydration because text nodes are
  1903. // essentially merged when rendered to HTML strings
  1904. res[lastIndex] = createTextVNode(last.text + c);
  1905. }
  1906. else if (c !== '') {
  1907. // convert primitive to vnode
  1908. res.push(createTextVNode(c));
  1909. }
  1910. }
  1911. else {
  1912. if (isTextNode(c) && isTextNode(last)) {
  1913. // merge adjacent text nodes
  1914. res[lastIndex] = createTextVNode(last.text + c.text);
  1915. }
  1916. else {
  1917. // default key for nested array children (likely generated by v-for)
  1918. if (isTrue(children._isVList) &&
  1919. isDef(c.tag) &&
  1920. isUndef(c.key) &&
  1921. isDef(nestedIndex)) {
  1922. c.key = `__vlist${nestedIndex}_${i}__`;
  1923. }
  1924. res.push(c);
  1925. }
  1926. }
  1927. }
  1928. return res;
  1929. }
  1930. /**
  1931. * Runtime helper for rendering v-for lists.
  1932. */
  1933. function renderList(val, render) {
  1934. let ret = null, i, l, keys, key;
  1935. if (isArray(val) || typeof val === 'string') {
  1936. ret = new Array(val.length);
  1937. for (i = 0, l = val.length; i < l; i++) {
  1938. ret[i] = render(val[i], i);
  1939. }
  1940. }
  1941. else if (typeof val === 'number') {
  1942. ret = new Array(val);
  1943. for (i = 0; i < val; i++) {
  1944. ret[i] = render(i + 1, i);
  1945. }
  1946. }
  1947. else if (isObject(val)) {
  1948. if (hasSymbol && val[Symbol.iterator]) {
  1949. ret = [];
  1950. const iterator = val[Symbol.iterator]();
  1951. let result = iterator.next();
  1952. while (!result.done) {
  1953. ret.push(render(result.value, ret.length));
  1954. result = iterator.next();
  1955. }
  1956. }
  1957. else {
  1958. keys = Object.keys(val);
  1959. ret = new Array(keys.length);
  1960. for (i = 0, l = keys.length; i < l; i++) {
  1961. key = keys[i];
  1962. ret[i] = render(val[key], key, i);
  1963. }
  1964. }
  1965. }
  1966. if (!isDef(ret)) {
  1967. ret = [];
  1968. }
  1969. ret._isVList = true;
  1970. return ret;
  1971. }
  1972. /**
  1973. * Runtime helper for rendering <slot>
  1974. */
  1975. function renderSlot(name, fallbackRender, props, bindObject) {
  1976. const scopedSlotFn = this.$scopedSlots[name];
  1977. let nodes;
  1978. if (scopedSlotFn) {
  1979. // scoped slot
  1980. props = props || {};
  1981. if (bindObject) {
  1982. if (!isObject(bindObject)) {
  1983. warn('slot v-bind without argument expects an Object', this);
  1984. }
  1985. props = extend(extend({}, bindObject), props);
  1986. }
  1987. nodes =
  1988. scopedSlotFn(props) ||
  1989. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1990. }
  1991. else {
  1992. nodes =
  1993. this.$slots[name] ||
  1994. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  1995. }
  1996. const target = props && props.slot;
  1997. if (target) {
  1998. return this.$createElement('template', { slot: target }, nodes);
  1999. }
  2000. else {
  2001. return nodes;
  2002. }
  2003. }
  2004. /**
  2005. * Runtime helper for resolving filters
  2006. */
  2007. function resolveFilter(id) {
  2008. return resolveAsset(this.$options, 'filters', id, true) || identity;
  2009. }
  2010. function isKeyNotMatch(expect, actual) {
  2011. if (isArray(expect)) {
  2012. return expect.indexOf(actual) === -1;
  2013. }
  2014. else {
  2015. return expect !== actual;
  2016. }
  2017. }
  2018. /**
  2019. * Runtime helper for checking keyCodes from config.
  2020. * exposed as Vue.prototype._k
  2021. * passing in eventKeyName as last argument separately for backwards compat
  2022. */
  2023. function checkKeyCodes(eventKeyCode, key, builtInKeyCode, eventKeyName, builtInKeyName) {
  2024. const mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  2025. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  2026. return isKeyNotMatch(builtInKeyName, eventKeyName);
  2027. }
  2028. else if (mappedKeyCode) {
  2029. return isKeyNotMatch(mappedKeyCode, eventKeyCode);
  2030. }
  2031. else if (eventKeyName) {
  2032. return hyphenate(eventKeyName) !== key;
  2033. }
  2034. return eventKeyCode === undefined;
  2035. }
  2036. /**
  2037. * Runtime helper for merging v-bind="object" into a VNode's data.
  2038. */
  2039. function bindObjectProps(data, tag, value, asProp, isSync) {
  2040. if (value) {
  2041. if (!isObject(value)) {
  2042. warn('v-bind without argument expects an Object or Array value', this);
  2043. }
  2044. else {
  2045. if (isArray(value)) {
  2046. value = toObject(value);
  2047. }
  2048. let hash;
  2049. for (const key in value) {
  2050. if (key === 'class' || key === 'style' || isReservedAttribute(key)) {
  2051. hash = data;
  2052. }
  2053. else {
  2054. const type = data.attrs && data.attrs.type;
  2055. hash =
  2056. asProp || config.mustUseProp(tag, type, key)
  2057. ? data.domProps || (data.domProps = {})
  2058. : data.attrs || (data.attrs = {});
  2059. }
  2060. const camelizedKey = camelize(key);
  2061. const hyphenatedKey = hyphenate(key);
  2062. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  2063. hash[key] = value[key];
  2064. if (isSync) {
  2065. const on = data.on || (data.on = {});
  2066. on[`update:${key}`] = function ($event) {
  2067. value[key] = $event;
  2068. };
  2069. }
  2070. }
  2071. }
  2072. }
  2073. }
  2074. return data;
  2075. }
  2076. /**
  2077. * Runtime helper for rendering static trees.
  2078. */
  2079. function renderStatic(index, isInFor) {
  2080. const cached = this._staticTrees || (this._staticTrees = []);
  2081. let tree = cached[index];
  2082. // if has already-rendered static tree and not inside v-for,
  2083. // we can reuse the same tree.
  2084. if (tree && !isInFor) {
  2085. return tree;
  2086. }
  2087. // otherwise, render a fresh tree.
  2088. tree = cached[index] = this.$options.staticRenderFns[index].call(this._renderProxy, this._c, this // for render fns generated for functional component templates
  2089. );
  2090. markStatic(tree, `__static__${index}`, false);
  2091. return tree;
  2092. }
  2093. /**
  2094. * Runtime helper for v-once.
  2095. * Effectively it means marking the node as static with a unique key.
  2096. */
  2097. function markOnce(tree, index, key) {
  2098. markStatic(tree, `__once__${index}${key ? `_${key}` : ``}`, true);
  2099. return tree;
  2100. }
  2101. function markStatic(tree, key, isOnce) {
  2102. if (isArray(tree)) {
  2103. for (let i = 0; i < tree.length; i++) {
  2104. if (tree[i] && typeof tree[i] !== 'string') {
  2105. markStaticNode(tree[i], `${key}_${i}`, isOnce);
  2106. }
  2107. }
  2108. }
  2109. else {
  2110. markStaticNode(tree, key, isOnce);
  2111. }
  2112. }
  2113. function markStaticNode(node, key, isOnce) {
  2114. node.isStatic = true;
  2115. node.key = key;
  2116. node.isOnce = isOnce;
  2117. }
  2118. function bindObjectListeners(data, value) {
  2119. if (value) {
  2120. if (!isPlainObject(value)) {
  2121. warn('v-on without argument expects an Object value', this);
  2122. }
  2123. else {
  2124. const on = (data.on = data.on ? extend({}, data.on) : {});
  2125. for (const key in value) {
  2126. const existing = on[key];
  2127. const ours = value[key];
  2128. on[key] = existing ? [].concat(existing, ours) : ours;
  2129. }
  2130. }
  2131. }
  2132. return data;
  2133. }
  2134. function resolveScopedSlots(fns, res,
  2135. // the following are added in 2.6
  2136. hasDynamicKeys, contentHashKey) {
  2137. res = res || { $stable: !hasDynamicKeys };
  2138. for (let i = 0; i < fns.length; i++) {
  2139. const slot = fns[i];
  2140. if (isArray(slot)) {
  2141. resolveScopedSlots(slot, res, hasDynamicKeys);
  2142. }
  2143. else if (slot) {
  2144. // marker for reverse proxying v-slot without scope on this.$slots
  2145. // @ts-expect-error
  2146. if (slot.proxy) {
  2147. // @ts-expect-error
  2148. slot.fn.proxy = true;
  2149. }
  2150. res[slot.key] = slot.fn;
  2151. }
  2152. }
  2153. if (contentHashKey) {
  2154. res.$key = contentHashKey;
  2155. }
  2156. return res;
  2157. }
  2158. // helper to process dynamic keys for dynamic arguments in v-bind and v-on.
  2159. function bindDynamicKeys(baseObj, values) {
  2160. for (let i = 0; i < values.length; i += 2) {
  2161. const key = values[i];
  2162. if (typeof key === 'string' && key) {
  2163. baseObj[values[i]] = values[i + 1];
  2164. }
  2165. else if (key !== '' && key !== null) {
  2166. // null is a special value for explicitly removing a binding
  2167. warn(`Invalid value for dynamic directive argument (expected string or null): ${key}`, this);
  2168. }
  2169. }
  2170. return baseObj;
  2171. }
  2172. // helper to dynamically append modifier runtime markers to event names.
  2173. // ensure only append when value is already string, otherwise it will be cast
  2174. // to string and cause the type check to miss.
  2175. function prependModifier(value, symbol) {
  2176. return typeof value === 'string' ? symbol + value : value;
  2177. }
  2178. function installRenderHelpers(target) {
  2179. target._o = markOnce;
  2180. target._n = toNumber;
  2181. target._s = toString;
  2182. target._l = renderList;
  2183. target._t = renderSlot;
  2184. target._q = looseEqual;
  2185. target._i = looseIndexOf;
  2186. target._m = renderStatic;
  2187. target._f = resolveFilter;
  2188. target._k = checkKeyCodes;
  2189. target._b = bindObjectProps;
  2190. target._v = createTextVNode;
  2191. target._e = createEmptyVNode;
  2192. target._u = resolveScopedSlots;
  2193. target._g = bindObjectListeners;
  2194. target._d = bindDynamicKeys;
  2195. target._p = prependModifier;
  2196. }
  2197. /**
  2198. * Runtime helper for resolving raw children VNodes into a slot object.
  2199. */
  2200. function resolveSlots(children, context) {
  2201. if (!children || !children.length) {
  2202. return {};
  2203. }
  2204. const slots = {};
  2205. for (let i = 0, l = children.length; i < l; i++) {
  2206. const child = children[i];
  2207. const data = child.data;
  2208. // remove slot attribute if the node is resolved as a Vue slot node
  2209. if (data && data.attrs && data.attrs.slot) {
  2210. delete data.attrs.slot;
  2211. }
  2212. // named slots should only be respected if the vnode was rendered in the
  2213. // same context.
  2214. if ((child.context === context || child.fnContext === context) &&
  2215. data &&
  2216. data.slot != null) {
  2217. const name = data.slot;
  2218. const slot = slots[name] || (slots[name] = []);
  2219. if (child.tag === 'template') {
  2220. slot.push.apply(slot, child.children || []);
  2221. }
  2222. else {
  2223. slot.push(child);
  2224. }
  2225. }
  2226. else {
  2227. (slots.default || (slots.default = [])).push(child);
  2228. }
  2229. }
  2230. // ignore slots that contains only whitespace
  2231. for (const name in slots) {
  2232. if (slots[name].every(isWhitespace)) {
  2233. delete slots[name];
  2234. }
  2235. }
  2236. return slots;
  2237. }
  2238. function isWhitespace(node) {
  2239. return (node.isComment && !node.asyncFactory) || node.text === ' ';
  2240. }
  2241. function isAsyncPlaceholder(node) {
  2242. // @ts-expect-error not really boolean type
  2243. return node.isComment && node.asyncFactory;
  2244. }
  2245. function normalizeScopedSlots(ownerVm, scopedSlots, normalSlots, prevScopedSlots) {
  2246. let res;
  2247. const hasNormalSlots = Object.keys(normalSlots).length > 0;
  2248. const isStable = scopedSlots ? !!scopedSlots.$stable : !hasNormalSlots;
  2249. const key = scopedSlots && scopedSlots.$key;
  2250. if (!scopedSlots) {
  2251. res = {};
  2252. }
  2253. else if (scopedSlots._normalized) {
  2254. // fast path 1: child component re-render only, parent did not change
  2255. return scopedSlots._normalized;
  2256. }
  2257. else if (isStable &&
  2258. prevScopedSlots &&
  2259. prevScopedSlots !== emptyObject &&
  2260. key === prevScopedSlots.$key &&
  2261. !hasNormalSlots &&
  2262. !prevScopedSlots.$hasNormal) {
  2263. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  2264. // only need to normalize once
  2265. return prevScopedSlots;
  2266. }
  2267. else {
  2268. res = {};
  2269. for (const key in scopedSlots) {
  2270. if (scopedSlots[key] && key[0] !== '$') {
  2271. res[key] = normalizeScopedSlot(ownerVm, normalSlots, key, scopedSlots[key]);
  2272. }
  2273. }
  2274. }
  2275. // expose normal slots on scopedSlots
  2276. for (const key in normalSlots) {
  2277. if (!(key in res)) {
  2278. res[key] = proxyNormalSlot(normalSlots, key);
  2279. }
  2280. }
  2281. // avoriaz seems to mock a non-extensible $scopedSlots object
  2282. // and when that is passed down this would cause an error
  2283. if (scopedSlots && Object.isExtensible(scopedSlots)) {
  2284. scopedSlots._normalized = res;
  2285. }
  2286. def(res, '$stable', isStable);
  2287. def(res, '$key', key);
  2288. def(res, '$hasNormal', hasNormalSlots);
  2289. return res;
  2290. }
  2291. function normalizeScopedSlot(vm, normalSlots, key, fn) {
  2292. const normalized = function () {
  2293. const cur = currentInstance;
  2294. setCurrentInstance(vm);
  2295. let res = arguments.length ? fn.apply(null, arguments) : fn({});
  2296. res =
  2297. res && typeof res === 'object' && !isArray(res)
  2298. ? [res] // single vnode
  2299. : normalizeChildren(res);
  2300. const vnode = res && res[0];
  2301. setCurrentInstance(cur);
  2302. return res &&
  2303. (!vnode ||
  2304. (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode))) // #9658, #10391
  2305. ? undefined
  2306. : res;
  2307. };
  2308. // this is a slot using the new v-slot syntax without scope. although it is
  2309. // compiled as a scoped slot, render fn users would expect it to be present
  2310. // on this.$slots because the usage is semantically a normal slot.
  2311. if (fn.proxy) {
  2312. Object.defineProperty(normalSlots, key, {
  2313. get: normalized,
  2314. enumerable: true,
  2315. configurable: true
  2316. });
  2317. }
  2318. return normalized;
  2319. }
  2320. function proxyNormalSlot(slots, key) {
  2321. return () => slots[key];
  2322. }
  2323. function initSetup(vm) {
  2324. const options = vm.$options;
  2325. const setup = options.setup;
  2326. if (setup) {
  2327. const ctx = (vm._setupContext = createSetupContext(vm));
  2328. setCurrentInstance(vm);
  2329. pushTarget();
  2330. const setupResult = invokeWithErrorHandling(setup, null, [vm._props || shallowReactive({}), ctx], vm, `setup`);
  2331. popTarget();
  2332. setCurrentInstance();
  2333. if (isFunction(setupResult)) {
  2334. // render function
  2335. // @ts-ignore
  2336. options.render = setupResult;
  2337. }
  2338. else if (isObject(setupResult)) {
  2339. // bindings
  2340. if (setupResult instanceof VNode) {
  2341. warn(`setup() should not return VNodes directly - ` +
  2342. `return a render function instead.`);
  2343. }
  2344. vm._setupState = setupResult;
  2345. // __sfc indicates compiled bindings from <script setup>
  2346. if (!setupResult.__sfc) {
  2347. for (const key in setupResult) {
  2348. if (!isReserved(key)) {
  2349. proxyWithRefUnwrap(vm, setupResult, key);
  2350. }
  2351. else {
  2352. warn(`Avoid using variables that start with _ or $ in setup().`);
  2353. }
  2354. }
  2355. }
  2356. else {
  2357. // exposed for compiled render fn
  2358. const proxy = (vm._setupProxy = {});
  2359. for (const key in setupResult) {
  2360. if (key !== '__sfc') {
  2361. proxyWithRefUnwrap(proxy, setupResult, key);
  2362. }
  2363. }
  2364. }
  2365. }
  2366. else if (setupResult !== undefined) {
  2367. warn(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
  2368. }
  2369. }
  2370. }
  2371. function createSetupContext(vm) {
  2372. let exposeCalled = false;
  2373. return {
  2374. get attrs() {
  2375. if (!vm._attrsProxy) {
  2376. const proxy = (vm._attrsProxy = {});
  2377. def(proxy, '_v_attr_proxy', true);
  2378. syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs');
  2379. }
  2380. return vm._attrsProxy;
  2381. },
  2382. get listeners() {
  2383. if (!vm._listenersProxy) {
  2384. const proxy = (vm._listenersProxy = {});
  2385. syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners');
  2386. }
  2387. return vm._listenersProxy;
  2388. },
  2389. get slots() {
  2390. return initSlotsProxy(vm);
  2391. },
  2392. emit: bind(vm.$emit, vm),
  2393. expose(exposed) {
  2394. {
  2395. if (exposeCalled) {
  2396. warn(`expose() should be called only once per setup().`, vm);
  2397. }
  2398. exposeCalled = true;
  2399. }
  2400. if (exposed) {
  2401. Object.keys(exposed).forEach(key => proxyWithRefUnwrap(vm, exposed, key));
  2402. }
  2403. }
  2404. };
  2405. }
  2406. function syncSetupProxy(to, from, prev, instance, type) {
  2407. let changed = false;
  2408. for (const key in from) {
  2409. if (!(key in to)) {
  2410. changed = true;
  2411. defineProxyAttr(to, key, instance, type);
  2412. }
  2413. else if (from[key] !== prev[key]) {
  2414. changed = true;
  2415. }
  2416. }
  2417. for (const key in to) {
  2418. if (!(key in from)) {
  2419. changed = true;
  2420. delete to[key];
  2421. }
  2422. }
  2423. return changed;
  2424. }
  2425. function defineProxyAttr(proxy, key, instance, type) {
  2426. Object.defineProperty(proxy, key, {
  2427. enumerable: true,
  2428. configurable: true,
  2429. get() {
  2430. return instance[type][key];
  2431. }
  2432. });
  2433. }
  2434. function initSlotsProxy(vm) {
  2435. if (!vm._slotsProxy) {
  2436. syncSetupSlots((vm._slotsProxy = {}), vm.$scopedSlots);
  2437. }
  2438. return vm._slotsProxy;
  2439. }
  2440. function syncSetupSlots(to, from) {
  2441. for (const key in from) {
  2442. to[key] = from[key];
  2443. }
  2444. for (const key in to) {
  2445. if (!(key in from)) {
  2446. delete to[key];
  2447. }
  2448. }
  2449. }
  2450. /**
  2451. * @internal use manual type def because public setup context type relies on
  2452. * legacy VNode types
  2453. */
  2454. function useSlots() {
  2455. return getContext().slots;
  2456. }
  2457. /**
  2458. * @internal use manual type def because public setup context type relies on
  2459. * legacy VNode types
  2460. */
  2461. function useAttrs() {
  2462. return getContext().attrs;
  2463. }
  2464. /**
  2465. * Vue 2 only
  2466. * @internal use manual type def because public setup context type relies on
  2467. * legacy VNode types
  2468. */
  2469. function useListeners() {
  2470. return getContext().listeners;
  2471. }
  2472. function getContext() {
  2473. if (!currentInstance) {
  2474. warn(`useContext() called without active instance.`);
  2475. }
  2476. const vm = currentInstance;
  2477. return vm._setupContext || (vm._setupContext = createSetupContext(vm));
  2478. }
  2479. /**
  2480. * Runtime helper for merging default declarations. Imported by compiled code
  2481. * only.
  2482. * @internal
  2483. */
  2484. function mergeDefaults(raw, defaults) {
  2485. const props = isArray(raw)
  2486. ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
  2487. : raw;
  2488. for (const key in defaults) {
  2489. const opt = props[key];
  2490. if (opt) {
  2491. if (isArray(opt) || isFunction(opt)) {
  2492. props[key] = { type: opt, default: defaults[key] };
  2493. }
  2494. else {
  2495. opt.default = defaults[key];
  2496. }
  2497. }
  2498. else if (opt === null) {
  2499. props[key] = { default: defaults[key] };
  2500. }
  2501. else {
  2502. warn(`props default key "${key}" has no corresponding declaration.`);
  2503. }
  2504. }
  2505. return props;
  2506. }
  2507. function initRender(vm) {
  2508. vm._vnode = null; // the root of the child tree
  2509. vm._staticTrees = null; // v-once cached trees
  2510. const options = vm.$options;
  2511. const parentVnode = (vm.$vnode = options._parentVnode); // the placeholder node in parent tree
  2512. const renderContext = parentVnode && parentVnode.context;
  2513. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  2514. vm.$scopedSlots = parentVnode
  2515. ? normalizeScopedSlots(vm.$parent, parentVnode.data.scopedSlots, vm.$slots)
  2516. : emptyObject;
  2517. // bind the createElement fn to this instance
  2518. // so that we get proper render context inside it.
  2519. // args order: tag, data, children, normalizationType, alwaysNormalize
  2520. // internal version is used by render functions compiled from templates
  2521. // @ts-expect-error
  2522. vm._c = (a, b, c, d) => createElement$1(vm, a, b, c, d, false);
  2523. // normalization is always applied for the public version, used in
  2524. // user-written render functions.
  2525. // @ts-expect-error
  2526. vm.$createElement = (a, b, c, d) => createElement$1(vm, a, b, c, d, true);
  2527. // $attrs & $listeners are exposed for easier HOC creation.
  2528. // they need to be reactive so that HOCs using them are always updated
  2529. const parentData = parentVnode && parentVnode.data;
  2530. /* istanbul ignore else */
  2531. {
  2532. defineReactive(vm, '$attrs', (parentData && parentData.attrs) || emptyObject, () => {
  2533. !isUpdatingChildComponent && warn(`$attrs is readonly.`, vm);
  2534. }, true);
  2535. defineReactive(vm, '$listeners', options._parentListeners || emptyObject, () => {
  2536. !isUpdatingChildComponent && warn(`$listeners is readonly.`, vm);
  2537. }, true);
  2538. }
  2539. }
  2540. let currentRenderingInstance = null;
  2541. function renderMixin(Vue) {
  2542. // install runtime convenience helpers
  2543. installRenderHelpers(Vue.prototype);
  2544. Vue.prototype.$nextTick = function (fn) {
  2545. return nextTick(fn, this);
  2546. };
  2547. Vue.prototype._render = function () {
  2548. const vm = this;
  2549. const { render, _parentVnode } = vm.$options;
  2550. if (_parentVnode && vm._isMounted) {
  2551. vm.$scopedSlots = normalizeScopedSlots(vm.$parent, _parentVnode.data.scopedSlots, vm.$slots, vm.$scopedSlots);
  2552. if (vm._slotsProxy) {
  2553. syncSetupSlots(vm._slotsProxy, vm.$scopedSlots);
  2554. }
  2555. }
  2556. // set parent vnode. this allows render functions to have access
  2557. // to the data on the placeholder node.
  2558. vm.$vnode = _parentVnode;
  2559. // render self
  2560. const prevInst = currentInstance;
  2561. const prevRenderInst = currentRenderingInstance;
  2562. let vnode;
  2563. try {
  2564. setCurrentInstance(vm);
  2565. currentRenderingInstance = vm;
  2566. vnode = render.call(vm._renderProxy, vm.$createElement);
  2567. }
  2568. catch (e) {
  2569. handleError(e, vm, `render`);
  2570. // return error render result,
  2571. // or previous vnode to prevent render error causing blank component
  2572. /* istanbul ignore else */
  2573. if (vm.$options.renderError) {
  2574. try {
  2575. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  2576. }
  2577. catch (e) {
  2578. handleError(e, vm, `renderError`);
  2579. vnode = vm._vnode;
  2580. }
  2581. }
  2582. else {
  2583. vnode = vm._vnode;
  2584. }
  2585. }
  2586. finally {
  2587. currentRenderingInstance = prevRenderInst;
  2588. setCurrentInstance(prevInst);
  2589. }
  2590. // if the returned array contains only a single node, allow it
  2591. if (isArray(vnode) && vnode.length === 1) {
  2592. vnode = vnode[0];
  2593. }
  2594. // return empty vnode in case the render function errored out
  2595. if (!(vnode instanceof VNode)) {
  2596. if (isArray(vnode)) {
  2597. warn('Multiple root nodes returned from render function. Render function ' +
  2598. 'should return a single root node.', vm);
  2599. }
  2600. vnode = createEmptyVNode();
  2601. }
  2602. // set parent
  2603. vnode.parent = _parentVnode;
  2604. return vnode;
  2605. };
  2606. }
  2607. function ensureCtor(comp, base) {
  2608. if (comp.__esModule || (hasSymbol && comp[Symbol.toStringTag] === 'Module')) {
  2609. comp = comp.default;
  2610. }
  2611. return isObject(comp) ? base.extend(comp) : comp;
  2612. }
  2613. function createAsyncPlaceholder(factory, data, context, children, tag) {
  2614. const node = createEmptyVNode();
  2615. node.asyncFactory = factory;
  2616. node.asyncMeta = { data, context, children, tag };
  2617. return node;
  2618. }
  2619. function resolveAsyncComponent(factory, baseCtor) {
  2620. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  2621. return factory.errorComp;
  2622. }
  2623. if (isDef(factory.resolved)) {
  2624. return factory.resolved;
  2625. }
  2626. const owner = currentRenderingInstance;
  2627. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  2628. // already pending
  2629. factory.owners.push(owner);
  2630. }
  2631. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  2632. return factory.loadingComp;
  2633. }
  2634. if (owner && !isDef(factory.owners)) {
  2635. const owners = (factory.owners = [owner]);
  2636. let sync = true;
  2637. let timerLoading = null;
  2638. let timerTimeout = null;
  2639. owner.$on('hook:destroyed', () => remove$2(owners, owner));
  2640. const forceRender = (renderCompleted) => {
  2641. for (let i = 0, l = owners.length; i < l; i++) {
  2642. owners[i].$forceUpdate();
  2643. }
  2644. if (renderCompleted) {
  2645. owners.length = 0;
  2646. if (timerLoading !== null) {
  2647. clearTimeout(timerLoading);
  2648. timerLoading = null;
  2649. }
  2650. if (timerTimeout !== null) {
  2651. clearTimeout(timerTimeout);
  2652. timerTimeout = null;
  2653. }
  2654. }
  2655. };
  2656. const resolve = once((res) => {
  2657. // cache resolved
  2658. factory.resolved = ensureCtor(res, baseCtor);
  2659. // invoke callbacks only if this is not a synchronous resolve
  2660. // (async resolves are shimmed as synchronous during SSR)
  2661. if (!sync) {
  2662. forceRender(true);
  2663. }
  2664. else {
  2665. owners.length = 0;
  2666. }
  2667. });
  2668. const reject = once(reason => {
  2669. warn(`Failed to resolve async component: ${String(factory)}` +
  2670. (reason ? `\nReason: ${reason}` : ''));
  2671. if (isDef(factory.errorComp)) {
  2672. factory.error = true;
  2673. forceRender(true);
  2674. }
  2675. });
  2676. const res = factory(resolve, reject);
  2677. if (isObject(res)) {
  2678. if (isPromise(res)) {
  2679. // () => Promise
  2680. if (isUndef(factory.resolved)) {
  2681. res.then(resolve, reject);
  2682. }
  2683. }
  2684. else if (isPromise(res.component)) {
  2685. res.component.then(resolve, reject);
  2686. if (isDef(res.error)) {
  2687. factory.errorComp = ensureCtor(res.error, baseCtor);
  2688. }
  2689. if (isDef(res.loading)) {
  2690. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  2691. if (res.delay === 0) {
  2692. factory.loading = true;
  2693. }
  2694. else {
  2695. // @ts-expect-error NodeJS timeout type
  2696. timerLoading = setTimeout(() => {
  2697. timerLoading = null;
  2698. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  2699. factory.loading = true;
  2700. forceRender(false);
  2701. }
  2702. }, res.delay || 200);
  2703. }
  2704. }
  2705. if (isDef(res.timeout)) {
  2706. // @ts-expect-error NodeJS timeout type
  2707. timerTimeout = setTimeout(() => {
  2708. timerTimeout = null;
  2709. if (isUndef(factory.resolved)) {
  2710. reject(`timeout (${res.timeout}ms)` );
  2711. }
  2712. }, res.timeout);
  2713. }
  2714. }
  2715. }
  2716. sync = false;
  2717. // return in case resolved synchronously
  2718. return factory.loading ? factory.loadingComp : factory.resolved;
  2719. }
  2720. }
  2721. function getFirstComponentChild(children) {
  2722. if (isArray(children)) {
  2723. for (let i = 0; i < children.length; i++) {
  2724. const c = children[i];
  2725. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  2726. return c;
  2727. }
  2728. }
  2729. }
  2730. }
  2731. const SIMPLE_NORMALIZE = 1;
  2732. const ALWAYS_NORMALIZE = 2;
  2733. // wrapper function for providing a more flexible interface
  2734. // without getting yelled at by flow
  2735. function createElement$1(context, tag, data, children, normalizationType, alwaysNormalize) {
  2736. if (isArray(data) || isPrimitive(data)) {
  2737. normalizationType = children;
  2738. children = data;
  2739. data = undefined;
  2740. }
  2741. if (isTrue(alwaysNormalize)) {
  2742. normalizationType = ALWAYS_NORMALIZE;
  2743. }
  2744. return _createElement(context, tag, data, children, normalizationType);
  2745. }
  2746. function _createElement(context, tag, data, children, normalizationType) {
  2747. if (isDef(data) && isDef(data.__ob__)) {
  2748. warn(`Avoid using observed data object as vnode data: ${JSON.stringify(data)}\n` + 'Always create fresh vnode data objects in each render!', context);
  2749. return createEmptyVNode();
  2750. }
  2751. // object syntax in v-bind
  2752. if (isDef(data) && isDef(data.is)) {
  2753. tag = data.is;
  2754. }
  2755. if (!tag) {
  2756. // in case of component :is set to falsy value
  2757. return createEmptyVNode();
  2758. }
  2759. // warn against non-primitive key
  2760. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)) {
  2761. warn('Avoid using non-primitive value as key, ' +
  2762. 'use string/number value instead.', context);
  2763. }
  2764. // support single function children as default scoped slot
  2765. if (isArray(children) && isFunction(children[0])) {
  2766. data = data || {};
  2767. data.scopedSlots = { default: children[0] };
  2768. children.length = 0;
  2769. }
  2770. if (normalizationType === ALWAYS_NORMALIZE) {
  2771. children = normalizeChildren(children);
  2772. }
  2773. else if (normalizationType === SIMPLE_NORMALIZE) {
  2774. children = simpleNormalizeChildren(children);
  2775. }
  2776. let vnode, ns;
  2777. if (typeof tag === 'string') {
  2778. let Ctor;
  2779. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  2780. if (config.isReservedTag(tag)) {
  2781. // platform built-in elements
  2782. if (isDef(data) &&
  2783. isDef(data.nativeOn) &&
  2784. data.tag !== 'component') {
  2785. warn(`The .native modifier for v-on is only valid on components but it was used on <${tag}>.`, context);
  2786. }
  2787. vnode = new VNode(config.parsePlatformTagName(tag), data, children, undefined, undefined, context);
  2788. }
  2789. else if ((!data || !data.pre) &&
  2790. isDef((Ctor = resolveAsset(context.$options, 'components', tag)))) {
  2791. // component
  2792. vnode = createComponent(Ctor, data, context, children, tag);
  2793. }
  2794. else {
  2795. // unknown or unlisted namespaced elements
  2796. // check at runtime because it may get assigned a namespace when its
  2797. // parent normalizes children
  2798. vnode = new VNode(tag, data, children, undefined, undefined, context);
  2799. }
  2800. }
  2801. else {
  2802. // direct component options / constructor
  2803. vnode = createComponent(tag, data, context, children);
  2804. }
  2805. if (isArray(vnode)) {
  2806. return vnode;
  2807. }
  2808. else if (isDef(vnode)) {
  2809. if (isDef(ns))
  2810. applyNS(vnode, ns);
  2811. if (isDef(data))
  2812. registerDeepBindings(data);
  2813. return vnode;
  2814. }
  2815. else {
  2816. return createEmptyVNode();
  2817. }
  2818. }
  2819. function applyNS(vnode, ns, force) {
  2820. vnode.ns = ns;
  2821. if (vnode.tag === 'foreignObject') {
  2822. // use default namespace inside foreignObject
  2823. ns = undefined;
  2824. force = true;
  2825. }
  2826. if (isDef(vnode.children)) {
  2827. for (let i = 0, l = vnode.children.length; i < l; i++) {
  2828. const child = vnode.children[i];
  2829. if (isDef(child.tag) &&
  2830. (isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  2831. applyNS(child, ns, force);
  2832. }
  2833. }
  2834. }
  2835. }
  2836. // ref #5318
  2837. // necessary to ensure parent re-render when deep bindings like :style and
  2838. // :class are used on slot nodes
  2839. function registerDeepBindings(data) {
  2840. if (isObject(data.style)) {
  2841. traverse(data.style);
  2842. }
  2843. if (isObject(data.class)) {
  2844. traverse(data.class);
  2845. }
  2846. }
  2847. /**
  2848. * @internal this function needs manual public type declaration because it relies
  2849. * on previously manually authored types from Vue 2
  2850. */
  2851. function h(type, props, children) {
  2852. if (!currentInstance) {
  2853. warn(`globally imported h() can only be invoked when there is an active ` +
  2854. `component instance, e.g. synchronously in a component's render or setup function.`);
  2855. }
  2856. return createElement$1(currentInstance, type, props, children, 2, true);
  2857. }
  2858. function handleError(err, vm, info) {
  2859. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  2860. // See: https://github.com/vuejs/vuex/issues/1505
  2861. pushTarget();
  2862. try {
  2863. if (vm) {
  2864. let cur = vm;
  2865. while ((cur = cur.$parent)) {
  2866. const hooks = cur.$options.errorCaptured;
  2867. if (hooks) {
  2868. for (let i = 0; i < hooks.length; i++) {
  2869. try {
  2870. const capture = hooks[i].call(cur, err, vm, info) === false;
  2871. if (capture)
  2872. return;
  2873. }
  2874. catch (e) {
  2875. globalHandleError(e, cur, 'errorCaptured hook');
  2876. }
  2877. }
  2878. }
  2879. }
  2880. }
  2881. globalHandleError(err, vm, info);
  2882. }
  2883. finally {
  2884. popTarget();
  2885. }
  2886. }
  2887. function invokeWithErrorHandling(handler, context, args, vm, info) {
  2888. let res;
  2889. try {
  2890. res = args ? handler.apply(context, args) : handler.call(context);
  2891. if (res && !res._isVue && isPromise(res) && !res._handled) {
  2892. res.catch(e => handleError(e, vm, info + ` (Promise/async)`));
  2893. res._handled = true;
  2894. }
  2895. }
  2896. catch (e) {
  2897. handleError(e, vm, info);
  2898. }
  2899. return res;
  2900. }
  2901. function globalHandleError(err, vm, info) {
  2902. if (config.errorHandler) {
  2903. try {
  2904. return config.errorHandler.call(null, err, vm, info);
  2905. }
  2906. catch (e) {
  2907. // if the user intentionally throws the original error in the handler,
  2908. // do not log it twice
  2909. if (e !== err) {
  2910. logError(e, null, 'config.errorHandler');
  2911. }
  2912. }
  2913. }
  2914. logError(err, vm, info);
  2915. }
  2916. function logError(err, vm, info) {
  2917. {
  2918. warn(`Error in ${info}: "${err.toString()}"`, vm);
  2919. }
  2920. /* istanbul ignore else */
  2921. if (inBrowser && typeof console !== 'undefined') {
  2922. console.error(err);
  2923. }
  2924. else {
  2925. throw err;
  2926. }
  2927. }
  2928. /* globals MutationObserver */
  2929. let isUsingMicroTask = false;
  2930. const callbacks = [];
  2931. let pending = false;
  2932. function flushCallbacks() {
  2933. pending = false;
  2934. const copies = callbacks.slice(0);
  2935. callbacks.length = 0;
  2936. for (let i = 0; i < copies.length; i++) {
  2937. copies[i]();
  2938. }
  2939. }
  2940. // Here we have async deferring wrappers using microtasks.
  2941. // In 2.5 we used (macro) tasks (in combination with microtasks).
  2942. // However, it has subtle problems when state is changed right before repaint
  2943. // (e.g. #6813, out-in transitions).
  2944. // Also, using (macro) tasks in event handler would cause some weird behaviors
  2945. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  2946. // So we now use microtasks everywhere, again.
  2947. // A major drawback of this tradeoff is that there are some scenarios
  2948. // where microtasks have too high a priority and fire in between supposedly
  2949. // sequential events (e.g. #4521, #6690, which have workarounds)
  2950. // or even between bubbling of the same event (#6566).
  2951. let timerFunc;
  2952. // The nextTick behavior leverages the microtask queue, which can be accessed
  2953. // via either native Promise.then or MutationObserver.
  2954. // MutationObserver has wider support, however it is seriously bugged in
  2955. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  2956. // completely stops working after triggering a few times... so, if native
  2957. // Promise is available, we will use it:
  2958. /* istanbul ignore next, $flow-disable-line */
  2959. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  2960. const p = Promise.resolve();
  2961. timerFunc = () => {
  2962. p.then(flushCallbacks);
  2963. // In problematic UIWebViews, Promise.then doesn't completely break, but
  2964. // it can get stuck in a weird state where callbacks are pushed into the
  2965. // microtask queue but the queue isn't being flushed, until the browser
  2966. // needs to do some other work, e.g. handle a timer. Therefore we can
  2967. // "force" the microtask queue to be flushed by adding an empty timer.
  2968. if (isIOS)
  2969. setTimeout(noop);
  2970. };
  2971. isUsingMicroTask = true;
  2972. }
  2973. else if (!isIE &&
  2974. typeof MutationObserver !== 'undefined' &&
  2975. (isNative(MutationObserver) ||
  2976. // PhantomJS and iOS 7.x
  2977. MutationObserver.toString() === '[object MutationObserverConstructor]')) {
  2978. // Use MutationObserver where native Promise is not available,
  2979. // e.g. PhantomJS, iOS7, Android 4.4
  2980. // (#6466 MutationObserver is unreliable in IE11)
  2981. let counter = 1;
  2982. const observer = new MutationObserver(flushCallbacks);
  2983. const textNode = document.createTextNode(String(counter));
  2984. observer.observe(textNode, {
  2985. characterData: true
  2986. });
  2987. timerFunc = () => {
  2988. counter = (counter + 1) % 2;
  2989. textNode.data = String(counter);
  2990. };
  2991. isUsingMicroTask = true;
  2992. }
  2993. else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  2994. // Fallback to setImmediate.
  2995. // Technically it leverages the (macro) task queue,
  2996. // but it is still a better choice than setTimeout.
  2997. timerFunc = () => {
  2998. setImmediate(flushCallbacks);
  2999. };
  3000. }
  3001. else {
  3002. // Fallback to setTimeout.
  3003. timerFunc = () => {
  3004. setTimeout(flushCallbacks, 0);
  3005. };
  3006. }
  3007. /**
  3008. * @internal
  3009. */
  3010. function nextTick(cb, ctx) {
  3011. let _resolve;
  3012. callbacks.push(() => {
  3013. if (cb) {
  3014. try {
  3015. cb.call(ctx);
  3016. }
  3017. catch (e) {
  3018. handleError(e, ctx, 'nextTick');
  3019. }
  3020. }
  3021. else if (_resolve) {
  3022. _resolve(ctx);
  3023. }
  3024. });
  3025. if (!pending) {
  3026. pending = true;
  3027. timerFunc();
  3028. }
  3029. // $flow-disable-line
  3030. if (!cb && typeof Promise !== 'undefined') {
  3031. return new Promise(resolve => {
  3032. _resolve = resolve;
  3033. });
  3034. }
  3035. }
  3036. function useCssModule(name = '$style') {
  3037. /* istanbul ignore else */
  3038. {
  3039. if (!currentInstance) {
  3040. warn(`useCssModule must be called inside setup()`);
  3041. return emptyObject;
  3042. }
  3043. const mod = currentInstance[name];
  3044. if (!mod) {
  3045. warn(`Current instance does not have CSS module named "${name}".`);
  3046. return emptyObject;
  3047. }
  3048. return mod;
  3049. }
  3050. }
  3051. /**
  3052. * Runtime helper for SFC's CSS variable injection feature.
  3053. * @private
  3054. */
  3055. function useCssVars(getter) {
  3056. if (!inBrowser && !false)
  3057. return;
  3058. const instance = currentInstance;
  3059. if (!instance) {
  3060. warn(`useCssVars is called without current active component instance.`);
  3061. return;
  3062. }
  3063. watchPostEffect(() => {
  3064. const el = instance.$el;
  3065. const vars = getter(instance, instance._setupProxy);
  3066. if (el && el.nodeType === 1) {
  3067. const style = el.style;
  3068. for (const key in vars) {
  3069. style.setProperty(`--${key}`, vars[key]);
  3070. }
  3071. }
  3072. });
  3073. }
  3074. /**
  3075. * v3-compatible async component API.
  3076. * @internal the type is manually declared in <root>/types/v3-define-async-component.d.ts
  3077. * because it relies on existing manual types
  3078. */
  3079. function defineAsyncComponent(source) {
  3080. if (isFunction(source)) {
  3081. source = { loader: source };
  3082. }
  3083. const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
  3084. suspensible = false, // in Vue 3 default is true
  3085. onError: userOnError } = source;
  3086. if (suspensible) {
  3087. warn(`The suspensible option for async components is not supported in Vue2. It is ignored.`);
  3088. }
  3089. let pendingRequest = null;
  3090. let retries = 0;
  3091. const retry = () => {
  3092. retries++;
  3093. pendingRequest = null;
  3094. return load();
  3095. };
  3096. const load = () => {
  3097. let thisRequest;
  3098. return (pendingRequest ||
  3099. (thisRequest = pendingRequest =
  3100. loader()
  3101. .catch(err => {
  3102. err = err instanceof Error ? err : new Error(String(err));
  3103. if (userOnError) {
  3104. return new Promise((resolve, reject) => {
  3105. const userRetry = () => resolve(retry());
  3106. const userFail = () => reject(err);
  3107. userOnError(err, userRetry, userFail, retries + 1);
  3108. });
  3109. }
  3110. else {
  3111. throw err;
  3112. }
  3113. })
  3114. .then((comp) => {
  3115. if (thisRequest !== pendingRequest && pendingRequest) {
  3116. return pendingRequest;
  3117. }
  3118. if (!comp) {
  3119. warn(`Async component loader resolved to undefined. ` +
  3120. `If you are using retry(), make sure to return its return value.`);
  3121. }
  3122. // interop module default
  3123. if (comp &&
  3124. (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
  3125. comp = comp.default;
  3126. }
  3127. if (comp && !isObject(comp) && !isFunction(comp)) {
  3128. throw new Error(`Invalid async component load result: ${comp}`);
  3129. }
  3130. return comp;
  3131. })));
  3132. };
  3133. return () => {
  3134. const component = load();
  3135. return {
  3136. component,
  3137. delay,
  3138. timeout,
  3139. error: errorComponent,
  3140. loading: loadingComponent
  3141. };
  3142. };
  3143. }
  3144. function createLifeCycle(hookName) {
  3145. return (fn, target = currentInstance) => {
  3146. if (!target) {
  3147. warn(`${formatName(hookName)} is called when there is no active component instance to be ` +
  3148. `associated with. ` +
  3149. `Lifecycle injection APIs can only be used during execution of setup().`);
  3150. return;
  3151. }
  3152. return injectHook(target, hookName, fn);
  3153. };
  3154. }
  3155. function formatName(name) {
  3156. if (name === 'beforeDestroy') {
  3157. name = 'beforeUnmount';
  3158. }
  3159. else if (name === 'destroyed') {
  3160. name = 'unmounted';
  3161. }
  3162. return `on${name[0].toUpperCase() + name.slice(1)}`;
  3163. }
  3164. function injectHook(instance, hookName, fn) {
  3165. const options = instance.$options;
  3166. options[hookName] = mergeLifecycleHook(options[hookName], fn);
  3167. }
  3168. const onBeforeMount = createLifeCycle('beforeMount');
  3169. const onMounted = createLifeCycle('mounted');
  3170. const onBeforeUpdate = createLifeCycle('beforeUpdate');
  3171. const onUpdated = createLifeCycle('updated');
  3172. const onBeforeUnmount = createLifeCycle('beforeDestroy');
  3173. const onUnmounted = createLifeCycle('destroyed');
  3174. const onActivated = createLifeCycle('activated');
  3175. const onDeactivated = createLifeCycle('deactivated');
  3176. const onServerPrefetch = createLifeCycle('serverPrefetch');
  3177. const onRenderTracked = createLifeCycle('renderTracked');
  3178. const onRenderTriggered = createLifeCycle('renderTriggered');
  3179. const injectErrorCapturedHook = createLifeCycle('errorCaptured');
  3180. function onErrorCaptured(hook, target = currentInstance) {
  3181. injectErrorCapturedHook(hook, target);
  3182. }
  3183. /**
  3184. * Note: also update dist/vue.runtime.mjs when adding new exports to this file.
  3185. */
  3186. const version = '2.7.16';
  3187. /**
  3188. * @internal type is manually declared in <root>/types/v3-define-component.d.ts
  3189. */
  3190. function defineComponent(options) {
  3191. return options;
  3192. }
  3193. var vca = /*#__PURE__*/Object.freeze({
  3194. __proto__: null,
  3195. version: version,
  3196. defineComponent: defineComponent,
  3197. ref: ref$1,
  3198. shallowRef: shallowRef,
  3199. isRef: isRef,
  3200. toRef: toRef,
  3201. toRefs: toRefs,
  3202. unref: unref,
  3203. proxyRefs: proxyRefs,
  3204. customRef: customRef,
  3205. triggerRef: triggerRef,
  3206. reactive: reactive,
  3207. isReactive: isReactive,
  3208. isReadonly: isReadonly,
  3209. isShallow: isShallow,
  3210. isProxy: isProxy,
  3211. shallowReactive: shallowReactive,
  3212. markRaw: markRaw,
  3213. toRaw: toRaw,
  3214. readonly: readonly,
  3215. shallowReadonly: shallowReadonly,
  3216. computed: computed,
  3217. watch: watch,
  3218. watchEffect: watchEffect,
  3219. watchPostEffect: watchPostEffect,
  3220. watchSyncEffect: watchSyncEffect,
  3221. EffectScope: EffectScope,
  3222. effectScope: effectScope,
  3223. onScopeDispose: onScopeDispose,
  3224. getCurrentScope: getCurrentScope,
  3225. provide: provide,
  3226. inject: inject,
  3227. h: h,
  3228. getCurrentInstance: getCurrentInstance,
  3229. useSlots: useSlots,
  3230. useAttrs: useAttrs,
  3231. useListeners: useListeners,
  3232. mergeDefaults: mergeDefaults,
  3233. nextTick: nextTick,
  3234. set: set,
  3235. del: del,
  3236. useCssModule: useCssModule,
  3237. useCssVars: useCssVars,
  3238. defineAsyncComponent: defineAsyncComponent,
  3239. onBeforeMount: onBeforeMount,
  3240. onMounted: onMounted,
  3241. onBeforeUpdate: onBeforeUpdate,
  3242. onUpdated: onUpdated,
  3243. onBeforeUnmount: onBeforeUnmount,
  3244. onUnmounted: onUnmounted,
  3245. onActivated: onActivated,
  3246. onDeactivated: onDeactivated,
  3247. onServerPrefetch: onServerPrefetch,
  3248. onRenderTracked: onRenderTracked,
  3249. onRenderTriggered: onRenderTriggered,
  3250. onErrorCaptured: onErrorCaptured
  3251. });
  3252. const seenObjects = new _Set();
  3253. /**
  3254. * Recursively traverse an object to evoke all converted
  3255. * getters, so that every nested property inside the object
  3256. * is collected as a "deep" dependency.
  3257. */
  3258. function traverse(val) {
  3259. _traverse(val, seenObjects);
  3260. seenObjects.clear();
  3261. return val;
  3262. }
  3263. function _traverse(val, seen) {
  3264. let i, keys;
  3265. const isA = isArray(val);
  3266. if ((!isA && !isObject(val)) ||
  3267. val.__v_skip /* ReactiveFlags.SKIP */ ||
  3268. Object.isFrozen(val) ||
  3269. val instanceof VNode) {
  3270. return;
  3271. }
  3272. if (val.__ob__) {
  3273. const depId = val.__ob__.dep.id;
  3274. if (seen.has(depId)) {
  3275. return;
  3276. }
  3277. seen.add(depId);
  3278. }
  3279. if (isA) {
  3280. i = val.length;
  3281. while (i--)
  3282. _traverse(val[i], seen);
  3283. }
  3284. else if (isRef(val)) {
  3285. _traverse(val.value, seen);
  3286. }
  3287. else {
  3288. keys = Object.keys(val);
  3289. i = keys.length;
  3290. while (i--)
  3291. _traverse(val[keys[i]], seen);
  3292. }
  3293. }
  3294. let uid$1 = 0;
  3295. /**
  3296. * A watcher parses an expression, collects dependencies,
  3297. * and fires callback when the expression value changes.
  3298. * This is used for both the $watch() api and directives.
  3299. * @internal
  3300. */
  3301. class Watcher {
  3302. constructor(vm, expOrFn, cb, options, isRenderWatcher) {
  3303. recordEffectScope(this,
  3304. // if the active effect scope is manually created (not a component scope),
  3305. // prioritize it
  3306. activeEffectScope && !activeEffectScope._vm
  3307. ? activeEffectScope
  3308. : vm
  3309. ? vm._scope
  3310. : undefined);
  3311. if ((this.vm = vm) && isRenderWatcher) {
  3312. vm._watcher = this;
  3313. }
  3314. // options
  3315. if (options) {
  3316. this.deep = !!options.deep;
  3317. this.user = !!options.user;
  3318. this.lazy = !!options.lazy;
  3319. this.sync = !!options.sync;
  3320. this.before = options.before;
  3321. {
  3322. this.onTrack = options.onTrack;
  3323. this.onTrigger = options.onTrigger;
  3324. }
  3325. }
  3326. else {
  3327. this.deep = this.user = this.lazy = this.sync = false;
  3328. }
  3329. this.cb = cb;
  3330. this.id = ++uid$1; // uid for batching
  3331. this.active = true;
  3332. this.post = false;
  3333. this.dirty = this.lazy; // for lazy watchers
  3334. this.deps = [];
  3335. this.newDeps = [];
  3336. this.depIds = new _Set();
  3337. this.newDepIds = new _Set();
  3338. this.expression = expOrFn.toString() ;
  3339. // parse expression for getter
  3340. if (isFunction(expOrFn)) {
  3341. this.getter = expOrFn;
  3342. }
  3343. else {
  3344. this.getter = parsePath(expOrFn);
  3345. if (!this.getter) {
  3346. this.getter = noop;
  3347. warn(`Failed watching path: "${expOrFn}" ` +
  3348. 'Watcher only accepts simple dot-delimited paths. ' +
  3349. 'For full control, use a function instead.', vm);
  3350. }
  3351. }
  3352. this.value = this.lazy ? undefined : this.get();
  3353. }
  3354. /**
  3355. * Evaluate the getter, and re-collect dependencies.
  3356. */
  3357. get() {
  3358. pushTarget(this);
  3359. let value;
  3360. const vm = this.vm;
  3361. try {
  3362. value = this.getter.call(vm, vm);
  3363. }
  3364. catch (e) {
  3365. if (this.user) {
  3366. handleError(e, vm, `getter for watcher "${this.expression}"`);
  3367. }
  3368. else {
  3369. throw e;
  3370. }
  3371. }
  3372. finally {
  3373. // "touch" every property so they are all tracked as
  3374. // dependencies for deep watching
  3375. if (this.deep) {
  3376. traverse(value);
  3377. }
  3378. popTarget();
  3379. this.cleanupDeps();
  3380. }
  3381. return value;
  3382. }
  3383. /**
  3384. * Add a dependency to this directive.
  3385. */
  3386. addDep(dep) {
  3387. const id = dep.id;
  3388. if (!this.newDepIds.has(id)) {
  3389. this.newDepIds.add(id);
  3390. this.newDeps.push(dep);
  3391. if (!this.depIds.has(id)) {
  3392. dep.addSub(this);
  3393. }
  3394. }
  3395. }
  3396. /**
  3397. * Clean up for dependency collection.
  3398. */
  3399. cleanupDeps() {
  3400. let i = this.deps.length;
  3401. while (i--) {
  3402. const dep = this.deps[i];
  3403. if (!this.newDepIds.has(dep.id)) {
  3404. dep.removeSub(this);
  3405. }
  3406. }
  3407. let tmp = this.depIds;
  3408. this.depIds = this.newDepIds;
  3409. this.newDepIds = tmp;
  3410. this.newDepIds.clear();
  3411. tmp = this.deps;
  3412. this.deps = this.newDeps;
  3413. this.newDeps = tmp;
  3414. this.newDeps.length = 0;
  3415. }
  3416. /**
  3417. * Subscriber interface.
  3418. * Will be called when a dependency changes.
  3419. */
  3420. update() {
  3421. /* istanbul ignore else */
  3422. if (this.lazy) {
  3423. this.dirty = true;
  3424. }
  3425. else if (this.sync) {
  3426. this.run();
  3427. }
  3428. else {
  3429. queueWatcher(this);
  3430. }
  3431. }
  3432. /**
  3433. * Scheduler job interface.
  3434. * Will be called by the scheduler.
  3435. */
  3436. run() {
  3437. if (this.active) {
  3438. const value = this.get();
  3439. if (value !== this.value ||
  3440. // Deep watchers and watchers on Object/Arrays should fire even
  3441. // when the value is the same, because the value may
  3442. // have mutated.
  3443. isObject(value) ||
  3444. this.deep) {
  3445. // set new value
  3446. const oldValue = this.value;
  3447. this.value = value;
  3448. if (this.user) {
  3449. const info = `callback for watcher "${this.expression}"`;
  3450. invokeWithErrorHandling(this.cb, this.vm, [value, oldValue], this.vm, info);
  3451. }
  3452. else {
  3453. this.cb.call(this.vm, value, oldValue);
  3454. }
  3455. }
  3456. }
  3457. }
  3458. /**
  3459. * Evaluate the value of the watcher.
  3460. * This only gets called for lazy watchers.
  3461. */
  3462. evaluate() {
  3463. this.value = this.get();
  3464. this.dirty = false;
  3465. }
  3466. /**
  3467. * Depend on all deps collected by this watcher.
  3468. */
  3469. depend() {
  3470. let i = this.deps.length;
  3471. while (i--) {
  3472. this.deps[i].depend();
  3473. }
  3474. }
  3475. /**
  3476. * Remove self from all dependencies' subscriber list.
  3477. */
  3478. teardown() {
  3479. if (this.vm && !this.vm._isBeingDestroyed) {
  3480. remove$2(this.vm._scope.effects, this);
  3481. }
  3482. if (this.active) {
  3483. let i = this.deps.length;
  3484. while (i--) {
  3485. this.deps[i].removeSub(this);
  3486. }
  3487. this.active = false;
  3488. if (this.onStop) {
  3489. this.onStop();
  3490. }
  3491. }
  3492. }
  3493. }
  3494. let mark;
  3495. let measure;
  3496. {
  3497. const perf = inBrowser && window.performance;
  3498. /* istanbul ignore if */
  3499. if (perf &&
  3500. // @ts-ignore
  3501. perf.mark &&
  3502. // @ts-ignore
  3503. perf.measure &&
  3504. // @ts-ignore
  3505. perf.clearMarks &&
  3506. // @ts-ignore
  3507. perf.clearMeasures) {
  3508. mark = tag => perf.mark(tag);
  3509. measure = (name, startTag, endTag) => {
  3510. perf.measure(name, startTag, endTag);
  3511. perf.clearMarks(startTag);
  3512. perf.clearMarks(endTag);
  3513. // perf.clearMeasures(name)
  3514. };
  3515. }
  3516. }
  3517. function initEvents(vm) {
  3518. vm._events = Object.create(null);
  3519. vm._hasHookEvent = false;
  3520. // init parent attached events
  3521. const listeners = vm.$options._parentListeners;
  3522. if (listeners) {
  3523. updateComponentListeners(vm, listeners);
  3524. }
  3525. }
  3526. let target$1;
  3527. function add$1(event, fn) {
  3528. target$1.$on(event, fn);
  3529. }
  3530. function remove$1(event, fn) {
  3531. target$1.$off(event, fn);
  3532. }
  3533. function createOnceHandler$1(event, fn) {
  3534. const _target = target$1;
  3535. return function onceHandler() {
  3536. const res = fn.apply(null, arguments);
  3537. if (res !== null) {
  3538. _target.$off(event, onceHandler);
  3539. }
  3540. };
  3541. }
  3542. function updateComponentListeners(vm, listeners, oldListeners) {
  3543. target$1 = vm;
  3544. updateListeners(listeners, oldListeners || {}, add$1, remove$1, createOnceHandler$1, vm);
  3545. target$1 = undefined;
  3546. }
  3547. function eventsMixin(Vue) {
  3548. const hookRE = /^hook:/;
  3549. Vue.prototype.$on = function (event, fn) {
  3550. const vm = this;
  3551. if (isArray(event)) {
  3552. for (let i = 0, l = event.length; i < l; i++) {
  3553. vm.$on(event[i], fn);
  3554. }
  3555. }
  3556. else {
  3557. (vm._events[event] || (vm._events[event] = [])).push(fn);
  3558. // optimize hook:event cost by using a boolean flag marked at registration
  3559. // instead of a hash lookup
  3560. if (hookRE.test(event)) {
  3561. vm._hasHookEvent = true;
  3562. }
  3563. }
  3564. return vm;
  3565. };
  3566. Vue.prototype.$once = function (event, fn) {
  3567. const vm = this;
  3568. function on() {
  3569. vm.$off(event, on);
  3570. fn.apply(vm, arguments);
  3571. }
  3572. on.fn = fn;
  3573. vm.$on(event, on);
  3574. return vm;
  3575. };
  3576. Vue.prototype.$off = function (event, fn) {
  3577. const vm = this;
  3578. // all
  3579. if (!arguments.length) {
  3580. vm._events = Object.create(null);
  3581. return vm;
  3582. }
  3583. // array of events
  3584. if (isArray(event)) {
  3585. for (let i = 0, l = event.length; i < l; i++) {
  3586. vm.$off(event[i], fn);
  3587. }
  3588. return vm;
  3589. }
  3590. // specific event
  3591. const cbs = vm._events[event];
  3592. if (!cbs) {
  3593. return vm;
  3594. }
  3595. if (!fn) {
  3596. vm._events[event] = null;
  3597. return vm;
  3598. }
  3599. // specific handler
  3600. let cb;
  3601. let i = cbs.length;
  3602. while (i--) {
  3603. cb = cbs[i];
  3604. if (cb === fn || cb.fn === fn) {
  3605. cbs.splice(i, 1);
  3606. break;
  3607. }
  3608. }
  3609. return vm;
  3610. };
  3611. Vue.prototype.$emit = function (event) {
  3612. const vm = this;
  3613. {
  3614. const lowerCaseEvent = event.toLowerCase();
  3615. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  3616. tip(`Event "${lowerCaseEvent}" is emitted in component ` +
  3617. `${formatComponentName(vm)} but the handler is registered for "${event}". ` +
  3618. `Note that HTML attributes are case-insensitive and you cannot use ` +
  3619. `v-on to listen to camelCase events when using in-DOM templates. ` +
  3620. `You should probably use "${hyphenate(event)}" instead of "${event}".`);
  3621. }
  3622. }
  3623. let cbs = vm._events[event];
  3624. if (cbs) {
  3625. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  3626. const args = toArray(arguments, 1);
  3627. const info = `event handler for "${event}"`;
  3628. for (let i = 0, l = cbs.length; i < l; i++) {
  3629. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  3630. }
  3631. }
  3632. return vm;
  3633. };
  3634. }
  3635. let activeInstance = null;
  3636. let isUpdatingChildComponent = false;
  3637. function setActiveInstance(vm) {
  3638. const prevActiveInstance = activeInstance;
  3639. activeInstance = vm;
  3640. return () => {
  3641. activeInstance = prevActiveInstance;
  3642. };
  3643. }
  3644. function initLifecycle(vm) {
  3645. const options = vm.$options;
  3646. // locate first non-abstract parent
  3647. let parent = options.parent;
  3648. if (parent && !options.abstract) {
  3649. while (parent.$options.abstract && parent.$parent) {
  3650. parent = parent.$parent;
  3651. }
  3652. parent.$children.push(vm);
  3653. }
  3654. vm.$parent = parent;
  3655. vm.$root = parent ? parent.$root : vm;
  3656. vm.$children = [];
  3657. vm.$refs = {};
  3658. vm._provided = parent ? parent._provided : Object.create(null);
  3659. vm._watcher = null;
  3660. vm._inactive = null;
  3661. vm._directInactive = false;
  3662. vm._isMounted = false;
  3663. vm._isDestroyed = false;
  3664. vm._isBeingDestroyed = false;
  3665. }
  3666. function lifecycleMixin(Vue) {
  3667. Vue.prototype._update = function (vnode, hydrating) {
  3668. const vm = this;
  3669. const prevEl = vm.$el;
  3670. const prevVnode = vm._vnode;
  3671. const restoreActiveInstance = setActiveInstance(vm);
  3672. vm._vnode = vnode;
  3673. // Vue.prototype.__patch__ is injected in entry points
  3674. // based on the rendering backend used.
  3675. if (!prevVnode) {
  3676. // initial render
  3677. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  3678. }
  3679. else {
  3680. // updates
  3681. vm.$el = vm.__patch__(prevVnode, vnode);
  3682. }
  3683. restoreActiveInstance();
  3684. // update __vue__ reference
  3685. if (prevEl) {
  3686. prevEl.__vue__ = null;
  3687. }
  3688. if (vm.$el) {
  3689. vm.$el.__vue__ = vm;
  3690. }
  3691. // if parent is an HOC, update its $el as well
  3692. let wrapper = vm;
  3693. while (wrapper &&
  3694. wrapper.$vnode &&
  3695. wrapper.$parent &&
  3696. wrapper.$vnode === wrapper.$parent._vnode) {
  3697. wrapper.$parent.$el = wrapper.$el;
  3698. wrapper = wrapper.$parent;
  3699. }
  3700. // updated hook is called by the scheduler to ensure that children are
  3701. // updated in a parent's updated hook.
  3702. };
  3703. Vue.prototype.$forceUpdate = function () {
  3704. const vm = this;
  3705. if (vm._watcher) {
  3706. vm._watcher.update();
  3707. }
  3708. };
  3709. Vue.prototype.$destroy = function () {
  3710. const vm = this;
  3711. if (vm._isBeingDestroyed) {
  3712. return;
  3713. }
  3714. callHook$1(vm, 'beforeDestroy');
  3715. vm._isBeingDestroyed = true;
  3716. // remove self from parent
  3717. const parent = vm.$parent;
  3718. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  3719. remove$2(parent.$children, vm);
  3720. }
  3721. // teardown scope. this includes both the render watcher and other
  3722. // watchers created
  3723. vm._scope.stop();
  3724. // remove reference from data ob
  3725. // frozen object may not have observer.
  3726. if (vm._data.__ob__) {
  3727. vm._data.__ob__.vmCount--;
  3728. }
  3729. // call the last hook...
  3730. vm._isDestroyed = true;
  3731. // invoke destroy hooks on current rendered tree
  3732. vm.__patch__(vm._vnode, null);
  3733. // fire destroyed hook
  3734. callHook$1(vm, 'destroyed');
  3735. // turn off all instance listeners.
  3736. vm.$off();
  3737. // remove __vue__ reference
  3738. if (vm.$el) {
  3739. vm.$el.__vue__ = null;
  3740. }
  3741. // release circular reference (#6759)
  3742. if (vm.$vnode) {
  3743. vm.$vnode.parent = null;
  3744. }
  3745. };
  3746. }
  3747. function mountComponent(vm, el, hydrating) {
  3748. vm.$el = el;
  3749. if (!vm.$options.render) {
  3750. // @ts-expect-error invalid type
  3751. vm.$options.render = createEmptyVNode;
  3752. {
  3753. /* istanbul ignore if */
  3754. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  3755. vm.$options.el ||
  3756. el) {
  3757. warn('You are using the runtime-only build of Vue where the template ' +
  3758. 'compiler is not available. Either pre-compile the templates into ' +
  3759. 'render functions, or use the compiler-included build.', vm);
  3760. }
  3761. else {
  3762. warn('Failed to mount component: template or render function not defined.', vm);
  3763. }
  3764. }
  3765. }
  3766. callHook$1(vm, 'beforeMount');
  3767. let updateComponent;
  3768. /* istanbul ignore if */
  3769. if (config.performance && mark) {
  3770. updateComponent = () => {
  3771. const name = vm._name;
  3772. const id = vm._uid;
  3773. const startTag = `vue-perf-start:${id}`;
  3774. const endTag = `vue-perf-end:${id}`;
  3775. mark(startTag);
  3776. const vnode = vm._render();
  3777. mark(endTag);
  3778. measure(`vue ${name} render`, startTag, endTag);
  3779. mark(startTag);
  3780. vm._update(vnode, hydrating);
  3781. mark(endTag);
  3782. measure(`vue ${name} patch`, startTag, endTag);
  3783. };
  3784. }
  3785. else {
  3786. updateComponent = () => {
  3787. vm._update(vm._render(), hydrating);
  3788. };
  3789. }
  3790. const watcherOptions = {
  3791. before() {
  3792. if (vm._isMounted && !vm._isDestroyed) {
  3793. callHook$1(vm, 'beforeUpdate');
  3794. }
  3795. }
  3796. };
  3797. {
  3798. watcherOptions.onTrack = e => callHook$1(vm, 'renderTracked', [e]);
  3799. watcherOptions.onTrigger = e => callHook$1(vm, 'renderTriggered', [e]);
  3800. }
  3801. // we set this to vm._watcher inside the watcher's constructor
  3802. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  3803. // component's mounted hook), which relies on vm._watcher being already defined
  3804. new Watcher(vm, updateComponent, noop, watcherOptions, true /* isRenderWatcher */);
  3805. hydrating = false;
  3806. // flush buffer for flush: "pre" watchers queued in setup()
  3807. const preWatchers = vm._preWatchers;
  3808. if (preWatchers) {
  3809. for (let i = 0; i < preWatchers.length; i++) {
  3810. preWatchers[i].run();
  3811. }
  3812. }
  3813. // manually mounted instance, call mounted on self
  3814. // mounted is called for render-created child components in its inserted hook
  3815. if (vm.$vnode == null) {
  3816. vm._isMounted = true;
  3817. callHook$1(vm, 'mounted');
  3818. }
  3819. return vm;
  3820. }
  3821. function updateChildComponent(vm, propsData, listeners, parentVnode, renderChildren) {
  3822. {
  3823. isUpdatingChildComponent = true;
  3824. }
  3825. // determine whether component has slot children
  3826. // we need to do this before overwriting $options._renderChildren.
  3827. // check if there are dynamic scopedSlots (hand-written or compiled but with
  3828. // dynamic slot names). Static scoped slots compiled from template has the
  3829. // "$stable" marker.
  3830. const newScopedSlots = parentVnode.data.scopedSlots;
  3831. const oldScopedSlots = vm.$scopedSlots;
  3832. const hasDynamicScopedSlot = !!((newScopedSlots && !newScopedSlots.$stable) ||
  3833. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  3834. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) ||
  3835. (!newScopedSlots && vm.$scopedSlots.$key));
  3836. // Any static slot children from the parent may have changed during parent's
  3837. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  3838. // update is necessary to ensure correctness.
  3839. let needsForceUpdate = !!(renderChildren || // has new static slots
  3840. vm.$options._renderChildren || // has old static slots
  3841. hasDynamicScopedSlot);
  3842. const prevVNode = vm.$vnode;
  3843. vm.$options._parentVnode = parentVnode;
  3844. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  3845. if (vm._vnode) {
  3846. // update child tree's parent
  3847. vm._vnode.parent = parentVnode;
  3848. }
  3849. vm.$options._renderChildren = renderChildren;
  3850. // update $attrs and $listeners hash
  3851. // these are also reactive so they may trigger child update if the child
  3852. // used them during render
  3853. const attrs = parentVnode.data.attrs || emptyObject;
  3854. if (vm._attrsProxy) {
  3855. // force update if attrs are accessed and has changed since it may be
  3856. // passed to a child component.
  3857. if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
  3858. needsForceUpdate = true;
  3859. }
  3860. }
  3861. vm.$attrs = attrs;
  3862. // update listeners
  3863. listeners = listeners || emptyObject;
  3864. const prevListeners = vm.$options._parentListeners;
  3865. if (vm._listenersProxy) {
  3866. syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
  3867. }
  3868. vm.$listeners = vm.$options._parentListeners = listeners;
  3869. updateComponentListeners(vm, listeners, prevListeners);
  3870. // update props
  3871. if (propsData && vm.$options.props) {
  3872. toggleObserving(false);
  3873. const props = vm._props;
  3874. const propKeys = vm.$options._propKeys || [];
  3875. for (let i = 0; i < propKeys.length; i++) {
  3876. const key = propKeys[i];
  3877. const propOptions = vm.$options.props; // wtf flow?
  3878. props[key] = validateProp(key, propOptions, propsData, vm);
  3879. }
  3880. toggleObserving(true);
  3881. // keep a copy of raw propsData
  3882. vm.$options.propsData = propsData;
  3883. }
  3884. // resolve slots + force update if has children
  3885. if (needsForceUpdate) {
  3886. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  3887. vm.$forceUpdate();
  3888. }
  3889. {
  3890. isUpdatingChildComponent = false;
  3891. }
  3892. }
  3893. function isInInactiveTree(vm) {
  3894. while (vm && (vm = vm.$parent)) {
  3895. if (vm._inactive)
  3896. return true;
  3897. }
  3898. return false;
  3899. }
  3900. function activateChildComponent(vm, direct) {
  3901. if (direct) {
  3902. vm._directInactive = false;
  3903. if (isInInactiveTree(vm)) {
  3904. return;
  3905. }
  3906. }
  3907. else if (vm._directInactive) {
  3908. return;
  3909. }
  3910. if (vm._inactive || vm._inactive === null) {
  3911. vm._inactive = false;
  3912. for (let i = 0; i < vm.$children.length; i++) {
  3913. activateChildComponent(vm.$children[i]);
  3914. }
  3915. callHook$1(vm, 'activated');
  3916. }
  3917. }
  3918. function deactivateChildComponent(vm, direct) {
  3919. if (direct) {
  3920. vm._directInactive = true;
  3921. if (isInInactiveTree(vm)) {
  3922. return;
  3923. }
  3924. }
  3925. if (!vm._inactive) {
  3926. vm._inactive = true;
  3927. for (let i = 0; i < vm.$children.length; i++) {
  3928. deactivateChildComponent(vm.$children[i]);
  3929. }
  3930. callHook$1(vm, 'deactivated');
  3931. }
  3932. }
  3933. function callHook$1(vm, hook, args, setContext = true) {
  3934. // #7573 disable dep collection when invoking lifecycle hooks
  3935. pushTarget();
  3936. const prevInst = currentInstance;
  3937. const prevScope = getCurrentScope();
  3938. setContext && setCurrentInstance(vm);
  3939. const handlers = vm.$options[hook];
  3940. const info = `${hook} hook`;
  3941. if (handlers) {
  3942. for (let i = 0, j = handlers.length; i < j; i++) {
  3943. invokeWithErrorHandling(handlers[i], vm, args || null, vm, info);
  3944. }
  3945. }
  3946. if (vm._hasHookEvent) {
  3947. vm.$emit('hook:' + hook);
  3948. }
  3949. if (setContext) {
  3950. setCurrentInstance(prevInst);
  3951. prevScope && prevScope.on();
  3952. }
  3953. popTarget();
  3954. }
  3955. const MAX_UPDATE_COUNT = 100;
  3956. const queue = [];
  3957. const activatedChildren = [];
  3958. let has = {};
  3959. let circular = {};
  3960. let waiting = false;
  3961. let flushing = false;
  3962. let index = 0;
  3963. /**
  3964. * Reset the scheduler's state.
  3965. */
  3966. function resetSchedulerState() {
  3967. index = queue.length = activatedChildren.length = 0;
  3968. has = {};
  3969. {
  3970. circular = {};
  3971. }
  3972. waiting = flushing = false;
  3973. }
  3974. // Async edge case #6566 requires saving the timestamp when event listeners are
  3975. // attached. However, calling performance.now() has a perf overhead especially
  3976. // if the page has thousands of event listeners. Instead, we take a timestamp
  3977. // every time the scheduler flushes and use that for all event listeners
  3978. // attached during that flush.
  3979. let currentFlushTimestamp = 0;
  3980. // Async edge case fix requires storing an event listener's attach timestamp.
  3981. let getNow = Date.now;
  3982. // Determine what event timestamp the browser is using. Annoyingly, the
  3983. // timestamp can either be hi-res (relative to page load) or low-res
  3984. // (relative to UNIX epoch), so in order to compare time we have to use the
  3985. // same timestamp type when saving the flush timestamp.
  3986. // All IE versions use low-res event timestamps, and have problematic clock
  3987. // implementations (#9632)
  3988. if (inBrowser && !isIE) {
  3989. const performance = window.performance;
  3990. if (performance &&
  3991. typeof performance.now === 'function' &&
  3992. getNow() > document.createEvent('Event').timeStamp) {
  3993. // if the event timestamp, although evaluated AFTER the Date.now(), is
  3994. // smaller than it, it means the event is using a hi-res timestamp,
  3995. // and we need to use the hi-res version for event listener timestamps as
  3996. // well.
  3997. getNow = () => performance.now();
  3998. }
  3999. }
  4000. const sortCompareFn = (a, b) => {
  4001. if (a.post) {
  4002. if (!b.post)
  4003. return 1;
  4004. }
  4005. else if (b.post) {
  4006. return -1;
  4007. }
  4008. return a.id - b.id;
  4009. };
  4010. /**
  4011. * Flush both queues and run the watchers.
  4012. */
  4013. function flushSchedulerQueue() {
  4014. currentFlushTimestamp = getNow();
  4015. flushing = true;
  4016. let watcher, id;
  4017. // Sort queue before flush.
  4018. // This ensures that:
  4019. // 1. Components are updated from parent to child. (because parent is always
  4020. // created before the child)
  4021. // 2. A component's user watchers are run before its render watcher (because
  4022. // user watchers are created before the render watcher)
  4023. // 3. If a component is destroyed during a parent component's watcher run,
  4024. // its watchers can be skipped.
  4025. queue.sort(sortCompareFn);
  4026. // do not cache length because more watchers might be pushed
  4027. // as we run existing watchers
  4028. for (index = 0; index < queue.length; index++) {
  4029. watcher = queue[index];
  4030. if (watcher.before) {
  4031. watcher.before();
  4032. }
  4033. id = watcher.id;
  4034. has[id] = null;
  4035. watcher.run();
  4036. // in dev build, check and stop circular updates.
  4037. if (has[id] != null) {
  4038. circular[id] = (circular[id] || 0) + 1;
  4039. if (circular[id] > MAX_UPDATE_COUNT) {
  4040. warn('You may have an infinite update loop ' +
  4041. (watcher.user
  4042. ? `in watcher with expression "${watcher.expression}"`
  4043. : `in a component render function.`), watcher.vm);
  4044. break;
  4045. }
  4046. }
  4047. }
  4048. // keep copies of post queues before resetting state
  4049. const activatedQueue = activatedChildren.slice();
  4050. const updatedQueue = queue.slice();
  4051. resetSchedulerState();
  4052. // call component updated and activated hooks
  4053. callActivatedHooks(activatedQueue);
  4054. callUpdatedHooks(updatedQueue);
  4055. cleanupDeps();
  4056. // devtool hook
  4057. /* istanbul ignore if */
  4058. if (devtools && config.devtools) {
  4059. devtools.emit('flush');
  4060. }
  4061. }
  4062. function callUpdatedHooks(queue) {
  4063. let i = queue.length;
  4064. while (i--) {
  4065. const watcher = queue[i];
  4066. const vm = watcher.vm;
  4067. if (vm && vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  4068. callHook$1(vm, 'updated');
  4069. }
  4070. }
  4071. }
  4072. /**
  4073. * Queue a kept-alive component that was activated during patch.
  4074. * The queue will be processed after the entire tree has been patched.
  4075. */
  4076. function queueActivatedComponent(vm) {
  4077. // setting _inactive to false here so that a render function can
  4078. // rely on checking whether it's in an inactive tree (e.g. router-view)
  4079. vm._inactive = false;
  4080. activatedChildren.push(vm);
  4081. }
  4082. function callActivatedHooks(queue) {
  4083. for (let i = 0; i < queue.length; i++) {
  4084. queue[i]._inactive = true;
  4085. activateChildComponent(queue[i], true /* true */);
  4086. }
  4087. }
  4088. /**
  4089. * Push a watcher into the watcher queue.
  4090. * Jobs with duplicate IDs will be skipped unless it's
  4091. * pushed when the queue is being flushed.
  4092. */
  4093. function queueWatcher(watcher) {
  4094. const id = watcher.id;
  4095. if (has[id] != null) {
  4096. return;
  4097. }
  4098. if (watcher === Dep.target && watcher.noRecurse) {
  4099. return;
  4100. }
  4101. has[id] = true;
  4102. if (!flushing) {
  4103. queue.push(watcher);
  4104. }
  4105. else {
  4106. // if already flushing, splice the watcher based on its id
  4107. // if already past its id, it will be run next immediately.
  4108. let i = queue.length - 1;
  4109. while (i > index && queue[i].id > watcher.id) {
  4110. i--;
  4111. }
  4112. queue.splice(i + 1, 0, watcher);
  4113. }
  4114. // queue the flush
  4115. if (!waiting) {
  4116. waiting = true;
  4117. if (!config.async) {
  4118. flushSchedulerQueue();
  4119. return;
  4120. }
  4121. nextTick(flushSchedulerQueue);
  4122. }
  4123. }
  4124. function initProvide(vm) {
  4125. const provideOption = vm.$options.provide;
  4126. if (provideOption) {
  4127. const provided = isFunction(provideOption)
  4128. ? provideOption.call(vm)
  4129. : provideOption;
  4130. if (!isObject(provided)) {
  4131. return;
  4132. }
  4133. const source = resolveProvided(vm);
  4134. // IE9 doesn't support Object.getOwnPropertyDescriptors so we have to
  4135. // iterate the keys ourselves.
  4136. const keys = hasSymbol ? Reflect.ownKeys(provided) : Object.keys(provided);
  4137. for (let i = 0; i < keys.length; i++) {
  4138. const key = keys[i];
  4139. Object.defineProperty(source, key, Object.getOwnPropertyDescriptor(provided, key));
  4140. }
  4141. }
  4142. }
  4143. function initInjections(vm) {
  4144. const result = resolveInject(vm.$options.inject, vm);
  4145. if (result) {
  4146. toggleObserving(false);
  4147. Object.keys(result).forEach(key => {
  4148. /* istanbul ignore else */
  4149. {
  4150. defineReactive(vm, key, result[key], () => {
  4151. warn(`Avoid mutating an injected value directly since the changes will be ` +
  4152. `overwritten whenever the provided component re-renders. ` +
  4153. `injection being mutated: "${key}"`, vm);
  4154. });
  4155. }
  4156. });
  4157. toggleObserving(true);
  4158. }
  4159. }
  4160. function resolveInject(inject, vm) {
  4161. if (inject) {
  4162. // inject is :any because flow is not smart enough to figure out cached
  4163. const result = Object.create(null);
  4164. const keys = hasSymbol ? Reflect.ownKeys(inject) : Object.keys(inject);
  4165. for (let i = 0; i < keys.length; i++) {
  4166. const key = keys[i];
  4167. // #6574 in case the inject object is observed...
  4168. if (key === '__ob__')
  4169. continue;
  4170. const provideKey = inject[key].from;
  4171. if (provideKey in vm._provided) {
  4172. result[key] = vm._provided[provideKey];
  4173. }
  4174. else if ('default' in inject[key]) {
  4175. const provideDefault = inject[key].default;
  4176. result[key] = isFunction(provideDefault)
  4177. ? provideDefault.call(vm)
  4178. : provideDefault;
  4179. }
  4180. else {
  4181. warn(`Injection "${key}" not found`, vm);
  4182. }
  4183. }
  4184. return result;
  4185. }
  4186. }
  4187. function FunctionalRenderContext(data, props, children, parent, Ctor) {
  4188. const options = Ctor.options;
  4189. // ensure the createElement function in functional components
  4190. // gets a unique context - this is necessary for correct named slot check
  4191. let contextVm;
  4192. if (hasOwn(parent, '_uid')) {
  4193. contextVm = Object.create(parent);
  4194. contextVm._original = parent;
  4195. }
  4196. else {
  4197. // the context vm passed in is a functional context as well.
  4198. // in this case we want to make sure we are able to get a hold to the
  4199. // real context instance.
  4200. contextVm = parent;
  4201. // @ts-ignore
  4202. parent = parent._original;
  4203. }
  4204. const isCompiled = isTrue(options._compiled);
  4205. const needNormalization = !isCompiled;
  4206. this.data = data;
  4207. this.props = props;
  4208. this.children = children;
  4209. this.parent = parent;
  4210. this.listeners = data.on || emptyObject;
  4211. this.injections = resolveInject(options.inject, parent);
  4212. this.slots = () => {
  4213. if (!this.$slots) {
  4214. normalizeScopedSlots(parent, data.scopedSlots, (this.$slots = resolveSlots(children, parent)));
  4215. }
  4216. return this.$slots;
  4217. };
  4218. Object.defineProperty(this, 'scopedSlots', {
  4219. enumerable: true,
  4220. get() {
  4221. return normalizeScopedSlots(parent, data.scopedSlots, this.slots());
  4222. }
  4223. });
  4224. // support for compiled functional template
  4225. if (isCompiled) {
  4226. // exposing $options for renderStatic()
  4227. this.$options = options;
  4228. // pre-resolve slots for renderSlot()
  4229. this.$slots = this.slots();
  4230. this.$scopedSlots = normalizeScopedSlots(parent, data.scopedSlots, this.$slots);
  4231. }
  4232. if (options._scopeId) {
  4233. this._c = (a, b, c, d) => {
  4234. const vnode = createElement$1(contextVm, a, b, c, d, needNormalization);
  4235. if (vnode && !isArray(vnode)) {
  4236. vnode.fnScopeId = options._scopeId;
  4237. vnode.fnContext = parent;
  4238. }
  4239. return vnode;
  4240. };
  4241. }
  4242. else {
  4243. this._c = (a, b, c, d) => createElement$1(contextVm, a, b, c, d, needNormalization);
  4244. }
  4245. }
  4246. installRenderHelpers(FunctionalRenderContext.prototype);
  4247. function createFunctionalComponent(Ctor, propsData, data, contextVm, children) {
  4248. const options = Ctor.options;
  4249. const props = {};
  4250. const propOptions = options.props;
  4251. if (isDef(propOptions)) {
  4252. for (const key in propOptions) {
  4253. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  4254. }
  4255. }
  4256. else {
  4257. if (isDef(data.attrs))
  4258. mergeProps(props, data.attrs);
  4259. if (isDef(data.props))
  4260. mergeProps(props, data.props);
  4261. }
  4262. const renderContext = new FunctionalRenderContext(data, props, children, contextVm, Ctor);
  4263. const vnode = options.render.call(null, renderContext._c, renderContext);
  4264. if (vnode instanceof VNode) {
  4265. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext);
  4266. }
  4267. else if (isArray(vnode)) {
  4268. const vnodes = normalizeChildren(vnode) || [];
  4269. const res = new Array(vnodes.length);
  4270. for (let i = 0; i < vnodes.length; i++) {
  4271. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  4272. }
  4273. return res;
  4274. }
  4275. }
  4276. function cloneAndMarkFunctionalResult(vnode, data, contextVm, options, renderContext) {
  4277. // #7817 clone node before setting fnContext, otherwise if the node is reused
  4278. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  4279. // that should not be matched to match.
  4280. const clone = cloneVNode(vnode);
  4281. clone.fnContext = contextVm;
  4282. clone.fnOptions = options;
  4283. {
  4284. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext =
  4285. renderContext;
  4286. }
  4287. if (data.slot) {
  4288. (clone.data || (clone.data = {})).slot = data.slot;
  4289. }
  4290. return clone;
  4291. }
  4292. function mergeProps(to, from) {
  4293. for (const key in from) {
  4294. to[camelize(key)] = from[key];
  4295. }
  4296. }
  4297. function getComponentName(options) {
  4298. return options.name || options.__name || options._componentTag;
  4299. }
  4300. // inline hooks to be invoked on component VNodes during patch
  4301. const componentVNodeHooks = {
  4302. init(vnode, hydrating) {
  4303. if (vnode.componentInstance &&
  4304. !vnode.componentInstance._isDestroyed &&
  4305. vnode.data.keepAlive) {
  4306. // kept-alive components, treat as a patch
  4307. const mountedNode = vnode; // work around flow
  4308. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  4309. }
  4310. else {
  4311. const child = (vnode.componentInstance = createComponentInstanceForVnode(vnode, activeInstance));
  4312. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  4313. }
  4314. },
  4315. prepatch(oldVnode, vnode) {
  4316. const options = vnode.componentOptions;
  4317. const child = (vnode.componentInstance = oldVnode.componentInstance);
  4318. updateChildComponent(child, options.propsData, // updated props
  4319. options.listeners, // updated listeners
  4320. vnode, // new parent vnode
  4321. options.children // new children
  4322. );
  4323. },
  4324. insert(vnode) {
  4325. const { context, componentInstance } = vnode;
  4326. if (!componentInstance._isMounted) {
  4327. componentInstance._isMounted = true;
  4328. callHook$1(componentInstance, 'mounted');
  4329. }
  4330. if (vnode.data.keepAlive) {
  4331. if (context._isMounted) {
  4332. // vue-router#1212
  4333. // During updates, a kept-alive component's child components may
  4334. // change, so directly walking the tree here may call activated hooks
  4335. // on incorrect children. Instead we push them into a queue which will
  4336. // be processed after the whole patch process ended.
  4337. queueActivatedComponent(componentInstance);
  4338. }
  4339. else {
  4340. activateChildComponent(componentInstance, true /* direct */);
  4341. }
  4342. }
  4343. },
  4344. destroy(vnode) {
  4345. const { componentInstance } = vnode;
  4346. if (!componentInstance._isDestroyed) {
  4347. if (!vnode.data.keepAlive) {
  4348. componentInstance.$destroy();
  4349. }
  4350. else {
  4351. deactivateChildComponent(componentInstance, true /* direct */);
  4352. }
  4353. }
  4354. }
  4355. };
  4356. const hooksToMerge = Object.keys(componentVNodeHooks);
  4357. function createComponent(Ctor, data, context, children, tag) {
  4358. if (isUndef(Ctor)) {
  4359. return;
  4360. }
  4361. const baseCtor = context.$options._base;
  4362. // plain options object: turn it into a constructor
  4363. if (isObject(Ctor)) {
  4364. Ctor = baseCtor.extend(Ctor);
  4365. }
  4366. // if at this stage it's not a constructor or an async component factory,
  4367. // reject.
  4368. if (typeof Ctor !== 'function') {
  4369. {
  4370. warn(`Invalid Component definition: ${String(Ctor)}`, context);
  4371. }
  4372. return;
  4373. }
  4374. // async component
  4375. let asyncFactory;
  4376. // @ts-expect-error
  4377. if (isUndef(Ctor.cid)) {
  4378. asyncFactory = Ctor;
  4379. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  4380. if (Ctor === undefined) {
  4381. // return a placeholder node for async component, which is rendered
  4382. // as a comment node but preserves all the raw information for the node.
  4383. // the information will be used for async server-rendering and hydration.
  4384. return createAsyncPlaceholder(asyncFactory, data, context, children, tag);
  4385. }
  4386. }
  4387. data = data || {};
  4388. // resolve constructor options in case global mixins are applied after
  4389. // component constructor creation
  4390. resolveConstructorOptions(Ctor);
  4391. // transform component v-model data into props & events
  4392. if (isDef(data.model)) {
  4393. // @ts-expect-error
  4394. transformModel(Ctor.options, data);
  4395. }
  4396. // extract props
  4397. // @ts-expect-error
  4398. const propsData = extractPropsFromVNodeData(data, Ctor, tag);
  4399. // functional component
  4400. // @ts-expect-error
  4401. if (isTrue(Ctor.options.functional)) {
  4402. return createFunctionalComponent(Ctor, propsData, data, context, children);
  4403. }
  4404. // extract listeners, since these needs to be treated as
  4405. // child component listeners instead of DOM listeners
  4406. const listeners = data.on;
  4407. // replace with listeners with .native modifier
  4408. // so it gets processed during parent component patch.
  4409. data.on = data.nativeOn;
  4410. // @ts-expect-error
  4411. if (isTrue(Ctor.options.abstract)) {
  4412. // abstract components do not keep anything
  4413. // other than props & listeners & slot
  4414. // work around flow
  4415. const slot = data.slot;
  4416. data = {};
  4417. if (slot) {
  4418. data.slot = slot;
  4419. }
  4420. }
  4421. // install component management hooks onto the placeholder node
  4422. installComponentHooks(data);
  4423. // return a placeholder vnode
  4424. // @ts-expect-error
  4425. const name = getComponentName(Ctor.options) || tag;
  4426. const vnode = new VNode(
  4427. // @ts-expect-error
  4428. `vue-component-${Ctor.cid}${name ? `-${name}` : ''}`, data, undefined, undefined, undefined, context,
  4429. // @ts-expect-error
  4430. { Ctor, propsData, listeners, tag, children }, asyncFactory);
  4431. return vnode;
  4432. }
  4433. function createComponentInstanceForVnode(
  4434. // we know it's MountedComponentVNode but flow doesn't
  4435. vnode,
  4436. // activeInstance in lifecycle state
  4437. parent) {
  4438. const options = {
  4439. _isComponent: true,
  4440. _parentVnode: vnode,
  4441. parent
  4442. };
  4443. // check inline-template render functions
  4444. const inlineTemplate = vnode.data.inlineTemplate;
  4445. if (isDef(inlineTemplate)) {
  4446. options.render = inlineTemplate.render;
  4447. options.staticRenderFns = inlineTemplate.staticRenderFns;
  4448. }
  4449. return new vnode.componentOptions.Ctor(options);
  4450. }
  4451. function installComponentHooks(data) {
  4452. const hooks = data.hook || (data.hook = {});
  4453. for (let i = 0; i < hooksToMerge.length; i++) {
  4454. const key = hooksToMerge[i];
  4455. const existing = hooks[key];
  4456. const toMerge = componentVNodeHooks[key];
  4457. // @ts-expect-error
  4458. if (existing !== toMerge && !(existing && existing._merged)) {
  4459. hooks[key] = existing ? mergeHook(toMerge, existing) : toMerge;
  4460. }
  4461. }
  4462. }
  4463. function mergeHook(f1, f2) {
  4464. const merged = (a, b) => {
  4465. // flow complains about extra args which is why we use any
  4466. f1(a, b);
  4467. f2(a, b);
  4468. };
  4469. merged._merged = true;
  4470. return merged;
  4471. }
  4472. // transform component v-model info (value and callback) into
  4473. // prop and event handler respectively.
  4474. function transformModel(options, data) {
  4475. const prop = (options.model && options.model.prop) || 'value';
  4476. const event = (options.model && options.model.event) || 'input';
  4477. (data.attrs || (data.attrs = {}))[prop] = data.model.value;
  4478. const on = data.on || (data.on = {});
  4479. const existing = on[event];
  4480. const callback = data.model.callback;
  4481. if (isDef(existing)) {
  4482. if (isArray(existing)
  4483. ? existing.indexOf(callback) === -1
  4484. : existing !== callback) {
  4485. on[event] = [callback].concat(existing);
  4486. }
  4487. }
  4488. else {
  4489. on[event] = callback;
  4490. }
  4491. }
  4492. let warn = noop;
  4493. let tip = noop;
  4494. let generateComponentTrace; // work around flow check
  4495. let formatComponentName;
  4496. {
  4497. const hasConsole = typeof console !== 'undefined';
  4498. const classifyRE = /(?:^|[-_])(\w)/g;
  4499. const classify = str => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  4500. warn = (msg, vm = currentInstance) => {
  4501. const trace = vm ? generateComponentTrace(vm) : '';
  4502. if (config.warnHandler) {
  4503. config.warnHandler.call(null, msg, vm, trace);
  4504. }
  4505. else if (hasConsole && !config.silent) {
  4506. console.error(`[Vue warn]: ${msg}${trace}`);
  4507. }
  4508. };
  4509. tip = (msg, vm) => {
  4510. if (hasConsole && !config.silent) {
  4511. console.warn(`[Vue tip]: ${msg}` + (vm ? generateComponentTrace(vm) : ''));
  4512. }
  4513. };
  4514. formatComponentName = (vm, includeFile) => {
  4515. if (vm.$root === vm) {
  4516. return '<Root>';
  4517. }
  4518. const options = isFunction(vm) && vm.cid != null
  4519. ? vm.options
  4520. : vm._isVue
  4521. ? vm.$options || vm.constructor.options
  4522. : vm;
  4523. let name = getComponentName(options);
  4524. const file = options.__file;
  4525. if (!name && file) {
  4526. const match = file.match(/([^/\\]+)\.vue$/);
  4527. name = match && match[1];
  4528. }
  4529. return ((name ? `<${classify(name)}>` : `<Anonymous>`) +
  4530. (file && includeFile !== false ? ` at ${file}` : ''));
  4531. };
  4532. const repeat = (str, n) => {
  4533. let res = '';
  4534. while (n) {
  4535. if (n % 2 === 1)
  4536. res += str;
  4537. if (n > 1)
  4538. str += str;
  4539. n >>= 1;
  4540. }
  4541. return res;
  4542. };
  4543. generateComponentTrace = (vm) => {
  4544. if (vm._isVue && vm.$parent) {
  4545. const tree = [];
  4546. let currentRecursiveSequence = 0;
  4547. while (vm) {
  4548. if (tree.length > 0) {
  4549. const last = tree[tree.length - 1];
  4550. if (last.constructor === vm.constructor) {
  4551. currentRecursiveSequence++;
  4552. vm = vm.$parent;
  4553. continue;
  4554. }
  4555. else if (currentRecursiveSequence > 0) {
  4556. tree[tree.length - 1] = [last, currentRecursiveSequence];
  4557. currentRecursiveSequence = 0;
  4558. }
  4559. }
  4560. tree.push(vm);
  4561. vm = vm.$parent;
  4562. }
  4563. return ('\n\nfound in\n\n' +
  4564. tree
  4565. .map((vm, i) => `${i === 0 ? '---> ' : repeat(' ', 5 + i * 2)}${isArray(vm)
  4566. ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`
  4567. : formatComponentName(vm)}`)
  4568. .join('\n'));
  4569. }
  4570. else {
  4571. return `\n\n(found in ${formatComponentName(vm)})`;
  4572. }
  4573. };
  4574. }
  4575. /**
  4576. * Option overwriting strategies are functions that handle
  4577. * how to merge a parent option value and a child option
  4578. * value into the final value.
  4579. */
  4580. const strats = config.optionMergeStrategies;
  4581. /**
  4582. * Options with restrictions
  4583. */
  4584. {
  4585. strats.el = strats.propsData = function (parent, child, vm, key) {
  4586. if (!vm) {
  4587. warn(`option "${key}" can only be used during instance ` +
  4588. 'creation with the `new` keyword.');
  4589. }
  4590. return defaultStrat(parent, child);
  4591. };
  4592. }
  4593. /**
  4594. * Helper that recursively merges two data objects together.
  4595. */
  4596. function mergeData(to, from, recursive = true) {
  4597. if (!from)
  4598. return to;
  4599. let key, toVal, fromVal;
  4600. const keys = hasSymbol
  4601. ? Reflect.ownKeys(from)
  4602. : Object.keys(from);
  4603. for (let i = 0; i < keys.length; i++) {
  4604. key = keys[i];
  4605. // in case the object is already observed...
  4606. if (key === '__ob__')
  4607. continue;
  4608. toVal = to[key];
  4609. fromVal = from[key];
  4610. if (!recursive || !hasOwn(to, key)) {
  4611. set(to, key, fromVal);
  4612. }
  4613. else if (toVal !== fromVal &&
  4614. isPlainObject(toVal) &&
  4615. isPlainObject(fromVal)) {
  4616. mergeData(toVal, fromVal);
  4617. }
  4618. }
  4619. return to;
  4620. }
  4621. /**
  4622. * Data
  4623. */
  4624. function mergeDataOrFn(parentVal, childVal, vm) {
  4625. if (!vm) {
  4626. // in a Vue.extend merge, both should be functions
  4627. if (!childVal) {
  4628. return parentVal;
  4629. }
  4630. if (!parentVal) {
  4631. return childVal;
  4632. }
  4633. // when parentVal & childVal are both present,
  4634. // we need to return a function that returns the
  4635. // merged result of both functions... no need to
  4636. // check if parentVal is a function here because
  4637. // it has to be a function to pass previous merges.
  4638. return function mergedDataFn() {
  4639. return mergeData(isFunction(childVal) ? childVal.call(this, this) : childVal, isFunction(parentVal) ? parentVal.call(this, this) : parentVal);
  4640. };
  4641. }
  4642. else {
  4643. return function mergedInstanceDataFn() {
  4644. // instance merge
  4645. const instanceData = isFunction(childVal)
  4646. ? childVal.call(vm, vm)
  4647. : childVal;
  4648. const defaultData = isFunction(parentVal)
  4649. ? parentVal.call(vm, vm)
  4650. : parentVal;
  4651. if (instanceData) {
  4652. return mergeData(instanceData, defaultData);
  4653. }
  4654. else {
  4655. return defaultData;
  4656. }
  4657. };
  4658. }
  4659. }
  4660. strats.data = function (parentVal, childVal, vm) {
  4661. if (!vm) {
  4662. if (childVal && typeof childVal !== 'function') {
  4663. warn('The "data" option should be a function ' +
  4664. 'that returns a per-instance value in component ' +
  4665. 'definitions.', vm);
  4666. return parentVal;
  4667. }
  4668. return mergeDataOrFn(parentVal, childVal);
  4669. }
  4670. return mergeDataOrFn(parentVal, childVal, vm);
  4671. };
  4672. /**
  4673. * Hooks and props are merged as arrays.
  4674. */
  4675. function mergeLifecycleHook(parentVal, childVal) {
  4676. const res = childVal
  4677. ? parentVal
  4678. ? parentVal.concat(childVal)
  4679. : isArray(childVal)
  4680. ? childVal
  4681. : [childVal]
  4682. : parentVal;
  4683. return res ? dedupeHooks(res) : res;
  4684. }
  4685. function dedupeHooks(hooks) {
  4686. const res = [];
  4687. for (let i = 0; i < hooks.length; i++) {
  4688. if (res.indexOf(hooks[i]) === -1) {
  4689. res.push(hooks[i]);
  4690. }
  4691. }
  4692. return res;
  4693. }
  4694. LIFECYCLE_HOOKS.forEach(hook => {
  4695. strats[hook] = mergeLifecycleHook;
  4696. });
  4697. /**
  4698. * Assets
  4699. *
  4700. * When a vm is present (instance creation), we need to do
  4701. * a three-way merge between constructor options, instance
  4702. * options and parent options.
  4703. */
  4704. function mergeAssets(parentVal, childVal, vm, key) {
  4705. const res = Object.create(parentVal || null);
  4706. if (childVal) {
  4707. assertObjectType(key, childVal, vm);
  4708. return extend(res, childVal);
  4709. }
  4710. else {
  4711. return res;
  4712. }
  4713. }
  4714. ASSET_TYPES.forEach(function (type) {
  4715. strats[type + 's'] = mergeAssets;
  4716. });
  4717. /**
  4718. * Watchers.
  4719. *
  4720. * Watchers hashes should not overwrite one
  4721. * another, so we merge them as arrays.
  4722. */
  4723. strats.watch = function (parentVal, childVal, vm, key) {
  4724. // work around Firefox's Object.prototype.watch...
  4725. //@ts-expect-error work around
  4726. if (parentVal === nativeWatch)
  4727. parentVal = undefined;
  4728. //@ts-expect-error work around
  4729. if (childVal === nativeWatch)
  4730. childVal = undefined;
  4731. /* istanbul ignore if */
  4732. if (!childVal)
  4733. return Object.create(parentVal || null);
  4734. {
  4735. assertObjectType(key, childVal, vm);
  4736. }
  4737. if (!parentVal)
  4738. return childVal;
  4739. const ret = {};
  4740. extend(ret, parentVal);
  4741. for (const key in childVal) {
  4742. let parent = ret[key];
  4743. const child = childVal[key];
  4744. if (parent && !isArray(parent)) {
  4745. parent = [parent];
  4746. }
  4747. ret[key] = parent ? parent.concat(child) : isArray(child) ? child : [child];
  4748. }
  4749. return ret;
  4750. };
  4751. /**
  4752. * Other object hashes.
  4753. */
  4754. strats.props =
  4755. strats.methods =
  4756. strats.inject =
  4757. strats.computed =
  4758. function (parentVal, childVal, vm, key) {
  4759. if (childVal && true) {
  4760. assertObjectType(key, childVal, vm);
  4761. }
  4762. if (!parentVal)
  4763. return childVal;
  4764. const ret = Object.create(null);
  4765. extend(ret, parentVal);
  4766. if (childVal)
  4767. extend(ret, childVal);
  4768. return ret;
  4769. };
  4770. strats.provide = function (parentVal, childVal) {
  4771. if (!parentVal)
  4772. return childVal;
  4773. return function () {
  4774. const ret = Object.create(null);
  4775. mergeData(ret, isFunction(parentVal) ? parentVal.call(this) : parentVal);
  4776. if (childVal) {
  4777. mergeData(ret, isFunction(childVal) ? childVal.call(this) : childVal, false // non-recursive
  4778. );
  4779. }
  4780. return ret;
  4781. };
  4782. };
  4783. /**
  4784. * Default strategy.
  4785. */
  4786. const defaultStrat = function (parentVal, childVal) {
  4787. return childVal === undefined ? parentVal : childVal;
  4788. };
  4789. /**
  4790. * Validate component names
  4791. */
  4792. function checkComponents(options) {
  4793. for (const key in options.components) {
  4794. validateComponentName(key);
  4795. }
  4796. }
  4797. function validateComponentName(name) {
  4798. if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeRegExp.source}]*$`).test(name)) {
  4799. warn('Invalid component name: "' +
  4800. name +
  4801. '". Component names ' +
  4802. 'should conform to valid custom element name in html5 specification.');
  4803. }
  4804. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  4805. warn('Do not use built-in or reserved HTML elements as component ' +
  4806. 'id: ' +
  4807. name);
  4808. }
  4809. }
  4810. /**
  4811. * Ensure all props option syntax are normalized into the
  4812. * Object-based format.
  4813. */
  4814. function normalizeProps(options, vm) {
  4815. const props = options.props;
  4816. if (!props)
  4817. return;
  4818. const res = {};
  4819. let i, val, name;
  4820. if (isArray(props)) {
  4821. i = props.length;
  4822. while (i--) {
  4823. val = props[i];
  4824. if (typeof val === 'string') {
  4825. name = camelize(val);
  4826. res[name] = { type: null };
  4827. }
  4828. else {
  4829. warn('props must be strings when using array syntax.');
  4830. }
  4831. }
  4832. }
  4833. else if (isPlainObject(props)) {
  4834. for (const key in props) {
  4835. val = props[key];
  4836. name = camelize(key);
  4837. res[name] = isPlainObject(val) ? val : { type: val };
  4838. }
  4839. }
  4840. else {
  4841. warn(`Invalid value for option "props": expected an Array or an Object, ` +
  4842. `but got ${toRawType(props)}.`, vm);
  4843. }
  4844. options.props = res;
  4845. }
  4846. /**
  4847. * Normalize all injections into Object-based format
  4848. */
  4849. function normalizeInject(options, vm) {
  4850. const inject = options.inject;
  4851. if (!inject)
  4852. return;
  4853. const normalized = (options.inject = {});
  4854. if (isArray(inject)) {
  4855. for (let i = 0; i < inject.length; i++) {
  4856. normalized[inject[i]] = { from: inject[i] };
  4857. }
  4858. }
  4859. else if (isPlainObject(inject)) {
  4860. for (const key in inject) {
  4861. const val = inject[key];
  4862. normalized[key] = isPlainObject(val)
  4863. ? extend({ from: key }, val)
  4864. : { from: val };
  4865. }
  4866. }
  4867. else {
  4868. warn(`Invalid value for option "inject": expected an Array or an Object, ` +
  4869. `but got ${toRawType(inject)}.`, vm);
  4870. }
  4871. }
  4872. /**
  4873. * Normalize raw function directives into object format.
  4874. */
  4875. function normalizeDirectives$1(options) {
  4876. const dirs = options.directives;
  4877. if (dirs) {
  4878. for (const key in dirs) {
  4879. const def = dirs[key];
  4880. if (isFunction(def)) {
  4881. dirs[key] = { bind: def, update: def };
  4882. }
  4883. }
  4884. }
  4885. }
  4886. function assertObjectType(name, value, vm) {
  4887. if (!isPlainObject(value)) {
  4888. warn(`Invalid value for option "${name}": expected an Object, ` +
  4889. `but got ${toRawType(value)}.`, vm);
  4890. }
  4891. }
  4892. /**
  4893. * Merge two option objects into a new one.
  4894. * Core utility used in both instantiation and inheritance.
  4895. */
  4896. function mergeOptions(parent, child, vm) {
  4897. {
  4898. checkComponents(child);
  4899. }
  4900. if (isFunction(child)) {
  4901. // @ts-expect-error
  4902. child = child.options;
  4903. }
  4904. normalizeProps(child, vm);
  4905. normalizeInject(child, vm);
  4906. normalizeDirectives$1(child);
  4907. // Apply extends and mixins on the child options,
  4908. // but only if it is a raw options object that isn't
  4909. // the result of another mergeOptions call.
  4910. // Only merged options has the _base property.
  4911. if (!child._base) {
  4912. if (child.extends) {
  4913. parent = mergeOptions(parent, child.extends, vm);
  4914. }
  4915. if (child.mixins) {
  4916. for (let i = 0, l = child.mixins.length; i < l; i++) {
  4917. parent = mergeOptions(parent, child.mixins[i], vm);
  4918. }
  4919. }
  4920. }
  4921. const options = {};
  4922. let key;
  4923. for (key in parent) {
  4924. mergeField(key);
  4925. }
  4926. for (key in child) {
  4927. if (!hasOwn(parent, key)) {
  4928. mergeField(key);
  4929. }
  4930. }
  4931. function mergeField(key) {
  4932. const strat = strats[key] || defaultStrat;
  4933. options[key] = strat(parent[key], child[key], vm, key);
  4934. }
  4935. return options;
  4936. }
  4937. /**
  4938. * Resolve an asset.
  4939. * This function is used because child instances need access
  4940. * to assets defined in its ancestor chain.
  4941. */
  4942. function resolveAsset(options, type, id, warnMissing) {
  4943. /* istanbul ignore if */
  4944. if (typeof id !== 'string') {
  4945. return;
  4946. }
  4947. const assets = options[type];
  4948. // check local registration variations first
  4949. if (hasOwn(assets, id))
  4950. return assets[id];
  4951. const camelizedId = camelize(id);
  4952. if (hasOwn(assets, camelizedId))
  4953. return assets[camelizedId];
  4954. const PascalCaseId = capitalize(camelizedId);
  4955. if (hasOwn(assets, PascalCaseId))
  4956. return assets[PascalCaseId];
  4957. // fallback to prototype chain
  4958. const res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  4959. if (warnMissing && !res) {
  4960. warn('Failed to resolve ' + type.slice(0, -1) + ': ' + id);
  4961. }
  4962. return res;
  4963. }
  4964. function validateProp(key, propOptions, propsData, vm) {
  4965. const prop = propOptions[key];
  4966. const absent = !hasOwn(propsData, key);
  4967. let value = propsData[key];
  4968. // boolean casting
  4969. const booleanIndex = getTypeIndex(Boolean, prop.type);
  4970. if (booleanIndex > -1) {
  4971. if (absent && !hasOwn(prop, 'default')) {
  4972. value = false;
  4973. }
  4974. else if (value === '' || value === hyphenate(key)) {
  4975. // only cast empty string / same name to boolean if
  4976. // boolean has higher priority
  4977. const stringIndex = getTypeIndex(String, prop.type);
  4978. if (stringIndex < 0 || booleanIndex < stringIndex) {
  4979. value = true;
  4980. }
  4981. }
  4982. }
  4983. // check default value
  4984. if (value === undefined) {
  4985. value = getPropDefaultValue(vm, prop, key);
  4986. // since the default value is a fresh copy,
  4987. // make sure to observe it.
  4988. const prevShouldObserve = shouldObserve;
  4989. toggleObserving(true);
  4990. observe(value);
  4991. toggleObserving(prevShouldObserve);
  4992. }
  4993. {
  4994. assertProp(prop, key, value, vm, absent);
  4995. }
  4996. return value;
  4997. }
  4998. /**
  4999. * Get the default value of a prop.
  5000. */
  5001. function getPropDefaultValue(vm, prop, key) {
  5002. // no default, return undefined
  5003. if (!hasOwn(prop, 'default')) {
  5004. return undefined;
  5005. }
  5006. const def = prop.default;
  5007. // warn against non-factory defaults for Object & Array
  5008. if (isObject(def)) {
  5009. warn('Invalid default value for prop "' +
  5010. key +
  5011. '": ' +
  5012. 'Props with type Object/Array must use a factory function ' +
  5013. 'to return the default value.', vm);
  5014. }
  5015. // the raw prop value was also undefined from previous render,
  5016. // return previous default value to avoid unnecessary watcher trigger
  5017. if (vm &&
  5018. vm.$options.propsData &&
  5019. vm.$options.propsData[key] === undefined &&
  5020. vm._props[key] !== undefined) {
  5021. return vm._props[key];
  5022. }
  5023. // call factory function for non-Function types
  5024. // a value is Function if its prototype is function even across different execution context
  5025. return isFunction(def) && getType(prop.type) !== 'Function'
  5026. ? def.call(vm)
  5027. : def;
  5028. }
  5029. /**
  5030. * Assert whether a prop is valid.
  5031. */
  5032. function assertProp(prop, name, value, vm, absent) {
  5033. if (prop.required && absent) {
  5034. warn('Missing required prop: "' + name + '"', vm);
  5035. return;
  5036. }
  5037. if (value == null && !prop.required) {
  5038. return;
  5039. }
  5040. let type = prop.type;
  5041. let valid = !type || type === true;
  5042. const expectedTypes = [];
  5043. if (type) {
  5044. if (!isArray(type)) {
  5045. type = [type];
  5046. }
  5047. for (let i = 0; i < type.length && !valid; i++) {
  5048. const assertedType = assertType(value, type[i], vm);
  5049. expectedTypes.push(assertedType.expectedType || '');
  5050. valid = assertedType.valid;
  5051. }
  5052. }
  5053. const haveExpectedTypes = expectedTypes.some(t => t);
  5054. if (!valid && haveExpectedTypes) {
  5055. warn(getInvalidTypeMessage(name, value, expectedTypes), vm);
  5056. return;
  5057. }
  5058. const validator = prop.validator;
  5059. if (validator) {
  5060. if (!validator(value)) {
  5061. warn('Invalid prop: custom validator check failed for prop "' + name + '".', vm);
  5062. }
  5063. }
  5064. }
  5065. const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/;
  5066. function assertType(value, type, vm) {
  5067. let valid;
  5068. const expectedType = getType(type);
  5069. if (simpleCheckRE.test(expectedType)) {
  5070. const t = typeof value;
  5071. valid = t === expectedType.toLowerCase();
  5072. // for primitive wrapper objects
  5073. if (!valid && t === 'object') {
  5074. valid = value instanceof type;
  5075. }
  5076. }
  5077. else if (expectedType === 'Object') {
  5078. valid = isPlainObject(value);
  5079. }
  5080. else if (expectedType === 'Array') {
  5081. valid = isArray(value);
  5082. }
  5083. else {
  5084. try {
  5085. valid = value instanceof type;
  5086. }
  5087. catch (e) {
  5088. warn('Invalid prop type: "' + String(type) + '" is not a constructor', vm);
  5089. valid = false;
  5090. }
  5091. }
  5092. return {
  5093. valid,
  5094. expectedType
  5095. };
  5096. }
  5097. const functionTypeCheckRE = /^\s*function (\w+)/;
  5098. /**
  5099. * Use function string name to check built-in types,
  5100. * because a simple equality check will fail when running
  5101. * across different vms / iframes.
  5102. */
  5103. function getType(fn) {
  5104. const match = fn && fn.toString().match(functionTypeCheckRE);
  5105. return match ? match[1] : '';
  5106. }
  5107. function isSameType(a, b) {
  5108. return getType(a) === getType(b);
  5109. }
  5110. function getTypeIndex(type, expectedTypes) {
  5111. if (!isArray(expectedTypes)) {
  5112. return isSameType(expectedTypes, type) ? 0 : -1;
  5113. }
  5114. for (let i = 0, len = expectedTypes.length; i < len; i++) {
  5115. if (isSameType(expectedTypes[i], type)) {
  5116. return i;
  5117. }
  5118. }
  5119. return -1;
  5120. }
  5121. function getInvalidTypeMessage(name, value, expectedTypes) {
  5122. let message = `Invalid prop: type check failed for prop "${name}".` +
  5123. ` Expected ${expectedTypes.map(capitalize).join(', ')}`;
  5124. const expectedType = expectedTypes[0];
  5125. const receivedType = toRawType(value);
  5126. // check if we need to specify expected value
  5127. if (expectedTypes.length === 1 &&
  5128. isExplicable(expectedType) &&
  5129. isExplicable(typeof value) &&
  5130. !isBoolean(expectedType, receivedType)) {
  5131. message += ` with value ${styleValue(value, expectedType)}`;
  5132. }
  5133. message += `, got ${receivedType} `;
  5134. // check if we need to specify received value
  5135. if (isExplicable(receivedType)) {
  5136. message += `with value ${styleValue(value, receivedType)}.`;
  5137. }
  5138. return message;
  5139. }
  5140. function styleValue(value, type) {
  5141. if (type === 'String') {
  5142. return `"${value}"`;
  5143. }
  5144. else if (type === 'Number') {
  5145. return `${Number(value)}`;
  5146. }
  5147. else {
  5148. return `${value}`;
  5149. }
  5150. }
  5151. const EXPLICABLE_TYPES = ['string', 'number', 'boolean'];
  5152. function isExplicable(value) {
  5153. return EXPLICABLE_TYPES.some(elem => value.toLowerCase() === elem);
  5154. }
  5155. function isBoolean(...args) {
  5156. return args.some(elem => elem.toLowerCase() === 'boolean');
  5157. }
  5158. /* not type checking this file because flow doesn't play well with Proxy */
  5159. let initProxy;
  5160. {
  5161. const allowedGlobals = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' +
  5162. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  5163. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
  5164. 'require' // for Webpack/Browserify
  5165. );
  5166. const warnNonPresent = (target, key) => {
  5167. warn(`Property or method "${key}" is not defined on the instance but ` +
  5168. 'referenced during render. Make sure that this property is reactive, ' +
  5169. 'either in the data option, or for class-based components, by ' +
  5170. 'initializing the property. ' +
  5171. 'See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target);
  5172. };
  5173. const warnReservedPrefix = (target, key) => {
  5174. warn(`Property "${key}" must be accessed with "$data.${key}" because ` +
  5175. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  5176. 'prevent conflicts with Vue internals. ' +
  5177. 'See: https://v2.vuejs.org/v2/api/#data', target);
  5178. };
  5179. const hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy);
  5180. if (hasProxy) {
  5181. const isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  5182. config.keyCodes = new Proxy(config.keyCodes, {
  5183. set(target, key, value) {
  5184. if (isBuiltInModifier(key)) {
  5185. warn(`Avoid overwriting built-in modifier in config.keyCodes: .${key}`);
  5186. return false;
  5187. }
  5188. else {
  5189. target[key] = value;
  5190. return true;
  5191. }
  5192. }
  5193. });
  5194. }
  5195. const hasHandler = {
  5196. has(target, key) {
  5197. const has = key in target;
  5198. const isAllowed = allowedGlobals(key) ||
  5199. (typeof key === 'string' &&
  5200. key.charAt(0) === '_' &&
  5201. !(key in target.$data));
  5202. if (!has && !isAllowed) {
  5203. if (key in target.$data)
  5204. warnReservedPrefix(target, key);
  5205. else
  5206. warnNonPresent(target, key);
  5207. }
  5208. return has || !isAllowed;
  5209. }
  5210. };
  5211. const getHandler = {
  5212. get(target, key) {
  5213. if (typeof key === 'string' && !(key in target)) {
  5214. if (key in target.$data)
  5215. warnReservedPrefix(target, key);
  5216. else
  5217. warnNonPresent(target, key);
  5218. }
  5219. return target[key];
  5220. }
  5221. };
  5222. initProxy = function initProxy(vm) {
  5223. if (hasProxy) {
  5224. // determine which proxy handler to use
  5225. const options = vm.$options;
  5226. const handlers = options.render && options.render._withStripped ? getHandler : hasHandler;
  5227. vm._renderProxy = new Proxy(vm, handlers);
  5228. }
  5229. else {
  5230. vm._renderProxy = vm;
  5231. }
  5232. };
  5233. }
  5234. const sharedPropertyDefinition = {
  5235. enumerable: true,
  5236. configurable: true,
  5237. get: noop,
  5238. set: noop
  5239. };
  5240. function proxy(target, sourceKey, key) {
  5241. sharedPropertyDefinition.get = function proxyGetter() {
  5242. return this[sourceKey][key];
  5243. };
  5244. sharedPropertyDefinition.set = function proxySetter(val) {
  5245. this[sourceKey][key] = val;
  5246. };
  5247. Object.defineProperty(target, key, sharedPropertyDefinition);
  5248. }
  5249. function initState(vm) {
  5250. const opts = vm.$options;
  5251. if (opts.props)
  5252. initProps$1(vm, opts.props);
  5253. // Composition API
  5254. initSetup(vm);
  5255. if (opts.methods)
  5256. initMethods(vm, opts.methods);
  5257. if (opts.data) {
  5258. initData(vm);
  5259. }
  5260. else {
  5261. const ob = observe((vm._data = {}));
  5262. ob && ob.vmCount++;
  5263. }
  5264. if (opts.computed)
  5265. initComputed$1(vm, opts.computed);
  5266. if (opts.watch && opts.watch !== nativeWatch) {
  5267. initWatch(vm, opts.watch);
  5268. }
  5269. }
  5270. function initProps$1(vm, propsOptions) {
  5271. const propsData = vm.$options.propsData || {};
  5272. const props = (vm._props = shallowReactive({}));
  5273. // cache prop keys so that future props updates can iterate using Array
  5274. // instead of dynamic object key enumeration.
  5275. const keys = (vm.$options._propKeys = []);
  5276. const isRoot = !vm.$parent;
  5277. // root instance props should be converted
  5278. if (!isRoot) {
  5279. toggleObserving(false);
  5280. }
  5281. for (const key in propsOptions) {
  5282. keys.push(key);
  5283. const value = validateProp(key, propsOptions, propsData, vm);
  5284. /* istanbul ignore else */
  5285. {
  5286. const hyphenatedKey = hyphenate(key);
  5287. if (isReservedAttribute(hyphenatedKey) ||
  5288. config.isReservedAttr(hyphenatedKey)) {
  5289. warn(`"${hyphenatedKey}" is a reserved attribute and cannot be used as component prop.`, vm);
  5290. }
  5291. defineReactive(props, key, value, () => {
  5292. if (!isRoot && !isUpdatingChildComponent) {
  5293. warn(`Avoid mutating a prop directly since the value will be ` +
  5294. `overwritten whenever the parent component re-renders. ` +
  5295. `Instead, use a data or computed property based on the prop's ` +
  5296. `value. Prop being mutated: "${key}"`, vm);
  5297. }
  5298. }, true /* shallow */);
  5299. }
  5300. // static props are already proxied on the component's prototype
  5301. // during Vue.extend(). We only need to proxy props defined at
  5302. // instantiation here.
  5303. if (!(key in vm)) {
  5304. proxy(vm, `_props`, key);
  5305. }
  5306. }
  5307. toggleObserving(true);
  5308. }
  5309. function initData(vm) {
  5310. let data = vm.$options.data;
  5311. data = vm._data = isFunction(data) ? getData(data, vm) : data || {};
  5312. if (!isPlainObject(data)) {
  5313. data = {};
  5314. warn('data functions should return an object:\n' +
  5315. 'https://v2.vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm);
  5316. }
  5317. // proxy data on instance
  5318. const keys = Object.keys(data);
  5319. const props = vm.$options.props;
  5320. const methods = vm.$options.methods;
  5321. let i = keys.length;
  5322. while (i--) {
  5323. const key = keys[i];
  5324. {
  5325. if (methods && hasOwn(methods, key)) {
  5326. warn(`Method "${key}" has already been defined as a data property.`, vm);
  5327. }
  5328. }
  5329. if (props && hasOwn(props, key)) {
  5330. warn(`The data property "${key}" is already declared as a prop. ` +
  5331. `Use prop default value instead.`, vm);
  5332. }
  5333. else if (!isReserved(key)) {
  5334. proxy(vm, `_data`, key);
  5335. }
  5336. }
  5337. // observe data
  5338. const ob = observe(data);
  5339. ob && ob.vmCount++;
  5340. }
  5341. function getData(data, vm) {
  5342. // #7573 disable dep collection when invoking data getters
  5343. pushTarget();
  5344. try {
  5345. return data.call(vm, vm);
  5346. }
  5347. catch (e) {
  5348. handleError(e, vm, `data()`);
  5349. return {};
  5350. }
  5351. finally {
  5352. popTarget();
  5353. }
  5354. }
  5355. const computedWatcherOptions = { lazy: true };
  5356. function initComputed$1(vm, computed) {
  5357. // $flow-disable-line
  5358. const watchers = (vm._computedWatchers = Object.create(null));
  5359. // computed properties are just getters during SSR
  5360. const isSSR = isServerRendering();
  5361. for (const key in computed) {
  5362. const userDef = computed[key];
  5363. const getter = isFunction(userDef) ? userDef : userDef.get;
  5364. if (getter == null) {
  5365. warn(`Getter is missing for computed property "${key}".`, vm);
  5366. }
  5367. if (!isSSR) {
  5368. // create internal watcher for the computed property.
  5369. watchers[key] = new Watcher(vm, getter || noop, noop, computedWatcherOptions);
  5370. }
  5371. // component-defined computed properties are already defined on the
  5372. // component prototype. We only need to define computed properties defined
  5373. // at instantiation here.
  5374. if (!(key in vm)) {
  5375. defineComputed(vm, key, userDef);
  5376. }
  5377. else {
  5378. if (key in vm.$data) {
  5379. warn(`The computed property "${key}" is already defined in data.`, vm);
  5380. }
  5381. else if (vm.$options.props && key in vm.$options.props) {
  5382. warn(`The computed property "${key}" is already defined as a prop.`, vm);
  5383. }
  5384. else if (vm.$options.methods && key in vm.$options.methods) {
  5385. warn(`The computed property "${key}" is already defined as a method.`, vm);
  5386. }
  5387. }
  5388. }
  5389. }
  5390. function defineComputed(target, key, userDef) {
  5391. const shouldCache = !isServerRendering();
  5392. if (isFunction(userDef)) {
  5393. sharedPropertyDefinition.get = shouldCache
  5394. ? createComputedGetter(key)
  5395. : createGetterInvoker(userDef);
  5396. sharedPropertyDefinition.set = noop;
  5397. }
  5398. else {
  5399. sharedPropertyDefinition.get = userDef.get
  5400. ? shouldCache && userDef.cache !== false
  5401. ? createComputedGetter(key)
  5402. : createGetterInvoker(userDef.get)
  5403. : noop;
  5404. sharedPropertyDefinition.set = userDef.set || noop;
  5405. }
  5406. if (sharedPropertyDefinition.set === noop) {
  5407. sharedPropertyDefinition.set = function () {
  5408. warn(`Computed property "${key}" was assigned to but it has no setter.`, this);
  5409. };
  5410. }
  5411. Object.defineProperty(target, key, sharedPropertyDefinition);
  5412. }
  5413. function createComputedGetter(key) {
  5414. return function computedGetter() {
  5415. const watcher = this._computedWatchers && this._computedWatchers[key];
  5416. if (watcher) {
  5417. if (watcher.dirty) {
  5418. watcher.evaluate();
  5419. }
  5420. if (Dep.target) {
  5421. if (Dep.target.onTrack) {
  5422. Dep.target.onTrack({
  5423. effect: Dep.target,
  5424. target: this,
  5425. type: "get" /* TrackOpTypes.GET */,
  5426. key
  5427. });
  5428. }
  5429. watcher.depend();
  5430. }
  5431. return watcher.value;
  5432. }
  5433. };
  5434. }
  5435. function createGetterInvoker(fn) {
  5436. return function computedGetter() {
  5437. return fn.call(this, this);
  5438. };
  5439. }
  5440. function initMethods(vm, methods) {
  5441. const props = vm.$options.props;
  5442. for (const key in methods) {
  5443. {
  5444. if (typeof methods[key] !== 'function') {
  5445. warn(`Method "${key}" has type "${typeof methods[key]}" in the component definition. ` +
  5446. `Did you reference the function correctly?`, vm);
  5447. }
  5448. if (props && hasOwn(props, key)) {
  5449. warn(`Method "${key}" has already been defined as a prop.`, vm);
  5450. }
  5451. if (key in vm && isReserved(key)) {
  5452. warn(`Method "${key}" conflicts with an existing Vue instance method. ` +
  5453. `Avoid defining component methods that start with _ or $.`);
  5454. }
  5455. }
  5456. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  5457. }
  5458. }
  5459. function initWatch(vm, watch) {
  5460. for (const key in watch) {
  5461. const handler = watch[key];
  5462. if (isArray(handler)) {
  5463. for (let i = 0; i < handler.length; i++) {
  5464. createWatcher(vm, key, handler[i]);
  5465. }
  5466. }
  5467. else {
  5468. createWatcher(vm, key, handler);
  5469. }
  5470. }
  5471. }
  5472. function createWatcher(vm, expOrFn, handler, options) {
  5473. if (isPlainObject(handler)) {
  5474. options = handler;
  5475. handler = handler.handler;
  5476. }
  5477. if (typeof handler === 'string') {
  5478. handler = vm[handler];
  5479. }
  5480. return vm.$watch(expOrFn, handler, options);
  5481. }
  5482. function stateMixin(Vue) {
  5483. // flow somehow has problems with directly declared definition object
  5484. // when using Object.defineProperty, so we have to procedurally build up
  5485. // the object here.
  5486. const dataDef = {};
  5487. dataDef.get = function () {
  5488. return this._data;
  5489. };
  5490. const propsDef = {};
  5491. propsDef.get = function () {
  5492. return this._props;
  5493. };
  5494. {
  5495. dataDef.set = function () {
  5496. warn('Avoid replacing instance root $data. ' +
  5497. 'Use nested data properties instead.', this);
  5498. };
  5499. propsDef.set = function () {
  5500. warn(`$props is readonly.`, this);
  5501. };
  5502. }
  5503. Object.defineProperty(Vue.prototype, '$data', dataDef);
  5504. Object.defineProperty(Vue.prototype, '$props', propsDef);
  5505. Vue.prototype.$set = set;
  5506. Vue.prototype.$delete = del;
  5507. Vue.prototype.$watch = function (expOrFn, cb, options) {
  5508. const vm = this;
  5509. if (isPlainObject(cb)) {
  5510. return createWatcher(vm, expOrFn, cb, options);
  5511. }
  5512. options = options || {};
  5513. options.user = true;
  5514. const watcher = new Watcher(vm, expOrFn, cb, options);
  5515. if (options.immediate) {
  5516. const info = `callback for immediate watcher "${watcher.expression}"`;
  5517. pushTarget();
  5518. invokeWithErrorHandling(cb, vm, [watcher.value], vm, info);
  5519. popTarget();
  5520. }
  5521. return function unwatchFn() {
  5522. watcher.teardown();
  5523. };
  5524. };
  5525. }
  5526. let uid = 0;
  5527. function initMixin$1(Vue) {
  5528. Vue.prototype._init = function (options) {
  5529. const vm = this;
  5530. // a uid
  5531. vm._uid = uid++;
  5532. let startTag, endTag;
  5533. /* istanbul ignore if */
  5534. if (config.performance && mark) {
  5535. startTag = `vue-perf-start:${vm._uid}`;
  5536. endTag = `vue-perf-end:${vm._uid}`;
  5537. mark(startTag);
  5538. }
  5539. // a flag to mark this as a Vue instance without having to do instanceof
  5540. // check
  5541. vm._isVue = true;
  5542. // avoid instances from being observed
  5543. vm.__v_skip = true;
  5544. // effect scope
  5545. vm._scope = new EffectScope(true /* detached */);
  5546. // #13134 edge case where a child component is manually created during the
  5547. // render of a parent component
  5548. vm._scope.parent = undefined;
  5549. vm._scope._vm = true;
  5550. // merge options
  5551. if (options && options._isComponent) {
  5552. // optimize internal component instantiation
  5553. // since dynamic options merging is pretty slow, and none of the
  5554. // internal component options needs special treatment.
  5555. initInternalComponent(vm, options);
  5556. }
  5557. else {
  5558. vm.$options = mergeOptions(resolveConstructorOptions(vm.constructor), options || {}, vm);
  5559. }
  5560. /* istanbul ignore else */
  5561. {
  5562. initProxy(vm);
  5563. }
  5564. // expose real self
  5565. vm._self = vm;
  5566. initLifecycle(vm);
  5567. initEvents(vm);
  5568. initRender(vm);
  5569. callHook$1(vm, 'beforeCreate', undefined, false /* setContext */);
  5570. initInjections(vm); // resolve injections before data/props
  5571. initState(vm);
  5572. initProvide(vm); // resolve provide after data/props
  5573. callHook$1(vm, 'created');
  5574. /* istanbul ignore if */
  5575. if (config.performance && mark) {
  5576. vm._name = formatComponentName(vm, false);
  5577. mark(endTag);
  5578. measure(`vue ${vm._name} init`, startTag, endTag);
  5579. }
  5580. if (vm.$options.el) {
  5581. vm.$mount(vm.$options.el);
  5582. }
  5583. };
  5584. }
  5585. function initInternalComponent(vm, options) {
  5586. const opts = (vm.$options = Object.create(vm.constructor.options));
  5587. // doing this because it's faster than dynamic enumeration.
  5588. const parentVnode = options._parentVnode;
  5589. opts.parent = options.parent;
  5590. opts._parentVnode = parentVnode;
  5591. const vnodeComponentOptions = parentVnode.componentOptions;
  5592. opts.propsData = vnodeComponentOptions.propsData;
  5593. opts._parentListeners = vnodeComponentOptions.listeners;
  5594. opts._renderChildren = vnodeComponentOptions.children;
  5595. opts._componentTag = vnodeComponentOptions.tag;
  5596. if (options.render) {
  5597. opts.render = options.render;
  5598. opts.staticRenderFns = options.staticRenderFns;
  5599. }
  5600. }
  5601. function resolveConstructorOptions(Ctor) {
  5602. let options = Ctor.options;
  5603. if (Ctor.super) {
  5604. const superOptions = resolveConstructorOptions(Ctor.super);
  5605. const cachedSuperOptions = Ctor.superOptions;
  5606. if (superOptions !== cachedSuperOptions) {
  5607. // super option changed,
  5608. // need to resolve new options.
  5609. Ctor.superOptions = superOptions;
  5610. // check if there are any late-modified/attached options (#4976)
  5611. const modifiedOptions = resolveModifiedOptions(Ctor);
  5612. // update base extend options
  5613. if (modifiedOptions) {
  5614. extend(Ctor.extendOptions, modifiedOptions);
  5615. }
  5616. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  5617. if (options.name) {
  5618. options.components[options.name] = Ctor;
  5619. }
  5620. }
  5621. }
  5622. return options;
  5623. }
  5624. function resolveModifiedOptions(Ctor) {
  5625. let modified;
  5626. const latest = Ctor.options;
  5627. const sealed = Ctor.sealedOptions;
  5628. for (const key in latest) {
  5629. if (latest[key] !== sealed[key]) {
  5630. if (!modified)
  5631. modified = {};
  5632. modified[key] = latest[key];
  5633. }
  5634. }
  5635. return modified;
  5636. }
  5637. function Vue(options) {
  5638. if (!(this instanceof Vue)) {
  5639. warn('Vue is a constructor and should be called with the `new` keyword');
  5640. }
  5641. this._init(options);
  5642. }
  5643. //@ts-expect-error Vue has function type
  5644. initMixin$1(Vue);
  5645. //@ts-expect-error Vue has function type
  5646. stateMixin(Vue);
  5647. //@ts-expect-error Vue has function type
  5648. eventsMixin(Vue);
  5649. //@ts-expect-error Vue has function type
  5650. lifecycleMixin(Vue);
  5651. //@ts-expect-error Vue has function type
  5652. renderMixin(Vue);
  5653. function initUse(Vue) {
  5654. Vue.use = function (plugin) {
  5655. const installedPlugins = this._installedPlugins || (this._installedPlugins = []);
  5656. if (installedPlugins.indexOf(plugin) > -1) {
  5657. return this;
  5658. }
  5659. // additional parameters
  5660. const args = toArray(arguments, 1);
  5661. args.unshift(this);
  5662. if (isFunction(plugin.install)) {
  5663. plugin.install.apply(plugin, args);
  5664. }
  5665. else if (isFunction(plugin)) {
  5666. plugin.apply(null, args);
  5667. }
  5668. installedPlugins.push(plugin);
  5669. return this;
  5670. };
  5671. }
  5672. function initMixin(Vue) {
  5673. Vue.mixin = function (mixin) {
  5674. this.options = mergeOptions(this.options, mixin);
  5675. return this;
  5676. };
  5677. }
  5678. function initExtend(Vue) {
  5679. /**
  5680. * Each instance constructor, including Vue, has a unique
  5681. * cid. This enables us to create wrapped "child
  5682. * constructors" for prototypal inheritance and cache them.
  5683. */
  5684. Vue.cid = 0;
  5685. let cid = 1;
  5686. /**
  5687. * Class inheritance
  5688. */
  5689. Vue.extend = function (extendOptions) {
  5690. extendOptions = extendOptions || {};
  5691. const Super = this;
  5692. const SuperId = Super.cid;
  5693. const cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  5694. if (cachedCtors[SuperId]) {
  5695. return cachedCtors[SuperId];
  5696. }
  5697. const name = getComponentName(extendOptions) || getComponentName(Super.options);
  5698. if (name) {
  5699. validateComponentName(name);
  5700. }
  5701. const Sub = function VueComponent(options) {
  5702. this._init(options);
  5703. };
  5704. Sub.prototype = Object.create(Super.prototype);
  5705. Sub.prototype.constructor = Sub;
  5706. Sub.cid = cid++;
  5707. Sub.options = mergeOptions(Super.options, extendOptions);
  5708. Sub['super'] = Super;
  5709. // For props and computed properties, we define the proxy getters on
  5710. // the Vue instances at extension time, on the extended prototype. This
  5711. // avoids Object.defineProperty calls for each instance created.
  5712. if (Sub.options.props) {
  5713. initProps(Sub);
  5714. }
  5715. if (Sub.options.computed) {
  5716. initComputed(Sub);
  5717. }
  5718. // allow further extension/mixin/plugin usage
  5719. Sub.extend = Super.extend;
  5720. Sub.mixin = Super.mixin;
  5721. Sub.use = Super.use;
  5722. // create asset registers, so extended classes
  5723. // can have their private assets too.
  5724. ASSET_TYPES.forEach(function (type) {
  5725. Sub[type] = Super[type];
  5726. });
  5727. // enable recursive self-lookup
  5728. if (name) {
  5729. Sub.options.components[name] = Sub;
  5730. }
  5731. // keep a reference to the super options at extension time.
  5732. // later at instantiation we can check if Super's options have
  5733. // been updated.
  5734. Sub.superOptions = Super.options;
  5735. Sub.extendOptions = extendOptions;
  5736. Sub.sealedOptions = extend({}, Sub.options);
  5737. // cache constructor
  5738. cachedCtors[SuperId] = Sub;
  5739. return Sub;
  5740. };
  5741. }
  5742. function initProps(Comp) {
  5743. const props = Comp.options.props;
  5744. for (const key in props) {
  5745. proxy(Comp.prototype, `_props`, key);
  5746. }
  5747. }
  5748. function initComputed(Comp) {
  5749. const computed = Comp.options.computed;
  5750. for (const key in computed) {
  5751. defineComputed(Comp.prototype, key, computed[key]);
  5752. }
  5753. }
  5754. function initAssetRegisters(Vue) {
  5755. /**
  5756. * Create asset registration methods.
  5757. */
  5758. ASSET_TYPES.forEach(type => {
  5759. // @ts-expect-error function is not exact same type
  5760. Vue[type] = function (id, definition) {
  5761. if (!definition) {
  5762. return this.options[type + 's'][id];
  5763. }
  5764. else {
  5765. /* istanbul ignore if */
  5766. if (type === 'component') {
  5767. validateComponentName(id);
  5768. }
  5769. if (type === 'component' && isPlainObject(definition)) {
  5770. // @ts-expect-error
  5771. definition.name = definition.name || id;
  5772. definition = this.options._base.extend(definition);
  5773. }
  5774. if (type === 'directive' && isFunction(definition)) {
  5775. definition = { bind: definition, update: definition };
  5776. }
  5777. this.options[type + 's'][id] = definition;
  5778. return definition;
  5779. }
  5780. };
  5781. });
  5782. }
  5783. function _getComponentName(opts) {
  5784. return opts && (getComponentName(opts.Ctor.options) || opts.tag);
  5785. }
  5786. function matches(pattern, name) {
  5787. if (isArray(pattern)) {
  5788. return pattern.indexOf(name) > -1;
  5789. }
  5790. else if (typeof pattern === 'string') {
  5791. return pattern.split(',').indexOf(name) > -1;
  5792. }
  5793. else if (isRegExp(pattern)) {
  5794. return pattern.test(name);
  5795. }
  5796. /* istanbul ignore next */
  5797. return false;
  5798. }
  5799. function pruneCache(keepAliveInstance, filter) {
  5800. const { cache, keys, _vnode, $vnode } = keepAliveInstance;
  5801. for (const key in cache) {
  5802. const entry = cache[key];
  5803. if (entry) {
  5804. const name = entry.name;
  5805. if (name && !filter(name)) {
  5806. pruneCacheEntry(cache, key, keys, _vnode);
  5807. }
  5808. }
  5809. }
  5810. $vnode.componentOptions.children = undefined;
  5811. }
  5812. function pruneCacheEntry(cache, key, keys, current) {
  5813. const entry = cache[key];
  5814. if (entry && (!current || entry.tag !== current.tag)) {
  5815. // @ts-expect-error can be undefined
  5816. entry.componentInstance.$destroy();
  5817. }
  5818. cache[key] = null;
  5819. remove$2(keys, key);
  5820. }
  5821. const patternTypes = [String, RegExp, Array];
  5822. // TODO defineComponent
  5823. var KeepAlive = {
  5824. name: 'keep-alive',
  5825. abstract: true,
  5826. props: {
  5827. include: patternTypes,
  5828. exclude: patternTypes,
  5829. max: [String, Number]
  5830. },
  5831. methods: {
  5832. cacheVNode() {
  5833. const { cache, keys, vnodeToCache, keyToCache } = this;
  5834. if (vnodeToCache) {
  5835. const { tag, componentInstance, componentOptions } = vnodeToCache;
  5836. cache[keyToCache] = {
  5837. name: _getComponentName(componentOptions),
  5838. tag,
  5839. componentInstance
  5840. };
  5841. keys.push(keyToCache);
  5842. // prune oldest entry
  5843. if (this.max && keys.length > parseInt(this.max)) {
  5844. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  5845. }
  5846. this.vnodeToCache = null;
  5847. }
  5848. }
  5849. },
  5850. created() {
  5851. this.cache = Object.create(null);
  5852. this.keys = [];
  5853. },
  5854. destroyed() {
  5855. for (const key in this.cache) {
  5856. pruneCacheEntry(this.cache, key, this.keys);
  5857. }
  5858. },
  5859. mounted() {
  5860. this.cacheVNode();
  5861. this.$watch('include', val => {
  5862. pruneCache(this, name => matches(val, name));
  5863. });
  5864. this.$watch('exclude', val => {
  5865. pruneCache(this, name => !matches(val, name));
  5866. });
  5867. },
  5868. updated() {
  5869. this.cacheVNode();
  5870. },
  5871. render() {
  5872. const slot = this.$slots.default;
  5873. const vnode = getFirstComponentChild(slot);
  5874. const componentOptions = vnode && vnode.componentOptions;
  5875. if (componentOptions) {
  5876. // check pattern
  5877. const name = _getComponentName(componentOptions);
  5878. const { include, exclude } = this;
  5879. if (
  5880. // not included
  5881. (include && (!name || !matches(include, name))) ||
  5882. // excluded
  5883. (exclude && name && matches(exclude, name))) {
  5884. return vnode;
  5885. }
  5886. const { cache, keys } = this;
  5887. const key = vnode.key == null
  5888. ? // same constructor may get registered as different local components
  5889. // so cid alone is not enough (#3269)
  5890. componentOptions.Ctor.cid +
  5891. (componentOptions.tag ? `::${componentOptions.tag}` : '')
  5892. : vnode.key;
  5893. if (cache[key]) {
  5894. vnode.componentInstance = cache[key].componentInstance;
  5895. // make current key freshest
  5896. remove$2(keys, key);
  5897. keys.push(key);
  5898. }
  5899. else {
  5900. // delay setting the cache until update
  5901. this.vnodeToCache = vnode;
  5902. this.keyToCache = key;
  5903. }
  5904. // @ts-expect-error can vnode.data can be undefined
  5905. vnode.data.keepAlive = true;
  5906. }
  5907. return vnode || (slot && slot[0]);
  5908. }
  5909. };
  5910. var builtInComponents = {
  5911. KeepAlive
  5912. };
  5913. function initGlobalAPI(Vue) {
  5914. // config
  5915. const configDef = {};
  5916. configDef.get = () => config;
  5917. {
  5918. configDef.set = () => {
  5919. warn('Do not replace the Vue.config object, set individual fields instead.');
  5920. };
  5921. }
  5922. Object.defineProperty(Vue, 'config', configDef);
  5923. // exposed util methods.
  5924. // NOTE: these are not considered part of the public API - avoid relying on
  5925. // them unless you are aware of the risk.
  5926. Vue.util = {
  5927. warn,
  5928. extend,
  5929. mergeOptions,
  5930. defineReactive
  5931. };
  5932. Vue.set = set;
  5933. Vue.delete = del;
  5934. Vue.nextTick = nextTick;
  5935. // 2.6 explicit observable API
  5936. Vue.observable = (obj) => {
  5937. observe(obj);
  5938. return obj;
  5939. };
  5940. Vue.options = Object.create(null);
  5941. ASSET_TYPES.forEach(type => {
  5942. Vue.options[type + 's'] = Object.create(null);
  5943. });
  5944. // this is used to identify the "base" constructor to extend all plain-object
  5945. // components with in Weex's multi-instance scenarios.
  5946. Vue.options._base = Vue;
  5947. extend(Vue.options.components, builtInComponents);
  5948. initUse(Vue);
  5949. initMixin(Vue);
  5950. initExtend(Vue);
  5951. initAssetRegisters(Vue);
  5952. }
  5953. initGlobalAPI(Vue);
  5954. Object.defineProperty(Vue.prototype, '$isServer', {
  5955. get: isServerRendering
  5956. });
  5957. Object.defineProperty(Vue.prototype, '$ssrContext', {
  5958. get() {
  5959. /* istanbul ignore next */
  5960. return this.$vnode && this.$vnode.ssrContext;
  5961. }
  5962. });
  5963. // expose FunctionalRenderContext for ssr runtime helper installation
  5964. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  5965. value: FunctionalRenderContext
  5966. });
  5967. Vue.version = version;
  5968. // these are reserved for web because they are directly compiled away
  5969. // during template compilation
  5970. const isReservedAttr = makeMap('style,class');
  5971. // attributes that should be using props for binding
  5972. const acceptValue = makeMap('input,textarea,option,select,progress');
  5973. const mustUseProp = (tag, type, attr) => {
  5974. return ((attr === 'value' && acceptValue(tag) && type !== 'button') ||
  5975. (attr === 'selected' && tag === 'option') ||
  5976. (attr === 'checked' && tag === 'input') ||
  5977. (attr === 'muted' && tag === 'video'));
  5978. };
  5979. const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  5980. const isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  5981. const convertEnumeratedValue = (key, value) => {
  5982. return isFalsyAttrValue(value) || value === 'false'
  5983. ? 'false'
  5984. : // allow arbitrary string value for contenteditable
  5985. key === 'contenteditable' && isValidContentEditableValue(value)
  5986. ? value
  5987. : 'true';
  5988. };
  5989. const isBooleanAttr = makeMap('allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  5990. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  5991. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  5992. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  5993. 'required,reversed,scoped,seamless,selected,sortable,' +
  5994. 'truespeed,typemustmatch,visible');
  5995. const xlinkNS = 'http://www.w3.org/1999/xlink';
  5996. const isXlink = (name) => {
  5997. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink';
  5998. };
  5999. const getXlinkProp = (name) => {
  6000. return isXlink(name) ? name.slice(6, name.length) : '';
  6001. };
  6002. const isFalsyAttrValue = (val) => {
  6003. return val == null || val === false;
  6004. };
  6005. function genClassForVnode(vnode) {
  6006. let data = vnode.data;
  6007. let parentNode = vnode;
  6008. let childNode = vnode;
  6009. while (isDef(childNode.componentInstance)) {
  6010. childNode = childNode.componentInstance._vnode;
  6011. if (childNode && childNode.data) {
  6012. data = mergeClassData(childNode.data, data);
  6013. }
  6014. }
  6015. // @ts-expect-error parentNode.parent not VNodeWithData
  6016. while (isDef((parentNode = parentNode.parent))) {
  6017. if (parentNode && parentNode.data) {
  6018. data = mergeClassData(data, parentNode.data);
  6019. }
  6020. }
  6021. return renderClass(data.staticClass, data.class);
  6022. }
  6023. function mergeClassData(child, parent) {
  6024. return {
  6025. staticClass: concat(child.staticClass, parent.staticClass),
  6026. class: isDef(child.class) ? [child.class, parent.class] : parent.class
  6027. };
  6028. }
  6029. function renderClass(staticClass, dynamicClass) {
  6030. if (isDef(staticClass) || isDef(dynamicClass)) {
  6031. return concat(staticClass, stringifyClass(dynamicClass));
  6032. }
  6033. /* istanbul ignore next */
  6034. return '';
  6035. }
  6036. function concat(a, b) {
  6037. return a ? (b ? a + ' ' + b : a) : b || '';
  6038. }
  6039. function stringifyClass(value) {
  6040. if (Array.isArray(value)) {
  6041. return stringifyArray(value);
  6042. }
  6043. if (isObject(value)) {
  6044. return stringifyObject(value);
  6045. }
  6046. if (typeof value === 'string') {
  6047. return value;
  6048. }
  6049. /* istanbul ignore next */
  6050. return '';
  6051. }
  6052. function stringifyArray(value) {
  6053. let res = '';
  6054. let stringified;
  6055. for (let i = 0, l = value.length; i < l; i++) {
  6056. if (isDef((stringified = stringifyClass(value[i]))) && stringified !== '') {
  6057. if (res)
  6058. res += ' ';
  6059. res += stringified;
  6060. }
  6061. }
  6062. return res;
  6063. }
  6064. function stringifyObject(value) {
  6065. let res = '';
  6066. for (const key in value) {
  6067. if (value[key]) {
  6068. if (res)
  6069. res += ' ';
  6070. res += key;
  6071. }
  6072. }
  6073. return res;
  6074. }
  6075. const namespaceMap = {
  6076. svg: 'http://www.w3.org/2000/svg',
  6077. math: 'http://www.w3.org/1998/Math/MathML'
  6078. };
  6079. const isHTMLTag = makeMap('html,body,base,head,link,meta,style,title,' +
  6080. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  6081. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  6082. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  6083. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  6084. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  6085. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  6086. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  6087. 'output,progress,select,textarea,' +
  6088. 'details,dialog,menu,menuitem,summary,' +
  6089. 'content,element,shadow,template,blockquote,iframe,tfoot');
  6090. // this map is intentionally selective, only covering SVG elements that may
  6091. // contain child elements.
  6092. const isSVG = makeMap('svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  6093. 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  6094. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', true);
  6095. const isReservedTag = (tag) => {
  6096. return isHTMLTag(tag) || isSVG(tag);
  6097. };
  6098. function getTagNamespace(tag) {
  6099. if (isSVG(tag)) {
  6100. return 'svg';
  6101. }
  6102. // basic support for MathML
  6103. // note it doesn't support other MathML elements being component roots
  6104. if (tag === 'math') {
  6105. return 'math';
  6106. }
  6107. }
  6108. const unknownElementCache = Object.create(null);
  6109. function isUnknownElement(tag) {
  6110. /* istanbul ignore if */
  6111. if (!inBrowser) {
  6112. return true;
  6113. }
  6114. if (isReservedTag(tag)) {
  6115. return false;
  6116. }
  6117. tag = tag.toLowerCase();
  6118. /* istanbul ignore if */
  6119. if (unknownElementCache[tag] != null) {
  6120. return unknownElementCache[tag];
  6121. }
  6122. const el = document.createElement(tag);
  6123. if (tag.indexOf('-') > -1) {
  6124. // https://stackoverflow.com/a/28210364/1070244
  6125. return (unknownElementCache[tag] =
  6126. el.constructor === window.HTMLUnknownElement ||
  6127. el.constructor === window.HTMLElement);
  6128. }
  6129. else {
  6130. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()));
  6131. }
  6132. }
  6133. const isTextInputType = makeMap('text,number,password,search,email,tel,url');
  6134. /**
  6135. * Query an element selector if it's not an element already.
  6136. */
  6137. function query(el) {
  6138. if (typeof el === 'string') {
  6139. const selected = document.querySelector(el);
  6140. if (!selected) {
  6141. warn('Cannot find element: ' + el);
  6142. return document.createElement('div');
  6143. }
  6144. return selected;
  6145. }
  6146. else {
  6147. return el;
  6148. }
  6149. }
  6150. function createElement(tagName, vnode) {
  6151. const elm = document.createElement(tagName);
  6152. if (tagName !== 'select') {
  6153. return elm;
  6154. }
  6155. // false or null will remove the attribute but undefined will not
  6156. if (vnode.data &&
  6157. vnode.data.attrs &&
  6158. vnode.data.attrs.multiple !== undefined) {
  6159. elm.setAttribute('multiple', 'multiple');
  6160. }
  6161. return elm;
  6162. }
  6163. function createElementNS(namespace, tagName) {
  6164. return document.createElementNS(namespaceMap[namespace], tagName);
  6165. }
  6166. function createTextNode(text) {
  6167. return document.createTextNode(text);
  6168. }
  6169. function createComment(text) {
  6170. return document.createComment(text);
  6171. }
  6172. function insertBefore(parentNode, newNode, referenceNode) {
  6173. parentNode.insertBefore(newNode, referenceNode);
  6174. }
  6175. function removeChild(node, child) {
  6176. node.removeChild(child);
  6177. }
  6178. function appendChild(node, child) {
  6179. node.appendChild(child);
  6180. }
  6181. function parentNode(node) {
  6182. return node.parentNode;
  6183. }
  6184. function nextSibling(node) {
  6185. return node.nextSibling;
  6186. }
  6187. function tagName(node) {
  6188. return node.tagName;
  6189. }
  6190. function setTextContent(node, text) {
  6191. node.textContent = text;
  6192. }
  6193. function setStyleScope(node, scopeId) {
  6194. node.setAttribute(scopeId, '');
  6195. }
  6196. var nodeOps = /*#__PURE__*/Object.freeze({
  6197. __proto__: null,
  6198. createElement: createElement,
  6199. createElementNS: createElementNS,
  6200. createTextNode: createTextNode,
  6201. createComment: createComment,
  6202. insertBefore: insertBefore,
  6203. removeChild: removeChild,
  6204. appendChild: appendChild,
  6205. parentNode: parentNode,
  6206. nextSibling: nextSibling,
  6207. tagName: tagName,
  6208. setTextContent: setTextContent,
  6209. setStyleScope: setStyleScope
  6210. });
  6211. var ref = {
  6212. create(_, vnode) {
  6213. registerRef(vnode);
  6214. },
  6215. update(oldVnode, vnode) {
  6216. if (oldVnode.data.ref !== vnode.data.ref) {
  6217. registerRef(oldVnode, true);
  6218. registerRef(vnode);
  6219. }
  6220. },
  6221. destroy(vnode) {
  6222. registerRef(vnode, true);
  6223. }
  6224. };
  6225. function registerRef(vnode, isRemoval) {
  6226. const ref = vnode.data.ref;
  6227. if (!isDef(ref))
  6228. return;
  6229. const vm = vnode.context;
  6230. const refValue = vnode.componentInstance || vnode.elm;
  6231. const value = isRemoval ? null : refValue;
  6232. const $refsValue = isRemoval ? undefined : refValue;
  6233. if (isFunction(ref)) {
  6234. invokeWithErrorHandling(ref, vm, [value], vm, `template ref function`);
  6235. return;
  6236. }
  6237. const isFor = vnode.data.refInFor;
  6238. const _isString = typeof ref === 'string' || typeof ref === 'number';
  6239. const _isRef = isRef(ref);
  6240. const refs = vm.$refs;
  6241. if (_isString || _isRef) {
  6242. if (isFor) {
  6243. const existing = _isString ? refs[ref] : ref.value;
  6244. if (isRemoval) {
  6245. isArray(existing) && remove$2(existing, refValue);
  6246. }
  6247. else {
  6248. if (!isArray(existing)) {
  6249. if (_isString) {
  6250. refs[ref] = [refValue];
  6251. setSetupRef(vm, ref, refs[ref]);
  6252. }
  6253. else {
  6254. ref.value = [refValue];
  6255. }
  6256. }
  6257. else if (!existing.includes(refValue)) {
  6258. existing.push(refValue);
  6259. }
  6260. }
  6261. }
  6262. else if (_isString) {
  6263. if (isRemoval && refs[ref] !== refValue) {
  6264. return;
  6265. }
  6266. refs[ref] = $refsValue;
  6267. setSetupRef(vm, ref, value);
  6268. }
  6269. else if (_isRef) {
  6270. if (isRemoval && ref.value !== refValue) {
  6271. return;
  6272. }
  6273. ref.value = value;
  6274. }
  6275. else {
  6276. warn(`Invalid template ref type: ${typeof ref}`);
  6277. }
  6278. }
  6279. }
  6280. function setSetupRef({ _setupState }, key, val) {
  6281. if (_setupState && hasOwn(_setupState, key)) {
  6282. if (isRef(_setupState[key])) {
  6283. _setupState[key].value = val;
  6284. }
  6285. else {
  6286. _setupState[key] = val;
  6287. }
  6288. }
  6289. }
  6290. /**
  6291. * Virtual DOM patching algorithm based on Snabbdom by
  6292. * Simon Friis Vindum (@paldepind)
  6293. * Licensed under the MIT License
  6294. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  6295. *
  6296. * modified by Evan You (@yyx990803)
  6297. *
  6298. * Not type-checking this because this file is perf-critical and the cost
  6299. * of making flow understand it is not worth it.
  6300. */
  6301. const emptyNode = new VNode('', {}, []);
  6302. const hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  6303. function sameVnode(a, b) {
  6304. return (a.key === b.key &&
  6305. a.asyncFactory === b.asyncFactory &&
  6306. ((a.tag === b.tag &&
  6307. a.isComment === b.isComment &&
  6308. isDef(a.data) === isDef(b.data) &&
  6309. sameInputType(a, b)) ||
  6310. (isTrue(a.isAsyncPlaceholder) && isUndef(b.asyncFactory.error))));
  6311. }
  6312. function sameInputType(a, b) {
  6313. if (a.tag !== 'input')
  6314. return true;
  6315. let i;
  6316. const typeA = isDef((i = a.data)) && isDef((i = i.attrs)) && i.type;
  6317. const typeB = isDef((i = b.data)) && isDef((i = i.attrs)) && i.type;
  6318. return typeA === typeB || (isTextInputType(typeA) && isTextInputType(typeB));
  6319. }
  6320. function createKeyToOldIdx(children, beginIdx, endIdx) {
  6321. let i, key;
  6322. const map = {};
  6323. for (i = beginIdx; i <= endIdx; ++i) {
  6324. key = children[i].key;
  6325. if (isDef(key))
  6326. map[key] = i;
  6327. }
  6328. return map;
  6329. }
  6330. function createPatchFunction(backend) {
  6331. let i, j;
  6332. const cbs = {};
  6333. const { modules, nodeOps } = backend;
  6334. for (i = 0; i < hooks.length; ++i) {
  6335. cbs[hooks[i]] = [];
  6336. for (j = 0; j < modules.length; ++j) {
  6337. if (isDef(modules[j][hooks[i]])) {
  6338. cbs[hooks[i]].push(modules[j][hooks[i]]);
  6339. }
  6340. }
  6341. }
  6342. function emptyNodeAt(elm) {
  6343. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm);
  6344. }
  6345. function createRmCb(childElm, listeners) {
  6346. function remove() {
  6347. if (--remove.listeners === 0) {
  6348. removeNode(childElm);
  6349. }
  6350. }
  6351. remove.listeners = listeners;
  6352. return remove;
  6353. }
  6354. function removeNode(el) {
  6355. const parent = nodeOps.parentNode(el);
  6356. // element may have already been removed due to v-html / v-text
  6357. if (isDef(parent)) {
  6358. nodeOps.removeChild(parent, el);
  6359. }
  6360. }
  6361. function isUnknownElement(vnode, inVPre) {
  6362. return (!inVPre &&
  6363. !vnode.ns &&
  6364. !(config.ignoredElements.length &&
  6365. config.ignoredElements.some(ignore => {
  6366. return isRegExp(ignore)
  6367. ? ignore.test(vnode.tag)
  6368. : ignore === vnode.tag;
  6369. })) &&
  6370. config.isUnknownElement(vnode.tag));
  6371. }
  6372. let creatingElmInVPre = 0;
  6373. function createElm(vnode, insertedVnodeQueue, parentElm, refElm, nested, ownerArray, index) {
  6374. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6375. // This vnode was used in a previous render!
  6376. // now it's used as a new node, overwriting its elm would cause
  6377. // potential patch errors down the road when it's used as an insertion
  6378. // reference node. Instead, we clone the node on-demand before creating
  6379. // associated DOM element for it.
  6380. vnode = ownerArray[index] = cloneVNode(vnode);
  6381. }
  6382. vnode.isRootInsert = !nested; // for transition enter check
  6383. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  6384. return;
  6385. }
  6386. const data = vnode.data;
  6387. const children = vnode.children;
  6388. const tag = vnode.tag;
  6389. if (isDef(tag)) {
  6390. {
  6391. if (data && data.pre) {
  6392. creatingElmInVPre++;
  6393. }
  6394. if (isUnknownElement(vnode, creatingElmInVPre)) {
  6395. warn('Unknown custom element: <' +
  6396. tag +
  6397. '> - did you ' +
  6398. 'register the component correctly? For recursive components, ' +
  6399. 'make sure to provide the "name" option.', vnode.context);
  6400. }
  6401. }
  6402. vnode.elm = vnode.ns
  6403. ? nodeOps.createElementNS(vnode.ns, tag)
  6404. : nodeOps.createElement(tag, vnode);
  6405. setScope(vnode);
  6406. createChildren(vnode, children, insertedVnodeQueue);
  6407. if (isDef(data)) {
  6408. invokeCreateHooks(vnode, insertedVnodeQueue);
  6409. }
  6410. insert(parentElm, vnode.elm, refElm);
  6411. if (data && data.pre) {
  6412. creatingElmInVPre--;
  6413. }
  6414. }
  6415. else if (isTrue(vnode.isComment)) {
  6416. vnode.elm = nodeOps.createComment(vnode.text);
  6417. insert(parentElm, vnode.elm, refElm);
  6418. }
  6419. else {
  6420. vnode.elm = nodeOps.createTextNode(vnode.text);
  6421. insert(parentElm, vnode.elm, refElm);
  6422. }
  6423. }
  6424. function createComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6425. let i = vnode.data;
  6426. if (isDef(i)) {
  6427. const isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  6428. if (isDef((i = i.hook)) && isDef((i = i.init))) {
  6429. i(vnode, false /* hydrating */);
  6430. }
  6431. // after calling the init hook, if the vnode is a child component
  6432. // it should've created a child instance and mounted it. the child
  6433. // component also has set the placeholder vnode's elm.
  6434. // in that case we can just return the element and be done.
  6435. if (isDef(vnode.componentInstance)) {
  6436. initComponent(vnode, insertedVnodeQueue);
  6437. insert(parentElm, vnode.elm, refElm);
  6438. if (isTrue(isReactivated)) {
  6439. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  6440. }
  6441. return true;
  6442. }
  6443. }
  6444. }
  6445. function initComponent(vnode, insertedVnodeQueue) {
  6446. if (isDef(vnode.data.pendingInsert)) {
  6447. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  6448. vnode.data.pendingInsert = null;
  6449. }
  6450. vnode.elm = vnode.componentInstance.$el;
  6451. if (isPatchable(vnode)) {
  6452. invokeCreateHooks(vnode, insertedVnodeQueue);
  6453. setScope(vnode);
  6454. }
  6455. else {
  6456. // empty component root.
  6457. // skip all element-related modules except for ref (#3455)
  6458. registerRef(vnode);
  6459. // make sure to invoke the insert hook
  6460. insertedVnodeQueue.push(vnode);
  6461. }
  6462. }
  6463. function reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
  6464. let i;
  6465. // hack for #4339: a reactivated component with inner transition
  6466. // does not trigger because the inner node's created hooks are not called
  6467. // again. It's not ideal to involve module-specific logic in here but
  6468. // there doesn't seem to be a better way to do it.
  6469. let innerNode = vnode;
  6470. while (innerNode.componentInstance) {
  6471. innerNode = innerNode.componentInstance._vnode;
  6472. if (isDef((i = innerNode.data)) && isDef((i = i.transition))) {
  6473. for (i = 0; i < cbs.activate.length; ++i) {
  6474. cbs.activate[i](emptyNode, innerNode);
  6475. }
  6476. insertedVnodeQueue.push(innerNode);
  6477. break;
  6478. }
  6479. }
  6480. // unlike a newly created component,
  6481. // a reactivated keep-alive component doesn't insert itself
  6482. insert(parentElm, vnode.elm, refElm);
  6483. }
  6484. function insert(parent, elm, ref) {
  6485. if (isDef(parent)) {
  6486. if (isDef(ref)) {
  6487. if (nodeOps.parentNode(ref) === parent) {
  6488. nodeOps.insertBefore(parent, elm, ref);
  6489. }
  6490. }
  6491. else {
  6492. nodeOps.appendChild(parent, elm);
  6493. }
  6494. }
  6495. }
  6496. function createChildren(vnode, children, insertedVnodeQueue) {
  6497. if (isArray(children)) {
  6498. {
  6499. checkDuplicateKeys(children);
  6500. }
  6501. for (let i = 0; i < children.length; ++i) {
  6502. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  6503. }
  6504. }
  6505. else if (isPrimitive(vnode.text)) {
  6506. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  6507. }
  6508. }
  6509. function isPatchable(vnode) {
  6510. while (vnode.componentInstance) {
  6511. vnode = vnode.componentInstance._vnode;
  6512. }
  6513. return isDef(vnode.tag);
  6514. }
  6515. function invokeCreateHooks(vnode, insertedVnodeQueue) {
  6516. for (let i = 0; i < cbs.create.length; ++i) {
  6517. cbs.create[i](emptyNode, vnode);
  6518. }
  6519. i = vnode.data.hook; // Reuse variable
  6520. if (isDef(i)) {
  6521. if (isDef(i.create))
  6522. i.create(emptyNode, vnode);
  6523. if (isDef(i.insert))
  6524. insertedVnodeQueue.push(vnode);
  6525. }
  6526. }
  6527. // set scope id attribute for scoped CSS.
  6528. // this is implemented as a special case to avoid the overhead
  6529. // of going through the normal attribute patching process.
  6530. function setScope(vnode) {
  6531. let i;
  6532. if (isDef((i = vnode.fnScopeId))) {
  6533. nodeOps.setStyleScope(vnode.elm, i);
  6534. }
  6535. else {
  6536. let ancestor = vnode;
  6537. while (ancestor) {
  6538. if (isDef((i = ancestor.context)) && isDef((i = i.$options._scopeId))) {
  6539. nodeOps.setStyleScope(vnode.elm, i);
  6540. }
  6541. ancestor = ancestor.parent;
  6542. }
  6543. }
  6544. // for slot content they should also get the scopeId from the host instance.
  6545. if (isDef((i = activeInstance)) &&
  6546. i !== vnode.context &&
  6547. i !== vnode.fnContext &&
  6548. isDef((i = i.$options._scopeId))) {
  6549. nodeOps.setStyleScope(vnode.elm, i);
  6550. }
  6551. }
  6552. function addVnodes(parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  6553. for (; startIdx <= endIdx; ++startIdx) {
  6554. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  6555. }
  6556. }
  6557. function invokeDestroyHook(vnode) {
  6558. let i, j;
  6559. const data = vnode.data;
  6560. if (isDef(data)) {
  6561. if (isDef((i = data.hook)) && isDef((i = i.destroy)))
  6562. i(vnode);
  6563. for (i = 0; i < cbs.destroy.length; ++i)
  6564. cbs.destroy[i](vnode);
  6565. }
  6566. if (isDef((i = vnode.children))) {
  6567. for (j = 0; j < vnode.children.length; ++j) {
  6568. invokeDestroyHook(vnode.children[j]);
  6569. }
  6570. }
  6571. }
  6572. function removeVnodes(vnodes, startIdx, endIdx) {
  6573. for (; startIdx <= endIdx; ++startIdx) {
  6574. const ch = vnodes[startIdx];
  6575. if (isDef(ch)) {
  6576. if (isDef(ch.tag)) {
  6577. removeAndInvokeRemoveHook(ch);
  6578. invokeDestroyHook(ch);
  6579. }
  6580. else {
  6581. // Text node
  6582. removeNode(ch.elm);
  6583. }
  6584. }
  6585. }
  6586. }
  6587. function removeAndInvokeRemoveHook(vnode, rm) {
  6588. if (isDef(rm) || isDef(vnode.data)) {
  6589. let i;
  6590. const listeners = cbs.remove.length + 1;
  6591. if (isDef(rm)) {
  6592. // we have a recursively passed down rm callback
  6593. // increase the listeners count
  6594. rm.listeners += listeners;
  6595. }
  6596. else {
  6597. // directly removing
  6598. rm = createRmCb(vnode.elm, listeners);
  6599. }
  6600. // recursively invoke hooks on child component root node
  6601. if (isDef((i = vnode.componentInstance)) &&
  6602. isDef((i = i._vnode)) &&
  6603. isDef(i.data)) {
  6604. removeAndInvokeRemoveHook(i, rm);
  6605. }
  6606. for (i = 0; i < cbs.remove.length; ++i) {
  6607. cbs.remove[i](vnode, rm);
  6608. }
  6609. if (isDef((i = vnode.data.hook)) && isDef((i = i.remove))) {
  6610. i(vnode, rm);
  6611. }
  6612. else {
  6613. rm();
  6614. }
  6615. }
  6616. else {
  6617. removeNode(vnode.elm);
  6618. }
  6619. }
  6620. function updateChildren(parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  6621. let oldStartIdx = 0;
  6622. let newStartIdx = 0;
  6623. let oldEndIdx = oldCh.length - 1;
  6624. let oldStartVnode = oldCh[0];
  6625. let oldEndVnode = oldCh[oldEndIdx];
  6626. let newEndIdx = newCh.length - 1;
  6627. let newStartVnode = newCh[0];
  6628. let newEndVnode = newCh[newEndIdx];
  6629. let oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  6630. // removeOnly is a special flag used only by <transition-group>
  6631. // to ensure removed elements stay in correct relative positions
  6632. // during leaving transitions
  6633. const canMove = !removeOnly;
  6634. {
  6635. checkDuplicateKeys(newCh);
  6636. }
  6637. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  6638. if (isUndef(oldStartVnode)) {
  6639. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  6640. }
  6641. else if (isUndef(oldEndVnode)) {
  6642. oldEndVnode = oldCh[--oldEndIdx];
  6643. }
  6644. else if (sameVnode(oldStartVnode, newStartVnode)) {
  6645. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6646. oldStartVnode = oldCh[++oldStartIdx];
  6647. newStartVnode = newCh[++newStartIdx];
  6648. }
  6649. else if (sameVnode(oldEndVnode, newEndVnode)) {
  6650. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6651. oldEndVnode = oldCh[--oldEndIdx];
  6652. newEndVnode = newCh[--newEndIdx];
  6653. }
  6654. else if (sameVnode(oldStartVnode, newEndVnode)) {
  6655. // Vnode moved right
  6656. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  6657. canMove &&
  6658. nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  6659. oldStartVnode = oldCh[++oldStartIdx];
  6660. newEndVnode = newCh[--newEndIdx];
  6661. }
  6662. else if (sameVnode(oldEndVnode, newStartVnode)) {
  6663. // Vnode moved left
  6664. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6665. canMove &&
  6666. nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  6667. oldEndVnode = oldCh[--oldEndIdx];
  6668. newStartVnode = newCh[++newStartIdx];
  6669. }
  6670. else {
  6671. if (isUndef(oldKeyToIdx))
  6672. oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
  6673. idxInOld = isDef(newStartVnode.key)
  6674. ? oldKeyToIdx[newStartVnode.key]
  6675. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  6676. if (isUndef(idxInOld)) {
  6677. // New element
  6678. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6679. }
  6680. else {
  6681. vnodeToMove = oldCh[idxInOld];
  6682. if (sameVnode(vnodeToMove, newStartVnode)) {
  6683. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  6684. oldCh[idxInOld] = undefined;
  6685. canMove &&
  6686. nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  6687. }
  6688. else {
  6689. // same key but different element. treat as new element
  6690. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  6691. }
  6692. }
  6693. newStartVnode = newCh[++newStartIdx];
  6694. }
  6695. }
  6696. if (oldStartIdx > oldEndIdx) {
  6697. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  6698. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  6699. }
  6700. else if (newStartIdx > newEndIdx) {
  6701. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  6702. }
  6703. }
  6704. function checkDuplicateKeys(children) {
  6705. const seenKeys = {};
  6706. for (let i = 0; i < children.length; i++) {
  6707. const vnode = children[i];
  6708. const key = vnode.key;
  6709. if (isDef(key)) {
  6710. if (seenKeys[key]) {
  6711. warn(`Duplicate keys detected: '${key}'. This may cause an update error.`, vnode.context);
  6712. }
  6713. else {
  6714. seenKeys[key] = true;
  6715. }
  6716. }
  6717. }
  6718. }
  6719. function findIdxInOld(node, oldCh, start, end) {
  6720. for (let i = start; i < end; i++) {
  6721. const c = oldCh[i];
  6722. if (isDef(c) && sameVnode(node, c))
  6723. return i;
  6724. }
  6725. }
  6726. function patchVnode(oldVnode, vnode, insertedVnodeQueue, ownerArray, index, removeOnly) {
  6727. if (oldVnode === vnode) {
  6728. return;
  6729. }
  6730. if (isDef(vnode.elm) && isDef(ownerArray)) {
  6731. // clone reused vnode
  6732. vnode = ownerArray[index] = cloneVNode(vnode);
  6733. }
  6734. const elm = (vnode.elm = oldVnode.elm);
  6735. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  6736. if (isDef(vnode.asyncFactory.resolved)) {
  6737. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  6738. }
  6739. else {
  6740. vnode.isAsyncPlaceholder = true;
  6741. }
  6742. return;
  6743. }
  6744. // reuse element for static trees.
  6745. // note we only do this if the vnode is cloned -
  6746. // if the new node is not cloned it means the render functions have been
  6747. // reset by the hot-reload-api and we need to do a proper re-render.
  6748. if (isTrue(vnode.isStatic) &&
  6749. isTrue(oldVnode.isStatic) &&
  6750. vnode.key === oldVnode.key &&
  6751. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))) {
  6752. vnode.componentInstance = oldVnode.componentInstance;
  6753. return;
  6754. }
  6755. let i;
  6756. const data = vnode.data;
  6757. if (isDef(data) && isDef((i = data.hook)) && isDef((i = i.prepatch))) {
  6758. i(oldVnode, vnode);
  6759. }
  6760. const oldCh = oldVnode.children;
  6761. const ch = vnode.children;
  6762. if (isDef(data) && isPatchable(vnode)) {
  6763. for (i = 0; i < cbs.update.length; ++i)
  6764. cbs.update[i](oldVnode, vnode);
  6765. if (isDef((i = data.hook)) && isDef((i = i.update)))
  6766. i(oldVnode, vnode);
  6767. }
  6768. if (isUndef(vnode.text)) {
  6769. if (isDef(oldCh) && isDef(ch)) {
  6770. if (oldCh !== ch)
  6771. updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly);
  6772. }
  6773. else if (isDef(ch)) {
  6774. {
  6775. checkDuplicateKeys(ch);
  6776. }
  6777. if (isDef(oldVnode.text))
  6778. nodeOps.setTextContent(elm, '');
  6779. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  6780. }
  6781. else if (isDef(oldCh)) {
  6782. removeVnodes(oldCh, 0, oldCh.length - 1);
  6783. }
  6784. else if (isDef(oldVnode.text)) {
  6785. nodeOps.setTextContent(elm, '');
  6786. }
  6787. }
  6788. else if (oldVnode.text !== vnode.text) {
  6789. nodeOps.setTextContent(elm, vnode.text);
  6790. }
  6791. if (isDef(data)) {
  6792. if (isDef((i = data.hook)) && isDef((i = i.postpatch)))
  6793. i(oldVnode, vnode);
  6794. }
  6795. }
  6796. function invokeInsertHook(vnode, queue, initial) {
  6797. // delay insert hooks for component root nodes, invoke them after the
  6798. // element is really inserted
  6799. if (isTrue(initial) && isDef(vnode.parent)) {
  6800. vnode.parent.data.pendingInsert = queue;
  6801. }
  6802. else {
  6803. for (let i = 0; i < queue.length; ++i) {
  6804. queue[i].data.hook.insert(queue[i]);
  6805. }
  6806. }
  6807. }
  6808. let hydrationBailed = false;
  6809. // list of modules that can skip create hook during hydration because they
  6810. // are already rendered on the client or has no need for initialization
  6811. // Note: style is excluded because it relies on initial clone for future
  6812. // deep updates (#7063).
  6813. const isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  6814. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  6815. function hydrate(elm, vnode, insertedVnodeQueue, inVPre) {
  6816. let i;
  6817. const { tag, data, children } = vnode;
  6818. inVPre = inVPre || (data && data.pre);
  6819. vnode.elm = elm;
  6820. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  6821. vnode.isAsyncPlaceholder = true;
  6822. return true;
  6823. }
  6824. // assert node match
  6825. {
  6826. if (!assertNodeMatch(elm, vnode, inVPre)) {
  6827. return false;
  6828. }
  6829. }
  6830. if (isDef(data)) {
  6831. if (isDef((i = data.hook)) && isDef((i = i.init)))
  6832. i(vnode, true /* hydrating */);
  6833. if (isDef((i = vnode.componentInstance))) {
  6834. // child component. it should have hydrated its own tree.
  6835. initComponent(vnode, insertedVnodeQueue);
  6836. return true;
  6837. }
  6838. }
  6839. if (isDef(tag)) {
  6840. if (isDef(children)) {
  6841. // empty element, allow client to pick up and populate children
  6842. if (!elm.hasChildNodes()) {
  6843. createChildren(vnode, children, insertedVnodeQueue);
  6844. }
  6845. else {
  6846. // v-html and domProps: innerHTML
  6847. if (isDef((i = data)) &&
  6848. isDef((i = i.domProps)) &&
  6849. isDef((i = i.innerHTML))) {
  6850. if (i !== elm.innerHTML) {
  6851. /* istanbul ignore if */
  6852. if (typeof console !== 'undefined' &&
  6853. !hydrationBailed) {
  6854. hydrationBailed = true;
  6855. console.warn('Parent: ', elm);
  6856. console.warn('server innerHTML: ', i);
  6857. console.warn('client innerHTML: ', elm.innerHTML);
  6858. }
  6859. return false;
  6860. }
  6861. }
  6862. else {
  6863. // iterate and compare children lists
  6864. let childrenMatch = true;
  6865. let childNode = elm.firstChild;
  6866. for (let i = 0; i < children.length; i++) {
  6867. if (!childNode ||
  6868. !hydrate(childNode, children[i], insertedVnodeQueue, inVPre)) {
  6869. childrenMatch = false;
  6870. break;
  6871. }
  6872. childNode = childNode.nextSibling;
  6873. }
  6874. // if childNode is not null, it means the actual childNodes list is
  6875. // longer than the virtual children list.
  6876. if (!childrenMatch || childNode) {
  6877. /* istanbul ignore if */
  6878. if (typeof console !== 'undefined' &&
  6879. !hydrationBailed) {
  6880. hydrationBailed = true;
  6881. console.warn('Parent: ', elm);
  6882. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  6883. }
  6884. return false;
  6885. }
  6886. }
  6887. }
  6888. }
  6889. if (isDef(data)) {
  6890. let fullInvoke = false;
  6891. for (const key in data) {
  6892. if (!isRenderedModule(key)) {
  6893. fullInvoke = true;
  6894. invokeCreateHooks(vnode, insertedVnodeQueue);
  6895. break;
  6896. }
  6897. }
  6898. if (!fullInvoke && data['class']) {
  6899. // ensure collecting deps for deep class bindings for future updates
  6900. traverse(data['class']);
  6901. }
  6902. }
  6903. }
  6904. else if (elm.data !== vnode.text) {
  6905. elm.data = vnode.text;
  6906. }
  6907. return true;
  6908. }
  6909. function assertNodeMatch(node, vnode, inVPre) {
  6910. if (isDef(vnode.tag)) {
  6911. return (vnode.tag.indexOf('vue-component') === 0 ||
  6912. (!isUnknownElement(vnode, inVPre) &&
  6913. vnode.tag.toLowerCase() ===
  6914. (node.tagName && node.tagName.toLowerCase())));
  6915. }
  6916. else {
  6917. return node.nodeType === (vnode.isComment ? 8 : 3);
  6918. }
  6919. }
  6920. return function patch(oldVnode, vnode, hydrating, removeOnly) {
  6921. if (isUndef(vnode)) {
  6922. if (isDef(oldVnode))
  6923. invokeDestroyHook(oldVnode);
  6924. return;
  6925. }
  6926. let isInitialPatch = false;
  6927. const insertedVnodeQueue = [];
  6928. if (isUndef(oldVnode)) {
  6929. // empty mount (likely as component), create new root element
  6930. isInitialPatch = true;
  6931. createElm(vnode, insertedVnodeQueue);
  6932. }
  6933. else {
  6934. const isRealElement = isDef(oldVnode.nodeType);
  6935. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  6936. // patch existing root node
  6937. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  6938. }
  6939. else {
  6940. if (isRealElement) {
  6941. // mounting to a real element
  6942. // check if this is server-rendered content and if we can perform
  6943. // a successful hydration.
  6944. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  6945. oldVnode.removeAttribute(SSR_ATTR);
  6946. hydrating = true;
  6947. }
  6948. if (isTrue(hydrating)) {
  6949. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  6950. invokeInsertHook(vnode, insertedVnodeQueue, true);
  6951. return oldVnode;
  6952. }
  6953. else {
  6954. warn('The client-side rendered virtual DOM tree is not matching ' +
  6955. 'server-rendered content. This is likely caused by incorrect ' +
  6956. 'HTML markup, for example nesting block-level elements inside ' +
  6957. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  6958. 'full client-side render.');
  6959. }
  6960. }
  6961. // either not server-rendered, or hydration failed.
  6962. // create an empty node and replace it
  6963. oldVnode = emptyNodeAt(oldVnode);
  6964. }
  6965. // replacing existing element
  6966. const oldElm = oldVnode.elm;
  6967. const parentElm = nodeOps.parentNode(oldElm);
  6968. // create new node
  6969. createElm(vnode, insertedVnodeQueue,
  6970. // extremely rare edge case: do not insert if old element is in a
  6971. // leaving transition. Only happens when combining transition +
  6972. // keep-alive + HOCs. (#4590)
  6973. oldElm._leaveCb ? null : parentElm, nodeOps.nextSibling(oldElm));
  6974. // update parent placeholder node element, recursively
  6975. if (isDef(vnode.parent)) {
  6976. let ancestor = vnode.parent;
  6977. const patchable = isPatchable(vnode);
  6978. while (ancestor) {
  6979. for (let i = 0; i < cbs.destroy.length; ++i) {
  6980. cbs.destroy[i](ancestor);
  6981. }
  6982. ancestor.elm = vnode.elm;
  6983. if (patchable) {
  6984. for (let i = 0; i < cbs.create.length; ++i) {
  6985. cbs.create[i](emptyNode, ancestor);
  6986. }
  6987. // #6513
  6988. // invoke insert hooks that may have been merged by create hooks.
  6989. // e.g. for directives that uses the "inserted" hook.
  6990. const insert = ancestor.data.hook.insert;
  6991. if (insert.merged) {
  6992. // start at index 1 to avoid re-invoking component mounted hook
  6993. // clone insert hooks to avoid being mutated during iteration.
  6994. // e.g. for customed directives under transition group.
  6995. const cloned = insert.fns.slice(1);
  6996. for (let i = 0; i < cloned.length; i++) {
  6997. cloned[i]();
  6998. }
  6999. }
  7000. }
  7001. else {
  7002. registerRef(ancestor);
  7003. }
  7004. ancestor = ancestor.parent;
  7005. }
  7006. }
  7007. // destroy old node
  7008. if (isDef(parentElm)) {
  7009. removeVnodes([oldVnode], 0, 0);
  7010. }
  7011. else if (isDef(oldVnode.tag)) {
  7012. invokeDestroyHook(oldVnode);
  7013. }
  7014. }
  7015. }
  7016. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  7017. return vnode.elm;
  7018. };
  7019. }
  7020. var directives = {
  7021. create: updateDirectives,
  7022. update: updateDirectives,
  7023. destroy: function unbindDirectives(vnode) {
  7024. // @ts-expect-error emptyNode is not VNodeWithData
  7025. updateDirectives(vnode, emptyNode);
  7026. }
  7027. };
  7028. function updateDirectives(oldVnode, vnode) {
  7029. if (oldVnode.data.directives || vnode.data.directives) {
  7030. _update(oldVnode, vnode);
  7031. }
  7032. }
  7033. function _update(oldVnode, vnode) {
  7034. const isCreate = oldVnode === emptyNode;
  7035. const isDestroy = vnode === emptyNode;
  7036. const oldDirs = normalizeDirectives(oldVnode.data.directives, oldVnode.context);
  7037. const newDirs = normalizeDirectives(vnode.data.directives, vnode.context);
  7038. const dirsWithInsert = [];
  7039. const dirsWithPostpatch = [];
  7040. let key, oldDir, dir;
  7041. for (key in newDirs) {
  7042. oldDir = oldDirs[key];
  7043. dir = newDirs[key];
  7044. if (!oldDir) {
  7045. // new directive, bind
  7046. callHook(dir, 'bind', vnode, oldVnode);
  7047. if (dir.def && dir.def.inserted) {
  7048. dirsWithInsert.push(dir);
  7049. }
  7050. }
  7051. else {
  7052. // existing directive, update
  7053. dir.oldValue = oldDir.value;
  7054. dir.oldArg = oldDir.arg;
  7055. callHook(dir, 'update', vnode, oldVnode);
  7056. if (dir.def && dir.def.componentUpdated) {
  7057. dirsWithPostpatch.push(dir);
  7058. }
  7059. }
  7060. }
  7061. if (dirsWithInsert.length) {
  7062. const callInsert = () => {
  7063. for (let i = 0; i < dirsWithInsert.length; i++) {
  7064. callHook(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  7065. }
  7066. };
  7067. if (isCreate) {
  7068. mergeVNodeHook(vnode, 'insert', callInsert);
  7069. }
  7070. else {
  7071. callInsert();
  7072. }
  7073. }
  7074. if (dirsWithPostpatch.length) {
  7075. mergeVNodeHook(vnode, 'postpatch', () => {
  7076. for (let i = 0; i < dirsWithPostpatch.length; i++) {
  7077. callHook(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  7078. }
  7079. });
  7080. }
  7081. if (!isCreate) {
  7082. for (key in oldDirs) {
  7083. if (!newDirs[key]) {
  7084. // no longer present, unbind
  7085. callHook(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  7086. }
  7087. }
  7088. }
  7089. }
  7090. const emptyModifiers = Object.create(null);
  7091. function normalizeDirectives(dirs, vm) {
  7092. const res = Object.create(null);
  7093. if (!dirs) {
  7094. // $flow-disable-line
  7095. return res;
  7096. }
  7097. let i, dir;
  7098. for (i = 0; i < dirs.length; i++) {
  7099. dir = dirs[i];
  7100. if (!dir.modifiers) {
  7101. // $flow-disable-line
  7102. dir.modifiers = emptyModifiers;
  7103. }
  7104. res[getRawDirName(dir)] = dir;
  7105. if (vm._setupState && vm._setupState.__sfc) {
  7106. const setupDef = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name);
  7107. if (typeof setupDef === 'function') {
  7108. dir.def = {
  7109. bind: setupDef,
  7110. update: setupDef,
  7111. };
  7112. }
  7113. else {
  7114. dir.def = setupDef;
  7115. }
  7116. }
  7117. dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true);
  7118. }
  7119. // $flow-disable-line
  7120. return res;
  7121. }
  7122. function getRawDirName(dir) {
  7123. return (dir.rawName || `${dir.name}.${Object.keys(dir.modifiers || {}).join('.')}`);
  7124. }
  7125. function callHook(dir, hook, vnode, oldVnode, isDestroy) {
  7126. const fn = dir.def && dir.def[hook];
  7127. if (fn) {
  7128. try {
  7129. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  7130. }
  7131. catch (e) {
  7132. handleError(e, vnode.context, `directive ${dir.name} ${hook} hook`);
  7133. }
  7134. }
  7135. }
  7136. var baseModules = [ref, directives];
  7137. function updateAttrs(oldVnode, vnode) {
  7138. const opts = vnode.componentOptions;
  7139. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  7140. return;
  7141. }
  7142. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  7143. return;
  7144. }
  7145. let key, cur, old;
  7146. const elm = vnode.elm;
  7147. const oldAttrs = oldVnode.data.attrs || {};
  7148. let attrs = vnode.data.attrs || {};
  7149. // clone observed objects, as the user probably wants to mutate it
  7150. if (isDef(attrs.__ob__) || isTrue(attrs._v_attr_proxy)) {
  7151. attrs = vnode.data.attrs = extend({}, attrs);
  7152. }
  7153. for (key in attrs) {
  7154. cur = attrs[key];
  7155. old = oldAttrs[key];
  7156. if (old !== cur) {
  7157. setAttr(elm, key, cur, vnode.data.pre);
  7158. }
  7159. }
  7160. // #4391: in IE9, setting type can reset value for input[type=radio]
  7161. // #6666: IE/Edge forces progress value down to 1 before setting a max
  7162. /* istanbul ignore if */
  7163. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  7164. setAttr(elm, 'value', attrs.value);
  7165. }
  7166. for (key in oldAttrs) {
  7167. if (isUndef(attrs[key])) {
  7168. if (isXlink(key)) {
  7169. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7170. }
  7171. else if (!isEnumeratedAttr(key)) {
  7172. elm.removeAttribute(key);
  7173. }
  7174. }
  7175. }
  7176. }
  7177. function setAttr(el, key, value, isInPre) {
  7178. if (isInPre || el.tagName.indexOf('-') > -1) {
  7179. baseSetAttr(el, key, value);
  7180. }
  7181. else if (isBooleanAttr(key)) {
  7182. // set attribute for blank value
  7183. // e.g. <option disabled>Select one</option>
  7184. if (isFalsyAttrValue(value)) {
  7185. el.removeAttribute(key);
  7186. }
  7187. else {
  7188. // technically allowfullscreen is a boolean attribute for <iframe>,
  7189. // but Flash expects a value of "true" when used on <embed> tag
  7190. value = key === 'allowfullscreen' && el.tagName === 'EMBED' ? 'true' : key;
  7191. el.setAttribute(key, value);
  7192. }
  7193. }
  7194. else if (isEnumeratedAttr(key)) {
  7195. el.setAttribute(key, convertEnumeratedValue(key, value));
  7196. }
  7197. else if (isXlink(key)) {
  7198. if (isFalsyAttrValue(value)) {
  7199. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  7200. }
  7201. else {
  7202. el.setAttributeNS(xlinkNS, key, value);
  7203. }
  7204. }
  7205. else {
  7206. baseSetAttr(el, key, value);
  7207. }
  7208. }
  7209. function baseSetAttr(el, key, value) {
  7210. if (isFalsyAttrValue(value)) {
  7211. el.removeAttribute(key);
  7212. }
  7213. else {
  7214. // #7138: IE10 & 11 fires input event when setting placeholder on
  7215. // <textarea>... block the first input event and remove the blocker
  7216. // immediately.
  7217. /* istanbul ignore if */
  7218. if (isIE &&
  7219. !isIE9 &&
  7220. el.tagName === 'TEXTAREA' &&
  7221. key === 'placeholder' &&
  7222. value !== '' &&
  7223. !el.__ieph) {
  7224. const blocker = e => {
  7225. e.stopImmediatePropagation();
  7226. el.removeEventListener('input', blocker);
  7227. };
  7228. el.addEventListener('input', blocker);
  7229. // $flow-disable-line
  7230. el.__ieph = true; /* IE placeholder patched */
  7231. }
  7232. el.setAttribute(key, value);
  7233. }
  7234. }
  7235. var attrs = {
  7236. create: updateAttrs,
  7237. update: updateAttrs
  7238. };
  7239. function updateClass(oldVnode, vnode) {
  7240. const el = vnode.elm;
  7241. const data = vnode.data;
  7242. const oldData = oldVnode.data;
  7243. if (isUndef(data.staticClass) &&
  7244. isUndef(data.class) &&
  7245. (isUndef(oldData) ||
  7246. (isUndef(oldData.staticClass) && isUndef(oldData.class)))) {
  7247. return;
  7248. }
  7249. let cls = genClassForVnode(vnode);
  7250. // handle transition classes
  7251. const transitionClass = el._transitionClasses;
  7252. if (isDef(transitionClass)) {
  7253. cls = concat(cls, stringifyClass(transitionClass));
  7254. }
  7255. // set the class
  7256. if (cls !== el._prevClass) {
  7257. el.setAttribute('class', cls);
  7258. el._prevClass = cls;
  7259. }
  7260. }
  7261. var klass = {
  7262. create: updateClass,
  7263. update: updateClass
  7264. };
  7265. // in some cases, the event used has to be determined at runtime
  7266. // so we used some reserved tokens during compile.
  7267. const RANGE_TOKEN = '__r';
  7268. const CHECKBOX_RADIO_TOKEN = '__c';
  7269. // normalize v-model event tokens that can only be determined at runtime.
  7270. // it's important to place the event as the first in the array because
  7271. // the whole point is ensuring the v-model callback gets called before
  7272. // user-attached handlers.
  7273. function normalizeEvents(on) {
  7274. /* istanbul ignore if */
  7275. if (isDef(on[RANGE_TOKEN])) {
  7276. // IE input[type=range] only supports `change` event
  7277. const event = isIE ? 'change' : 'input';
  7278. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  7279. delete on[RANGE_TOKEN];
  7280. }
  7281. // This was originally intended to fix #4521 but no longer necessary
  7282. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  7283. /* istanbul ignore if */
  7284. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  7285. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  7286. delete on[CHECKBOX_RADIO_TOKEN];
  7287. }
  7288. }
  7289. let target;
  7290. function createOnceHandler(event, handler, capture) {
  7291. const _target = target; // save current target element in closure
  7292. return function onceHandler() {
  7293. const res = handler.apply(null, arguments);
  7294. if (res !== null) {
  7295. remove(event, onceHandler, capture, _target);
  7296. }
  7297. };
  7298. }
  7299. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  7300. // implementation and does not fire microtasks in between event propagation, so
  7301. // safe to exclude.
  7302. const useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  7303. function add(name, handler, capture, passive) {
  7304. // async edge case #6566: inner click event triggers patch, event handler
  7305. // attached to outer element during patch, and triggered again. This
  7306. // happens because browsers fire microtask ticks between event propagation.
  7307. // the solution is simple: we save the timestamp when a handler is attached,
  7308. // and the handler would only fire if the event passed to it was fired
  7309. // AFTER it was attached.
  7310. if (useMicrotaskFix) {
  7311. const attachedTimestamp = currentFlushTimestamp;
  7312. const original = handler;
  7313. //@ts-expect-error
  7314. handler = original._wrapper = function (e) {
  7315. if (
  7316. // no bubbling, should always fire.
  7317. // this is just a safety net in case event.timeStamp is unreliable in
  7318. // certain weird environments...
  7319. e.target === e.currentTarget ||
  7320. // event is fired after handler attachment
  7321. e.timeStamp >= attachedTimestamp ||
  7322. // bail for environments that have buggy event.timeStamp implementations
  7323. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  7324. // #9681 QtWebEngine event.timeStamp is negative value
  7325. e.timeStamp <= 0 ||
  7326. // #9448 bail if event is fired in another document in a multi-page
  7327. // electron/nw.js app, since event.timeStamp will be using a different
  7328. // starting reference
  7329. e.target.ownerDocument !== document) {
  7330. return original.apply(this, arguments);
  7331. }
  7332. };
  7333. }
  7334. target.addEventListener(name, handler, supportsPassive ? { capture, passive } : capture);
  7335. }
  7336. function remove(name, handler, capture, _target) {
  7337. (_target || target).removeEventListener(name,
  7338. //@ts-expect-error
  7339. handler._wrapper || handler, capture);
  7340. }
  7341. function updateDOMListeners(oldVnode, vnode) {
  7342. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  7343. return;
  7344. }
  7345. const on = vnode.data.on || {};
  7346. const oldOn = oldVnode.data.on || {};
  7347. // vnode is empty when removing all listeners,
  7348. // and use old vnode dom element
  7349. target = vnode.elm || oldVnode.elm;
  7350. normalizeEvents(on);
  7351. updateListeners(on, oldOn, add, remove, createOnceHandler, vnode.context);
  7352. target = undefined;
  7353. }
  7354. var events = {
  7355. create: updateDOMListeners,
  7356. update: updateDOMListeners,
  7357. // @ts-expect-error emptyNode has actually data
  7358. destroy: (vnode) => updateDOMListeners(vnode, emptyNode)
  7359. };
  7360. let svgContainer;
  7361. function updateDOMProps(oldVnode, vnode) {
  7362. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  7363. return;
  7364. }
  7365. let key, cur;
  7366. const elm = vnode.elm;
  7367. const oldProps = oldVnode.data.domProps || {};
  7368. let props = vnode.data.domProps || {};
  7369. // clone observed objects, as the user probably wants to mutate it
  7370. if (isDef(props.__ob__) || isTrue(props._v_attr_proxy)) {
  7371. props = vnode.data.domProps = extend({}, props);
  7372. }
  7373. for (key in oldProps) {
  7374. if (!(key in props)) {
  7375. elm[key] = '';
  7376. }
  7377. }
  7378. for (key in props) {
  7379. cur = props[key];
  7380. // ignore children if the node has textContent or innerHTML,
  7381. // as these will throw away existing DOM nodes and cause removal errors
  7382. // on subsequent patches (#3360)
  7383. if (key === 'textContent' || key === 'innerHTML') {
  7384. if (vnode.children)
  7385. vnode.children.length = 0;
  7386. if (cur === oldProps[key])
  7387. continue;
  7388. // #6601 work around Chrome version <= 55 bug where single textNode
  7389. // replaced by innerHTML/textContent retains its parentNode property
  7390. if (elm.childNodes.length === 1) {
  7391. elm.removeChild(elm.childNodes[0]);
  7392. }
  7393. }
  7394. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  7395. // store value as _value as well since
  7396. // non-string values will be stringified
  7397. elm._value = cur;
  7398. // avoid resetting cursor position when value is the same
  7399. const strCur = isUndef(cur) ? '' : String(cur);
  7400. if (shouldUpdateValue(elm, strCur)) {
  7401. elm.value = strCur;
  7402. }
  7403. }
  7404. else if (key === 'innerHTML' &&
  7405. isSVG(elm.tagName) &&
  7406. isUndef(elm.innerHTML)) {
  7407. // IE doesn't support innerHTML for SVG elements
  7408. svgContainer = svgContainer || document.createElement('div');
  7409. svgContainer.innerHTML = `<svg>${cur}</svg>`;
  7410. const svg = svgContainer.firstChild;
  7411. while (elm.firstChild) {
  7412. elm.removeChild(elm.firstChild);
  7413. }
  7414. while (svg.firstChild) {
  7415. elm.appendChild(svg.firstChild);
  7416. }
  7417. }
  7418. else if (
  7419. // skip the update if old and new VDOM state is the same.
  7420. // `value` is handled separately because the DOM value may be temporarily
  7421. // out of sync with VDOM state due to focus, composition and modifiers.
  7422. // This #4521 by skipping the unnecessary `checked` update.
  7423. cur !== oldProps[key]) {
  7424. // some property updates can throw
  7425. // e.g. `value` on <progress> w/ non-finite value
  7426. try {
  7427. elm[key] = cur;
  7428. }
  7429. catch (e) { }
  7430. }
  7431. }
  7432. }
  7433. function shouldUpdateValue(elm, checkVal) {
  7434. return (
  7435. //@ts-expect-error
  7436. !elm.composing &&
  7437. (elm.tagName === 'OPTION' ||
  7438. isNotInFocusAndDirty(elm, checkVal) ||
  7439. isDirtyWithModifiers(elm, checkVal)));
  7440. }
  7441. function isNotInFocusAndDirty(elm, checkVal) {
  7442. // return true when textbox (.number and .trim) loses focus and its value is
  7443. // not equal to the updated value
  7444. let notInFocus = true;
  7445. // #6157
  7446. // work around IE bug when accessing document.activeElement in an iframe
  7447. try {
  7448. notInFocus = document.activeElement !== elm;
  7449. }
  7450. catch (e) { }
  7451. return notInFocus && elm.value !== checkVal;
  7452. }
  7453. function isDirtyWithModifiers(elm, newVal) {
  7454. const value = elm.value;
  7455. const modifiers = elm._vModifiers; // injected by v-model runtime
  7456. if (isDef(modifiers)) {
  7457. if (modifiers.number) {
  7458. return toNumber(value) !== toNumber(newVal);
  7459. }
  7460. if (modifiers.trim) {
  7461. return value.trim() !== newVal.trim();
  7462. }
  7463. }
  7464. return value !== newVal;
  7465. }
  7466. var domProps = {
  7467. create: updateDOMProps,
  7468. update: updateDOMProps
  7469. };
  7470. const parseStyleText = cached(function (cssText) {
  7471. const res = {};
  7472. const listDelimiter = /;(?![^(]*\))/g;
  7473. const propertyDelimiter = /:(.+)/;
  7474. cssText.split(listDelimiter).forEach(function (item) {
  7475. if (item) {
  7476. const tmp = item.split(propertyDelimiter);
  7477. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  7478. }
  7479. });
  7480. return res;
  7481. });
  7482. // merge static and dynamic style data on the same vnode
  7483. function normalizeStyleData(data) {
  7484. const style = normalizeStyleBinding(data.style);
  7485. // static style is pre-processed into an object during compilation
  7486. // and is always a fresh object, so it's safe to merge into it
  7487. return data.staticStyle ? extend(data.staticStyle, style) : style;
  7488. }
  7489. // normalize possible array / string values into Object
  7490. function normalizeStyleBinding(bindingStyle) {
  7491. if (Array.isArray(bindingStyle)) {
  7492. return toObject(bindingStyle);
  7493. }
  7494. if (typeof bindingStyle === 'string') {
  7495. return parseStyleText(bindingStyle);
  7496. }
  7497. return bindingStyle;
  7498. }
  7499. /**
  7500. * parent component style should be after child's
  7501. * so that parent component's style could override it
  7502. */
  7503. function getStyle(vnode, checkChild) {
  7504. const res = {};
  7505. let styleData;
  7506. if (checkChild) {
  7507. let childNode = vnode;
  7508. while (childNode.componentInstance) {
  7509. childNode = childNode.componentInstance._vnode;
  7510. if (childNode &&
  7511. childNode.data &&
  7512. (styleData = normalizeStyleData(childNode.data))) {
  7513. extend(res, styleData);
  7514. }
  7515. }
  7516. }
  7517. if ((styleData = normalizeStyleData(vnode.data))) {
  7518. extend(res, styleData);
  7519. }
  7520. let parentNode = vnode;
  7521. // @ts-expect-error parentNode.parent not VNodeWithData
  7522. while ((parentNode = parentNode.parent)) {
  7523. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  7524. extend(res, styleData);
  7525. }
  7526. }
  7527. return res;
  7528. }
  7529. const cssVarRE = /^--/;
  7530. const importantRE = /\s*!important$/;
  7531. const setProp = (el, name, val) => {
  7532. /* istanbul ignore if */
  7533. if (cssVarRE.test(name)) {
  7534. el.style.setProperty(name, val);
  7535. }
  7536. else if (importantRE.test(val)) {
  7537. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  7538. }
  7539. else {
  7540. const normalizedName = normalize(name);
  7541. if (Array.isArray(val)) {
  7542. // Support values array created by autoprefixer, e.g.
  7543. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  7544. // Set them one by one, and the browser will only set those it can recognize
  7545. for (let i = 0, len = val.length; i < len; i++) {
  7546. el.style[normalizedName] = val[i];
  7547. }
  7548. }
  7549. else {
  7550. el.style[normalizedName] = val;
  7551. }
  7552. }
  7553. };
  7554. const vendorNames = ['Webkit', 'Moz', 'ms'];
  7555. let emptyStyle;
  7556. const normalize = cached(function (prop) {
  7557. emptyStyle = emptyStyle || document.createElement('div').style;
  7558. prop = camelize(prop);
  7559. if (prop !== 'filter' && prop in emptyStyle) {
  7560. return prop;
  7561. }
  7562. const capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  7563. for (let i = 0; i < vendorNames.length; i++) {
  7564. const name = vendorNames[i] + capName;
  7565. if (name in emptyStyle) {
  7566. return name;
  7567. }
  7568. }
  7569. });
  7570. function updateStyle(oldVnode, vnode) {
  7571. const data = vnode.data;
  7572. const oldData = oldVnode.data;
  7573. if (isUndef(data.staticStyle) &&
  7574. isUndef(data.style) &&
  7575. isUndef(oldData.staticStyle) &&
  7576. isUndef(oldData.style)) {
  7577. return;
  7578. }
  7579. let cur, name;
  7580. const el = vnode.elm;
  7581. const oldStaticStyle = oldData.staticStyle;
  7582. const oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  7583. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  7584. const oldStyle = oldStaticStyle || oldStyleBinding;
  7585. const style = normalizeStyleBinding(vnode.data.style) || {};
  7586. // store normalized style under a different key for next diff
  7587. // make sure to clone it if it's reactive, since the user likely wants
  7588. // to mutate it.
  7589. vnode.data.normalizedStyle = isDef(style.__ob__) ? extend({}, style) : style;
  7590. const newStyle = getStyle(vnode, true);
  7591. for (name in oldStyle) {
  7592. if (isUndef(newStyle[name])) {
  7593. setProp(el, name, '');
  7594. }
  7595. }
  7596. for (name in newStyle) {
  7597. cur = newStyle[name];
  7598. // ie9 setting to null has no effect, must use empty string
  7599. setProp(el, name, cur == null ? '' : cur);
  7600. }
  7601. }
  7602. var style = {
  7603. create: updateStyle,
  7604. update: updateStyle
  7605. };
  7606. const whitespaceRE = /\s+/;
  7607. /**
  7608. * Add class with compatibility for SVG since classList is not supported on
  7609. * SVG elements in IE
  7610. */
  7611. function addClass(el, cls) {
  7612. /* istanbul ignore if */
  7613. if (!cls || !(cls = cls.trim())) {
  7614. return;
  7615. }
  7616. /* istanbul ignore else */
  7617. if (el.classList) {
  7618. if (cls.indexOf(' ') > -1) {
  7619. cls.split(whitespaceRE).forEach(c => el.classList.add(c));
  7620. }
  7621. else {
  7622. el.classList.add(cls);
  7623. }
  7624. }
  7625. else {
  7626. const cur = ` ${el.getAttribute('class') || ''} `;
  7627. if (cur.indexOf(' ' + cls + ' ') < 0) {
  7628. el.setAttribute('class', (cur + cls).trim());
  7629. }
  7630. }
  7631. }
  7632. /**
  7633. * Remove class with compatibility for SVG since classList is not supported on
  7634. * SVG elements in IE
  7635. */
  7636. function removeClass(el, cls) {
  7637. /* istanbul ignore if */
  7638. if (!cls || !(cls = cls.trim())) {
  7639. return;
  7640. }
  7641. /* istanbul ignore else */
  7642. if (el.classList) {
  7643. if (cls.indexOf(' ') > -1) {
  7644. cls.split(whitespaceRE).forEach(c => el.classList.remove(c));
  7645. }
  7646. else {
  7647. el.classList.remove(cls);
  7648. }
  7649. if (!el.classList.length) {
  7650. el.removeAttribute('class');
  7651. }
  7652. }
  7653. else {
  7654. let cur = ` ${el.getAttribute('class') || ''} `;
  7655. const tar = ' ' + cls + ' ';
  7656. while (cur.indexOf(tar) >= 0) {
  7657. cur = cur.replace(tar, ' ');
  7658. }
  7659. cur = cur.trim();
  7660. if (cur) {
  7661. el.setAttribute('class', cur);
  7662. }
  7663. else {
  7664. el.removeAttribute('class');
  7665. }
  7666. }
  7667. }
  7668. function resolveTransition(def) {
  7669. if (!def) {
  7670. return;
  7671. }
  7672. /* istanbul ignore else */
  7673. if (typeof def === 'object') {
  7674. const res = {};
  7675. if (def.css !== false) {
  7676. extend(res, autoCssTransition(def.name || 'v'));
  7677. }
  7678. extend(res, def);
  7679. return res;
  7680. }
  7681. else if (typeof def === 'string') {
  7682. return autoCssTransition(def);
  7683. }
  7684. }
  7685. const autoCssTransition = cached(name => {
  7686. return {
  7687. enterClass: `${name}-enter`,
  7688. enterToClass: `${name}-enter-to`,
  7689. enterActiveClass: `${name}-enter-active`,
  7690. leaveClass: `${name}-leave`,
  7691. leaveToClass: `${name}-leave-to`,
  7692. leaveActiveClass: `${name}-leave-active`
  7693. };
  7694. });
  7695. const hasTransition = inBrowser && !isIE9;
  7696. const TRANSITION = 'transition';
  7697. const ANIMATION = 'animation';
  7698. // Transition property/event sniffing
  7699. let transitionProp = 'transition';
  7700. let transitionEndEvent = 'transitionend';
  7701. let animationProp = 'animation';
  7702. let animationEndEvent = 'animationend';
  7703. if (hasTransition) {
  7704. /* istanbul ignore if */
  7705. if (window.ontransitionend === undefined &&
  7706. window.onwebkittransitionend !== undefined) {
  7707. transitionProp = 'WebkitTransition';
  7708. transitionEndEvent = 'webkitTransitionEnd';
  7709. }
  7710. if (window.onanimationend === undefined &&
  7711. window.onwebkitanimationend !== undefined) {
  7712. animationProp = 'WebkitAnimation';
  7713. animationEndEvent = 'webkitAnimationEnd';
  7714. }
  7715. }
  7716. // binding to window is necessary to make hot reload work in IE in strict mode
  7717. const raf = inBrowser
  7718. ? window.requestAnimationFrame
  7719. ? window.requestAnimationFrame.bind(window)
  7720. : setTimeout
  7721. : /* istanbul ignore next */ /* istanbul ignore next */ fn => fn();
  7722. function nextFrame(fn) {
  7723. raf(() => {
  7724. // @ts-expect-error
  7725. raf(fn);
  7726. });
  7727. }
  7728. function addTransitionClass(el, cls) {
  7729. const transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  7730. if (transitionClasses.indexOf(cls) < 0) {
  7731. transitionClasses.push(cls);
  7732. addClass(el, cls);
  7733. }
  7734. }
  7735. function removeTransitionClass(el, cls) {
  7736. if (el._transitionClasses) {
  7737. remove$2(el._transitionClasses, cls);
  7738. }
  7739. removeClass(el, cls);
  7740. }
  7741. function whenTransitionEnds(el, expectedType, cb) {
  7742. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  7743. if (!type)
  7744. return cb();
  7745. const event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  7746. let ended = 0;
  7747. const end = () => {
  7748. el.removeEventListener(event, onEnd);
  7749. cb();
  7750. };
  7751. const onEnd = e => {
  7752. if (e.target === el) {
  7753. if (++ended >= propCount) {
  7754. end();
  7755. }
  7756. }
  7757. };
  7758. setTimeout(() => {
  7759. if (ended < propCount) {
  7760. end();
  7761. }
  7762. }, timeout + 1);
  7763. el.addEventListener(event, onEnd);
  7764. }
  7765. const transformRE = /\b(transform|all)(,|$)/;
  7766. function getTransitionInfo(el, expectedType) {
  7767. const styles = window.getComputedStyle(el);
  7768. // JSDOM may return undefined for transition properties
  7769. const transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  7770. const transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  7771. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  7772. const animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  7773. const animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  7774. const animationTimeout = getTimeout(animationDelays, animationDurations);
  7775. let type;
  7776. let timeout = 0;
  7777. let propCount = 0;
  7778. /* istanbul ignore if */
  7779. if (expectedType === TRANSITION) {
  7780. if (transitionTimeout > 0) {
  7781. type = TRANSITION;
  7782. timeout = transitionTimeout;
  7783. propCount = transitionDurations.length;
  7784. }
  7785. }
  7786. else if (expectedType === ANIMATION) {
  7787. if (animationTimeout > 0) {
  7788. type = ANIMATION;
  7789. timeout = animationTimeout;
  7790. propCount = animationDurations.length;
  7791. }
  7792. }
  7793. else {
  7794. timeout = Math.max(transitionTimeout, animationTimeout);
  7795. type =
  7796. timeout > 0
  7797. ? transitionTimeout > animationTimeout
  7798. ? TRANSITION
  7799. : ANIMATION
  7800. : null;
  7801. propCount = type
  7802. ? type === TRANSITION
  7803. ? transitionDurations.length
  7804. : animationDurations.length
  7805. : 0;
  7806. }
  7807. const hasTransform = type === TRANSITION && transformRE.test(styles[transitionProp + 'Property']);
  7808. return {
  7809. type,
  7810. timeout,
  7811. propCount,
  7812. hasTransform
  7813. };
  7814. }
  7815. function getTimeout(delays, durations) {
  7816. /* istanbul ignore next */
  7817. while (delays.length < durations.length) {
  7818. delays = delays.concat(delays);
  7819. }
  7820. return Math.max.apply(null, durations.map((d, i) => {
  7821. return toMs(d) + toMs(delays[i]);
  7822. }));
  7823. }
  7824. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  7825. // in a locale-dependent way, using a comma instead of a dot.
  7826. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  7827. // as a floor function) causing unexpected behaviors
  7828. function toMs(s) {
  7829. return Number(s.slice(0, -1).replace(',', '.')) * 1000;
  7830. }
  7831. function enter(vnode, toggleDisplay) {
  7832. const el = vnode.elm;
  7833. // call leave callback now
  7834. if (isDef(el._leaveCb)) {
  7835. el._leaveCb.cancelled = true;
  7836. el._leaveCb();
  7837. }
  7838. const data = resolveTransition(vnode.data.transition);
  7839. if (isUndef(data)) {
  7840. return;
  7841. }
  7842. /* istanbul ignore if */
  7843. if (isDef(el._enterCb) || el.nodeType !== 1) {
  7844. return;
  7845. }
  7846. const { css, type, enterClass, enterToClass, enterActiveClass, appearClass, appearToClass, appearActiveClass, beforeEnter, enter, afterEnter, enterCancelled, beforeAppear, appear, afterAppear, appearCancelled, duration } = data;
  7847. // activeInstance will always be the <transition> component managing this
  7848. // transition. One edge case to check is when the <transition> is placed
  7849. // as the root node of a child component. In that case we need to check
  7850. // <transition>'s parent for appear check.
  7851. let context = activeInstance;
  7852. let transitionNode = activeInstance.$vnode;
  7853. while (transitionNode && transitionNode.parent) {
  7854. context = transitionNode.context;
  7855. transitionNode = transitionNode.parent;
  7856. }
  7857. const isAppear = !context._isMounted || !vnode.isRootInsert;
  7858. if (isAppear && !appear && appear !== '') {
  7859. return;
  7860. }
  7861. const startClass = isAppear && appearClass ? appearClass : enterClass;
  7862. const activeClass = isAppear && appearActiveClass ? appearActiveClass : enterActiveClass;
  7863. const toClass = isAppear && appearToClass ? appearToClass : enterToClass;
  7864. const beforeEnterHook = isAppear ? beforeAppear || beforeEnter : beforeEnter;
  7865. const enterHook = isAppear ? (isFunction(appear) ? appear : enter) : enter;
  7866. const afterEnterHook = isAppear ? afterAppear || afterEnter : afterEnter;
  7867. const enterCancelledHook = isAppear
  7868. ? appearCancelled || enterCancelled
  7869. : enterCancelled;
  7870. const explicitEnterDuration = toNumber(isObject(duration) ? duration.enter : duration);
  7871. if (explicitEnterDuration != null) {
  7872. checkDuration(explicitEnterDuration, 'enter', vnode);
  7873. }
  7874. const expectsCSS = css !== false && !isIE9;
  7875. const userWantsControl = getHookArgumentsLength(enterHook);
  7876. const cb = (el._enterCb = once(() => {
  7877. if (expectsCSS) {
  7878. removeTransitionClass(el, toClass);
  7879. removeTransitionClass(el, activeClass);
  7880. }
  7881. // @ts-expect-error
  7882. if (cb.cancelled) {
  7883. if (expectsCSS) {
  7884. removeTransitionClass(el, startClass);
  7885. }
  7886. enterCancelledHook && enterCancelledHook(el);
  7887. }
  7888. else {
  7889. afterEnterHook && afterEnterHook(el);
  7890. }
  7891. el._enterCb = null;
  7892. }));
  7893. if (!vnode.data.show) {
  7894. // remove pending leave element on enter by injecting an insert hook
  7895. mergeVNodeHook(vnode, 'insert', () => {
  7896. const parent = el.parentNode;
  7897. const pendingNode = parent && parent._pending && parent._pending[vnode.key];
  7898. if (pendingNode &&
  7899. pendingNode.tag === vnode.tag &&
  7900. pendingNode.elm._leaveCb) {
  7901. pendingNode.elm._leaveCb();
  7902. }
  7903. enterHook && enterHook(el, cb);
  7904. });
  7905. }
  7906. // start enter transition
  7907. beforeEnterHook && beforeEnterHook(el);
  7908. if (expectsCSS) {
  7909. addTransitionClass(el, startClass);
  7910. addTransitionClass(el, activeClass);
  7911. nextFrame(() => {
  7912. removeTransitionClass(el, startClass);
  7913. // @ts-expect-error
  7914. if (!cb.cancelled) {
  7915. addTransitionClass(el, toClass);
  7916. if (!userWantsControl) {
  7917. if (isValidDuration(explicitEnterDuration)) {
  7918. setTimeout(cb, explicitEnterDuration);
  7919. }
  7920. else {
  7921. whenTransitionEnds(el, type, cb);
  7922. }
  7923. }
  7924. }
  7925. });
  7926. }
  7927. if (vnode.data.show) {
  7928. toggleDisplay && toggleDisplay();
  7929. enterHook && enterHook(el, cb);
  7930. }
  7931. if (!expectsCSS && !userWantsControl) {
  7932. cb();
  7933. }
  7934. }
  7935. function leave(vnode, rm) {
  7936. const el = vnode.elm;
  7937. // call enter callback now
  7938. if (isDef(el._enterCb)) {
  7939. el._enterCb.cancelled = true;
  7940. el._enterCb();
  7941. }
  7942. const data = resolveTransition(vnode.data.transition);
  7943. if (isUndef(data) || el.nodeType !== 1) {
  7944. return rm();
  7945. }
  7946. /* istanbul ignore if */
  7947. if (isDef(el._leaveCb)) {
  7948. return;
  7949. }
  7950. const { css, type, leaveClass, leaveToClass, leaveActiveClass, beforeLeave, leave, afterLeave, leaveCancelled, delayLeave, duration } = data;
  7951. const expectsCSS = css !== false && !isIE9;
  7952. const userWantsControl = getHookArgumentsLength(leave);
  7953. const explicitLeaveDuration = toNumber(isObject(duration) ? duration.leave : duration);
  7954. if (isDef(explicitLeaveDuration)) {
  7955. checkDuration(explicitLeaveDuration, 'leave', vnode);
  7956. }
  7957. const cb = (el._leaveCb = once(() => {
  7958. if (el.parentNode && el.parentNode._pending) {
  7959. el.parentNode._pending[vnode.key] = null;
  7960. }
  7961. if (expectsCSS) {
  7962. removeTransitionClass(el, leaveToClass);
  7963. removeTransitionClass(el, leaveActiveClass);
  7964. }
  7965. // @ts-expect-error
  7966. if (cb.cancelled) {
  7967. if (expectsCSS) {
  7968. removeTransitionClass(el, leaveClass);
  7969. }
  7970. leaveCancelled && leaveCancelled(el);
  7971. }
  7972. else {
  7973. rm();
  7974. afterLeave && afterLeave(el);
  7975. }
  7976. el._leaveCb = null;
  7977. }));
  7978. if (delayLeave) {
  7979. delayLeave(performLeave);
  7980. }
  7981. else {
  7982. performLeave();
  7983. }
  7984. function performLeave() {
  7985. // the delayed leave may have already been cancelled
  7986. // @ts-expect-error
  7987. if (cb.cancelled) {
  7988. return;
  7989. }
  7990. // record leaving element
  7991. if (!vnode.data.show && el.parentNode) {
  7992. (el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] =
  7993. vnode;
  7994. }
  7995. beforeLeave && beforeLeave(el);
  7996. if (expectsCSS) {
  7997. addTransitionClass(el, leaveClass);
  7998. addTransitionClass(el, leaveActiveClass);
  7999. nextFrame(() => {
  8000. removeTransitionClass(el, leaveClass);
  8001. // @ts-expect-error
  8002. if (!cb.cancelled) {
  8003. addTransitionClass(el, leaveToClass);
  8004. if (!userWantsControl) {
  8005. if (isValidDuration(explicitLeaveDuration)) {
  8006. setTimeout(cb, explicitLeaveDuration);
  8007. }
  8008. else {
  8009. whenTransitionEnds(el, type, cb);
  8010. }
  8011. }
  8012. }
  8013. });
  8014. }
  8015. leave && leave(el, cb);
  8016. if (!expectsCSS && !userWantsControl) {
  8017. cb();
  8018. }
  8019. }
  8020. }
  8021. // only used in dev mode
  8022. function checkDuration(val, name, vnode) {
  8023. if (typeof val !== 'number') {
  8024. warn(`<transition> explicit ${name} duration is not a valid number - ` +
  8025. `got ${JSON.stringify(val)}.`, vnode.context);
  8026. }
  8027. else if (isNaN(val)) {
  8028. warn(`<transition> explicit ${name} duration is NaN - ` +
  8029. 'the duration expression might be incorrect.', vnode.context);
  8030. }
  8031. }
  8032. function isValidDuration(val) {
  8033. return typeof val === 'number' && !isNaN(val);
  8034. }
  8035. /**
  8036. * Normalize a transition hook's argument length. The hook may be:
  8037. * - a merged hook (invoker) with the original in .fns
  8038. * - a wrapped component method (check ._length)
  8039. * - a plain function (.length)
  8040. */
  8041. function getHookArgumentsLength(fn) {
  8042. if (isUndef(fn)) {
  8043. return false;
  8044. }
  8045. // @ts-expect-error
  8046. const invokerFns = fn.fns;
  8047. if (isDef(invokerFns)) {
  8048. // invoker
  8049. return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);
  8050. }
  8051. else {
  8052. // @ts-expect-error
  8053. return (fn._length || fn.length) > 1;
  8054. }
  8055. }
  8056. function _enter(_, vnode) {
  8057. if (vnode.data.show !== true) {
  8058. enter(vnode);
  8059. }
  8060. }
  8061. var transition = inBrowser
  8062. ? {
  8063. create: _enter,
  8064. activate: _enter,
  8065. remove(vnode, rm) {
  8066. /* istanbul ignore else */
  8067. if (vnode.data.show !== true) {
  8068. // @ts-expect-error
  8069. leave(vnode, rm);
  8070. }
  8071. else {
  8072. rm();
  8073. }
  8074. }
  8075. }
  8076. : {};
  8077. var platformModules = [attrs, klass, events, domProps, style, transition];
  8078. // the directive module should be applied last, after all
  8079. // built-in modules have been applied.
  8080. const modules = platformModules.concat(baseModules);
  8081. const patch = createPatchFunction({ nodeOps, modules });
  8082. /**
  8083. * Not type checking this file because flow doesn't like attaching
  8084. * properties to Elements.
  8085. */
  8086. /* istanbul ignore if */
  8087. if (isIE9) {
  8088. // http://www.matts411.com/post/internet-explorer-9-oninput/
  8089. document.addEventListener('selectionchange', () => {
  8090. const el = document.activeElement;
  8091. // @ts-expect-error
  8092. if (el && el.vmodel) {
  8093. trigger(el, 'input');
  8094. }
  8095. });
  8096. }
  8097. const directive = {
  8098. inserted(el, binding, vnode, oldVnode) {
  8099. if (vnode.tag === 'select') {
  8100. // #6903
  8101. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  8102. mergeVNodeHook(vnode, 'postpatch', () => {
  8103. directive.componentUpdated(el, binding, vnode);
  8104. });
  8105. }
  8106. else {
  8107. setSelected(el, binding, vnode.context);
  8108. }
  8109. el._vOptions = [].map.call(el.options, getValue);
  8110. }
  8111. else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  8112. el._vModifiers = binding.modifiers;
  8113. if (!binding.modifiers.lazy) {
  8114. el.addEventListener('compositionstart', onCompositionStart);
  8115. el.addEventListener('compositionend', onCompositionEnd);
  8116. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  8117. // switching focus before confirming composition choice
  8118. // this also fixes the issue where some browsers e.g. iOS Chrome
  8119. // fires "change" instead of "input" on autocomplete.
  8120. el.addEventListener('change', onCompositionEnd);
  8121. /* istanbul ignore if */
  8122. if (isIE9) {
  8123. el.vmodel = true;
  8124. }
  8125. }
  8126. }
  8127. },
  8128. componentUpdated(el, binding, vnode) {
  8129. if (vnode.tag === 'select') {
  8130. setSelected(el, binding, vnode.context);
  8131. // in case the options rendered by v-for have changed,
  8132. // it's possible that the value is out-of-sync with the rendered options.
  8133. // detect such cases and filter out values that no longer has a matching
  8134. // option in the DOM.
  8135. const prevOptions = el._vOptions;
  8136. const curOptions = (el._vOptions = [].map.call(el.options, getValue));
  8137. if (curOptions.some((o, i) => !looseEqual(o, prevOptions[i]))) {
  8138. // trigger change event if
  8139. // no matching option found for at least one value
  8140. const needReset = el.multiple
  8141. ? binding.value.some(v => hasNoMatchingOption(v, curOptions))
  8142. : binding.value !== binding.oldValue &&
  8143. hasNoMatchingOption(binding.value, curOptions);
  8144. if (needReset) {
  8145. trigger(el, 'change');
  8146. }
  8147. }
  8148. }
  8149. }
  8150. };
  8151. function setSelected(el, binding, vm) {
  8152. actuallySetSelected(el, binding, vm);
  8153. /* istanbul ignore if */
  8154. if (isIE || isEdge) {
  8155. setTimeout(() => {
  8156. actuallySetSelected(el, binding, vm);
  8157. }, 0);
  8158. }
  8159. }
  8160. function actuallySetSelected(el, binding, vm) {
  8161. const value = binding.value;
  8162. const isMultiple = el.multiple;
  8163. if (isMultiple && !Array.isArray(value)) {
  8164. warn(`<select multiple v-model="${binding.expression}"> ` +
  8165. `expects an Array value for its binding, but got ${Object.prototype.toString
  8166. .call(value)
  8167. .slice(8, -1)}`, vm);
  8168. return;
  8169. }
  8170. let selected, option;
  8171. for (let i = 0, l = el.options.length; i < l; i++) {
  8172. option = el.options[i];
  8173. if (isMultiple) {
  8174. selected = looseIndexOf(value, getValue(option)) > -1;
  8175. if (option.selected !== selected) {
  8176. option.selected = selected;
  8177. }
  8178. }
  8179. else {
  8180. if (looseEqual(getValue(option), value)) {
  8181. if (el.selectedIndex !== i) {
  8182. el.selectedIndex = i;
  8183. }
  8184. return;
  8185. }
  8186. }
  8187. }
  8188. if (!isMultiple) {
  8189. el.selectedIndex = -1;
  8190. }
  8191. }
  8192. function hasNoMatchingOption(value, options) {
  8193. return options.every(o => !looseEqual(o, value));
  8194. }
  8195. function getValue(option) {
  8196. return '_value' in option ? option._value : option.value;
  8197. }
  8198. function onCompositionStart(e) {
  8199. e.target.composing = true;
  8200. }
  8201. function onCompositionEnd(e) {
  8202. // prevent triggering an input event for no reason
  8203. if (!e.target.composing)
  8204. return;
  8205. e.target.composing = false;
  8206. trigger(e.target, 'input');
  8207. }
  8208. function trigger(el, type) {
  8209. const e = document.createEvent('HTMLEvents');
  8210. e.initEvent(type, true, true);
  8211. el.dispatchEvent(e);
  8212. }
  8213. // recursively search for possible transition defined inside the component root
  8214. function locateNode(vnode) {
  8215. // @ts-expect-error
  8216. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  8217. ? locateNode(vnode.componentInstance._vnode)
  8218. : vnode;
  8219. }
  8220. var show = {
  8221. bind(el, { value }, vnode) {
  8222. vnode = locateNode(vnode);
  8223. const transition = vnode.data && vnode.data.transition;
  8224. const originalDisplay = (el.__vOriginalDisplay =
  8225. el.style.display === 'none' ? '' : el.style.display);
  8226. if (value && transition) {
  8227. vnode.data.show = true;
  8228. enter(vnode, () => {
  8229. el.style.display = originalDisplay;
  8230. });
  8231. }
  8232. else {
  8233. el.style.display = value ? originalDisplay : 'none';
  8234. }
  8235. },
  8236. update(el, { value, oldValue }, vnode) {
  8237. /* istanbul ignore if */
  8238. if (!value === !oldValue)
  8239. return;
  8240. vnode = locateNode(vnode);
  8241. const transition = vnode.data && vnode.data.transition;
  8242. if (transition) {
  8243. vnode.data.show = true;
  8244. if (value) {
  8245. enter(vnode, () => {
  8246. el.style.display = el.__vOriginalDisplay;
  8247. });
  8248. }
  8249. else {
  8250. leave(vnode, () => {
  8251. el.style.display = 'none';
  8252. });
  8253. }
  8254. }
  8255. else {
  8256. el.style.display = value ? el.__vOriginalDisplay : 'none';
  8257. }
  8258. },
  8259. unbind(el, binding, vnode, oldVnode, isDestroy) {
  8260. if (!isDestroy) {
  8261. el.style.display = el.__vOriginalDisplay;
  8262. }
  8263. }
  8264. };
  8265. var platformDirectives = {
  8266. model: directive,
  8267. show
  8268. };
  8269. // Provides transition support for a single element/component.
  8270. const transitionProps = {
  8271. name: String,
  8272. appear: Boolean,
  8273. css: Boolean,
  8274. mode: String,
  8275. type: String,
  8276. enterClass: String,
  8277. leaveClass: String,
  8278. enterToClass: String,
  8279. leaveToClass: String,
  8280. enterActiveClass: String,
  8281. leaveActiveClass: String,
  8282. appearClass: String,
  8283. appearActiveClass: String,
  8284. appearToClass: String,
  8285. duration: [Number, String, Object]
  8286. };
  8287. // in case the child is also an abstract component, e.g. <keep-alive>
  8288. // we want to recursively retrieve the real component to be rendered
  8289. function getRealChild(vnode) {
  8290. const compOptions = vnode && vnode.componentOptions;
  8291. if (compOptions && compOptions.Ctor.options.abstract) {
  8292. return getRealChild(getFirstComponentChild(compOptions.children));
  8293. }
  8294. else {
  8295. return vnode;
  8296. }
  8297. }
  8298. function extractTransitionData(comp) {
  8299. const data = {};
  8300. const options = comp.$options;
  8301. // props
  8302. for (const key in options.propsData) {
  8303. data[key] = comp[key];
  8304. }
  8305. // events.
  8306. // extract listeners and pass them directly to the transition methods
  8307. const listeners = options._parentListeners;
  8308. for (const key in listeners) {
  8309. data[camelize(key)] = listeners[key];
  8310. }
  8311. return data;
  8312. }
  8313. function placeholder(h, rawChild) {
  8314. // @ts-expect-error
  8315. if (/\d-keep-alive$/.test(rawChild.tag)) {
  8316. return h('keep-alive', {
  8317. props: rawChild.componentOptions.propsData
  8318. });
  8319. }
  8320. }
  8321. function hasParentTransition(vnode) {
  8322. while ((vnode = vnode.parent)) {
  8323. if (vnode.data.transition) {
  8324. return true;
  8325. }
  8326. }
  8327. }
  8328. function isSameChild(child, oldChild) {
  8329. return oldChild.key === child.key && oldChild.tag === child.tag;
  8330. }
  8331. const isNotTextNode = (c) => c.tag || isAsyncPlaceholder(c);
  8332. const isVShowDirective = d => d.name === 'show';
  8333. var Transition = {
  8334. name: 'transition',
  8335. props: transitionProps,
  8336. abstract: true,
  8337. render(h) {
  8338. let children = this.$slots.default;
  8339. if (!children) {
  8340. return;
  8341. }
  8342. // filter out text nodes (possible whitespaces)
  8343. children = children.filter(isNotTextNode);
  8344. /* istanbul ignore if */
  8345. if (!children.length) {
  8346. return;
  8347. }
  8348. // warn multiple elements
  8349. if (children.length > 1) {
  8350. warn('<transition> can only be used on a single element. Use ' +
  8351. '<transition-group> for lists.', this.$parent);
  8352. }
  8353. const mode = this.mode;
  8354. // warn invalid mode
  8355. if (mode && mode !== 'in-out' && mode !== 'out-in') {
  8356. warn('invalid <transition> mode: ' + mode, this.$parent);
  8357. }
  8358. const rawChild = children[0];
  8359. // if this is a component root node and the component's
  8360. // parent container node also has transition, skip.
  8361. if (hasParentTransition(this.$vnode)) {
  8362. return rawChild;
  8363. }
  8364. // apply transition data to child
  8365. // use getRealChild() to ignore abstract components e.g. keep-alive
  8366. const child = getRealChild(rawChild);
  8367. /* istanbul ignore if */
  8368. if (!child) {
  8369. return rawChild;
  8370. }
  8371. if (this._leaving) {
  8372. return placeholder(h, rawChild);
  8373. }
  8374. // ensure a key that is unique to the vnode type and to this transition
  8375. // component instance. This key will be used to remove pending leaving nodes
  8376. // during entering.
  8377. const id = `__transition-${this._uid}-`;
  8378. child.key =
  8379. child.key == null
  8380. ? child.isComment
  8381. ? id + 'comment'
  8382. : id + child.tag
  8383. : isPrimitive(child.key)
  8384. ? String(child.key).indexOf(id) === 0
  8385. ? child.key
  8386. : id + child.key
  8387. : child.key;
  8388. const data = ((child.data || (child.data = {})).transition =
  8389. extractTransitionData(this));
  8390. const oldRawChild = this._vnode;
  8391. const oldChild = getRealChild(oldRawChild);
  8392. // mark v-show
  8393. // so that the transition module can hand over the control to the directive
  8394. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  8395. child.data.show = true;
  8396. }
  8397. if (oldChild &&
  8398. oldChild.data &&
  8399. !isSameChild(child, oldChild) &&
  8400. !isAsyncPlaceholder(oldChild) &&
  8401. // #6687 component root is a comment node
  8402. !(oldChild.componentInstance &&
  8403. oldChild.componentInstance._vnode.isComment)) {
  8404. // replace old child transition data with fresh one
  8405. // important for dynamic transitions!
  8406. const oldData = (oldChild.data.transition = extend({}, data));
  8407. // handle transition mode
  8408. if (mode === 'out-in') {
  8409. // return placeholder node and queue update when leave finishes
  8410. this._leaving = true;
  8411. mergeVNodeHook(oldData, 'afterLeave', () => {
  8412. this._leaving = false;
  8413. this.$forceUpdate();
  8414. });
  8415. return placeholder(h, rawChild);
  8416. }
  8417. else if (mode === 'in-out') {
  8418. if (isAsyncPlaceholder(child)) {
  8419. return oldRawChild;
  8420. }
  8421. let delayedLeave;
  8422. const performLeave = () => {
  8423. delayedLeave();
  8424. };
  8425. mergeVNodeHook(data, 'afterEnter', performLeave);
  8426. mergeVNodeHook(data, 'enterCancelled', performLeave);
  8427. mergeVNodeHook(oldData, 'delayLeave', leave => {
  8428. delayedLeave = leave;
  8429. });
  8430. }
  8431. }
  8432. return rawChild;
  8433. }
  8434. };
  8435. // Provides transition support for list items.
  8436. const props = extend({
  8437. tag: String,
  8438. moveClass: String
  8439. }, transitionProps);
  8440. delete props.mode;
  8441. var TransitionGroup = {
  8442. props,
  8443. beforeMount() {
  8444. const update = this._update;
  8445. this._update = (vnode, hydrating) => {
  8446. const restoreActiveInstance = setActiveInstance(this);
  8447. // force removing pass
  8448. this.__patch__(this._vnode, this.kept, false, // hydrating
  8449. true // removeOnly (!important, avoids unnecessary moves)
  8450. );
  8451. this._vnode = this.kept;
  8452. restoreActiveInstance();
  8453. update.call(this, vnode, hydrating);
  8454. };
  8455. },
  8456. render(h) {
  8457. const tag = this.tag || this.$vnode.data.tag || 'span';
  8458. const map = Object.create(null);
  8459. const prevChildren = (this.prevChildren = this.children);
  8460. const rawChildren = this.$slots.default || [];
  8461. const children = (this.children = []);
  8462. const transitionData = extractTransitionData(this);
  8463. for (let i = 0; i < rawChildren.length; i++) {
  8464. const c = rawChildren[i];
  8465. if (c.tag) {
  8466. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  8467. children.push(c);
  8468. map[c.key] = c;
  8469. (c.data || (c.data = {})).transition = transitionData;
  8470. }
  8471. else {
  8472. const opts = c.componentOptions;
  8473. const name = opts
  8474. ? getComponentName(opts.Ctor.options) || opts.tag || ''
  8475. : c.tag;
  8476. warn(`<transition-group> children must be keyed: <${name}>`);
  8477. }
  8478. }
  8479. }
  8480. if (prevChildren) {
  8481. const kept = [];
  8482. const removed = [];
  8483. for (let i = 0; i < prevChildren.length; i++) {
  8484. const c = prevChildren[i];
  8485. c.data.transition = transitionData;
  8486. // @ts-expect-error .getBoundingClientRect is not typed in Node
  8487. c.data.pos = c.elm.getBoundingClientRect();
  8488. if (map[c.key]) {
  8489. kept.push(c);
  8490. }
  8491. else {
  8492. removed.push(c);
  8493. }
  8494. }
  8495. this.kept = h(tag, null, kept);
  8496. this.removed = removed;
  8497. }
  8498. return h(tag, null, children);
  8499. },
  8500. updated() {
  8501. const children = this.prevChildren;
  8502. const moveClass = this.moveClass || (this.name || 'v') + '-move';
  8503. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  8504. return;
  8505. }
  8506. // we divide the work into three loops to avoid mixing DOM reads and writes
  8507. // in each iteration - which helps prevent layout thrashing.
  8508. children.forEach(callPendingCbs);
  8509. children.forEach(recordPosition);
  8510. children.forEach(applyTranslation);
  8511. // force reflow to put everything in position
  8512. // assign to this to avoid being removed in tree-shaking
  8513. // $flow-disable-line
  8514. this._reflow = document.body.offsetHeight;
  8515. children.forEach((c) => {
  8516. if (c.data.moved) {
  8517. const el = c.elm;
  8518. const s = el.style;
  8519. addTransitionClass(el, moveClass);
  8520. s.transform = s.WebkitTransform = s.transitionDuration = '';
  8521. el.addEventListener(transitionEndEvent, (el._moveCb = function cb(e) {
  8522. if (e && e.target !== el) {
  8523. return;
  8524. }
  8525. if (!e || /transform$/.test(e.propertyName)) {
  8526. el.removeEventListener(transitionEndEvent, cb);
  8527. el._moveCb = null;
  8528. removeTransitionClass(el, moveClass);
  8529. }
  8530. }));
  8531. }
  8532. });
  8533. },
  8534. methods: {
  8535. hasMove(el, moveClass) {
  8536. /* istanbul ignore if */
  8537. if (!hasTransition) {
  8538. return false;
  8539. }
  8540. /* istanbul ignore if */
  8541. if (this._hasMove) {
  8542. return this._hasMove;
  8543. }
  8544. // Detect whether an element with the move class applied has
  8545. // CSS transitions. Since the element may be inside an entering
  8546. // transition at this very moment, we make a clone of it and remove
  8547. // all other transition classes applied to ensure only the move class
  8548. // is applied.
  8549. const clone = el.cloneNode();
  8550. if (el._transitionClasses) {
  8551. el._transitionClasses.forEach((cls) => {
  8552. removeClass(clone, cls);
  8553. });
  8554. }
  8555. addClass(clone, moveClass);
  8556. clone.style.display = 'none';
  8557. this.$el.appendChild(clone);
  8558. const info = getTransitionInfo(clone);
  8559. this.$el.removeChild(clone);
  8560. return (this._hasMove = info.hasTransform);
  8561. }
  8562. }
  8563. };
  8564. function callPendingCbs(c) {
  8565. /* istanbul ignore if */
  8566. if (c.elm._moveCb) {
  8567. c.elm._moveCb();
  8568. }
  8569. /* istanbul ignore if */
  8570. if (c.elm._enterCb) {
  8571. c.elm._enterCb();
  8572. }
  8573. }
  8574. function recordPosition(c) {
  8575. c.data.newPos = c.elm.getBoundingClientRect();
  8576. }
  8577. function applyTranslation(c) {
  8578. const oldPos = c.data.pos;
  8579. const newPos = c.data.newPos;
  8580. const dx = oldPos.left - newPos.left;
  8581. const dy = oldPos.top - newPos.top;
  8582. if (dx || dy) {
  8583. c.data.moved = true;
  8584. const s = c.elm.style;
  8585. s.transform = s.WebkitTransform = `translate(${dx}px,${dy}px)`;
  8586. s.transitionDuration = '0s';
  8587. }
  8588. }
  8589. var platformComponents = {
  8590. Transition,
  8591. TransitionGroup
  8592. };
  8593. // install platform specific utils
  8594. Vue.config.mustUseProp = mustUseProp;
  8595. Vue.config.isReservedTag = isReservedTag;
  8596. Vue.config.isReservedAttr = isReservedAttr;
  8597. Vue.config.getTagNamespace = getTagNamespace;
  8598. Vue.config.isUnknownElement = isUnknownElement;
  8599. // install platform runtime directives & components
  8600. extend(Vue.options.directives, platformDirectives);
  8601. extend(Vue.options.components, platformComponents);
  8602. // install platform patch function
  8603. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  8604. // public mount method
  8605. Vue.prototype.$mount = function (el, hydrating) {
  8606. el = el && inBrowser ? query(el) : undefined;
  8607. return mountComponent(this, el, hydrating);
  8608. };
  8609. // devtools global hook
  8610. /* istanbul ignore next */
  8611. if (inBrowser) {
  8612. setTimeout(() => {
  8613. if (config.devtools) {
  8614. if (devtools) {
  8615. devtools.emit('init', Vue);
  8616. }
  8617. else {
  8618. // @ts-expect-error
  8619. console[console.info ? 'info' : 'log']('Download the Vue Devtools extension for a better development experience:\n' +
  8620. 'https://github.com/vuejs/vue-devtools');
  8621. }
  8622. }
  8623. if (config.productionTip !== false &&
  8624. typeof console !== 'undefined') {
  8625. // @ts-expect-error
  8626. console[console.info ? 'info' : 'log'](`You are running Vue in development mode.\n` +
  8627. `Make sure to turn on production mode when deploying for production.\n` +
  8628. `See more tips at https://vuejs.org/guide/deployment.html`);
  8629. }
  8630. }, 0);
  8631. }
  8632. extend(Vue, vca);
  8633. module.exports = Vue;