vue.runtime.global.js 416 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000
  1. var Vue = (function (exports) {
  2. 'use strict';
  3. /**
  4. * Make a map and return a function for checking if a key
  5. * is in that map.
  6. * IMPORTANT: all calls of this function must be prefixed with
  7. * \/\*#\_\_PURE\_\_\*\/
  8. * So that rollup can tree-shake them if necessary.
  9. */
  10. function makeMap(str, expectsLowerCase) {
  11. const map = Object.create(null);
  12. const list = str.split(',');
  13. for (let i = 0; i < list.length; i++) {
  14. map[list[i]] = true;
  15. }
  16. return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
  17. }
  18. const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
  19. 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
  20. 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt';
  21. const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);
  22. /**
  23. * On the client we only need to offer special cases for boolean attributes that
  24. * have different names from their corresponding dom properties:
  25. * - itemscope -> N/A
  26. * - allowfullscreen -> allowFullscreen
  27. * - formnovalidate -> formNoValidate
  28. * - ismap -> isMap
  29. * - nomodule -> noModule
  30. * - novalidate -> noValidate
  31. * - readonly -> readOnly
  32. */
  33. const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
  34. const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
  35. /**
  36. * Boolean attributes should be included if the value is truthy or ''.
  37. * e.g. `<select multiple>` compiles to `{ multiple: '' }`
  38. */
  39. function includeBooleanAttr(value) {
  40. return !!value || value === '';
  41. }
  42. function normalizeStyle(value) {
  43. if (isArray(value)) {
  44. const res = {};
  45. for (let i = 0; i < value.length; i++) {
  46. const item = value[i];
  47. const normalized = isString(item)
  48. ? parseStringStyle(item)
  49. : normalizeStyle(item);
  50. if (normalized) {
  51. for (const key in normalized) {
  52. res[key] = normalized[key];
  53. }
  54. }
  55. }
  56. return res;
  57. }
  58. else if (isString(value)) {
  59. return value;
  60. }
  61. else if (isObject(value)) {
  62. return value;
  63. }
  64. }
  65. const listDelimiterRE = /;(?![^(]*\))/g;
  66. const propertyDelimiterRE = /:(.+)/;
  67. function parseStringStyle(cssText) {
  68. const ret = {};
  69. cssText.split(listDelimiterRE).forEach(item => {
  70. if (item) {
  71. const tmp = item.split(propertyDelimiterRE);
  72. tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
  73. }
  74. });
  75. return ret;
  76. }
  77. function normalizeClass(value) {
  78. let res = '';
  79. if (isString(value)) {
  80. res = value;
  81. }
  82. else if (isArray(value)) {
  83. for (let i = 0; i < value.length; i++) {
  84. const normalized = normalizeClass(value[i]);
  85. if (normalized) {
  86. res += normalized + ' ';
  87. }
  88. }
  89. }
  90. else if (isObject(value)) {
  91. for (const name in value) {
  92. if (value[name]) {
  93. res += name + ' ';
  94. }
  95. }
  96. }
  97. return res.trim();
  98. }
  99. function normalizeProps(props) {
  100. if (!props)
  101. return null;
  102. let { class: klass, style } = props;
  103. if (klass && !isString(klass)) {
  104. props.class = normalizeClass(klass);
  105. }
  106. if (style) {
  107. props.style = normalizeStyle(style);
  108. }
  109. return props;
  110. }
  111. // These tag configs are shared between compiler-dom and runtime-dom, so they
  112. // https://developer.mozilla.org/en-US/docs/Web/HTML/Element
  113. const HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,' +
  114. 'header,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,' +
  115. 'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' +
  116. 'data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,' +
  117. 'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' +
  118. 'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' +
  119. 'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' +
  120. 'option,output,progress,select,textarea,details,dialog,menu,' +
  121. 'summary,template,blockquote,iframe,tfoot';
  122. // https://developer.mozilla.org/en-US/docs/Web/SVG/Element
  123. const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' +
  124. 'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' +
  125. 'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' +
  126. 'feDistanceLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' +
  127. 'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' +
  128. 'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' +
  129. 'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' +
  130. 'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' +
  131. 'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
  132. 'text,textPath,title,tspan,unknown,use,view';
  133. /**
  134. * Compiler only.
  135. * Do NOT use in runtime code paths unless behind `true` flag.
  136. */
  137. const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS);
  138. /**
  139. * Compiler only.
  140. * Do NOT use in runtime code paths unless behind `true` flag.
  141. */
  142. const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
  143. function looseCompareArrays(a, b) {
  144. if (a.length !== b.length)
  145. return false;
  146. let equal = true;
  147. for (let i = 0; equal && i < a.length; i++) {
  148. equal = looseEqual(a[i], b[i]);
  149. }
  150. return equal;
  151. }
  152. function looseEqual(a, b) {
  153. if (a === b)
  154. return true;
  155. let aValidType = isDate(a);
  156. let bValidType = isDate(b);
  157. if (aValidType || bValidType) {
  158. return aValidType && bValidType ? a.getTime() === b.getTime() : false;
  159. }
  160. aValidType = isSymbol(a);
  161. bValidType = isSymbol(b);
  162. if (aValidType || bValidType) {
  163. return a === b;
  164. }
  165. aValidType = isArray(a);
  166. bValidType = isArray(b);
  167. if (aValidType || bValidType) {
  168. return aValidType && bValidType ? looseCompareArrays(a, b) : false;
  169. }
  170. aValidType = isObject(a);
  171. bValidType = isObject(b);
  172. if (aValidType || bValidType) {
  173. /* istanbul ignore if: this if will probably never be called */
  174. if (!aValidType || !bValidType) {
  175. return false;
  176. }
  177. const aKeysCount = Object.keys(a).length;
  178. const bKeysCount = Object.keys(b).length;
  179. if (aKeysCount !== bKeysCount) {
  180. return false;
  181. }
  182. for (const key in a) {
  183. const aHasKey = a.hasOwnProperty(key);
  184. const bHasKey = b.hasOwnProperty(key);
  185. if ((aHasKey && !bHasKey) ||
  186. (!aHasKey && bHasKey) ||
  187. !looseEqual(a[key], b[key])) {
  188. return false;
  189. }
  190. }
  191. }
  192. return String(a) === String(b);
  193. }
  194. function looseIndexOf(arr, val) {
  195. return arr.findIndex(item => looseEqual(item, val));
  196. }
  197. /**
  198. * For converting {{ interpolation }} values to displayed strings.
  199. * @private
  200. */
  201. const toDisplayString = (val) => {
  202. return isString(val)
  203. ? val
  204. : val == null
  205. ? ''
  206. : isArray(val) ||
  207. (isObject(val) &&
  208. (val.toString === objectToString || !isFunction(val.toString)))
  209. ? JSON.stringify(val, replacer, 2)
  210. : String(val);
  211. };
  212. const replacer = (_key, val) => {
  213. // can't use isRef here since @vue/shared has no deps
  214. if (val && val.__v_isRef) {
  215. return replacer(_key, val.value);
  216. }
  217. else if (isMap(val)) {
  218. return {
  219. [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val]) => {
  220. entries[`${key} =>`] = val;
  221. return entries;
  222. }, {})
  223. };
  224. }
  225. else if (isSet(val)) {
  226. return {
  227. [`Set(${val.size})`]: [...val.values()]
  228. };
  229. }
  230. else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
  231. return String(val);
  232. }
  233. return val;
  234. };
  235. const EMPTY_OBJ = Object.freeze({})
  236. ;
  237. const EMPTY_ARR = Object.freeze([]) ;
  238. const NOOP = () => { };
  239. /**
  240. * Always return false.
  241. */
  242. const NO = () => false;
  243. const onRE = /^on[^a-z]/;
  244. const isOn = (key) => onRE.test(key);
  245. const isModelListener = (key) => key.startsWith('onUpdate:');
  246. const extend = Object.assign;
  247. const remove = (arr, el) => {
  248. const i = arr.indexOf(el);
  249. if (i > -1) {
  250. arr.splice(i, 1);
  251. }
  252. };
  253. const hasOwnProperty = Object.prototype.hasOwnProperty;
  254. const hasOwn = (val, key) => hasOwnProperty.call(val, key);
  255. const isArray = Array.isArray;
  256. const isMap = (val) => toTypeString(val) === '[object Map]';
  257. const isSet = (val) => toTypeString(val) === '[object Set]';
  258. const isDate = (val) => toTypeString(val) === '[object Date]';
  259. const isFunction = (val) => typeof val === 'function';
  260. const isString = (val) => typeof val === 'string';
  261. const isSymbol = (val) => typeof val === 'symbol';
  262. const isObject = (val) => val !== null && typeof val === 'object';
  263. const isPromise = (val) => {
  264. return isObject(val) && isFunction(val.then) && isFunction(val.catch);
  265. };
  266. const objectToString = Object.prototype.toString;
  267. const toTypeString = (value) => objectToString.call(value);
  268. const toRawType = (value) => {
  269. // extract "RawType" from strings like "[object RawType]"
  270. return toTypeString(value).slice(8, -1);
  271. };
  272. const isPlainObject = (val) => toTypeString(val) === '[object Object]';
  273. const isIntegerKey = (key) => isString(key) &&
  274. key !== 'NaN' &&
  275. key[0] !== '-' &&
  276. '' + parseInt(key, 10) === key;
  277. const isReservedProp = /*#__PURE__*/ makeMap(
  278. // the leading comma is intentional so empty string "" is also included
  279. ',key,ref,ref_for,ref_key,' +
  280. 'onVnodeBeforeMount,onVnodeMounted,' +
  281. 'onVnodeBeforeUpdate,onVnodeUpdated,' +
  282. 'onVnodeBeforeUnmount,onVnodeUnmounted');
  283. const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
  284. const cacheStringFunction = (fn) => {
  285. const cache = Object.create(null);
  286. return ((str) => {
  287. const hit = cache[str];
  288. return hit || (cache[str] = fn(str));
  289. });
  290. };
  291. const camelizeRE = /-(\w)/g;
  292. /**
  293. * @private
  294. */
  295. const camelize = cacheStringFunction((str) => {
  296. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  297. });
  298. const hyphenateRE = /\B([A-Z])/g;
  299. /**
  300. * @private
  301. */
  302. const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase());
  303. /**
  304. * @private
  305. */
  306. const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
  307. /**
  308. * @private
  309. */
  310. const toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``);
  311. // compare whether a value has changed, accounting for NaN.
  312. const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
  313. const invokeArrayFns = (fns, arg) => {
  314. for (let i = 0; i < fns.length; i++) {
  315. fns[i](arg);
  316. }
  317. };
  318. const def = (obj, key, value) => {
  319. Object.defineProperty(obj, key, {
  320. configurable: true,
  321. enumerable: false,
  322. value
  323. });
  324. };
  325. const toNumber = (val) => {
  326. const n = parseFloat(val);
  327. return isNaN(n) ? val : n;
  328. };
  329. let _globalThis;
  330. const getGlobalThis = () => {
  331. return (_globalThis ||
  332. (_globalThis =
  333. typeof globalThis !== 'undefined'
  334. ? globalThis
  335. : typeof self !== 'undefined'
  336. ? self
  337. : typeof window !== 'undefined'
  338. ? window
  339. : typeof global !== 'undefined'
  340. ? global
  341. : {}));
  342. };
  343. function warn(msg, ...args) {
  344. console.warn(`[Vue warn] ${msg}`, ...args);
  345. }
  346. let activeEffectScope;
  347. class EffectScope {
  348. constructor(detached = false) {
  349. /**
  350. * @internal
  351. */
  352. this.active = true;
  353. /**
  354. * @internal
  355. */
  356. this.effects = [];
  357. /**
  358. * @internal
  359. */
  360. this.cleanups = [];
  361. if (!detached && activeEffectScope) {
  362. this.parent = activeEffectScope;
  363. this.index =
  364. (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
  365. }
  366. }
  367. run(fn) {
  368. if (this.active) {
  369. const currentEffectScope = activeEffectScope;
  370. try {
  371. activeEffectScope = this;
  372. return fn();
  373. }
  374. finally {
  375. activeEffectScope = currentEffectScope;
  376. }
  377. }
  378. else {
  379. warn(`cannot run an inactive effect scope.`);
  380. }
  381. }
  382. /**
  383. * This should only be called on non-detached scopes
  384. * @internal
  385. */
  386. on() {
  387. activeEffectScope = this;
  388. }
  389. /**
  390. * This should only be called on non-detached scopes
  391. * @internal
  392. */
  393. off() {
  394. activeEffectScope = this.parent;
  395. }
  396. stop(fromParent) {
  397. if (this.active) {
  398. let i, l;
  399. for (i = 0, l = this.effects.length; i < l; i++) {
  400. this.effects[i].stop();
  401. }
  402. for (i = 0, l = this.cleanups.length; i < l; i++) {
  403. this.cleanups[i]();
  404. }
  405. if (this.scopes) {
  406. for (i = 0, l = this.scopes.length; i < l; i++) {
  407. this.scopes[i].stop(true);
  408. }
  409. }
  410. // nested scope, dereference from parent to avoid memory leaks
  411. if (this.parent && !fromParent) {
  412. // optimized O(1) removal
  413. const last = this.parent.scopes.pop();
  414. if (last && last !== this) {
  415. this.parent.scopes[this.index] = last;
  416. last.index = this.index;
  417. }
  418. }
  419. this.active = false;
  420. }
  421. }
  422. }
  423. function effectScope(detached) {
  424. return new EffectScope(detached);
  425. }
  426. function recordEffectScope(effect, scope = activeEffectScope) {
  427. if (scope && scope.active) {
  428. scope.effects.push(effect);
  429. }
  430. }
  431. function getCurrentScope() {
  432. return activeEffectScope;
  433. }
  434. function onScopeDispose(fn) {
  435. if (activeEffectScope) {
  436. activeEffectScope.cleanups.push(fn);
  437. }
  438. else {
  439. warn(`onScopeDispose() is called when there is no active effect scope` +
  440. ` to be associated with.`);
  441. }
  442. }
  443. const createDep = (effects) => {
  444. const dep = new Set(effects);
  445. dep.w = 0;
  446. dep.n = 0;
  447. return dep;
  448. };
  449. const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
  450. const newTracked = (dep) => (dep.n & trackOpBit) > 0;
  451. const initDepMarkers = ({ deps }) => {
  452. if (deps.length) {
  453. for (let i = 0; i < deps.length; i++) {
  454. deps[i].w |= trackOpBit; // set was tracked
  455. }
  456. }
  457. };
  458. const finalizeDepMarkers = (effect) => {
  459. const { deps } = effect;
  460. if (deps.length) {
  461. let ptr = 0;
  462. for (let i = 0; i < deps.length; i++) {
  463. const dep = deps[i];
  464. if (wasTracked(dep) && !newTracked(dep)) {
  465. dep.delete(effect);
  466. }
  467. else {
  468. deps[ptr++] = dep;
  469. }
  470. // clear bits
  471. dep.w &= ~trackOpBit;
  472. dep.n &= ~trackOpBit;
  473. }
  474. deps.length = ptr;
  475. }
  476. };
  477. const targetMap = new WeakMap();
  478. // The number of effects currently being tracked recursively.
  479. let effectTrackDepth = 0;
  480. let trackOpBit = 1;
  481. /**
  482. * The bitwise track markers support at most 30 levels of recursion.
  483. * This value is chosen to enable modern JS engines to use a SMI on all platforms.
  484. * When recursion depth is greater, fall back to using a full cleanup.
  485. */
  486. const maxMarkerBits = 30;
  487. let activeEffect;
  488. const ITERATE_KEY = Symbol('iterate' );
  489. const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
  490. class ReactiveEffect {
  491. constructor(fn, scheduler = null, scope) {
  492. this.fn = fn;
  493. this.scheduler = scheduler;
  494. this.active = true;
  495. this.deps = [];
  496. this.parent = undefined;
  497. recordEffectScope(this, scope);
  498. }
  499. run() {
  500. if (!this.active) {
  501. return this.fn();
  502. }
  503. let parent = activeEffect;
  504. let lastShouldTrack = shouldTrack;
  505. while (parent) {
  506. if (parent === this) {
  507. return;
  508. }
  509. parent = parent.parent;
  510. }
  511. try {
  512. this.parent = activeEffect;
  513. activeEffect = this;
  514. shouldTrack = true;
  515. trackOpBit = 1 << ++effectTrackDepth;
  516. if (effectTrackDepth <= maxMarkerBits) {
  517. initDepMarkers(this);
  518. }
  519. else {
  520. cleanupEffect(this);
  521. }
  522. return this.fn();
  523. }
  524. finally {
  525. if (effectTrackDepth <= maxMarkerBits) {
  526. finalizeDepMarkers(this);
  527. }
  528. trackOpBit = 1 << --effectTrackDepth;
  529. activeEffect = this.parent;
  530. shouldTrack = lastShouldTrack;
  531. this.parent = undefined;
  532. if (this.deferStop) {
  533. this.stop();
  534. }
  535. }
  536. }
  537. stop() {
  538. // stopped while running itself - defer the cleanup
  539. if (activeEffect === this) {
  540. this.deferStop = true;
  541. }
  542. else if (this.active) {
  543. cleanupEffect(this);
  544. if (this.onStop) {
  545. this.onStop();
  546. }
  547. this.active = false;
  548. }
  549. }
  550. }
  551. function cleanupEffect(effect) {
  552. const { deps } = effect;
  553. if (deps.length) {
  554. for (let i = 0; i < deps.length; i++) {
  555. deps[i].delete(effect);
  556. }
  557. deps.length = 0;
  558. }
  559. }
  560. function effect(fn, options) {
  561. if (fn.effect) {
  562. fn = fn.effect.fn;
  563. }
  564. const _effect = new ReactiveEffect(fn);
  565. if (options) {
  566. extend(_effect, options);
  567. if (options.scope)
  568. recordEffectScope(_effect, options.scope);
  569. }
  570. if (!options || !options.lazy) {
  571. _effect.run();
  572. }
  573. const runner = _effect.run.bind(_effect);
  574. runner.effect = _effect;
  575. return runner;
  576. }
  577. function stop(runner) {
  578. runner.effect.stop();
  579. }
  580. let shouldTrack = true;
  581. const trackStack = [];
  582. function pauseTracking() {
  583. trackStack.push(shouldTrack);
  584. shouldTrack = false;
  585. }
  586. function resetTracking() {
  587. const last = trackStack.pop();
  588. shouldTrack = last === undefined ? true : last;
  589. }
  590. function track(target, type, key) {
  591. if (shouldTrack && activeEffect) {
  592. let depsMap = targetMap.get(target);
  593. if (!depsMap) {
  594. targetMap.set(target, (depsMap = new Map()));
  595. }
  596. let dep = depsMap.get(key);
  597. if (!dep) {
  598. depsMap.set(key, (dep = createDep()));
  599. }
  600. const eventInfo = { effect: activeEffect, target, type, key }
  601. ;
  602. trackEffects(dep, eventInfo);
  603. }
  604. }
  605. function trackEffects(dep, debuggerEventExtraInfo) {
  606. let shouldTrack = false;
  607. if (effectTrackDepth <= maxMarkerBits) {
  608. if (!newTracked(dep)) {
  609. dep.n |= trackOpBit; // set newly tracked
  610. shouldTrack = !wasTracked(dep);
  611. }
  612. }
  613. else {
  614. // Full cleanup mode.
  615. shouldTrack = !dep.has(activeEffect);
  616. }
  617. if (shouldTrack) {
  618. dep.add(activeEffect);
  619. activeEffect.deps.push(dep);
  620. if (activeEffect.onTrack) {
  621. activeEffect.onTrack(Object.assign({ effect: activeEffect }, debuggerEventExtraInfo));
  622. }
  623. }
  624. }
  625. function trigger(target, type, key, newValue, oldValue, oldTarget) {
  626. const depsMap = targetMap.get(target);
  627. if (!depsMap) {
  628. // never been tracked
  629. return;
  630. }
  631. let deps = [];
  632. if (type === "clear" /* CLEAR */) {
  633. // collection being cleared
  634. // trigger all effects for target
  635. deps = [...depsMap.values()];
  636. }
  637. else if (key === 'length' && isArray(target)) {
  638. depsMap.forEach((dep, key) => {
  639. if (key === 'length' || key >= newValue) {
  640. deps.push(dep);
  641. }
  642. });
  643. }
  644. else {
  645. // schedule runs for SET | ADD | DELETE
  646. if (key !== void 0) {
  647. deps.push(depsMap.get(key));
  648. }
  649. // also run for iteration key on ADD | DELETE | Map.SET
  650. switch (type) {
  651. case "add" /* ADD */:
  652. if (!isArray(target)) {
  653. deps.push(depsMap.get(ITERATE_KEY));
  654. if (isMap(target)) {
  655. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
  656. }
  657. }
  658. else if (isIntegerKey(key)) {
  659. // new index added to array -> length changes
  660. deps.push(depsMap.get('length'));
  661. }
  662. break;
  663. case "delete" /* DELETE */:
  664. if (!isArray(target)) {
  665. deps.push(depsMap.get(ITERATE_KEY));
  666. if (isMap(target)) {
  667. deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
  668. }
  669. }
  670. break;
  671. case "set" /* SET */:
  672. if (isMap(target)) {
  673. deps.push(depsMap.get(ITERATE_KEY));
  674. }
  675. break;
  676. }
  677. }
  678. const eventInfo = { target, type, key, newValue, oldValue, oldTarget }
  679. ;
  680. if (deps.length === 1) {
  681. if (deps[0]) {
  682. {
  683. triggerEffects(deps[0], eventInfo);
  684. }
  685. }
  686. }
  687. else {
  688. const effects = [];
  689. for (const dep of deps) {
  690. if (dep) {
  691. effects.push(...dep);
  692. }
  693. }
  694. {
  695. triggerEffects(createDep(effects), eventInfo);
  696. }
  697. }
  698. }
  699. function triggerEffects(dep, debuggerEventExtraInfo) {
  700. // spread into array for stabilization
  701. const effects = isArray(dep) ? dep : [...dep];
  702. for (const effect of effects) {
  703. if (effect.computed) {
  704. triggerEffect(effect, debuggerEventExtraInfo);
  705. }
  706. }
  707. for (const effect of effects) {
  708. if (!effect.computed) {
  709. triggerEffect(effect, debuggerEventExtraInfo);
  710. }
  711. }
  712. }
  713. function triggerEffect(effect, debuggerEventExtraInfo) {
  714. if (effect !== activeEffect || effect.allowRecurse) {
  715. if (effect.onTrigger) {
  716. effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
  717. }
  718. if (effect.scheduler) {
  719. effect.scheduler();
  720. }
  721. else {
  722. effect.run();
  723. }
  724. }
  725. }
  726. const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
  727. const builtInSymbols = new Set(
  728. /*#__PURE__*/
  729. Object.getOwnPropertyNames(Symbol)
  730. // ios10.x Object.getOwnPropertyNames(Symbol) can enumerate 'arguments' and 'caller'
  731. // but accessing them on Symbol leads to TypeError because Symbol is a strict mode
  732. // function
  733. .filter(key => key !== 'arguments' && key !== 'caller')
  734. .map(key => Symbol[key])
  735. .filter(isSymbol));
  736. const get = /*#__PURE__*/ createGetter();
  737. const shallowGet = /*#__PURE__*/ createGetter(false, true);
  738. const readonlyGet = /*#__PURE__*/ createGetter(true);
  739. const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
  740. const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations();
  741. function createArrayInstrumentations() {
  742. const instrumentations = {};
  743. ['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
  744. instrumentations[key] = function (...args) {
  745. const arr = toRaw(this);
  746. for (let i = 0, l = this.length; i < l; i++) {
  747. track(arr, "get" /* GET */, i + '');
  748. }
  749. // we run the method using the original args first (which may be reactive)
  750. const res = arr[key](...args);
  751. if (res === -1 || res === false) {
  752. // if that didn't work, run it again using raw values.
  753. return arr[key](...args.map(toRaw));
  754. }
  755. else {
  756. return res;
  757. }
  758. };
  759. });
  760. ['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
  761. instrumentations[key] = function (...args) {
  762. pauseTracking();
  763. const res = toRaw(this)[key].apply(this, args);
  764. resetTracking();
  765. return res;
  766. };
  767. });
  768. return instrumentations;
  769. }
  770. function createGetter(isReadonly = false, shallow = false) {
  771. return function get(target, key, receiver) {
  772. if (key === "__v_isReactive" /* IS_REACTIVE */) {
  773. return !isReadonly;
  774. }
  775. else if (key === "__v_isReadonly" /* IS_READONLY */) {
  776. return isReadonly;
  777. }
  778. else if (key === "__v_isShallow" /* IS_SHALLOW */) {
  779. return shallow;
  780. }
  781. else if (key === "__v_raw" /* RAW */ &&
  782. receiver ===
  783. (isReadonly
  784. ? shallow
  785. ? shallowReadonlyMap
  786. : readonlyMap
  787. : shallow
  788. ? shallowReactiveMap
  789. : reactiveMap).get(target)) {
  790. return target;
  791. }
  792. const targetIsArray = isArray(target);
  793. if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
  794. return Reflect.get(arrayInstrumentations, key, receiver);
  795. }
  796. const res = Reflect.get(target, key, receiver);
  797. if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
  798. return res;
  799. }
  800. if (!isReadonly) {
  801. track(target, "get" /* GET */, key);
  802. }
  803. if (shallow) {
  804. return res;
  805. }
  806. if (isRef(res)) {
  807. // ref unwrapping - skip unwrap for Array + integer key.
  808. return targetIsArray && isIntegerKey(key) ? res : res.value;
  809. }
  810. if (isObject(res)) {
  811. // Convert returned value into a proxy as well. we do the isObject check
  812. // here to avoid invalid value warning. Also need to lazy access readonly
  813. // and reactive here to avoid circular dependency.
  814. return isReadonly ? readonly(res) : reactive(res);
  815. }
  816. return res;
  817. };
  818. }
  819. const set = /*#__PURE__*/ createSetter();
  820. const shallowSet = /*#__PURE__*/ createSetter(true);
  821. function createSetter(shallow = false) {
  822. return function set(target, key, value, receiver) {
  823. let oldValue = target[key];
  824. if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
  825. return false;
  826. }
  827. if (!shallow && !isReadonly(value)) {
  828. if (!isShallow(value)) {
  829. value = toRaw(value);
  830. oldValue = toRaw(oldValue);
  831. }
  832. if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
  833. oldValue.value = value;
  834. return true;
  835. }
  836. }
  837. const hadKey = isArray(target) && isIntegerKey(key)
  838. ? Number(key) < target.length
  839. : hasOwn(target, key);
  840. const result = Reflect.set(target, key, value, receiver);
  841. // don't trigger if target is something up in the prototype chain of original
  842. if (target === toRaw(receiver)) {
  843. if (!hadKey) {
  844. trigger(target, "add" /* ADD */, key, value);
  845. }
  846. else if (hasChanged(value, oldValue)) {
  847. trigger(target, "set" /* SET */, key, value, oldValue);
  848. }
  849. }
  850. return result;
  851. };
  852. }
  853. function deleteProperty(target, key) {
  854. const hadKey = hasOwn(target, key);
  855. const oldValue = target[key];
  856. const result = Reflect.deleteProperty(target, key);
  857. if (result && hadKey) {
  858. trigger(target, "delete" /* DELETE */, key, undefined, oldValue);
  859. }
  860. return result;
  861. }
  862. function has(target, key) {
  863. const result = Reflect.has(target, key);
  864. if (!isSymbol(key) || !builtInSymbols.has(key)) {
  865. track(target, "has" /* HAS */, key);
  866. }
  867. return result;
  868. }
  869. function ownKeys(target) {
  870. track(target, "iterate" /* ITERATE */, isArray(target) ? 'length' : ITERATE_KEY);
  871. return Reflect.ownKeys(target);
  872. }
  873. const mutableHandlers = {
  874. get,
  875. set,
  876. deleteProperty,
  877. has,
  878. ownKeys
  879. };
  880. const readonlyHandlers = {
  881. get: readonlyGet,
  882. set(target, key) {
  883. {
  884. warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
  885. }
  886. return true;
  887. },
  888. deleteProperty(target, key) {
  889. {
  890. warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
  891. }
  892. return true;
  893. }
  894. };
  895. const shallowReactiveHandlers = /*#__PURE__*/ extend({}, mutableHandlers, {
  896. get: shallowGet,
  897. set: shallowSet
  898. });
  899. // Props handlers are special in the sense that it should not unwrap top-level
  900. // refs (in order to allow refs to be explicitly passed down), but should
  901. // retain the reactivity of the normal readonly object.
  902. const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
  903. get: shallowReadonlyGet
  904. });
  905. const toShallow = (value) => value;
  906. const getProto = (v) => Reflect.getPrototypeOf(v);
  907. function get$1(target, key, isReadonly = false, isShallow = false) {
  908. // #1772: readonly(reactive(Map)) should return readonly + reactive version
  909. // of the value
  910. target = target["__v_raw" /* RAW */];
  911. const rawTarget = toRaw(target);
  912. const rawKey = toRaw(key);
  913. if (!isReadonly) {
  914. if (key !== rawKey) {
  915. track(rawTarget, "get" /* GET */, key);
  916. }
  917. track(rawTarget, "get" /* GET */, rawKey);
  918. }
  919. const { has } = getProto(rawTarget);
  920. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  921. if (has.call(rawTarget, key)) {
  922. return wrap(target.get(key));
  923. }
  924. else if (has.call(rawTarget, rawKey)) {
  925. return wrap(target.get(rawKey));
  926. }
  927. else if (target !== rawTarget) {
  928. // #3602 readonly(reactive(Map))
  929. // ensure that the nested reactive `Map` can do tracking for itself
  930. target.get(key);
  931. }
  932. }
  933. function has$1(key, isReadonly = false) {
  934. const target = this["__v_raw" /* RAW */];
  935. const rawTarget = toRaw(target);
  936. const rawKey = toRaw(key);
  937. if (!isReadonly) {
  938. if (key !== rawKey) {
  939. track(rawTarget, "has" /* HAS */, key);
  940. }
  941. track(rawTarget, "has" /* HAS */, rawKey);
  942. }
  943. return key === rawKey
  944. ? target.has(key)
  945. : target.has(key) || target.has(rawKey);
  946. }
  947. function size(target, isReadonly = false) {
  948. target = target["__v_raw" /* RAW */];
  949. !isReadonly && track(toRaw(target), "iterate" /* ITERATE */, ITERATE_KEY);
  950. return Reflect.get(target, 'size', target);
  951. }
  952. function add(value) {
  953. value = toRaw(value);
  954. const target = toRaw(this);
  955. const proto = getProto(target);
  956. const hadKey = proto.has.call(target, value);
  957. if (!hadKey) {
  958. target.add(value);
  959. trigger(target, "add" /* ADD */, value, value);
  960. }
  961. return this;
  962. }
  963. function set$1(key, value) {
  964. value = toRaw(value);
  965. const target = toRaw(this);
  966. const { has, get } = getProto(target);
  967. let hadKey = has.call(target, key);
  968. if (!hadKey) {
  969. key = toRaw(key);
  970. hadKey = has.call(target, key);
  971. }
  972. else {
  973. checkIdentityKeys(target, has, key);
  974. }
  975. const oldValue = get.call(target, key);
  976. target.set(key, value);
  977. if (!hadKey) {
  978. trigger(target, "add" /* ADD */, key, value);
  979. }
  980. else if (hasChanged(value, oldValue)) {
  981. trigger(target, "set" /* SET */, key, value, oldValue);
  982. }
  983. return this;
  984. }
  985. function deleteEntry(key) {
  986. const target = toRaw(this);
  987. const { has, get } = getProto(target);
  988. let hadKey = has.call(target, key);
  989. if (!hadKey) {
  990. key = toRaw(key);
  991. hadKey = has.call(target, key);
  992. }
  993. else {
  994. checkIdentityKeys(target, has, key);
  995. }
  996. const oldValue = get ? get.call(target, key) : undefined;
  997. // forward the operation before queueing reactions
  998. const result = target.delete(key);
  999. if (hadKey) {
  1000. trigger(target, "delete" /* DELETE */, key, undefined, oldValue);
  1001. }
  1002. return result;
  1003. }
  1004. function clear() {
  1005. const target = toRaw(this);
  1006. const hadItems = target.size !== 0;
  1007. const oldTarget = isMap(target)
  1008. ? new Map(target)
  1009. : new Set(target)
  1010. ;
  1011. // forward the operation before queueing reactions
  1012. const result = target.clear();
  1013. if (hadItems) {
  1014. trigger(target, "clear" /* CLEAR */, undefined, undefined, oldTarget);
  1015. }
  1016. return result;
  1017. }
  1018. function createForEach(isReadonly, isShallow) {
  1019. return function forEach(callback, thisArg) {
  1020. const observed = this;
  1021. const target = observed["__v_raw" /* RAW */];
  1022. const rawTarget = toRaw(target);
  1023. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  1024. !isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY);
  1025. return target.forEach((value, key) => {
  1026. // important: make sure the callback is
  1027. // 1. invoked with the reactive map as `this` and 3rd arg
  1028. // 2. the value received should be a corresponding reactive/readonly.
  1029. return callback.call(thisArg, wrap(value), wrap(key), observed);
  1030. });
  1031. };
  1032. }
  1033. function createIterableMethod(method, isReadonly, isShallow) {
  1034. return function (...args) {
  1035. const target = this["__v_raw" /* RAW */];
  1036. const rawTarget = toRaw(target);
  1037. const targetIsMap = isMap(rawTarget);
  1038. const isPair = method === 'entries' || (method === Symbol.iterator && targetIsMap);
  1039. const isKeyOnly = method === 'keys' && targetIsMap;
  1040. const innerIterator = target[method](...args);
  1041. const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
  1042. !isReadonly &&
  1043. track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
  1044. // return a wrapped iterator which returns observed versions of the
  1045. // values emitted from the real iterator
  1046. return {
  1047. // iterator protocol
  1048. next() {
  1049. const { value, done } = innerIterator.next();
  1050. return done
  1051. ? { value, done }
  1052. : {
  1053. value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
  1054. done
  1055. };
  1056. },
  1057. // iterable protocol
  1058. [Symbol.iterator]() {
  1059. return this;
  1060. }
  1061. };
  1062. };
  1063. }
  1064. function createReadonlyMethod(type) {
  1065. return function (...args) {
  1066. {
  1067. const key = args[0] ? `on key "${args[0]}" ` : ``;
  1068. console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
  1069. }
  1070. return type === "delete" /* DELETE */ ? false : this;
  1071. };
  1072. }
  1073. function createInstrumentations() {
  1074. const mutableInstrumentations = {
  1075. get(key) {
  1076. return get$1(this, key);
  1077. },
  1078. get size() {
  1079. return size(this);
  1080. },
  1081. has: has$1,
  1082. add,
  1083. set: set$1,
  1084. delete: deleteEntry,
  1085. clear,
  1086. forEach: createForEach(false, false)
  1087. };
  1088. const shallowInstrumentations = {
  1089. get(key) {
  1090. return get$1(this, key, false, true);
  1091. },
  1092. get size() {
  1093. return size(this);
  1094. },
  1095. has: has$1,
  1096. add,
  1097. set: set$1,
  1098. delete: deleteEntry,
  1099. clear,
  1100. forEach: createForEach(false, true)
  1101. };
  1102. const readonlyInstrumentations = {
  1103. get(key) {
  1104. return get$1(this, key, true);
  1105. },
  1106. get size() {
  1107. return size(this, true);
  1108. },
  1109. has(key) {
  1110. return has$1.call(this, key, true);
  1111. },
  1112. add: createReadonlyMethod("add" /* ADD */),
  1113. set: createReadonlyMethod("set" /* SET */),
  1114. delete: createReadonlyMethod("delete" /* DELETE */),
  1115. clear: createReadonlyMethod("clear" /* CLEAR */),
  1116. forEach: createForEach(true, false)
  1117. };
  1118. const shallowReadonlyInstrumentations = {
  1119. get(key) {
  1120. return get$1(this, key, true, true);
  1121. },
  1122. get size() {
  1123. return size(this, true);
  1124. },
  1125. has(key) {
  1126. return has$1.call(this, key, true);
  1127. },
  1128. add: createReadonlyMethod("add" /* ADD */),
  1129. set: createReadonlyMethod("set" /* SET */),
  1130. delete: createReadonlyMethod("delete" /* DELETE */),
  1131. clear: createReadonlyMethod("clear" /* CLEAR */),
  1132. forEach: createForEach(true, true)
  1133. };
  1134. const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
  1135. iteratorMethods.forEach(method => {
  1136. mutableInstrumentations[method] = createIterableMethod(method, false, false);
  1137. readonlyInstrumentations[method] = createIterableMethod(method, true, false);
  1138. shallowInstrumentations[method] = createIterableMethod(method, false, true);
  1139. shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
  1140. });
  1141. return [
  1142. mutableInstrumentations,
  1143. readonlyInstrumentations,
  1144. shallowInstrumentations,
  1145. shallowReadonlyInstrumentations
  1146. ];
  1147. }
  1148. const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/ createInstrumentations();
  1149. function createInstrumentationGetter(isReadonly, shallow) {
  1150. const instrumentations = shallow
  1151. ? isReadonly
  1152. ? shallowReadonlyInstrumentations
  1153. : shallowInstrumentations
  1154. : isReadonly
  1155. ? readonlyInstrumentations
  1156. : mutableInstrumentations;
  1157. return (target, key, receiver) => {
  1158. if (key === "__v_isReactive" /* IS_REACTIVE */) {
  1159. return !isReadonly;
  1160. }
  1161. else if (key === "__v_isReadonly" /* IS_READONLY */) {
  1162. return isReadonly;
  1163. }
  1164. else if (key === "__v_raw" /* RAW */) {
  1165. return target;
  1166. }
  1167. return Reflect.get(hasOwn(instrumentations, key) && key in target
  1168. ? instrumentations
  1169. : target, key, receiver);
  1170. };
  1171. }
  1172. const mutableCollectionHandlers = {
  1173. get: /*#__PURE__*/ createInstrumentationGetter(false, false)
  1174. };
  1175. const shallowCollectionHandlers = {
  1176. get: /*#__PURE__*/ createInstrumentationGetter(false, true)
  1177. };
  1178. const readonlyCollectionHandlers = {
  1179. get: /*#__PURE__*/ createInstrumentationGetter(true, false)
  1180. };
  1181. const shallowReadonlyCollectionHandlers = {
  1182. get: /*#__PURE__*/ createInstrumentationGetter(true, true)
  1183. };
  1184. function checkIdentityKeys(target, has, key) {
  1185. const rawKey = toRaw(key);
  1186. if (rawKey !== key && has.call(target, rawKey)) {
  1187. const type = toRawType(target);
  1188. console.warn(`Reactive ${type} contains both the raw and reactive ` +
  1189. `versions of the same object${type === `Map` ? ` as keys` : ``}, ` +
  1190. `which can lead to inconsistencies. ` +
  1191. `Avoid differentiating between the raw and reactive versions ` +
  1192. `of an object and only use the reactive version if possible.`);
  1193. }
  1194. }
  1195. const reactiveMap = new WeakMap();
  1196. const shallowReactiveMap = new WeakMap();
  1197. const readonlyMap = new WeakMap();
  1198. const shallowReadonlyMap = new WeakMap();
  1199. function targetTypeMap(rawType) {
  1200. switch (rawType) {
  1201. case 'Object':
  1202. case 'Array':
  1203. return 1 /* COMMON */;
  1204. case 'Map':
  1205. case 'Set':
  1206. case 'WeakMap':
  1207. case 'WeakSet':
  1208. return 2 /* COLLECTION */;
  1209. default:
  1210. return 0 /* INVALID */;
  1211. }
  1212. }
  1213. function getTargetType(value) {
  1214. return value["__v_skip" /* SKIP */] || !Object.isExtensible(value)
  1215. ? 0 /* INVALID */
  1216. : targetTypeMap(toRawType(value));
  1217. }
  1218. function reactive(target) {
  1219. // if trying to observe a readonly proxy, return the readonly version.
  1220. if (isReadonly(target)) {
  1221. return target;
  1222. }
  1223. return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
  1224. }
  1225. /**
  1226. * Return a shallowly-reactive copy of the original object, where only the root
  1227. * level properties are reactive. It also does not auto-unwrap refs (even at the
  1228. * root level).
  1229. */
  1230. function shallowReactive(target) {
  1231. return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
  1232. }
  1233. /**
  1234. * Creates a readonly copy of the original object. Note the returned copy is not
  1235. * made reactive, but `readonly` can be called on an already reactive object.
  1236. */
  1237. function readonly(target) {
  1238. return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
  1239. }
  1240. /**
  1241. * Returns a reactive-copy of the original object, where only the root level
  1242. * properties are readonly, and does NOT unwrap refs nor recursively convert
  1243. * returned properties.
  1244. * This is used for creating the props proxy object for stateful components.
  1245. */
  1246. function shallowReadonly(target) {
  1247. return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
  1248. }
  1249. function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
  1250. if (!isObject(target)) {
  1251. {
  1252. console.warn(`value cannot be made reactive: ${String(target)}`);
  1253. }
  1254. return target;
  1255. }
  1256. // target is already a Proxy, return it.
  1257. // exception: calling readonly() on a reactive object
  1258. if (target["__v_raw" /* RAW */] &&
  1259. !(isReadonly && target["__v_isReactive" /* IS_REACTIVE */])) {
  1260. return target;
  1261. }
  1262. // target already has corresponding Proxy
  1263. const existingProxy = proxyMap.get(target);
  1264. if (existingProxy) {
  1265. return existingProxy;
  1266. }
  1267. // only specific value types can be observed.
  1268. const targetType = getTargetType(target);
  1269. if (targetType === 0 /* INVALID */) {
  1270. return target;
  1271. }
  1272. const proxy = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers);
  1273. proxyMap.set(target, proxy);
  1274. return proxy;
  1275. }
  1276. function isReactive(value) {
  1277. if (isReadonly(value)) {
  1278. return isReactive(value["__v_raw" /* RAW */]);
  1279. }
  1280. return !!(value && value["__v_isReactive" /* IS_REACTIVE */]);
  1281. }
  1282. function isReadonly(value) {
  1283. return !!(value && value["__v_isReadonly" /* IS_READONLY */]);
  1284. }
  1285. function isShallow(value) {
  1286. return !!(value && value["__v_isShallow" /* IS_SHALLOW */]);
  1287. }
  1288. function isProxy(value) {
  1289. return isReactive(value) || isReadonly(value);
  1290. }
  1291. function toRaw(observed) {
  1292. const raw = observed && observed["__v_raw" /* RAW */];
  1293. return raw ? toRaw(raw) : observed;
  1294. }
  1295. function markRaw(value) {
  1296. def(value, "__v_skip" /* SKIP */, true);
  1297. return value;
  1298. }
  1299. const toReactive = (value) => isObject(value) ? reactive(value) : value;
  1300. const toReadonly = (value) => isObject(value) ? readonly(value) : value;
  1301. function trackRefValue(ref) {
  1302. if (shouldTrack && activeEffect) {
  1303. ref = toRaw(ref);
  1304. {
  1305. trackEffects(ref.dep || (ref.dep = createDep()), {
  1306. target: ref,
  1307. type: "get" /* GET */,
  1308. key: 'value'
  1309. });
  1310. }
  1311. }
  1312. }
  1313. function triggerRefValue(ref, newVal) {
  1314. ref = toRaw(ref);
  1315. if (ref.dep) {
  1316. {
  1317. triggerEffects(ref.dep, {
  1318. target: ref,
  1319. type: "set" /* SET */,
  1320. key: 'value',
  1321. newValue: newVal
  1322. });
  1323. }
  1324. }
  1325. }
  1326. function isRef(r) {
  1327. return !!(r && r.__v_isRef === true);
  1328. }
  1329. function ref(value) {
  1330. return createRef(value, false);
  1331. }
  1332. function shallowRef(value) {
  1333. return createRef(value, true);
  1334. }
  1335. function createRef(rawValue, shallow) {
  1336. if (isRef(rawValue)) {
  1337. return rawValue;
  1338. }
  1339. return new RefImpl(rawValue, shallow);
  1340. }
  1341. class RefImpl {
  1342. constructor(value, __v_isShallow) {
  1343. this.__v_isShallow = __v_isShallow;
  1344. this.dep = undefined;
  1345. this.__v_isRef = true;
  1346. this._rawValue = __v_isShallow ? value : toRaw(value);
  1347. this._value = __v_isShallow ? value : toReactive(value);
  1348. }
  1349. get value() {
  1350. trackRefValue(this);
  1351. return this._value;
  1352. }
  1353. set value(newVal) {
  1354. newVal = this.__v_isShallow ? newVal : toRaw(newVal);
  1355. if (hasChanged(newVal, this._rawValue)) {
  1356. this._rawValue = newVal;
  1357. this._value = this.__v_isShallow ? newVal : toReactive(newVal);
  1358. triggerRefValue(this, newVal);
  1359. }
  1360. }
  1361. }
  1362. function triggerRef(ref) {
  1363. triggerRefValue(ref, ref.value );
  1364. }
  1365. function unref(ref) {
  1366. return isRef(ref) ? ref.value : ref;
  1367. }
  1368. const shallowUnwrapHandlers = {
  1369. get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
  1370. set: (target, key, value, receiver) => {
  1371. const oldValue = target[key];
  1372. if (isRef(oldValue) && !isRef(value)) {
  1373. oldValue.value = value;
  1374. return true;
  1375. }
  1376. else {
  1377. return Reflect.set(target, key, value, receiver);
  1378. }
  1379. }
  1380. };
  1381. function proxyRefs(objectWithRefs) {
  1382. return isReactive(objectWithRefs)
  1383. ? objectWithRefs
  1384. : new Proxy(objectWithRefs, shallowUnwrapHandlers);
  1385. }
  1386. class CustomRefImpl {
  1387. constructor(factory) {
  1388. this.dep = undefined;
  1389. this.__v_isRef = true;
  1390. const { get, set } = factory(() => trackRefValue(this), () => triggerRefValue(this));
  1391. this._get = get;
  1392. this._set = set;
  1393. }
  1394. get value() {
  1395. return this._get();
  1396. }
  1397. set value(newVal) {
  1398. this._set(newVal);
  1399. }
  1400. }
  1401. function customRef(factory) {
  1402. return new CustomRefImpl(factory);
  1403. }
  1404. function toRefs(object) {
  1405. if (!isProxy(object)) {
  1406. console.warn(`toRefs() expects a reactive object but received a plain one.`);
  1407. }
  1408. const ret = isArray(object) ? new Array(object.length) : {};
  1409. for (const key in object) {
  1410. ret[key] = toRef(object, key);
  1411. }
  1412. return ret;
  1413. }
  1414. class ObjectRefImpl {
  1415. constructor(_object, _key, _defaultValue) {
  1416. this._object = _object;
  1417. this._key = _key;
  1418. this._defaultValue = _defaultValue;
  1419. this.__v_isRef = true;
  1420. }
  1421. get value() {
  1422. const val = this._object[this._key];
  1423. return val === undefined ? this._defaultValue : val;
  1424. }
  1425. set value(newVal) {
  1426. this._object[this._key] = newVal;
  1427. }
  1428. }
  1429. function toRef(object, key, defaultValue) {
  1430. const val = object[key];
  1431. return isRef(val)
  1432. ? val
  1433. : new ObjectRefImpl(object, key, defaultValue);
  1434. }
  1435. class ComputedRefImpl {
  1436. constructor(getter, _setter, isReadonly, isSSR) {
  1437. this._setter = _setter;
  1438. this.dep = undefined;
  1439. this.__v_isRef = true;
  1440. this._dirty = true;
  1441. this.effect = new ReactiveEffect(getter, () => {
  1442. if (!this._dirty) {
  1443. this._dirty = true;
  1444. triggerRefValue(this);
  1445. }
  1446. });
  1447. this.effect.computed = this;
  1448. this.effect.active = this._cacheable = !isSSR;
  1449. this["__v_isReadonly" /* IS_READONLY */] = isReadonly;
  1450. }
  1451. get value() {
  1452. // the computed ref may get wrapped by other proxies e.g. readonly() #3376
  1453. const self = toRaw(this);
  1454. trackRefValue(self);
  1455. if (self._dirty || !self._cacheable) {
  1456. self._dirty = false;
  1457. self._value = self.effect.run();
  1458. }
  1459. return self._value;
  1460. }
  1461. set value(newValue) {
  1462. this._setter(newValue);
  1463. }
  1464. }
  1465. function computed(getterOrOptions, debugOptions, isSSR = false) {
  1466. let getter;
  1467. let setter;
  1468. const onlyGetter = isFunction(getterOrOptions);
  1469. if (onlyGetter) {
  1470. getter = getterOrOptions;
  1471. setter = () => {
  1472. console.warn('Write operation failed: computed value is readonly');
  1473. }
  1474. ;
  1475. }
  1476. else {
  1477. getter = getterOrOptions.get;
  1478. setter = getterOrOptions.set;
  1479. }
  1480. const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
  1481. if (debugOptions && !isSSR) {
  1482. cRef.effect.onTrack = debugOptions.onTrack;
  1483. cRef.effect.onTrigger = debugOptions.onTrigger;
  1484. }
  1485. return cRef;
  1486. }
  1487. const stack = [];
  1488. function pushWarningContext(vnode) {
  1489. stack.push(vnode);
  1490. }
  1491. function popWarningContext() {
  1492. stack.pop();
  1493. }
  1494. function warn$1(msg, ...args) {
  1495. // avoid props formatting or warn handler tracking deps that might be mutated
  1496. // during patch, leading to infinite recursion.
  1497. pauseTracking();
  1498. const instance = stack.length ? stack[stack.length - 1].component : null;
  1499. const appWarnHandler = instance && instance.appContext.config.warnHandler;
  1500. const trace = getComponentTrace();
  1501. if (appWarnHandler) {
  1502. callWithErrorHandling(appWarnHandler, instance, 11 /* APP_WARN_HANDLER */, [
  1503. msg + args.join(''),
  1504. instance && instance.proxy,
  1505. trace
  1506. .map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`)
  1507. .join('\n'),
  1508. trace
  1509. ]);
  1510. }
  1511. else {
  1512. const warnArgs = [`[Vue warn]: ${msg}`, ...args];
  1513. /* istanbul ignore if */
  1514. if (trace.length &&
  1515. // avoid spamming console during tests
  1516. !false) {
  1517. warnArgs.push(`\n`, ...formatTrace(trace));
  1518. }
  1519. console.warn(...warnArgs);
  1520. }
  1521. resetTracking();
  1522. }
  1523. function getComponentTrace() {
  1524. let currentVNode = stack[stack.length - 1];
  1525. if (!currentVNode) {
  1526. return [];
  1527. }
  1528. // we can't just use the stack because it will be incomplete during updates
  1529. // that did not start from the root. Re-construct the parent chain using
  1530. // instance parent pointers.
  1531. const normalizedStack = [];
  1532. while (currentVNode) {
  1533. const last = normalizedStack[0];
  1534. if (last && last.vnode === currentVNode) {
  1535. last.recurseCount++;
  1536. }
  1537. else {
  1538. normalizedStack.push({
  1539. vnode: currentVNode,
  1540. recurseCount: 0
  1541. });
  1542. }
  1543. const parentInstance = currentVNode.component && currentVNode.component.parent;
  1544. currentVNode = parentInstance && parentInstance.vnode;
  1545. }
  1546. return normalizedStack;
  1547. }
  1548. /* istanbul ignore next */
  1549. function formatTrace(trace) {
  1550. const logs = [];
  1551. trace.forEach((entry, i) => {
  1552. logs.push(...(i === 0 ? [] : [`\n`]), ...formatTraceEntry(entry));
  1553. });
  1554. return logs;
  1555. }
  1556. function formatTraceEntry({ vnode, recurseCount }) {
  1557. const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
  1558. const isRoot = vnode.component ? vnode.component.parent == null : false;
  1559. const open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`;
  1560. const close = `>` + postfix;
  1561. return vnode.props
  1562. ? [open, ...formatProps(vnode.props), close]
  1563. : [open + close];
  1564. }
  1565. /* istanbul ignore next */
  1566. function formatProps(props) {
  1567. const res = [];
  1568. const keys = Object.keys(props);
  1569. keys.slice(0, 3).forEach(key => {
  1570. res.push(...formatProp(key, props[key]));
  1571. });
  1572. if (keys.length > 3) {
  1573. res.push(` ...`);
  1574. }
  1575. return res;
  1576. }
  1577. /* istanbul ignore next */
  1578. function formatProp(key, value, raw) {
  1579. if (isString(value)) {
  1580. value = JSON.stringify(value);
  1581. return raw ? value : [`${key}=${value}`];
  1582. }
  1583. else if (typeof value === 'number' ||
  1584. typeof value === 'boolean' ||
  1585. value == null) {
  1586. return raw ? value : [`${key}=${value}`];
  1587. }
  1588. else if (isRef(value)) {
  1589. value = formatProp(key, toRaw(value.value), true);
  1590. return raw ? value : [`${key}=Ref<`, value, `>`];
  1591. }
  1592. else if (isFunction(value)) {
  1593. return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
  1594. }
  1595. else {
  1596. value = toRaw(value);
  1597. return raw ? value : [`${key}=`, value];
  1598. }
  1599. }
  1600. const ErrorTypeStrings = {
  1601. ["sp" /* SERVER_PREFETCH */]: 'serverPrefetch hook',
  1602. ["bc" /* BEFORE_CREATE */]: 'beforeCreate hook',
  1603. ["c" /* CREATED */]: 'created hook',
  1604. ["bm" /* BEFORE_MOUNT */]: 'beforeMount hook',
  1605. ["m" /* MOUNTED */]: 'mounted hook',
  1606. ["bu" /* BEFORE_UPDATE */]: 'beforeUpdate hook',
  1607. ["u" /* UPDATED */]: 'updated',
  1608. ["bum" /* BEFORE_UNMOUNT */]: 'beforeUnmount hook',
  1609. ["um" /* UNMOUNTED */]: 'unmounted hook',
  1610. ["a" /* ACTIVATED */]: 'activated hook',
  1611. ["da" /* DEACTIVATED */]: 'deactivated hook',
  1612. ["ec" /* ERROR_CAPTURED */]: 'errorCaptured hook',
  1613. ["rtc" /* RENDER_TRACKED */]: 'renderTracked hook',
  1614. ["rtg" /* RENDER_TRIGGERED */]: 'renderTriggered hook',
  1615. [0 /* SETUP_FUNCTION */]: 'setup function',
  1616. [1 /* RENDER_FUNCTION */]: 'render function',
  1617. [2 /* WATCH_GETTER */]: 'watcher getter',
  1618. [3 /* WATCH_CALLBACK */]: 'watcher callback',
  1619. [4 /* WATCH_CLEANUP */]: 'watcher cleanup function',
  1620. [5 /* NATIVE_EVENT_HANDLER */]: 'native event handler',
  1621. [6 /* COMPONENT_EVENT_HANDLER */]: 'component event handler',
  1622. [7 /* VNODE_HOOK */]: 'vnode hook',
  1623. [8 /* DIRECTIVE_HOOK */]: 'directive hook',
  1624. [9 /* TRANSITION_HOOK */]: 'transition hook',
  1625. [10 /* APP_ERROR_HANDLER */]: 'app errorHandler',
  1626. [11 /* APP_WARN_HANDLER */]: 'app warnHandler',
  1627. [12 /* FUNCTION_REF */]: 'ref function',
  1628. [13 /* ASYNC_COMPONENT_LOADER */]: 'async component loader',
  1629. [14 /* SCHEDULER */]: 'scheduler flush. This is likely a Vue internals bug. ' +
  1630. 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core'
  1631. };
  1632. function callWithErrorHandling(fn, instance, type, args) {
  1633. let res;
  1634. try {
  1635. res = args ? fn(...args) : fn();
  1636. }
  1637. catch (err) {
  1638. handleError(err, instance, type);
  1639. }
  1640. return res;
  1641. }
  1642. function callWithAsyncErrorHandling(fn, instance, type, args) {
  1643. if (isFunction(fn)) {
  1644. const res = callWithErrorHandling(fn, instance, type, args);
  1645. if (res && isPromise(res)) {
  1646. res.catch(err => {
  1647. handleError(err, instance, type);
  1648. });
  1649. }
  1650. return res;
  1651. }
  1652. const values = [];
  1653. for (let i = 0; i < fn.length; i++) {
  1654. values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
  1655. }
  1656. return values;
  1657. }
  1658. function handleError(err, instance, type, throwInDev = true) {
  1659. const contextVNode = instance ? instance.vnode : null;
  1660. if (instance) {
  1661. let cur = instance.parent;
  1662. // the exposed instance is the render proxy to keep it consistent with 2.x
  1663. const exposedInstance = instance.proxy;
  1664. // in production the hook receives only the error code
  1665. const errorInfo = ErrorTypeStrings[type] ;
  1666. while (cur) {
  1667. const errorCapturedHooks = cur.ec;
  1668. if (errorCapturedHooks) {
  1669. for (let i = 0; i < errorCapturedHooks.length; i++) {
  1670. if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
  1671. return;
  1672. }
  1673. }
  1674. }
  1675. cur = cur.parent;
  1676. }
  1677. // app-level handling
  1678. const appErrorHandler = instance.appContext.config.errorHandler;
  1679. if (appErrorHandler) {
  1680. callWithErrorHandling(appErrorHandler, null, 10 /* APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]);
  1681. return;
  1682. }
  1683. }
  1684. logError(err, type, contextVNode, throwInDev);
  1685. }
  1686. function logError(err, type, contextVNode, throwInDev = true) {
  1687. {
  1688. const info = ErrorTypeStrings[type];
  1689. if (contextVNode) {
  1690. pushWarningContext(contextVNode);
  1691. }
  1692. warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
  1693. if (contextVNode) {
  1694. popWarningContext();
  1695. }
  1696. // crash in dev by default so it's more noticeable
  1697. if (throwInDev) {
  1698. throw err;
  1699. }
  1700. else {
  1701. console.error(err);
  1702. }
  1703. }
  1704. }
  1705. let isFlushing = false;
  1706. let isFlushPending = false;
  1707. const queue = [];
  1708. let flushIndex = 0;
  1709. const pendingPreFlushCbs = [];
  1710. let activePreFlushCbs = null;
  1711. let preFlushIndex = 0;
  1712. const pendingPostFlushCbs = [];
  1713. let activePostFlushCbs = null;
  1714. let postFlushIndex = 0;
  1715. const resolvedPromise = /*#__PURE__*/ Promise.resolve();
  1716. let currentFlushPromise = null;
  1717. let currentPreFlushParentJob = null;
  1718. const RECURSION_LIMIT = 100;
  1719. function nextTick(fn) {
  1720. const p = currentFlushPromise || resolvedPromise;
  1721. return fn ? p.then(this ? fn.bind(this) : fn) : p;
  1722. }
  1723. // #2768
  1724. // Use binary-search to find a suitable position in the queue,
  1725. // so that the queue maintains the increasing order of job's id,
  1726. // which can prevent the job from being skipped and also can avoid repeated patching.
  1727. function findInsertionIndex(id) {
  1728. // the start index should be `flushIndex + 1`
  1729. let start = flushIndex + 1;
  1730. let end = queue.length;
  1731. while (start < end) {
  1732. const middle = (start + end) >>> 1;
  1733. const middleJobId = getId(queue[middle]);
  1734. middleJobId < id ? (start = middle + 1) : (end = middle);
  1735. }
  1736. return start;
  1737. }
  1738. function queueJob(job) {
  1739. // the dedupe search uses the startIndex argument of Array.includes()
  1740. // by default the search index includes the current job that is being run
  1741. // so it cannot recursively trigger itself again.
  1742. // if the job is a watch() callback, the search will start with a +1 index to
  1743. // allow it recursively trigger itself - it is the user's responsibility to
  1744. // ensure it doesn't end up in an infinite loop.
  1745. if ((!queue.length ||
  1746. !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) &&
  1747. job !== currentPreFlushParentJob) {
  1748. if (job.id == null) {
  1749. queue.push(job);
  1750. }
  1751. else {
  1752. queue.splice(findInsertionIndex(job.id), 0, job);
  1753. }
  1754. queueFlush();
  1755. }
  1756. }
  1757. function queueFlush() {
  1758. if (!isFlushing && !isFlushPending) {
  1759. isFlushPending = true;
  1760. currentFlushPromise = resolvedPromise.then(flushJobs);
  1761. }
  1762. }
  1763. function invalidateJob(job) {
  1764. const i = queue.indexOf(job);
  1765. if (i > flushIndex) {
  1766. queue.splice(i, 1);
  1767. }
  1768. }
  1769. function queueCb(cb, activeQueue, pendingQueue, index) {
  1770. if (!isArray(cb)) {
  1771. if (!activeQueue ||
  1772. !activeQueue.includes(cb, cb.allowRecurse ? index + 1 : index)) {
  1773. pendingQueue.push(cb);
  1774. }
  1775. }
  1776. else {
  1777. // if cb is an array, it is a component lifecycle hook which can only be
  1778. // triggered by a job, which is already deduped in the main queue, so
  1779. // we can skip duplicate check here to improve perf
  1780. pendingQueue.push(...cb);
  1781. }
  1782. queueFlush();
  1783. }
  1784. function queuePreFlushCb(cb) {
  1785. queueCb(cb, activePreFlushCbs, pendingPreFlushCbs, preFlushIndex);
  1786. }
  1787. function queuePostFlushCb(cb) {
  1788. queueCb(cb, activePostFlushCbs, pendingPostFlushCbs, postFlushIndex);
  1789. }
  1790. function flushPreFlushCbs(seen, parentJob = null) {
  1791. if (pendingPreFlushCbs.length) {
  1792. currentPreFlushParentJob = parentJob;
  1793. activePreFlushCbs = [...new Set(pendingPreFlushCbs)];
  1794. pendingPreFlushCbs.length = 0;
  1795. {
  1796. seen = seen || new Map();
  1797. }
  1798. for (preFlushIndex = 0; preFlushIndex < activePreFlushCbs.length; preFlushIndex++) {
  1799. if (checkRecursiveUpdates(seen, activePreFlushCbs[preFlushIndex])) {
  1800. continue;
  1801. }
  1802. activePreFlushCbs[preFlushIndex]();
  1803. }
  1804. activePreFlushCbs = null;
  1805. preFlushIndex = 0;
  1806. currentPreFlushParentJob = null;
  1807. // recursively flush until it drains
  1808. flushPreFlushCbs(seen, parentJob);
  1809. }
  1810. }
  1811. function flushPostFlushCbs(seen) {
  1812. // flush any pre cbs queued during the flush (e.g. pre watchers)
  1813. flushPreFlushCbs();
  1814. if (pendingPostFlushCbs.length) {
  1815. const deduped = [...new Set(pendingPostFlushCbs)];
  1816. pendingPostFlushCbs.length = 0;
  1817. // #1947 already has active queue, nested flushPostFlushCbs call
  1818. if (activePostFlushCbs) {
  1819. activePostFlushCbs.push(...deduped);
  1820. return;
  1821. }
  1822. activePostFlushCbs = deduped;
  1823. {
  1824. seen = seen || new Map();
  1825. }
  1826. activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
  1827. for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
  1828. if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
  1829. continue;
  1830. }
  1831. activePostFlushCbs[postFlushIndex]();
  1832. }
  1833. activePostFlushCbs = null;
  1834. postFlushIndex = 0;
  1835. }
  1836. }
  1837. const getId = (job) => job.id == null ? Infinity : job.id;
  1838. function flushJobs(seen) {
  1839. isFlushPending = false;
  1840. isFlushing = true;
  1841. {
  1842. seen = seen || new Map();
  1843. }
  1844. flushPreFlushCbs(seen);
  1845. // Sort queue before flush.
  1846. // This ensures that:
  1847. // 1. Components are updated from parent to child. (because parent is always
  1848. // created before the child so its render effect will have smaller
  1849. // priority number)
  1850. // 2. If a component is unmounted during a parent component's update,
  1851. // its update can be skipped.
  1852. queue.sort((a, b) => getId(a) - getId(b));
  1853. // conditional usage of checkRecursiveUpdate must be determined out of
  1854. // try ... catch block since Rollup by default de-optimizes treeshaking
  1855. // inside try-catch. This can leave all warning code unshaked. Although
  1856. // they would get eventually shaken by a minifier like terser, some minifiers
  1857. // would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610)
  1858. const check = (job) => checkRecursiveUpdates(seen, job)
  1859. ;
  1860. try {
  1861. for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
  1862. const job = queue[flushIndex];
  1863. if (job && job.active !== false) {
  1864. if (true && check(job)) {
  1865. continue;
  1866. }
  1867. // console.log(`running:`, job.id)
  1868. callWithErrorHandling(job, null, 14 /* SCHEDULER */);
  1869. }
  1870. }
  1871. }
  1872. finally {
  1873. flushIndex = 0;
  1874. queue.length = 0;
  1875. flushPostFlushCbs(seen);
  1876. isFlushing = false;
  1877. currentFlushPromise = null;
  1878. // some postFlushCb queued jobs!
  1879. // keep flushing until it drains.
  1880. if (queue.length ||
  1881. pendingPreFlushCbs.length ||
  1882. pendingPostFlushCbs.length) {
  1883. flushJobs(seen);
  1884. }
  1885. }
  1886. }
  1887. function checkRecursiveUpdates(seen, fn) {
  1888. if (!seen.has(fn)) {
  1889. seen.set(fn, 1);
  1890. }
  1891. else {
  1892. const count = seen.get(fn);
  1893. if (count > RECURSION_LIMIT) {
  1894. const instance = fn.ownerInstance;
  1895. const componentName = instance && getComponentName(instance.type);
  1896. warn$1(`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. ` +
  1897. `This means you have a reactive effect that is mutating its own ` +
  1898. `dependencies and thus recursively triggering itself. Possible sources ` +
  1899. `include component template, render function, updated hook or ` +
  1900. `watcher source function.`);
  1901. return true;
  1902. }
  1903. else {
  1904. seen.set(fn, count + 1);
  1905. }
  1906. }
  1907. }
  1908. /* eslint-disable no-restricted-globals */
  1909. let isHmrUpdating = false;
  1910. const hmrDirtyComponents = new Set();
  1911. // Expose the HMR runtime on the global object
  1912. // This makes it entirely tree-shakable without polluting the exports and makes
  1913. // it easier to be used in toolings like vue-loader
  1914. // Note: for a component to be eligible for HMR it also needs the __hmrId option
  1915. // to be set so that its instances can be registered / removed.
  1916. {
  1917. getGlobalThis().__VUE_HMR_RUNTIME__ = {
  1918. createRecord: tryWrap(createRecord),
  1919. rerender: tryWrap(rerender),
  1920. reload: tryWrap(reload)
  1921. };
  1922. }
  1923. const map = new Map();
  1924. function registerHMR(instance) {
  1925. const id = instance.type.__hmrId;
  1926. let record = map.get(id);
  1927. if (!record) {
  1928. createRecord(id, instance.type);
  1929. record = map.get(id);
  1930. }
  1931. record.instances.add(instance);
  1932. }
  1933. function unregisterHMR(instance) {
  1934. map.get(instance.type.__hmrId).instances.delete(instance);
  1935. }
  1936. function createRecord(id, initialDef) {
  1937. if (map.has(id)) {
  1938. return false;
  1939. }
  1940. map.set(id, {
  1941. initialDef: normalizeClassComponent(initialDef),
  1942. instances: new Set()
  1943. });
  1944. return true;
  1945. }
  1946. function normalizeClassComponent(component) {
  1947. return isClassComponent(component) ? component.__vccOpts : component;
  1948. }
  1949. function rerender(id, newRender) {
  1950. const record = map.get(id);
  1951. if (!record) {
  1952. return;
  1953. }
  1954. // update initial record (for not-yet-rendered component)
  1955. record.initialDef.render = newRender;
  1956. [...record.instances].forEach(instance => {
  1957. if (newRender) {
  1958. instance.render = newRender;
  1959. normalizeClassComponent(instance.type).render = newRender;
  1960. }
  1961. instance.renderCache = [];
  1962. // this flag forces child components with slot content to update
  1963. isHmrUpdating = true;
  1964. instance.update();
  1965. isHmrUpdating = false;
  1966. });
  1967. }
  1968. function reload(id, newComp) {
  1969. const record = map.get(id);
  1970. if (!record)
  1971. return;
  1972. newComp = normalizeClassComponent(newComp);
  1973. // update initial def (for not-yet-rendered components)
  1974. updateComponentDef(record.initialDef, newComp);
  1975. // create a snapshot which avoids the set being mutated during updates
  1976. const instances = [...record.instances];
  1977. for (const instance of instances) {
  1978. const oldComp = normalizeClassComponent(instance.type);
  1979. if (!hmrDirtyComponents.has(oldComp)) {
  1980. // 1. Update existing comp definition to match new one
  1981. if (oldComp !== record.initialDef) {
  1982. updateComponentDef(oldComp, newComp);
  1983. }
  1984. // 2. mark definition dirty. This forces the renderer to replace the
  1985. // component on patch.
  1986. hmrDirtyComponents.add(oldComp);
  1987. }
  1988. // 3. invalidate options resolution cache
  1989. instance.appContext.optionsCache.delete(instance.type);
  1990. // 4. actually update
  1991. if (instance.ceReload) {
  1992. // custom element
  1993. hmrDirtyComponents.add(oldComp);
  1994. instance.ceReload(newComp.styles);
  1995. hmrDirtyComponents.delete(oldComp);
  1996. }
  1997. else if (instance.parent) {
  1998. // 4. Force the parent instance to re-render. This will cause all updated
  1999. // components to be unmounted and re-mounted. Queue the update so that we
  2000. // don't end up forcing the same parent to re-render multiple times.
  2001. queueJob(instance.parent.update);
  2002. // instance is the inner component of an async custom element
  2003. // invoke to reset styles
  2004. if (instance.parent.type.__asyncLoader &&
  2005. instance.parent.ceReload) {
  2006. instance.parent.ceReload(newComp.styles);
  2007. }
  2008. }
  2009. else if (instance.appContext.reload) {
  2010. // root instance mounted via createApp() has a reload method
  2011. instance.appContext.reload();
  2012. }
  2013. else if (typeof window !== 'undefined') {
  2014. // root instance inside tree created via raw render(). Force reload.
  2015. window.location.reload();
  2016. }
  2017. else {
  2018. console.warn('[HMR] Root or manually mounted instance modified. Full reload required.');
  2019. }
  2020. }
  2021. // 5. make sure to cleanup dirty hmr components after update
  2022. queuePostFlushCb(() => {
  2023. for (const instance of instances) {
  2024. hmrDirtyComponents.delete(normalizeClassComponent(instance.type));
  2025. }
  2026. });
  2027. }
  2028. function updateComponentDef(oldComp, newComp) {
  2029. extend(oldComp, newComp);
  2030. for (const key in oldComp) {
  2031. if (key !== '__file' && !(key in newComp)) {
  2032. delete oldComp[key];
  2033. }
  2034. }
  2035. }
  2036. function tryWrap(fn) {
  2037. return (id, arg) => {
  2038. try {
  2039. return fn(id, arg);
  2040. }
  2041. catch (e) {
  2042. console.error(e);
  2043. console.warn(`[HMR] Something went wrong during Vue component hot-reload. ` +
  2044. `Full reload required.`);
  2045. }
  2046. };
  2047. }
  2048. let buffer = [];
  2049. let devtoolsNotInstalled = false;
  2050. function emit(event, ...args) {
  2051. if (exports.devtools) {
  2052. exports.devtools.emit(event, ...args);
  2053. }
  2054. else if (!devtoolsNotInstalled) {
  2055. buffer.push({ event, args });
  2056. }
  2057. }
  2058. function setDevtoolsHook(hook, target) {
  2059. var _a, _b;
  2060. exports.devtools = hook;
  2061. if (exports.devtools) {
  2062. exports.devtools.enabled = true;
  2063. buffer.forEach(({ event, args }) => exports.devtools.emit(event, ...args));
  2064. buffer = [];
  2065. }
  2066. else if (
  2067. // handle late devtools injection - only do this if we are in an actual
  2068. // browser environment to avoid the timer handle stalling test runner exit
  2069. // (#4815)
  2070. typeof window !== 'undefined' &&
  2071. // some envs mock window but not fully
  2072. window.HTMLElement &&
  2073. // also exclude jsdom
  2074. !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
  2075. const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
  2076. target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
  2077. replay.push((newHook) => {
  2078. setDevtoolsHook(newHook, target);
  2079. });
  2080. // clear buffer after 3s - the user probably doesn't have devtools installed
  2081. // at all, and keeping the buffer will cause memory leaks (#4738)
  2082. setTimeout(() => {
  2083. if (!exports.devtools) {
  2084. target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
  2085. devtoolsNotInstalled = true;
  2086. buffer = [];
  2087. }
  2088. }, 3000);
  2089. }
  2090. else {
  2091. // non-browser env, assume not installed
  2092. devtoolsNotInstalled = true;
  2093. buffer = [];
  2094. }
  2095. }
  2096. function devtoolsInitApp(app, version) {
  2097. emit("app:init" /* APP_INIT */, app, version, {
  2098. Fragment,
  2099. Text,
  2100. Comment,
  2101. Static
  2102. });
  2103. }
  2104. function devtoolsUnmountApp(app) {
  2105. emit("app:unmount" /* APP_UNMOUNT */, app);
  2106. }
  2107. const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook("component:added" /* COMPONENT_ADDED */);
  2108. const devtoolsComponentUpdated =
  2109. /*#__PURE__*/ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */);
  2110. const devtoolsComponentRemoved =
  2111. /*#__PURE__*/ createDevtoolsComponentHook("component:removed" /* COMPONENT_REMOVED */);
  2112. function createDevtoolsComponentHook(hook) {
  2113. return (component) => {
  2114. emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component);
  2115. };
  2116. }
  2117. const devtoolsPerfStart = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:start" /* PERFORMANCE_START */);
  2118. const devtoolsPerfEnd = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:end" /* PERFORMANCE_END */);
  2119. function createDevtoolsPerformanceHook(hook) {
  2120. return (component, type, time) => {
  2121. emit(hook, component.appContext.app, component.uid, component, type, time);
  2122. };
  2123. }
  2124. function devtoolsComponentEmit(component, event, params) {
  2125. emit("component:emit" /* COMPONENT_EMIT */, component.appContext.app, component, event, params);
  2126. }
  2127. function emit$1(instance, event, ...rawArgs) {
  2128. if (instance.isUnmounted)
  2129. return;
  2130. const props = instance.vnode.props || EMPTY_OBJ;
  2131. {
  2132. const { emitsOptions, propsOptions: [propsOptions] } = instance;
  2133. if (emitsOptions) {
  2134. if (!(event in emitsOptions) &&
  2135. !(false )) {
  2136. if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
  2137. warn$1(`Component emitted event "${event}" but it is neither declared in ` +
  2138. `the emits option nor as an "${toHandlerKey(event)}" prop.`);
  2139. }
  2140. }
  2141. else {
  2142. const validator = emitsOptions[event];
  2143. if (isFunction(validator)) {
  2144. const isValid = validator(...rawArgs);
  2145. if (!isValid) {
  2146. warn$1(`Invalid event arguments: event validation failed for event "${event}".`);
  2147. }
  2148. }
  2149. }
  2150. }
  2151. }
  2152. let args = rawArgs;
  2153. const isModelListener = event.startsWith('update:');
  2154. // for v-model update:xxx events, apply modifiers on args
  2155. const modelArg = isModelListener && event.slice(7);
  2156. if (modelArg && modelArg in props) {
  2157. const modifiersKey = `${modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`;
  2158. const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
  2159. if (trim) {
  2160. args = rawArgs.map(a => a.trim());
  2161. }
  2162. if (number) {
  2163. args = rawArgs.map(toNumber);
  2164. }
  2165. }
  2166. {
  2167. devtoolsComponentEmit(instance, event, args);
  2168. }
  2169. {
  2170. const lowerCaseEvent = event.toLowerCase();
  2171. if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
  2172. warn$1(`Event "${lowerCaseEvent}" is emitted in component ` +
  2173. `${formatComponentName(instance, instance.type)} but the handler is registered for "${event}". ` +
  2174. `Note that HTML attributes are case-insensitive and you cannot use ` +
  2175. `v-on to listen to camelCase events when using in-DOM templates. ` +
  2176. `You should probably use "${hyphenate(event)}" instead of "${event}".`);
  2177. }
  2178. }
  2179. let handlerName;
  2180. let handler = props[(handlerName = toHandlerKey(event))] ||
  2181. // also try camelCase event handler (#2249)
  2182. props[(handlerName = toHandlerKey(camelize(event)))];
  2183. // for v-model update:xxx events, also trigger kebab-case equivalent
  2184. // for props passed via kebab-case
  2185. if (!handler && isModelListener) {
  2186. handler = props[(handlerName = toHandlerKey(hyphenate(event)))];
  2187. }
  2188. if (handler) {
  2189. callWithAsyncErrorHandling(handler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
  2190. }
  2191. const onceHandler = props[handlerName + `Once`];
  2192. if (onceHandler) {
  2193. if (!instance.emitted) {
  2194. instance.emitted = {};
  2195. }
  2196. else if (instance.emitted[handlerName]) {
  2197. return;
  2198. }
  2199. instance.emitted[handlerName] = true;
  2200. callWithAsyncErrorHandling(onceHandler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
  2201. }
  2202. }
  2203. function normalizeEmitsOptions(comp, appContext, asMixin = false) {
  2204. const cache = appContext.emitsCache;
  2205. const cached = cache.get(comp);
  2206. if (cached !== undefined) {
  2207. return cached;
  2208. }
  2209. const raw = comp.emits;
  2210. let normalized = {};
  2211. // apply mixin/extends props
  2212. let hasExtends = false;
  2213. if (!isFunction(comp)) {
  2214. const extendEmits = (raw) => {
  2215. const normalizedFromExtend = normalizeEmitsOptions(raw, appContext, true);
  2216. if (normalizedFromExtend) {
  2217. hasExtends = true;
  2218. extend(normalized, normalizedFromExtend);
  2219. }
  2220. };
  2221. if (!asMixin && appContext.mixins.length) {
  2222. appContext.mixins.forEach(extendEmits);
  2223. }
  2224. if (comp.extends) {
  2225. extendEmits(comp.extends);
  2226. }
  2227. if (comp.mixins) {
  2228. comp.mixins.forEach(extendEmits);
  2229. }
  2230. }
  2231. if (!raw && !hasExtends) {
  2232. cache.set(comp, null);
  2233. return null;
  2234. }
  2235. if (isArray(raw)) {
  2236. raw.forEach(key => (normalized[key] = null));
  2237. }
  2238. else {
  2239. extend(normalized, raw);
  2240. }
  2241. cache.set(comp, normalized);
  2242. return normalized;
  2243. }
  2244. // Check if an incoming prop key is a declared emit event listener.
  2245. // e.g. With `emits: { click: null }`, props named `onClick` and `onclick` are
  2246. // both considered matched listeners.
  2247. function isEmitListener(options, key) {
  2248. if (!options || !isOn(key)) {
  2249. return false;
  2250. }
  2251. key = key.slice(2).replace(/Once$/, '');
  2252. return (hasOwn(options, key[0].toLowerCase() + key.slice(1)) ||
  2253. hasOwn(options, hyphenate(key)) ||
  2254. hasOwn(options, key));
  2255. }
  2256. /**
  2257. * mark the current rendering instance for asset resolution (e.g.
  2258. * resolveComponent, resolveDirective) during render
  2259. */
  2260. let currentRenderingInstance = null;
  2261. let currentScopeId = null;
  2262. /**
  2263. * Note: rendering calls maybe nested. The function returns the parent rendering
  2264. * instance if present, which should be restored after the render is done:
  2265. *
  2266. * ```js
  2267. * const prev = setCurrentRenderingInstance(i)
  2268. * // ...render
  2269. * setCurrentRenderingInstance(prev)
  2270. * ```
  2271. */
  2272. function setCurrentRenderingInstance(instance) {
  2273. const prev = currentRenderingInstance;
  2274. currentRenderingInstance = instance;
  2275. currentScopeId = (instance && instance.type.__scopeId) || null;
  2276. return prev;
  2277. }
  2278. /**
  2279. * Set scope id when creating hoisted vnodes.
  2280. * @private compiler helper
  2281. */
  2282. function pushScopeId(id) {
  2283. currentScopeId = id;
  2284. }
  2285. /**
  2286. * Technically we no longer need this after 3.0.8 but we need to keep the same
  2287. * API for backwards compat w/ code generated by compilers.
  2288. * @private
  2289. */
  2290. function popScopeId() {
  2291. currentScopeId = null;
  2292. }
  2293. /**
  2294. * Only for backwards compat
  2295. * @private
  2296. */
  2297. const withScopeId = (_id) => withCtx;
  2298. /**
  2299. * Wrap a slot function to memoize current rendering instance
  2300. * @private compiler helper
  2301. */
  2302. function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot // false only
  2303. ) {
  2304. if (!ctx)
  2305. return fn;
  2306. // already normalized
  2307. if (fn._n) {
  2308. return fn;
  2309. }
  2310. const renderFnWithContext = (...args) => {
  2311. // If a user calls a compiled slot inside a template expression (#1745), it
  2312. // can mess up block tracking, so by default we disable block tracking and
  2313. // force bail out when invoking a compiled slot (indicated by the ._d flag).
  2314. // This isn't necessary if rendering a compiled `<slot>`, so we flip the
  2315. // ._d flag off when invoking the wrapped fn inside `renderSlot`.
  2316. if (renderFnWithContext._d) {
  2317. setBlockTracking(-1);
  2318. }
  2319. const prevInstance = setCurrentRenderingInstance(ctx);
  2320. const res = fn(...args);
  2321. setCurrentRenderingInstance(prevInstance);
  2322. if (renderFnWithContext._d) {
  2323. setBlockTracking(1);
  2324. }
  2325. {
  2326. devtoolsComponentUpdated(ctx);
  2327. }
  2328. return res;
  2329. };
  2330. // mark normalized to avoid duplicated wrapping
  2331. renderFnWithContext._n = true;
  2332. // mark this as compiled by default
  2333. // this is used in vnode.ts -> normalizeChildren() to set the slot
  2334. // rendering flag.
  2335. renderFnWithContext._c = true;
  2336. // disable block tracking by default
  2337. renderFnWithContext._d = true;
  2338. return renderFnWithContext;
  2339. }
  2340. /**
  2341. * dev only flag to track whether $attrs was used during render.
  2342. * If $attrs was used during render then the warning for failed attrs
  2343. * fallthrough can be suppressed.
  2344. */
  2345. let accessedAttrs = false;
  2346. function markAttrsAccessed() {
  2347. accessedAttrs = true;
  2348. }
  2349. function renderComponentRoot(instance) {
  2350. const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
  2351. let result;
  2352. let fallthroughAttrs;
  2353. const prev = setCurrentRenderingInstance(instance);
  2354. {
  2355. accessedAttrs = false;
  2356. }
  2357. try {
  2358. if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
  2359. // withProxy is a proxy with a different `has` trap only for
  2360. // runtime-compiled render functions using `with` block.
  2361. const proxyToUse = withProxy || proxy;
  2362. result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));
  2363. fallthroughAttrs = attrs;
  2364. }
  2365. else {
  2366. // functional
  2367. const render = Component;
  2368. // in dev, mark attrs accessed if optional props (attrs === props)
  2369. if (true && attrs === props) {
  2370. markAttrsAccessed();
  2371. }
  2372. result = normalizeVNode(render.length > 1
  2373. ? render(props, true
  2374. ? {
  2375. get attrs() {
  2376. markAttrsAccessed();
  2377. return attrs;
  2378. },
  2379. slots,
  2380. emit
  2381. }
  2382. : { attrs, slots, emit })
  2383. : render(props, null /* we know it doesn't need it */));
  2384. fallthroughAttrs = Component.props
  2385. ? attrs
  2386. : getFunctionalFallthrough(attrs);
  2387. }
  2388. }
  2389. catch (err) {
  2390. blockStack.length = 0;
  2391. handleError(err, instance, 1 /* RENDER_FUNCTION */);
  2392. result = createVNode(Comment);
  2393. }
  2394. // attr merging
  2395. // in dev mode, comments are preserved, and it's possible for a template
  2396. // to have comments along side the root element which makes it a fragment
  2397. let root = result;
  2398. let setRoot = undefined;
  2399. if (result.patchFlag > 0 &&
  2400. result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
  2401. [root, setRoot] = getChildRoot(result);
  2402. }
  2403. if (fallthroughAttrs && inheritAttrs !== false) {
  2404. const keys = Object.keys(fallthroughAttrs);
  2405. const { shapeFlag } = root;
  2406. if (keys.length) {
  2407. if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
  2408. if (propsOptions && keys.some(isModelListener)) {
  2409. // If a v-model listener (onUpdate:xxx) has a corresponding declared
  2410. // prop, it indicates this component expects to handle v-model and
  2411. // it should not fallthrough.
  2412. // related: #1543, #1643, #1989
  2413. fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
  2414. }
  2415. root = cloneVNode(root, fallthroughAttrs);
  2416. }
  2417. else if (!accessedAttrs && root.type !== Comment) {
  2418. const allAttrs = Object.keys(attrs);
  2419. const eventAttrs = [];
  2420. const extraAttrs = [];
  2421. for (let i = 0, l = allAttrs.length; i < l; i++) {
  2422. const key = allAttrs[i];
  2423. if (isOn(key)) {
  2424. // ignore v-model handlers when they fail to fallthrough
  2425. if (!isModelListener(key)) {
  2426. // remove `on`, lowercase first letter to reflect event casing
  2427. // accurately
  2428. eventAttrs.push(key[2].toLowerCase() + key.slice(3));
  2429. }
  2430. }
  2431. else {
  2432. extraAttrs.push(key);
  2433. }
  2434. }
  2435. if (extraAttrs.length) {
  2436. warn$1(`Extraneous non-props attributes (` +
  2437. `${extraAttrs.join(', ')}) ` +
  2438. `were passed to component but could not be automatically inherited ` +
  2439. `because component renders fragment or text root nodes.`);
  2440. }
  2441. if (eventAttrs.length) {
  2442. warn$1(`Extraneous non-emits event listeners (` +
  2443. `${eventAttrs.join(', ')}) ` +
  2444. `were passed to component but could not be automatically inherited ` +
  2445. `because component renders fragment or text root nodes. ` +
  2446. `If the listener is intended to be a component custom event listener only, ` +
  2447. `declare it using the "emits" option.`);
  2448. }
  2449. }
  2450. }
  2451. }
  2452. // inherit directives
  2453. if (vnode.dirs) {
  2454. if (!isElementRoot(root)) {
  2455. warn$1(`Runtime directive used on component with non-element root node. ` +
  2456. `The directives will not function as intended.`);
  2457. }
  2458. // clone before mutating since the root may be a hoisted vnode
  2459. root = cloneVNode(root);
  2460. root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
  2461. }
  2462. // inherit transition data
  2463. if (vnode.transition) {
  2464. if (!isElementRoot(root)) {
  2465. warn$1(`Component inside <Transition> renders non-element root node ` +
  2466. `that cannot be animated.`);
  2467. }
  2468. root.transition = vnode.transition;
  2469. }
  2470. if (setRoot) {
  2471. setRoot(root);
  2472. }
  2473. else {
  2474. result = root;
  2475. }
  2476. setCurrentRenderingInstance(prev);
  2477. return result;
  2478. }
  2479. /**
  2480. * dev only
  2481. * In dev mode, template root level comments are rendered, which turns the
  2482. * template into a fragment root, but we need to locate the single element
  2483. * root for attrs and scope id processing.
  2484. */
  2485. const getChildRoot = (vnode) => {
  2486. const rawChildren = vnode.children;
  2487. const dynamicChildren = vnode.dynamicChildren;
  2488. const childRoot = filterSingleRoot(rawChildren);
  2489. if (!childRoot) {
  2490. return [vnode, undefined];
  2491. }
  2492. const index = rawChildren.indexOf(childRoot);
  2493. const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
  2494. const setRoot = (updatedRoot) => {
  2495. rawChildren[index] = updatedRoot;
  2496. if (dynamicChildren) {
  2497. if (dynamicIndex > -1) {
  2498. dynamicChildren[dynamicIndex] = updatedRoot;
  2499. }
  2500. else if (updatedRoot.patchFlag > 0) {
  2501. vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
  2502. }
  2503. }
  2504. };
  2505. return [normalizeVNode(childRoot), setRoot];
  2506. };
  2507. function filterSingleRoot(children) {
  2508. let singleRoot;
  2509. for (let i = 0; i < children.length; i++) {
  2510. const child = children[i];
  2511. if (isVNode(child)) {
  2512. // ignore user comment
  2513. if (child.type !== Comment || child.children === 'v-if') {
  2514. if (singleRoot) {
  2515. // has more than 1 non-comment child, return now
  2516. return;
  2517. }
  2518. else {
  2519. singleRoot = child;
  2520. }
  2521. }
  2522. }
  2523. else {
  2524. return;
  2525. }
  2526. }
  2527. return singleRoot;
  2528. }
  2529. const getFunctionalFallthrough = (attrs) => {
  2530. let res;
  2531. for (const key in attrs) {
  2532. if (key === 'class' || key === 'style' || isOn(key)) {
  2533. (res || (res = {}))[key] = attrs[key];
  2534. }
  2535. }
  2536. return res;
  2537. };
  2538. const filterModelListeners = (attrs, props) => {
  2539. const res = {};
  2540. for (const key in attrs) {
  2541. if (!isModelListener(key) || !(key.slice(9) in props)) {
  2542. res[key] = attrs[key];
  2543. }
  2544. }
  2545. return res;
  2546. };
  2547. const isElementRoot = (vnode) => {
  2548. return (vnode.shapeFlag & (6 /* COMPONENT */ | 1 /* ELEMENT */) ||
  2549. vnode.type === Comment // potential v-if branch switch
  2550. );
  2551. };
  2552. function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
  2553. const { props: prevProps, children: prevChildren, component } = prevVNode;
  2554. const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
  2555. const emits = component.emitsOptions;
  2556. // Parent component's render function was hot-updated. Since this may have
  2557. // caused the child component's slots content to have changed, we need to
  2558. // force the child to update as well.
  2559. if ((prevChildren || nextChildren) && isHmrUpdating) {
  2560. return true;
  2561. }
  2562. // force child update for runtime directive or transition on component vnode.
  2563. if (nextVNode.dirs || nextVNode.transition) {
  2564. return true;
  2565. }
  2566. if (optimized && patchFlag >= 0) {
  2567. if (patchFlag & 1024 /* DYNAMIC_SLOTS */) {
  2568. // slot content that references values that might have changed,
  2569. // e.g. in a v-for
  2570. return true;
  2571. }
  2572. if (patchFlag & 16 /* FULL_PROPS */) {
  2573. if (!prevProps) {
  2574. return !!nextProps;
  2575. }
  2576. // presence of this flag indicates props are always non-null
  2577. return hasPropsChanged(prevProps, nextProps, emits);
  2578. }
  2579. else if (patchFlag & 8 /* PROPS */) {
  2580. const dynamicProps = nextVNode.dynamicProps;
  2581. for (let i = 0; i < dynamicProps.length; i++) {
  2582. const key = dynamicProps[i];
  2583. if (nextProps[key] !== prevProps[key] &&
  2584. !isEmitListener(emits, key)) {
  2585. return true;
  2586. }
  2587. }
  2588. }
  2589. }
  2590. else {
  2591. // this path is only taken by manually written render functions
  2592. // so presence of any children leads to a forced update
  2593. if (prevChildren || nextChildren) {
  2594. if (!nextChildren || !nextChildren.$stable) {
  2595. return true;
  2596. }
  2597. }
  2598. if (prevProps === nextProps) {
  2599. return false;
  2600. }
  2601. if (!prevProps) {
  2602. return !!nextProps;
  2603. }
  2604. if (!nextProps) {
  2605. return true;
  2606. }
  2607. return hasPropsChanged(prevProps, nextProps, emits);
  2608. }
  2609. return false;
  2610. }
  2611. function hasPropsChanged(prevProps, nextProps, emitsOptions) {
  2612. const nextKeys = Object.keys(nextProps);
  2613. if (nextKeys.length !== Object.keys(prevProps).length) {
  2614. return true;
  2615. }
  2616. for (let i = 0; i < nextKeys.length; i++) {
  2617. const key = nextKeys[i];
  2618. if (nextProps[key] !== prevProps[key] &&
  2619. !isEmitListener(emitsOptions, key)) {
  2620. return true;
  2621. }
  2622. }
  2623. return false;
  2624. }
  2625. function updateHOCHostEl({ vnode, parent }, el // HostNode
  2626. ) {
  2627. while (parent && parent.subTree === vnode) {
  2628. (vnode = parent.vnode).el = el;
  2629. parent = parent.parent;
  2630. }
  2631. }
  2632. const isSuspense = (type) => type.__isSuspense;
  2633. // Suspense exposes a component-like API, and is treated like a component
  2634. // in the compiler, but internally it's a special built-in type that hooks
  2635. // directly into the renderer.
  2636. const SuspenseImpl = {
  2637. name: 'Suspense',
  2638. // In order to make Suspense tree-shakable, we need to avoid importing it
  2639. // directly in the renderer. The renderer checks for the __isSuspense flag
  2640. // on a vnode's type and calls the `process` method, passing in renderer
  2641. // internals.
  2642. __isSuspense: true,
  2643. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized,
  2644. // platform-specific impl passed from renderer
  2645. rendererInternals) {
  2646. if (n1 == null) {
  2647. mountSuspense(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals);
  2648. }
  2649. else {
  2650. patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, rendererInternals);
  2651. }
  2652. },
  2653. hydrate: hydrateSuspense,
  2654. create: createSuspenseBoundary,
  2655. normalize: normalizeSuspenseChildren
  2656. };
  2657. // Force-casted public typing for h and TSX props inference
  2658. const Suspense = (SuspenseImpl );
  2659. function triggerEvent(vnode, name) {
  2660. const eventListener = vnode.props && vnode.props[name];
  2661. if (isFunction(eventListener)) {
  2662. eventListener();
  2663. }
  2664. }
  2665. function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
  2666. const { p: patch, o: { createElement } } = rendererInternals;
  2667. const hiddenContainer = createElement('div');
  2668. const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals));
  2669. // start mounting the content subtree in an off-dom container
  2670. patch(null, (suspense.pendingBranch = vnode.ssContent), hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds);
  2671. // now check if we have encountered any async deps
  2672. if (suspense.deps > 0) {
  2673. // has async
  2674. // invoke @fallback event
  2675. triggerEvent(vnode, 'onPending');
  2676. triggerEvent(vnode, 'onFallback');
  2677. // mount the fallback tree
  2678. patch(null, vnode.ssFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2679. isSVG, slotScopeIds);
  2680. setActiveBranch(suspense, vnode.ssFallback);
  2681. }
  2682. else {
  2683. // Suspense has no async deps. Just resolve.
  2684. suspense.resolve();
  2685. }
  2686. }
  2687. function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
  2688. const suspense = (n2.suspense = n1.suspense);
  2689. suspense.vnode = n2;
  2690. n2.el = n1.el;
  2691. const newBranch = n2.ssContent;
  2692. const newFallback = n2.ssFallback;
  2693. const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
  2694. if (pendingBranch) {
  2695. suspense.pendingBranch = newBranch;
  2696. if (isSameVNodeType(newBranch, pendingBranch)) {
  2697. // same root type but content may have changed.
  2698. patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2699. if (suspense.deps <= 0) {
  2700. suspense.resolve();
  2701. }
  2702. else if (isInFallback) {
  2703. patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2704. isSVG, slotScopeIds, optimized);
  2705. setActiveBranch(suspense, newFallback);
  2706. }
  2707. }
  2708. else {
  2709. // toggled before pending tree is resolved
  2710. suspense.pendingId++;
  2711. if (isHydrating) {
  2712. // if toggled before hydration is finished, the current DOM tree is
  2713. // no longer valid. set it as the active branch so it will be unmounted
  2714. // when resolved
  2715. suspense.isHydrating = false;
  2716. suspense.activeBranch = pendingBranch;
  2717. }
  2718. else {
  2719. unmount(pendingBranch, parentComponent, suspense);
  2720. }
  2721. // increment pending ID. this is used to invalidate async callbacks
  2722. // reset suspense state
  2723. suspense.deps = 0;
  2724. // discard effects from pending branch
  2725. suspense.effects.length = 0;
  2726. // discard previous container
  2727. suspense.hiddenContainer = createElement('div');
  2728. if (isInFallback) {
  2729. // already in fallback state
  2730. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2731. if (suspense.deps <= 0) {
  2732. suspense.resolve();
  2733. }
  2734. else {
  2735. patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2736. isSVG, slotScopeIds, optimized);
  2737. setActiveBranch(suspense, newFallback);
  2738. }
  2739. }
  2740. else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2741. // toggled "back" to current active branch
  2742. patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2743. // force resolve
  2744. suspense.resolve(true);
  2745. }
  2746. else {
  2747. // switched to a 3rd branch
  2748. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2749. if (suspense.deps <= 0) {
  2750. suspense.resolve();
  2751. }
  2752. }
  2753. }
  2754. }
  2755. else {
  2756. if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
  2757. // root did not change, just normal patch
  2758. patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2759. setActiveBranch(suspense, newBranch);
  2760. }
  2761. else {
  2762. // root node toggled
  2763. // invoke @pending event
  2764. triggerEvent(n2, 'onPending');
  2765. // mount pending branch in off-dom container
  2766. suspense.pendingBranch = newBranch;
  2767. suspense.pendingId++;
  2768. patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
  2769. if (suspense.deps <= 0) {
  2770. // incoming branch has no async deps, resolve now.
  2771. suspense.resolve();
  2772. }
  2773. else {
  2774. const { timeout, pendingId } = suspense;
  2775. if (timeout > 0) {
  2776. setTimeout(() => {
  2777. if (suspense.pendingId === pendingId) {
  2778. suspense.fallback(newFallback);
  2779. }
  2780. }, timeout);
  2781. }
  2782. else if (timeout === 0) {
  2783. suspense.fallback(newFallback);
  2784. }
  2785. }
  2786. }
  2787. }
  2788. }
  2789. let hasWarned = false;
  2790. function createSuspenseBoundary(vnode, parent, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
  2791. /* istanbul ignore if */
  2792. if (!hasWarned) {
  2793. hasWarned = true;
  2794. // @ts-ignore `console.info` cannot be null error
  2795. console[console.info ? 'info' : 'log'](`<Suspense> is an experimental feature and its API will likely change.`);
  2796. }
  2797. const { p: patch, m: move, um: unmount, n: next, o: { parentNode, remove } } = rendererInternals;
  2798. const timeout = toNumber(vnode.props && vnode.props.timeout);
  2799. const suspense = {
  2800. vnode,
  2801. parent,
  2802. parentComponent,
  2803. isSVG,
  2804. container,
  2805. hiddenContainer,
  2806. anchor,
  2807. deps: 0,
  2808. pendingId: 0,
  2809. timeout: typeof timeout === 'number' ? timeout : -1,
  2810. activeBranch: null,
  2811. pendingBranch: null,
  2812. isInFallback: true,
  2813. isHydrating,
  2814. isUnmounted: false,
  2815. effects: [],
  2816. resolve(resume = false) {
  2817. {
  2818. if (!resume && !suspense.pendingBranch) {
  2819. throw new Error(`suspense.resolve() is called without a pending branch.`);
  2820. }
  2821. if (suspense.isUnmounted) {
  2822. throw new Error(`suspense.resolve() is called on an already unmounted suspense boundary.`);
  2823. }
  2824. }
  2825. const { vnode, activeBranch, pendingBranch, pendingId, effects, parentComponent, container } = suspense;
  2826. if (suspense.isHydrating) {
  2827. suspense.isHydrating = false;
  2828. }
  2829. else if (!resume) {
  2830. const delayEnter = activeBranch &&
  2831. pendingBranch.transition &&
  2832. pendingBranch.transition.mode === 'out-in';
  2833. if (delayEnter) {
  2834. activeBranch.transition.afterLeave = () => {
  2835. if (pendingId === suspense.pendingId) {
  2836. move(pendingBranch, container, anchor, 0 /* ENTER */);
  2837. }
  2838. };
  2839. }
  2840. // this is initial anchor on mount
  2841. let { anchor } = suspense;
  2842. // unmount current active tree
  2843. if (activeBranch) {
  2844. // if the fallback tree was mounted, it may have been moved
  2845. // as part of a parent suspense. get the latest anchor for insertion
  2846. anchor = next(activeBranch);
  2847. unmount(activeBranch, parentComponent, suspense, true);
  2848. }
  2849. if (!delayEnter) {
  2850. // move content from off-dom container to actual container
  2851. move(pendingBranch, container, anchor, 0 /* ENTER */);
  2852. }
  2853. }
  2854. setActiveBranch(suspense, pendingBranch);
  2855. suspense.pendingBranch = null;
  2856. suspense.isInFallback = false;
  2857. // flush buffered effects
  2858. // check if there is a pending parent suspense
  2859. let parent = suspense.parent;
  2860. let hasUnresolvedAncestor = false;
  2861. while (parent) {
  2862. if (parent.pendingBranch) {
  2863. // found a pending parent suspense, merge buffered post jobs
  2864. // into that parent
  2865. parent.effects.push(...effects);
  2866. hasUnresolvedAncestor = true;
  2867. break;
  2868. }
  2869. parent = parent.parent;
  2870. }
  2871. // no pending parent suspense, flush all jobs
  2872. if (!hasUnresolvedAncestor) {
  2873. queuePostFlushCb(effects);
  2874. }
  2875. suspense.effects = [];
  2876. // invoke @resolve event
  2877. triggerEvent(vnode, 'onResolve');
  2878. },
  2879. fallback(fallbackVNode) {
  2880. if (!suspense.pendingBranch) {
  2881. return;
  2882. }
  2883. const { vnode, activeBranch, parentComponent, container, isSVG } = suspense;
  2884. // invoke @fallback event
  2885. triggerEvent(vnode, 'onFallback');
  2886. const anchor = next(activeBranch);
  2887. const mountFallback = () => {
  2888. if (!suspense.isInFallback) {
  2889. return;
  2890. }
  2891. // mount the fallback tree
  2892. patch(null, fallbackVNode, container, anchor, parentComponent, null, // fallback tree will not have suspense context
  2893. isSVG, slotScopeIds, optimized);
  2894. setActiveBranch(suspense, fallbackVNode);
  2895. };
  2896. const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === 'out-in';
  2897. if (delayEnter) {
  2898. activeBranch.transition.afterLeave = mountFallback;
  2899. }
  2900. suspense.isInFallback = true;
  2901. // unmount current active branch
  2902. unmount(activeBranch, parentComponent, null, // no suspense so unmount hooks fire now
  2903. true // shouldRemove
  2904. );
  2905. if (!delayEnter) {
  2906. mountFallback();
  2907. }
  2908. },
  2909. move(container, anchor, type) {
  2910. suspense.activeBranch &&
  2911. move(suspense.activeBranch, container, anchor, type);
  2912. suspense.container = container;
  2913. },
  2914. next() {
  2915. return suspense.activeBranch && next(suspense.activeBranch);
  2916. },
  2917. registerDep(instance, setupRenderEffect) {
  2918. const isInPendingSuspense = !!suspense.pendingBranch;
  2919. if (isInPendingSuspense) {
  2920. suspense.deps++;
  2921. }
  2922. const hydratedEl = instance.vnode.el;
  2923. instance
  2924. .asyncDep.catch(err => {
  2925. handleError(err, instance, 0 /* SETUP_FUNCTION */);
  2926. })
  2927. .then(asyncSetupResult => {
  2928. // retry when the setup() promise resolves.
  2929. // component may have been unmounted before resolve.
  2930. if (instance.isUnmounted ||
  2931. suspense.isUnmounted ||
  2932. suspense.pendingId !== instance.suspenseId) {
  2933. return;
  2934. }
  2935. // retry from this component
  2936. instance.asyncResolved = true;
  2937. const { vnode } = instance;
  2938. {
  2939. pushWarningContext(vnode);
  2940. }
  2941. handleSetupResult(instance, asyncSetupResult, false);
  2942. if (hydratedEl) {
  2943. // vnode may have been replaced if an update happened before the
  2944. // async dep is resolved.
  2945. vnode.el = hydratedEl;
  2946. }
  2947. const placeholder = !hydratedEl && instance.subTree.el;
  2948. setupRenderEffect(instance, vnode,
  2949. // component may have been moved before resolve.
  2950. // if this is not a hydration, instance.subTree will be the comment
  2951. // placeholder.
  2952. parentNode(hydratedEl || instance.subTree.el),
  2953. // anchor will not be used if this is hydration, so only need to
  2954. // consider the comment placeholder case.
  2955. hydratedEl ? null : next(instance.subTree), suspense, isSVG, optimized);
  2956. if (placeholder) {
  2957. remove(placeholder);
  2958. }
  2959. updateHOCHostEl(instance, vnode.el);
  2960. {
  2961. popWarningContext();
  2962. }
  2963. // only decrease deps count if suspense is not already resolved
  2964. if (isInPendingSuspense && --suspense.deps === 0) {
  2965. suspense.resolve();
  2966. }
  2967. });
  2968. },
  2969. unmount(parentSuspense, doRemove) {
  2970. suspense.isUnmounted = true;
  2971. if (suspense.activeBranch) {
  2972. unmount(suspense.activeBranch, parentComponent, parentSuspense, doRemove);
  2973. }
  2974. if (suspense.pendingBranch) {
  2975. unmount(suspense.pendingBranch, parentComponent, parentSuspense, doRemove);
  2976. }
  2977. }
  2978. };
  2979. return suspense;
  2980. }
  2981. function hydrateSuspense(node, vnode, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals, hydrateNode) {
  2982. /* eslint-disable no-restricted-globals */
  2983. const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, node.parentNode, document.createElement('div'), null, isSVG, slotScopeIds, optimized, rendererInternals, true /* hydrating */));
  2984. // there are two possible scenarios for server-rendered suspense:
  2985. // - success: ssr content should be fully resolved
  2986. // - failure: ssr content should be the fallback branch.
  2987. // however, on the client we don't really know if it has failed or not
  2988. // attempt to hydrate the DOM assuming it has succeeded, but we still
  2989. // need to construct a suspense boundary first
  2990. const result = hydrateNode(node, (suspense.pendingBranch = vnode.ssContent), parentComponent, suspense, slotScopeIds, optimized);
  2991. if (suspense.deps === 0) {
  2992. suspense.resolve();
  2993. }
  2994. return result;
  2995. /* eslint-enable no-restricted-globals */
  2996. }
  2997. function normalizeSuspenseChildren(vnode) {
  2998. const { shapeFlag, children } = vnode;
  2999. const isSlotChildren = shapeFlag & 32 /* SLOTS_CHILDREN */;
  3000. vnode.ssContent = normalizeSuspenseSlot(isSlotChildren ? children.default : children);
  3001. vnode.ssFallback = isSlotChildren
  3002. ? normalizeSuspenseSlot(children.fallback)
  3003. : createVNode(Comment);
  3004. }
  3005. function normalizeSuspenseSlot(s) {
  3006. let block;
  3007. if (isFunction(s)) {
  3008. const trackBlock = isBlockTreeEnabled && s._c;
  3009. if (trackBlock) {
  3010. // disableTracking: false
  3011. // allow block tracking for compiled slots
  3012. // (see ./componentRenderContext.ts)
  3013. s._d = false;
  3014. openBlock();
  3015. }
  3016. s = s();
  3017. if (trackBlock) {
  3018. s._d = true;
  3019. block = currentBlock;
  3020. closeBlock();
  3021. }
  3022. }
  3023. if (isArray(s)) {
  3024. const singleChild = filterSingleRoot(s);
  3025. if (!singleChild) {
  3026. warn$1(`<Suspense> slots expect a single root node.`);
  3027. }
  3028. s = singleChild;
  3029. }
  3030. s = normalizeVNode(s);
  3031. if (block && !s.dynamicChildren) {
  3032. s.dynamicChildren = block.filter(c => c !== s);
  3033. }
  3034. return s;
  3035. }
  3036. function queueEffectWithSuspense(fn, suspense) {
  3037. if (suspense && suspense.pendingBranch) {
  3038. if (isArray(fn)) {
  3039. suspense.effects.push(...fn);
  3040. }
  3041. else {
  3042. suspense.effects.push(fn);
  3043. }
  3044. }
  3045. else {
  3046. queuePostFlushCb(fn);
  3047. }
  3048. }
  3049. function setActiveBranch(suspense, branch) {
  3050. suspense.activeBranch = branch;
  3051. const { vnode, parentComponent } = suspense;
  3052. const el = (vnode.el = branch.el);
  3053. // in case suspense is the root node of a component,
  3054. // recursively update the HOC el
  3055. if (parentComponent && parentComponent.subTree === vnode) {
  3056. parentComponent.vnode.el = el;
  3057. updateHOCHostEl(parentComponent, el);
  3058. }
  3059. }
  3060. function provide(key, value) {
  3061. if (!currentInstance) {
  3062. {
  3063. warn$1(`provide() can only be used inside setup().`);
  3064. }
  3065. }
  3066. else {
  3067. let provides = currentInstance.provides;
  3068. // by default an instance inherits its parent's provides object
  3069. // but when it needs to provide values of its own, it creates its
  3070. // own provides object using parent provides object as prototype.
  3071. // this way in `inject` we can simply look up injections from direct
  3072. // parent and let the prototype chain do the work.
  3073. const parentProvides = currentInstance.parent && currentInstance.parent.provides;
  3074. if (parentProvides === provides) {
  3075. provides = currentInstance.provides = Object.create(parentProvides);
  3076. }
  3077. // TS doesn't allow symbol as index type
  3078. provides[key] = value;
  3079. }
  3080. }
  3081. function inject(key, defaultValue, treatDefaultAsFactory = false) {
  3082. // fallback to `currentRenderingInstance` so that this can be called in
  3083. // a functional component
  3084. const instance = currentInstance || currentRenderingInstance;
  3085. if (instance) {
  3086. // #2400
  3087. // to support `app.use` plugins,
  3088. // fallback to appContext's `provides` if the instance is at root
  3089. const provides = instance.parent == null
  3090. ? instance.vnode.appContext && instance.vnode.appContext.provides
  3091. : instance.parent.provides;
  3092. if (provides && key in provides) {
  3093. // TS doesn't allow symbol as index type
  3094. return provides[key];
  3095. }
  3096. else if (arguments.length > 1) {
  3097. return treatDefaultAsFactory && isFunction(defaultValue)
  3098. ? defaultValue.call(instance.proxy)
  3099. : defaultValue;
  3100. }
  3101. else {
  3102. warn$1(`injection "${String(key)}" not found.`);
  3103. }
  3104. }
  3105. else {
  3106. warn$1(`inject() can only be used inside setup() or functional components.`);
  3107. }
  3108. }
  3109. // Simple effect.
  3110. function watchEffect(effect, options) {
  3111. return doWatch(effect, null, options);
  3112. }
  3113. function watchPostEffect(effect, options) {
  3114. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
  3115. }
  3116. function watchSyncEffect(effect, options) {
  3117. return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
  3118. }
  3119. // initial value for watchers to trigger on undefined initial values
  3120. const INITIAL_WATCHER_VALUE = {};
  3121. // implementation
  3122. function watch(source, cb, options) {
  3123. if (!isFunction(cb)) {
  3124. warn$1(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
  3125. `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
  3126. `supports \`watch(source, cb, options?) signature.`);
  3127. }
  3128. return doWatch(source, cb, options);
  3129. }
  3130. function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
  3131. if (!cb) {
  3132. if (immediate !== undefined) {
  3133. warn$1(`watch() "immediate" option is only respected when using the ` +
  3134. `watch(source, callback, options?) signature.`);
  3135. }
  3136. if (deep !== undefined) {
  3137. warn$1(`watch() "deep" option is only respected when using the ` +
  3138. `watch(source, callback, options?) signature.`);
  3139. }
  3140. }
  3141. const warnInvalidSource = (s) => {
  3142. warn$1(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, ` +
  3143. `a reactive object, or an array of these types.`);
  3144. };
  3145. const instance = currentInstance;
  3146. let getter;
  3147. let forceTrigger = false;
  3148. let isMultiSource = false;
  3149. if (isRef(source)) {
  3150. getter = () => source.value;
  3151. forceTrigger = isShallow(source);
  3152. }
  3153. else if (isReactive(source)) {
  3154. getter = () => source;
  3155. deep = true;
  3156. }
  3157. else if (isArray(source)) {
  3158. isMultiSource = true;
  3159. forceTrigger = source.some(s => isReactive(s) || isShallow(s));
  3160. getter = () => source.map(s => {
  3161. if (isRef(s)) {
  3162. return s.value;
  3163. }
  3164. else if (isReactive(s)) {
  3165. return traverse(s);
  3166. }
  3167. else if (isFunction(s)) {
  3168. return callWithErrorHandling(s, instance, 2 /* WATCH_GETTER */);
  3169. }
  3170. else {
  3171. warnInvalidSource(s);
  3172. }
  3173. });
  3174. }
  3175. else if (isFunction(source)) {
  3176. if (cb) {
  3177. // getter with cb
  3178. getter = () => callWithErrorHandling(source, instance, 2 /* WATCH_GETTER */);
  3179. }
  3180. else {
  3181. // no cb -> simple effect
  3182. getter = () => {
  3183. if (instance && instance.isUnmounted) {
  3184. return;
  3185. }
  3186. if (cleanup) {
  3187. cleanup();
  3188. }
  3189. return callWithAsyncErrorHandling(source, instance, 3 /* WATCH_CALLBACK */, [onCleanup]);
  3190. };
  3191. }
  3192. }
  3193. else {
  3194. getter = NOOP;
  3195. warnInvalidSource(source);
  3196. }
  3197. if (cb && deep) {
  3198. const baseGetter = getter;
  3199. getter = () => traverse(baseGetter());
  3200. }
  3201. let cleanup;
  3202. let onCleanup = (fn) => {
  3203. cleanup = effect.onStop = () => {
  3204. callWithErrorHandling(fn, instance, 4 /* WATCH_CLEANUP */);
  3205. };
  3206. };
  3207. let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
  3208. const job = () => {
  3209. if (!effect.active) {
  3210. return;
  3211. }
  3212. if (cb) {
  3213. // watch(source, cb)
  3214. const newValue = effect.run();
  3215. if (deep ||
  3216. forceTrigger ||
  3217. (isMultiSource
  3218. ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
  3219. : hasChanged(newValue, oldValue)) ||
  3220. (false )) {
  3221. // cleanup before running cb again
  3222. if (cleanup) {
  3223. cleanup();
  3224. }
  3225. callWithAsyncErrorHandling(cb, instance, 3 /* WATCH_CALLBACK */, [
  3226. newValue,
  3227. // pass undefined as the old value when it's changed for the first time
  3228. oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
  3229. onCleanup
  3230. ]);
  3231. oldValue = newValue;
  3232. }
  3233. }
  3234. else {
  3235. // watchEffect
  3236. effect.run();
  3237. }
  3238. };
  3239. // important: mark the job as a watcher callback so that scheduler knows
  3240. // it is allowed to self-trigger (#1727)
  3241. job.allowRecurse = !!cb;
  3242. let scheduler;
  3243. if (flush === 'sync') {
  3244. scheduler = job; // the scheduler function gets called directly
  3245. }
  3246. else if (flush === 'post') {
  3247. scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
  3248. }
  3249. else {
  3250. // default: 'pre'
  3251. scheduler = () => queuePreFlushCb(job);
  3252. }
  3253. const effect = new ReactiveEffect(getter, scheduler);
  3254. {
  3255. effect.onTrack = onTrack;
  3256. effect.onTrigger = onTrigger;
  3257. }
  3258. // initial run
  3259. if (cb) {
  3260. if (immediate) {
  3261. job();
  3262. }
  3263. else {
  3264. oldValue = effect.run();
  3265. }
  3266. }
  3267. else if (flush === 'post') {
  3268. queuePostRenderEffect(effect.run.bind(effect), instance && instance.suspense);
  3269. }
  3270. else {
  3271. effect.run();
  3272. }
  3273. return () => {
  3274. effect.stop();
  3275. if (instance && instance.scope) {
  3276. remove(instance.scope.effects, effect);
  3277. }
  3278. };
  3279. }
  3280. // this.$watch
  3281. function instanceWatch(source, value, options) {
  3282. const publicThis = this.proxy;
  3283. const getter = isString(source)
  3284. ? source.includes('.')
  3285. ? createPathGetter(publicThis, source)
  3286. : () => publicThis[source]
  3287. : source.bind(publicThis, publicThis);
  3288. let cb;
  3289. if (isFunction(value)) {
  3290. cb = value;
  3291. }
  3292. else {
  3293. cb = value.handler;
  3294. options = value;
  3295. }
  3296. const cur = currentInstance;
  3297. setCurrentInstance(this);
  3298. const res = doWatch(getter, cb.bind(publicThis), options);
  3299. if (cur) {
  3300. setCurrentInstance(cur);
  3301. }
  3302. else {
  3303. unsetCurrentInstance();
  3304. }
  3305. return res;
  3306. }
  3307. function createPathGetter(ctx, path) {
  3308. const segments = path.split('.');
  3309. return () => {
  3310. let cur = ctx;
  3311. for (let i = 0; i < segments.length && cur; i++) {
  3312. cur = cur[segments[i]];
  3313. }
  3314. return cur;
  3315. };
  3316. }
  3317. function traverse(value, seen) {
  3318. if (!isObject(value) || value["__v_skip" /* SKIP */]) {
  3319. return value;
  3320. }
  3321. seen = seen || new Set();
  3322. if (seen.has(value)) {
  3323. return value;
  3324. }
  3325. seen.add(value);
  3326. if (isRef(value)) {
  3327. traverse(value.value, seen);
  3328. }
  3329. else if (isArray(value)) {
  3330. for (let i = 0; i < value.length; i++) {
  3331. traverse(value[i], seen);
  3332. }
  3333. }
  3334. else if (isSet(value) || isMap(value)) {
  3335. value.forEach((v) => {
  3336. traverse(v, seen);
  3337. });
  3338. }
  3339. else if (isPlainObject(value)) {
  3340. for (const key in value) {
  3341. traverse(value[key], seen);
  3342. }
  3343. }
  3344. return value;
  3345. }
  3346. function useTransitionState() {
  3347. const state = {
  3348. isMounted: false,
  3349. isLeaving: false,
  3350. isUnmounting: false,
  3351. leavingVNodes: new Map()
  3352. };
  3353. onMounted(() => {
  3354. state.isMounted = true;
  3355. });
  3356. onBeforeUnmount(() => {
  3357. state.isUnmounting = true;
  3358. });
  3359. return state;
  3360. }
  3361. const TransitionHookValidator = [Function, Array];
  3362. const BaseTransitionImpl = {
  3363. name: `BaseTransition`,
  3364. props: {
  3365. mode: String,
  3366. appear: Boolean,
  3367. persisted: Boolean,
  3368. // enter
  3369. onBeforeEnter: TransitionHookValidator,
  3370. onEnter: TransitionHookValidator,
  3371. onAfterEnter: TransitionHookValidator,
  3372. onEnterCancelled: TransitionHookValidator,
  3373. // leave
  3374. onBeforeLeave: TransitionHookValidator,
  3375. onLeave: TransitionHookValidator,
  3376. onAfterLeave: TransitionHookValidator,
  3377. onLeaveCancelled: TransitionHookValidator,
  3378. // appear
  3379. onBeforeAppear: TransitionHookValidator,
  3380. onAppear: TransitionHookValidator,
  3381. onAfterAppear: TransitionHookValidator,
  3382. onAppearCancelled: TransitionHookValidator
  3383. },
  3384. setup(props, { slots }) {
  3385. const instance = getCurrentInstance();
  3386. const state = useTransitionState();
  3387. let prevTransitionKey;
  3388. return () => {
  3389. const children = slots.default && getTransitionRawChildren(slots.default(), true);
  3390. if (!children || !children.length) {
  3391. return;
  3392. }
  3393. let child = children[0];
  3394. if (children.length > 1) {
  3395. let hasFound = false;
  3396. // locate first non-comment child
  3397. for (const c of children) {
  3398. if (c.type !== Comment) {
  3399. if (hasFound) {
  3400. // warn more than one non-comment child
  3401. warn$1('<transition> can only be used on a single element or component. ' +
  3402. 'Use <transition-group> for lists.');
  3403. break;
  3404. }
  3405. child = c;
  3406. hasFound = true;
  3407. }
  3408. }
  3409. }
  3410. // there's no need to track reactivity for these props so use the raw
  3411. // props for a bit better perf
  3412. const rawProps = toRaw(props);
  3413. const { mode } = rawProps;
  3414. // check mode
  3415. if (mode &&
  3416. mode !== 'in-out' &&
  3417. mode !== 'out-in' &&
  3418. mode !== 'default') {
  3419. warn$1(`invalid <transition> mode: ${mode}`);
  3420. }
  3421. if (state.isLeaving) {
  3422. return emptyPlaceholder(child);
  3423. }
  3424. // in the case of <transition><keep-alive/></transition>, we need to
  3425. // compare the type of the kept-alive children.
  3426. const innerChild = getKeepAliveChild(child);
  3427. if (!innerChild) {
  3428. return emptyPlaceholder(child);
  3429. }
  3430. const enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance);
  3431. setTransitionHooks(innerChild, enterHooks);
  3432. const oldChild = instance.subTree;
  3433. const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
  3434. let transitionKeyChanged = false;
  3435. const { getTransitionKey } = innerChild.type;
  3436. if (getTransitionKey) {
  3437. const key = getTransitionKey();
  3438. if (prevTransitionKey === undefined) {
  3439. prevTransitionKey = key;
  3440. }
  3441. else if (key !== prevTransitionKey) {
  3442. prevTransitionKey = key;
  3443. transitionKeyChanged = true;
  3444. }
  3445. }
  3446. // handle mode
  3447. if (oldInnerChild &&
  3448. oldInnerChild.type !== Comment &&
  3449. (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
  3450. const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);
  3451. // update old tree's hooks in case of dynamic transition
  3452. setTransitionHooks(oldInnerChild, leavingHooks);
  3453. // switching between different views
  3454. if (mode === 'out-in') {
  3455. state.isLeaving = true;
  3456. // return placeholder node and queue update when leave finishes
  3457. leavingHooks.afterLeave = () => {
  3458. state.isLeaving = false;
  3459. instance.update();
  3460. };
  3461. return emptyPlaceholder(child);
  3462. }
  3463. else if (mode === 'in-out' && innerChild.type !== Comment) {
  3464. leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
  3465. const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);
  3466. leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
  3467. // early removal callback
  3468. el._leaveCb = () => {
  3469. earlyRemove();
  3470. el._leaveCb = undefined;
  3471. delete enterHooks.delayedLeave;
  3472. };
  3473. enterHooks.delayedLeave = delayedLeave;
  3474. };
  3475. }
  3476. }
  3477. return child;
  3478. };
  3479. }
  3480. };
  3481. // export the public type for h/tsx inference
  3482. // also to avoid inline import() in generated d.ts files
  3483. const BaseTransition = BaseTransitionImpl;
  3484. function getLeavingNodesForType(state, vnode) {
  3485. const { leavingVNodes } = state;
  3486. let leavingVNodesCache = leavingVNodes.get(vnode.type);
  3487. if (!leavingVNodesCache) {
  3488. leavingVNodesCache = Object.create(null);
  3489. leavingVNodes.set(vnode.type, leavingVNodesCache);
  3490. }
  3491. return leavingVNodesCache;
  3492. }
  3493. // The transition hooks are attached to the vnode as vnode.transition
  3494. // and will be called at appropriate timing in the renderer.
  3495. function resolveTransitionHooks(vnode, props, state, instance) {
  3496. const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props;
  3497. const key = String(vnode.key);
  3498. const leavingVNodesCache = getLeavingNodesForType(state, vnode);
  3499. const callHook = (hook, args) => {
  3500. hook &&
  3501. callWithAsyncErrorHandling(hook, instance, 9 /* TRANSITION_HOOK */, args);
  3502. };
  3503. const callAsyncHook = (hook, args) => {
  3504. const done = args[1];
  3505. callHook(hook, args);
  3506. if (isArray(hook)) {
  3507. if (hook.every(hook => hook.length <= 1))
  3508. done();
  3509. }
  3510. else if (hook.length <= 1) {
  3511. done();
  3512. }
  3513. };
  3514. const hooks = {
  3515. mode,
  3516. persisted,
  3517. beforeEnter(el) {
  3518. let hook = onBeforeEnter;
  3519. if (!state.isMounted) {
  3520. if (appear) {
  3521. hook = onBeforeAppear || onBeforeEnter;
  3522. }
  3523. else {
  3524. return;
  3525. }
  3526. }
  3527. // for same element (v-show)
  3528. if (el._leaveCb) {
  3529. el._leaveCb(true /* cancelled */);
  3530. }
  3531. // for toggled element with same key (v-if)
  3532. const leavingVNode = leavingVNodesCache[key];
  3533. if (leavingVNode &&
  3534. isSameVNodeType(vnode, leavingVNode) &&
  3535. leavingVNode.el._leaveCb) {
  3536. // force early removal (not cancelled)
  3537. leavingVNode.el._leaveCb();
  3538. }
  3539. callHook(hook, [el]);
  3540. },
  3541. enter(el) {
  3542. let hook = onEnter;
  3543. let afterHook = onAfterEnter;
  3544. let cancelHook = onEnterCancelled;
  3545. if (!state.isMounted) {
  3546. if (appear) {
  3547. hook = onAppear || onEnter;
  3548. afterHook = onAfterAppear || onAfterEnter;
  3549. cancelHook = onAppearCancelled || onEnterCancelled;
  3550. }
  3551. else {
  3552. return;
  3553. }
  3554. }
  3555. let called = false;
  3556. const done = (el._enterCb = (cancelled) => {
  3557. if (called)
  3558. return;
  3559. called = true;
  3560. if (cancelled) {
  3561. callHook(cancelHook, [el]);
  3562. }
  3563. else {
  3564. callHook(afterHook, [el]);
  3565. }
  3566. if (hooks.delayedLeave) {
  3567. hooks.delayedLeave();
  3568. }
  3569. el._enterCb = undefined;
  3570. });
  3571. if (hook) {
  3572. callAsyncHook(hook, [el, done]);
  3573. }
  3574. else {
  3575. done();
  3576. }
  3577. },
  3578. leave(el, remove) {
  3579. const key = String(vnode.key);
  3580. if (el._enterCb) {
  3581. el._enterCb(true /* cancelled */);
  3582. }
  3583. if (state.isUnmounting) {
  3584. return remove();
  3585. }
  3586. callHook(onBeforeLeave, [el]);
  3587. let called = false;
  3588. const done = (el._leaveCb = (cancelled) => {
  3589. if (called)
  3590. return;
  3591. called = true;
  3592. remove();
  3593. if (cancelled) {
  3594. callHook(onLeaveCancelled, [el]);
  3595. }
  3596. else {
  3597. callHook(onAfterLeave, [el]);
  3598. }
  3599. el._leaveCb = undefined;
  3600. if (leavingVNodesCache[key] === vnode) {
  3601. delete leavingVNodesCache[key];
  3602. }
  3603. });
  3604. leavingVNodesCache[key] = vnode;
  3605. if (onLeave) {
  3606. callAsyncHook(onLeave, [el, done]);
  3607. }
  3608. else {
  3609. done();
  3610. }
  3611. },
  3612. clone(vnode) {
  3613. return resolveTransitionHooks(vnode, props, state, instance);
  3614. }
  3615. };
  3616. return hooks;
  3617. }
  3618. // the placeholder really only handles one special case: KeepAlive
  3619. // in the case of a KeepAlive in a leave phase we need to return a KeepAlive
  3620. // placeholder with empty content to avoid the KeepAlive instance from being
  3621. // unmounted.
  3622. function emptyPlaceholder(vnode) {
  3623. if (isKeepAlive(vnode)) {
  3624. vnode = cloneVNode(vnode);
  3625. vnode.children = null;
  3626. return vnode;
  3627. }
  3628. }
  3629. function getKeepAliveChild(vnode) {
  3630. return isKeepAlive(vnode)
  3631. ? vnode.children
  3632. ? vnode.children[0]
  3633. : undefined
  3634. : vnode;
  3635. }
  3636. function setTransitionHooks(vnode, hooks) {
  3637. if (vnode.shapeFlag & 6 /* COMPONENT */ && vnode.component) {
  3638. setTransitionHooks(vnode.component.subTree, hooks);
  3639. }
  3640. else if (vnode.shapeFlag & 128 /* SUSPENSE */) {
  3641. vnode.ssContent.transition = hooks.clone(vnode.ssContent);
  3642. vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
  3643. }
  3644. else {
  3645. vnode.transition = hooks;
  3646. }
  3647. }
  3648. function getTransitionRawChildren(children, keepComment = false, parentKey) {
  3649. let ret = [];
  3650. let keyedFragmentCount = 0;
  3651. for (let i = 0; i < children.length; i++) {
  3652. let child = children[i];
  3653. // #5360 inherit parent key in case of <template v-for>
  3654. const key = parentKey == null
  3655. ? child.key
  3656. : String(parentKey) + String(child.key != null ? child.key : i);
  3657. // handle fragment children case, e.g. v-for
  3658. if (child.type === Fragment) {
  3659. if (child.patchFlag & 128 /* KEYED_FRAGMENT */)
  3660. keyedFragmentCount++;
  3661. ret = ret.concat(getTransitionRawChildren(child.children, keepComment, key));
  3662. }
  3663. // comment placeholders should be skipped, e.g. v-if
  3664. else if (keepComment || child.type !== Comment) {
  3665. ret.push(key != null ? cloneVNode(child, { key }) : child);
  3666. }
  3667. }
  3668. // #1126 if a transition children list contains multiple sub fragments, these
  3669. // fragments will be merged into a flat children array. Since each v-for
  3670. // fragment may contain different static bindings inside, we need to de-op
  3671. // these children to force full diffs to ensure correct behavior.
  3672. if (keyedFragmentCount > 1) {
  3673. for (let i = 0; i < ret.length; i++) {
  3674. ret[i].patchFlag = -2 /* BAIL */;
  3675. }
  3676. }
  3677. return ret;
  3678. }
  3679. // implementation, close to no-op
  3680. function defineComponent(options) {
  3681. return isFunction(options) ? { setup: options, name: options.name } : options;
  3682. }
  3683. const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
  3684. function defineAsyncComponent(source) {
  3685. if (isFunction(source)) {
  3686. source = { loader: source };
  3687. }
  3688. const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
  3689. suspensible = true, onError: userOnError } = source;
  3690. let pendingRequest = null;
  3691. let resolvedComp;
  3692. let retries = 0;
  3693. const retry = () => {
  3694. retries++;
  3695. pendingRequest = null;
  3696. return load();
  3697. };
  3698. const load = () => {
  3699. let thisRequest;
  3700. return (pendingRequest ||
  3701. (thisRequest = pendingRequest =
  3702. loader()
  3703. .catch(err => {
  3704. err = err instanceof Error ? err : new Error(String(err));
  3705. if (userOnError) {
  3706. return new Promise((resolve, reject) => {
  3707. const userRetry = () => resolve(retry());
  3708. const userFail = () => reject(err);
  3709. userOnError(err, userRetry, userFail, retries + 1);
  3710. });
  3711. }
  3712. else {
  3713. throw err;
  3714. }
  3715. })
  3716. .then((comp) => {
  3717. if (thisRequest !== pendingRequest && pendingRequest) {
  3718. return pendingRequest;
  3719. }
  3720. if (!comp) {
  3721. warn$1(`Async component loader resolved to undefined. ` +
  3722. `If you are using retry(), make sure to return its return value.`);
  3723. }
  3724. // interop module default
  3725. if (comp &&
  3726. (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
  3727. comp = comp.default;
  3728. }
  3729. if (comp && !isObject(comp) && !isFunction(comp)) {
  3730. throw new Error(`Invalid async component load result: ${comp}`);
  3731. }
  3732. resolvedComp = comp;
  3733. return comp;
  3734. })));
  3735. };
  3736. return defineComponent({
  3737. name: 'AsyncComponentWrapper',
  3738. __asyncLoader: load,
  3739. get __asyncResolved() {
  3740. return resolvedComp;
  3741. },
  3742. setup() {
  3743. const instance = currentInstance;
  3744. // already resolved
  3745. if (resolvedComp) {
  3746. return () => createInnerComp(resolvedComp, instance);
  3747. }
  3748. const onError = (err) => {
  3749. pendingRequest = null;
  3750. handleError(err, instance, 13 /* ASYNC_COMPONENT_LOADER */, !errorComponent /* do not throw in dev if user provided error component */);
  3751. };
  3752. // suspense-controlled or SSR.
  3753. if ((suspensible && instance.suspense) ||
  3754. (false )) {
  3755. return load()
  3756. .then(comp => {
  3757. return () => createInnerComp(comp, instance);
  3758. })
  3759. .catch(err => {
  3760. onError(err);
  3761. return () => errorComponent
  3762. ? createVNode(errorComponent, {
  3763. error: err
  3764. })
  3765. : null;
  3766. });
  3767. }
  3768. const loaded = ref(false);
  3769. const error = ref();
  3770. const delayed = ref(!!delay);
  3771. if (delay) {
  3772. setTimeout(() => {
  3773. delayed.value = false;
  3774. }, delay);
  3775. }
  3776. if (timeout != null) {
  3777. setTimeout(() => {
  3778. if (!loaded.value && !error.value) {
  3779. const err = new Error(`Async component timed out after ${timeout}ms.`);
  3780. onError(err);
  3781. error.value = err;
  3782. }
  3783. }, timeout);
  3784. }
  3785. load()
  3786. .then(() => {
  3787. loaded.value = true;
  3788. if (instance.parent && isKeepAlive(instance.parent.vnode)) {
  3789. // parent is keep-alive, force update so the loaded component's
  3790. // name is taken into account
  3791. queueJob(instance.parent.update);
  3792. }
  3793. })
  3794. .catch(err => {
  3795. onError(err);
  3796. error.value = err;
  3797. });
  3798. return () => {
  3799. if (loaded.value && resolvedComp) {
  3800. return createInnerComp(resolvedComp, instance);
  3801. }
  3802. else if (error.value && errorComponent) {
  3803. return createVNode(errorComponent, {
  3804. error: error.value
  3805. });
  3806. }
  3807. else if (loadingComponent && !delayed.value) {
  3808. return createVNode(loadingComponent);
  3809. }
  3810. };
  3811. }
  3812. });
  3813. }
  3814. function createInnerComp(comp, { vnode: { ref, props, children, shapeFlag }, parent }) {
  3815. const vnode = createVNode(comp, props, children);
  3816. // ensure inner component inherits the async wrapper's ref owner
  3817. vnode.ref = ref;
  3818. return vnode;
  3819. }
  3820. const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
  3821. const KeepAliveImpl = {
  3822. name: `KeepAlive`,
  3823. // Marker for special handling inside the renderer. We are not using a ===
  3824. // check directly on KeepAlive in the renderer, because importing it directly
  3825. // would prevent it from being tree-shaken.
  3826. __isKeepAlive: true,
  3827. props: {
  3828. include: [String, RegExp, Array],
  3829. exclude: [String, RegExp, Array],
  3830. max: [String, Number]
  3831. },
  3832. setup(props, { slots }) {
  3833. const instance = getCurrentInstance();
  3834. // KeepAlive communicates with the instantiated renderer via the
  3835. // ctx where the renderer passes in its internals,
  3836. // and the KeepAlive instance exposes activate/deactivate implementations.
  3837. // The whole point of this is to avoid importing KeepAlive directly in the
  3838. // renderer to facilitate tree-shaking.
  3839. const sharedContext = instance.ctx;
  3840. const cache = new Map();
  3841. const keys = new Set();
  3842. let current = null;
  3843. {
  3844. instance.__v_cache = cache;
  3845. }
  3846. const parentSuspense = instance.suspense;
  3847. const { renderer: { p: patch, m: move, um: _unmount, o: { createElement } } } = sharedContext;
  3848. const storageContainer = createElement('div');
  3849. sharedContext.activate = (vnode, container, anchor, isSVG, optimized) => {
  3850. const instance = vnode.component;
  3851. move(vnode, container, anchor, 0 /* ENTER */, parentSuspense);
  3852. // in case props have changed
  3853. patch(instance.vnode, vnode, container, anchor, instance, parentSuspense, isSVG, vnode.slotScopeIds, optimized);
  3854. queuePostRenderEffect(() => {
  3855. instance.isDeactivated = false;
  3856. if (instance.a) {
  3857. invokeArrayFns(instance.a);
  3858. }
  3859. const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
  3860. if (vnodeHook) {
  3861. invokeVNodeHook(vnodeHook, instance.parent, vnode);
  3862. }
  3863. }, parentSuspense);
  3864. {
  3865. // Update components tree
  3866. devtoolsComponentAdded(instance);
  3867. }
  3868. };
  3869. sharedContext.deactivate = (vnode) => {
  3870. const instance = vnode.component;
  3871. move(vnode, storageContainer, null, 1 /* LEAVE */, parentSuspense);
  3872. queuePostRenderEffect(() => {
  3873. if (instance.da) {
  3874. invokeArrayFns(instance.da);
  3875. }
  3876. const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
  3877. if (vnodeHook) {
  3878. invokeVNodeHook(vnodeHook, instance.parent, vnode);
  3879. }
  3880. instance.isDeactivated = true;
  3881. }, parentSuspense);
  3882. {
  3883. // Update components tree
  3884. devtoolsComponentAdded(instance);
  3885. }
  3886. };
  3887. function unmount(vnode) {
  3888. // reset the shapeFlag so it can be properly unmounted
  3889. resetShapeFlag(vnode);
  3890. _unmount(vnode, instance, parentSuspense, true);
  3891. }
  3892. function pruneCache(filter) {
  3893. cache.forEach((vnode, key) => {
  3894. const name = getComponentName(vnode.type);
  3895. if (name && (!filter || !filter(name))) {
  3896. pruneCacheEntry(key);
  3897. }
  3898. });
  3899. }
  3900. function pruneCacheEntry(key) {
  3901. const cached = cache.get(key);
  3902. if (!current || cached.type !== current.type) {
  3903. unmount(cached);
  3904. }
  3905. else if (current) {
  3906. // current active instance should no longer be kept-alive.
  3907. // we can't unmount it now but it might be later, so reset its flag now.
  3908. resetShapeFlag(current);
  3909. }
  3910. cache.delete(key);
  3911. keys.delete(key);
  3912. }
  3913. // prune cache on include/exclude prop change
  3914. watch(() => [props.include, props.exclude], ([include, exclude]) => {
  3915. include && pruneCache(name => matches(include, name));
  3916. exclude && pruneCache(name => !matches(exclude, name));
  3917. },
  3918. // prune post-render after `current` has been updated
  3919. { flush: 'post', deep: true });
  3920. // cache sub tree after render
  3921. let pendingCacheKey = null;
  3922. const cacheSubtree = () => {
  3923. // fix #1621, the pendingCacheKey could be 0
  3924. if (pendingCacheKey != null) {
  3925. cache.set(pendingCacheKey, getInnerChild(instance.subTree));
  3926. }
  3927. };
  3928. onMounted(cacheSubtree);
  3929. onUpdated(cacheSubtree);
  3930. onBeforeUnmount(() => {
  3931. cache.forEach(cached => {
  3932. const { subTree, suspense } = instance;
  3933. const vnode = getInnerChild(subTree);
  3934. if (cached.type === vnode.type) {
  3935. // current instance will be unmounted as part of keep-alive's unmount
  3936. resetShapeFlag(vnode);
  3937. // but invoke its deactivated hook here
  3938. const da = vnode.component.da;
  3939. da && queuePostRenderEffect(da, suspense);
  3940. return;
  3941. }
  3942. unmount(cached);
  3943. });
  3944. });
  3945. return () => {
  3946. pendingCacheKey = null;
  3947. if (!slots.default) {
  3948. return null;
  3949. }
  3950. const children = slots.default();
  3951. const rawVNode = children[0];
  3952. if (children.length > 1) {
  3953. {
  3954. warn$1(`KeepAlive should contain exactly one component child.`);
  3955. }
  3956. current = null;
  3957. return children;
  3958. }
  3959. else if (!isVNode(rawVNode) ||
  3960. (!(rawVNode.shapeFlag & 4 /* STATEFUL_COMPONENT */) &&
  3961. !(rawVNode.shapeFlag & 128 /* SUSPENSE */))) {
  3962. current = null;
  3963. return rawVNode;
  3964. }
  3965. let vnode = getInnerChild(rawVNode);
  3966. const comp = vnode.type;
  3967. // for async components, name check should be based in its loaded
  3968. // inner component if available
  3969. const name = getComponentName(isAsyncWrapper(vnode)
  3970. ? vnode.type.__asyncResolved || {}
  3971. : comp);
  3972. const { include, exclude, max } = props;
  3973. if ((include && (!name || !matches(include, name))) ||
  3974. (exclude && name && matches(exclude, name))) {
  3975. current = vnode;
  3976. return rawVNode;
  3977. }
  3978. const key = vnode.key == null ? comp : vnode.key;
  3979. const cachedVNode = cache.get(key);
  3980. // clone vnode if it's reused because we are going to mutate it
  3981. if (vnode.el) {
  3982. vnode = cloneVNode(vnode);
  3983. if (rawVNode.shapeFlag & 128 /* SUSPENSE */) {
  3984. rawVNode.ssContent = vnode;
  3985. }
  3986. }
  3987. // #1513 it's possible for the returned vnode to be cloned due to attr
  3988. // fallthrough or scopeId, so the vnode here may not be the final vnode
  3989. // that is mounted. Instead of caching it directly, we store the pending
  3990. // key and cache `instance.subTree` (the normalized vnode) in
  3991. // beforeMount/beforeUpdate hooks.
  3992. pendingCacheKey = key;
  3993. if (cachedVNode) {
  3994. // copy over mounted state
  3995. vnode.el = cachedVNode.el;
  3996. vnode.component = cachedVNode.component;
  3997. if (vnode.transition) {
  3998. // recursively update transition hooks on subTree
  3999. setTransitionHooks(vnode, vnode.transition);
  4000. }
  4001. // avoid vnode being mounted as fresh
  4002. vnode.shapeFlag |= 512 /* COMPONENT_KEPT_ALIVE */;
  4003. // make this key the freshest
  4004. keys.delete(key);
  4005. keys.add(key);
  4006. }
  4007. else {
  4008. keys.add(key);
  4009. // prune oldest entry
  4010. if (max && keys.size > parseInt(max, 10)) {
  4011. pruneCacheEntry(keys.values().next().value);
  4012. }
  4013. }
  4014. // avoid vnode being unmounted
  4015. vnode.shapeFlag |= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
  4016. current = vnode;
  4017. return isSuspense(rawVNode.type) ? rawVNode : vnode;
  4018. };
  4019. }
  4020. };
  4021. // export the public type for h/tsx inference
  4022. // also to avoid inline import() in generated d.ts files
  4023. const KeepAlive = KeepAliveImpl;
  4024. function matches(pattern, name) {
  4025. if (isArray(pattern)) {
  4026. return pattern.some((p) => matches(p, name));
  4027. }
  4028. else if (isString(pattern)) {
  4029. return pattern.split(',').includes(name);
  4030. }
  4031. else if (pattern.test) {
  4032. return pattern.test(name);
  4033. }
  4034. /* istanbul ignore next */
  4035. return false;
  4036. }
  4037. function onActivated(hook, target) {
  4038. registerKeepAliveHook(hook, "a" /* ACTIVATED */, target);
  4039. }
  4040. function onDeactivated(hook, target) {
  4041. registerKeepAliveHook(hook, "da" /* DEACTIVATED */, target);
  4042. }
  4043. function registerKeepAliveHook(hook, type, target = currentInstance) {
  4044. // cache the deactivate branch check wrapper for injected hooks so the same
  4045. // hook can be properly deduped by the scheduler. "__wdc" stands for "with
  4046. // deactivation check".
  4047. const wrappedHook = hook.__wdc ||
  4048. (hook.__wdc = () => {
  4049. // only fire the hook if the target instance is NOT in a deactivated branch.
  4050. let current = target;
  4051. while (current) {
  4052. if (current.isDeactivated) {
  4053. return;
  4054. }
  4055. current = current.parent;
  4056. }
  4057. return hook();
  4058. });
  4059. injectHook(type, wrappedHook, target);
  4060. // In addition to registering it on the target instance, we walk up the parent
  4061. // chain and register it on all ancestor instances that are keep-alive roots.
  4062. // This avoids the need to walk the entire component tree when invoking these
  4063. // hooks, and more importantly, avoids the need to track child components in
  4064. // arrays.
  4065. if (target) {
  4066. let current = target.parent;
  4067. while (current && current.parent) {
  4068. if (isKeepAlive(current.parent.vnode)) {
  4069. injectToKeepAliveRoot(wrappedHook, type, target, current);
  4070. }
  4071. current = current.parent;
  4072. }
  4073. }
  4074. }
  4075. function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
  4076. // injectHook wraps the original for error handling, so make sure to remove
  4077. // the wrapped version.
  4078. const injected = injectHook(type, hook, keepAliveRoot, true /* prepend */);
  4079. onUnmounted(() => {
  4080. remove(keepAliveRoot[type], injected);
  4081. }, target);
  4082. }
  4083. function resetShapeFlag(vnode) {
  4084. let shapeFlag = vnode.shapeFlag;
  4085. if (shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
  4086. shapeFlag -= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
  4087. }
  4088. if (shapeFlag & 512 /* COMPONENT_KEPT_ALIVE */) {
  4089. shapeFlag -= 512 /* COMPONENT_KEPT_ALIVE */;
  4090. }
  4091. vnode.shapeFlag = shapeFlag;
  4092. }
  4093. function getInnerChild(vnode) {
  4094. return vnode.shapeFlag & 128 /* SUSPENSE */ ? vnode.ssContent : vnode;
  4095. }
  4096. function injectHook(type, hook, target = currentInstance, prepend = false) {
  4097. if (target) {
  4098. const hooks = target[type] || (target[type] = []);
  4099. // cache the error handling wrapper for injected hooks so the same hook
  4100. // can be properly deduped by the scheduler. "__weh" stands for "with error
  4101. // handling".
  4102. const wrappedHook = hook.__weh ||
  4103. (hook.__weh = (...args) => {
  4104. if (target.isUnmounted) {
  4105. return;
  4106. }
  4107. // disable tracking inside all lifecycle hooks
  4108. // since they can potentially be called inside effects.
  4109. pauseTracking();
  4110. // Set currentInstance during hook invocation.
  4111. // This assumes the hook does not synchronously trigger other hooks, which
  4112. // can only be false when the user does something really funky.
  4113. setCurrentInstance(target);
  4114. const res = callWithAsyncErrorHandling(hook, target, type, args);
  4115. unsetCurrentInstance();
  4116. resetTracking();
  4117. return res;
  4118. });
  4119. if (prepend) {
  4120. hooks.unshift(wrappedHook);
  4121. }
  4122. else {
  4123. hooks.push(wrappedHook);
  4124. }
  4125. return wrappedHook;
  4126. }
  4127. else {
  4128. const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ''));
  4129. warn$1(`${apiName} is called when there is no active component instance to be ` +
  4130. `associated with. ` +
  4131. `Lifecycle injection APIs can only be used during execution of setup().` +
  4132. (` If you are using async setup(), make sure to register lifecycle ` +
  4133. `hooks before the first await statement.`
  4134. ));
  4135. }
  4136. }
  4137. const createHook = (lifecycle) => (hook, target = currentInstance) =>
  4138. // post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
  4139. (!isInSSRComponentSetup || lifecycle === "sp" /* SERVER_PREFETCH */) &&
  4140. injectHook(lifecycle, hook, target);
  4141. const onBeforeMount = createHook("bm" /* BEFORE_MOUNT */);
  4142. const onMounted = createHook("m" /* MOUNTED */);
  4143. const onBeforeUpdate = createHook("bu" /* BEFORE_UPDATE */);
  4144. const onUpdated = createHook("u" /* UPDATED */);
  4145. const onBeforeUnmount = createHook("bum" /* BEFORE_UNMOUNT */);
  4146. const onUnmounted = createHook("um" /* UNMOUNTED */);
  4147. const onServerPrefetch = createHook("sp" /* SERVER_PREFETCH */);
  4148. const onRenderTriggered = createHook("rtg" /* RENDER_TRIGGERED */);
  4149. const onRenderTracked = createHook("rtc" /* RENDER_TRACKED */);
  4150. function onErrorCaptured(hook, target = currentInstance) {
  4151. injectHook("ec" /* ERROR_CAPTURED */, hook, target);
  4152. }
  4153. /**
  4154. Runtime helper for applying directives to a vnode. Example usage:
  4155. const comp = resolveComponent('comp')
  4156. const foo = resolveDirective('foo')
  4157. const bar = resolveDirective('bar')
  4158. return withDirectives(h(comp), [
  4159. [foo, this.x],
  4160. [bar, this.y]
  4161. ])
  4162. */
  4163. function validateDirectiveName(name) {
  4164. if (isBuiltInDirective(name)) {
  4165. warn$1('Do not use built-in directive ids as custom directive id: ' + name);
  4166. }
  4167. }
  4168. /**
  4169. * Adds directives to a VNode.
  4170. */
  4171. function withDirectives(vnode, directives) {
  4172. const internalInstance = currentRenderingInstance;
  4173. if (internalInstance === null) {
  4174. warn$1(`withDirectives can only be used inside render functions.`);
  4175. return vnode;
  4176. }
  4177. const instance = getExposeProxy(internalInstance) ||
  4178. internalInstance.proxy;
  4179. const bindings = vnode.dirs || (vnode.dirs = []);
  4180. for (let i = 0; i < directives.length; i++) {
  4181. let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
  4182. if (isFunction(dir)) {
  4183. dir = {
  4184. mounted: dir,
  4185. updated: dir
  4186. };
  4187. }
  4188. if (dir.deep) {
  4189. traverse(value);
  4190. }
  4191. bindings.push({
  4192. dir,
  4193. instance,
  4194. value,
  4195. oldValue: void 0,
  4196. arg,
  4197. modifiers
  4198. });
  4199. }
  4200. return vnode;
  4201. }
  4202. function invokeDirectiveHook(vnode, prevVNode, instance, name) {
  4203. const bindings = vnode.dirs;
  4204. const oldBindings = prevVNode && prevVNode.dirs;
  4205. for (let i = 0; i < bindings.length; i++) {
  4206. const binding = bindings[i];
  4207. if (oldBindings) {
  4208. binding.oldValue = oldBindings[i].value;
  4209. }
  4210. let hook = binding.dir[name];
  4211. if (hook) {
  4212. // disable tracking inside all lifecycle hooks
  4213. // since they can potentially be called inside effects.
  4214. pauseTracking();
  4215. callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [
  4216. vnode.el,
  4217. binding,
  4218. vnode,
  4219. prevVNode
  4220. ]);
  4221. resetTracking();
  4222. }
  4223. }
  4224. }
  4225. const COMPONENTS = 'components';
  4226. const DIRECTIVES = 'directives';
  4227. /**
  4228. * @private
  4229. */
  4230. function resolveComponent(name, maybeSelfReference) {
  4231. return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
  4232. }
  4233. const NULL_DYNAMIC_COMPONENT = Symbol();
  4234. /**
  4235. * @private
  4236. */
  4237. function resolveDynamicComponent(component) {
  4238. if (isString(component)) {
  4239. return resolveAsset(COMPONENTS, component, false) || component;
  4240. }
  4241. else {
  4242. // invalid types will fallthrough to createVNode and raise warning
  4243. return (component || NULL_DYNAMIC_COMPONENT);
  4244. }
  4245. }
  4246. /**
  4247. * @private
  4248. */
  4249. function resolveDirective(name) {
  4250. return resolveAsset(DIRECTIVES, name);
  4251. }
  4252. // implementation
  4253. function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
  4254. const instance = currentRenderingInstance || currentInstance;
  4255. if (instance) {
  4256. const Component = instance.type;
  4257. // explicit self name has highest priority
  4258. if (type === COMPONENTS) {
  4259. const selfName = getComponentName(Component, false /* do not include inferred name to avoid breaking existing code */);
  4260. if (selfName &&
  4261. (selfName === name ||
  4262. selfName === camelize(name) ||
  4263. selfName === capitalize(camelize(name)))) {
  4264. return Component;
  4265. }
  4266. }
  4267. const res =
  4268. // local registration
  4269. // check instance[type] first which is resolved for options API
  4270. resolve(instance[type] || Component[type], name) ||
  4271. // global registration
  4272. resolve(instance.appContext[type], name);
  4273. if (!res && maybeSelfReference) {
  4274. // fallback to implicit self-reference
  4275. return Component;
  4276. }
  4277. if (warnMissing && !res) {
  4278. const extra = type === COMPONENTS
  4279. ? `\nIf this is a native custom element, make sure to exclude it from ` +
  4280. `component resolution via compilerOptions.isCustomElement.`
  4281. : ``;
  4282. warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
  4283. }
  4284. return res;
  4285. }
  4286. else {
  4287. warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
  4288. `can only be used in render() or setup().`);
  4289. }
  4290. }
  4291. function resolve(registry, name) {
  4292. return (registry &&
  4293. (registry[name] ||
  4294. registry[camelize(name)] ||
  4295. registry[capitalize(camelize(name))]));
  4296. }
  4297. /**
  4298. * Actual implementation
  4299. */
  4300. function renderList(source, renderItem, cache, index) {
  4301. let ret;
  4302. const cached = (cache && cache[index]);
  4303. if (isArray(source) || isString(source)) {
  4304. ret = new Array(source.length);
  4305. for (let i = 0, l = source.length; i < l; i++) {
  4306. ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
  4307. }
  4308. }
  4309. else if (typeof source === 'number') {
  4310. if (!Number.isInteger(source)) {
  4311. warn$1(`The v-for range expect an integer value but got ${source}.`);
  4312. }
  4313. ret = new Array(source);
  4314. for (let i = 0; i < source; i++) {
  4315. ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
  4316. }
  4317. }
  4318. else if (isObject(source)) {
  4319. if (source[Symbol.iterator]) {
  4320. ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
  4321. }
  4322. else {
  4323. const keys = Object.keys(source);
  4324. ret = new Array(keys.length);
  4325. for (let i = 0, l = keys.length; i < l; i++) {
  4326. const key = keys[i];
  4327. ret[i] = renderItem(source[key], key, i, cached && cached[i]);
  4328. }
  4329. }
  4330. }
  4331. else {
  4332. ret = [];
  4333. }
  4334. if (cache) {
  4335. cache[index] = ret;
  4336. }
  4337. return ret;
  4338. }
  4339. /**
  4340. * Compiler runtime helper for creating dynamic slots object
  4341. * @private
  4342. */
  4343. function createSlots(slots, dynamicSlots) {
  4344. for (let i = 0; i < dynamicSlots.length; i++) {
  4345. const slot = dynamicSlots[i];
  4346. // array of dynamic slot generated by <template v-for="..." #[...]>
  4347. if (isArray(slot)) {
  4348. for (let j = 0; j < slot.length; j++) {
  4349. slots[slot[j].name] = slot[j].fn;
  4350. }
  4351. }
  4352. else if (slot) {
  4353. // conditional single slot generated by <template v-if="..." #foo>
  4354. slots[slot.name] = slot.fn;
  4355. }
  4356. }
  4357. return slots;
  4358. }
  4359. /**
  4360. * Compiler runtime helper for rendering `<slot/>`
  4361. * @private
  4362. */
  4363. function renderSlot(slots, name, props = {},
  4364. // this is not a user-facing function, so the fallback is always generated by
  4365. // the compiler and guaranteed to be a function returning an array
  4366. fallback, noSlotted) {
  4367. if (currentRenderingInstance.isCE ||
  4368. (currentRenderingInstance.parent &&
  4369. isAsyncWrapper(currentRenderingInstance.parent) &&
  4370. currentRenderingInstance.parent.isCE)) {
  4371. return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
  4372. }
  4373. let slot = slots[name];
  4374. if (slot && slot.length > 1) {
  4375. warn$1(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
  4376. `function. You need to mark this component with $dynamic-slots in the ` +
  4377. `parent template.`);
  4378. slot = () => [];
  4379. }
  4380. // a compiled slot disables block tracking by default to avoid manual
  4381. // invocation interfering with template-based block tracking, but in
  4382. // `renderSlot` we can be sure that it's template-based so we can force
  4383. // enable it.
  4384. if (slot && slot._c) {
  4385. slot._d = false;
  4386. }
  4387. openBlock();
  4388. const validSlotContent = slot && ensureValidVNode(slot(props));
  4389. const rendered = createBlock(Fragment, { key: props.key || `_${name}` }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 /* STABLE */
  4390. ? 64 /* STABLE_FRAGMENT */
  4391. : -2 /* BAIL */);
  4392. if (!noSlotted && rendered.scopeId) {
  4393. rendered.slotScopeIds = [rendered.scopeId + '-s'];
  4394. }
  4395. if (slot && slot._c) {
  4396. slot._d = true;
  4397. }
  4398. return rendered;
  4399. }
  4400. function ensureValidVNode(vnodes) {
  4401. return vnodes.some(child => {
  4402. if (!isVNode(child))
  4403. return true;
  4404. if (child.type === Comment)
  4405. return false;
  4406. if (child.type === Fragment &&
  4407. !ensureValidVNode(child.children))
  4408. return false;
  4409. return true;
  4410. })
  4411. ? vnodes
  4412. : null;
  4413. }
  4414. /**
  4415. * For prefixing keys in v-on="obj" with "on"
  4416. * @private
  4417. */
  4418. function toHandlers(obj) {
  4419. const ret = {};
  4420. if (!isObject(obj)) {
  4421. warn$1(`v-on with no argument expects an object value.`);
  4422. return ret;
  4423. }
  4424. for (const key in obj) {
  4425. ret[toHandlerKey(key)] = obj[key];
  4426. }
  4427. return ret;
  4428. }
  4429. /**
  4430. * #2437 In Vue 3, functional components do not have a public instance proxy but
  4431. * they exist in the internal parent chain. For code that relies on traversing
  4432. * public $parent chains, skip functional ones and go to the parent instead.
  4433. */
  4434. const getPublicInstance = (i) => {
  4435. if (!i)
  4436. return null;
  4437. if (isStatefulComponent(i))
  4438. return getExposeProxy(i) || i.proxy;
  4439. return getPublicInstance(i.parent);
  4440. };
  4441. const publicPropertiesMap =
  4442. // Move PURE marker to new line to workaround compiler discarding it
  4443. // due to type annotation
  4444. /*#__PURE__*/ extend(Object.create(null), {
  4445. $: i => i,
  4446. $el: i => i.vnode.el,
  4447. $data: i => i.data,
  4448. $props: i => (shallowReadonly(i.props) ),
  4449. $attrs: i => (shallowReadonly(i.attrs) ),
  4450. $slots: i => (shallowReadonly(i.slots) ),
  4451. $refs: i => (shallowReadonly(i.refs) ),
  4452. $parent: i => getPublicInstance(i.parent),
  4453. $root: i => getPublicInstance(i.root),
  4454. $emit: i => i.emit,
  4455. $options: i => (resolveMergedOptions(i) ),
  4456. $forceUpdate: i => i.f || (i.f = () => queueJob(i.update)),
  4457. $nextTick: i => i.n || (i.n = nextTick.bind(i.proxy)),
  4458. $watch: i => (instanceWatch.bind(i) )
  4459. });
  4460. const isReservedPrefix = (key) => key === '_' || key === '$';
  4461. const PublicInstanceProxyHandlers = {
  4462. get({ _: instance }, key) {
  4463. const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
  4464. // for internal formatters to know that this is a Vue instance
  4465. if (key === '__isVue') {
  4466. return true;
  4467. }
  4468. // prioritize <script setup> bindings during dev.
  4469. // this allows even properties that start with _ or $ to be used - so that
  4470. // it aligns with the production behavior where the render fn is inlined and
  4471. // indeed has access to all declared variables.
  4472. if (setupState !== EMPTY_OBJ &&
  4473. setupState.__isScriptSetup &&
  4474. hasOwn(setupState, key)) {
  4475. return setupState[key];
  4476. }
  4477. // data / props / ctx
  4478. // This getter gets called for every property access on the render context
  4479. // during render and is a major hotspot. The most expensive part of this
  4480. // is the multiple hasOwn() calls. It's much faster to do a simple property
  4481. // access on a plain object, so we use an accessCache object (with null
  4482. // prototype) to memoize what access type a key corresponds to.
  4483. let normalizedProps;
  4484. if (key[0] !== '$') {
  4485. const n = accessCache[key];
  4486. if (n !== undefined) {
  4487. switch (n) {
  4488. case 1 /* SETUP */:
  4489. return setupState[key];
  4490. case 2 /* DATA */:
  4491. return data[key];
  4492. case 4 /* CONTEXT */:
  4493. return ctx[key];
  4494. case 3 /* PROPS */:
  4495. return props[key];
  4496. // default: just fallthrough
  4497. }
  4498. }
  4499. else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
  4500. accessCache[key] = 1 /* SETUP */;
  4501. return setupState[key];
  4502. }
  4503. else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  4504. accessCache[key] = 2 /* DATA */;
  4505. return data[key];
  4506. }
  4507. else if (
  4508. // only cache other properties when instance has declared (thus stable)
  4509. // props
  4510. (normalizedProps = instance.propsOptions[0]) &&
  4511. hasOwn(normalizedProps, key)) {
  4512. accessCache[key] = 3 /* PROPS */;
  4513. return props[key];
  4514. }
  4515. else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  4516. accessCache[key] = 4 /* CONTEXT */;
  4517. return ctx[key];
  4518. }
  4519. else if (shouldCacheAccess) {
  4520. accessCache[key] = 0 /* OTHER */;
  4521. }
  4522. }
  4523. const publicGetter = publicPropertiesMap[key];
  4524. let cssModule, globalProperties;
  4525. // public $xxx properties
  4526. if (publicGetter) {
  4527. if (key === '$attrs') {
  4528. track(instance, "get" /* GET */, key);
  4529. markAttrsAccessed();
  4530. }
  4531. return publicGetter(instance);
  4532. }
  4533. else if (
  4534. // css module (injected by vue-loader)
  4535. (cssModule = type.__cssModules) &&
  4536. (cssModule = cssModule[key])) {
  4537. return cssModule;
  4538. }
  4539. else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
  4540. // user may set custom properties to `this` that start with `$`
  4541. accessCache[key] = 4 /* CONTEXT */;
  4542. return ctx[key];
  4543. }
  4544. else if (
  4545. // global properties
  4546. ((globalProperties = appContext.config.globalProperties),
  4547. hasOwn(globalProperties, key))) {
  4548. {
  4549. return globalProperties[key];
  4550. }
  4551. }
  4552. else if (currentRenderingInstance &&
  4553. (!isString(key) ||
  4554. // #1091 avoid internal isRef/isVNode checks on component instance leading
  4555. // to infinite warning loop
  4556. key.indexOf('__v') !== 0)) {
  4557. if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
  4558. warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
  4559. `character ("$" or "_") and is not proxied on the render context.`);
  4560. }
  4561. else if (instance === currentRenderingInstance) {
  4562. warn$1(`Property ${JSON.stringify(key)} was accessed during render ` +
  4563. `but is not defined on instance.`);
  4564. }
  4565. }
  4566. },
  4567. set({ _: instance }, key, value) {
  4568. const { data, setupState, ctx } = instance;
  4569. if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
  4570. setupState[key] = value;
  4571. return true;
  4572. }
  4573. else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
  4574. data[key] = value;
  4575. return true;
  4576. }
  4577. else if (hasOwn(instance.props, key)) {
  4578. warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
  4579. return false;
  4580. }
  4581. if (key[0] === '$' && key.slice(1) in instance) {
  4582. warn$1(`Attempting to mutate public property "${key}". ` +
  4583. `Properties starting with $ are reserved and readonly.`, instance);
  4584. return false;
  4585. }
  4586. else {
  4587. if (key in instance.appContext.config.globalProperties) {
  4588. Object.defineProperty(ctx, key, {
  4589. enumerable: true,
  4590. configurable: true,
  4591. value
  4592. });
  4593. }
  4594. else {
  4595. ctx[key] = value;
  4596. }
  4597. }
  4598. return true;
  4599. },
  4600. has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
  4601. let normalizedProps;
  4602. return (!!accessCache[key] ||
  4603. (data !== EMPTY_OBJ && hasOwn(data, key)) ||
  4604. (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
  4605. ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
  4606. hasOwn(ctx, key) ||
  4607. hasOwn(publicPropertiesMap, key) ||
  4608. hasOwn(appContext.config.globalProperties, key));
  4609. },
  4610. defineProperty(target, key, descriptor) {
  4611. if (descriptor.get != null) {
  4612. // invalidate key cache of a getter based property #5417
  4613. target._.accessCache[key] = 0;
  4614. }
  4615. else if (hasOwn(descriptor, 'value')) {
  4616. this.set(target, key, descriptor.value, null);
  4617. }
  4618. return Reflect.defineProperty(target, key, descriptor);
  4619. }
  4620. };
  4621. {
  4622. PublicInstanceProxyHandlers.ownKeys = (target) => {
  4623. warn$1(`Avoid app logic that relies on enumerating keys on a component instance. ` +
  4624. `The keys will be empty in production mode to avoid performance overhead.`);
  4625. return Reflect.ownKeys(target);
  4626. };
  4627. }
  4628. const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend({}, PublicInstanceProxyHandlers, {
  4629. get(target, key) {
  4630. // fast path for unscopables when using `with` block
  4631. if (key === Symbol.unscopables) {
  4632. return;
  4633. }
  4634. return PublicInstanceProxyHandlers.get(target, key, target);
  4635. },
  4636. has(_, key) {
  4637. const has = key[0] !== '_' && !isGloballyWhitelisted(key);
  4638. if (!has && PublicInstanceProxyHandlers.has(_, key)) {
  4639. warn$1(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
  4640. }
  4641. return has;
  4642. }
  4643. });
  4644. // dev only
  4645. // In dev mode, the proxy target exposes the same properties as seen on `this`
  4646. // for easier console inspection. In prod mode it will be an empty object so
  4647. // these properties definitions can be skipped.
  4648. function createDevRenderContext(instance) {
  4649. const target = {};
  4650. // expose internal instance for proxy handlers
  4651. Object.defineProperty(target, `_`, {
  4652. configurable: true,
  4653. enumerable: false,
  4654. get: () => instance
  4655. });
  4656. // expose public properties
  4657. Object.keys(publicPropertiesMap).forEach(key => {
  4658. Object.defineProperty(target, key, {
  4659. configurable: true,
  4660. enumerable: false,
  4661. get: () => publicPropertiesMap[key](instance),
  4662. // intercepted by the proxy so no need for implementation,
  4663. // but needed to prevent set errors
  4664. set: NOOP
  4665. });
  4666. });
  4667. return target;
  4668. }
  4669. // dev only
  4670. function exposePropsOnRenderContext(instance) {
  4671. const { ctx, propsOptions: [propsOptions] } = instance;
  4672. if (propsOptions) {
  4673. Object.keys(propsOptions).forEach(key => {
  4674. Object.defineProperty(ctx, key, {
  4675. enumerable: true,
  4676. configurable: true,
  4677. get: () => instance.props[key],
  4678. set: NOOP
  4679. });
  4680. });
  4681. }
  4682. }
  4683. // dev only
  4684. function exposeSetupStateOnRenderContext(instance) {
  4685. const { ctx, setupState } = instance;
  4686. Object.keys(toRaw(setupState)).forEach(key => {
  4687. if (!setupState.__isScriptSetup) {
  4688. if (isReservedPrefix(key[0])) {
  4689. warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
  4690. `which are reserved prefixes for Vue internals.`);
  4691. return;
  4692. }
  4693. Object.defineProperty(ctx, key, {
  4694. enumerable: true,
  4695. configurable: true,
  4696. get: () => setupState[key],
  4697. set: NOOP
  4698. });
  4699. }
  4700. });
  4701. }
  4702. function createDuplicateChecker() {
  4703. const cache = Object.create(null);
  4704. return (type, key) => {
  4705. if (cache[key]) {
  4706. warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
  4707. }
  4708. else {
  4709. cache[key] = type;
  4710. }
  4711. };
  4712. }
  4713. let shouldCacheAccess = true;
  4714. function applyOptions(instance) {
  4715. const options = resolveMergedOptions(instance);
  4716. const publicThis = instance.proxy;
  4717. const ctx = instance.ctx;
  4718. // do not cache property access on public proxy during state initialization
  4719. shouldCacheAccess = false;
  4720. // call beforeCreate first before accessing other options since
  4721. // the hook may mutate resolved options (#2791)
  4722. if (options.beforeCreate) {
  4723. callHook(options.beforeCreate, instance, "bc" /* BEFORE_CREATE */);
  4724. }
  4725. const {
  4726. // state
  4727. data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
  4728. // lifecycle
  4729. created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
  4730. // public API
  4731. expose, inheritAttrs,
  4732. // assets
  4733. components, directives, filters } = options;
  4734. const checkDuplicateProperties = createDuplicateChecker() ;
  4735. {
  4736. const [propsOptions] = instance.propsOptions;
  4737. if (propsOptions) {
  4738. for (const key in propsOptions) {
  4739. checkDuplicateProperties("Props" /* PROPS */, key);
  4740. }
  4741. }
  4742. }
  4743. // options initialization order (to be consistent with Vue 2):
  4744. // - props (already done outside of this function)
  4745. // - inject
  4746. // - methods
  4747. // - data (deferred since it relies on `this` access)
  4748. // - computed
  4749. // - watch (deferred since it relies on `this` access)
  4750. if (injectOptions) {
  4751. resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);
  4752. }
  4753. if (methods) {
  4754. for (const key in methods) {
  4755. const methodHandler = methods[key];
  4756. if (isFunction(methodHandler)) {
  4757. // In dev mode, we use the `createRenderContext` function to define
  4758. // methods to the proxy target, and those are read-only but
  4759. // reconfigurable, so it needs to be redefined here
  4760. {
  4761. Object.defineProperty(ctx, key, {
  4762. value: methodHandler.bind(publicThis),
  4763. configurable: true,
  4764. enumerable: true,
  4765. writable: true
  4766. });
  4767. }
  4768. {
  4769. checkDuplicateProperties("Methods" /* METHODS */, key);
  4770. }
  4771. }
  4772. else {
  4773. warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
  4774. `Did you reference the function correctly?`);
  4775. }
  4776. }
  4777. }
  4778. if (dataOptions) {
  4779. if (!isFunction(dataOptions)) {
  4780. warn$1(`The data option must be a function. ` +
  4781. `Plain object usage is no longer supported.`);
  4782. }
  4783. const data = dataOptions.call(publicThis, publicThis);
  4784. if (isPromise(data)) {
  4785. warn$1(`data() returned a Promise - note data() cannot be async; If you ` +
  4786. `intend to perform data fetching before component renders, use ` +
  4787. `async setup() + <Suspense>.`);
  4788. }
  4789. if (!isObject(data)) {
  4790. warn$1(`data() should return an object.`);
  4791. }
  4792. else {
  4793. instance.data = reactive(data);
  4794. {
  4795. for (const key in data) {
  4796. checkDuplicateProperties("Data" /* DATA */, key);
  4797. // expose data on ctx during dev
  4798. if (!isReservedPrefix(key[0])) {
  4799. Object.defineProperty(ctx, key, {
  4800. configurable: true,
  4801. enumerable: true,
  4802. get: () => data[key],
  4803. set: NOOP
  4804. });
  4805. }
  4806. }
  4807. }
  4808. }
  4809. }
  4810. // state initialization complete at this point - start caching access
  4811. shouldCacheAccess = true;
  4812. if (computedOptions) {
  4813. for (const key in computedOptions) {
  4814. const opt = computedOptions[key];
  4815. const get = isFunction(opt)
  4816. ? opt.bind(publicThis, publicThis)
  4817. : isFunction(opt.get)
  4818. ? opt.get.bind(publicThis, publicThis)
  4819. : NOOP;
  4820. if (get === NOOP) {
  4821. warn$1(`Computed property "${key}" has no getter.`);
  4822. }
  4823. const set = !isFunction(opt) && isFunction(opt.set)
  4824. ? opt.set.bind(publicThis)
  4825. : () => {
  4826. warn$1(`Write operation failed: computed property "${key}" is readonly.`);
  4827. }
  4828. ;
  4829. const c = computed$1({
  4830. get,
  4831. set
  4832. });
  4833. Object.defineProperty(ctx, key, {
  4834. enumerable: true,
  4835. configurable: true,
  4836. get: () => c.value,
  4837. set: v => (c.value = v)
  4838. });
  4839. {
  4840. checkDuplicateProperties("Computed" /* COMPUTED */, key);
  4841. }
  4842. }
  4843. }
  4844. if (watchOptions) {
  4845. for (const key in watchOptions) {
  4846. createWatcher(watchOptions[key], ctx, publicThis, key);
  4847. }
  4848. }
  4849. if (provideOptions) {
  4850. const provides = isFunction(provideOptions)
  4851. ? provideOptions.call(publicThis)
  4852. : provideOptions;
  4853. Reflect.ownKeys(provides).forEach(key => {
  4854. provide(key, provides[key]);
  4855. });
  4856. }
  4857. if (created) {
  4858. callHook(created, instance, "c" /* CREATED */);
  4859. }
  4860. function registerLifecycleHook(register, hook) {
  4861. if (isArray(hook)) {
  4862. hook.forEach(_hook => register(_hook.bind(publicThis)));
  4863. }
  4864. else if (hook) {
  4865. register(hook.bind(publicThis));
  4866. }
  4867. }
  4868. registerLifecycleHook(onBeforeMount, beforeMount);
  4869. registerLifecycleHook(onMounted, mounted);
  4870. registerLifecycleHook(onBeforeUpdate, beforeUpdate);
  4871. registerLifecycleHook(onUpdated, updated);
  4872. registerLifecycleHook(onActivated, activated);
  4873. registerLifecycleHook(onDeactivated, deactivated);
  4874. registerLifecycleHook(onErrorCaptured, errorCaptured);
  4875. registerLifecycleHook(onRenderTracked, renderTracked);
  4876. registerLifecycleHook(onRenderTriggered, renderTriggered);
  4877. registerLifecycleHook(onBeforeUnmount, beforeUnmount);
  4878. registerLifecycleHook(onUnmounted, unmounted);
  4879. registerLifecycleHook(onServerPrefetch, serverPrefetch);
  4880. if (isArray(expose)) {
  4881. if (expose.length) {
  4882. const exposed = instance.exposed || (instance.exposed = {});
  4883. expose.forEach(key => {
  4884. Object.defineProperty(exposed, key, {
  4885. get: () => publicThis[key],
  4886. set: val => (publicThis[key] = val)
  4887. });
  4888. });
  4889. }
  4890. else if (!instance.exposed) {
  4891. instance.exposed = {};
  4892. }
  4893. }
  4894. // options that are handled when creating the instance but also need to be
  4895. // applied from mixins
  4896. if (render && instance.render === NOOP) {
  4897. instance.render = render;
  4898. }
  4899. if (inheritAttrs != null) {
  4900. instance.inheritAttrs = inheritAttrs;
  4901. }
  4902. // asset options.
  4903. if (components)
  4904. instance.components = components;
  4905. if (directives)
  4906. instance.directives = directives;
  4907. }
  4908. function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
  4909. if (isArray(injectOptions)) {
  4910. injectOptions = normalizeInject(injectOptions);
  4911. }
  4912. for (const key in injectOptions) {
  4913. const opt = injectOptions[key];
  4914. let injected;
  4915. if (isObject(opt)) {
  4916. if ('default' in opt) {
  4917. injected = inject(opt.from || key, opt.default, true /* treat default function as factory */);
  4918. }
  4919. else {
  4920. injected = inject(opt.from || key);
  4921. }
  4922. }
  4923. else {
  4924. injected = inject(opt);
  4925. }
  4926. if (isRef(injected)) {
  4927. // TODO remove the check in 3.3
  4928. if (unwrapRef) {
  4929. Object.defineProperty(ctx, key, {
  4930. enumerable: true,
  4931. configurable: true,
  4932. get: () => injected.value,
  4933. set: v => (injected.value = v)
  4934. });
  4935. }
  4936. else {
  4937. {
  4938. warn$1(`injected property "${key}" is a ref and will be auto-unwrapped ` +
  4939. `and no longer needs \`.value\` in the next minor release. ` +
  4940. `To opt-in to the new behavior now, ` +
  4941. `set \`app.config.unwrapInjectedRef = true\` (this config is ` +
  4942. `temporary and will not be needed in the future.)`);
  4943. }
  4944. ctx[key] = injected;
  4945. }
  4946. }
  4947. else {
  4948. ctx[key] = injected;
  4949. }
  4950. {
  4951. checkDuplicateProperties("Inject" /* INJECT */, key);
  4952. }
  4953. }
  4954. }
  4955. function callHook(hook, instance, type) {
  4956. callWithAsyncErrorHandling(isArray(hook)
  4957. ? hook.map(h => h.bind(instance.proxy))
  4958. : hook.bind(instance.proxy), instance, type);
  4959. }
  4960. function createWatcher(raw, ctx, publicThis, key) {
  4961. const getter = key.includes('.')
  4962. ? createPathGetter(publicThis, key)
  4963. : () => publicThis[key];
  4964. if (isString(raw)) {
  4965. const handler = ctx[raw];
  4966. if (isFunction(handler)) {
  4967. watch(getter, handler);
  4968. }
  4969. else {
  4970. warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
  4971. }
  4972. }
  4973. else if (isFunction(raw)) {
  4974. watch(getter, raw.bind(publicThis));
  4975. }
  4976. else if (isObject(raw)) {
  4977. if (isArray(raw)) {
  4978. raw.forEach(r => createWatcher(r, ctx, publicThis, key));
  4979. }
  4980. else {
  4981. const handler = isFunction(raw.handler)
  4982. ? raw.handler.bind(publicThis)
  4983. : ctx[raw.handler];
  4984. if (isFunction(handler)) {
  4985. watch(getter, handler, raw);
  4986. }
  4987. else {
  4988. warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
  4989. }
  4990. }
  4991. }
  4992. else {
  4993. warn$1(`Invalid watch option: "${key}"`, raw);
  4994. }
  4995. }
  4996. /**
  4997. * Resolve merged options and cache it on the component.
  4998. * This is done only once per-component since the merging does not involve
  4999. * instances.
  5000. */
  5001. function resolveMergedOptions(instance) {
  5002. const base = instance.type;
  5003. const { mixins, extends: extendsOptions } = base;
  5004. const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
  5005. const cached = cache.get(base);
  5006. let resolved;
  5007. if (cached) {
  5008. resolved = cached;
  5009. }
  5010. else if (!globalMixins.length && !mixins && !extendsOptions) {
  5011. {
  5012. resolved = base;
  5013. }
  5014. }
  5015. else {
  5016. resolved = {};
  5017. if (globalMixins.length) {
  5018. globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
  5019. }
  5020. mergeOptions(resolved, base, optionMergeStrategies);
  5021. }
  5022. cache.set(base, resolved);
  5023. return resolved;
  5024. }
  5025. function mergeOptions(to, from, strats, asMixin = false) {
  5026. const { mixins, extends: extendsOptions } = from;
  5027. if (extendsOptions) {
  5028. mergeOptions(to, extendsOptions, strats, true);
  5029. }
  5030. if (mixins) {
  5031. mixins.forEach((m) => mergeOptions(to, m, strats, true));
  5032. }
  5033. for (const key in from) {
  5034. if (asMixin && key === 'expose') {
  5035. warn$1(`"expose" option is ignored when declared in mixins or extends. ` +
  5036. `It should only be declared in the base component itself.`);
  5037. }
  5038. else {
  5039. const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
  5040. to[key] = strat ? strat(to[key], from[key]) : from[key];
  5041. }
  5042. }
  5043. return to;
  5044. }
  5045. const internalOptionMergeStrats = {
  5046. data: mergeDataFn,
  5047. props: mergeObjectOptions,
  5048. emits: mergeObjectOptions,
  5049. // objects
  5050. methods: mergeObjectOptions,
  5051. computed: mergeObjectOptions,
  5052. // lifecycle
  5053. beforeCreate: mergeAsArray,
  5054. created: mergeAsArray,
  5055. beforeMount: mergeAsArray,
  5056. mounted: mergeAsArray,
  5057. beforeUpdate: mergeAsArray,
  5058. updated: mergeAsArray,
  5059. beforeDestroy: mergeAsArray,
  5060. beforeUnmount: mergeAsArray,
  5061. destroyed: mergeAsArray,
  5062. unmounted: mergeAsArray,
  5063. activated: mergeAsArray,
  5064. deactivated: mergeAsArray,
  5065. errorCaptured: mergeAsArray,
  5066. serverPrefetch: mergeAsArray,
  5067. // assets
  5068. components: mergeObjectOptions,
  5069. directives: mergeObjectOptions,
  5070. // watch
  5071. watch: mergeWatchOptions,
  5072. // provide / inject
  5073. provide: mergeDataFn,
  5074. inject: mergeInject
  5075. };
  5076. function mergeDataFn(to, from) {
  5077. if (!from) {
  5078. return to;
  5079. }
  5080. if (!to) {
  5081. return from;
  5082. }
  5083. return function mergedDataFn() {
  5084. return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
  5085. };
  5086. }
  5087. function mergeInject(to, from) {
  5088. return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
  5089. }
  5090. function normalizeInject(raw) {
  5091. if (isArray(raw)) {
  5092. const res = {};
  5093. for (let i = 0; i < raw.length; i++) {
  5094. res[raw[i]] = raw[i];
  5095. }
  5096. return res;
  5097. }
  5098. return raw;
  5099. }
  5100. function mergeAsArray(to, from) {
  5101. return to ? [...new Set([].concat(to, from))] : from;
  5102. }
  5103. function mergeObjectOptions(to, from) {
  5104. return to ? extend(extend(Object.create(null), to), from) : from;
  5105. }
  5106. function mergeWatchOptions(to, from) {
  5107. if (!to)
  5108. return from;
  5109. if (!from)
  5110. return to;
  5111. const merged = extend(Object.create(null), to);
  5112. for (const key in from) {
  5113. merged[key] = mergeAsArray(to[key], from[key]);
  5114. }
  5115. return merged;
  5116. }
  5117. function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
  5118. isSSR = false) {
  5119. const props = {};
  5120. const attrs = {};
  5121. def(attrs, InternalObjectKey, 1);
  5122. instance.propsDefaults = Object.create(null);
  5123. setFullProps(instance, rawProps, props, attrs);
  5124. // ensure all declared prop keys are present
  5125. for (const key in instance.propsOptions[0]) {
  5126. if (!(key in props)) {
  5127. props[key] = undefined;
  5128. }
  5129. }
  5130. // validation
  5131. {
  5132. validateProps(rawProps || {}, props, instance);
  5133. }
  5134. if (isStateful) {
  5135. // stateful
  5136. instance.props = isSSR ? props : shallowReactive(props);
  5137. }
  5138. else {
  5139. if (!instance.type.props) {
  5140. // functional w/ optional props, props === attrs
  5141. instance.props = attrs;
  5142. }
  5143. else {
  5144. // functional w/ declared props
  5145. instance.props = props;
  5146. }
  5147. }
  5148. instance.attrs = attrs;
  5149. }
  5150. function updateProps(instance, rawProps, rawPrevProps, optimized) {
  5151. const { props, attrs, vnode: { patchFlag } } = instance;
  5152. const rawCurrentProps = toRaw(props);
  5153. const [options] = instance.propsOptions;
  5154. let hasAttrsChanged = false;
  5155. if (
  5156. // always force full diff in dev
  5157. // - #1942 if hmr is enabled with sfc component
  5158. // - vite#872 non-sfc component used by sfc component
  5159. !((instance.type.__hmrId ||
  5160. (instance.parent && instance.parent.type.__hmrId))) &&
  5161. (optimized || patchFlag > 0) &&
  5162. !(patchFlag & 16 /* FULL_PROPS */)) {
  5163. if (patchFlag & 8 /* PROPS */) {
  5164. // Compiler-generated props & no keys change, just set the updated
  5165. // the props.
  5166. const propsToUpdate = instance.vnode.dynamicProps;
  5167. for (let i = 0; i < propsToUpdate.length; i++) {
  5168. let key = propsToUpdate[i];
  5169. // skip if the prop key is a declared emit event listener
  5170. if (isEmitListener(instance.emitsOptions, key)) {
  5171. continue;
  5172. }
  5173. // PROPS flag guarantees rawProps to be non-null
  5174. const value = rawProps[key];
  5175. if (options) {
  5176. // attr / props separation was done on init and will be consistent
  5177. // in this code path, so just check if attrs have it.
  5178. if (hasOwn(attrs, key)) {
  5179. if (value !== attrs[key]) {
  5180. attrs[key] = value;
  5181. hasAttrsChanged = true;
  5182. }
  5183. }
  5184. else {
  5185. const camelizedKey = camelize(key);
  5186. props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false /* isAbsent */);
  5187. }
  5188. }
  5189. else {
  5190. if (value !== attrs[key]) {
  5191. attrs[key] = value;
  5192. hasAttrsChanged = true;
  5193. }
  5194. }
  5195. }
  5196. }
  5197. }
  5198. else {
  5199. // full props update.
  5200. if (setFullProps(instance, rawProps, props, attrs)) {
  5201. hasAttrsChanged = true;
  5202. }
  5203. // in case of dynamic props, check if we need to delete keys from
  5204. // the props object
  5205. let kebabKey;
  5206. for (const key in rawCurrentProps) {
  5207. if (!rawProps ||
  5208. // for camelCase
  5209. (!hasOwn(rawProps, key) &&
  5210. // it's possible the original props was passed in as kebab-case
  5211. // and converted to camelCase (#955)
  5212. ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
  5213. if (options) {
  5214. if (rawPrevProps &&
  5215. // for camelCase
  5216. (rawPrevProps[key] !== undefined ||
  5217. // for kebab-case
  5218. rawPrevProps[kebabKey] !== undefined)) {
  5219. props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true /* isAbsent */);
  5220. }
  5221. }
  5222. else {
  5223. delete props[key];
  5224. }
  5225. }
  5226. }
  5227. // in the case of functional component w/o props declaration, props and
  5228. // attrs point to the same object so it should already have been updated.
  5229. if (attrs !== rawCurrentProps) {
  5230. for (const key in attrs) {
  5231. if (!rawProps ||
  5232. (!hasOwn(rawProps, key) &&
  5233. (!false ))) {
  5234. delete attrs[key];
  5235. hasAttrsChanged = true;
  5236. }
  5237. }
  5238. }
  5239. }
  5240. // trigger updates for $attrs in case it's used in component slots
  5241. if (hasAttrsChanged) {
  5242. trigger(instance, "set" /* SET */, '$attrs');
  5243. }
  5244. {
  5245. validateProps(rawProps || {}, props, instance);
  5246. }
  5247. }
  5248. function setFullProps(instance, rawProps, props, attrs) {
  5249. const [options, needCastKeys] = instance.propsOptions;
  5250. let hasAttrsChanged = false;
  5251. let rawCastValues;
  5252. if (rawProps) {
  5253. for (let key in rawProps) {
  5254. // key, ref are reserved and never passed down
  5255. if (isReservedProp(key)) {
  5256. continue;
  5257. }
  5258. const value = rawProps[key];
  5259. // prop option names are camelized during normalization, so to support
  5260. // kebab -> camel conversion here we need to camelize the key.
  5261. let camelKey;
  5262. if (options && hasOwn(options, (camelKey = camelize(key)))) {
  5263. if (!needCastKeys || !needCastKeys.includes(camelKey)) {
  5264. props[camelKey] = value;
  5265. }
  5266. else {
  5267. (rawCastValues || (rawCastValues = {}))[camelKey] = value;
  5268. }
  5269. }
  5270. else if (!isEmitListener(instance.emitsOptions, key)) {
  5271. if (!(key in attrs) || value !== attrs[key]) {
  5272. attrs[key] = value;
  5273. hasAttrsChanged = true;
  5274. }
  5275. }
  5276. }
  5277. }
  5278. if (needCastKeys) {
  5279. const rawCurrentProps = toRaw(props);
  5280. const castValues = rawCastValues || EMPTY_OBJ;
  5281. for (let i = 0; i < needCastKeys.length; i++) {
  5282. const key = needCastKeys[i];
  5283. props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
  5284. }
  5285. }
  5286. return hasAttrsChanged;
  5287. }
  5288. function resolvePropValue(options, props, key, value, instance, isAbsent) {
  5289. const opt = options[key];
  5290. if (opt != null) {
  5291. const hasDefault = hasOwn(opt, 'default');
  5292. // default values
  5293. if (hasDefault && value === undefined) {
  5294. const defaultValue = opt.default;
  5295. if (opt.type !== Function && isFunction(defaultValue)) {
  5296. const { propsDefaults } = instance;
  5297. if (key in propsDefaults) {
  5298. value = propsDefaults[key];
  5299. }
  5300. else {
  5301. setCurrentInstance(instance);
  5302. value = propsDefaults[key] = defaultValue.call(null, props);
  5303. unsetCurrentInstance();
  5304. }
  5305. }
  5306. else {
  5307. value = defaultValue;
  5308. }
  5309. }
  5310. // boolean casting
  5311. if (opt[0 /* shouldCast */]) {
  5312. if (isAbsent && !hasDefault) {
  5313. value = false;
  5314. }
  5315. else if (opt[1 /* shouldCastTrue */] &&
  5316. (value === '' || value === hyphenate(key))) {
  5317. value = true;
  5318. }
  5319. }
  5320. }
  5321. return value;
  5322. }
  5323. function normalizePropsOptions(comp, appContext, asMixin = false) {
  5324. const cache = appContext.propsCache;
  5325. const cached = cache.get(comp);
  5326. if (cached) {
  5327. return cached;
  5328. }
  5329. const raw = comp.props;
  5330. const normalized = {};
  5331. const needCastKeys = [];
  5332. // apply mixin/extends props
  5333. let hasExtends = false;
  5334. if (!isFunction(comp)) {
  5335. const extendProps = (raw) => {
  5336. hasExtends = true;
  5337. const [props, keys] = normalizePropsOptions(raw, appContext, true);
  5338. extend(normalized, props);
  5339. if (keys)
  5340. needCastKeys.push(...keys);
  5341. };
  5342. if (!asMixin && appContext.mixins.length) {
  5343. appContext.mixins.forEach(extendProps);
  5344. }
  5345. if (comp.extends) {
  5346. extendProps(comp.extends);
  5347. }
  5348. if (comp.mixins) {
  5349. comp.mixins.forEach(extendProps);
  5350. }
  5351. }
  5352. if (!raw && !hasExtends) {
  5353. cache.set(comp, EMPTY_ARR);
  5354. return EMPTY_ARR;
  5355. }
  5356. if (isArray(raw)) {
  5357. for (let i = 0; i < raw.length; i++) {
  5358. if (!isString(raw[i])) {
  5359. warn$1(`props must be strings when using array syntax.`, raw[i]);
  5360. }
  5361. const normalizedKey = camelize(raw[i]);
  5362. if (validatePropName(normalizedKey)) {
  5363. normalized[normalizedKey] = EMPTY_OBJ;
  5364. }
  5365. }
  5366. }
  5367. else if (raw) {
  5368. if (!isObject(raw)) {
  5369. warn$1(`invalid props options`, raw);
  5370. }
  5371. for (const key in raw) {
  5372. const normalizedKey = camelize(key);
  5373. if (validatePropName(normalizedKey)) {
  5374. const opt = raw[key];
  5375. const prop = (normalized[normalizedKey] =
  5376. isArray(opt) || isFunction(opt) ? { type: opt } : opt);
  5377. if (prop) {
  5378. const booleanIndex = getTypeIndex(Boolean, prop.type);
  5379. const stringIndex = getTypeIndex(String, prop.type);
  5380. prop[0 /* shouldCast */] = booleanIndex > -1;
  5381. prop[1 /* shouldCastTrue */] =
  5382. stringIndex < 0 || booleanIndex < stringIndex;
  5383. // if the prop needs boolean casting or default value
  5384. if (booleanIndex > -1 || hasOwn(prop, 'default')) {
  5385. needCastKeys.push(normalizedKey);
  5386. }
  5387. }
  5388. }
  5389. }
  5390. }
  5391. const res = [normalized, needCastKeys];
  5392. cache.set(comp, res);
  5393. return res;
  5394. }
  5395. function validatePropName(key) {
  5396. if (key[0] !== '$') {
  5397. return true;
  5398. }
  5399. else {
  5400. warn$1(`Invalid prop name: "${key}" is a reserved property.`);
  5401. }
  5402. return false;
  5403. }
  5404. // use function string name to check type constructors
  5405. // so that it works across vms / iframes.
  5406. function getType(ctor) {
  5407. const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
  5408. return match ? match[1] : ctor === null ? 'null' : '';
  5409. }
  5410. function isSameType(a, b) {
  5411. return getType(a) === getType(b);
  5412. }
  5413. function getTypeIndex(type, expectedTypes) {
  5414. if (isArray(expectedTypes)) {
  5415. return expectedTypes.findIndex(t => isSameType(t, type));
  5416. }
  5417. else if (isFunction(expectedTypes)) {
  5418. return isSameType(expectedTypes, type) ? 0 : -1;
  5419. }
  5420. return -1;
  5421. }
  5422. /**
  5423. * dev only
  5424. */
  5425. function validateProps(rawProps, props, instance) {
  5426. const resolvedValues = toRaw(props);
  5427. const options = instance.propsOptions[0];
  5428. for (const key in options) {
  5429. let opt = options[key];
  5430. if (opt == null)
  5431. continue;
  5432. validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)));
  5433. }
  5434. }
  5435. /**
  5436. * dev only
  5437. */
  5438. function validateProp(name, value, prop, isAbsent) {
  5439. const { type, required, validator } = prop;
  5440. // required!
  5441. if (required && isAbsent) {
  5442. warn$1('Missing required prop: "' + name + '"');
  5443. return;
  5444. }
  5445. // missing but optional
  5446. if (value == null && !prop.required) {
  5447. return;
  5448. }
  5449. // type check
  5450. if (type != null && type !== true) {
  5451. let isValid = false;
  5452. const types = isArray(type) ? type : [type];
  5453. const expectedTypes = [];
  5454. // value is valid as long as one of the specified types match
  5455. for (let i = 0; i < types.length && !isValid; i++) {
  5456. const { valid, expectedType } = assertType(value, types[i]);
  5457. expectedTypes.push(expectedType || '');
  5458. isValid = valid;
  5459. }
  5460. if (!isValid) {
  5461. warn$1(getInvalidTypeMessage(name, value, expectedTypes));
  5462. return;
  5463. }
  5464. }
  5465. // custom validator
  5466. if (validator && !validator(value)) {
  5467. warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
  5468. }
  5469. }
  5470. const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol,BigInt');
  5471. /**
  5472. * dev only
  5473. */
  5474. function assertType(value, type) {
  5475. let valid;
  5476. const expectedType = getType(type);
  5477. if (isSimpleType(expectedType)) {
  5478. const t = typeof value;
  5479. valid = t === expectedType.toLowerCase();
  5480. // for primitive wrapper objects
  5481. if (!valid && t === 'object') {
  5482. valid = value instanceof type;
  5483. }
  5484. }
  5485. else if (expectedType === 'Object') {
  5486. valid = isObject(value);
  5487. }
  5488. else if (expectedType === 'Array') {
  5489. valid = isArray(value);
  5490. }
  5491. else if (expectedType === 'null') {
  5492. valid = value === null;
  5493. }
  5494. else {
  5495. valid = value instanceof type;
  5496. }
  5497. return {
  5498. valid,
  5499. expectedType
  5500. };
  5501. }
  5502. /**
  5503. * dev only
  5504. */
  5505. function getInvalidTypeMessage(name, value, expectedTypes) {
  5506. let message = `Invalid prop: type check failed for prop "${name}".` +
  5507. ` Expected ${expectedTypes.map(capitalize).join(' | ')}`;
  5508. const expectedType = expectedTypes[0];
  5509. const receivedType = toRawType(value);
  5510. const expectedValue = styleValue(value, expectedType);
  5511. const receivedValue = styleValue(value, receivedType);
  5512. // check if we need to specify expected value
  5513. if (expectedTypes.length === 1 &&
  5514. isExplicable(expectedType) &&
  5515. !isBoolean(expectedType, receivedType)) {
  5516. message += ` with value ${expectedValue}`;
  5517. }
  5518. message += `, got ${receivedType} `;
  5519. // check if we need to specify received value
  5520. if (isExplicable(receivedType)) {
  5521. message += `with value ${receivedValue}.`;
  5522. }
  5523. return message;
  5524. }
  5525. /**
  5526. * dev only
  5527. */
  5528. function styleValue(value, type) {
  5529. if (type === 'String') {
  5530. return `"${value}"`;
  5531. }
  5532. else if (type === 'Number') {
  5533. return `${Number(value)}`;
  5534. }
  5535. else {
  5536. return `${value}`;
  5537. }
  5538. }
  5539. /**
  5540. * dev only
  5541. */
  5542. function isExplicable(type) {
  5543. const explicitTypes = ['string', 'number', 'boolean'];
  5544. return explicitTypes.some(elem => type.toLowerCase() === elem);
  5545. }
  5546. /**
  5547. * dev only
  5548. */
  5549. function isBoolean(...args) {
  5550. return args.some(elem => elem.toLowerCase() === 'boolean');
  5551. }
  5552. const isInternalKey = (key) => key[0] === '_' || key === '$stable';
  5553. const normalizeSlotValue = (value) => isArray(value)
  5554. ? value.map(normalizeVNode)
  5555. : [normalizeVNode(value)];
  5556. const normalizeSlot = (key, rawSlot, ctx) => {
  5557. if (rawSlot._n) {
  5558. // already normalized - #5353
  5559. return rawSlot;
  5560. }
  5561. const normalized = withCtx((...args) => {
  5562. if (currentInstance) {
  5563. warn$1(`Slot "${key}" invoked outside of the render function: ` +
  5564. `this will not track dependencies used in the slot. ` +
  5565. `Invoke the slot function inside the render function instead.`);
  5566. }
  5567. return normalizeSlotValue(rawSlot(...args));
  5568. }, ctx);
  5569. normalized._c = false;
  5570. return normalized;
  5571. };
  5572. const normalizeObjectSlots = (rawSlots, slots, instance) => {
  5573. const ctx = rawSlots._ctx;
  5574. for (const key in rawSlots) {
  5575. if (isInternalKey(key))
  5576. continue;
  5577. const value = rawSlots[key];
  5578. if (isFunction(value)) {
  5579. slots[key] = normalizeSlot(key, value, ctx);
  5580. }
  5581. else if (value != null) {
  5582. {
  5583. warn$1(`Non-function value encountered for slot "${key}". ` +
  5584. `Prefer function slots for better performance.`);
  5585. }
  5586. const normalized = normalizeSlotValue(value);
  5587. slots[key] = () => normalized;
  5588. }
  5589. }
  5590. };
  5591. const normalizeVNodeSlots = (instance, children) => {
  5592. if (!isKeepAlive(instance.vnode) &&
  5593. !(false )) {
  5594. warn$1(`Non-function value encountered for default slot. ` +
  5595. `Prefer function slots for better performance.`);
  5596. }
  5597. const normalized = normalizeSlotValue(children);
  5598. instance.slots.default = () => normalized;
  5599. };
  5600. const initSlots = (instance, children) => {
  5601. if (instance.vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
  5602. const type = children._;
  5603. if (type) {
  5604. // users can get the shallow readonly version of the slots object through `this.$slots`,
  5605. // we should avoid the proxy object polluting the slots of the internal instance
  5606. instance.slots = toRaw(children);
  5607. // make compiler marker non-enumerable
  5608. def(children, '_', type);
  5609. }
  5610. else {
  5611. normalizeObjectSlots(children, (instance.slots = {}));
  5612. }
  5613. }
  5614. else {
  5615. instance.slots = {};
  5616. if (children) {
  5617. normalizeVNodeSlots(instance, children);
  5618. }
  5619. }
  5620. def(instance.slots, InternalObjectKey, 1);
  5621. };
  5622. const updateSlots = (instance, children, optimized) => {
  5623. const { vnode, slots } = instance;
  5624. let needDeletionCheck = true;
  5625. let deletionComparisonTarget = EMPTY_OBJ;
  5626. if (vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
  5627. const type = children._;
  5628. if (type) {
  5629. // compiled slots.
  5630. if (isHmrUpdating) {
  5631. // Parent was HMR updated so slot content may have changed.
  5632. // force update slots and mark instance for hmr as well
  5633. extend(slots, children);
  5634. }
  5635. else if (optimized && type === 1 /* STABLE */) {
  5636. // compiled AND stable.
  5637. // no need to update, and skip stale slots removal.
  5638. needDeletionCheck = false;
  5639. }
  5640. else {
  5641. // compiled but dynamic (v-if/v-for on slots) - update slots, but skip
  5642. // normalization.
  5643. extend(slots, children);
  5644. // #2893
  5645. // when rendering the optimized slots by manually written render function,
  5646. // we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
  5647. // i.e. let the `renderSlot` create the bailed Fragment
  5648. if (!optimized && type === 1 /* STABLE */) {
  5649. delete slots._;
  5650. }
  5651. }
  5652. }
  5653. else {
  5654. needDeletionCheck = !children.$stable;
  5655. normalizeObjectSlots(children, slots);
  5656. }
  5657. deletionComparisonTarget = children;
  5658. }
  5659. else if (children) {
  5660. // non slot object children (direct value) passed to a component
  5661. normalizeVNodeSlots(instance, children);
  5662. deletionComparisonTarget = { default: 1 };
  5663. }
  5664. // delete stale slots
  5665. if (needDeletionCheck) {
  5666. for (const key in slots) {
  5667. if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
  5668. delete slots[key];
  5669. }
  5670. }
  5671. }
  5672. };
  5673. function createAppContext() {
  5674. return {
  5675. app: null,
  5676. config: {
  5677. isNativeTag: NO,
  5678. performance: false,
  5679. globalProperties: {},
  5680. optionMergeStrategies: {},
  5681. errorHandler: undefined,
  5682. warnHandler: undefined,
  5683. compilerOptions: {}
  5684. },
  5685. mixins: [],
  5686. components: {},
  5687. directives: {},
  5688. provides: Object.create(null),
  5689. optionsCache: new WeakMap(),
  5690. propsCache: new WeakMap(),
  5691. emitsCache: new WeakMap()
  5692. };
  5693. }
  5694. let uid = 0;
  5695. function createAppAPI(render, hydrate) {
  5696. return function createApp(rootComponent, rootProps = null) {
  5697. if (!isFunction(rootComponent)) {
  5698. rootComponent = Object.assign({}, rootComponent);
  5699. }
  5700. if (rootProps != null && !isObject(rootProps)) {
  5701. warn$1(`root props passed to app.mount() must be an object.`);
  5702. rootProps = null;
  5703. }
  5704. const context = createAppContext();
  5705. const installedPlugins = new Set();
  5706. let isMounted = false;
  5707. const app = (context.app = {
  5708. _uid: uid++,
  5709. _component: rootComponent,
  5710. _props: rootProps,
  5711. _container: null,
  5712. _context: context,
  5713. _instance: null,
  5714. version,
  5715. get config() {
  5716. return context.config;
  5717. },
  5718. set config(v) {
  5719. {
  5720. warn$1(`app.config cannot be replaced. Modify individual options instead.`);
  5721. }
  5722. },
  5723. use(plugin, ...options) {
  5724. if (installedPlugins.has(plugin)) {
  5725. warn$1(`Plugin has already been applied to target app.`);
  5726. }
  5727. else if (plugin && isFunction(plugin.install)) {
  5728. installedPlugins.add(plugin);
  5729. plugin.install(app, ...options);
  5730. }
  5731. else if (isFunction(plugin)) {
  5732. installedPlugins.add(plugin);
  5733. plugin(app, ...options);
  5734. }
  5735. else {
  5736. warn$1(`A plugin must either be a function or an object with an "install" ` +
  5737. `function.`);
  5738. }
  5739. return app;
  5740. },
  5741. mixin(mixin) {
  5742. {
  5743. if (!context.mixins.includes(mixin)) {
  5744. context.mixins.push(mixin);
  5745. }
  5746. else {
  5747. warn$1('Mixin has already been applied to target app' +
  5748. (mixin.name ? `: ${mixin.name}` : ''));
  5749. }
  5750. }
  5751. return app;
  5752. },
  5753. component(name, component) {
  5754. {
  5755. validateComponentName(name, context.config);
  5756. }
  5757. if (!component) {
  5758. return context.components[name];
  5759. }
  5760. if (context.components[name]) {
  5761. warn$1(`Component "${name}" has already been registered in target app.`);
  5762. }
  5763. context.components[name] = component;
  5764. return app;
  5765. },
  5766. directive(name, directive) {
  5767. {
  5768. validateDirectiveName(name);
  5769. }
  5770. if (!directive) {
  5771. return context.directives[name];
  5772. }
  5773. if (context.directives[name]) {
  5774. warn$1(`Directive "${name}" has already been registered in target app.`);
  5775. }
  5776. context.directives[name] = directive;
  5777. return app;
  5778. },
  5779. mount(rootContainer, isHydrate, isSVG) {
  5780. if (!isMounted) {
  5781. // #5571
  5782. if (rootContainer.__vue_app__) {
  5783. warn$1(`There is already an app instance mounted on the host container.\n` +
  5784. ` If you want to mount another app on the same host container,` +
  5785. ` you need to unmount the previous app by calling \`app.unmount()\` first.`);
  5786. }
  5787. const vnode = createVNode(rootComponent, rootProps);
  5788. // store app context on the root VNode.
  5789. // this will be set on the root instance on initial mount.
  5790. vnode.appContext = context;
  5791. // HMR root reload
  5792. {
  5793. context.reload = () => {
  5794. render(cloneVNode(vnode), rootContainer, isSVG);
  5795. };
  5796. }
  5797. if (isHydrate && hydrate) {
  5798. hydrate(vnode, rootContainer);
  5799. }
  5800. else {
  5801. render(vnode, rootContainer, isSVG);
  5802. }
  5803. isMounted = true;
  5804. app._container = rootContainer;
  5805. rootContainer.__vue_app__ = app;
  5806. {
  5807. app._instance = vnode.component;
  5808. devtoolsInitApp(app, version);
  5809. }
  5810. return getExposeProxy(vnode.component) || vnode.component.proxy;
  5811. }
  5812. else {
  5813. warn$1(`App has already been mounted.\n` +
  5814. `If you want to remount the same app, move your app creation logic ` +
  5815. `into a factory function and create fresh app instances for each ` +
  5816. `mount - e.g. \`const createMyApp = () => createApp(App)\``);
  5817. }
  5818. },
  5819. unmount() {
  5820. if (isMounted) {
  5821. render(null, app._container);
  5822. {
  5823. app._instance = null;
  5824. devtoolsUnmountApp(app);
  5825. }
  5826. delete app._container.__vue_app__;
  5827. }
  5828. else {
  5829. warn$1(`Cannot unmount an app that is not mounted.`);
  5830. }
  5831. },
  5832. provide(key, value) {
  5833. if (key in context.provides) {
  5834. warn$1(`App already provides property with key "${String(key)}". ` +
  5835. `It will be overwritten with the new value.`);
  5836. }
  5837. context.provides[key] = value;
  5838. return app;
  5839. }
  5840. });
  5841. return app;
  5842. };
  5843. }
  5844. /**
  5845. * Function for handling a template ref
  5846. */
  5847. function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
  5848. if (isArray(rawRef)) {
  5849. rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
  5850. return;
  5851. }
  5852. if (isAsyncWrapper(vnode) && !isUnmount) {
  5853. // when mounting async components, nothing needs to be done,
  5854. // because the template ref is forwarded to inner component
  5855. return;
  5856. }
  5857. const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
  5858. ? getExposeProxy(vnode.component) || vnode.component.proxy
  5859. : vnode.el;
  5860. const value = isUnmount ? null : refValue;
  5861. const { i: owner, r: ref } = rawRef;
  5862. if (!owner) {
  5863. warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
  5864. `A vnode with ref must be created inside the render function.`);
  5865. return;
  5866. }
  5867. const oldRef = oldRawRef && oldRawRef.r;
  5868. const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
  5869. const setupState = owner.setupState;
  5870. // dynamic ref changed. unset old ref
  5871. if (oldRef != null && oldRef !== ref) {
  5872. if (isString(oldRef)) {
  5873. refs[oldRef] = null;
  5874. if (hasOwn(setupState, oldRef)) {
  5875. setupState[oldRef] = null;
  5876. }
  5877. }
  5878. else if (isRef(oldRef)) {
  5879. oldRef.value = null;
  5880. }
  5881. }
  5882. if (isFunction(ref)) {
  5883. callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
  5884. }
  5885. else {
  5886. const _isString = isString(ref);
  5887. const _isRef = isRef(ref);
  5888. if (_isString || _isRef) {
  5889. const doSet = () => {
  5890. if (rawRef.f) {
  5891. const existing = _isString ? refs[ref] : ref.value;
  5892. if (isUnmount) {
  5893. isArray(existing) && remove(existing, refValue);
  5894. }
  5895. else {
  5896. if (!isArray(existing)) {
  5897. if (_isString) {
  5898. refs[ref] = [refValue];
  5899. if (hasOwn(setupState, ref)) {
  5900. setupState[ref] = refs[ref];
  5901. }
  5902. }
  5903. else {
  5904. ref.value = [refValue];
  5905. if (rawRef.k)
  5906. refs[rawRef.k] = ref.value;
  5907. }
  5908. }
  5909. else if (!existing.includes(refValue)) {
  5910. existing.push(refValue);
  5911. }
  5912. }
  5913. }
  5914. else if (_isString) {
  5915. refs[ref] = value;
  5916. if (hasOwn(setupState, ref)) {
  5917. setupState[ref] = value;
  5918. }
  5919. }
  5920. else if (_isRef) {
  5921. ref.value = value;
  5922. if (rawRef.k)
  5923. refs[rawRef.k] = value;
  5924. }
  5925. else {
  5926. warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
  5927. }
  5928. };
  5929. if (value) {
  5930. doSet.id = -1;
  5931. queuePostRenderEffect(doSet, parentSuspense);
  5932. }
  5933. else {
  5934. doSet();
  5935. }
  5936. }
  5937. else {
  5938. warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
  5939. }
  5940. }
  5941. }
  5942. let hasMismatch = false;
  5943. const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
  5944. const isComment = (node) => node.nodeType === 8 /* COMMENT */;
  5945. // Note: hydration is DOM-specific
  5946. // But we have to place it in core due to tight coupling with core - splitting
  5947. // it out creates a ton of unnecessary complexity.
  5948. // Hydration also depends on some renderer internal logic which needs to be
  5949. // passed in via arguments.
  5950. function createHydrationFunctions(rendererInternals) {
  5951. const { mt: mountComponent, p: patch, o: { patchProp, createText, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
  5952. const hydrate = (vnode, container) => {
  5953. if (!container.hasChildNodes()) {
  5954. warn$1(`Attempting to hydrate existing markup but container is empty. ` +
  5955. `Performing full mount instead.`);
  5956. patch(null, vnode, container);
  5957. flushPostFlushCbs();
  5958. container._vnode = vnode;
  5959. return;
  5960. }
  5961. hasMismatch = false;
  5962. hydrateNode(container.firstChild, vnode, null, null, null);
  5963. flushPostFlushCbs();
  5964. container._vnode = vnode;
  5965. if (hasMismatch && !false) {
  5966. // this error should show up in production
  5967. console.error(`Hydration completed but contains mismatches.`);
  5968. }
  5969. };
  5970. const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
  5971. const isFragmentStart = isComment(node) && node.data === '[';
  5972. const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
  5973. const { type, ref, shapeFlag, patchFlag } = vnode;
  5974. const domType = node.nodeType;
  5975. vnode.el = node;
  5976. if (patchFlag === -2 /* BAIL */) {
  5977. optimized = false;
  5978. vnode.dynamicChildren = null;
  5979. }
  5980. let nextNode = null;
  5981. switch (type) {
  5982. case Text:
  5983. if (domType !== 3 /* TEXT */) {
  5984. // #5728 empty text node inside a slot can cause hydration failure
  5985. // because the server rendered HTML won't contain a text node
  5986. if (vnode.children === '') {
  5987. insert((vnode.el = createText('')), parentNode(node), node);
  5988. nextNode = node;
  5989. }
  5990. else {
  5991. nextNode = onMismatch();
  5992. }
  5993. }
  5994. else {
  5995. if (node.data !== vnode.children) {
  5996. hasMismatch = true;
  5997. warn$1(`Hydration text mismatch:` +
  5998. `\n- Client: ${JSON.stringify(node.data)}` +
  5999. `\n- Server: ${JSON.stringify(vnode.children)}`);
  6000. node.data = vnode.children;
  6001. }
  6002. nextNode = nextSibling(node);
  6003. }
  6004. break;
  6005. case Comment:
  6006. if (domType !== 8 /* COMMENT */ || isFragmentStart) {
  6007. nextNode = onMismatch();
  6008. }
  6009. else {
  6010. nextNode = nextSibling(node);
  6011. }
  6012. break;
  6013. case Static:
  6014. if (domType !== 1 /* ELEMENT */ && domType !== 3 /* TEXT */) {
  6015. nextNode = onMismatch();
  6016. }
  6017. else {
  6018. // determine anchor, adopt content
  6019. nextNode = node;
  6020. // if the static vnode has its content stripped during build,
  6021. // adopt it from the server-rendered HTML.
  6022. const needToAdoptContent = !vnode.children.length;
  6023. for (let i = 0; i < vnode.staticCount; i++) {
  6024. if (needToAdoptContent)
  6025. vnode.children +=
  6026. nextNode.nodeType === 1 /* ELEMENT */
  6027. ? nextNode.outerHTML
  6028. : nextNode.data;
  6029. if (i === vnode.staticCount - 1) {
  6030. vnode.anchor = nextNode;
  6031. }
  6032. nextNode = nextSibling(nextNode);
  6033. }
  6034. return nextNode;
  6035. }
  6036. break;
  6037. case Fragment:
  6038. if (!isFragmentStart) {
  6039. nextNode = onMismatch();
  6040. }
  6041. else {
  6042. nextNode = hydrateFragment(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  6043. }
  6044. break;
  6045. default:
  6046. if (shapeFlag & 1 /* ELEMENT */) {
  6047. if (domType !== 1 /* ELEMENT */ ||
  6048. vnode.type.toLowerCase() !==
  6049. node.tagName.toLowerCase()) {
  6050. nextNode = onMismatch();
  6051. }
  6052. else {
  6053. nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  6054. }
  6055. }
  6056. else if (shapeFlag & 6 /* COMPONENT */) {
  6057. // when setting up the render effect, if the initial vnode already
  6058. // has .el set, the component will perform hydration instead of mount
  6059. // on its sub-tree.
  6060. vnode.slotScopeIds = slotScopeIds;
  6061. const container = parentNode(node);
  6062. mountComponent(vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), optimized);
  6063. // component may be async, so in the case of fragments we cannot rely
  6064. // on component's rendered output to determine the end of the fragment
  6065. // instead, we do a lookahead to find the end anchor node.
  6066. nextNode = isFragmentStart
  6067. ? locateClosingAsyncAnchor(node)
  6068. : nextSibling(node);
  6069. // #4293 teleport as component root
  6070. if (nextNode &&
  6071. isComment(nextNode) &&
  6072. nextNode.data === 'teleport end') {
  6073. nextNode = nextSibling(nextNode);
  6074. }
  6075. // #3787
  6076. // if component is async, it may get moved / unmounted before its
  6077. // inner component is loaded, so we need to give it a placeholder
  6078. // vnode that matches its adopted DOM.
  6079. if (isAsyncWrapper(vnode)) {
  6080. let subTree;
  6081. if (isFragmentStart) {
  6082. subTree = createVNode(Fragment);
  6083. subTree.anchor = nextNode
  6084. ? nextNode.previousSibling
  6085. : container.lastChild;
  6086. }
  6087. else {
  6088. subTree =
  6089. node.nodeType === 3 ? createTextVNode('') : createVNode('div');
  6090. }
  6091. subTree.el = node;
  6092. vnode.component.subTree = subTree;
  6093. }
  6094. }
  6095. else if (shapeFlag & 64 /* TELEPORT */) {
  6096. if (domType !== 8 /* COMMENT */) {
  6097. nextNode = onMismatch();
  6098. }
  6099. else {
  6100. nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren);
  6101. }
  6102. }
  6103. else if (shapeFlag & 128 /* SUSPENSE */) {
  6104. nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, isSVGContainer(parentNode(node)), slotScopeIds, optimized, rendererInternals, hydrateNode);
  6105. }
  6106. else {
  6107. warn$1('Invalid HostVNode type:', type, `(${typeof type})`);
  6108. }
  6109. }
  6110. if (ref != null) {
  6111. setRef(ref, null, parentSuspense, vnode);
  6112. }
  6113. return nextNode;
  6114. };
  6115. const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6116. optimized = optimized || !!vnode.dynamicChildren;
  6117. const { type, props, patchFlag, shapeFlag, dirs } = vnode;
  6118. // #4006 for form elements with non-string v-model value bindings
  6119. // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
  6120. const forcePatchValue = (type === 'input' && dirs) || type === 'option';
  6121. // skip props & children if this is hoisted static nodes
  6122. // #5405 in dev, always hydrate children for HMR
  6123. {
  6124. if (dirs) {
  6125. invokeDirectiveHook(vnode, null, parentComponent, 'created');
  6126. }
  6127. // props
  6128. if (props) {
  6129. if (forcePatchValue ||
  6130. !optimized ||
  6131. patchFlag & (16 /* FULL_PROPS */ | 32 /* HYDRATE_EVENTS */)) {
  6132. for (const key in props) {
  6133. if ((forcePatchValue && key.endsWith('value')) ||
  6134. (isOn(key) && !isReservedProp(key))) {
  6135. patchProp(el, key, null, props[key], false, undefined, parentComponent);
  6136. }
  6137. }
  6138. }
  6139. else if (props.onClick) {
  6140. // Fast path for click listeners (which is most often) to avoid
  6141. // iterating through props.
  6142. patchProp(el, 'onClick', null, props.onClick, false, undefined, parentComponent);
  6143. }
  6144. }
  6145. // vnode / directive hooks
  6146. let vnodeHooks;
  6147. if ((vnodeHooks = props && props.onVnodeBeforeMount)) {
  6148. invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  6149. }
  6150. if (dirs) {
  6151. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
  6152. }
  6153. if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
  6154. queueEffectWithSuspense(() => {
  6155. vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
  6156. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
  6157. }, parentSuspense);
  6158. }
  6159. // children
  6160. if (shapeFlag & 16 /* ARRAY_CHILDREN */ &&
  6161. // skip if element has innerHTML / textContent
  6162. !(props && (props.innerHTML || props.textContent))) {
  6163. let next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized);
  6164. let hasWarned = false;
  6165. while (next) {
  6166. hasMismatch = true;
  6167. if (!hasWarned) {
  6168. warn$1(`Hydration children mismatch in <${vnode.type}>: ` +
  6169. `server rendered element contains more child nodes than client vdom.`);
  6170. hasWarned = true;
  6171. }
  6172. // The SSRed DOM contains more nodes than it should. Remove them.
  6173. const cur = next;
  6174. next = next.nextSibling;
  6175. remove(cur);
  6176. }
  6177. }
  6178. else if (shapeFlag & 8 /* TEXT_CHILDREN */) {
  6179. if (el.textContent !== vnode.children) {
  6180. hasMismatch = true;
  6181. warn$1(`Hydration text content mismatch in <${vnode.type}>:\n` +
  6182. `- Client: ${el.textContent}\n` +
  6183. `- Server: ${vnode.children}`);
  6184. el.textContent = vnode.children;
  6185. }
  6186. }
  6187. }
  6188. return el.nextSibling;
  6189. };
  6190. const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6191. optimized = optimized || !!parentVNode.dynamicChildren;
  6192. const children = parentVNode.children;
  6193. const l = children.length;
  6194. let hasWarned = false;
  6195. for (let i = 0; i < l; i++) {
  6196. const vnode = optimized
  6197. ? children[i]
  6198. : (children[i] = normalizeVNode(children[i]));
  6199. if (node) {
  6200. node = hydrateNode(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
  6201. }
  6202. else if (vnode.type === Text && !vnode.children) {
  6203. continue;
  6204. }
  6205. else {
  6206. hasMismatch = true;
  6207. if (!hasWarned) {
  6208. warn$1(`Hydration children mismatch in <${container.tagName.toLowerCase()}>: ` +
  6209. `server rendered element contains fewer child nodes than client vdom.`);
  6210. hasWarned = true;
  6211. }
  6212. // the SSRed DOM didn't contain enough nodes. Mount the missing ones.
  6213. patch(null, vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
  6214. }
  6215. }
  6216. return node;
  6217. };
  6218. const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
  6219. const { slotScopeIds: fragmentSlotScopeIds } = vnode;
  6220. if (fragmentSlotScopeIds) {
  6221. slotScopeIds = slotScopeIds
  6222. ? slotScopeIds.concat(fragmentSlotScopeIds)
  6223. : fragmentSlotScopeIds;
  6224. }
  6225. const container = parentNode(node);
  6226. const next = hydrateChildren(nextSibling(node), vnode, container, parentComponent, parentSuspense, slotScopeIds, optimized);
  6227. if (next && isComment(next) && next.data === ']') {
  6228. return nextSibling((vnode.anchor = next));
  6229. }
  6230. else {
  6231. // fragment didn't hydrate successfully, since we didn't get a end anchor
  6232. // back. This should have led to node/children mismatch warnings.
  6233. hasMismatch = true;
  6234. // since the anchor is missing, we need to create one and insert it
  6235. insert((vnode.anchor = createComment(`]`)), container, next);
  6236. return next;
  6237. }
  6238. };
  6239. const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
  6240. hasMismatch = true;
  6241. warn$1(`Hydration node mismatch:\n- Client vnode:`, vnode.type, `\n- Server rendered DOM:`, node, node.nodeType === 3 /* TEXT */
  6242. ? `(text)`
  6243. : isComment(node) && node.data === '['
  6244. ? `(start of fragment)`
  6245. : ``);
  6246. vnode.el = null;
  6247. if (isFragment) {
  6248. // remove excessive fragment nodes
  6249. const end = locateClosingAsyncAnchor(node);
  6250. while (true) {
  6251. const next = nextSibling(node);
  6252. if (next && next !== end) {
  6253. remove(next);
  6254. }
  6255. else {
  6256. break;
  6257. }
  6258. }
  6259. }
  6260. const next = nextSibling(node);
  6261. const container = parentNode(node);
  6262. remove(node);
  6263. patch(null, vnode, container, next, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
  6264. return next;
  6265. };
  6266. const locateClosingAsyncAnchor = (node) => {
  6267. let match = 0;
  6268. while (node) {
  6269. node = nextSibling(node);
  6270. if (node && isComment(node)) {
  6271. if (node.data === '[')
  6272. match++;
  6273. if (node.data === ']') {
  6274. if (match === 0) {
  6275. return nextSibling(node);
  6276. }
  6277. else {
  6278. match--;
  6279. }
  6280. }
  6281. }
  6282. }
  6283. return node;
  6284. };
  6285. return [hydrate, hydrateNode];
  6286. }
  6287. /* eslint-disable no-restricted-globals */
  6288. let supported;
  6289. let perf;
  6290. function startMeasure(instance, type) {
  6291. if (instance.appContext.config.performance && isSupported()) {
  6292. perf.mark(`vue-${type}-${instance.uid}`);
  6293. }
  6294. {
  6295. devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
  6296. }
  6297. }
  6298. function endMeasure(instance, type) {
  6299. if (instance.appContext.config.performance && isSupported()) {
  6300. const startTag = `vue-${type}-${instance.uid}`;
  6301. const endTag = startTag + `:end`;
  6302. perf.mark(endTag);
  6303. perf.measure(`<${formatComponentName(instance, instance.type)}> ${type}`, startTag, endTag);
  6304. perf.clearMarks(startTag);
  6305. perf.clearMarks(endTag);
  6306. }
  6307. {
  6308. devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
  6309. }
  6310. }
  6311. function isSupported() {
  6312. if (supported !== undefined) {
  6313. return supported;
  6314. }
  6315. if (typeof window !== 'undefined' && window.performance) {
  6316. supported = true;
  6317. perf = window.performance;
  6318. }
  6319. else {
  6320. supported = false;
  6321. }
  6322. return supported;
  6323. }
  6324. const queuePostRenderEffect = queueEffectWithSuspense
  6325. ;
  6326. /**
  6327. * The createRenderer function accepts two generic arguments:
  6328. * HostNode and HostElement, corresponding to Node and Element types in the
  6329. * host environment. For example, for runtime-dom, HostNode would be the DOM
  6330. * `Node` interface and HostElement would be the DOM `Element` interface.
  6331. *
  6332. * Custom renderers can pass in the platform specific types like this:
  6333. *
  6334. * ``` js
  6335. * const { render, createApp } = createRenderer<Node, Element>({
  6336. * patchProp,
  6337. * ...nodeOps
  6338. * })
  6339. * ```
  6340. */
  6341. function createRenderer(options) {
  6342. return baseCreateRenderer(options);
  6343. }
  6344. // Separate API for creating hydration-enabled renderer.
  6345. // Hydration logic is only used when calling this function, making it
  6346. // tree-shakable.
  6347. function createHydrationRenderer(options) {
  6348. return baseCreateRenderer(options, createHydrationFunctions);
  6349. }
  6350. // implementation
  6351. function baseCreateRenderer(options, createHydrationFns) {
  6352. const target = getGlobalThis();
  6353. target.__VUE__ = true;
  6354. {
  6355. setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
  6356. }
  6357. const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = NOOP, cloneNode: hostCloneNode, insertStaticContent: hostInsertStaticContent } = options;
  6358. // Note: functions inside this closure should use `const xxx = () => {}`
  6359. // style in order to prevent being inlined by minifiers.
  6360. const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
  6361. if (n1 === n2) {
  6362. return;
  6363. }
  6364. // patching & not same type, unmount old tree
  6365. if (n1 && !isSameVNodeType(n1, n2)) {
  6366. anchor = getNextHostNode(n1);
  6367. unmount(n1, parentComponent, parentSuspense, true);
  6368. n1 = null;
  6369. }
  6370. if (n2.patchFlag === -2 /* BAIL */) {
  6371. optimized = false;
  6372. n2.dynamicChildren = null;
  6373. }
  6374. const { type, ref, shapeFlag } = n2;
  6375. switch (type) {
  6376. case Text:
  6377. processText(n1, n2, container, anchor);
  6378. break;
  6379. case Comment:
  6380. processCommentNode(n1, n2, container, anchor);
  6381. break;
  6382. case Static:
  6383. if (n1 == null) {
  6384. mountStaticNode(n2, container, anchor, isSVG);
  6385. }
  6386. else {
  6387. patchStaticNode(n1, n2, container, isSVG);
  6388. }
  6389. break;
  6390. case Fragment:
  6391. processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6392. break;
  6393. default:
  6394. if (shapeFlag & 1 /* ELEMENT */) {
  6395. processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6396. }
  6397. else if (shapeFlag & 6 /* COMPONENT */) {
  6398. processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6399. }
  6400. else if (shapeFlag & 64 /* TELEPORT */) {
  6401. type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
  6402. }
  6403. else if (shapeFlag & 128 /* SUSPENSE */) {
  6404. type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
  6405. }
  6406. else {
  6407. warn$1('Invalid VNode type:', type, `(${typeof type})`);
  6408. }
  6409. }
  6410. // set ref
  6411. if (ref != null && parentComponent) {
  6412. setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
  6413. }
  6414. };
  6415. const processText = (n1, n2, container, anchor) => {
  6416. if (n1 == null) {
  6417. hostInsert((n2.el = hostCreateText(n2.children)), container, anchor);
  6418. }
  6419. else {
  6420. const el = (n2.el = n1.el);
  6421. if (n2.children !== n1.children) {
  6422. hostSetText(el, n2.children);
  6423. }
  6424. }
  6425. };
  6426. const processCommentNode = (n1, n2, container, anchor) => {
  6427. if (n1 == null) {
  6428. hostInsert((n2.el = hostCreateComment(n2.children || '')), container, anchor);
  6429. }
  6430. else {
  6431. // there's no support for dynamic comments
  6432. n2.el = n1.el;
  6433. }
  6434. };
  6435. const mountStaticNode = (n2, container, anchor, isSVG) => {
  6436. [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG, n2.el, n2.anchor);
  6437. };
  6438. /**
  6439. * Dev / HMR only
  6440. */
  6441. const patchStaticNode = (n1, n2, container, isSVG) => {
  6442. // static nodes are only patched during dev for HMR
  6443. if (n2.children !== n1.children) {
  6444. const anchor = hostNextSibling(n1.anchor);
  6445. // remove existing
  6446. removeStaticNode(n1);
  6447. [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
  6448. }
  6449. else {
  6450. n2.el = n1.el;
  6451. n2.anchor = n1.anchor;
  6452. }
  6453. };
  6454. const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
  6455. let next;
  6456. while (el && el !== anchor) {
  6457. next = hostNextSibling(el);
  6458. hostInsert(el, container, nextSibling);
  6459. el = next;
  6460. }
  6461. hostInsert(anchor, container, nextSibling);
  6462. };
  6463. const removeStaticNode = ({ el, anchor }) => {
  6464. let next;
  6465. while (el && el !== anchor) {
  6466. next = hostNextSibling(el);
  6467. hostRemove(el);
  6468. el = next;
  6469. }
  6470. hostRemove(anchor);
  6471. };
  6472. const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6473. isSVG = isSVG || n2.type === 'svg';
  6474. if (n1 == null) {
  6475. mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6476. }
  6477. else {
  6478. patchElement(n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6479. }
  6480. };
  6481. const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6482. let el;
  6483. let vnodeHook;
  6484. const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
  6485. {
  6486. el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
  6487. // mount children first, since some props may rely on child content
  6488. // being already rendered, e.g. `<select value>`
  6489. if (shapeFlag & 8 /* TEXT_CHILDREN */) {
  6490. hostSetElementText(el, vnode.children);
  6491. }
  6492. else if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  6493. mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
  6494. }
  6495. if (dirs) {
  6496. invokeDirectiveHook(vnode, null, parentComponent, 'created');
  6497. }
  6498. // props
  6499. if (props) {
  6500. for (const key in props) {
  6501. if (key !== 'value' && !isReservedProp(key)) {
  6502. hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  6503. }
  6504. }
  6505. /**
  6506. * Special case for setting value on DOM elements:
  6507. * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
  6508. * - it needs to be forced (#1471)
  6509. * #2353 proposes adding another renderer option to configure this, but
  6510. * the properties affects are so finite it is worth special casing it
  6511. * here to reduce the complexity. (Special casing it also should not
  6512. * affect non-DOM renderers)
  6513. */
  6514. if ('value' in props) {
  6515. hostPatchProp(el, 'value', null, props.value);
  6516. }
  6517. if ((vnodeHook = props.onVnodeBeforeMount)) {
  6518. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  6519. }
  6520. }
  6521. // scopeId
  6522. setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
  6523. }
  6524. {
  6525. Object.defineProperty(el, '__vnode', {
  6526. value: vnode,
  6527. enumerable: false
  6528. });
  6529. Object.defineProperty(el, '__vueParentComponent', {
  6530. value: parentComponent,
  6531. enumerable: false
  6532. });
  6533. }
  6534. if (dirs) {
  6535. invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
  6536. }
  6537. // #1583 For inside suspense + suspense not resolved case, enter hook should call when suspense resolved
  6538. // #1689 For inside suspense + suspense resolved case, just call it
  6539. const needCallTransitionHooks = (!parentSuspense || (parentSuspense && !parentSuspense.pendingBranch)) &&
  6540. transition &&
  6541. !transition.persisted;
  6542. if (needCallTransitionHooks) {
  6543. transition.beforeEnter(el);
  6544. }
  6545. hostInsert(el, container, anchor);
  6546. if ((vnodeHook = props && props.onVnodeMounted) ||
  6547. needCallTransitionHooks ||
  6548. dirs) {
  6549. queuePostRenderEffect(() => {
  6550. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  6551. needCallTransitionHooks && transition.enter(el);
  6552. dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
  6553. }, parentSuspense);
  6554. }
  6555. };
  6556. const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
  6557. if (scopeId) {
  6558. hostSetScopeId(el, scopeId);
  6559. }
  6560. if (slotScopeIds) {
  6561. for (let i = 0; i < slotScopeIds.length; i++) {
  6562. hostSetScopeId(el, slotScopeIds[i]);
  6563. }
  6564. }
  6565. if (parentComponent) {
  6566. let subTree = parentComponent.subTree;
  6567. if (subTree.patchFlag > 0 &&
  6568. subTree.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
  6569. subTree =
  6570. filterSingleRoot(subTree.children) || subTree;
  6571. }
  6572. if (vnode === subTree) {
  6573. const parentVNode = parentComponent.vnode;
  6574. setScopeId(el, parentVNode, parentVNode.scopeId, parentVNode.slotScopeIds, parentComponent.parent);
  6575. }
  6576. }
  6577. };
  6578. const mountChildren = (children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, start = 0) => {
  6579. for (let i = start; i < children.length; i++) {
  6580. const child = (children[i] = optimized
  6581. ? cloneIfMounted(children[i])
  6582. : normalizeVNode(children[i]));
  6583. patch(null, child, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6584. }
  6585. };
  6586. const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6587. const el = (n2.el = n1.el);
  6588. let { patchFlag, dynamicChildren, dirs } = n2;
  6589. // #1426 take the old vnode's patch flag into account since user may clone a
  6590. // compiler-generated vnode, which de-opts to FULL_PROPS
  6591. patchFlag |= n1.patchFlag & 16 /* FULL_PROPS */;
  6592. const oldProps = n1.props || EMPTY_OBJ;
  6593. const newProps = n2.props || EMPTY_OBJ;
  6594. let vnodeHook;
  6595. // disable recurse in beforeUpdate hooks
  6596. parentComponent && toggleRecurse(parentComponent, false);
  6597. if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
  6598. invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  6599. }
  6600. if (dirs) {
  6601. invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
  6602. }
  6603. parentComponent && toggleRecurse(parentComponent, true);
  6604. if (isHmrUpdating) {
  6605. // HMR updated, force full diff
  6606. patchFlag = 0;
  6607. optimized = false;
  6608. dynamicChildren = null;
  6609. }
  6610. const areChildrenSVG = isSVG && n2.type !== 'foreignObject';
  6611. if (dynamicChildren) {
  6612. patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds);
  6613. if (parentComponent && parentComponent.type.__hmrId) {
  6614. traverseStaticChildren(n1, n2);
  6615. }
  6616. }
  6617. else if (!optimized) {
  6618. // full diff
  6619. patchChildren(n1, n2, el, null, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds, false);
  6620. }
  6621. if (patchFlag > 0) {
  6622. // the presence of a patchFlag means this element's render code was
  6623. // generated by the compiler and can take the fast path.
  6624. // in this path old node and new node are guaranteed to have the same shape
  6625. // (i.e. at the exact same position in the source template)
  6626. if (patchFlag & 16 /* FULL_PROPS */) {
  6627. // element props contain dynamic keys, full diff needed
  6628. patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
  6629. }
  6630. else {
  6631. // class
  6632. // this flag is matched when the element has dynamic class bindings.
  6633. if (patchFlag & 2 /* CLASS */) {
  6634. if (oldProps.class !== newProps.class) {
  6635. hostPatchProp(el, 'class', null, newProps.class, isSVG);
  6636. }
  6637. }
  6638. // style
  6639. // this flag is matched when the element has dynamic style bindings
  6640. if (patchFlag & 4 /* STYLE */) {
  6641. hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG);
  6642. }
  6643. // props
  6644. // This flag is matched when the element has dynamic prop/attr bindings
  6645. // other than class and style. The keys of dynamic prop/attrs are saved for
  6646. // faster iteration.
  6647. // Note dynamic keys like :[foo]="bar" will cause this optimization to
  6648. // bail out and go through a full diff because we need to unset the old key
  6649. if (patchFlag & 8 /* PROPS */) {
  6650. // if the flag is present then dynamicProps must be non-null
  6651. const propsToUpdate = n2.dynamicProps;
  6652. for (let i = 0; i < propsToUpdate.length; i++) {
  6653. const key = propsToUpdate[i];
  6654. const prev = oldProps[key];
  6655. const next = newProps[key];
  6656. // #1471 force patch value
  6657. if (next !== prev || key === 'value') {
  6658. hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren);
  6659. }
  6660. }
  6661. }
  6662. }
  6663. // text
  6664. // This flag is matched when the element has only dynamic text children.
  6665. if (patchFlag & 1 /* TEXT */) {
  6666. if (n1.children !== n2.children) {
  6667. hostSetElementText(el, n2.children);
  6668. }
  6669. }
  6670. }
  6671. else if (!optimized && dynamicChildren == null) {
  6672. // unoptimized, full diff
  6673. patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
  6674. }
  6675. if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
  6676. queuePostRenderEffect(() => {
  6677. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
  6678. dirs && invokeDirectiveHook(n2, n1, parentComponent, 'updated');
  6679. }, parentSuspense);
  6680. }
  6681. };
  6682. // The fast path for blocks.
  6683. const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => {
  6684. for (let i = 0; i < newChildren.length; i++) {
  6685. const oldVNode = oldChildren[i];
  6686. const newVNode = newChildren[i];
  6687. // Determine the container (parent element) for the patch.
  6688. const container =
  6689. // oldVNode may be an errored async setup() component inside Suspense
  6690. // which will not have a mounted element
  6691. oldVNode.el &&
  6692. // - In the case of a Fragment, we need to provide the actual parent
  6693. // of the Fragment itself so it can move its children.
  6694. (oldVNode.type === Fragment ||
  6695. // - In the case of different nodes, there is going to be a replacement
  6696. // which also requires the correct parent container
  6697. !isSameVNodeType(oldVNode, newVNode) ||
  6698. // - In the case of a component, it could contain anything.
  6699. oldVNode.shapeFlag & (6 /* COMPONENT */ | 64 /* TELEPORT */))
  6700. ? hostParentNode(oldVNode.el)
  6701. : // In other cases, the parent container is not actually used so we
  6702. // just pass the block element here to avoid a DOM parentNode call.
  6703. fallbackContainer;
  6704. patch(oldVNode, newVNode, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, true);
  6705. }
  6706. };
  6707. const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
  6708. if (oldProps !== newProps) {
  6709. for (const key in newProps) {
  6710. // empty string is not valid prop
  6711. if (isReservedProp(key))
  6712. continue;
  6713. const next = newProps[key];
  6714. const prev = oldProps[key];
  6715. // defer patching value
  6716. if (next !== prev && key !== 'value') {
  6717. hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  6718. }
  6719. }
  6720. if (oldProps !== EMPTY_OBJ) {
  6721. for (const key in oldProps) {
  6722. if (!isReservedProp(key) && !(key in newProps)) {
  6723. hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
  6724. }
  6725. }
  6726. }
  6727. if ('value' in newProps) {
  6728. hostPatchProp(el, 'value', oldProps.value, newProps.value);
  6729. }
  6730. }
  6731. };
  6732. const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6733. const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
  6734. const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
  6735. let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
  6736. if (// #5523 dev root fragment may inherit directives
  6737. (isHmrUpdating || patchFlag & 2048 /* DEV_ROOT_FRAGMENT */)) {
  6738. // HMR updated / Dev root fragment (w/ comments), force full diff
  6739. patchFlag = 0;
  6740. optimized = false;
  6741. dynamicChildren = null;
  6742. }
  6743. // check if this is a slot fragment with :slotted scope ids
  6744. if (fragmentSlotScopeIds) {
  6745. slotScopeIds = slotScopeIds
  6746. ? slotScopeIds.concat(fragmentSlotScopeIds)
  6747. : fragmentSlotScopeIds;
  6748. }
  6749. if (n1 == null) {
  6750. hostInsert(fragmentStartAnchor, container, anchor);
  6751. hostInsert(fragmentEndAnchor, container, anchor);
  6752. // a fragment can only have array children
  6753. // since they are either generated by the compiler, or implicitly created
  6754. // from arrays.
  6755. mountChildren(n2.children, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6756. }
  6757. else {
  6758. if (patchFlag > 0 &&
  6759. patchFlag & 64 /* STABLE_FRAGMENT */ &&
  6760. dynamicChildren &&
  6761. // #2715 the previous fragment could've been a BAILed one as a result
  6762. // of renderSlot() with no valid children
  6763. n1.dynamicChildren) {
  6764. // a stable fragment (template root or <template v-for>) doesn't need to
  6765. // patch children order, but it may contain dynamicChildren.
  6766. patchBlockChildren(n1.dynamicChildren, dynamicChildren, container, parentComponent, parentSuspense, isSVG, slotScopeIds);
  6767. if (parentComponent && parentComponent.type.__hmrId) {
  6768. traverseStaticChildren(n1, n2);
  6769. }
  6770. else if (
  6771. // #2080 if the stable fragment has a key, it's a <template v-for> that may
  6772. // get moved around. Make sure all root level vnodes inherit el.
  6773. // #2134 or if it's a component root, it may also get moved around
  6774. // as the component is being moved.
  6775. n2.key != null ||
  6776. (parentComponent && n2 === parentComponent.subTree)) {
  6777. traverseStaticChildren(n1, n2, true /* shallow */);
  6778. }
  6779. }
  6780. else {
  6781. // keyed / unkeyed, or manual fragments.
  6782. // for keyed & unkeyed, since they are compiler generated from v-for,
  6783. // each child is guaranteed to be a block so the fragment will never
  6784. // have dynamicChildren.
  6785. patchChildren(n1, n2, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  6786. }
  6787. }
  6788. };
  6789. const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  6790. n2.slotScopeIds = slotScopeIds;
  6791. if (n1 == null) {
  6792. if (n2.shapeFlag & 512 /* COMPONENT_KEPT_ALIVE */) {
  6793. parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized);
  6794. }
  6795. else {
  6796. mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
  6797. }
  6798. }
  6799. else {
  6800. updateComponent(n1, n2, optimized);
  6801. }
  6802. };
  6803. const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
  6804. const instance = (initialVNode.component = createComponentInstance(initialVNode, parentComponent, parentSuspense));
  6805. if (instance.type.__hmrId) {
  6806. registerHMR(instance);
  6807. }
  6808. {
  6809. pushWarningContext(initialVNode);
  6810. startMeasure(instance, `mount`);
  6811. }
  6812. // inject renderer internals for keepAlive
  6813. if (isKeepAlive(initialVNode)) {
  6814. instance.ctx.renderer = internals;
  6815. }
  6816. // resolve props and slots for setup context
  6817. {
  6818. {
  6819. startMeasure(instance, `init`);
  6820. }
  6821. setupComponent(instance);
  6822. {
  6823. endMeasure(instance, `init`);
  6824. }
  6825. }
  6826. // setup() is async. This component relies on async logic to be resolved
  6827. // before proceeding
  6828. if (instance.asyncDep) {
  6829. parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
  6830. // Give it a placeholder if this is not hydration
  6831. // TODO handle self-defined fallback
  6832. if (!initialVNode.el) {
  6833. const placeholder = (instance.subTree = createVNode(Comment));
  6834. processCommentNode(null, placeholder, container, anchor);
  6835. }
  6836. return;
  6837. }
  6838. setupRenderEffect(instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized);
  6839. {
  6840. popWarningContext();
  6841. endMeasure(instance, `mount`);
  6842. }
  6843. };
  6844. const updateComponent = (n1, n2, optimized) => {
  6845. const instance = (n2.component = n1.component);
  6846. if (shouldUpdateComponent(n1, n2, optimized)) {
  6847. if (instance.asyncDep &&
  6848. !instance.asyncResolved) {
  6849. // async & still pending - just update props and slots
  6850. // since the component's reactive effect for render isn't set-up yet
  6851. {
  6852. pushWarningContext(n2);
  6853. }
  6854. updateComponentPreRender(instance, n2, optimized);
  6855. {
  6856. popWarningContext();
  6857. }
  6858. return;
  6859. }
  6860. else {
  6861. // normal update
  6862. instance.next = n2;
  6863. // in case the child component is also queued, remove it to avoid
  6864. // double updating the same child component in the same flush.
  6865. invalidateJob(instance.update);
  6866. // instance.update is the reactive effect.
  6867. instance.update();
  6868. }
  6869. }
  6870. else {
  6871. // no update needed. just copy over properties
  6872. n2.el = n1.el;
  6873. instance.vnode = n2;
  6874. }
  6875. };
  6876. const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
  6877. const componentUpdateFn = () => {
  6878. if (!instance.isMounted) {
  6879. let vnodeHook;
  6880. const { el, props } = initialVNode;
  6881. const { bm, m, parent } = instance;
  6882. const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
  6883. toggleRecurse(instance, false);
  6884. // beforeMount hook
  6885. if (bm) {
  6886. invokeArrayFns(bm);
  6887. }
  6888. // onVnodeBeforeMount
  6889. if (!isAsyncWrapperVNode &&
  6890. (vnodeHook = props && props.onVnodeBeforeMount)) {
  6891. invokeVNodeHook(vnodeHook, parent, initialVNode);
  6892. }
  6893. toggleRecurse(instance, true);
  6894. if (el && hydrateNode) {
  6895. // vnode has adopted host node - perform hydration instead of mount.
  6896. const hydrateSubTree = () => {
  6897. {
  6898. startMeasure(instance, `render`);
  6899. }
  6900. instance.subTree = renderComponentRoot(instance);
  6901. {
  6902. endMeasure(instance, `render`);
  6903. }
  6904. {
  6905. startMeasure(instance, `hydrate`);
  6906. }
  6907. hydrateNode(el, instance.subTree, instance, parentSuspense, null);
  6908. {
  6909. endMeasure(instance, `hydrate`);
  6910. }
  6911. };
  6912. if (isAsyncWrapperVNode) {
  6913. initialVNode.type.__asyncLoader().then(
  6914. // note: we are moving the render call into an async callback,
  6915. // which means it won't track dependencies - but it's ok because
  6916. // a server-rendered async wrapper is already in resolved state
  6917. // and it will never need to change.
  6918. () => !instance.isUnmounted && hydrateSubTree());
  6919. }
  6920. else {
  6921. hydrateSubTree();
  6922. }
  6923. }
  6924. else {
  6925. {
  6926. startMeasure(instance, `render`);
  6927. }
  6928. const subTree = (instance.subTree = renderComponentRoot(instance));
  6929. {
  6930. endMeasure(instance, `render`);
  6931. }
  6932. {
  6933. startMeasure(instance, `patch`);
  6934. }
  6935. patch(null, subTree, container, anchor, instance, parentSuspense, isSVG);
  6936. {
  6937. endMeasure(instance, `patch`);
  6938. }
  6939. initialVNode.el = subTree.el;
  6940. }
  6941. // mounted hook
  6942. if (m) {
  6943. queuePostRenderEffect(m, parentSuspense);
  6944. }
  6945. // onVnodeMounted
  6946. if (!isAsyncWrapperVNode &&
  6947. (vnodeHook = props && props.onVnodeMounted)) {
  6948. const scopedInitialVNode = initialVNode;
  6949. queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode), parentSuspense);
  6950. }
  6951. // activated hook for keep-alive roots.
  6952. // #1742 activated hook must be accessed after first render
  6953. // since the hook may be injected by a child keep-alive
  6954. if (initialVNode.shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */ ||
  6955. (parent &&
  6956. isAsyncWrapper(parent.vnode) &&
  6957. parent.vnode.shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */)) {
  6958. instance.a && queuePostRenderEffect(instance.a, parentSuspense);
  6959. }
  6960. instance.isMounted = true;
  6961. {
  6962. devtoolsComponentAdded(instance);
  6963. }
  6964. // #2458: deference mount-only object parameters to prevent memleaks
  6965. initialVNode = container = anchor = null;
  6966. }
  6967. else {
  6968. // updateComponent
  6969. // This is triggered by mutation of component's own state (next: null)
  6970. // OR parent calling processComponent (next: VNode)
  6971. let { next, bu, u, parent, vnode } = instance;
  6972. let originNext = next;
  6973. let vnodeHook;
  6974. {
  6975. pushWarningContext(next || instance.vnode);
  6976. }
  6977. // Disallow component effect recursion during pre-lifecycle hooks.
  6978. toggleRecurse(instance, false);
  6979. if (next) {
  6980. next.el = vnode.el;
  6981. updateComponentPreRender(instance, next, optimized);
  6982. }
  6983. else {
  6984. next = vnode;
  6985. }
  6986. // beforeUpdate hook
  6987. if (bu) {
  6988. invokeArrayFns(bu);
  6989. }
  6990. // onVnodeBeforeUpdate
  6991. if ((vnodeHook = next.props && next.props.onVnodeBeforeUpdate)) {
  6992. invokeVNodeHook(vnodeHook, parent, next, vnode);
  6993. }
  6994. toggleRecurse(instance, true);
  6995. // render
  6996. {
  6997. startMeasure(instance, `render`);
  6998. }
  6999. const nextTree = renderComponentRoot(instance);
  7000. {
  7001. endMeasure(instance, `render`);
  7002. }
  7003. const prevTree = instance.subTree;
  7004. instance.subTree = nextTree;
  7005. {
  7006. startMeasure(instance, `patch`);
  7007. }
  7008. patch(prevTree, nextTree,
  7009. // parent may have changed if it's in a teleport
  7010. hostParentNode(prevTree.el),
  7011. // anchor may have changed if it's in a fragment
  7012. getNextHostNode(prevTree), instance, parentSuspense, isSVG);
  7013. {
  7014. endMeasure(instance, `patch`);
  7015. }
  7016. next.el = nextTree.el;
  7017. if (originNext === null) {
  7018. // self-triggered update. In case of HOC, update parent component
  7019. // vnode el. HOC is indicated by parent instance's subTree pointing
  7020. // to child component's vnode
  7021. updateHOCHostEl(instance, nextTree.el);
  7022. }
  7023. // updated hook
  7024. if (u) {
  7025. queuePostRenderEffect(u, parentSuspense);
  7026. }
  7027. // onVnodeUpdated
  7028. if ((vnodeHook = next.props && next.props.onVnodeUpdated)) {
  7029. queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, next, vnode), parentSuspense);
  7030. }
  7031. {
  7032. devtoolsComponentUpdated(instance);
  7033. }
  7034. {
  7035. popWarningContext();
  7036. }
  7037. }
  7038. };
  7039. // create reactive effect for rendering
  7040. const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(update), instance.scope // track it in component's effect scope
  7041. ));
  7042. const update = (instance.update = () => effect.run());
  7043. update.id = instance.uid;
  7044. // allowRecurse
  7045. // #1801, #2043 component render effects should allow recursive updates
  7046. toggleRecurse(instance, true);
  7047. {
  7048. effect.onTrack = instance.rtc
  7049. ? e => invokeArrayFns(instance.rtc, e)
  7050. : void 0;
  7051. effect.onTrigger = instance.rtg
  7052. ? e => invokeArrayFns(instance.rtg, e)
  7053. : void 0;
  7054. update.ownerInstance = instance;
  7055. }
  7056. update();
  7057. };
  7058. const updateComponentPreRender = (instance, nextVNode, optimized) => {
  7059. nextVNode.component = instance;
  7060. const prevProps = instance.vnode.props;
  7061. instance.vnode = nextVNode;
  7062. instance.next = null;
  7063. updateProps(instance, nextVNode.props, prevProps, optimized);
  7064. updateSlots(instance, nextVNode.children, optimized);
  7065. pauseTracking();
  7066. // props update may have triggered pre-flush watchers.
  7067. // flush them before the render update.
  7068. flushPreFlushCbs(undefined, instance.update);
  7069. resetTracking();
  7070. };
  7071. const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized = false) => {
  7072. const c1 = n1 && n1.children;
  7073. const prevShapeFlag = n1 ? n1.shapeFlag : 0;
  7074. const c2 = n2.children;
  7075. const { patchFlag, shapeFlag } = n2;
  7076. // fast path
  7077. if (patchFlag > 0) {
  7078. if (patchFlag & 128 /* KEYED_FRAGMENT */) {
  7079. // this could be either fully-keyed or mixed (some keyed some not)
  7080. // presence of patchFlag means children are guaranteed to be arrays
  7081. patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7082. return;
  7083. }
  7084. else if (patchFlag & 256 /* UNKEYED_FRAGMENT */) {
  7085. // unkeyed
  7086. patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7087. return;
  7088. }
  7089. }
  7090. // children has 3 possibilities: text, array or no children.
  7091. if (shapeFlag & 8 /* TEXT_CHILDREN */) {
  7092. // text children fast path
  7093. if (prevShapeFlag & 16 /* ARRAY_CHILDREN */) {
  7094. unmountChildren(c1, parentComponent, parentSuspense);
  7095. }
  7096. if (c2 !== c1) {
  7097. hostSetElementText(container, c2);
  7098. }
  7099. }
  7100. else {
  7101. if (prevShapeFlag & 16 /* ARRAY_CHILDREN */) {
  7102. // prev children was array
  7103. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  7104. // two arrays, cannot assume anything, do full diff
  7105. patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7106. }
  7107. else {
  7108. // no new children, just unmount old
  7109. unmountChildren(c1, parentComponent, parentSuspense, true);
  7110. }
  7111. }
  7112. else {
  7113. // prev children was text OR null
  7114. // new children is array OR null
  7115. if (prevShapeFlag & 8 /* TEXT_CHILDREN */) {
  7116. hostSetElementText(container, '');
  7117. }
  7118. // mount new if array
  7119. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  7120. mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7121. }
  7122. }
  7123. }
  7124. };
  7125. const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  7126. c1 = c1 || EMPTY_ARR;
  7127. c2 = c2 || EMPTY_ARR;
  7128. const oldLength = c1.length;
  7129. const newLength = c2.length;
  7130. const commonLength = Math.min(oldLength, newLength);
  7131. let i;
  7132. for (i = 0; i < commonLength; i++) {
  7133. const nextChild = (c2[i] = optimized
  7134. ? cloneIfMounted(c2[i])
  7135. : normalizeVNode(c2[i]));
  7136. patch(c1[i], nextChild, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7137. }
  7138. if (oldLength > newLength) {
  7139. // remove old
  7140. unmountChildren(c1, parentComponent, parentSuspense, true, false, commonLength);
  7141. }
  7142. else {
  7143. // mount new
  7144. mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, commonLength);
  7145. }
  7146. };
  7147. // can be all-keyed or mixed
  7148. const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
  7149. let i = 0;
  7150. const l2 = c2.length;
  7151. let e1 = c1.length - 1; // prev ending index
  7152. let e2 = l2 - 1; // next ending index
  7153. // 1. sync from start
  7154. // (a b) c
  7155. // (a b) d e
  7156. while (i <= e1 && i <= e2) {
  7157. const n1 = c1[i];
  7158. const n2 = (c2[i] = optimized
  7159. ? cloneIfMounted(c2[i])
  7160. : normalizeVNode(c2[i]));
  7161. if (isSameVNodeType(n1, n2)) {
  7162. patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7163. }
  7164. else {
  7165. break;
  7166. }
  7167. i++;
  7168. }
  7169. // 2. sync from end
  7170. // a (b c)
  7171. // d e (b c)
  7172. while (i <= e1 && i <= e2) {
  7173. const n1 = c1[e1];
  7174. const n2 = (c2[e2] = optimized
  7175. ? cloneIfMounted(c2[e2])
  7176. : normalizeVNode(c2[e2]));
  7177. if (isSameVNodeType(n1, n2)) {
  7178. patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7179. }
  7180. else {
  7181. break;
  7182. }
  7183. e1--;
  7184. e2--;
  7185. }
  7186. // 3. common sequence + mount
  7187. // (a b)
  7188. // (a b) c
  7189. // i = 2, e1 = 1, e2 = 2
  7190. // (a b)
  7191. // c (a b)
  7192. // i = 0, e1 = -1, e2 = 0
  7193. if (i > e1) {
  7194. if (i <= e2) {
  7195. const nextPos = e2 + 1;
  7196. const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
  7197. while (i <= e2) {
  7198. patch(null, (c2[i] = optimized
  7199. ? cloneIfMounted(c2[i])
  7200. : normalizeVNode(c2[i])), container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7201. i++;
  7202. }
  7203. }
  7204. }
  7205. // 4. common sequence + unmount
  7206. // (a b) c
  7207. // (a b)
  7208. // i = 2, e1 = 2, e2 = 1
  7209. // a (b c)
  7210. // (b c)
  7211. // i = 0, e1 = 0, e2 = -1
  7212. else if (i > e2) {
  7213. while (i <= e1) {
  7214. unmount(c1[i], parentComponent, parentSuspense, true);
  7215. i++;
  7216. }
  7217. }
  7218. // 5. unknown sequence
  7219. // [i ... e1 + 1]: a b [c d e] f g
  7220. // [i ... e2 + 1]: a b [e d c h] f g
  7221. // i = 2, e1 = 4, e2 = 5
  7222. else {
  7223. const s1 = i; // prev starting index
  7224. const s2 = i; // next starting index
  7225. // 5.1 build key:index map for newChildren
  7226. const keyToNewIndexMap = new Map();
  7227. for (i = s2; i <= e2; i++) {
  7228. const nextChild = (c2[i] = optimized
  7229. ? cloneIfMounted(c2[i])
  7230. : normalizeVNode(c2[i]));
  7231. if (nextChild.key != null) {
  7232. if (keyToNewIndexMap.has(nextChild.key)) {
  7233. warn$1(`Duplicate keys found during update:`, JSON.stringify(nextChild.key), `Make sure keys are unique.`);
  7234. }
  7235. keyToNewIndexMap.set(nextChild.key, i);
  7236. }
  7237. }
  7238. // 5.2 loop through old children left to be patched and try to patch
  7239. // matching nodes & remove nodes that are no longer present
  7240. let j;
  7241. let patched = 0;
  7242. const toBePatched = e2 - s2 + 1;
  7243. let moved = false;
  7244. // used to track whether any node has moved
  7245. let maxNewIndexSoFar = 0;
  7246. // works as Map<newIndex, oldIndex>
  7247. // Note that oldIndex is offset by +1
  7248. // and oldIndex = 0 is a special value indicating the new node has
  7249. // no corresponding old node.
  7250. // used for determining longest stable subsequence
  7251. const newIndexToOldIndexMap = new Array(toBePatched);
  7252. for (i = 0; i < toBePatched; i++)
  7253. newIndexToOldIndexMap[i] = 0;
  7254. for (i = s1; i <= e1; i++) {
  7255. const prevChild = c1[i];
  7256. if (patched >= toBePatched) {
  7257. // all new children have been patched so this can only be a removal
  7258. unmount(prevChild, parentComponent, parentSuspense, true);
  7259. continue;
  7260. }
  7261. let newIndex;
  7262. if (prevChild.key != null) {
  7263. newIndex = keyToNewIndexMap.get(prevChild.key);
  7264. }
  7265. else {
  7266. // key-less node, try to locate a key-less node of the same type
  7267. for (j = s2; j <= e2; j++) {
  7268. if (newIndexToOldIndexMap[j - s2] === 0 &&
  7269. isSameVNodeType(prevChild, c2[j])) {
  7270. newIndex = j;
  7271. break;
  7272. }
  7273. }
  7274. }
  7275. if (newIndex === undefined) {
  7276. unmount(prevChild, parentComponent, parentSuspense, true);
  7277. }
  7278. else {
  7279. newIndexToOldIndexMap[newIndex - s2] = i + 1;
  7280. if (newIndex >= maxNewIndexSoFar) {
  7281. maxNewIndexSoFar = newIndex;
  7282. }
  7283. else {
  7284. moved = true;
  7285. }
  7286. patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7287. patched++;
  7288. }
  7289. }
  7290. // 5.3 move and mount
  7291. // generate longest stable subsequence only when nodes have moved
  7292. const increasingNewIndexSequence = moved
  7293. ? getSequence(newIndexToOldIndexMap)
  7294. : EMPTY_ARR;
  7295. j = increasingNewIndexSequence.length - 1;
  7296. // looping backwards so that we can use last patched node as anchor
  7297. for (i = toBePatched - 1; i >= 0; i--) {
  7298. const nextIndex = s2 + i;
  7299. const nextChild = c2[nextIndex];
  7300. const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
  7301. if (newIndexToOldIndexMap[i] === 0) {
  7302. // mount new
  7303. patch(null, nextChild, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7304. }
  7305. else if (moved) {
  7306. // move if:
  7307. // There is no stable subsequence (e.g. a reverse)
  7308. // OR current node is not among the stable sequence
  7309. if (j < 0 || i !== increasingNewIndexSequence[j]) {
  7310. move(nextChild, container, anchor, 2 /* REORDER */);
  7311. }
  7312. else {
  7313. j--;
  7314. }
  7315. }
  7316. }
  7317. }
  7318. };
  7319. const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
  7320. const { el, type, transition, children, shapeFlag } = vnode;
  7321. if (shapeFlag & 6 /* COMPONENT */) {
  7322. move(vnode.component.subTree, container, anchor, moveType);
  7323. return;
  7324. }
  7325. if (shapeFlag & 128 /* SUSPENSE */) {
  7326. vnode.suspense.move(container, anchor, moveType);
  7327. return;
  7328. }
  7329. if (shapeFlag & 64 /* TELEPORT */) {
  7330. type.move(vnode, container, anchor, internals);
  7331. return;
  7332. }
  7333. if (type === Fragment) {
  7334. hostInsert(el, container, anchor);
  7335. for (let i = 0; i < children.length; i++) {
  7336. move(children[i], container, anchor, moveType);
  7337. }
  7338. hostInsert(vnode.anchor, container, anchor);
  7339. return;
  7340. }
  7341. if (type === Static) {
  7342. moveStaticNode(vnode, container, anchor);
  7343. return;
  7344. }
  7345. // single nodes
  7346. const needTransition = moveType !== 2 /* REORDER */ &&
  7347. shapeFlag & 1 /* ELEMENT */ &&
  7348. transition;
  7349. if (needTransition) {
  7350. if (moveType === 0 /* ENTER */) {
  7351. transition.beforeEnter(el);
  7352. hostInsert(el, container, anchor);
  7353. queuePostRenderEffect(() => transition.enter(el), parentSuspense);
  7354. }
  7355. else {
  7356. const { leave, delayLeave, afterLeave } = transition;
  7357. const remove = () => hostInsert(el, container, anchor);
  7358. const performLeave = () => {
  7359. leave(el, () => {
  7360. remove();
  7361. afterLeave && afterLeave();
  7362. });
  7363. };
  7364. if (delayLeave) {
  7365. delayLeave(el, remove, performLeave);
  7366. }
  7367. else {
  7368. performLeave();
  7369. }
  7370. }
  7371. }
  7372. else {
  7373. hostInsert(el, container, anchor);
  7374. }
  7375. };
  7376. const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
  7377. const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs } = vnode;
  7378. // unset ref
  7379. if (ref != null) {
  7380. setRef(ref, null, parentSuspense, vnode, true);
  7381. }
  7382. if (shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
  7383. parentComponent.ctx.deactivate(vnode);
  7384. return;
  7385. }
  7386. const shouldInvokeDirs = shapeFlag & 1 /* ELEMENT */ && dirs;
  7387. const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
  7388. let vnodeHook;
  7389. if (shouldInvokeVnodeHook &&
  7390. (vnodeHook = props && props.onVnodeBeforeUnmount)) {
  7391. invokeVNodeHook(vnodeHook, parentComponent, vnode);
  7392. }
  7393. if (shapeFlag & 6 /* COMPONENT */) {
  7394. unmountComponent(vnode.component, parentSuspense, doRemove);
  7395. }
  7396. else {
  7397. if (shapeFlag & 128 /* SUSPENSE */) {
  7398. vnode.suspense.unmount(parentSuspense, doRemove);
  7399. return;
  7400. }
  7401. if (shouldInvokeDirs) {
  7402. invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount');
  7403. }
  7404. if (shapeFlag & 64 /* TELEPORT */) {
  7405. vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove);
  7406. }
  7407. else if (dynamicChildren &&
  7408. // #1153: fast path should not be taken for non-stable (v-for) fragments
  7409. (type !== Fragment ||
  7410. (patchFlag > 0 && patchFlag & 64 /* STABLE_FRAGMENT */))) {
  7411. // fast path for block nodes: only need to unmount dynamic children.
  7412. unmountChildren(dynamicChildren, parentComponent, parentSuspense, false, true);
  7413. }
  7414. else if ((type === Fragment &&
  7415. patchFlag &
  7416. (128 /* KEYED_FRAGMENT */ | 256 /* UNKEYED_FRAGMENT */)) ||
  7417. (!optimized && shapeFlag & 16 /* ARRAY_CHILDREN */)) {
  7418. unmountChildren(children, parentComponent, parentSuspense);
  7419. }
  7420. if (doRemove) {
  7421. remove(vnode);
  7422. }
  7423. }
  7424. if ((shouldInvokeVnodeHook &&
  7425. (vnodeHook = props && props.onVnodeUnmounted)) ||
  7426. shouldInvokeDirs) {
  7427. queuePostRenderEffect(() => {
  7428. vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
  7429. shouldInvokeDirs &&
  7430. invokeDirectiveHook(vnode, null, parentComponent, 'unmounted');
  7431. }, parentSuspense);
  7432. }
  7433. };
  7434. const remove = vnode => {
  7435. const { type, el, anchor, transition } = vnode;
  7436. if (type === Fragment) {
  7437. if (vnode.patchFlag > 0 &&
  7438. vnode.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */ &&
  7439. transition &&
  7440. !transition.persisted) {
  7441. vnode.children.forEach(child => {
  7442. if (child.type === Comment) {
  7443. hostRemove(child.el);
  7444. }
  7445. else {
  7446. remove(child);
  7447. }
  7448. });
  7449. }
  7450. else {
  7451. removeFragment(el, anchor);
  7452. }
  7453. return;
  7454. }
  7455. if (type === Static) {
  7456. removeStaticNode(vnode);
  7457. return;
  7458. }
  7459. const performRemove = () => {
  7460. hostRemove(el);
  7461. if (transition && !transition.persisted && transition.afterLeave) {
  7462. transition.afterLeave();
  7463. }
  7464. };
  7465. if (vnode.shapeFlag & 1 /* ELEMENT */ &&
  7466. transition &&
  7467. !transition.persisted) {
  7468. const { leave, delayLeave } = transition;
  7469. const performLeave = () => leave(el, performRemove);
  7470. if (delayLeave) {
  7471. delayLeave(vnode.el, performRemove, performLeave);
  7472. }
  7473. else {
  7474. performLeave();
  7475. }
  7476. }
  7477. else {
  7478. performRemove();
  7479. }
  7480. };
  7481. const removeFragment = (cur, end) => {
  7482. // For fragments, directly remove all contained DOM nodes.
  7483. // (fragment child nodes cannot have transition)
  7484. let next;
  7485. while (cur !== end) {
  7486. next = hostNextSibling(cur);
  7487. hostRemove(cur);
  7488. cur = next;
  7489. }
  7490. hostRemove(end);
  7491. };
  7492. const unmountComponent = (instance, parentSuspense, doRemove) => {
  7493. if (instance.type.__hmrId) {
  7494. unregisterHMR(instance);
  7495. }
  7496. const { bum, scope, update, subTree, um } = instance;
  7497. // beforeUnmount hook
  7498. if (bum) {
  7499. invokeArrayFns(bum);
  7500. }
  7501. // stop effects in component scope
  7502. scope.stop();
  7503. // update may be null if a component is unmounted before its async
  7504. // setup has resolved.
  7505. if (update) {
  7506. // so that scheduler will no longer invoke it
  7507. update.active = false;
  7508. unmount(subTree, instance, parentSuspense, doRemove);
  7509. }
  7510. // unmounted hook
  7511. if (um) {
  7512. queuePostRenderEffect(um, parentSuspense);
  7513. }
  7514. queuePostRenderEffect(() => {
  7515. instance.isUnmounted = true;
  7516. }, parentSuspense);
  7517. // A component with async dep inside a pending suspense is unmounted before
  7518. // its async dep resolves. This should remove the dep from the suspense, and
  7519. // cause the suspense to resolve immediately if that was the last dep.
  7520. if (parentSuspense &&
  7521. parentSuspense.pendingBranch &&
  7522. !parentSuspense.isUnmounted &&
  7523. instance.asyncDep &&
  7524. !instance.asyncResolved &&
  7525. instance.suspenseId === parentSuspense.pendingId) {
  7526. parentSuspense.deps--;
  7527. if (parentSuspense.deps === 0) {
  7528. parentSuspense.resolve();
  7529. }
  7530. }
  7531. {
  7532. devtoolsComponentRemoved(instance);
  7533. }
  7534. };
  7535. const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
  7536. for (let i = start; i < children.length; i++) {
  7537. unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
  7538. }
  7539. };
  7540. const getNextHostNode = vnode => {
  7541. if (vnode.shapeFlag & 6 /* COMPONENT */) {
  7542. return getNextHostNode(vnode.component.subTree);
  7543. }
  7544. if (vnode.shapeFlag & 128 /* SUSPENSE */) {
  7545. return vnode.suspense.next();
  7546. }
  7547. return hostNextSibling((vnode.anchor || vnode.el));
  7548. };
  7549. const render = (vnode, container, isSVG) => {
  7550. if (vnode == null) {
  7551. if (container._vnode) {
  7552. unmount(container._vnode, null, null, true);
  7553. }
  7554. }
  7555. else {
  7556. patch(container._vnode || null, vnode, container, null, null, null, isSVG);
  7557. }
  7558. flushPostFlushCbs();
  7559. container._vnode = vnode;
  7560. };
  7561. const internals = {
  7562. p: patch,
  7563. um: unmount,
  7564. m: move,
  7565. r: remove,
  7566. mt: mountComponent,
  7567. mc: mountChildren,
  7568. pc: patchChildren,
  7569. pbc: patchBlockChildren,
  7570. n: getNextHostNode,
  7571. o: options
  7572. };
  7573. let hydrate;
  7574. let hydrateNode;
  7575. if (createHydrationFns) {
  7576. [hydrate, hydrateNode] = createHydrationFns(internals);
  7577. }
  7578. return {
  7579. render,
  7580. hydrate,
  7581. createApp: createAppAPI(render, hydrate)
  7582. };
  7583. }
  7584. function toggleRecurse({ effect, update }, allowed) {
  7585. effect.allowRecurse = update.allowRecurse = allowed;
  7586. }
  7587. /**
  7588. * #1156
  7589. * When a component is HMR-enabled, we need to make sure that all static nodes
  7590. * inside a block also inherit the DOM element from the previous tree so that
  7591. * HMR updates (which are full updates) can retrieve the element for patching.
  7592. *
  7593. * #2080
  7594. * Inside keyed `template` fragment static children, if a fragment is moved,
  7595. * the children will always be moved. Therefore, in order to ensure correct move
  7596. * position, el should be inherited from previous nodes.
  7597. */
  7598. function traverseStaticChildren(n1, n2, shallow = false) {
  7599. const ch1 = n1.children;
  7600. const ch2 = n2.children;
  7601. if (isArray(ch1) && isArray(ch2)) {
  7602. for (let i = 0; i < ch1.length; i++) {
  7603. // this is only called in the optimized path so array children are
  7604. // guaranteed to be vnodes
  7605. const c1 = ch1[i];
  7606. let c2 = ch2[i];
  7607. if (c2.shapeFlag & 1 /* ELEMENT */ && !c2.dynamicChildren) {
  7608. if (c2.patchFlag <= 0 || c2.patchFlag === 32 /* HYDRATE_EVENTS */) {
  7609. c2 = ch2[i] = cloneIfMounted(ch2[i]);
  7610. c2.el = c1.el;
  7611. }
  7612. if (!shallow)
  7613. traverseStaticChildren(c1, c2);
  7614. }
  7615. // also inherit for comment nodes, but not placeholders (e.g. v-if which
  7616. // would have received .el during block patch)
  7617. if (c2.type === Comment && !c2.el) {
  7618. c2.el = c1.el;
  7619. }
  7620. }
  7621. }
  7622. }
  7623. // https://en.wikipedia.org/wiki/Longest_increasing_subsequence
  7624. function getSequence(arr) {
  7625. const p = arr.slice();
  7626. const result = [0];
  7627. let i, j, u, v, c;
  7628. const len = arr.length;
  7629. for (i = 0; i < len; i++) {
  7630. const arrI = arr[i];
  7631. if (arrI !== 0) {
  7632. j = result[result.length - 1];
  7633. if (arr[j] < arrI) {
  7634. p[i] = j;
  7635. result.push(i);
  7636. continue;
  7637. }
  7638. u = 0;
  7639. v = result.length - 1;
  7640. while (u < v) {
  7641. c = (u + v) >> 1;
  7642. if (arr[result[c]] < arrI) {
  7643. u = c + 1;
  7644. }
  7645. else {
  7646. v = c;
  7647. }
  7648. }
  7649. if (arrI < arr[result[u]]) {
  7650. if (u > 0) {
  7651. p[i] = result[u - 1];
  7652. }
  7653. result[u] = i;
  7654. }
  7655. }
  7656. }
  7657. u = result.length;
  7658. v = result[u - 1];
  7659. while (u-- > 0) {
  7660. result[u] = v;
  7661. v = p[v];
  7662. }
  7663. return result;
  7664. }
  7665. const isTeleport = (type) => type.__isTeleport;
  7666. const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === '');
  7667. const isTargetSVG = (target) => typeof SVGElement !== 'undefined' && target instanceof SVGElement;
  7668. const resolveTarget = (props, select) => {
  7669. const targetSelector = props && props.to;
  7670. if (isString(targetSelector)) {
  7671. if (!select) {
  7672. warn$1(`Current renderer does not support string target for Teleports. ` +
  7673. `(missing querySelector renderer option)`);
  7674. return null;
  7675. }
  7676. else {
  7677. const target = select(targetSelector);
  7678. if (!target) {
  7679. warn$1(`Failed to locate Teleport target with selector "${targetSelector}". ` +
  7680. `Note the target element must exist before the component is mounted - ` +
  7681. `i.e. the target cannot be rendered by the component itself, and ` +
  7682. `ideally should be outside of the entire Vue component tree.`);
  7683. }
  7684. return target;
  7685. }
  7686. }
  7687. else {
  7688. if (!targetSelector && !isTeleportDisabled(props)) {
  7689. warn$1(`Invalid Teleport target: ${targetSelector}`);
  7690. }
  7691. return targetSelector;
  7692. }
  7693. };
  7694. const TeleportImpl = {
  7695. __isTeleport: true,
  7696. process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
  7697. const { mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, o: { insert, querySelector, createText, createComment } } = internals;
  7698. const disabled = isTeleportDisabled(n2.props);
  7699. let { shapeFlag, children, dynamicChildren } = n2;
  7700. // #3302
  7701. // HMR updated, force full diff
  7702. if (isHmrUpdating) {
  7703. optimized = false;
  7704. dynamicChildren = null;
  7705. }
  7706. if (n1 == null) {
  7707. // insert anchors in the main view
  7708. const placeholder = (n2.el = createComment('teleport start')
  7709. );
  7710. const mainAnchor = (n2.anchor = createComment('teleport end')
  7711. );
  7712. insert(placeholder, container, anchor);
  7713. insert(mainAnchor, container, anchor);
  7714. const target = (n2.target = resolveTarget(n2.props, querySelector));
  7715. const targetAnchor = (n2.targetAnchor = createText(''));
  7716. if (target) {
  7717. insert(targetAnchor, target);
  7718. // #2652 we could be teleporting from a non-SVG tree into an SVG tree
  7719. isSVG = isSVG || isTargetSVG(target);
  7720. }
  7721. else if (!disabled) {
  7722. warn$1('Invalid Teleport target on mount:', target, `(${typeof target})`);
  7723. }
  7724. const mount = (container, anchor) => {
  7725. // Teleport *always* has Array children. This is enforced in both the
  7726. // compiler and vnode children normalization.
  7727. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  7728. mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
  7729. }
  7730. };
  7731. if (disabled) {
  7732. mount(container, mainAnchor);
  7733. }
  7734. else if (target) {
  7735. mount(target, targetAnchor);
  7736. }
  7737. }
  7738. else {
  7739. // update content
  7740. n2.el = n1.el;
  7741. const mainAnchor = (n2.anchor = n1.anchor);
  7742. const target = (n2.target = n1.target);
  7743. const targetAnchor = (n2.targetAnchor = n1.targetAnchor);
  7744. const wasDisabled = isTeleportDisabled(n1.props);
  7745. const currentContainer = wasDisabled ? container : target;
  7746. const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
  7747. isSVG = isSVG || isTargetSVG(target);
  7748. if (dynamicChildren) {
  7749. // fast path when the teleport happens to be a block root
  7750. patchBlockChildren(n1.dynamicChildren, dynamicChildren, currentContainer, parentComponent, parentSuspense, isSVG, slotScopeIds);
  7751. // even in block tree mode we need to make sure all root-level nodes
  7752. // in the teleport inherit previous DOM references so that they can
  7753. // be moved in future patches.
  7754. traverseStaticChildren(n1, n2, true);
  7755. }
  7756. else if (!optimized) {
  7757. patchChildren(n1, n2, currentContainer, currentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, false);
  7758. }
  7759. if (disabled) {
  7760. if (!wasDisabled) {
  7761. // enabled -> disabled
  7762. // move into main container
  7763. moveTeleport(n2, container, mainAnchor, internals, 1 /* TOGGLE */);
  7764. }
  7765. }
  7766. else {
  7767. // target changed
  7768. if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
  7769. const nextTarget = (n2.target = resolveTarget(n2.props, querySelector));
  7770. if (nextTarget) {
  7771. moveTeleport(n2, nextTarget, null, internals, 0 /* TARGET_CHANGE */);
  7772. }
  7773. else {
  7774. warn$1('Invalid Teleport target on update:', target, `(${typeof target})`);
  7775. }
  7776. }
  7777. else if (wasDisabled) {
  7778. // disabled -> enabled
  7779. // move into teleport target
  7780. moveTeleport(n2, target, targetAnchor, internals, 1 /* TOGGLE */);
  7781. }
  7782. }
  7783. }
  7784. },
  7785. remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
  7786. const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
  7787. if (target) {
  7788. hostRemove(targetAnchor);
  7789. }
  7790. // an unmounted teleport should always remove its children if not disabled
  7791. if (doRemove || !isTeleportDisabled(props)) {
  7792. hostRemove(anchor);
  7793. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  7794. for (let i = 0; i < children.length; i++) {
  7795. const child = children[i];
  7796. unmount(child, parentComponent, parentSuspense, true, !!child.dynamicChildren);
  7797. }
  7798. }
  7799. }
  7800. },
  7801. move: moveTeleport,
  7802. hydrate: hydrateTeleport
  7803. };
  7804. function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2 /* REORDER */) {
  7805. // move target anchor if this is a target change.
  7806. if (moveType === 0 /* TARGET_CHANGE */) {
  7807. insert(vnode.targetAnchor, container, parentAnchor);
  7808. }
  7809. const { el, anchor, shapeFlag, children, props } = vnode;
  7810. const isReorder = moveType === 2 /* REORDER */;
  7811. // move main view anchor if this is a re-order.
  7812. if (isReorder) {
  7813. insert(el, container, parentAnchor);
  7814. }
  7815. // if this is a re-order and teleport is enabled (content is in target)
  7816. // do not move children. So the opposite is: only move children if this
  7817. // is not a reorder, or the teleport is disabled
  7818. if (!isReorder || isTeleportDisabled(props)) {
  7819. // Teleport has either Array children or no children.
  7820. if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
  7821. for (let i = 0; i < children.length; i++) {
  7822. move(children[i], container, parentAnchor, 2 /* REORDER */);
  7823. }
  7824. }
  7825. }
  7826. // move main view anchor if this is a re-order.
  7827. if (isReorder) {
  7828. insert(anchor, container, parentAnchor);
  7829. }
  7830. }
  7831. function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, { o: { nextSibling, parentNode, querySelector } }, hydrateChildren) {
  7832. const target = (vnode.target = resolveTarget(vnode.props, querySelector));
  7833. if (target) {
  7834. // if multiple teleports rendered to the same target element, we need to
  7835. // pick up from where the last teleport finished instead of the first node
  7836. const targetNode = target._lpa || target.firstChild;
  7837. if (vnode.shapeFlag & 16 /* ARRAY_CHILDREN */) {
  7838. if (isTeleportDisabled(vnode.props)) {
  7839. vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized);
  7840. vnode.targetAnchor = targetNode;
  7841. }
  7842. else {
  7843. vnode.anchor = nextSibling(node);
  7844. // lookahead until we find the target anchor
  7845. // we cannot rely on return value of hydrateChildren() because there
  7846. // could be nested teleports
  7847. let targetAnchor = targetNode;
  7848. while (targetAnchor) {
  7849. targetAnchor = nextSibling(targetAnchor);
  7850. if (targetAnchor &&
  7851. targetAnchor.nodeType === 8 &&
  7852. targetAnchor.data === 'teleport anchor') {
  7853. vnode.targetAnchor = targetAnchor;
  7854. target._lpa =
  7855. vnode.targetAnchor && nextSibling(vnode.targetAnchor);
  7856. break;
  7857. }
  7858. }
  7859. hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
  7860. }
  7861. }
  7862. }
  7863. return vnode.anchor && nextSibling(vnode.anchor);
  7864. }
  7865. // Force-casted public typing for h and TSX props inference
  7866. const Teleport = TeleportImpl;
  7867. const Fragment = Symbol('Fragment' );
  7868. const Text = Symbol('Text' );
  7869. const Comment = Symbol('Comment' );
  7870. const Static = Symbol('Static' );
  7871. // Since v-if and v-for are the two possible ways node structure can dynamically
  7872. // change, once we consider v-if branches and each v-for fragment a block, we
  7873. // can divide a template into nested blocks, and within each block the node
  7874. // structure would be stable. This allows us to skip most children diffing
  7875. // and only worry about the dynamic nodes (indicated by patch flags).
  7876. const blockStack = [];
  7877. let currentBlock = null;
  7878. /**
  7879. * Open a block.
  7880. * This must be called before `createBlock`. It cannot be part of `createBlock`
  7881. * because the children of the block are evaluated before `createBlock` itself
  7882. * is called. The generated code typically looks like this:
  7883. *
  7884. * ```js
  7885. * function render() {
  7886. * return (openBlock(),createBlock('div', null, [...]))
  7887. * }
  7888. * ```
  7889. * disableTracking is true when creating a v-for fragment block, since a v-for
  7890. * fragment always diffs its children.
  7891. *
  7892. * @private
  7893. */
  7894. function openBlock(disableTracking = false) {
  7895. blockStack.push((currentBlock = disableTracking ? null : []));
  7896. }
  7897. function closeBlock() {
  7898. blockStack.pop();
  7899. currentBlock = blockStack[blockStack.length - 1] || null;
  7900. }
  7901. // Whether we should be tracking dynamic child nodes inside a block.
  7902. // Only tracks when this value is > 0
  7903. // We are not using a simple boolean because this value may need to be
  7904. // incremented/decremented by nested usage of v-once (see below)
  7905. let isBlockTreeEnabled = 1;
  7906. /**
  7907. * Block tracking sometimes needs to be disabled, for example during the
  7908. * creation of a tree that needs to be cached by v-once. The compiler generates
  7909. * code like this:
  7910. *
  7911. * ``` js
  7912. * _cache[1] || (
  7913. * setBlockTracking(-1),
  7914. * _cache[1] = createVNode(...),
  7915. * setBlockTracking(1),
  7916. * _cache[1]
  7917. * )
  7918. * ```
  7919. *
  7920. * @private
  7921. */
  7922. function setBlockTracking(value) {
  7923. isBlockTreeEnabled += value;
  7924. }
  7925. function setupBlock(vnode) {
  7926. // save current block children on the block vnode
  7927. vnode.dynamicChildren =
  7928. isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
  7929. // close block
  7930. closeBlock();
  7931. // a block is always going to be patched, so track it as a child of its
  7932. // parent block
  7933. if (isBlockTreeEnabled > 0 && currentBlock) {
  7934. currentBlock.push(vnode);
  7935. }
  7936. return vnode;
  7937. }
  7938. /**
  7939. * @private
  7940. */
  7941. function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
  7942. return setupBlock(createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, true /* isBlock */));
  7943. }
  7944. /**
  7945. * Create a block root vnode. Takes the same exact arguments as `createVNode`.
  7946. * A block root keeps track of dynamic nodes within the block in the
  7947. * `dynamicChildren` array.
  7948. *
  7949. * @private
  7950. */
  7951. function createBlock(type, props, children, patchFlag, dynamicProps) {
  7952. return setupBlock(createVNode(type, props, children, patchFlag, dynamicProps, true /* isBlock: prevent a block from tracking itself */));
  7953. }
  7954. function isVNode(value) {
  7955. return value ? value.__v_isVNode === true : false;
  7956. }
  7957. function isSameVNodeType(n1, n2) {
  7958. if (n2.shapeFlag & 6 /* COMPONENT */ &&
  7959. hmrDirtyComponents.has(n2.type)) {
  7960. // HMR only: if the component has been hot-updated, force a reload.
  7961. return false;
  7962. }
  7963. return n1.type === n2.type && n1.key === n2.key;
  7964. }
  7965. let vnodeArgsTransformer;
  7966. /**
  7967. * Internal API for registering an arguments transform for createVNode
  7968. * used for creating stubs in the test-utils
  7969. * It is *internal* but needs to be exposed for test-utils to pick up proper
  7970. * typings
  7971. */
  7972. function transformVNodeArgs(transformer) {
  7973. vnodeArgsTransformer = transformer;
  7974. }
  7975. const createVNodeWithArgsTransform = (...args) => {
  7976. return _createVNode(...(vnodeArgsTransformer
  7977. ? vnodeArgsTransformer(args, currentRenderingInstance)
  7978. : args));
  7979. };
  7980. const InternalObjectKey = `__vInternal`;
  7981. const normalizeKey = ({ key }) => key != null ? key : null;
  7982. const normalizeRef = ({ ref, ref_key, ref_for }) => {
  7983. return (ref != null
  7984. ? isString(ref) || isRef(ref) || isFunction(ref)
  7985. ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for }
  7986. : ref
  7987. : null);
  7988. };
  7989. function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1 /* ELEMENT */, isBlockNode = false, needFullChildrenNormalization = false) {
  7990. const vnode = {
  7991. __v_isVNode: true,
  7992. __v_skip: true,
  7993. type,
  7994. props,
  7995. key: props && normalizeKey(props),
  7996. ref: props && normalizeRef(props),
  7997. scopeId: currentScopeId,
  7998. slotScopeIds: null,
  7999. children,
  8000. component: null,
  8001. suspense: null,
  8002. ssContent: null,
  8003. ssFallback: null,
  8004. dirs: null,
  8005. transition: null,
  8006. el: null,
  8007. anchor: null,
  8008. target: null,
  8009. targetAnchor: null,
  8010. staticCount: 0,
  8011. shapeFlag,
  8012. patchFlag,
  8013. dynamicProps,
  8014. dynamicChildren: null,
  8015. appContext: null
  8016. };
  8017. if (needFullChildrenNormalization) {
  8018. normalizeChildren(vnode, children);
  8019. // normalize suspense children
  8020. if (shapeFlag & 128 /* SUSPENSE */) {
  8021. type.normalize(vnode);
  8022. }
  8023. }
  8024. else if (children) {
  8025. // compiled element vnode - if children is passed, only possible types are
  8026. // string or Array.
  8027. vnode.shapeFlag |= isString(children)
  8028. ? 8 /* TEXT_CHILDREN */
  8029. : 16 /* ARRAY_CHILDREN */;
  8030. }
  8031. // validate key
  8032. if (vnode.key !== vnode.key) {
  8033. warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
  8034. }
  8035. // track vnode for block tree
  8036. if (isBlockTreeEnabled > 0 &&
  8037. // avoid a block node from tracking itself
  8038. !isBlockNode &&
  8039. // has current parent block
  8040. currentBlock &&
  8041. // presence of a patch flag indicates this node needs patching on updates.
  8042. // component nodes also should always be patched, because even if the
  8043. // component doesn't need to update, it needs to persist the instance on to
  8044. // the next vnode so that it can be properly unmounted later.
  8045. (vnode.patchFlag > 0 || shapeFlag & 6 /* COMPONENT */) &&
  8046. // the EVENTS flag is only for hydration and if it is the only flag, the
  8047. // vnode should not be considered dynamic due to handler caching.
  8048. vnode.patchFlag !== 32 /* HYDRATE_EVENTS */) {
  8049. currentBlock.push(vnode);
  8050. }
  8051. return vnode;
  8052. }
  8053. const createVNode = (createVNodeWithArgsTransform );
  8054. function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
  8055. if (!type || type === NULL_DYNAMIC_COMPONENT) {
  8056. if (!type) {
  8057. warn$1(`Invalid vnode type when creating vnode: ${type}.`);
  8058. }
  8059. type = Comment;
  8060. }
  8061. if (isVNode(type)) {
  8062. // createVNode receiving an existing vnode. This happens in cases like
  8063. // <component :is="vnode"/>
  8064. // #2078 make sure to merge refs during the clone instead of overwriting it
  8065. const cloned = cloneVNode(type, props, true /* mergeRef: true */);
  8066. if (children) {
  8067. normalizeChildren(cloned, children);
  8068. }
  8069. if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
  8070. if (cloned.shapeFlag & 6 /* COMPONENT */) {
  8071. currentBlock[currentBlock.indexOf(type)] = cloned;
  8072. }
  8073. else {
  8074. currentBlock.push(cloned);
  8075. }
  8076. }
  8077. cloned.patchFlag |= -2 /* BAIL */;
  8078. return cloned;
  8079. }
  8080. // class component normalization.
  8081. if (isClassComponent(type)) {
  8082. type = type.__vccOpts;
  8083. }
  8084. // class & style normalization.
  8085. if (props) {
  8086. // for reactive or proxy objects, we need to clone it to enable mutation.
  8087. props = guardReactiveProps(props);
  8088. let { class: klass, style } = props;
  8089. if (klass && !isString(klass)) {
  8090. props.class = normalizeClass(klass);
  8091. }
  8092. if (isObject(style)) {
  8093. // reactive state objects need to be cloned since they are likely to be
  8094. // mutated
  8095. if (isProxy(style) && !isArray(style)) {
  8096. style = extend({}, style);
  8097. }
  8098. props.style = normalizeStyle(style);
  8099. }
  8100. }
  8101. // encode the vnode type information into a bitmap
  8102. const shapeFlag = isString(type)
  8103. ? 1 /* ELEMENT */
  8104. : isSuspense(type)
  8105. ? 128 /* SUSPENSE */
  8106. : isTeleport(type)
  8107. ? 64 /* TELEPORT */
  8108. : isObject(type)
  8109. ? 4 /* STATEFUL_COMPONENT */
  8110. : isFunction(type)
  8111. ? 2 /* FUNCTIONAL_COMPONENT */
  8112. : 0;
  8113. if (shapeFlag & 4 /* STATEFUL_COMPONENT */ && isProxy(type)) {
  8114. type = toRaw(type);
  8115. warn$1(`Vue received a Component which was made a reactive object. This can ` +
  8116. `lead to unnecessary performance overhead, and should be avoided by ` +
  8117. `marking the component with \`markRaw\` or using \`shallowRef\` ` +
  8118. `instead of \`ref\`.`, `\nComponent that was made reactive: `, type);
  8119. }
  8120. return createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, isBlockNode, true);
  8121. }
  8122. function guardReactiveProps(props) {
  8123. if (!props)
  8124. return null;
  8125. return isProxy(props) || InternalObjectKey in props
  8126. ? extend({}, props)
  8127. : props;
  8128. }
  8129. function cloneVNode(vnode, extraProps, mergeRef = false) {
  8130. // This is intentionally NOT using spread or extend to avoid the runtime
  8131. // key enumeration cost.
  8132. const { props, ref, patchFlag, children } = vnode;
  8133. const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
  8134. const cloned = {
  8135. __v_isVNode: true,
  8136. __v_skip: true,
  8137. type: vnode.type,
  8138. props: mergedProps,
  8139. key: mergedProps && normalizeKey(mergedProps),
  8140. ref: extraProps && extraProps.ref
  8141. ? // #2078 in the case of <component :is="vnode" ref="extra"/>
  8142. // if the vnode itself already has a ref, cloneVNode will need to merge
  8143. // the refs so the single vnode can be set on multiple refs
  8144. mergeRef && ref
  8145. ? isArray(ref)
  8146. ? ref.concat(normalizeRef(extraProps))
  8147. : [ref, normalizeRef(extraProps)]
  8148. : normalizeRef(extraProps)
  8149. : ref,
  8150. scopeId: vnode.scopeId,
  8151. slotScopeIds: vnode.slotScopeIds,
  8152. children: patchFlag === -1 /* HOISTED */ && isArray(children)
  8153. ? children.map(deepCloneVNode)
  8154. : children,
  8155. target: vnode.target,
  8156. targetAnchor: vnode.targetAnchor,
  8157. staticCount: vnode.staticCount,
  8158. shapeFlag: vnode.shapeFlag,
  8159. // if the vnode is cloned with extra props, we can no longer assume its
  8160. // existing patch flag to be reliable and need to add the FULL_PROPS flag.
  8161. // note: preserve flag for fragments since they use the flag for children
  8162. // fast paths only.
  8163. patchFlag: extraProps && vnode.type !== Fragment
  8164. ? patchFlag === -1 // hoisted node
  8165. ? 16 /* FULL_PROPS */
  8166. : patchFlag | 16 /* FULL_PROPS */
  8167. : patchFlag,
  8168. dynamicProps: vnode.dynamicProps,
  8169. dynamicChildren: vnode.dynamicChildren,
  8170. appContext: vnode.appContext,
  8171. dirs: vnode.dirs,
  8172. transition: vnode.transition,
  8173. // These should technically only be non-null on mounted VNodes. However,
  8174. // they *should* be copied for kept-alive vnodes. So we just always copy
  8175. // them since them being non-null during a mount doesn't affect the logic as
  8176. // they will simply be overwritten.
  8177. component: vnode.component,
  8178. suspense: vnode.suspense,
  8179. ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
  8180. ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
  8181. el: vnode.el,
  8182. anchor: vnode.anchor
  8183. };
  8184. return cloned;
  8185. }
  8186. /**
  8187. * Dev only, for HMR of hoisted vnodes reused in v-for
  8188. * https://github.com/vitejs/vite/issues/2022
  8189. */
  8190. function deepCloneVNode(vnode) {
  8191. const cloned = cloneVNode(vnode);
  8192. if (isArray(vnode.children)) {
  8193. cloned.children = vnode.children.map(deepCloneVNode);
  8194. }
  8195. return cloned;
  8196. }
  8197. /**
  8198. * @private
  8199. */
  8200. function createTextVNode(text = ' ', flag = 0) {
  8201. return createVNode(Text, null, text, flag);
  8202. }
  8203. /**
  8204. * @private
  8205. */
  8206. function createStaticVNode(content, numberOfNodes) {
  8207. // A static vnode can contain multiple stringified elements, and the number
  8208. // of elements is necessary for hydration.
  8209. const vnode = createVNode(Static, null, content);
  8210. vnode.staticCount = numberOfNodes;
  8211. return vnode;
  8212. }
  8213. /**
  8214. * @private
  8215. */
  8216. function createCommentVNode(text = '',
  8217. // when used as the v-else branch, the comment node must be created as a
  8218. // block to ensure correct updates.
  8219. asBlock = false) {
  8220. return asBlock
  8221. ? (openBlock(), createBlock(Comment, null, text))
  8222. : createVNode(Comment, null, text);
  8223. }
  8224. function normalizeVNode(child) {
  8225. if (child == null || typeof child === 'boolean') {
  8226. // empty placeholder
  8227. return createVNode(Comment);
  8228. }
  8229. else if (isArray(child)) {
  8230. // fragment
  8231. return createVNode(Fragment, null,
  8232. // #3666, avoid reference pollution when reusing vnode
  8233. child.slice());
  8234. }
  8235. else if (typeof child === 'object') {
  8236. // already vnode, this should be the most common since compiled templates
  8237. // always produce all-vnode children arrays
  8238. return cloneIfMounted(child);
  8239. }
  8240. else {
  8241. // strings and numbers
  8242. return createVNode(Text, null, String(child));
  8243. }
  8244. }
  8245. // optimized normalization for template-compiled render fns
  8246. function cloneIfMounted(child) {
  8247. return child.el === null || child.memo ? child : cloneVNode(child);
  8248. }
  8249. function normalizeChildren(vnode, children) {
  8250. let type = 0;
  8251. const { shapeFlag } = vnode;
  8252. if (children == null) {
  8253. children = null;
  8254. }
  8255. else if (isArray(children)) {
  8256. type = 16 /* ARRAY_CHILDREN */;
  8257. }
  8258. else if (typeof children === 'object') {
  8259. if (shapeFlag & (1 /* ELEMENT */ | 64 /* TELEPORT */)) {
  8260. // Normalize slot to plain children for plain element and Teleport
  8261. const slot = children.default;
  8262. if (slot) {
  8263. // _c marker is added by withCtx() indicating this is a compiled slot
  8264. slot._c && (slot._d = false);
  8265. normalizeChildren(vnode, slot());
  8266. slot._c && (slot._d = true);
  8267. }
  8268. return;
  8269. }
  8270. else {
  8271. type = 32 /* SLOTS_CHILDREN */;
  8272. const slotFlag = children._;
  8273. if (!slotFlag && !(InternalObjectKey in children)) {
  8274. children._ctx = currentRenderingInstance;
  8275. }
  8276. else if (slotFlag === 3 /* FORWARDED */ && currentRenderingInstance) {
  8277. // a child component receives forwarded slots from the parent.
  8278. // its slot type is determined by its parent's slot type.
  8279. if (currentRenderingInstance.slots._ === 1 /* STABLE */) {
  8280. children._ = 1 /* STABLE */;
  8281. }
  8282. else {
  8283. children._ = 2 /* DYNAMIC */;
  8284. vnode.patchFlag |= 1024 /* DYNAMIC_SLOTS */;
  8285. }
  8286. }
  8287. }
  8288. }
  8289. else if (isFunction(children)) {
  8290. children = { default: children, _ctx: currentRenderingInstance };
  8291. type = 32 /* SLOTS_CHILDREN */;
  8292. }
  8293. else {
  8294. children = String(children);
  8295. // force teleport children to array so it can be moved around
  8296. if (shapeFlag & 64 /* TELEPORT */) {
  8297. type = 16 /* ARRAY_CHILDREN */;
  8298. children = [createTextVNode(children)];
  8299. }
  8300. else {
  8301. type = 8 /* TEXT_CHILDREN */;
  8302. }
  8303. }
  8304. vnode.children = children;
  8305. vnode.shapeFlag |= type;
  8306. }
  8307. function mergeProps(...args) {
  8308. const ret = {};
  8309. for (let i = 0; i < args.length; i++) {
  8310. const toMerge = args[i];
  8311. for (const key in toMerge) {
  8312. if (key === 'class') {
  8313. if (ret.class !== toMerge.class) {
  8314. ret.class = normalizeClass([ret.class, toMerge.class]);
  8315. }
  8316. }
  8317. else if (key === 'style') {
  8318. ret.style = normalizeStyle([ret.style, toMerge.style]);
  8319. }
  8320. else if (isOn(key)) {
  8321. const existing = ret[key];
  8322. const incoming = toMerge[key];
  8323. if (incoming &&
  8324. existing !== incoming &&
  8325. !(isArray(existing) && existing.includes(incoming))) {
  8326. ret[key] = existing
  8327. ? [].concat(existing, incoming)
  8328. : incoming;
  8329. }
  8330. }
  8331. else if (key !== '') {
  8332. ret[key] = toMerge[key];
  8333. }
  8334. }
  8335. }
  8336. return ret;
  8337. }
  8338. function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
  8339. callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
  8340. vnode,
  8341. prevVNode
  8342. ]);
  8343. }
  8344. const emptyAppContext = createAppContext();
  8345. let uid$1 = 0;
  8346. function createComponentInstance(vnode, parent, suspense) {
  8347. const type = vnode.type;
  8348. // inherit parent app context - or - if root, adopt from root vnode
  8349. const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
  8350. const instance = {
  8351. uid: uid$1++,
  8352. vnode,
  8353. type,
  8354. parent,
  8355. appContext,
  8356. root: null,
  8357. next: null,
  8358. subTree: null,
  8359. effect: null,
  8360. update: null,
  8361. scope: new EffectScope(true /* detached */),
  8362. render: null,
  8363. proxy: null,
  8364. exposed: null,
  8365. exposeProxy: null,
  8366. withProxy: null,
  8367. provides: parent ? parent.provides : Object.create(appContext.provides),
  8368. accessCache: null,
  8369. renderCache: [],
  8370. // local resolved assets
  8371. components: null,
  8372. directives: null,
  8373. // resolved props and emits options
  8374. propsOptions: normalizePropsOptions(type, appContext),
  8375. emitsOptions: normalizeEmitsOptions(type, appContext),
  8376. // emit
  8377. emit: null,
  8378. emitted: null,
  8379. // props default value
  8380. propsDefaults: EMPTY_OBJ,
  8381. // inheritAttrs
  8382. inheritAttrs: type.inheritAttrs,
  8383. // state
  8384. ctx: EMPTY_OBJ,
  8385. data: EMPTY_OBJ,
  8386. props: EMPTY_OBJ,
  8387. attrs: EMPTY_OBJ,
  8388. slots: EMPTY_OBJ,
  8389. refs: EMPTY_OBJ,
  8390. setupState: EMPTY_OBJ,
  8391. setupContext: null,
  8392. // suspense related
  8393. suspense,
  8394. suspenseId: suspense ? suspense.pendingId : 0,
  8395. asyncDep: null,
  8396. asyncResolved: false,
  8397. // lifecycle hooks
  8398. // not using enums here because it results in computed properties
  8399. isMounted: false,
  8400. isUnmounted: false,
  8401. isDeactivated: false,
  8402. bc: null,
  8403. c: null,
  8404. bm: null,
  8405. m: null,
  8406. bu: null,
  8407. u: null,
  8408. um: null,
  8409. bum: null,
  8410. da: null,
  8411. a: null,
  8412. rtg: null,
  8413. rtc: null,
  8414. ec: null,
  8415. sp: null
  8416. };
  8417. {
  8418. instance.ctx = createDevRenderContext(instance);
  8419. }
  8420. instance.root = parent ? parent.root : instance;
  8421. instance.emit = emit$1.bind(null, instance);
  8422. // apply custom element special handling
  8423. if (vnode.ce) {
  8424. vnode.ce(instance);
  8425. }
  8426. return instance;
  8427. }
  8428. let currentInstance = null;
  8429. const getCurrentInstance = () => currentInstance || currentRenderingInstance;
  8430. const setCurrentInstance = (instance) => {
  8431. currentInstance = instance;
  8432. instance.scope.on();
  8433. };
  8434. const unsetCurrentInstance = () => {
  8435. currentInstance && currentInstance.scope.off();
  8436. currentInstance = null;
  8437. };
  8438. const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component');
  8439. function validateComponentName(name, config) {
  8440. const appIsNativeTag = config.isNativeTag || NO;
  8441. if (isBuiltInTag(name) || appIsNativeTag(name)) {
  8442. warn$1('Do not use built-in or reserved HTML elements as component id: ' + name);
  8443. }
  8444. }
  8445. function isStatefulComponent(instance) {
  8446. return instance.vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */;
  8447. }
  8448. let isInSSRComponentSetup = false;
  8449. function setupComponent(instance, isSSR = false) {
  8450. isInSSRComponentSetup = isSSR;
  8451. const { props, children } = instance.vnode;
  8452. const isStateful = isStatefulComponent(instance);
  8453. initProps(instance, props, isStateful, isSSR);
  8454. initSlots(instance, children);
  8455. const setupResult = isStateful
  8456. ? setupStatefulComponent(instance, isSSR)
  8457. : undefined;
  8458. isInSSRComponentSetup = false;
  8459. return setupResult;
  8460. }
  8461. function setupStatefulComponent(instance, isSSR) {
  8462. var _a;
  8463. const Component = instance.type;
  8464. {
  8465. if (Component.name) {
  8466. validateComponentName(Component.name, instance.appContext.config);
  8467. }
  8468. if (Component.components) {
  8469. const names = Object.keys(Component.components);
  8470. for (let i = 0; i < names.length; i++) {
  8471. validateComponentName(names[i], instance.appContext.config);
  8472. }
  8473. }
  8474. if (Component.directives) {
  8475. const names = Object.keys(Component.directives);
  8476. for (let i = 0; i < names.length; i++) {
  8477. validateDirectiveName(names[i]);
  8478. }
  8479. }
  8480. if (Component.compilerOptions && isRuntimeOnly()) {
  8481. warn$1(`"compilerOptions" is only supported when using a build of Vue that ` +
  8482. `includes the runtime compiler. Since you are using a runtime-only ` +
  8483. `build, the options should be passed via your build tool config instead.`);
  8484. }
  8485. }
  8486. // 0. create render proxy property access cache
  8487. instance.accessCache = Object.create(null);
  8488. // 1. create public instance / render proxy
  8489. // also mark it raw so it's never observed
  8490. instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
  8491. {
  8492. exposePropsOnRenderContext(instance);
  8493. }
  8494. // 2. call setup()
  8495. const { setup } = Component;
  8496. if (setup) {
  8497. const setupContext = (instance.setupContext =
  8498. setup.length > 1 ? createSetupContext(instance) : null);
  8499. setCurrentInstance(instance);
  8500. pauseTracking();
  8501. const setupResult = callWithErrorHandling(setup, instance, 0 /* SETUP_FUNCTION */, [shallowReadonly(instance.props) , setupContext]);
  8502. resetTracking();
  8503. unsetCurrentInstance();
  8504. if (isPromise(setupResult)) {
  8505. setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
  8506. if (isSSR) {
  8507. // return the promise so server-renderer can wait on it
  8508. return setupResult
  8509. .then((resolvedResult) => {
  8510. handleSetupResult(instance, resolvedResult, isSSR);
  8511. })
  8512. .catch(e => {
  8513. handleError(e, instance, 0 /* SETUP_FUNCTION */);
  8514. });
  8515. }
  8516. else {
  8517. // async setup returned Promise.
  8518. // bail here and wait for re-entry.
  8519. instance.asyncDep = setupResult;
  8520. if (!instance.suspense) {
  8521. const name = (_a = Component.name) !== null && _a !== void 0 ? _a : 'Anonymous';
  8522. warn$1(`Component <${name}>: setup function returned a promise, but no ` +
  8523. `<Suspense> boundary was found in the parent component tree. ` +
  8524. `A component with async setup() must be nested in a <Suspense> ` +
  8525. `in order to be rendered.`);
  8526. }
  8527. }
  8528. }
  8529. else {
  8530. handleSetupResult(instance, setupResult, isSSR);
  8531. }
  8532. }
  8533. else {
  8534. finishComponentSetup(instance, isSSR);
  8535. }
  8536. }
  8537. function handleSetupResult(instance, setupResult, isSSR) {
  8538. if (isFunction(setupResult)) {
  8539. // setup returned an inline render function
  8540. {
  8541. instance.render = setupResult;
  8542. }
  8543. }
  8544. else if (isObject(setupResult)) {
  8545. if (isVNode(setupResult)) {
  8546. warn$1(`setup() should not return VNodes directly - ` +
  8547. `return a render function instead.`);
  8548. }
  8549. // setup returned bindings.
  8550. // assuming a render function compiled from template is present.
  8551. {
  8552. instance.devtoolsRawSetupState = setupResult;
  8553. }
  8554. instance.setupState = proxyRefs(setupResult);
  8555. {
  8556. exposeSetupStateOnRenderContext(instance);
  8557. }
  8558. }
  8559. else if (setupResult !== undefined) {
  8560. warn$1(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
  8561. }
  8562. finishComponentSetup(instance, isSSR);
  8563. }
  8564. let compile;
  8565. let installWithProxy;
  8566. /**
  8567. * For runtime-dom to register the compiler.
  8568. * Note the exported method uses any to avoid d.ts relying on the compiler types.
  8569. */
  8570. function registerRuntimeCompiler(_compile) {
  8571. compile = _compile;
  8572. installWithProxy = i => {
  8573. if (i.render._rc) {
  8574. i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
  8575. }
  8576. };
  8577. }
  8578. // dev only
  8579. const isRuntimeOnly = () => !compile;
  8580. function finishComponentSetup(instance, isSSR, skipOptions) {
  8581. const Component = instance.type;
  8582. // template / render function normalization
  8583. // could be already set when returned from setup()
  8584. if (!instance.render) {
  8585. // only do on-the-fly compile if not in SSR - SSR on-the-fly compilation
  8586. // is done by server-renderer
  8587. if (!isSSR && compile && !Component.render) {
  8588. const template = Component.template;
  8589. if (template) {
  8590. {
  8591. startMeasure(instance, `compile`);
  8592. }
  8593. const { isCustomElement, compilerOptions } = instance.appContext.config;
  8594. const { delimiters, compilerOptions: componentCompilerOptions } = Component;
  8595. const finalCompilerOptions = extend(extend({
  8596. isCustomElement,
  8597. delimiters
  8598. }, compilerOptions), componentCompilerOptions);
  8599. Component.render = compile(template, finalCompilerOptions);
  8600. {
  8601. endMeasure(instance, `compile`);
  8602. }
  8603. }
  8604. }
  8605. instance.render = (Component.render || NOOP);
  8606. // for runtime-compiled render functions using `with` blocks, the render
  8607. // proxy used needs a different `has` handler which is more performant and
  8608. // also only allows a whitelist of globals to fallthrough.
  8609. if (installWithProxy) {
  8610. installWithProxy(instance);
  8611. }
  8612. }
  8613. // support for 2.x options
  8614. {
  8615. setCurrentInstance(instance);
  8616. pauseTracking();
  8617. applyOptions(instance);
  8618. resetTracking();
  8619. unsetCurrentInstance();
  8620. }
  8621. // warn missing template/render
  8622. // the runtime compilation of template in SSR is done by server-render
  8623. if (!Component.render && instance.render === NOOP && !isSSR) {
  8624. /* istanbul ignore if */
  8625. if (!compile && Component.template) {
  8626. warn$1(`Component provided template option but ` +
  8627. `runtime compilation is not supported in this build of Vue.` +
  8628. (` Use "vue.global.js" instead.`
  8629. ) /* should not happen */);
  8630. }
  8631. else {
  8632. warn$1(`Component is missing template or render function.`);
  8633. }
  8634. }
  8635. }
  8636. function createAttrsProxy(instance) {
  8637. return new Proxy(instance.attrs, {
  8638. get(target, key) {
  8639. markAttrsAccessed();
  8640. track(instance, "get" /* GET */, '$attrs');
  8641. return target[key];
  8642. },
  8643. set() {
  8644. warn$1(`setupContext.attrs is readonly.`);
  8645. return false;
  8646. },
  8647. deleteProperty() {
  8648. warn$1(`setupContext.attrs is readonly.`);
  8649. return false;
  8650. }
  8651. }
  8652. );
  8653. }
  8654. function createSetupContext(instance) {
  8655. const expose = exposed => {
  8656. if (instance.exposed) {
  8657. warn$1(`expose() should be called only once per setup().`);
  8658. }
  8659. instance.exposed = exposed || {};
  8660. };
  8661. let attrs;
  8662. {
  8663. // We use getters in dev in case libs like test-utils overwrite instance
  8664. // properties (overwrites should not be done in prod)
  8665. return Object.freeze({
  8666. get attrs() {
  8667. return attrs || (attrs = createAttrsProxy(instance));
  8668. },
  8669. get slots() {
  8670. return shallowReadonly(instance.slots);
  8671. },
  8672. get emit() {
  8673. return (event, ...args) => instance.emit(event, ...args);
  8674. },
  8675. expose
  8676. });
  8677. }
  8678. }
  8679. function getExposeProxy(instance) {
  8680. if (instance.exposed) {
  8681. return (instance.exposeProxy ||
  8682. (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
  8683. get(target, key) {
  8684. if (key in target) {
  8685. return target[key];
  8686. }
  8687. else if (key in publicPropertiesMap) {
  8688. return publicPropertiesMap[key](instance);
  8689. }
  8690. }
  8691. })));
  8692. }
  8693. }
  8694. const classifyRE = /(?:^|[-_])(\w)/g;
  8695. const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  8696. function getComponentName(Component, includeInferred = true) {
  8697. return isFunction(Component)
  8698. ? Component.displayName || Component.name
  8699. : Component.name || (includeInferred && Component.__name);
  8700. }
  8701. /* istanbul ignore next */
  8702. function formatComponentName(instance, Component, isRoot = false) {
  8703. let name = getComponentName(Component);
  8704. if (!name && Component.__file) {
  8705. const match = Component.__file.match(/([^/\\]+)\.\w+$/);
  8706. if (match) {
  8707. name = match[1];
  8708. }
  8709. }
  8710. if (!name && instance && instance.parent) {
  8711. // try to infer the name based on reverse resolution
  8712. const inferFromRegistry = (registry) => {
  8713. for (const key in registry) {
  8714. if (registry[key] === Component) {
  8715. return key;
  8716. }
  8717. }
  8718. };
  8719. name =
  8720. inferFromRegistry(instance.components ||
  8721. instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
  8722. }
  8723. return name ? classify(name) : isRoot ? `App` : `Anonymous`;
  8724. }
  8725. function isClassComponent(value) {
  8726. return isFunction(value) && '__vccOpts' in value;
  8727. }
  8728. const computed$1 = ((getterOrOptions, debugOptions) => {
  8729. // @ts-ignore
  8730. return computed(getterOrOptions, debugOptions, isInSSRComponentSetup);
  8731. });
  8732. // dev only
  8733. const warnRuntimeUsage = (method) => warn$1(`${method}() is a compiler-hint helper that is only usable inside ` +
  8734. `<script setup> of a single file component. Its arguments should be ` +
  8735. `compiled away and passing it at runtime has no effect.`);
  8736. // implementation
  8737. function defineProps() {
  8738. {
  8739. warnRuntimeUsage(`defineProps`);
  8740. }
  8741. return null;
  8742. }
  8743. // implementation
  8744. function defineEmits() {
  8745. {
  8746. warnRuntimeUsage(`defineEmits`);
  8747. }
  8748. return null;
  8749. }
  8750. /**
  8751. * Vue `<script setup>` compiler macro for declaring a component's exposed
  8752. * instance properties when it is accessed by a parent component via template
  8753. * refs.
  8754. *
  8755. * `<script setup>` components are closed by default - i.e. variables inside
  8756. * the `<script setup>` scope is not exposed to parent unless explicitly exposed
  8757. * via `defineExpose`.
  8758. *
  8759. * This is only usable inside `<script setup>`, is compiled away in the
  8760. * output and should **not** be actually called at runtime.
  8761. */
  8762. function defineExpose(exposed) {
  8763. {
  8764. warnRuntimeUsage(`defineExpose`);
  8765. }
  8766. }
  8767. /**
  8768. * Vue `<script setup>` compiler macro for providing props default values when
  8769. * using type-based `defineProps` declaration.
  8770. *
  8771. * Example usage:
  8772. * ```ts
  8773. * withDefaults(defineProps<{
  8774. * size?: number
  8775. * labels?: string[]
  8776. * }>(), {
  8777. * size: 3,
  8778. * labels: () => ['default label']
  8779. * })
  8780. * ```
  8781. *
  8782. * This is only usable inside `<script setup>`, is compiled away in the output
  8783. * and should **not** be actually called at runtime.
  8784. */
  8785. function withDefaults(props, defaults) {
  8786. {
  8787. warnRuntimeUsage(`withDefaults`);
  8788. }
  8789. return null;
  8790. }
  8791. function useSlots() {
  8792. return getContext().slots;
  8793. }
  8794. function useAttrs() {
  8795. return getContext().attrs;
  8796. }
  8797. function getContext() {
  8798. const i = getCurrentInstance();
  8799. if (!i) {
  8800. warn$1(`useContext() called without active instance.`);
  8801. }
  8802. return i.setupContext || (i.setupContext = createSetupContext(i));
  8803. }
  8804. /**
  8805. * Runtime helper for merging default declarations. Imported by compiled code
  8806. * only.
  8807. * @internal
  8808. */
  8809. function mergeDefaults(raw, defaults) {
  8810. const props = isArray(raw)
  8811. ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
  8812. : raw;
  8813. for (const key in defaults) {
  8814. const opt = props[key];
  8815. if (opt) {
  8816. if (isArray(opt) || isFunction(opt)) {
  8817. props[key] = { type: opt, default: defaults[key] };
  8818. }
  8819. else {
  8820. opt.default = defaults[key];
  8821. }
  8822. }
  8823. else if (opt === null) {
  8824. props[key] = { default: defaults[key] };
  8825. }
  8826. else {
  8827. warn$1(`props default key "${key}" has no corresponding declaration.`);
  8828. }
  8829. }
  8830. return props;
  8831. }
  8832. /**
  8833. * Used to create a proxy for the rest element when destructuring props with
  8834. * defineProps().
  8835. * @internal
  8836. */
  8837. function createPropsRestProxy(props, excludedKeys) {
  8838. const ret = {};
  8839. for (const key in props) {
  8840. if (!excludedKeys.includes(key)) {
  8841. Object.defineProperty(ret, key, {
  8842. enumerable: true,
  8843. get: () => props[key]
  8844. });
  8845. }
  8846. }
  8847. return ret;
  8848. }
  8849. /**
  8850. * `<script setup>` helper for persisting the current instance context over
  8851. * async/await flows.
  8852. *
  8853. * `@vue/compiler-sfc` converts the following:
  8854. *
  8855. * ```ts
  8856. * const x = await foo()
  8857. * ```
  8858. *
  8859. * into:
  8860. *
  8861. * ```ts
  8862. * let __temp, __restore
  8863. * const x = (([__temp, __restore] = withAsyncContext(() => foo())),__temp=await __temp,__restore(),__temp)
  8864. * ```
  8865. * @internal
  8866. */
  8867. function withAsyncContext(getAwaitable) {
  8868. const ctx = getCurrentInstance();
  8869. if (!ctx) {
  8870. warn$1(`withAsyncContext called without active current instance. ` +
  8871. `This is likely a bug.`);
  8872. }
  8873. let awaitable = getAwaitable();
  8874. unsetCurrentInstance();
  8875. if (isPromise(awaitable)) {
  8876. awaitable = awaitable.catch(e => {
  8877. setCurrentInstance(ctx);
  8878. throw e;
  8879. });
  8880. }
  8881. return [awaitable, () => setCurrentInstance(ctx)];
  8882. }
  8883. // Actual implementation
  8884. function h(type, propsOrChildren, children) {
  8885. const l = arguments.length;
  8886. if (l === 2) {
  8887. if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
  8888. // single vnode without props
  8889. if (isVNode(propsOrChildren)) {
  8890. return createVNode(type, null, [propsOrChildren]);
  8891. }
  8892. // props without children
  8893. return createVNode(type, propsOrChildren);
  8894. }
  8895. else {
  8896. // omit props
  8897. return createVNode(type, null, propsOrChildren);
  8898. }
  8899. }
  8900. else {
  8901. if (l > 3) {
  8902. children = Array.prototype.slice.call(arguments, 2);
  8903. }
  8904. else if (l === 3 && isVNode(children)) {
  8905. children = [children];
  8906. }
  8907. return createVNode(type, propsOrChildren, children);
  8908. }
  8909. }
  8910. const ssrContextKey = Symbol(`ssrContext` );
  8911. const useSSRContext = () => {
  8912. {
  8913. warn$1(`useSSRContext() is not supported in the global build.`);
  8914. }
  8915. };
  8916. function initCustomFormatter() {
  8917. /* eslint-disable no-restricted-globals */
  8918. if (typeof window === 'undefined') {
  8919. return;
  8920. }
  8921. const vueStyle = { style: 'color:#3ba776' };
  8922. const numberStyle = { style: 'color:#0b1bc9' };
  8923. const stringStyle = { style: 'color:#b62e24' };
  8924. const keywordStyle = { style: 'color:#9d288c' };
  8925. // custom formatter for Chrome
  8926. // https://www.mattzeunert.com/2016/02/19/custom-chrome-devtools-object-formatters.html
  8927. const formatter = {
  8928. header(obj) {
  8929. // TODO also format ComponentPublicInstance & ctx.slots/attrs in setup
  8930. if (!isObject(obj)) {
  8931. return null;
  8932. }
  8933. if (obj.__isVue) {
  8934. return ['div', vueStyle, `VueInstance`];
  8935. }
  8936. else if (isRef(obj)) {
  8937. return [
  8938. 'div',
  8939. {},
  8940. ['span', vueStyle, genRefFlag(obj)],
  8941. '<',
  8942. formatValue(obj.value),
  8943. `>`
  8944. ];
  8945. }
  8946. else if (isReactive(obj)) {
  8947. return [
  8948. 'div',
  8949. {},
  8950. ['span', vueStyle, isShallow(obj) ? 'ShallowReactive' : 'Reactive'],
  8951. '<',
  8952. formatValue(obj),
  8953. `>${isReadonly(obj) ? ` (readonly)` : ``}`
  8954. ];
  8955. }
  8956. else if (isReadonly(obj)) {
  8957. return [
  8958. 'div',
  8959. {},
  8960. ['span', vueStyle, isShallow(obj) ? 'ShallowReadonly' : 'Readonly'],
  8961. '<',
  8962. formatValue(obj),
  8963. '>'
  8964. ];
  8965. }
  8966. return null;
  8967. },
  8968. hasBody(obj) {
  8969. return obj && obj.__isVue;
  8970. },
  8971. body(obj) {
  8972. if (obj && obj.__isVue) {
  8973. return [
  8974. 'div',
  8975. {},
  8976. ...formatInstance(obj.$)
  8977. ];
  8978. }
  8979. }
  8980. };
  8981. function formatInstance(instance) {
  8982. const blocks = [];
  8983. if (instance.type.props && instance.props) {
  8984. blocks.push(createInstanceBlock('props', toRaw(instance.props)));
  8985. }
  8986. if (instance.setupState !== EMPTY_OBJ) {
  8987. blocks.push(createInstanceBlock('setup', instance.setupState));
  8988. }
  8989. if (instance.data !== EMPTY_OBJ) {
  8990. blocks.push(createInstanceBlock('data', toRaw(instance.data)));
  8991. }
  8992. const computed = extractKeys(instance, 'computed');
  8993. if (computed) {
  8994. blocks.push(createInstanceBlock('computed', computed));
  8995. }
  8996. const injected = extractKeys(instance, 'inject');
  8997. if (injected) {
  8998. blocks.push(createInstanceBlock('injected', injected));
  8999. }
  9000. blocks.push([
  9001. 'div',
  9002. {},
  9003. [
  9004. 'span',
  9005. {
  9006. style: keywordStyle.style + ';opacity:0.66'
  9007. },
  9008. '$ (internal): '
  9009. ],
  9010. ['object', { object: instance }]
  9011. ]);
  9012. return blocks;
  9013. }
  9014. function createInstanceBlock(type, target) {
  9015. target = extend({}, target);
  9016. if (!Object.keys(target).length) {
  9017. return ['span', {}];
  9018. }
  9019. return [
  9020. 'div',
  9021. { style: 'line-height:1.25em;margin-bottom:0.6em' },
  9022. [
  9023. 'div',
  9024. {
  9025. style: 'color:#476582'
  9026. },
  9027. type
  9028. ],
  9029. [
  9030. 'div',
  9031. {
  9032. style: 'padding-left:1.25em'
  9033. },
  9034. ...Object.keys(target).map(key => {
  9035. return [
  9036. 'div',
  9037. {},
  9038. ['span', keywordStyle, key + ': '],
  9039. formatValue(target[key], false)
  9040. ];
  9041. })
  9042. ]
  9043. ];
  9044. }
  9045. function formatValue(v, asRaw = true) {
  9046. if (typeof v === 'number') {
  9047. return ['span', numberStyle, v];
  9048. }
  9049. else if (typeof v === 'string') {
  9050. return ['span', stringStyle, JSON.stringify(v)];
  9051. }
  9052. else if (typeof v === 'boolean') {
  9053. return ['span', keywordStyle, v];
  9054. }
  9055. else if (isObject(v)) {
  9056. return ['object', { object: asRaw ? toRaw(v) : v }];
  9057. }
  9058. else {
  9059. return ['span', stringStyle, String(v)];
  9060. }
  9061. }
  9062. function extractKeys(instance, type) {
  9063. const Comp = instance.type;
  9064. if (isFunction(Comp)) {
  9065. return;
  9066. }
  9067. const extracted = {};
  9068. for (const key in instance.ctx) {
  9069. if (isKeyOfType(Comp, key, type)) {
  9070. extracted[key] = instance.ctx[key];
  9071. }
  9072. }
  9073. return extracted;
  9074. }
  9075. function isKeyOfType(Comp, key, type) {
  9076. const opts = Comp[type];
  9077. if ((isArray(opts) && opts.includes(key)) ||
  9078. (isObject(opts) && key in opts)) {
  9079. return true;
  9080. }
  9081. if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
  9082. return true;
  9083. }
  9084. if (Comp.mixins && Comp.mixins.some(m => isKeyOfType(m, key, type))) {
  9085. return true;
  9086. }
  9087. }
  9088. function genRefFlag(v) {
  9089. if (isShallow(v)) {
  9090. return `ShallowRef`;
  9091. }
  9092. if (v.effect) {
  9093. return `ComputedRef`;
  9094. }
  9095. return `Ref`;
  9096. }
  9097. if (window.devtoolsFormatters) {
  9098. window.devtoolsFormatters.push(formatter);
  9099. }
  9100. else {
  9101. window.devtoolsFormatters = [formatter];
  9102. }
  9103. }
  9104. function withMemo(memo, render, cache, index) {
  9105. const cached = cache[index];
  9106. if (cached && isMemoSame(cached, memo)) {
  9107. return cached;
  9108. }
  9109. const ret = render();
  9110. // shallow clone
  9111. ret.memo = memo.slice();
  9112. return (cache[index] = ret);
  9113. }
  9114. function isMemoSame(cached, memo) {
  9115. const prev = cached.memo;
  9116. if (prev.length != memo.length) {
  9117. return false;
  9118. }
  9119. for (let i = 0; i < prev.length; i++) {
  9120. if (hasChanged(prev[i], memo[i])) {
  9121. return false;
  9122. }
  9123. }
  9124. // make sure to let parent block track it when returning cached
  9125. if (isBlockTreeEnabled > 0 && currentBlock) {
  9126. currentBlock.push(cached);
  9127. }
  9128. return true;
  9129. }
  9130. // Core API ------------------------------------------------------------------
  9131. const version = "3.2.37";
  9132. /**
  9133. * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
  9134. * @internal
  9135. */
  9136. const ssrUtils = (null);
  9137. /**
  9138. * @internal only exposed in compat builds
  9139. */
  9140. const resolveFilter = null;
  9141. /**
  9142. * @internal only exposed in compat builds.
  9143. */
  9144. const compatUtils = (null);
  9145. const svgNS = 'http://www.w3.org/2000/svg';
  9146. const doc = (typeof document !== 'undefined' ? document : null);
  9147. const templateContainer = doc && /*#__PURE__*/ doc.createElement('template');
  9148. const nodeOps = {
  9149. insert: (child, parent, anchor) => {
  9150. parent.insertBefore(child, anchor || null);
  9151. },
  9152. remove: child => {
  9153. const parent = child.parentNode;
  9154. if (parent) {
  9155. parent.removeChild(child);
  9156. }
  9157. },
  9158. createElement: (tag, isSVG, is, props) => {
  9159. const el = isSVG
  9160. ? doc.createElementNS(svgNS, tag)
  9161. : doc.createElement(tag, is ? { is } : undefined);
  9162. if (tag === 'select' && props && props.multiple != null) {
  9163. el.setAttribute('multiple', props.multiple);
  9164. }
  9165. return el;
  9166. },
  9167. createText: text => doc.createTextNode(text),
  9168. createComment: text => doc.createComment(text),
  9169. setText: (node, text) => {
  9170. node.nodeValue = text;
  9171. },
  9172. setElementText: (el, text) => {
  9173. el.textContent = text;
  9174. },
  9175. parentNode: node => node.parentNode,
  9176. nextSibling: node => node.nextSibling,
  9177. querySelector: selector => doc.querySelector(selector),
  9178. setScopeId(el, id) {
  9179. el.setAttribute(id, '');
  9180. },
  9181. cloneNode(el) {
  9182. const cloned = el.cloneNode(true);
  9183. // #3072
  9184. // - in `patchDOMProp`, we store the actual value in the `el._value` property.
  9185. // - normally, elements using `:value` bindings will not be hoisted, but if
  9186. // the bound value is a constant, e.g. `:value="true"` - they do get
  9187. // hoisted.
  9188. // - in production, hoisted nodes are cloned when subsequent inserts, but
  9189. // cloneNode() does not copy the custom property we attached.
  9190. // - This may need to account for other custom DOM properties we attach to
  9191. // elements in addition to `_value` in the future.
  9192. if (`_value` in el) {
  9193. cloned._value = el._value;
  9194. }
  9195. return cloned;
  9196. },
  9197. // __UNSAFE__
  9198. // Reason: innerHTML.
  9199. // Static content here can only come from compiled templates.
  9200. // As long as the user only uses trusted templates, this is safe.
  9201. insertStaticContent(content, parent, anchor, isSVG, start, end) {
  9202. // <parent> before | first ... last | anchor </parent>
  9203. const before = anchor ? anchor.previousSibling : parent.lastChild;
  9204. // #5308 can only take cached path if:
  9205. // - has a single root node
  9206. // - nextSibling info is still available
  9207. if (start && (start === end || start.nextSibling)) {
  9208. // cached
  9209. while (true) {
  9210. parent.insertBefore(start.cloneNode(true), anchor);
  9211. if (start === end || !(start = start.nextSibling))
  9212. break;
  9213. }
  9214. }
  9215. else {
  9216. // fresh insert
  9217. templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
  9218. const template = templateContainer.content;
  9219. if (isSVG) {
  9220. // remove outer svg wrapper
  9221. const wrapper = template.firstChild;
  9222. while (wrapper.firstChild) {
  9223. template.appendChild(wrapper.firstChild);
  9224. }
  9225. template.removeChild(wrapper);
  9226. }
  9227. parent.insertBefore(template, anchor);
  9228. }
  9229. return [
  9230. // first
  9231. before ? before.nextSibling : parent.firstChild,
  9232. // last
  9233. anchor ? anchor.previousSibling : parent.lastChild
  9234. ];
  9235. }
  9236. };
  9237. // compiler should normalize class + :class bindings on the same element
  9238. // into a single binding ['staticClass', dynamic]
  9239. function patchClass(el, value, isSVG) {
  9240. // directly setting className should be faster than setAttribute in theory
  9241. // if this is an element during a transition, take the temporary transition
  9242. // classes into account.
  9243. const transitionClasses = el._vtc;
  9244. if (transitionClasses) {
  9245. value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');
  9246. }
  9247. if (value == null) {
  9248. el.removeAttribute('class');
  9249. }
  9250. else if (isSVG) {
  9251. el.setAttribute('class', value);
  9252. }
  9253. else {
  9254. el.className = value;
  9255. }
  9256. }
  9257. function patchStyle(el, prev, next) {
  9258. const style = el.style;
  9259. const isCssString = isString(next);
  9260. if (next && !isCssString) {
  9261. for (const key in next) {
  9262. setStyle(style, key, next[key]);
  9263. }
  9264. if (prev && !isString(prev)) {
  9265. for (const key in prev) {
  9266. if (next[key] == null) {
  9267. setStyle(style, key, '');
  9268. }
  9269. }
  9270. }
  9271. }
  9272. else {
  9273. const currentDisplay = style.display;
  9274. if (isCssString) {
  9275. if (prev !== next) {
  9276. style.cssText = next;
  9277. }
  9278. }
  9279. else if (prev) {
  9280. el.removeAttribute('style');
  9281. }
  9282. // indicates that the `display` of the element is controlled by `v-show`,
  9283. // so we always keep the current `display` value regardless of the `style`
  9284. // value, thus handing over control to `v-show`.
  9285. if ('_vod' in el) {
  9286. style.display = currentDisplay;
  9287. }
  9288. }
  9289. }
  9290. const importantRE = /\s*!important$/;
  9291. function setStyle(style, name, val) {
  9292. if (isArray(val)) {
  9293. val.forEach(v => setStyle(style, name, v));
  9294. }
  9295. else {
  9296. if (val == null)
  9297. val = '';
  9298. if (name.startsWith('--')) {
  9299. // custom property definition
  9300. style.setProperty(name, val);
  9301. }
  9302. else {
  9303. const prefixed = autoPrefix(style, name);
  9304. if (importantRE.test(val)) {
  9305. // !important
  9306. style.setProperty(hyphenate(prefixed), val.replace(importantRE, ''), 'important');
  9307. }
  9308. else {
  9309. style[prefixed] = val;
  9310. }
  9311. }
  9312. }
  9313. }
  9314. const prefixes = ['Webkit', 'Moz', 'ms'];
  9315. const prefixCache = {};
  9316. function autoPrefix(style, rawName) {
  9317. const cached = prefixCache[rawName];
  9318. if (cached) {
  9319. return cached;
  9320. }
  9321. let name = camelize(rawName);
  9322. if (name !== 'filter' && name in style) {
  9323. return (prefixCache[rawName] = name);
  9324. }
  9325. name = capitalize(name);
  9326. for (let i = 0; i < prefixes.length; i++) {
  9327. const prefixed = prefixes[i] + name;
  9328. if (prefixed in style) {
  9329. return (prefixCache[rawName] = prefixed);
  9330. }
  9331. }
  9332. return rawName;
  9333. }
  9334. const xlinkNS = 'http://www.w3.org/1999/xlink';
  9335. function patchAttr(el, key, value, isSVG, instance) {
  9336. if (isSVG && key.startsWith('xlink:')) {
  9337. if (value == null) {
  9338. el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
  9339. }
  9340. else {
  9341. el.setAttributeNS(xlinkNS, key, value);
  9342. }
  9343. }
  9344. else {
  9345. // note we are only checking boolean attributes that don't have a
  9346. // corresponding dom prop of the same name here.
  9347. const isBoolean = isSpecialBooleanAttr(key);
  9348. if (value == null || (isBoolean && !includeBooleanAttr(value))) {
  9349. el.removeAttribute(key);
  9350. }
  9351. else {
  9352. el.setAttribute(key, isBoolean ? '' : value);
  9353. }
  9354. }
  9355. }
  9356. // __UNSAFE__
  9357. // functions. The user is responsible for using them with only trusted content.
  9358. function patchDOMProp(el, key, value,
  9359. // the following args are passed only due to potential innerHTML/textContent
  9360. // overriding existing VNodes, in which case the old tree must be properly
  9361. // unmounted.
  9362. prevChildren, parentComponent, parentSuspense, unmountChildren) {
  9363. if (key === 'innerHTML' || key === 'textContent') {
  9364. if (prevChildren) {
  9365. unmountChildren(prevChildren, parentComponent, parentSuspense);
  9366. }
  9367. el[key] = value == null ? '' : value;
  9368. return;
  9369. }
  9370. if (key === 'value' &&
  9371. el.tagName !== 'PROGRESS' &&
  9372. // custom elements may use _value internally
  9373. !el.tagName.includes('-')) {
  9374. // store value as _value as well since
  9375. // non-string values will be stringified.
  9376. el._value = value;
  9377. const newValue = value == null ? '' : value;
  9378. if (el.value !== newValue ||
  9379. // #4956: always set for OPTION elements because its value falls back to
  9380. // textContent if no value attribute is present. And setting .value for
  9381. // OPTION has no side effect
  9382. el.tagName === 'OPTION') {
  9383. el.value = newValue;
  9384. }
  9385. if (value == null) {
  9386. el.removeAttribute(key);
  9387. }
  9388. return;
  9389. }
  9390. let needRemove = false;
  9391. if (value === '' || value == null) {
  9392. const type = typeof el[key];
  9393. if (type === 'boolean') {
  9394. // e.g. <select multiple> compiles to { multiple: '' }
  9395. value = includeBooleanAttr(value);
  9396. }
  9397. else if (value == null && type === 'string') {
  9398. // e.g. <div :id="null">
  9399. value = '';
  9400. needRemove = true;
  9401. }
  9402. else if (type === 'number') {
  9403. // e.g. <img :width="null">
  9404. // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
  9405. value = 0;
  9406. needRemove = true;
  9407. }
  9408. }
  9409. // some properties perform value validation and throw,
  9410. // some properties has getter, no setter, will error in 'use strict'
  9411. // eg. <select :type="null"></select> <select :willValidate="null"></select>
  9412. try {
  9413. el[key] = value;
  9414. }
  9415. catch (e) {
  9416. {
  9417. warn$1(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
  9418. `value ${value} is invalid.`, e);
  9419. }
  9420. }
  9421. needRemove && el.removeAttribute(key);
  9422. }
  9423. // Async edge case fix requires storing an event listener's attach timestamp.
  9424. const [_getNow, skipTimestampCheck] = /*#__PURE__*/ (() => {
  9425. let _getNow = Date.now;
  9426. let skipTimestampCheck = false;
  9427. if (typeof window !== 'undefined') {
  9428. // Determine what event timestamp the browser is using. Annoyingly, the
  9429. // timestamp can either be hi-res (relative to page load) or low-res
  9430. // (relative to UNIX epoch), so in order to compare time we have to use the
  9431. // same timestamp type when saving the flush timestamp.
  9432. if (Date.now() > document.createEvent('Event').timeStamp) {
  9433. // if the low-res timestamp which is bigger than the event timestamp
  9434. // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
  9435. // and we need to use the hi-res version for event listeners as well.
  9436. _getNow = performance.now.bind(performance);
  9437. }
  9438. // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
  9439. // and does not fire microtasks in between event propagation, so safe to exclude.
  9440. const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
  9441. skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
  9442. }
  9443. return [_getNow, skipTimestampCheck];
  9444. })();
  9445. // To avoid the overhead of repeatedly calling performance.now(), we cache
  9446. // and use the same timestamp for all event listeners attached in the same tick.
  9447. let cachedNow = 0;
  9448. const p = /*#__PURE__*/ Promise.resolve();
  9449. const reset = () => {
  9450. cachedNow = 0;
  9451. };
  9452. const getNow = () => cachedNow || (p.then(reset), (cachedNow = _getNow()));
  9453. function addEventListener(el, event, handler, options) {
  9454. el.addEventListener(event, handler, options);
  9455. }
  9456. function removeEventListener(el, event, handler, options) {
  9457. el.removeEventListener(event, handler, options);
  9458. }
  9459. function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
  9460. // vei = vue event invokers
  9461. const invokers = el._vei || (el._vei = {});
  9462. const existingInvoker = invokers[rawName];
  9463. if (nextValue && existingInvoker) {
  9464. // patch
  9465. existingInvoker.value = nextValue;
  9466. }
  9467. else {
  9468. const [name, options] = parseName(rawName);
  9469. if (nextValue) {
  9470. // add
  9471. const invoker = (invokers[rawName] = createInvoker(nextValue, instance));
  9472. addEventListener(el, name, invoker, options);
  9473. }
  9474. else if (existingInvoker) {
  9475. // remove
  9476. removeEventListener(el, name, existingInvoker, options);
  9477. invokers[rawName] = undefined;
  9478. }
  9479. }
  9480. }
  9481. const optionsModifierRE = /(?:Once|Passive|Capture)$/;
  9482. function parseName(name) {
  9483. let options;
  9484. if (optionsModifierRE.test(name)) {
  9485. options = {};
  9486. let m;
  9487. while ((m = name.match(optionsModifierRE))) {
  9488. name = name.slice(0, name.length - m[0].length);
  9489. options[m[0].toLowerCase()] = true;
  9490. }
  9491. }
  9492. return [hyphenate(name.slice(2)), options];
  9493. }
  9494. function createInvoker(initialValue, instance) {
  9495. const invoker = (e) => {
  9496. // async edge case #6566: inner click event triggers patch, event handler
  9497. // attached to outer element during patch, and triggered again. This
  9498. // happens because browsers fire microtask ticks between event propagation.
  9499. // the solution is simple: we save the timestamp when a handler is attached,
  9500. // and the handler would only fire if the event passed to it was fired
  9501. // AFTER it was attached.
  9502. const timeStamp = e.timeStamp || _getNow();
  9503. if (skipTimestampCheck || timeStamp >= invoker.attached - 1) {
  9504. callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 /* NATIVE_EVENT_HANDLER */, [e]);
  9505. }
  9506. };
  9507. invoker.value = initialValue;
  9508. invoker.attached = getNow();
  9509. return invoker;
  9510. }
  9511. function patchStopImmediatePropagation(e, value) {
  9512. if (isArray(value)) {
  9513. const originalStop = e.stopImmediatePropagation;
  9514. e.stopImmediatePropagation = () => {
  9515. originalStop.call(e);
  9516. e._stopped = true;
  9517. };
  9518. return value.map(fn => (e) => !e._stopped && fn && fn(e));
  9519. }
  9520. else {
  9521. return value;
  9522. }
  9523. }
  9524. const nativeOnRE = /^on[a-z]/;
  9525. const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
  9526. if (key === 'class') {
  9527. patchClass(el, nextValue, isSVG);
  9528. }
  9529. else if (key === 'style') {
  9530. patchStyle(el, prevValue, nextValue);
  9531. }
  9532. else if (isOn(key)) {
  9533. // ignore v-model listeners
  9534. if (!isModelListener(key)) {
  9535. patchEvent(el, key, prevValue, nextValue, parentComponent);
  9536. }
  9537. }
  9538. else if (key[0] === '.'
  9539. ? ((key = key.slice(1)), true)
  9540. : key[0] === '^'
  9541. ? ((key = key.slice(1)), false)
  9542. : shouldSetAsProp(el, key, nextValue, isSVG)) {
  9543. patchDOMProp(el, key, nextValue, prevChildren, parentComponent, parentSuspense, unmountChildren);
  9544. }
  9545. else {
  9546. // special case for <input v-model type="checkbox"> with
  9547. // :true-value & :false-value
  9548. // store value as dom properties since non-string values will be
  9549. // stringified.
  9550. if (key === 'true-value') {
  9551. el._trueValue = nextValue;
  9552. }
  9553. else if (key === 'false-value') {
  9554. el._falseValue = nextValue;
  9555. }
  9556. patchAttr(el, key, nextValue, isSVG);
  9557. }
  9558. };
  9559. function shouldSetAsProp(el, key, value, isSVG) {
  9560. if (isSVG) {
  9561. // most keys must be set as attribute on svg elements to work
  9562. // ...except innerHTML & textContent
  9563. if (key === 'innerHTML' || key === 'textContent') {
  9564. return true;
  9565. }
  9566. // or native onclick with function values
  9567. if (key in el && nativeOnRE.test(key) && isFunction(value)) {
  9568. return true;
  9569. }
  9570. return false;
  9571. }
  9572. // these are enumerated attrs, however their corresponding DOM properties
  9573. // are actually booleans - this leads to setting it with a string "false"
  9574. // value leading it to be coerced to `true`, so we need to always treat
  9575. // them as attributes.
  9576. // Note that `contentEditable` doesn't have this problem: its DOM
  9577. // property is also enumerated string values.
  9578. if (key === 'spellcheck' || key === 'draggable' || key === 'translate') {
  9579. return false;
  9580. }
  9581. // #1787, #2840 form property on form elements is readonly and must be set as
  9582. // attribute.
  9583. if (key === 'form') {
  9584. return false;
  9585. }
  9586. // #1526 <input list> must be set as attribute
  9587. if (key === 'list' && el.tagName === 'INPUT') {
  9588. return false;
  9589. }
  9590. // #2766 <textarea type> must be set as attribute
  9591. if (key === 'type' && el.tagName === 'TEXTAREA') {
  9592. return false;
  9593. }
  9594. // native onclick with string value, must be set as attribute
  9595. if (nativeOnRE.test(key) && isString(value)) {
  9596. return false;
  9597. }
  9598. return key in el;
  9599. }
  9600. function defineCustomElement(options, hydrate) {
  9601. const Comp = defineComponent(options);
  9602. class VueCustomElement extends VueElement {
  9603. constructor(initialProps) {
  9604. super(Comp, initialProps, hydrate);
  9605. }
  9606. }
  9607. VueCustomElement.def = Comp;
  9608. return VueCustomElement;
  9609. }
  9610. const defineSSRCustomElement = ((options) => {
  9611. // @ts-ignore
  9612. return defineCustomElement(options, hydrate);
  9613. });
  9614. const BaseClass = (typeof HTMLElement !== 'undefined' ? HTMLElement : class {
  9615. });
  9616. class VueElement extends BaseClass {
  9617. constructor(_def, _props = {}, hydrate) {
  9618. super();
  9619. this._def = _def;
  9620. this._props = _props;
  9621. /**
  9622. * @internal
  9623. */
  9624. this._instance = null;
  9625. this._connected = false;
  9626. this._resolved = false;
  9627. this._numberProps = null;
  9628. if (this.shadowRoot && hydrate) {
  9629. hydrate(this._createVNode(), this.shadowRoot);
  9630. }
  9631. else {
  9632. if (this.shadowRoot) {
  9633. warn$1(`Custom element has pre-rendered declarative shadow root but is not ` +
  9634. `defined as hydratable. Use \`defineSSRCustomElement\`.`);
  9635. }
  9636. this.attachShadow({ mode: 'open' });
  9637. }
  9638. }
  9639. connectedCallback() {
  9640. this._connected = true;
  9641. if (!this._instance) {
  9642. this._resolveDef();
  9643. }
  9644. }
  9645. disconnectedCallback() {
  9646. this._connected = false;
  9647. nextTick(() => {
  9648. if (!this._connected) {
  9649. render(null, this.shadowRoot);
  9650. this._instance = null;
  9651. }
  9652. });
  9653. }
  9654. /**
  9655. * resolve inner component definition (handle possible async component)
  9656. */
  9657. _resolveDef() {
  9658. if (this._resolved) {
  9659. return;
  9660. }
  9661. this._resolved = true;
  9662. // set initial attrs
  9663. for (let i = 0; i < this.attributes.length; i++) {
  9664. this._setAttr(this.attributes[i].name);
  9665. }
  9666. // watch future attr changes
  9667. new MutationObserver(mutations => {
  9668. for (const m of mutations) {
  9669. this._setAttr(m.attributeName);
  9670. }
  9671. }).observe(this, { attributes: true });
  9672. const resolve = (def) => {
  9673. const { props, styles } = def;
  9674. const hasOptions = !isArray(props);
  9675. const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
  9676. // cast Number-type props set before resolve
  9677. let numberProps;
  9678. if (hasOptions) {
  9679. for (const key in this._props) {
  9680. const opt = props[key];
  9681. if (opt === Number || (opt && opt.type === Number)) {
  9682. this._props[key] = toNumber(this._props[key]);
  9683. (numberProps || (numberProps = Object.create(null)))[key] = true;
  9684. }
  9685. }
  9686. }
  9687. this._numberProps = numberProps;
  9688. // check if there are props set pre-upgrade or connect
  9689. for (const key of Object.keys(this)) {
  9690. if (key[0] !== '_') {
  9691. this._setProp(key, this[key], true, false);
  9692. }
  9693. }
  9694. // defining getter/setters on prototype
  9695. for (const key of rawKeys.map(camelize)) {
  9696. Object.defineProperty(this, key, {
  9697. get() {
  9698. return this._getProp(key);
  9699. },
  9700. set(val) {
  9701. this._setProp(key, val);
  9702. }
  9703. });
  9704. }
  9705. // apply CSS
  9706. this._applyStyles(styles);
  9707. // initial render
  9708. this._update();
  9709. };
  9710. const asyncDef = this._def.__asyncLoader;
  9711. if (asyncDef) {
  9712. asyncDef().then(resolve);
  9713. }
  9714. else {
  9715. resolve(this._def);
  9716. }
  9717. }
  9718. _setAttr(key) {
  9719. let value = this.getAttribute(key);
  9720. if (this._numberProps && this._numberProps[key]) {
  9721. value = toNumber(value);
  9722. }
  9723. this._setProp(camelize(key), value, false);
  9724. }
  9725. /**
  9726. * @internal
  9727. */
  9728. _getProp(key) {
  9729. return this._props[key];
  9730. }
  9731. /**
  9732. * @internal
  9733. */
  9734. _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
  9735. if (val !== this._props[key]) {
  9736. this._props[key] = val;
  9737. if (shouldUpdate && this._instance) {
  9738. this._update();
  9739. }
  9740. // reflect
  9741. if (shouldReflect) {
  9742. if (val === true) {
  9743. this.setAttribute(hyphenate(key), '');
  9744. }
  9745. else if (typeof val === 'string' || typeof val === 'number') {
  9746. this.setAttribute(hyphenate(key), val + '');
  9747. }
  9748. else if (!val) {
  9749. this.removeAttribute(hyphenate(key));
  9750. }
  9751. }
  9752. }
  9753. }
  9754. _update() {
  9755. render(this._createVNode(), this.shadowRoot);
  9756. }
  9757. _createVNode() {
  9758. const vnode = createVNode(this._def, extend({}, this._props));
  9759. if (!this._instance) {
  9760. vnode.ce = instance => {
  9761. this._instance = instance;
  9762. instance.isCE = true;
  9763. // HMR
  9764. {
  9765. instance.ceReload = newStyles => {
  9766. // always reset styles
  9767. if (this._styles) {
  9768. this._styles.forEach(s => this.shadowRoot.removeChild(s));
  9769. this._styles.length = 0;
  9770. }
  9771. this._applyStyles(newStyles);
  9772. // if this is an async component, ceReload is called from the inner
  9773. // component so no need to reload the async wrapper
  9774. if (!this._def.__asyncLoader) {
  9775. // reload
  9776. this._instance = null;
  9777. this._update();
  9778. }
  9779. };
  9780. }
  9781. // intercept emit
  9782. instance.emit = (event, ...args) => {
  9783. this.dispatchEvent(new CustomEvent(event, {
  9784. detail: args
  9785. }));
  9786. };
  9787. // locate nearest Vue custom element parent for provide/inject
  9788. let parent = this;
  9789. while ((parent =
  9790. parent && (parent.parentNode || parent.host))) {
  9791. if (parent instanceof VueElement) {
  9792. instance.parent = parent._instance;
  9793. break;
  9794. }
  9795. }
  9796. };
  9797. }
  9798. return vnode;
  9799. }
  9800. _applyStyles(styles) {
  9801. if (styles) {
  9802. styles.forEach(css => {
  9803. const s = document.createElement('style');
  9804. s.textContent = css;
  9805. this.shadowRoot.appendChild(s);
  9806. // record for HMR
  9807. {
  9808. (this._styles || (this._styles = [])).push(s);
  9809. }
  9810. });
  9811. }
  9812. }
  9813. }
  9814. function useCssModule(name = '$style') {
  9815. /* istanbul ignore else */
  9816. {
  9817. {
  9818. warn$1(`useCssModule() is not supported in the global build.`);
  9819. }
  9820. return EMPTY_OBJ;
  9821. }
  9822. }
  9823. /**
  9824. * Runtime helper for SFC's CSS variable injection feature.
  9825. * @private
  9826. */
  9827. function useCssVars(getter) {
  9828. const instance = getCurrentInstance();
  9829. /* istanbul ignore next */
  9830. if (!instance) {
  9831. warn$1(`useCssVars is called without current active component instance.`);
  9832. return;
  9833. }
  9834. const setVars = () => setVarsOnVNode(instance.subTree, getter(instance.proxy));
  9835. watchPostEffect(setVars);
  9836. onMounted(() => {
  9837. const ob = new MutationObserver(setVars);
  9838. ob.observe(instance.subTree.el.parentNode, { childList: true });
  9839. onUnmounted(() => ob.disconnect());
  9840. });
  9841. }
  9842. function setVarsOnVNode(vnode, vars) {
  9843. if (vnode.shapeFlag & 128 /* SUSPENSE */) {
  9844. const suspense = vnode.suspense;
  9845. vnode = suspense.activeBranch;
  9846. if (suspense.pendingBranch && !suspense.isHydrating) {
  9847. suspense.effects.push(() => {
  9848. setVarsOnVNode(suspense.activeBranch, vars);
  9849. });
  9850. }
  9851. }
  9852. // drill down HOCs until it's a non-component vnode
  9853. while (vnode.component) {
  9854. vnode = vnode.component.subTree;
  9855. }
  9856. if (vnode.shapeFlag & 1 /* ELEMENT */ && vnode.el) {
  9857. setVarsOnNode(vnode.el, vars);
  9858. }
  9859. else if (vnode.type === Fragment) {
  9860. vnode.children.forEach(c => setVarsOnVNode(c, vars));
  9861. }
  9862. else if (vnode.type === Static) {
  9863. let { el, anchor } = vnode;
  9864. while (el) {
  9865. setVarsOnNode(el, vars);
  9866. if (el === anchor)
  9867. break;
  9868. el = el.nextSibling;
  9869. }
  9870. }
  9871. }
  9872. function setVarsOnNode(el, vars) {
  9873. if (el.nodeType === 1) {
  9874. const style = el.style;
  9875. for (const key in vars) {
  9876. style.setProperty(`--${key}`, vars[key]);
  9877. }
  9878. }
  9879. }
  9880. const TRANSITION = 'transition';
  9881. const ANIMATION = 'animation';
  9882. // DOM Transition is a higher-order-component based on the platform-agnostic
  9883. // base Transition component, with DOM-specific logic.
  9884. const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
  9885. Transition.displayName = 'Transition';
  9886. const DOMTransitionPropsValidators = {
  9887. name: String,
  9888. type: String,
  9889. css: {
  9890. type: Boolean,
  9891. default: true
  9892. },
  9893. duration: [String, Number, Object],
  9894. enterFromClass: String,
  9895. enterActiveClass: String,
  9896. enterToClass: String,
  9897. appearFromClass: String,
  9898. appearActiveClass: String,
  9899. appearToClass: String,
  9900. leaveFromClass: String,
  9901. leaveActiveClass: String,
  9902. leaveToClass: String
  9903. };
  9904. const TransitionPropsValidators = (Transition.props =
  9905. /*#__PURE__*/ extend({}, BaseTransition.props, DOMTransitionPropsValidators));
  9906. /**
  9907. * #3227 Incoming hooks may be merged into arrays when wrapping Transition
  9908. * with custom HOCs.
  9909. */
  9910. const callHook$1 = (hook, args = []) => {
  9911. if (isArray(hook)) {
  9912. hook.forEach(h => h(...args));
  9913. }
  9914. else if (hook) {
  9915. hook(...args);
  9916. }
  9917. };
  9918. /**
  9919. * Check if a hook expects a callback (2nd arg), which means the user
  9920. * intends to explicitly control the end of the transition.
  9921. */
  9922. const hasExplicitCallback = (hook) => {
  9923. return hook
  9924. ? isArray(hook)
  9925. ? hook.some(h => h.length > 1)
  9926. : hook.length > 1
  9927. : false;
  9928. };
  9929. function resolveTransitionProps(rawProps) {
  9930. const baseProps = {};
  9931. for (const key in rawProps) {
  9932. if (!(key in DOMTransitionPropsValidators)) {
  9933. baseProps[key] = rawProps[key];
  9934. }
  9935. }
  9936. if (rawProps.css === false) {
  9937. return baseProps;
  9938. }
  9939. const { name = 'v', type, duration, enterFromClass = `${name}-enter-from`, enterActiveClass = `${name}-enter-active`, enterToClass = `${name}-enter-to`, appearFromClass = enterFromClass, appearActiveClass = enterActiveClass, appearToClass = enterToClass, leaveFromClass = `${name}-leave-from`, leaveActiveClass = `${name}-leave-active`, leaveToClass = `${name}-leave-to` } = rawProps;
  9940. const durations = normalizeDuration(duration);
  9941. const enterDuration = durations && durations[0];
  9942. const leaveDuration = durations && durations[1];
  9943. const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps;
  9944. const finishEnter = (el, isAppear, done) => {
  9945. removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
  9946. removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
  9947. done && done();
  9948. };
  9949. const finishLeave = (el, done) => {
  9950. el._isLeaving = false;
  9951. removeTransitionClass(el, leaveFromClass);
  9952. removeTransitionClass(el, leaveToClass);
  9953. removeTransitionClass(el, leaveActiveClass);
  9954. done && done();
  9955. };
  9956. const makeEnterHook = (isAppear) => {
  9957. return (el, done) => {
  9958. const hook = isAppear ? onAppear : onEnter;
  9959. const resolve = () => finishEnter(el, isAppear, done);
  9960. callHook$1(hook, [el, resolve]);
  9961. nextFrame(() => {
  9962. removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
  9963. addTransitionClass(el, isAppear ? appearToClass : enterToClass);
  9964. if (!hasExplicitCallback(hook)) {
  9965. whenTransitionEnds(el, type, enterDuration, resolve);
  9966. }
  9967. });
  9968. };
  9969. };
  9970. return extend(baseProps, {
  9971. onBeforeEnter(el) {
  9972. callHook$1(onBeforeEnter, [el]);
  9973. addTransitionClass(el, enterFromClass);
  9974. addTransitionClass(el, enterActiveClass);
  9975. },
  9976. onBeforeAppear(el) {
  9977. callHook$1(onBeforeAppear, [el]);
  9978. addTransitionClass(el, appearFromClass);
  9979. addTransitionClass(el, appearActiveClass);
  9980. },
  9981. onEnter: makeEnterHook(false),
  9982. onAppear: makeEnterHook(true),
  9983. onLeave(el, done) {
  9984. el._isLeaving = true;
  9985. const resolve = () => finishLeave(el, done);
  9986. addTransitionClass(el, leaveFromClass);
  9987. // force reflow so *-leave-from classes immediately take effect (#2593)
  9988. forceReflow();
  9989. addTransitionClass(el, leaveActiveClass);
  9990. nextFrame(() => {
  9991. if (!el._isLeaving) {
  9992. // cancelled
  9993. return;
  9994. }
  9995. removeTransitionClass(el, leaveFromClass);
  9996. addTransitionClass(el, leaveToClass);
  9997. if (!hasExplicitCallback(onLeave)) {
  9998. whenTransitionEnds(el, type, leaveDuration, resolve);
  9999. }
  10000. });
  10001. callHook$1(onLeave, [el, resolve]);
  10002. },
  10003. onEnterCancelled(el) {
  10004. finishEnter(el, false);
  10005. callHook$1(onEnterCancelled, [el]);
  10006. },
  10007. onAppearCancelled(el) {
  10008. finishEnter(el, true);
  10009. callHook$1(onAppearCancelled, [el]);
  10010. },
  10011. onLeaveCancelled(el) {
  10012. finishLeave(el);
  10013. callHook$1(onLeaveCancelled, [el]);
  10014. }
  10015. });
  10016. }
  10017. function normalizeDuration(duration) {
  10018. if (duration == null) {
  10019. return null;
  10020. }
  10021. else if (isObject(duration)) {
  10022. return [NumberOf(duration.enter), NumberOf(duration.leave)];
  10023. }
  10024. else {
  10025. const n = NumberOf(duration);
  10026. return [n, n];
  10027. }
  10028. }
  10029. function NumberOf(val) {
  10030. const res = toNumber(val);
  10031. validateDuration(res);
  10032. return res;
  10033. }
  10034. function validateDuration(val) {
  10035. if (typeof val !== 'number') {
  10036. warn$1(`<transition> explicit duration is not a valid number - ` +
  10037. `got ${JSON.stringify(val)}.`);
  10038. }
  10039. else if (isNaN(val)) {
  10040. warn$1(`<transition> explicit duration is NaN - ` +
  10041. 'the duration expression might be incorrect.');
  10042. }
  10043. }
  10044. function addTransitionClass(el, cls) {
  10045. cls.split(/\s+/).forEach(c => c && el.classList.add(c));
  10046. (el._vtc ||
  10047. (el._vtc = new Set())).add(cls);
  10048. }
  10049. function removeTransitionClass(el, cls) {
  10050. cls.split(/\s+/).forEach(c => c && el.classList.remove(c));
  10051. const { _vtc } = el;
  10052. if (_vtc) {
  10053. _vtc.delete(cls);
  10054. if (!_vtc.size) {
  10055. el._vtc = undefined;
  10056. }
  10057. }
  10058. }
  10059. function nextFrame(cb) {
  10060. requestAnimationFrame(() => {
  10061. requestAnimationFrame(cb);
  10062. });
  10063. }
  10064. let endId = 0;
  10065. function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
  10066. const id = (el._endId = ++endId);
  10067. const resolveIfNotStale = () => {
  10068. if (id === el._endId) {
  10069. resolve();
  10070. }
  10071. };
  10072. if (explicitTimeout) {
  10073. return setTimeout(resolveIfNotStale, explicitTimeout);
  10074. }
  10075. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  10076. if (!type) {
  10077. return resolve();
  10078. }
  10079. const endEvent = type + 'end';
  10080. let ended = 0;
  10081. const end = () => {
  10082. el.removeEventListener(endEvent, onEnd);
  10083. resolveIfNotStale();
  10084. };
  10085. const onEnd = (e) => {
  10086. if (e.target === el && ++ended >= propCount) {
  10087. end();
  10088. }
  10089. };
  10090. setTimeout(() => {
  10091. if (ended < propCount) {
  10092. end();
  10093. }
  10094. }, timeout + 1);
  10095. el.addEventListener(endEvent, onEnd);
  10096. }
  10097. function getTransitionInfo(el, expectedType) {
  10098. const styles = window.getComputedStyle(el);
  10099. // JSDOM may return undefined for transition properties
  10100. const getStyleProperties = (key) => (styles[key] || '').split(', ');
  10101. const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
  10102. const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
  10103. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  10104. const animationDelays = getStyleProperties(ANIMATION + 'Delay');
  10105. const animationDurations = getStyleProperties(ANIMATION + 'Duration');
  10106. const animationTimeout = getTimeout(animationDelays, animationDurations);
  10107. let type = null;
  10108. let timeout = 0;
  10109. let propCount = 0;
  10110. /* istanbul ignore if */
  10111. if (expectedType === TRANSITION) {
  10112. if (transitionTimeout > 0) {
  10113. type = TRANSITION;
  10114. timeout = transitionTimeout;
  10115. propCount = transitionDurations.length;
  10116. }
  10117. }
  10118. else if (expectedType === ANIMATION) {
  10119. if (animationTimeout > 0) {
  10120. type = ANIMATION;
  10121. timeout = animationTimeout;
  10122. propCount = animationDurations.length;
  10123. }
  10124. }
  10125. else {
  10126. timeout = Math.max(transitionTimeout, animationTimeout);
  10127. type =
  10128. timeout > 0
  10129. ? transitionTimeout > animationTimeout
  10130. ? TRANSITION
  10131. : ANIMATION
  10132. : null;
  10133. propCount = type
  10134. ? type === TRANSITION
  10135. ? transitionDurations.length
  10136. : animationDurations.length
  10137. : 0;
  10138. }
  10139. const hasTransform = type === TRANSITION &&
  10140. /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
  10141. return {
  10142. type,
  10143. timeout,
  10144. propCount,
  10145. hasTransform
  10146. };
  10147. }
  10148. function getTimeout(delays, durations) {
  10149. while (delays.length < durations.length) {
  10150. delays = delays.concat(delays);
  10151. }
  10152. return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
  10153. }
  10154. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer
  10155. // numbers in a locale-dependent way, using a comma instead of a dot.
  10156. // If comma is not replaced with a dot, the input will be rounded down
  10157. // (i.e. acting as a floor function) causing unexpected behaviors
  10158. function toMs(s) {
  10159. return Number(s.slice(0, -1).replace(',', '.')) * 1000;
  10160. }
  10161. // synchronously force layout to put elements into a certain state
  10162. function forceReflow() {
  10163. return document.body.offsetHeight;
  10164. }
  10165. const positionMap = new WeakMap();
  10166. const newPositionMap = new WeakMap();
  10167. const TransitionGroupImpl = {
  10168. name: 'TransitionGroup',
  10169. props: /*#__PURE__*/ extend({}, TransitionPropsValidators, {
  10170. tag: String,
  10171. moveClass: String
  10172. }),
  10173. setup(props, { slots }) {
  10174. const instance = getCurrentInstance();
  10175. const state = useTransitionState();
  10176. let prevChildren;
  10177. let children;
  10178. onUpdated(() => {
  10179. // children is guaranteed to exist after initial render
  10180. if (!prevChildren.length) {
  10181. return;
  10182. }
  10183. const moveClass = props.moveClass || `${props.name || 'v'}-move`;
  10184. if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
  10185. return;
  10186. }
  10187. // we divide the work into three loops to avoid mixing DOM reads and writes
  10188. // in each iteration - which helps prevent layout thrashing.
  10189. prevChildren.forEach(callPendingCbs);
  10190. prevChildren.forEach(recordPosition);
  10191. const movedChildren = prevChildren.filter(applyTranslation);
  10192. // force reflow to put everything in position
  10193. forceReflow();
  10194. movedChildren.forEach(c => {
  10195. const el = c.el;
  10196. const style = el.style;
  10197. addTransitionClass(el, moveClass);
  10198. style.transform = style.webkitTransform = style.transitionDuration = '';
  10199. const cb = (el._moveCb = (e) => {
  10200. if (e && e.target !== el) {
  10201. return;
  10202. }
  10203. if (!e || /transform$/.test(e.propertyName)) {
  10204. el.removeEventListener('transitionend', cb);
  10205. el._moveCb = null;
  10206. removeTransitionClass(el, moveClass);
  10207. }
  10208. });
  10209. el.addEventListener('transitionend', cb);
  10210. });
  10211. });
  10212. return () => {
  10213. const rawProps = toRaw(props);
  10214. const cssTransitionProps = resolveTransitionProps(rawProps);
  10215. let tag = rawProps.tag || Fragment;
  10216. prevChildren = children;
  10217. children = slots.default ? getTransitionRawChildren(slots.default()) : [];
  10218. for (let i = 0; i < children.length; i++) {
  10219. const child = children[i];
  10220. if (child.key != null) {
  10221. setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
  10222. }
  10223. else {
  10224. warn$1(`<TransitionGroup> children must be keyed.`);
  10225. }
  10226. }
  10227. if (prevChildren) {
  10228. for (let i = 0; i < prevChildren.length; i++) {
  10229. const child = prevChildren[i];
  10230. setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
  10231. positionMap.set(child, child.el.getBoundingClientRect());
  10232. }
  10233. }
  10234. return createVNode(tag, null, children);
  10235. };
  10236. }
  10237. };
  10238. const TransitionGroup = TransitionGroupImpl;
  10239. function callPendingCbs(c) {
  10240. const el = c.el;
  10241. if (el._moveCb) {
  10242. el._moveCb();
  10243. }
  10244. if (el._enterCb) {
  10245. el._enterCb();
  10246. }
  10247. }
  10248. function recordPosition(c) {
  10249. newPositionMap.set(c, c.el.getBoundingClientRect());
  10250. }
  10251. function applyTranslation(c) {
  10252. const oldPos = positionMap.get(c);
  10253. const newPos = newPositionMap.get(c);
  10254. const dx = oldPos.left - newPos.left;
  10255. const dy = oldPos.top - newPos.top;
  10256. if (dx || dy) {
  10257. const s = c.el.style;
  10258. s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
  10259. s.transitionDuration = '0s';
  10260. return c;
  10261. }
  10262. }
  10263. function hasCSSTransform(el, root, moveClass) {
  10264. // Detect whether an element with the move class applied has
  10265. // CSS transitions. Since the element may be inside an entering
  10266. // transition at this very moment, we make a clone of it and remove
  10267. // all other transition classes applied to ensure only the move class
  10268. // is applied.
  10269. const clone = el.cloneNode();
  10270. if (el._vtc) {
  10271. el._vtc.forEach(cls => {
  10272. cls.split(/\s+/).forEach(c => c && clone.classList.remove(c));
  10273. });
  10274. }
  10275. moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c));
  10276. clone.style.display = 'none';
  10277. const container = (root.nodeType === 1 ? root : root.parentNode);
  10278. container.appendChild(clone);
  10279. const { hasTransform } = getTransitionInfo(clone);
  10280. container.removeChild(clone);
  10281. return hasTransform;
  10282. }
  10283. const getModelAssigner = (vnode) => {
  10284. const fn = vnode.props['onUpdate:modelValue'] ||
  10285. (false );
  10286. return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
  10287. };
  10288. function onCompositionStart(e) {
  10289. e.target.composing = true;
  10290. }
  10291. function onCompositionEnd(e) {
  10292. const target = e.target;
  10293. if (target.composing) {
  10294. target.composing = false;
  10295. target.dispatchEvent(new Event('input'));
  10296. }
  10297. }
  10298. // We are exporting the v-model runtime directly as vnode hooks so that it can
  10299. // be tree-shaken in case v-model is never used.
  10300. const vModelText = {
  10301. created(el, { modifiers: { lazy, trim, number } }, vnode) {
  10302. el._assign = getModelAssigner(vnode);
  10303. const castToNumber = number || (vnode.props && vnode.props.type === 'number');
  10304. addEventListener(el, lazy ? 'change' : 'input', e => {
  10305. if (e.target.composing)
  10306. return;
  10307. let domValue = el.value;
  10308. if (trim) {
  10309. domValue = domValue.trim();
  10310. }
  10311. if (castToNumber) {
  10312. domValue = toNumber(domValue);
  10313. }
  10314. el._assign(domValue);
  10315. });
  10316. if (trim) {
  10317. addEventListener(el, 'change', () => {
  10318. el.value = el.value.trim();
  10319. });
  10320. }
  10321. if (!lazy) {
  10322. addEventListener(el, 'compositionstart', onCompositionStart);
  10323. addEventListener(el, 'compositionend', onCompositionEnd);
  10324. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  10325. // switching focus before confirming composition choice
  10326. // this also fixes the issue where some browsers e.g. iOS Chrome
  10327. // fires "change" instead of "input" on autocomplete.
  10328. addEventListener(el, 'change', onCompositionEnd);
  10329. }
  10330. },
  10331. // set value on mounted so it's after min/max for type="range"
  10332. mounted(el, { value }) {
  10333. el.value = value == null ? '' : value;
  10334. },
  10335. beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
  10336. el._assign = getModelAssigner(vnode);
  10337. // avoid clearing unresolved text. #2302
  10338. if (el.composing)
  10339. return;
  10340. if (document.activeElement === el && el.type !== 'range') {
  10341. if (lazy) {
  10342. return;
  10343. }
  10344. if (trim && el.value.trim() === value) {
  10345. return;
  10346. }
  10347. if ((number || el.type === 'number') && toNumber(el.value) === value) {
  10348. return;
  10349. }
  10350. }
  10351. const newValue = value == null ? '' : value;
  10352. if (el.value !== newValue) {
  10353. el.value = newValue;
  10354. }
  10355. }
  10356. };
  10357. const vModelCheckbox = {
  10358. // #4096 array checkboxes need to be deep traversed
  10359. deep: true,
  10360. created(el, _, vnode) {
  10361. el._assign = getModelAssigner(vnode);
  10362. addEventListener(el, 'change', () => {
  10363. const modelValue = el._modelValue;
  10364. const elementValue = getValue(el);
  10365. const checked = el.checked;
  10366. const assign = el._assign;
  10367. if (isArray(modelValue)) {
  10368. const index = looseIndexOf(modelValue, elementValue);
  10369. const found = index !== -1;
  10370. if (checked && !found) {
  10371. assign(modelValue.concat(elementValue));
  10372. }
  10373. else if (!checked && found) {
  10374. const filtered = [...modelValue];
  10375. filtered.splice(index, 1);
  10376. assign(filtered);
  10377. }
  10378. }
  10379. else if (isSet(modelValue)) {
  10380. const cloned = new Set(modelValue);
  10381. if (checked) {
  10382. cloned.add(elementValue);
  10383. }
  10384. else {
  10385. cloned.delete(elementValue);
  10386. }
  10387. assign(cloned);
  10388. }
  10389. else {
  10390. assign(getCheckboxValue(el, checked));
  10391. }
  10392. });
  10393. },
  10394. // set initial checked on mount to wait for true-value/false-value
  10395. mounted: setChecked,
  10396. beforeUpdate(el, binding, vnode) {
  10397. el._assign = getModelAssigner(vnode);
  10398. setChecked(el, binding, vnode);
  10399. }
  10400. };
  10401. function setChecked(el, { value, oldValue }, vnode) {
  10402. el._modelValue = value;
  10403. if (isArray(value)) {
  10404. el.checked = looseIndexOf(value, vnode.props.value) > -1;
  10405. }
  10406. else if (isSet(value)) {
  10407. el.checked = value.has(vnode.props.value);
  10408. }
  10409. else if (value !== oldValue) {
  10410. el.checked = looseEqual(value, getCheckboxValue(el, true));
  10411. }
  10412. }
  10413. const vModelRadio = {
  10414. created(el, { value }, vnode) {
  10415. el.checked = looseEqual(value, vnode.props.value);
  10416. el._assign = getModelAssigner(vnode);
  10417. addEventListener(el, 'change', () => {
  10418. el._assign(getValue(el));
  10419. });
  10420. },
  10421. beforeUpdate(el, { value, oldValue }, vnode) {
  10422. el._assign = getModelAssigner(vnode);
  10423. if (value !== oldValue) {
  10424. el.checked = looseEqual(value, vnode.props.value);
  10425. }
  10426. }
  10427. };
  10428. const vModelSelect = {
  10429. // <select multiple> value need to be deep traversed
  10430. deep: true,
  10431. created(el, { value, modifiers: { number } }, vnode) {
  10432. const isSetModel = isSet(value);
  10433. addEventListener(el, 'change', () => {
  10434. const selectedVal = Array.prototype.filter
  10435. .call(el.options, (o) => o.selected)
  10436. .map((o) => number ? toNumber(getValue(o)) : getValue(o));
  10437. el._assign(el.multiple
  10438. ? isSetModel
  10439. ? new Set(selectedVal)
  10440. : selectedVal
  10441. : selectedVal[0]);
  10442. });
  10443. el._assign = getModelAssigner(vnode);
  10444. },
  10445. // set value in mounted & updated because <select> relies on its children
  10446. // <option>s.
  10447. mounted(el, { value }) {
  10448. setSelected(el, value);
  10449. },
  10450. beforeUpdate(el, _binding, vnode) {
  10451. el._assign = getModelAssigner(vnode);
  10452. },
  10453. updated(el, { value }) {
  10454. setSelected(el, value);
  10455. }
  10456. };
  10457. function setSelected(el, value) {
  10458. const isMultiple = el.multiple;
  10459. if (isMultiple && !isArray(value) && !isSet(value)) {
  10460. warn$1(`<select multiple v-model> expects an Array or Set value for its binding, ` +
  10461. `but got ${Object.prototype.toString.call(value).slice(8, -1)}.`);
  10462. return;
  10463. }
  10464. for (let i = 0, l = el.options.length; i < l; i++) {
  10465. const option = el.options[i];
  10466. const optionValue = getValue(option);
  10467. if (isMultiple) {
  10468. if (isArray(value)) {
  10469. option.selected = looseIndexOf(value, optionValue) > -1;
  10470. }
  10471. else {
  10472. option.selected = value.has(optionValue);
  10473. }
  10474. }
  10475. else {
  10476. if (looseEqual(getValue(option), value)) {
  10477. if (el.selectedIndex !== i)
  10478. el.selectedIndex = i;
  10479. return;
  10480. }
  10481. }
  10482. }
  10483. if (!isMultiple && el.selectedIndex !== -1) {
  10484. el.selectedIndex = -1;
  10485. }
  10486. }
  10487. // retrieve raw value set via :value bindings
  10488. function getValue(el) {
  10489. return '_value' in el ? el._value : el.value;
  10490. }
  10491. // retrieve raw value for true-value and false-value set via :true-value or :false-value bindings
  10492. function getCheckboxValue(el, checked) {
  10493. const key = checked ? '_trueValue' : '_falseValue';
  10494. return key in el ? el[key] : checked;
  10495. }
  10496. const vModelDynamic = {
  10497. created(el, binding, vnode) {
  10498. callModelHook(el, binding, vnode, null, 'created');
  10499. },
  10500. mounted(el, binding, vnode) {
  10501. callModelHook(el, binding, vnode, null, 'mounted');
  10502. },
  10503. beforeUpdate(el, binding, vnode, prevVNode) {
  10504. callModelHook(el, binding, vnode, prevVNode, 'beforeUpdate');
  10505. },
  10506. updated(el, binding, vnode, prevVNode) {
  10507. callModelHook(el, binding, vnode, prevVNode, 'updated');
  10508. }
  10509. };
  10510. function resolveDynamicModel(tagName, type) {
  10511. switch (tagName) {
  10512. case 'SELECT':
  10513. return vModelSelect;
  10514. case 'TEXTAREA':
  10515. return vModelText;
  10516. default:
  10517. switch (type) {
  10518. case 'checkbox':
  10519. return vModelCheckbox;
  10520. case 'radio':
  10521. return vModelRadio;
  10522. default:
  10523. return vModelText;
  10524. }
  10525. }
  10526. }
  10527. function callModelHook(el, binding, vnode, prevVNode, hook) {
  10528. const modelToUse = resolveDynamicModel(el.tagName, vnode.props && vnode.props.type);
  10529. const fn = modelToUse[hook];
  10530. fn && fn(el, binding, vnode, prevVNode);
  10531. }
  10532. const systemModifiers = ['ctrl', 'shift', 'alt', 'meta'];
  10533. const modifierGuards = {
  10534. stop: e => e.stopPropagation(),
  10535. prevent: e => e.preventDefault(),
  10536. self: e => e.target !== e.currentTarget,
  10537. ctrl: e => !e.ctrlKey,
  10538. shift: e => !e.shiftKey,
  10539. alt: e => !e.altKey,
  10540. meta: e => !e.metaKey,
  10541. left: e => 'button' in e && e.button !== 0,
  10542. middle: e => 'button' in e && e.button !== 1,
  10543. right: e => 'button' in e && e.button !== 2,
  10544. exact: (e, modifiers) => systemModifiers.some(m => e[`${m}Key`] && !modifiers.includes(m))
  10545. };
  10546. /**
  10547. * @private
  10548. */
  10549. const withModifiers = (fn, modifiers) => {
  10550. return (event, ...args) => {
  10551. for (let i = 0; i < modifiers.length; i++) {
  10552. const guard = modifierGuards[modifiers[i]];
  10553. if (guard && guard(event, modifiers))
  10554. return;
  10555. }
  10556. return fn(event, ...args);
  10557. };
  10558. };
  10559. // Kept for 2.x compat.
  10560. // Note: IE11 compat for `spacebar` and `del` is removed for now.
  10561. const keyNames = {
  10562. esc: 'escape',
  10563. space: ' ',
  10564. up: 'arrow-up',
  10565. left: 'arrow-left',
  10566. right: 'arrow-right',
  10567. down: 'arrow-down',
  10568. delete: 'backspace'
  10569. };
  10570. /**
  10571. * @private
  10572. */
  10573. const withKeys = (fn, modifiers) => {
  10574. return (event) => {
  10575. if (!('key' in event)) {
  10576. return;
  10577. }
  10578. const eventKey = hyphenate(event.key);
  10579. if (modifiers.some(k => k === eventKey || keyNames[k] === eventKey)) {
  10580. return fn(event);
  10581. }
  10582. };
  10583. };
  10584. const vShow = {
  10585. beforeMount(el, { value }, { transition }) {
  10586. el._vod = el.style.display === 'none' ? '' : el.style.display;
  10587. if (transition && value) {
  10588. transition.beforeEnter(el);
  10589. }
  10590. else {
  10591. setDisplay(el, value);
  10592. }
  10593. },
  10594. mounted(el, { value }, { transition }) {
  10595. if (transition && value) {
  10596. transition.enter(el);
  10597. }
  10598. },
  10599. updated(el, { value, oldValue }, { transition }) {
  10600. if (!value === !oldValue)
  10601. return;
  10602. if (transition) {
  10603. if (value) {
  10604. transition.beforeEnter(el);
  10605. setDisplay(el, true);
  10606. transition.enter(el);
  10607. }
  10608. else {
  10609. transition.leave(el, () => {
  10610. setDisplay(el, false);
  10611. });
  10612. }
  10613. }
  10614. else {
  10615. setDisplay(el, value);
  10616. }
  10617. },
  10618. beforeUnmount(el, { value }) {
  10619. setDisplay(el, value);
  10620. }
  10621. };
  10622. function setDisplay(el, value) {
  10623. el.style.display = value ? el._vod : 'none';
  10624. }
  10625. const rendererOptions = /*#__PURE__*/ extend({ patchProp }, nodeOps);
  10626. // lazy create the renderer - this makes core renderer logic tree-shakable
  10627. // in case the user only imports reactivity utilities from Vue.
  10628. let renderer;
  10629. let enabledHydration = false;
  10630. function ensureRenderer() {
  10631. return (renderer ||
  10632. (renderer = createRenderer(rendererOptions)));
  10633. }
  10634. function ensureHydrationRenderer() {
  10635. renderer = enabledHydration
  10636. ? renderer
  10637. : createHydrationRenderer(rendererOptions);
  10638. enabledHydration = true;
  10639. return renderer;
  10640. }
  10641. // use explicit type casts here to avoid import() calls in rolled-up d.ts
  10642. const render = ((...args) => {
  10643. ensureRenderer().render(...args);
  10644. });
  10645. const hydrate = ((...args) => {
  10646. ensureHydrationRenderer().hydrate(...args);
  10647. });
  10648. const createApp = ((...args) => {
  10649. const app = ensureRenderer().createApp(...args);
  10650. {
  10651. injectNativeTagCheck(app);
  10652. injectCompilerOptionsCheck(app);
  10653. }
  10654. const { mount } = app;
  10655. app.mount = (containerOrSelector) => {
  10656. const container = normalizeContainer(containerOrSelector);
  10657. if (!container)
  10658. return;
  10659. const component = app._component;
  10660. if (!isFunction(component) && !component.render && !component.template) {
  10661. // __UNSAFE__
  10662. // Reason: potential execution of JS expressions in in-DOM template.
  10663. // The user must make sure the in-DOM template is trusted. If it's
  10664. // rendered by the server, the template should not contain any user data.
  10665. component.template = container.innerHTML;
  10666. }
  10667. // clear content before mounting
  10668. container.innerHTML = '';
  10669. const proxy = mount(container, false, container instanceof SVGElement);
  10670. if (container instanceof Element) {
  10671. container.removeAttribute('v-cloak');
  10672. container.setAttribute('data-v-app', '');
  10673. }
  10674. return proxy;
  10675. };
  10676. return app;
  10677. });
  10678. const createSSRApp = ((...args) => {
  10679. const app = ensureHydrationRenderer().createApp(...args);
  10680. {
  10681. injectNativeTagCheck(app);
  10682. injectCompilerOptionsCheck(app);
  10683. }
  10684. const { mount } = app;
  10685. app.mount = (containerOrSelector) => {
  10686. const container = normalizeContainer(containerOrSelector);
  10687. if (container) {
  10688. return mount(container, true, container instanceof SVGElement);
  10689. }
  10690. };
  10691. return app;
  10692. });
  10693. function injectNativeTagCheck(app) {
  10694. // Inject `isNativeTag`
  10695. // this is used for component name validation (dev only)
  10696. Object.defineProperty(app.config, 'isNativeTag', {
  10697. value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
  10698. writable: false
  10699. });
  10700. }
  10701. // dev only
  10702. function injectCompilerOptionsCheck(app) {
  10703. if (isRuntimeOnly()) {
  10704. const isCustomElement = app.config.isCustomElement;
  10705. Object.defineProperty(app.config, 'isCustomElement', {
  10706. get() {
  10707. return isCustomElement;
  10708. },
  10709. set() {
  10710. warn$1(`The \`isCustomElement\` config option is deprecated. Use ` +
  10711. `\`compilerOptions.isCustomElement\` instead.`);
  10712. }
  10713. });
  10714. const compilerOptions = app.config.compilerOptions;
  10715. const msg = `The \`compilerOptions\` config option is only respected when using ` +
  10716. `a build of Vue.js that includes the runtime compiler (aka "full build"). ` +
  10717. `Since you are using the runtime-only build, \`compilerOptions\` ` +
  10718. `must be passed to \`@vue/compiler-dom\` in the build setup instead.\n` +
  10719. `- For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.\n` +
  10720. `- For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader\n` +
  10721. `- For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-dom`;
  10722. Object.defineProperty(app.config, 'compilerOptions', {
  10723. get() {
  10724. warn$1(msg);
  10725. return compilerOptions;
  10726. },
  10727. set() {
  10728. warn$1(msg);
  10729. }
  10730. });
  10731. }
  10732. }
  10733. function normalizeContainer(container) {
  10734. if (isString(container)) {
  10735. const res = document.querySelector(container);
  10736. if (!res) {
  10737. warn$1(`Failed to mount app: mount target selector "${container}" returned null.`);
  10738. }
  10739. return res;
  10740. }
  10741. if (window.ShadowRoot &&
  10742. container instanceof window.ShadowRoot &&
  10743. container.mode === 'closed') {
  10744. warn$1(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
  10745. }
  10746. return container;
  10747. }
  10748. /**
  10749. * @internal
  10750. */
  10751. const initDirectivesForSSR = NOOP;
  10752. function initDev() {
  10753. {
  10754. {
  10755. console.info(`You are running a development build of Vue.\n` +
  10756. `Make sure to use the production build (*.prod.js) when deploying for production.`);
  10757. }
  10758. initCustomFormatter();
  10759. }
  10760. }
  10761. // This entry exports the runtime only, and is built as
  10762. {
  10763. initDev();
  10764. }
  10765. const compile$1 = () => {
  10766. {
  10767. warn$1(`Runtime compilation is not supported in this build of Vue.` +
  10768. (` Use "vue.global.js" instead.`
  10769. ) /* should not happen */);
  10770. }
  10771. };
  10772. exports.BaseTransition = BaseTransition;
  10773. exports.Comment = Comment;
  10774. exports.EffectScope = EffectScope;
  10775. exports.Fragment = Fragment;
  10776. exports.KeepAlive = KeepAlive;
  10777. exports.ReactiveEffect = ReactiveEffect;
  10778. exports.Static = Static;
  10779. exports.Suspense = Suspense;
  10780. exports.Teleport = Teleport;
  10781. exports.Text = Text;
  10782. exports.Transition = Transition;
  10783. exports.TransitionGroup = TransitionGroup;
  10784. exports.VueElement = VueElement;
  10785. exports.callWithAsyncErrorHandling = callWithAsyncErrorHandling;
  10786. exports.callWithErrorHandling = callWithErrorHandling;
  10787. exports.camelize = camelize;
  10788. exports.capitalize = capitalize;
  10789. exports.cloneVNode = cloneVNode;
  10790. exports.compatUtils = compatUtils;
  10791. exports.compile = compile$1;
  10792. exports.computed = computed$1;
  10793. exports.createApp = createApp;
  10794. exports.createBlock = createBlock;
  10795. exports.createCommentVNode = createCommentVNode;
  10796. exports.createElementBlock = createElementBlock;
  10797. exports.createElementVNode = createBaseVNode;
  10798. exports.createHydrationRenderer = createHydrationRenderer;
  10799. exports.createPropsRestProxy = createPropsRestProxy;
  10800. exports.createRenderer = createRenderer;
  10801. exports.createSSRApp = createSSRApp;
  10802. exports.createSlots = createSlots;
  10803. exports.createStaticVNode = createStaticVNode;
  10804. exports.createTextVNode = createTextVNode;
  10805. exports.createVNode = createVNode;
  10806. exports.customRef = customRef;
  10807. exports.defineAsyncComponent = defineAsyncComponent;
  10808. exports.defineComponent = defineComponent;
  10809. exports.defineCustomElement = defineCustomElement;
  10810. exports.defineEmits = defineEmits;
  10811. exports.defineExpose = defineExpose;
  10812. exports.defineProps = defineProps;
  10813. exports.defineSSRCustomElement = defineSSRCustomElement;
  10814. exports.effect = effect;
  10815. exports.effectScope = effectScope;
  10816. exports.getCurrentInstance = getCurrentInstance;
  10817. exports.getCurrentScope = getCurrentScope;
  10818. exports.getTransitionRawChildren = getTransitionRawChildren;
  10819. exports.guardReactiveProps = guardReactiveProps;
  10820. exports.h = h;
  10821. exports.handleError = handleError;
  10822. exports.hydrate = hydrate;
  10823. exports.initCustomFormatter = initCustomFormatter;
  10824. exports.initDirectivesForSSR = initDirectivesForSSR;
  10825. exports.inject = inject;
  10826. exports.isMemoSame = isMemoSame;
  10827. exports.isProxy = isProxy;
  10828. exports.isReactive = isReactive;
  10829. exports.isReadonly = isReadonly;
  10830. exports.isRef = isRef;
  10831. exports.isRuntimeOnly = isRuntimeOnly;
  10832. exports.isShallow = isShallow;
  10833. exports.isVNode = isVNode;
  10834. exports.markRaw = markRaw;
  10835. exports.mergeDefaults = mergeDefaults;
  10836. exports.mergeProps = mergeProps;
  10837. exports.nextTick = nextTick;
  10838. exports.normalizeClass = normalizeClass;
  10839. exports.normalizeProps = normalizeProps;
  10840. exports.normalizeStyle = normalizeStyle;
  10841. exports.onActivated = onActivated;
  10842. exports.onBeforeMount = onBeforeMount;
  10843. exports.onBeforeUnmount = onBeforeUnmount;
  10844. exports.onBeforeUpdate = onBeforeUpdate;
  10845. exports.onDeactivated = onDeactivated;
  10846. exports.onErrorCaptured = onErrorCaptured;
  10847. exports.onMounted = onMounted;
  10848. exports.onRenderTracked = onRenderTracked;
  10849. exports.onRenderTriggered = onRenderTriggered;
  10850. exports.onScopeDispose = onScopeDispose;
  10851. exports.onServerPrefetch = onServerPrefetch;
  10852. exports.onUnmounted = onUnmounted;
  10853. exports.onUpdated = onUpdated;
  10854. exports.openBlock = openBlock;
  10855. exports.popScopeId = popScopeId;
  10856. exports.provide = provide;
  10857. exports.proxyRefs = proxyRefs;
  10858. exports.pushScopeId = pushScopeId;
  10859. exports.queuePostFlushCb = queuePostFlushCb;
  10860. exports.reactive = reactive;
  10861. exports.readonly = readonly;
  10862. exports.ref = ref;
  10863. exports.registerRuntimeCompiler = registerRuntimeCompiler;
  10864. exports.render = render;
  10865. exports.renderList = renderList;
  10866. exports.renderSlot = renderSlot;
  10867. exports.resolveComponent = resolveComponent;
  10868. exports.resolveDirective = resolveDirective;
  10869. exports.resolveDynamicComponent = resolveDynamicComponent;
  10870. exports.resolveFilter = resolveFilter;
  10871. exports.resolveTransitionHooks = resolveTransitionHooks;
  10872. exports.setBlockTracking = setBlockTracking;
  10873. exports.setDevtoolsHook = setDevtoolsHook;
  10874. exports.setTransitionHooks = setTransitionHooks;
  10875. exports.shallowReactive = shallowReactive;
  10876. exports.shallowReadonly = shallowReadonly;
  10877. exports.shallowRef = shallowRef;
  10878. exports.ssrContextKey = ssrContextKey;
  10879. exports.ssrUtils = ssrUtils;
  10880. exports.stop = stop;
  10881. exports.toDisplayString = toDisplayString;
  10882. exports.toHandlerKey = toHandlerKey;
  10883. exports.toHandlers = toHandlers;
  10884. exports.toRaw = toRaw;
  10885. exports.toRef = toRef;
  10886. exports.toRefs = toRefs;
  10887. exports.transformVNodeArgs = transformVNodeArgs;
  10888. exports.triggerRef = triggerRef;
  10889. exports.unref = unref;
  10890. exports.useAttrs = useAttrs;
  10891. exports.useCssModule = useCssModule;
  10892. exports.useCssVars = useCssVars;
  10893. exports.useSSRContext = useSSRContext;
  10894. exports.useSlots = useSlots;
  10895. exports.useTransitionState = useTransitionState;
  10896. exports.vModelCheckbox = vModelCheckbox;
  10897. exports.vModelDynamic = vModelDynamic;
  10898. exports.vModelRadio = vModelRadio;
  10899. exports.vModelSelect = vModelSelect;
  10900. exports.vModelText = vModelText;
  10901. exports.vShow = vShow;
  10902. exports.version = version;
  10903. exports.warn = warn$1;
  10904. exports.watch = watch;
  10905. exports.watchEffect = watchEffect;
  10906. exports.watchPostEffect = watchPostEffect;
  10907. exports.watchSyncEffect = watchSyncEffect;
  10908. exports.withAsyncContext = withAsyncContext;
  10909. exports.withCtx = withCtx;
  10910. exports.withDefaults = withDefaults;
  10911. exports.withDirectives = withDirectives;
  10912. exports.withKeys = withKeys;
  10913. exports.withMemo = withMemo;
  10914. exports.withModifiers = withModifiers;
  10915. exports.withScopeId = withScopeId;
  10916. Object.defineProperty(exports, '__esModule', { value: true });
  10917. return exports;
  10918. }({}));