compiler-sfc.js 643 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var require$$0 = require('source-map');
  4. var parser$1 = require('@babel/parser');
  5. var url = require('url');
  6. var path = require('path');
  7. var require$$0$1 = require('fs');
  8. var require$$2 = require('util');
  9. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  10. var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0);
  11. var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
  12. var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
  13. var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
  14. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  15. function getDefaultExportFromCjs (x) {
  16. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  17. }
  18. var splitRE$2 = /\r?\n/g;
  19. var emptyRE$1 = /^\s*$/;
  20. var needFixRE = /^(\r?\n)*[\t\s]/;
  21. var deIndent = function deindent (str) {
  22. if (!needFixRE.test(str)) {
  23. return str
  24. }
  25. var lines = str.split(splitRE$2);
  26. var min = Infinity;
  27. var type, cur, c;
  28. for (var i = 0; i < lines.length; i++) {
  29. var line = lines[i];
  30. if (!emptyRE$1.test(line)) {
  31. if (!type) {
  32. c = line.charAt(0);
  33. if (c === ' ' || c === '\t') {
  34. type = c;
  35. cur = count(line, type);
  36. if (cur < min) {
  37. min = cur;
  38. }
  39. } else {
  40. return str
  41. }
  42. } else {
  43. cur = count(line, type);
  44. if (cur < min) {
  45. min = cur;
  46. }
  47. }
  48. }
  49. }
  50. return lines.map(function (line) {
  51. return line.slice(min)
  52. }).join('\n')
  53. };
  54. function count (line, type) {
  55. var i = 0;
  56. while (line.charAt(i) === type) {
  57. i++;
  58. }
  59. return i
  60. }
  61. const emptyObject = Object.freeze({});
  62. const isArray = Array.isArray;
  63. // These helpers produce better VM code in JS engines due to their
  64. // explicitness and function inlining.
  65. function isUndef(v) {
  66. return v === undefined || v === null;
  67. }
  68. function isDef(v) {
  69. return v !== undefined && v !== null;
  70. }
  71. function isTrue(v) {
  72. return v === true;
  73. }
  74. function isFalse(v) {
  75. return v === false;
  76. }
  77. /**
  78. * Check if value is primitive.
  79. */
  80. function isPrimitive(value) {
  81. return (typeof value === 'string' ||
  82. typeof value === 'number' ||
  83. // $flow-disable-line
  84. typeof value === 'symbol' ||
  85. typeof value === 'boolean');
  86. }
  87. function isFunction(value) {
  88. return typeof value === 'function';
  89. }
  90. /**
  91. * Quick object check - this is primarily used to tell
  92. * objects from primitive values when we know the value
  93. * is a JSON-compliant type.
  94. */
  95. function isObject$1(obj) {
  96. return obj !== null && typeof obj === 'object';
  97. }
  98. /**
  99. * Get the raw type string of a value, e.g., [object Object].
  100. */
  101. const _toString = Object.prototype.toString;
  102. function toRawType(value) {
  103. return _toString.call(value).slice(8, -1);
  104. }
  105. /**
  106. * Strict object type check. Only returns true
  107. * for plain JavaScript objects.
  108. */
  109. function isPlainObject(obj) {
  110. return _toString.call(obj) === '[object Object]';
  111. }
  112. /**
  113. * Check if val is a valid array index.
  114. */
  115. function isValidArrayIndex(val) {
  116. const n = parseFloat(String(val));
  117. return n >= 0 && Math.floor(n) === n && isFinite(val);
  118. }
  119. function isPromise(val) {
  120. return (isDef(val) &&
  121. typeof val.then === 'function' &&
  122. typeof val.catch === 'function');
  123. }
  124. /**
  125. * Convert a value to a string that is actually rendered.
  126. */
  127. function toString$2(val) {
  128. return val == null
  129. ? ''
  130. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  131. ? JSON.stringify(val, null, 2)
  132. : String(val);
  133. }
  134. /**
  135. * Convert an input value to a number for persistence.
  136. * If the conversion fails, return original string.
  137. */
  138. function toNumber(val) {
  139. const n = parseFloat(val);
  140. return isNaN(n) ? val : n;
  141. }
  142. /**
  143. * Make a map and return a function for checking if a key
  144. * is in that map.
  145. */
  146. function makeMap(str, expectsLowerCase) {
  147. const map = Object.create(null);
  148. const list = str.split(',');
  149. for (let i = 0; i < list.length; i++) {
  150. map[list[i]] = true;
  151. }
  152. return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val];
  153. }
  154. /**
  155. * Check if a tag is a built-in tag.
  156. */
  157. const isBuiltInTag = makeMap('slot,component', true);
  158. /**
  159. * Check if an attribute is a reserved attribute.
  160. */
  161. const isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  162. /**
  163. * Check whether an object has the property.
  164. */
  165. const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  166. function hasOwn(obj, key) {
  167. return hasOwnProperty$1.call(obj, key);
  168. }
  169. /**
  170. * Create a cached version of a pure function.
  171. */
  172. function cached(fn) {
  173. const cache = Object.create(null);
  174. return function cachedFn(str) {
  175. const hit = cache[str];
  176. return hit || (cache[str] = fn(str));
  177. };
  178. }
  179. /**
  180. * Camelize a hyphen-delimited string.
  181. */
  182. const camelizeRE = /-(\w)/g;
  183. const camelize = cached((str) => {
  184. return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
  185. });
  186. /**
  187. * Capitalize a string.
  188. */
  189. const capitalize = cached((str) => {
  190. return str.charAt(0).toUpperCase() + str.slice(1);
  191. });
  192. /**
  193. * Hyphenate a camelCase string.
  194. */
  195. const hyphenateRE = /\B([A-Z])/g;
  196. const hyphenate = cached((str) => {
  197. return str.replace(hyphenateRE, '-$1').toLowerCase();
  198. });
  199. /**
  200. * Mix properties into target object.
  201. */
  202. function extend(to, _from) {
  203. for (const key in _from) {
  204. to[key] = _from[key];
  205. }
  206. return to;
  207. }
  208. /**
  209. * Merge an Array of Objects into a single Object.
  210. */
  211. function toObject(arr) {
  212. const res = {};
  213. for (let i = 0; i < arr.length; i++) {
  214. if (arr[i]) {
  215. extend(res, arr[i]);
  216. }
  217. }
  218. return res;
  219. }
  220. /* eslint-disable no-unused-vars */
  221. /**
  222. * Perform no operation.
  223. * Stubbing args to make Flow happy without leaving useless transpiled code
  224. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  225. */
  226. function noop(a, b, c) { }
  227. /**
  228. * Always return false.
  229. */
  230. const no = (a, b, c) => false;
  231. /* eslint-enable no-unused-vars */
  232. /**
  233. * Return the same value.
  234. */
  235. const identity = (_) => _;
  236. /**
  237. * Generate a string containing static keys from compiler modules.
  238. */
  239. function genStaticKeys$1(modules) {
  240. return modules
  241. .reduce((keys, m) => {
  242. return keys.concat(m.staticKeys || []);
  243. }, [])
  244. .join(',');
  245. }
  246. /**
  247. * Check if two values are loosely equal - that is,
  248. * if they are plain objects, do they have the same shape?
  249. */
  250. function looseEqual(a, b) {
  251. if (a === b)
  252. return true;
  253. const isObjectA = isObject$1(a);
  254. const isObjectB = isObject$1(b);
  255. if (isObjectA && isObjectB) {
  256. try {
  257. const isArrayA = Array.isArray(a);
  258. const isArrayB = Array.isArray(b);
  259. if (isArrayA && isArrayB) {
  260. return (a.length === b.length &&
  261. a.every((e, i) => {
  262. return looseEqual(e, b[i]);
  263. }));
  264. }
  265. else if (a instanceof Date && b instanceof Date) {
  266. return a.getTime() === b.getTime();
  267. }
  268. else if (!isArrayA && !isArrayB) {
  269. const keysA = Object.keys(a);
  270. const keysB = Object.keys(b);
  271. return (keysA.length === keysB.length &&
  272. keysA.every(key => {
  273. return looseEqual(a[key], b[key]);
  274. }));
  275. }
  276. else {
  277. /* istanbul ignore next */
  278. return false;
  279. }
  280. }
  281. catch (e) {
  282. /* istanbul ignore next */
  283. return false;
  284. }
  285. }
  286. else if (!isObjectA && !isObjectB) {
  287. return String(a) === String(b);
  288. }
  289. else {
  290. return false;
  291. }
  292. }
  293. /**
  294. * Return the first index at which a loosely equal value can be
  295. * found in the array (if value is a plain object, the array must
  296. * contain an object of the same shape), or -1 if it is not present.
  297. */
  298. function looseIndexOf(arr, val) {
  299. for (let i = 0; i < arr.length; i++) {
  300. if (looseEqual(arr[i], val))
  301. return i;
  302. }
  303. return -1;
  304. }
  305. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#polyfill
  306. function hasChanged(x, y) {
  307. if (x === y) {
  308. return x === 0 && 1 / x !== 1 / y;
  309. }
  310. else {
  311. return x === x || y === y;
  312. }
  313. }
  314. const isUnaryTag = makeMap('area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  315. 'link,meta,param,source,track,wbr');
  316. // Elements that you can, intentionally, leave open
  317. // (and which close themselves)
  318. const canBeLeftOpenTag = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source');
  319. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  320. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  321. const isNonPhrasingTag = makeMap('address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  322. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  323. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  324. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  325. 'title,tr,track');
  326. /**
  327. * unicode letters used for parsing html tags, component names and property paths.
  328. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  329. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  330. */
  331. const unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;
  332. /**
  333. * Define a property.
  334. */
  335. function def(obj, key, val, enumerable) {
  336. Object.defineProperty(obj, key, {
  337. value: val,
  338. enumerable: !!enumerable,
  339. writable: true,
  340. configurable: true
  341. });
  342. }
  343. /**
  344. * Not type-checking this file because it's mostly vendor code.
  345. */
  346. // Regular Expressions for parsing tags and attributes
  347. const attribute$2 = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  348. const dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  349. const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*`;
  350. const qnameCapture = `((?:${ncname}\\:)?${ncname})`;
  351. const startTagOpen = new RegExp(`^<${qnameCapture}`);
  352. const startTagClose = /^\s*(\/?)>/;
  353. const endTag = new RegExp(`^<\\/${qnameCapture}[^>]*>`);
  354. const doctype = /^<!DOCTYPE [^>]+>/i;
  355. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  356. const comment$3 = /^<!\--/;
  357. const conditionalComment = /^<!\[/;
  358. // Special Elements (can contain anything)
  359. const isPlainTextElement = makeMap('script,style,textarea', true);
  360. const reCache = {};
  361. const decodingMap = {
  362. '&lt;': '<',
  363. '&gt;': '>',
  364. '&quot;': '"',
  365. '&amp;': '&',
  366. '&#10;': '\n',
  367. '&#9;': '\t',
  368. '&#39;': "'"
  369. };
  370. const encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  371. const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  372. // #5992
  373. const isIgnoreNewlineTag = makeMap('pre,textarea', true);
  374. const shouldIgnoreFirstNewline = (tag, html) => tag && isIgnoreNewlineTag(tag) && html[0] === '\n';
  375. function decodeAttr(value, shouldDecodeNewlines) {
  376. const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  377. return value.replace(re, match => decodingMap[match]);
  378. }
  379. function parseHTML(html, options) {
  380. const stack = [];
  381. const expectHTML = options.expectHTML;
  382. const isUnaryTag = options.isUnaryTag || no;
  383. const canBeLeftOpenTag = options.canBeLeftOpenTag || no;
  384. let index = 0;
  385. let last, lastTag;
  386. while (html) {
  387. last = html;
  388. // Make sure we're not in a plaintext content element like script/style
  389. if (!lastTag || !isPlainTextElement(lastTag)) {
  390. let textEnd = html.indexOf('<');
  391. if (textEnd === 0) {
  392. // Comment:
  393. if (comment$3.test(html)) {
  394. const commentEnd = html.indexOf('-->');
  395. if (commentEnd >= 0) {
  396. if (options.shouldKeepComment && options.comment) {
  397. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  398. }
  399. advance(commentEnd + 3);
  400. continue;
  401. }
  402. }
  403. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  404. if (conditionalComment.test(html)) {
  405. const conditionalEnd = html.indexOf(']>');
  406. if (conditionalEnd >= 0) {
  407. advance(conditionalEnd + 2);
  408. continue;
  409. }
  410. }
  411. // Doctype:
  412. const doctypeMatch = html.match(doctype);
  413. if (doctypeMatch) {
  414. advance(doctypeMatch[0].length);
  415. continue;
  416. }
  417. // End tag:
  418. const endTagMatch = html.match(endTag);
  419. if (endTagMatch) {
  420. const curIndex = index;
  421. advance(endTagMatch[0].length);
  422. parseEndTag(endTagMatch[1], curIndex, index);
  423. continue;
  424. }
  425. // Start tag:
  426. const startTagMatch = parseStartTag();
  427. if (startTagMatch) {
  428. handleStartTag(startTagMatch);
  429. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  430. advance(1);
  431. }
  432. continue;
  433. }
  434. }
  435. let text, rest, next;
  436. if (textEnd >= 0) {
  437. rest = html.slice(textEnd);
  438. while (!endTag.test(rest) &&
  439. !startTagOpen.test(rest) &&
  440. !comment$3.test(rest) &&
  441. !conditionalComment.test(rest)) {
  442. // < in plain text, be forgiving and treat it as text
  443. next = rest.indexOf('<', 1);
  444. if (next < 0)
  445. break;
  446. textEnd += next;
  447. rest = html.slice(textEnd);
  448. }
  449. text = html.substring(0, textEnd);
  450. }
  451. if (textEnd < 0) {
  452. text = html;
  453. }
  454. if (text) {
  455. advance(text.length);
  456. }
  457. if (options.chars && text) {
  458. options.chars(text, index - text.length, index);
  459. }
  460. }
  461. else {
  462. let endTagLength = 0;
  463. const stackedTag = lastTag.toLowerCase();
  464. const reStackedTag = reCache[stackedTag] ||
  465. (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  466. const rest = html.replace(reStackedTag, function (all, text, endTag) {
  467. endTagLength = endTag.length;
  468. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  469. text = text
  470. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  471. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  472. }
  473. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  474. text = text.slice(1);
  475. }
  476. if (options.chars) {
  477. options.chars(text);
  478. }
  479. return '';
  480. });
  481. index += html.length - rest.length;
  482. html = rest;
  483. parseEndTag(stackedTag, index - endTagLength, index);
  484. }
  485. if (html === last) {
  486. options.chars && options.chars(html);
  487. if (process.env.NODE_ENV !== 'production' && !stack.length && options.warn) {
  488. options.warn(`Mal-formatted tag at end of template: "${html}"`, {
  489. start: index + html.length
  490. });
  491. }
  492. break;
  493. }
  494. }
  495. // Clean up any remaining tags
  496. parseEndTag();
  497. function advance(n) {
  498. index += n;
  499. html = html.substring(n);
  500. }
  501. function parseStartTag() {
  502. const start = html.match(startTagOpen);
  503. if (start) {
  504. const match = {
  505. tagName: start[1],
  506. attrs: [],
  507. start: index
  508. };
  509. advance(start[0].length);
  510. let end, attr;
  511. while (!(end = html.match(startTagClose)) &&
  512. (attr = html.match(dynamicArgAttribute) || html.match(attribute$2))) {
  513. attr.start = index;
  514. advance(attr[0].length);
  515. attr.end = index;
  516. match.attrs.push(attr);
  517. }
  518. if (end) {
  519. match.unarySlash = end[1];
  520. advance(end[0].length);
  521. match.end = index;
  522. return match;
  523. }
  524. }
  525. }
  526. function handleStartTag(match) {
  527. const tagName = match.tagName;
  528. const unarySlash = match.unarySlash;
  529. if (expectHTML) {
  530. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  531. parseEndTag(lastTag);
  532. }
  533. if (canBeLeftOpenTag(tagName) && lastTag === tagName) {
  534. parseEndTag(tagName);
  535. }
  536. }
  537. const unary = isUnaryTag(tagName) || !!unarySlash;
  538. const l = match.attrs.length;
  539. const attrs = new Array(l);
  540. for (let i = 0; i < l; i++) {
  541. const args = match.attrs[i];
  542. const value = args[3] || args[4] || args[5] || '';
  543. const shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  544. ? options.shouldDecodeNewlinesForHref
  545. : options.shouldDecodeNewlines;
  546. attrs[i] = {
  547. name: args[1],
  548. value: decodeAttr(value, shouldDecodeNewlines)
  549. };
  550. if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
  551. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  552. attrs[i].end = args.end;
  553. }
  554. }
  555. if (!unary) {
  556. stack.push({
  557. tag: tagName,
  558. lowerCasedTag: tagName.toLowerCase(),
  559. attrs: attrs,
  560. start: match.start,
  561. end: match.end
  562. });
  563. lastTag = tagName;
  564. }
  565. if (options.start) {
  566. options.start(tagName, attrs, unary, match.start, match.end);
  567. }
  568. }
  569. function parseEndTag(tagName, start, end) {
  570. let pos, lowerCasedTagName;
  571. if (start == null)
  572. start = index;
  573. if (end == null)
  574. end = index;
  575. // Find the closest opened tag of the same type
  576. if (tagName) {
  577. lowerCasedTagName = tagName.toLowerCase();
  578. for (pos = stack.length - 1; pos >= 0; pos--) {
  579. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  580. break;
  581. }
  582. }
  583. }
  584. else {
  585. // If no tag name is provided, clean shop
  586. pos = 0;
  587. }
  588. if (pos >= 0) {
  589. // Close all the open elements, up the stack
  590. for (let i = stack.length - 1; i >= pos; i--) {
  591. if (process.env.NODE_ENV !== 'production' && (i > pos || !tagName) && options.warn) {
  592. options.warn(`tag <${stack[i].tag}> has no matching end tag.`, {
  593. start: stack[i].start,
  594. end: stack[i].end
  595. });
  596. }
  597. if (options.end) {
  598. options.end(stack[i].tag, start, end);
  599. }
  600. }
  601. // Remove the open elements from the stack
  602. stack.length = pos;
  603. lastTag = pos && stack[pos - 1].tag;
  604. }
  605. else if (lowerCasedTagName === 'br') {
  606. if (options.start) {
  607. options.start(tagName, [], true, start, end);
  608. }
  609. }
  610. else if (lowerCasedTagName === 'p') {
  611. if (options.start) {
  612. options.start(tagName, [], false, start, end);
  613. }
  614. if (options.end) {
  615. options.end(tagName, start, end);
  616. }
  617. }
  618. }
  619. }
  620. const DEFAULT_FILENAME = 'anonymous.vue';
  621. const splitRE$1 = /\r?\n/g;
  622. const replaceRE = /./g;
  623. const isSpecialTag = makeMap('script,style,template', true);
  624. /**
  625. * Parse a single-file component (*.vue) file into an SFC Descriptor Object.
  626. */
  627. function parseComponent(source, options = {}) {
  628. const sfc = {
  629. source,
  630. filename: DEFAULT_FILENAME,
  631. template: null,
  632. script: null,
  633. scriptSetup: null,
  634. styles: [],
  635. customBlocks: [],
  636. cssVars: [],
  637. errors: [],
  638. shouldForceReload: null // attached in parse() by compiler-sfc
  639. };
  640. let depth = 0;
  641. let currentBlock = null;
  642. let warn = msg => {
  643. sfc.errors.push(msg);
  644. };
  645. if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
  646. warn = (msg, range) => {
  647. const data = { msg };
  648. if (range.start != null) {
  649. data.start = range.start;
  650. }
  651. if (range.end != null) {
  652. data.end = range.end;
  653. }
  654. sfc.errors.push(data);
  655. };
  656. }
  657. function start(tag, attrs, unary, start, end) {
  658. if (depth === 0) {
  659. currentBlock = {
  660. type: tag,
  661. content: '',
  662. start: end,
  663. end: 0,
  664. attrs: attrs.reduce((cumulated, { name, value }) => {
  665. cumulated[name] = value || true;
  666. return cumulated;
  667. }, {})
  668. };
  669. if (typeof currentBlock.attrs.src === 'string') {
  670. currentBlock.src = currentBlock.attrs.src;
  671. }
  672. if (isSpecialTag(tag)) {
  673. checkAttrs(currentBlock, attrs);
  674. if (tag === 'script') {
  675. const block = currentBlock;
  676. if (block.attrs.setup) {
  677. block.setup = currentBlock.attrs.setup;
  678. sfc.scriptSetup = block;
  679. }
  680. else {
  681. sfc.script = block;
  682. }
  683. }
  684. else if (tag === 'style') {
  685. sfc.styles.push(currentBlock);
  686. }
  687. else {
  688. sfc[tag] = currentBlock;
  689. }
  690. }
  691. else {
  692. // custom blocks
  693. sfc.customBlocks.push(currentBlock);
  694. }
  695. }
  696. if (!unary) {
  697. depth++;
  698. }
  699. }
  700. function checkAttrs(block, attrs) {
  701. for (let i = 0; i < attrs.length; i++) {
  702. const attr = attrs[i];
  703. if (attr.name === 'lang') {
  704. block.lang = attr.value;
  705. }
  706. if (attr.name === 'scoped') {
  707. block.scoped = true;
  708. }
  709. if (attr.name === 'module') {
  710. block.module = attr.value || true;
  711. }
  712. }
  713. }
  714. function end(tag, start) {
  715. if (depth === 1 && currentBlock) {
  716. currentBlock.end = start;
  717. let text = source.slice(currentBlock.start, currentBlock.end);
  718. if (options.deindent === true ||
  719. // by default, deindent unless it's script with default lang or (j/t)sx?
  720. (options.deindent !== false &&
  721. !(currentBlock.type === 'script' &&
  722. (!currentBlock.lang || /^(j|t)sx?$/.test(currentBlock.lang))))) {
  723. text = deIndent(text);
  724. }
  725. // pad content so that linters and pre-processors can output correct
  726. // line numbers in errors and warnings
  727. if (currentBlock.type !== 'template' && options.pad) {
  728. text = padContent(currentBlock, options.pad) + text;
  729. }
  730. currentBlock.content = text;
  731. currentBlock = null;
  732. }
  733. depth--;
  734. }
  735. function padContent(block, pad) {
  736. if (pad === 'space') {
  737. return source.slice(0, block.start).replace(replaceRE, ' ');
  738. }
  739. else {
  740. const offset = source.slice(0, block.start).split(splitRE$1).length;
  741. const padChar = block.type === 'script' && !block.lang ? '//\n' : '\n';
  742. return Array(offset).join(padChar);
  743. }
  744. }
  745. parseHTML(source, {
  746. warn,
  747. start,
  748. end,
  749. outputSourceRange: options.outputSourceRange
  750. });
  751. return sfc;
  752. }
  753. function pad (hash, len) {
  754. while (hash.length < len) {
  755. hash = '0' + hash;
  756. }
  757. return hash;
  758. }
  759. function fold (hash, text) {
  760. var i;
  761. var chr;
  762. var len;
  763. if (text.length === 0) {
  764. return hash;
  765. }
  766. for (i = 0, len = text.length; i < len; i++) {
  767. chr = text.charCodeAt(i);
  768. hash = ((hash << 5) - hash) + chr;
  769. hash |= 0;
  770. }
  771. return hash < 0 ? hash * -2 : hash;
  772. }
  773. function foldObject (hash, o, seen) {
  774. return Object.keys(o).sort().reduce(foldKey, hash);
  775. function foldKey (hash, key) {
  776. return foldValue(hash, o[key], key, seen);
  777. }
  778. }
  779. function foldValue (input, value, key, seen) {
  780. var hash = fold(fold(fold(input, key), toString$1(value)), typeof value);
  781. if (value === null) {
  782. return fold(hash, 'null');
  783. }
  784. if (value === undefined) {
  785. return fold(hash, 'undefined');
  786. }
  787. if (typeof value === 'object' || typeof value === 'function') {
  788. if (seen.indexOf(value) !== -1) {
  789. return fold(hash, '[Circular]' + key);
  790. }
  791. seen.push(value);
  792. var objHash = foldObject(hash, value, seen);
  793. if (!('valueOf' in value) || typeof value.valueOf !== 'function') {
  794. return objHash;
  795. }
  796. try {
  797. return fold(objHash, String(value.valueOf()))
  798. } catch (err) {
  799. return fold(objHash, '[valueOf exception]' + (err.stack || err.message))
  800. }
  801. }
  802. return fold(hash, value.toString());
  803. }
  804. function toString$1 (o) {
  805. return Object.prototype.toString.call(o);
  806. }
  807. function sum (o) {
  808. return pad(foldValue(0, o, '', []).toString(16), 8);
  809. }
  810. var hashSum = sum;
  811. var iterator;
  812. var hasRequiredIterator;
  813. function requireIterator () {
  814. if (hasRequiredIterator) return iterator;
  815. hasRequiredIterator = 1;
  816. iterator = function (Yallist) {
  817. Yallist.prototype[Symbol.iterator] = function* () {
  818. for (let walker = this.head; walker; walker = walker.next) {
  819. yield walker.value;
  820. }
  821. };
  822. };
  823. return iterator;
  824. }
  825. var yallist = Yallist$1;
  826. Yallist$1.Node = Node;
  827. Yallist$1.create = Yallist$1;
  828. function Yallist$1 (list) {
  829. var self = this;
  830. if (!(self instanceof Yallist$1)) {
  831. self = new Yallist$1();
  832. }
  833. self.tail = null;
  834. self.head = null;
  835. self.length = 0;
  836. if (list && typeof list.forEach === 'function') {
  837. list.forEach(function (item) {
  838. self.push(item);
  839. });
  840. } else if (arguments.length > 0) {
  841. for (var i = 0, l = arguments.length; i < l; i++) {
  842. self.push(arguments[i]);
  843. }
  844. }
  845. return self
  846. }
  847. Yallist$1.prototype.removeNode = function (node) {
  848. if (node.list !== this) {
  849. throw new Error('removing node which does not belong to this list')
  850. }
  851. var next = node.next;
  852. var prev = node.prev;
  853. if (next) {
  854. next.prev = prev;
  855. }
  856. if (prev) {
  857. prev.next = next;
  858. }
  859. if (node === this.head) {
  860. this.head = next;
  861. }
  862. if (node === this.tail) {
  863. this.tail = prev;
  864. }
  865. node.list.length--;
  866. node.next = null;
  867. node.prev = null;
  868. node.list = null;
  869. return next
  870. };
  871. Yallist$1.prototype.unshiftNode = function (node) {
  872. if (node === this.head) {
  873. return
  874. }
  875. if (node.list) {
  876. node.list.removeNode(node);
  877. }
  878. var head = this.head;
  879. node.list = this;
  880. node.next = head;
  881. if (head) {
  882. head.prev = node;
  883. }
  884. this.head = node;
  885. if (!this.tail) {
  886. this.tail = node;
  887. }
  888. this.length++;
  889. };
  890. Yallist$1.prototype.pushNode = function (node) {
  891. if (node === this.tail) {
  892. return
  893. }
  894. if (node.list) {
  895. node.list.removeNode(node);
  896. }
  897. var tail = this.tail;
  898. node.list = this;
  899. node.prev = tail;
  900. if (tail) {
  901. tail.next = node;
  902. }
  903. this.tail = node;
  904. if (!this.head) {
  905. this.head = node;
  906. }
  907. this.length++;
  908. };
  909. Yallist$1.prototype.push = function () {
  910. for (var i = 0, l = arguments.length; i < l; i++) {
  911. push(this, arguments[i]);
  912. }
  913. return this.length
  914. };
  915. Yallist$1.prototype.unshift = function () {
  916. for (var i = 0, l = arguments.length; i < l; i++) {
  917. unshift(this, arguments[i]);
  918. }
  919. return this.length
  920. };
  921. Yallist$1.prototype.pop = function () {
  922. if (!this.tail) {
  923. return undefined
  924. }
  925. var res = this.tail.value;
  926. this.tail = this.tail.prev;
  927. if (this.tail) {
  928. this.tail.next = null;
  929. } else {
  930. this.head = null;
  931. }
  932. this.length--;
  933. return res
  934. };
  935. Yallist$1.prototype.shift = function () {
  936. if (!this.head) {
  937. return undefined
  938. }
  939. var res = this.head.value;
  940. this.head = this.head.next;
  941. if (this.head) {
  942. this.head.prev = null;
  943. } else {
  944. this.tail = null;
  945. }
  946. this.length--;
  947. return res
  948. };
  949. Yallist$1.prototype.forEach = function (fn, thisp) {
  950. thisp = thisp || this;
  951. for (var walker = this.head, i = 0; walker !== null; i++) {
  952. fn.call(thisp, walker.value, i, this);
  953. walker = walker.next;
  954. }
  955. };
  956. Yallist$1.prototype.forEachReverse = function (fn, thisp) {
  957. thisp = thisp || this;
  958. for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
  959. fn.call(thisp, walker.value, i, this);
  960. walker = walker.prev;
  961. }
  962. };
  963. Yallist$1.prototype.get = function (n) {
  964. for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
  965. // abort out of the list early if we hit a cycle
  966. walker = walker.next;
  967. }
  968. if (i === n && walker !== null) {
  969. return walker.value
  970. }
  971. };
  972. Yallist$1.prototype.getReverse = function (n) {
  973. for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
  974. // abort out of the list early if we hit a cycle
  975. walker = walker.prev;
  976. }
  977. if (i === n && walker !== null) {
  978. return walker.value
  979. }
  980. };
  981. Yallist$1.prototype.map = function (fn, thisp) {
  982. thisp = thisp || this;
  983. var res = new Yallist$1();
  984. for (var walker = this.head; walker !== null;) {
  985. res.push(fn.call(thisp, walker.value, this));
  986. walker = walker.next;
  987. }
  988. return res
  989. };
  990. Yallist$1.prototype.mapReverse = function (fn, thisp) {
  991. thisp = thisp || this;
  992. var res = new Yallist$1();
  993. for (var walker = this.tail; walker !== null;) {
  994. res.push(fn.call(thisp, walker.value, this));
  995. walker = walker.prev;
  996. }
  997. return res
  998. };
  999. Yallist$1.prototype.reduce = function (fn, initial) {
  1000. var acc;
  1001. var walker = this.head;
  1002. if (arguments.length > 1) {
  1003. acc = initial;
  1004. } else if (this.head) {
  1005. walker = this.head.next;
  1006. acc = this.head.value;
  1007. } else {
  1008. throw new TypeError('Reduce of empty list with no initial value')
  1009. }
  1010. for (var i = 0; walker !== null; i++) {
  1011. acc = fn(acc, walker.value, i);
  1012. walker = walker.next;
  1013. }
  1014. return acc
  1015. };
  1016. Yallist$1.prototype.reduceReverse = function (fn, initial) {
  1017. var acc;
  1018. var walker = this.tail;
  1019. if (arguments.length > 1) {
  1020. acc = initial;
  1021. } else if (this.tail) {
  1022. walker = this.tail.prev;
  1023. acc = this.tail.value;
  1024. } else {
  1025. throw new TypeError('Reduce of empty list with no initial value')
  1026. }
  1027. for (var i = this.length - 1; walker !== null; i--) {
  1028. acc = fn(acc, walker.value, i);
  1029. walker = walker.prev;
  1030. }
  1031. return acc
  1032. };
  1033. Yallist$1.prototype.toArray = function () {
  1034. var arr = new Array(this.length);
  1035. for (var i = 0, walker = this.head; walker !== null; i++) {
  1036. arr[i] = walker.value;
  1037. walker = walker.next;
  1038. }
  1039. return arr
  1040. };
  1041. Yallist$1.prototype.toArrayReverse = function () {
  1042. var arr = new Array(this.length);
  1043. for (var i = 0, walker = this.tail; walker !== null; i++) {
  1044. arr[i] = walker.value;
  1045. walker = walker.prev;
  1046. }
  1047. return arr
  1048. };
  1049. Yallist$1.prototype.slice = function (from, to) {
  1050. to = to || this.length;
  1051. if (to < 0) {
  1052. to += this.length;
  1053. }
  1054. from = from || 0;
  1055. if (from < 0) {
  1056. from += this.length;
  1057. }
  1058. var ret = new Yallist$1();
  1059. if (to < from || to < 0) {
  1060. return ret
  1061. }
  1062. if (from < 0) {
  1063. from = 0;
  1064. }
  1065. if (to > this.length) {
  1066. to = this.length;
  1067. }
  1068. for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
  1069. walker = walker.next;
  1070. }
  1071. for (; walker !== null && i < to; i++, walker = walker.next) {
  1072. ret.push(walker.value);
  1073. }
  1074. return ret
  1075. };
  1076. Yallist$1.prototype.sliceReverse = function (from, to) {
  1077. to = to || this.length;
  1078. if (to < 0) {
  1079. to += this.length;
  1080. }
  1081. from = from || 0;
  1082. if (from < 0) {
  1083. from += this.length;
  1084. }
  1085. var ret = new Yallist$1();
  1086. if (to < from || to < 0) {
  1087. return ret
  1088. }
  1089. if (from < 0) {
  1090. from = 0;
  1091. }
  1092. if (to > this.length) {
  1093. to = this.length;
  1094. }
  1095. for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
  1096. walker = walker.prev;
  1097. }
  1098. for (; walker !== null && i > from; i--, walker = walker.prev) {
  1099. ret.push(walker.value);
  1100. }
  1101. return ret
  1102. };
  1103. Yallist$1.prototype.splice = function (start, deleteCount /*, ...nodes */) {
  1104. if (start > this.length) {
  1105. start = this.length - 1;
  1106. }
  1107. if (start < 0) {
  1108. start = this.length + start;
  1109. }
  1110. for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
  1111. walker = walker.next;
  1112. }
  1113. var ret = [];
  1114. for (var i = 0; walker && i < deleteCount; i++) {
  1115. ret.push(walker.value);
  1116. walker = this.removeNode(walker);
  1117. }
  1118. if (walker === null) {
  1119. walker = this.tail;
  1120. }
  1121. if (walker !== this.head && walker !== this.tail) {
  1122. walker = walker.prev;
  1123. }
  1124. for (var i = 2; i < arguments.length; i++) {
  1125. walker = insert(this, walker, arguments[i]);
  1126. }
  1127. return ret;
  1128. };
  1129. Yallist$1.prototype.reverse = function () {
  1130. var head = this.head;
  1131. var tail = this.tail;
  1132. for (var walker = head; walker !== null; walker = walker.prev) {
  1133. var p = walker.prev;
  1134. walker.prev = walker.next;
  1135. walker.next = p;
  1136. }
  1137. this.head = tail;
  1138. this.tail = head;
  1139. return this
  1140. };
  1141. function insert (self, node, value) {
  1142. var inserted = node === self.head ?
  1143. new Node(value, null, node, self) :
  1144. new Node(value, node, node.next, self);
  1145. if (inserted.next === null) {
  1146. self.tail = inserted;
  1147. }
  1148. if (inserted.prev === null) {
  1149. self.head = inserted;
  1150. }
  1151. self.length++;
  1152. return inserted
  1153. }
  1154. function push (self, item) {
  1155. self.tail = new Node(item, self.tail, null, self);
  1156. if (!self.head) {
  1157. self.head = self.tail;
  1158. }
  1159. self.length++;
  1160. }
  1161. function unshift (self, item) {
  1162. self.head = new Node(item, null, self.head, self);
  1163. if (!self.tail) {
  1164. self.tail = self.head;
  1165. }
  1166. self.length++;
  1167. }
  1168. function Node (value, prev, next, list) {
  1169. if (!(this instanceof Node)) {
  1170. return new Node(value, prev, next, list)
  1171. }
  1172. this.list = list;
  1173. this.value = value;
  1174. if (prev) {
  1175. prev.next = this;
  1176. this.prev = prev;
  1177. } else {
  1178. this.prev = null;
  1179. }
  1180. if (next) {
  1181. next.prev = this;
  1182. this.next = next;
  1183. } else {
  1184. this.next = null;
  1185. }
  1186. }
  1187. try {
  1188. // add if support for Symbol.iterator is present
  1189. requireIterator()(Yallist$1);
  1190. } catch (er) {}
  1191. // A linked list to keep track of recently-used-ness
  1192. const Yallist = yallist;
  1193. const MAX = Symbol('max');
  1194. const LENGTH = Symbol('length');
  1195. const LENGTH_CALCULATOR = Symbol('lengthCalculator');
  1196. const ALLOW_STALE = Symbol('allowStale');
  1197. const MAX_AGE = Symbol('maxAge');
  1198. const DISPOSE = Symbol('dispose');
  1199. const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet');
  1200. const LRU_LIST = Symbol('lruList');
  1201. const CACHE = Symbol('cache');
  1202. const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet');
  1203. const naiveLength = () => 1;
  1204. // lruList is a yallist where the head is the youngest
  1205. // item, and the tail is the oldest. the list contains the Hit
  1206. // objects as the entries.
  1207. // Each Hit object has a reference to its Yallist.Node. This
  1208. // never changes.
  1209. //
  1210. // cache is a Map (or PseudoMap) that matches the keys to
  1211. // the Yallist.Node object.
  1212. class LRUCache {
  1213. constructor (options) {
  1214. if (typeof options === 'number')
  1215. options = { max: options };
  1216. if (!options)
  1217. options = {};
  1218. if (options.max && (typeof options.max !== 'number' || options.max < 0))
  1219. throw new TypeError('max must be a non-negative number')
  1220. // Kind of weird to have a default max of Infinity, but oh well.
  1221. this[MAX] = options.max || Infinity;
  1222. const lc = options.length || naiveLength;
  1223. this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc;
  1224. this[ALLOW_STALE] = options.stale || false;
  1225. if (options.maxAge && typeof options.maxAge !== 'number')
  1226. throw new TypeError('maxAge must be a number')
  1227. this[MAX_AGE] = options.maxAge || 0;
  1228. this[DISPOSE] = options.dispose;
  1229. this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
  1230. this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false;
  1231. this.reset();
  1232. }
  1233. // resize the cache when the max changes.
  1234. set max (mL) {
  1235. if (typeof mL !== 'number' || mL < 0)
  1236. throw new TypeError('max must be a non-negative number')
  1237. this[MAX] = mL || Infinity;
  1238. trim(this);
  1239. }
  1240. get max () {
  1241. return this[MAX]
  1242. }
  1243. set allowStale (allowStale) {
  1244. this[ALLOW_STALE] = !!allowStale;
  1245. }
  1246. get allowStale () {
  1247. return this[ALLOW_STALE]
  1248. }
  1249. set maxAge (mA) {
  1250. if (typeof mA !== 'number')
  1251. throw new TypeError('maxAge must be a non-negative number')
  1252. this[MAX_AGE] = mA;
  1253. trim(this);
  1254. }
  1255. get maxAge () {
  1256. return this[MAX_AGE]
  1257. }
  1258. // resize the cache when the lengthCalculator changes.
  1259. set lengthCalculator (lC) {
  1260. if (typeof lC !== 'function')
  1261. lC = naiveLength;
  1262. if (lC !== this[LENGTH_CALCULATOR]) {
  1263. this[LENGTH_CALCULATOR] = lC;
  1264. this[LENGTH] = 0;
  1265. this[LRU_LIST].forEach(hit => {
  1266. hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
  1267. this[LENGTH] += hit.length;
  1268. });
  1269. }
  1270. trim(this);
  1271. }
  1272. get lengthCalculator () { return this[LENGTH_CALCULATOR] }
  1273. get length () { return this[LENGTH] }
  1274. get itemCount () { return this[LRU_LIST].length }
  1275. rforEach (fn, thisp) {
  1276. thisp = thisp || this;
  1277. for (let walker = this[LRU_LIST].tail; walker !== null;) {
  1278. const prev = walker.prev;
  1279. forEachStep(this, fn, walker, thisp);
  1280. walker = prev;
  1281. }
  1282. }
  1283. forEach (fn, thisp) {
  1284. thisp = thisp || this;
  1285. for (let walker = this[LRU_LIST].head; walker !== null;) {
  1286. const next = walker.next;
  1287. forEachStep(this, fn, walker, thisp);
  1288. walker = next;
  1289. }
  1290. }
  1291. keys () {
  1292. return this[LRU_LIST].toArray().map(k => k.key)
  1293. }
  1294. values () {
  1295. return this[LRU_LIST].toArray().map(k => k.value)
  1296. }
  1297. reset () {
  1298. if (this[DISPOSE] &&
  1299. this[LRU_LIST] &&
  1300. this[LRU_LIST].length) {
  1301. this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value));
  1302. }
  1303. this[CACHE] = new Map(); // hash of items by key
  1304. this[LRU_LIST] = new Yallist(); // list of items in order of use recency
  1305. this[LENGTH] = 0; // length of items in the list
  1306. }
  1307. dump () {
  1308. return this[LRU_LIST].map(hit =>
  1309. isStale(this, hit) ? false : {
  1310. k: hit.key,
  1311. v: hit.value,
  1312. e: hit.now + (hit.maxAge || 0)
  1313. }).toArray().filter(h => h)
  1314. }
  1315. dumpLru () {
  1316. return this[LRU_LIST]
  1317. }
  1318. set (key, value, maxAge) {
  1319. maxAge = maxAge || this[MAX_AGE];
  1320. if (maxAge && typeof maxAge !== 'number')
  1321. throw new TypeError('maxAge must be a number')
  1322. const now = maxAge ? Date.now() : 0;
  1323. const len = this[LENGTH_CALCULATOR](value, key);
  1324. if (this[CACHE].has(key)) {
  1325. if (len > this[MAX]) {
  1326. del(this, this[CACHE].get(key));
  1327. return false
  1328. }
  1329. const node = this[CACHE].get(key);
  1330. const item = node.value;
  1331. // dispose of the old one before overwriting
  1332. // split out into 2 ifs for better coverage tracking
  1333. if (this[DISPOSE]) {
  1334. if (!this[NO_DISPOSE_ON_SET])
  1335. this[DISPOSE](key, item.value);
  1336. }
  1337. item.now = now;
  1338. item.maxAge = maxAge;
  1339. item.value = value;
  1340. this[LENGTH] += len - item.length;
  1341. item.length = len;
  1342. this.get(key);
  1343. trim(this);
  1344. return true
  1345. }
  1346. const hit = new Entry(key, value, len, now, maxAge);
  1347. // oversized objects fall out of cache automatically.
  1348. if (hit.length > this[MAX]) {
  1349. if (this[DISPOSE])
  1350. this[DISPOSE](key, value);
  1351. return false
  1352. }
  1353. this[LENGTH] += hit.length;
  1354. this[LRU_LIST].unshift(hit);
  1355. this[CACHE].set(key, this[LRU_LIST].head);
  1356. trim(this);
  1357. return true
  1358. }
  1359. has (key) {
  1360. if (!this[CACHE].has(key)) return false
  1361. const hit = this[CACHE].get(key).value;
  1362. return !isStale(this, hit)
  1363. }
  1364. get (key) {
  1365. return get(this, key, true)
  1366. }
  1367. peek (key) {
  1368. return get(this, key, false)
  1369. }
  1370. pop () {
  1371. const node = this[LRU_LIST].tail;
  1372. if (!node)
  1373. return null
  1374. del(this, node);
  1375. return node.value
  1376. }
  1377. del (key) {
  1378. del(this, this[CACHE].get(key));
  1379. }
  1380. load (arr) {
  1381. // reset the cache
  1382. this.reset();
  1383. const now = Date.now();
  1384. // A previous serialized cache has the most recent items first
  1385. for (let l = arr.length - 1; l >= 0; l--) {
  1386. const hit = arr[l];
  1387. const expiresAt = hit.e || 0;
  1388. if (expiresAt === 0)
  1389. // the item was created without expiration in a non aged cache
  1390. this.set(hit.k, hit.v);
  1391. else {
  1392. const maxAge = expiresAt - now;
  1393. // dont add already expired items
  1394. if (maxAge > 0) {
  1395. this.set(hit.k, hit.v, maxAge);
  1396. }
  1397. }
  1398. }
  1399. }
  1400. prune () {
  1401. this[CACHE].forEach((value, key) => get(this, key, false));
  1402. }
  1403. }
  1404. const get = (self, key, doUse) => {
  1405. const node = self[CACHE].get(key);
  1406. if (node) {
  1407. const hit = node.value;
  1408. if (isStale(self, hit)) {
  1409. del(self, node);
  1410. if (!self[ALLOW_STALE])
  1411. return undefined
  1412. } else {
  1413. if (doUse) {
  1414. if (self[UPDATE_AGE_ON_GET])
  1415. node.value.now = Date.now();
  1416. self[LRU_LIST].unshiftNode(node);
  1417. }
  1418. }
  1419. return hit.value
  1420. }
  1421. };
  1422. const isStale = (self, hit) => {
  1423. if (!hit || (!hit.maxAge && !self[MAX_AGE]))
  1424. return false
  1425. const diff = Date.now() - hit.now;
  1426. return hit.maxAge ? diff > hit.maxAge
  1427. : self[MAX_AGE] && (diff > self[MAX_AGE])
  1428. };
  1429. const trim = self => {
  1430. if (self[LENGTH] > self[MAX]) {
  1431. for (let walker = self[LRU_LIST].tail;
  1432. self[LENGTH] > self[MAX] && walker !== null;) {
  1433. // We know that we're about to delete this one, and also
  1434. // what the next least recently used key will be, so just
  1435. // go ahead and set it now.
  1436. const prev = walker.prev;
  1437. del(self, walker);
  1438. walker = prev;
  1439. }
  1440. }
  1441. };
  1442. const del = (self, node) => {
  1443. if (node) {
  1444. const hit = node.value;
  1445. if (self[DISPOSE])
  1446. self[DISPOSE](hit.key, hit.value);
  1447. self[LENGTH] -= hit.length;
  1448. self[CACHE].delete(hit.key);
  1449. self[LRU_LIST].removeNode(node);
  1450. }
  1451. };
  1452. class Entry {
  1453. constructor (key, value, length, now, maxAge) {
  1454. this.key = key;
  1455. this.value = value;
  1456. this.length = length;
  1457. this.now = now;
  1458. this.maxAge = maxAge || 0;
  1459. }
  1460. }
  1461. const forEachStep = (self, fn, node, thisp) => {
  1462. let hit = node.value;
  1463. if (isStale(self, hit)) {
  1464. del(self, node);
  1465. if (!self[ALLOW_STALE])
  1466. hit = undefined;
  1467. }
  1468. if (hit)
  1469. fn.call(thisp, hit.value, hit.key, self);
  1470. };
  1471. var lruCache = LRUCache;
  1472. var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  1473. function encode(decoded) {
  1474. var sourceFileIndex = 0; // second field
  1475. var sourceCodeLine = 0; // third field
  1476. var sourceCodeColumn = 0; // fourth field
  1477. var nameIndex = 0; // fifth field
  1478. var mappings = '';
  1479. for (var i = 0; i < decoded.length; i++) {
  1480. var line = decoded[i];
  1481. if (i > 0)
  1482. mappings += ';';
  1483. if (line.length === 0)
  1484. continue;
  1485. var generatedCodeColumn = 0; // first field
  1486. var lineMappings = [];
  1487. for (var _i = 0, line_1 = line; _i < line_1.length; _i++) {
  1488. var segment = line_1[_i];
  1489. var segmentMappings = encodeInteger(segment[0] - generatedCodeColumn);
  1490. generatedCodeColumn = segment[0];
  1491. if (segment.length > 1) {
  1492. segmentMappings +=
  1493. encodeInteger(segment[1] - sourceFileIndex) +
  1494. encodeInteger(segment[2] - sourceCodeLine) +
  1495. encodeInteger(segment[3] - sourceCodeColumn);
  1496. sourceFileIndex = segment[1];
  1497. sourceCodeLine = segment[2];
  1498. sourceCodeColumn = segment[3];
  1499. }
  1500. if (segment.length === 5) {
  1501. segmentMappings += encodeInteger(segment[4] - nameIndex);
  1502. nameIndex = segment[4];
  1503. }
  1504. lineMappings.push(segmentMappings);
  1505. }
  1506. mappings += lineMappings.join(',');
  1507. }
  1508. return mappings;
  1509. }
  1510. function encodeInteger(num) {
  1511. var result = '';
  1512. num = num < 0 ? (-num << 1) | 1 : num << 1;
  1513. do {
  1514. var clamped = num & 31;
  1515. num >>>= 5;
  1516. if (num > 0) {
  1517. clamped |= 32;
  1518. }
  1519. result += chars[clamped];
  1520. } while (num > 0);
  1521. return result;
  1522. }
  1523. var BitSet = function BitSet(arg) {
  1524. this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
  1525. };
  1526. BitSet.prototype.add = function add (n) {
  1527. this.bits[n >> 5] |= 1 << (n & 31);
  1528. };
  1529. BitSet.prototype.has = function has (n) {
  1530. return !!(this.bits[n >> 5] & (1 << (n & 31)));
  1531. };
  1532. var Chunk = function Chunk(start, end, content) {
  1533. this.start = start;
  1534. this.end = end;
  1535. this.original = content;
  1536. this.intro = '';
  1537. this.outro = '';
  1538. this.content = content;
  1539. this.storeName = false;
  1540. this.edited = false;
  1541. // we make these non-enumerable, for sanity while debugging
  1542. Object.defineProperties(this, {
  1543. previous: { writable: true, value: null },
  1544. next: { writable: true, value: null },
  1545. });
  1546. };
  1547. Chunk.prototype.appendLeft = function appendLeft (content) {
  1548. this.outro += content;
  1549. };
  1550. Chunk.prototype.appendRight = function appendRight (content) {
  1551. this.intro = this.intro + content;
  1552. };
  1553. Chunk.prototype.clone = function clone () {
  1554. var chunk = new Chunk(this.start, this.end, this.original);
  1555. chunk.intro = this.intro;
  1556. chunk.outro = this.outro;
  1557. chunk.content = this.content;
  1558. chunk.storeName = this.storeName;
  1559. chunk.edited = this.edited;
  1560. return chunk;
  1561. };
  1562. Chunk.prototype.contains = function contains (index) {
  1563. return this.start < index && index < this.end;
  1564. };
  1565. Chunk.prototype.eachNext = function eachNext (fn) {
  1566. var chunk = this;
  1567. while (chunk) {
  1568. fn(chunk);
  1569. chunk = chunk.next;
  1570. }
  1571. };
  1572. Chunk.prototype.eachPrevious = function eachPrevious (fn) {
  1573. var chunk = this;
  1574. while (chunk) {
  1575. fn(chunk);
  1576. chunk = chunk.previous;
  1577. }
  1578. };
  1579. Chunk.prototype.edit = function edit (content, storeName, contentOnly) {
  1580. this.content = content;
  1581. if (!contentOnly) {
  1582. this.intro = '';
  1583. this.outro = '';
  1584. }
  1585. this.storeName = storeName;
  1586. this.edited = true;
  1587. return this;
  1588. };
  1589. Chunk.prototype.prependLeft = function prependLeft (content) {
  1590. this.outro = content + this.outro;
  1591. };
  1592. Chunk.prototype.prependRight = function prependRight (content) {
  1593. this.intro = content + this.intro;
  1594. };
  1595. Chunk.prototype.split = function split (index) {
  1596. var sliceIndex = index - this.start;
  1597. var originalBefore = this.original.slice(0, sliceIndex);
  1598. var originalAfter = this.original.slice(sliceIndex);
  1599. this.original = originalBefore;
  1600. var newChunk = new Chunk(index, this.end, originalAfter);
  1601. newChunk.outro = this.outro;
  1602. this.outro = '';
  1603. this.end = index;
  1604. if (this.edited) {
  1605. // TODO is this block necessary?...
  1606. newChunk.edit('', false);
  1607. this.content = '';
  1608. } else {
  1609. this.content = originalBefore;
  1610. }
  1611. newChunk.next = this.next;
  1612. if (newChunk.next) { newChunk.next.previous = newChunk; }
  1613. newChunk.previous = this;
  1614. this.next = newChunk;
  1615. return newChunk;
  1616. };
  1617. Chunk.prototype.toString = function toString () {
  1618. return this.intro + this.content + this.outro;
  1619. };
  1620. Chunk.prototype.trimEnd = function trimEnd (rx) {
  1621. this.outro = this.outro.replace(rx, '');
  1622. if (this.outro.length) { return true; }
  1623. var trimmed = this.content.replace(rx, '');
  1624. if (trimmed.length) {
  1625. if (trimmed !== this.content) {
  1626. this.split(this.start + trimmed.length).edit('', undefined, true);
  1627. }
  1628. return true;
  1629. } else {
  1630. this.edit('', undefined, true);
  1631. this.intro = this.intro.replace(rx, '');
  1632. if (this.intro.length) { return true; }
  1633. }
  1634. };
  1635. Chunk.prototype.trimStart = function trimStart (rx) {
  1636. this.intro = this.intro.replace(rx, '');
  1637. if (this.intro.length) { return true; }
  1638. var trimmed = this.content.replace(rx, '');
  1639. if (trimmed.length) {
  1640. if (trimmed !== this.content) {
  1641. this.split(this.end - trimmed.length);
  1642. this.edit('', undefined, true);
  1643. }
  1644. return true;
  1645. } else {
  1646. this.edit('', undefined, true);
  1647. this.outro = this.outro.replace(rx, '');
  1648. if (this.outro.length) { return true; }
  1649. }
  1650. };
  1651. var btoa = function () {
  1652. throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
  1653. };
  1654. if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
  1655. btoa = function (str) { return window.btoa(unescape(encodeURIComponent(str))); };
  1656. } else if (typeof Buffer === 'function') {
  1657. btoa = function (str) { return Buffer.from(str, 'utf-8').toString('base64'); };
  1658. }
  1659. var SourceMap = function SourceMap(properties) {
  1660. this.version = 3;
  1661. this.file = properties.file;
  1662. this.sources = properties.sources;
  1663. this.sourcesContent = properties.sourcesContent;
  1664. this.names = properties.names;
  1665. this.mappings = encode(properties.mappings);
  1666. };
  1667. SourceMap.prototype.toString = function toString () {
  1668. return JSON.stringify(this);
  1669. };
  1670. SourceMap.prototype.toUrl = function toUrl () {
  1671. return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
  1672. };
  1673. function guessIndent(code) {
  1674. var lines = code.split('\n');
  1675. var tabbed = lines.filter(function (line) { return /^\t+/.test(line); });
  1676. var spaced = lines.filter(function (line) { return /^ {2,}/.test(line); });
  1677. if (tabbed.length === 0 && spaced.length === 0) {
  1678. return null;
  1679. }
  1680. // More lines tabbed than spaced? Assume tabs, and
  1681. // default to tabs in the case of a tie (or nothing
  1682. // to go on)
  1683. if (tabbed.length >= spaced.length) {
  1684. return '\t';
  1685. }
  1686. // Otherwise, we need to guess the multiple
  1687. var min = spaced.reduce(function (previous, current) {
  1688. var numSpaces = /^ +/.exec(current)[0].length;
  1689. return Math.min(numSpaces, previous);
  1690. }, Infinity);
  1691. return new Array(min + 1).join(' ');
  1692. }
  1693. function getRelativePath(from, to) {
  1694. var fromParts = from.split(/[/\\]/);
  1695. var toParts = to.split(/[/\\]/);
  1696. fromParts.pop(); // get dirname
  1697. while (fromParts[0] === toParts[0]) {
  1698. fromParts.shift();
  1699. toParts.shift();
  1700. }
  1701. if (fromParts.length) {
  1702. var i = fromParts.length;
  1703. while (i--) { fromParts[i] = '..'; }
  1704. }
  1705. return fromParts.concat(toParts).join('/');
  1706. }
  1707. var toString = Object.prototype.toString;
  1708. function isObject(thing) {
  1709. return toString.call(thing) === '[object Object]';
  1710. }
  1711. function getLocator(source) {
  1712. var originalLines = source.split('\n');
  1713. var lineOffsets = [];
  1714. for (var i = 0, pos = 0; i < originalLines.length; i++) {
  1715. lineOffsets.push(pos);
  1716. pos += originalLines[i].length + 1;
  1717. }
  1718. return function locate(index) {
  1719. var i = 0;
  1720. var j = lineOffsets.length;
  1721. while (i < j) {
  1722. var m = (i + j) >> 1;
  1723. if (index < lineOffsets[m]) {
  1724. j = m;
  1725. } else {
  1726. i = m + 1;
  1727. }
  1728. }
  1729. var line = i - 1;
  1730. var column = index - lineOffsets[line];
  1731. return { line: line, column: column };
  1732. };
  1733. }
  1734. var Mappings = function Mappings(hires) {
  1735. this.hires = hires;
  1736. this.generatedCodeLine = 0;
  1737. this.generatedCodeColumn = 0;
  1738. this.raw = [];
  1739. this.rawSegments = this.raw[this.generatedCodeLine] = [];
  1740. this.pending = null;
  1741. };
  1742. Mappings.prototype.addEdit = function addEdit (sourceIndex, content, loc, nameIndex) {
  1743. if (content.length) {
  1744. var segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
  1745. if (nameIndex >= 0) {
  1746. segment.push(nameIndex);
  1747. }
  1748. this.rawSegments.push(segment);
  1749. } else if (this.pending) {
  1750. this.rawSegments.push(this.pending);
  1751. }
  1752. this.advance(content);
  1753. this.pending = null;
  1754. };
  1755. Mappings.prototype.addUneditedChunk = function addUneditedChunk (sourceIndex, chunk, original, loc, sourcemapLocations) {
  1756. var originalCharIndex = chunk.start;
  1757. var first = true;
  1758. while (originalCharIndex < chunk.end) {
  1759. if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
  1760. this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
  1761. }
  1762. if (original[originalCharIndex] === '\n') {
  1763. loc.line += 1;
  1764. loc.column = 0;
  1765. this.generatedCodeLine += 1;
  1766. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  1767. this.generatedCodeColumn = 0;
  1768. first = true;
  1769. } else {
  1770. loc.column += 1;
  1771. this.generatedCodeColumn += 1;
  1772. first = false;
  1773. }
  1774. originalCharIndex += 1;
  1775. }
  1776. this.pending = null;
  1777. };
  1778. Mappings.prototype.advance = function advance (str) {
  1779. if (!str) { return; }
  1780. var lines = str.split('\n');
  1781. if (lines.length > 1) {
  1782. for (var i = 0; i < lines.length - 1; i++) {
  1783. this.generatedCodeLine++;
  1784. this.raw[this.generatedCodeLine] = this.rawSegments = [];
  1785. }
  1786. this.generatedCodeColumn = 0;
  1787. }
  1788. this.generatedCodeColumn += lines[lines.length - 1].length;
  1789. };
  1790. var n = '\n';
  1791. var warned = {
  1792. insertLeft: false,
  1793. insertRight: false,
  1794. storeName: false,
  1795. };
  1796. var MagicString = function MagicString(string, options) {
  1797. if ( options === void 0 ) options = {};
  1798. var chunk = new Chunk(0, string.length, string);
  1799. Object.defineProperties(this, {
  1800. original: { writable: true, value: string },
  1801. outro: { writable: true, value: '' },
  1802. intro: { writable: true, value: '' },
  1803. firstChunk: { writable: true, value: chunk },
  1804. lastChunk: { writable: true, value: chunk },
  1805. lastSearchedChunk: { writable: true, value: chunk },
  1806. byStart: { writable: true, value: {} },
  1807. byEnd: { writable: true, value: {} },
  1808. filename: { writable: true, value: options.filename },
  1809. indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
  1810. sourcemapLocations: { writable: true, value: new BitSet() },
  1811. storedNames: { writable: true, value: {} },
  1812. indentStr: { writable: true, value: guessIndent(string) },
  1813. });
  1814. this.byStart[0] = chunk;
  1815. this.byEnd[string.length] = chunk;
  1816. };
  1817. MagicString.prototype.addSourcemapLocation = function addSourcemapLocation (char) {
  1818. this.sourcemapLocations.add(char);
  1819. };
  1820. MagicString.prototype.append = function append (content) {
  1821. if (typeof content !== 'string') { throw new TypeError('outro content must be a string'); }
  1822. this.outro += content;
  1823. return this;
  1824. };
  1825. MagicString.prototype.appendLeft = function appendLeft (index, content) {
  1826. if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
  1827. this._split(index);
  1828. var chunk = this.byEnd[index];
  1829. if (chunk) {
  1830. chunk.appendLeft(content);
  1831. } else {
  1832. this.intro += content;
  1833. }
  1834. return this;
  1835. };
  1836. MagicString.prototype.appendRight = function appendRight (index, content) {
  1837. if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
  1838. this._split(index);
  1839. var chunk = this.byStart[index];
  1840. if (chunk) {
  1841. chunk.appendRight(content);
  1842. } else {
  1843. this.outro += content;
  1844. }
  1845. return this;
  1846. };
  1847. MagicString.prototype.clone = function clone () {
  1848. var cloned = new MagicString(this.original, { filename: this.filename });
  1849. var originalChunk = this.firstChunk;
  1850. var clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
  1851. while (originalChunk) {
  1852. cloned.byStart[clonedChunk.start] = clonedChunk;
  1853. cloned.byEnd[clonedChunk.end] = clonedChunk;
  1854. var nextOriginalChunk = originalChunk.next;
  1855. var nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
  1856. if (nextClonedChunk) {
  1857. clonedChunk.next = nextClonedChunk;
  1858. nextClonedChunk.previous = clonedChunk;
  1859. clonedChunk = nextClonedChunk;
  1860. }
  1861. originalChunk = nextOriginalChunk;
  1862. }
  1863. cloned.lastChunk = clonedChunk;
  1864. if (this.indentExclusionRanges) {
  1865. cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
  1866. }
  1867. cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
  1868. cloned.intro = this.intro;
  1869. cloned.outro = this.outro;
  1870. return cloned;
  1871. };
  1872. MagicString.prototype.generateDecodedMap = function generateDecodedMap (options) {
  1873. var this$1$1 = this;
  1874. options = options || {};
  1875. var sourceIndex = 0;
  1876. var names = Object.keys(this.storedNames);
  1877. var mappings = new Mappings(options.hires);
  1878. var locate = getLocator(this.original);
  1879. if (this.intro) {
  1880. mappings.advance(this.intro);
  1881. }
  1882. this.firstChunk.eachNext(function (chunk) {
  1883. var loc = locate(chunk.start);
  1884. if (chunk.intro.length) { mappings.advance(chunk.intro); }
  1885. if (chunk.edited) {
  1886. mappings.addEdit(
  1887. sourceIndex,
  1888. chunk.content,
  1889. loc,
  1890. chunk.storeName ? names.indexOf(chunk.original) : -1
  1891. );
  1892. } else {
  1893. mappings.addUneditedChunk(sourceIndex, chunk, this$1$1.original, loc, this$1$1.sourcemapLocations);
  1894. }
  1895. if (chunk.outro.length) { mappings.advance(chunk.outro); }
  1896. });
  1897. return {
  1898. file: options.file ? options.file.split(/[/\\]/).pop() : null,
  1899. sources: [options.source ? getRelativePath(options.file || '', options.source) : null],
  1900. sourcesContent: options.includeContent ? [this.original] : [null],
  1901. names: names,
  1902. mappings: mappings.raw,
  1903. };
  1904. };
  1905. MagicString.prototype.generateMap = function generateMap (options) {
  1906. return new SourceMap(this.generateDecodedMap(options));
  1907. };
  1908. MagicString.prototype.getIndentString = function getIndentString () {
  1909. return this.indentStr === null ? '\t' : this.indentStr;
  1910. };
  1911. MagicString.prototype.indent = function indent (indentStr, options) {
  1912. var pattern = /^[^\r\n]/gm;
  1913. if (isObject(indentStr)) {
  1914. options = indentStr;
  1915. indentStr = undefined;
  1916. }
  1917. indentStr = indentStr !== undefined ? indentStr : this.indentStr || '\t';
  1918. if (indentStr === '') { return this; } // noop
  1919. options = options || {};
  1920. // Process exclusion ranges
  1921. var isExcluded = {};
  1922. if (options.exclude) {
  1923. var exclusions =
  1924. typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
  1925. exclusions.forEach(function (exclusion) {
  1926. for (var i = exclusion[0]; i < exclusion[1]; i += 1) {
  1927. isExcluded[i] = true;
  1928. }
  1929. });
  1930. }
  1931. var shouldIndentNextCharacter = options.indentStart !== false;
  1932. var replacer = function (match) {
  1933. if (shouldIndentNextCharacter) { return ("" + indentStr + match); }
  1934. shouldIndentNextCharacter = true;
  1935. return match;
  1936. };
  1937. this.intro = this.intro.replace(pattern, replacer);
  1938. var charIndex = 0;
  1939. var chunk = this.firstChunk;
  1940. while (chunk) {
  1941. var end = chunk.end;
  1942. if (chunk.edited) {
  1943. if (!isExcluded[charIndex]) {
  1944. chunk.content = chunk.content.replace(pattern, replacer);
  1945. if (chunk.content.length) {
  1946. shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
  1947. }
  1948. }
  1949. } else {
  1950. charIndex = chunk.start;
  1951. while (charIndex < end) {
  1952. if (!isExcluded[charIndex]) {
  1953. var char = this.original[charIndex];
  1954. if (char === '\n') {
  1955. shouldIndentNextCharacter = true;
  1956. } else if (char !== '\r' && shouldIndentNextCharacter) {
  1957. shouldIndentNextCharacter = false;
  1958. if (charIndex === chunk.start) {
  1959. chunk.prependRight(indentStr);
  1960. } else {
  1961. this._splitChunk(chunk, charIndex);
  1962. chunk = chunk.next;
  1963. chunk.prependRight(indentStr);
  1964. }
  1965. }
  1966. }
  1967. charIndex += 1;
  1968. }
  1969. }
  1970. charIndex = chunk.end;
  1971. chunk = chunk.next;
  1972. }
  1973. this.outro = this.outro.replace(pattern, replacer);
  1974. return this;
  1975. };
  1976. MagicString.prototype.insert = function insert () {
  1977. throw new Error(
  1978. 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)'
  1979. );
  1980. };
  1981. MagicString.prototype.insertLeft = function insertLeft (index, content) {
  1982. if (!warned.insertLeft) {
  1983. console.warn(
  1984. 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead'
  1985. ); // eslint-disable-line no-console
  1986. warned.insertLeft = true;
  1987. }
  1988. return this.appendLeft(index, content);
  1989. };
  1990. MagicString.prototype.insertRight = function insertRight (index, content) {
  1991. if (!warned.insertRight) {
  1992. console.warn(
  1993. 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead'
  1994. ); // eslint-disable-line no-console
  1995. warned.insertRight = true;
  1996. }
  1997. return this.prependRight(index, content);
  1998. };
  1999. MagicString.prototype.move = function move (start, end, index) {
  2000. if (index >= start && index <= end) { throw new Error('Cannot move a selection inside itself'); }
  2001. this._split(start);
  2002. this._split(end);
  2003. this._split(index);
  2004. var first = this.byStart[start];
  2005. var last = this.byEnd[end];
  2006. var oldLeft = first.previous;
  2007. var oldRight = last.next;
  2008. var newRight = this.byStart[index];
  2009. if (!newRight && last === this.lastChunk) { return this; }
  2010. var newLeft = newRight ? newRight.previous : this.lastChunk;
  2011. if (oldLeft) { oldLeft.next = oldRight; }
  2012. if (oldRight) { oldRight.previous = oldLeft; }
  2013. if (newLeft) { newLeft.next = first; }
  2014. if (newRight) { newRight.previous = last; }
  2015. if (!first.previous) { this.firstChunk = last.next; }
  2016. if (!last.next) {
  2017. this.lastChunk = first.previous;
  2018. this.lastChunk.next = null;
  2019. }
  2020. first.previous = newLeft;
  2021. last.next = newRight || null;
  2022. if (!newLeft) { this.firstChunk = first; }
  2023. if (!newRight) { this.lastChunk = last; }
  2024. return this;
  2025. };
  2026. MagicString.prototype.overwrite = function overwrite (start, end, content, options) {
  2027. if (typeof content !== 'string') { throw new TypeError('replacement content must be a string'); }
  2028. while (start < 0) { start += this.original.length; }
  2029. while (end < 0) { end += this.original.length; }
  2030. if (end > this.original.length) { throw new Error('end is out of bounds'); }
  2031. if (start === end)
  2032. { throw new Error(
  2033. 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead'
  2034. ); }
  2035. this._split(start);
  2036. this._split(end);
  2037. if (options === true) {
  2038. if (!warned.storeName) {
  2039. console.warn(
  2040. 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string'
  2041. ); // eslint-disable-line no-console
  2042. warned.storeName = true;
  2043. }
  2044. options = { storeName: true };
  2045. }
  2046. var storeName = options !== undefined ? options.storeName : false;
  2047. var contentOnly = options !== undefined ? options.contentOnly : false;
  2048. if (storeName) {
  2049. var original = this.original.slice(start, end);
  2050. Object.defineProperty(this.storedNames, original, { writable: true, value: true, enumerable: true });
  2051. }
  2052. var first = this.byStart[start];
  2053. var last = this.byEnd[end];
  2054. if (first) {
  2055. var chunk = first;
  2056. while (chunk !== last) {
  2057. if (chunk.next !== this.byStart[chunk.end]) {
  2058. throw new Error('Cannot overwrite across a split point');
  2059. }
  2060. chunk = chunk.next;
  2061. chunk.edit('', false);
  2062. }
  2063. first.edit(content, storeName, contentOnly);
  2064. } else {
  2065. // must be inserting at the end
  2066. var newChunk = new Chunk(start, end, '').edit(content, storeName);
  2067. // TODO last chunk in the array may not be the last chunk, if it's moved...
  2068. last.next = newChunk;
  2069. newChunk.previous = last;
  2070. }
  2071. return this;
  2072. };
  2073. MagicString.prototype.prepend = function prepend (content) {
  2074. if (typeof content !== 'string') { throw new TypeError('outro content must be a string'); }
  2075. this.intro = content + this.intro;
  2076. return this;
  2077. };
  2078. MagicString.prototype.prependLeft = function prependLeft (index, content) {
  2079. if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
  2080. this._split(index);
  2081. var chunk = this.byEnd[index];
  2082. if (chunk) {
  2083. chunk.prependLeft(content);
  2084. } else {
  2085. this.intro = content + this.intro;
  2086. }
  2087. return this;
  2088. };
  2089. MagicString.prototype.prependRight = function prependRight (index, content) {
  2090. if (typeof content !== 'string') { throw new TypeError('inserted content must be a string'); }
  2091. this._split(index);
  2092. var chunk = this.byStart[index];
  2093. if (chunk) {
  2094. chunk.prependRight(content);
  2095. } else {
  2096. this.outro = content + this.outro;
  2097. }
  2098. return this;
  2099. };
  2100. MagicString.prototype.remove = function remove (start, end) {
  2101. while (start < 0) { start += this.original.length; }
  2102. while (end < 0) { end += this.original.length; }
  2103. if (start === end) { return this; }
  2104. if (start < 0 || end > this.original.length) { throw new Error('Character is out of bounds'); }
  2105. if (start > end) { throw new Error('end must be greater than start'); }
  2106. this._split(start);
  2107. this._split(end);
  2108. var chunk = this.byStart[start];
  2109. while (chunk) {
  2110. chunk.intro = '';
  2111. chunk.outro = '';
  2112. chunk.edit('');
  2113. chunk = end > chunk.end ? this.byStart[chunk.end] : null;
  2114. }
  2115. return this;
  2116. };
  2117. MagicString.prototype.lastChar = function lastChar () {
  2118. if (this.outro.length) { return this.outro[this.outro.length - 1]; }
  2119. var chunk = this.lastChunk;
  2120. do {
  2121. if (chunk.outro.length) { return chunk.outro[chunk.outro.length - 1]; }
  2122. if (chunk.content.length) { return chunk.content[chunk.content.length - 1]; }
  2123. if (chunk.intro.length) { return chunk.intro[chunk.intro.length - 1]; }
  2124. } while ((chunk = chunk.previous));
  2125. if (this.intro.length) { return this.intro[this.intro.length - 1]; }
  2126. return '';
  2127. };
  2128. MagicString.prototype.lastLine = function lastLine () {
  2129. var lineIndex = this.outro.lastIndexOf(n);
  2130. if (lineIndex !== -1) { return this.outro.substr(lineIndex + 1); }
  2131. var lineStr = this.outro;
  2132. var chunk = this.lastChunk;
  2133. do {
  2134. if (chunk.outro.length > 0) {
  2135. lineIndex = chunk.outro.lastIndexOf(n);
  2136. if (lineIndex !== -1) { return chunk.outro.substr(lineIndex + 1) + lineStr; }
  2137. lineStr = chunk.outro + lineStr;
  2138. }
  2139. if (chunk.content.length > 0) {
  2140. lineIndex = chunk.content.lastIndexOf(n);
  2141. if (lineIndex !== -1) { return chunk.content.substr(lineIndex + 1) + lineStr; }
  2142. lineStr = chunk.content + lineStr;
  2143. }
  2144. if (chunk.intro.length > 0) {
  2145. lineIndex = chunk.intro.lastIndexOf(n);
  2146. if (lineIndex !== -1) { return chunk.intro.substr(lineIndex + 1) + lineStr; }
  2147. lineStr = chunk.intro + lineStr;
  2148. }
  2149. } while ((chunk = chunk.previous));
  2150. lineIndex = this.intro.lastIndexOf(n);
  2151. if (lineIndex !== -1) { return this.intro.substr(lineIndex + 1) + lineStr; }
  2152. return this.intro + lineStr;
  2153. };
  2154. MagicString.prototype.slice = function slice (start, end) {
  2155. if ( start === void 0 ) start = 0;
  2156. if ( end === void 0 ) end = this.original.length;
  2157. while (start < 0) { start += this.original.length; }
  2158. while (end < 0) { end += this.original.length; }
  2159. var result = '';
  2160. // find start chunk
  2161. var chunk = this.firstChunk;
  2162. while (chunk && (chunk.start > start || chunk.end <= start)) {
  2163. // found end chunk before start
  2164. if (chunk.start < end && chunk.end >= end) {
  2165. return result;
  2166. }
  2167. chunk = chunk.next;
  2168. }
  2169. if (chunk && chunk.edited && chunk.start !== start)
  2170. { throw new Error(("Cannot use replaced character " + start + " as slice start anchor.")); }
  2171. var startChunk = chunk;
  2172. while (chunk) {
  2173. if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
  2174. result += chunk.intro;
  2175. }
  2176. var containsEnd = chunk.start < end && chunk.end >= end;
  2177. if (containsEnd && chunk.edited && chunk.end !== end)
  2178. { throw new Error(("Cannot use replaced character " + end + " as slice end anchor.")); }
  2179. var sliceStart = startChunk === chunk ? start - chunk.start : 0;
  2180. var sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
  2181. result += chunk.content.slice(sliceStart, sliceEnd);
  2182. if (chunk.outro && (!containsEnd || chunk.end === end)) {
  2183. result += chunk.outro;
  2184. }
  2185. if (containsEnd) {
  2186. break;
  2187. }
  2188. chunk = chunk.next;
  2189. }
  2190. return result;
  2191. };
  2192. // TODO deprecate this? not really very useful
  2193. MagicString.prototype.snip = function snip (start, end) {
  2194. var clone = this.clone();
  2195. clone.remove(0, start);
  2196. clone.remove(end, clone.original.length);
  2197. return clone;
  2198. };
  2199. MagicString.prototype._split = function _split (index) {
  2200. if (this.byStart[index] || this.byEnd[index]) { return; }
  2201. var chunk = this.lastSearchedChunk;
  2202. var searchForward = index > chunk.end;
  2203. while (chunk) {
  2204. if (chunk.contains(index)) { return this._splitChunk(chunk, index); }
  2205. chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
  2206. }
  2207. };
  2208. MagicString.prototype._splitChunk = function _splitChunk (chunk, index) {
  2209. if (chunk.edited && chunk.content.length) {
  2210. // zero-length edited chunks are a special case (overlapping replacements)
  2211. var loc = getLocator(this.original)(index);
  2212. throw new Error(
  2213. ("Cannot split a chunk that has already been edited (" + (loc.line) + ":" + (loc.column) + " – \"" + (chunk.original) + "\")")
  2214. );
  2215. }
  2216. var newChunk = chunk.split(index);
  2217. this.byEnd[index] = chunk;
  2218. this.byStart[index] = newChunk;
  2219. this.byEnd[newChunk.end] = newChunk;
  2220. if (chunk === this.lastChunk) { this.lastChunk = newChunk; }
  2221. this.lastSearchedChunk = chunk;
  2222. return true;
  2223. };
  2224. MagicString.prototype.toString = function toString () {
  2225. var str = this.intro;
  2226. var chunk = this.firstChunk;
  2227. while (chunk) {
  2228. str += chunk.toString();
  2229. chunk = chunk.next;
  2230. }
  2231. return str + this.outro;
  2232. };
  2233. MagicString.prototype.isEmpty = function isEmpty () {
  2234. var chunk = this.firstChunk;
  2235. do {
  2236. if (
  2237. (chunk.intro.length && chunk.intro.trim()) ||
  2238. (chunk.content.length && chunk.content.trim()) ||
  2239. (chunk.outro.length && chunk.outro.trim())
  2240. )
  2241. { return false; }
  2242. } while ((chunk = chunk.next));
  2243. return true;
  2244. };
  2245. MagicString.prototype.length = function length () {
  2246. var chunk = this.firstChunk;
  2247. var length = 0;
  2248. do {
  2249. length += chunk.intro.length + chunk.content.length + chunk.outro.length;
  2250. } while ((chunk = chunk.next));
  2251. return length;
  2252. };
  2253. MagicString.prototype.trimLines = function trimLines () {
  2254. return this.trim('[\\r\\n]');
  2255. };
  2256. MagicString.prototype.trim = function trim (charType) {
  2257. return this.trimStart(charType).trimEnd(charType);
  2258. };
  2259. MagicString.prototype.trimEndAborted = function trimEndAborted (charType) {
  2260. var rx = new RegExp((charType || '\\s') + '+$');
  2261. this.outro = this.outro.replace(rx, '');
  2262. if (this.outro.length) { return true; }
  2263. var chunk = this.lastChunk;
  2264. do {
  2265. var end = chunk.end;
  2266. var aborted = chunk.trimEnd(rx);
  2267. // if chunk was trimmed, we have a new lastChunk
  2268. if (chunk.end !== end) {
  2269. if (this.lastChunk === chunk) {
  2270. this.lastChunk = chunk.next;
  2271. }
  2272. this.byEnd[chunk.end] = chunk;
  2273. this.byStart[chunk.next.start] = chunk.next;
  2274. this.byEnd[chunk.next.end] = chunk.next;
  2275. }
  2276. if (aborted) { return true; }
  2277. chunk = chunk.previous;
  2278. } while (chunk);
  2279. return false;
  2280. };
  2281. MagicString.prototype.trimEnd = function trimEnd (charType) {
  2282. this.trimEndAborted(charType);
  2283. return this;
  2284. };
  2285. MagicString.prototype.trimStartAborted = function trimStartAborted (charType) {
  2286. var rx = new RegExp('^' + (charType || '\\s') + '+');
  2287. this.intro = this.intro.replace(rx, '');
  2288. if (this.intro.length) { return true; }
  2289. var chunk = this.firstChunk;
  2290. do {
  2291. var end = chunk.end;
  2292. var aborted = chunk.trimStart(rx);
  2293. if (chunk.end !== end) {
  2294. // special case...
  2295. if (chunk === this.lastChunk) { this.lastChunk = chunk.next; }
  2296. this.byEnd[chunk.end] = chunk;
  2297. this.byStart[chunk.next.start] = chunk.next;
  2298. this.byEnd[chunk.next.end] = chunk.next;
  2299. }
  2300. if (aborted) { return true; }
  2301. chunk = chunk.next;
  2302. } while (chunk);
  2303. return false;
  2304. };
  2305. MagicString.prototype.trimStart = function trimStart (charType) {
  2306. this.trimStartAborted(charType);
  2307. return this;
  2308. };
  2309. // @ts-check
  2310. /** @typedef { import('estree').BaseNode} BaseNode */
  2311. /** @typedef {{
  2312. skip: () => void;
  2313. remove: () => void;
  2314. replace: (node: BaseNode) => void;
  2315. }} WalkerContext */
  2316. class WalkerBase {
  2317. constructor() {
  2318. /** @type {boolean} */
  2319. this.should_skip = false;
  2320. /** @type {boolean} */
  2321. this.should_remove = false;
  2322. /** @type {BaseNode | null} */
  2323. this.replacement = null;
  2324. /** @type {WalkerContext} */
  2325. this.context = {
  2326. skip: () => (this.should_skip = true),
  2327. remove: () => (this.should_remove = true),
  2328. replace: (node) => (this.replacement = node)
  2329. };
  2330. }
  2331. /**
  2332. *
  2333. * @param {any} parent
  2334. * @param {string} prop
  2335. * @param {number} index
  2336. * @param {BaseNode} node
  2337. */
  2338. replace(parent, prop, index, node) {
  2339. if (parent) {
  2340. if (index !== null) {
  2341. parent[prop][index] = node;
  2342. } else {
  2343. parent[prop] = node;
  2344. }
  2345. }
  2346. }
  2347. /**
  2348. *
  2349. * @param {any} parent
  2350. * @param {string} prop
  2351. * @param {number} index
  2352. */
  2353. remove(parent, prop, index) {
  2354. if (parent) {
  2355. if (index !== null) {
  2356. parent[prop].splice(index, 1);
  2357. } else {
  2358. delete parent[prop];
  2359. }
  2360. }
  2361. }
  2362. }
  2363. // @ts-check
  2364. /** @typedef { import('estree').BaseNode} BaseNode */
  2365. /** @typedef { import('./walker.js').WalkerContext} WalkerContext */
  2366. /** @typedef {(
  2367. * this: WalkerContext,
  2368. * node: BaseNode,
  2369. * parent: BaseNode,
  2370. * key: string,
  2371. * index: number
  2372. * ) => void} SyncHandler */
  2373. class SyncWalker extends WalkerBase {
  2374. /**
  2375. *
  2376. * @param {SyncHandler} enter
  2377. * @param {SyncHandler} leave
  2378. */
  2379. constructor(enter, leave) {
  2380. super();
  2381. /** @type {SyncHandler} */
  2382. this.enter = enter;
  2383. /** @type {SyncHandler} */
  2384. this.leave = leave;
  2385. }
  2386. /**
  2387. *
  2388. * @param {BaseNode} node
  2389. * @param {BaseNode} parent
  2390. * @param {string} [prop]
  2391. * @param {number} [index]
  2392. * @returns {BaseNode}
  2393. */
  2394. visit(node, parent, prop, index) {
  2395. if (node) {
  2396. if (this.enter) {
  2397. const _should_skip = this.should_skip;
  2398. const _should_remove = this.should_remove;
  2399. const _replacement = this.replacement;
  2400. this.should_skip = false;
  2401. this.should_remove = false;
  2402. this.replacement = null;
  2403. this.enter.call(this.context, node, parent, prop, index);
  2404. if (this.replacement) {
  2405. node = this.replacement;
  2406. this.replace(parent, prop, index, node);
  2407. }
  2408. if (this.should_remove) {
  2409. this.remove(parent, prop, index);
  2410. }
  2411. const skipped = this.should_skip;
  2412. const removed = this.should_remove;
  2413. this.should_skip = _should_skip;
  2414. this.should_remove = _should_remove;
  2415. this.replacement = _replacement;
  2416. if (skipped) return node;
  2417. if (removed) return null;
  2418. }
  2419. for (const key in node) {
  2420. const value = node[key];
  2421. if (typeof value !== "object") {
  2422. continue;
  2423. } else if (Array.isArray(value)) {
  2424. for (let i = 0; i < value.length; i += 1) {
  2425. if (value[i] !== null && typeof value[i].type === 'string') {
  2426. if (!this.visit(value[i], node, key, i)) {
  2427. // removed
  2428. i--;
  2429. }
  2430. }
  2431. }
  2432. } else if (value !== null && typeof value.type === "string") {
  2433. this.visit(value, node, key, null);
  2434. }
  2435. }
  2436. if (this.leave) {
  2437. const _replacement = this.replacement;
  2438. const _should_remove = this.should_remove;
  2439. this.replacement = null;
  2440. this.should_remove = false;
  2441. this.leave.call(this.context, node, parent, prop, index);
  2442. if (this.replacement) {
  2443. node = this.replacement;
  2444. this.replace(parent, prop, index, node);
  2445. }
  2446. if (this.should_remove) {
  2447. this.remove(parent, prop, index);
  2448. }
  2449. const removed = this.should_remove;
  2450. this.replacement = _replacement;
  2451. this.should_remove = _should_remove;
  2452. if (removed) return null;
  2453. }
  2454. }
  2455. return node;
  2456. }
  2457. }
  2458. // @ts-check
  2459. /** @typedef { import('estree').BaseNode} BaseNode */
  2460. /** @typedef { import('./sync.js').SyncHandler} SyncHandler */
  2461. /** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
  2462. /**
  2463. *
  2464. * @param {BaseNode} ast
  2465. * @param {{
  2466. * enter?: SyncHandler
  2467. * leave?: SyncHandler
  2468. * }} walker
  2469. * @returns {BaseNode}
  2470. */
  2471. function walk$1(ast, { enter, leave }) {
  2472. const instance = new SyncWalker(enter, leave);
  2473. return instance.visit(ast, null);
  2474. }
  2475. // https://github.com/vuejs/core/blob/main/packages/compiler-core/src/babelUtils.ts
  2476. function walkIdentifiers(root, onIdentifier, onNode) {
  2477. const parentStack = [];
  2478. const knownIds = Object.create(null);
  2479. const rootExp = root.type === 'Program' &&
  2480. root.body[0].type === 'ExpressionStatement' &&
  2481. root.body[0].expression;
  2482. walk$1(root, {
  2483. enter(node, parent) {
  2484. parent && parentStack.push(parent);
  2485. if (parent &&
  2486. parent.type.startsWith('TS') &&
  2487. parent.type !== 'TSAsExpression' &&
  2488. parent.type !== 'TSNonNullExpression' &&
  2489. parent.type !== 'TSTypeAssertion') {
  2490. return this.skip();
  2491. }
  2492. if (onNode)
  2493. onNode(node);
  2494. if (node.type === 'Identifier') {
  2495. const isLocal = !!knownIds[node.name];
  2496. const isRefed = isReferencedIdentifier(node, parent, parentStack);
  2497. if ((isRefed && !isLocal)) {
  2498. onIdentifier(node, parent, parentStack, isRefed, isLocal);
  2499. }
  2500. }
  2501. else if (node.type === 'ObjectProperty' &&
  2502. parent.type === 'ObjectPattern') {
  2503. node.inPattern = true;
  2504. }
  2505. else if (isFunctionType(node)) {
  2506. // walk function expressions and add its arguments to known identifiers
  2507. // so that we don't prefix them
  2508. walkFunctionParams(node, id => markScopeIdentifier(node, id, knownIds));
  2509. }
  2510. else if (node.type === 'BlockStatement') {
  2511. // #3445 record block-level local variables
  2512. walkBlockDeclarations(node, id => markScopeIdentifier(node, id, knownIds));
  2513. }
  2514. },
  2515. leave(node, parent) {
  2516. parent && parentStack.pop();
  2517. if (node !== rootExp && node.scopeIds) {
  2518. for (const id of node.scopeIds) {
  2519. knownIds[id]--;
  2520. if (knownIds[id] === 0) {
  2521. delete knownIds[id];
  2522. }
  2523. }
  2524. }
  2525. }
  2526. });
  2527. }
  2528. function isReferencedIdentifier(id, parent, parentStack) {
  2529. if (!parent) {
  2530. return true;
  2531. }
  2532. // is a special keyword but parsed as identifier
  2533. if (id.name === 'arguments') {
  2534. return false;
  2535. }
  2536. if (isReferenced(id, parent)) {
  2537. return true;
  2538. }
  2539. // babel's isReferenced check returns false for ids being assigned to, so we
  2540. // need to cover those cases here
  2541. switch (parent.type) {
  2542. case 'AssignmentExpression':
  2543. case 'AssignmentPattern':
  2544. return true;
  2545. case 'ObjectPattern':
  2546. case 'ArrayPattern':
  2547. return isInDestructureAssignment(parent, parentStack);
  2548. }
  2549. return false;
  2550. }
  2551. function isInDestructureAssignment(parent, parentStack) {
  2552. if (parent &&
  2553. (parent.type === 'ObjectProperty' || parent.type === 'ArrayPattern')) {
  2554. let i = parentStack.length;
  2555. while (i--) {
  2556. const p = parentStack[i];
  2557. if (p.type === 'AssignmentExpression') {
  2558. return true;
  2559. }
  2560. else if (p.type !== 'ObjectProperty' && !p.type.endsWith('Pattern')) {
  2561. break;
  2562. }
  2563. }
  2564. }
  2565. return false;
  2566. }
  2567. function walkFunctionParams(node, onIdent) {
  2568. for (const p of node.params) {
  2569. for (const id of extractIdentifiers(p)) {
  2570. onIdent(id);
  2571. }
  2572. }
  2573. }
  2574. function walkBlockDeclarations(block, onIdent) {
  2575. for (const stmt of block.body) {
  2576. if (stmt.type === 'VariableDeclaration') {
  2577. if (stmt.declare)
  2578. continue;
  2579. for (const decl of stmt.declarations) {
  2580. for (const id of extractIdentifiers(decl.id)) {
  2581. onIdent(id);
  2582. }
  2583. }
  2584. }
  2585. else if (stmt.type === 'FunctionDeclaration' ||
  2586. stmt.type === 'ClassDeclaration') {
  2587. if (stmt.declare || !stmt.id)
  2588. continue;
  2589. onIdent(stmt.id);
  2590. }
  2591. }
  2592. }
  2593. function extractIdentifiers(param, nodes = []) {
  2594. switch (param.type) {
  2595. case 'Identifier':
  2596. nodes.push(param);
  2597. break;
  2598. case 'MemberExpression':
  2599. let object = param;
  2600. while (object.type === 'MemberExpression') {
  2601. object = object.object;
  2602. }
  2603. nodes.push(object);
  2604. break;
  2605. case 'ObjectPattern':
  2606. for (const prop of param.properties) {
  2607. if (prop.type === 'RestElement') {
  2608. extractIdentifiers(prop.argument, nodes);
  2609. }
  2610. else {
  2611. extractIdentifiers(prop.value, nodes);
  2612. }
  2613. }
  2614. break;
  2615. case 'ArrayPattern':
  2616. param.elements.forEach(element => {
  2617. if (element)
  2618. extractIdentifiers(element, nodes);
  2619. });
  2620. break;
  2621. case 'RestElement':
  2622. extractIdentifiers(param.argument, nodes);
  2623. break;
  2624. case 'AssignmentPattern':
  2625. extractIdentifiers(param.left, nodes);
  2626. break;
  2627. }
  2628. return nodes;
  2629. }
  2630. function markScopeIdentifier(node, child, knownIds) {
  2631. const { name } = child;
  2632. if (node.scopeIds && node.scopeIds.has(name)) {
  2633. return;
  2634. }
  2635. if (name in knownIds) {
  2636. knownIds[name]++;
  2637. }
  2638. else {
  2639. knownIds[name] = 1;
  2640. }
  2641. (node.scopeIds || (node.scopeIds = new Set())).add(name);
  2642. }
  2643. const isFunctionType = (node) => {
  2644. return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
  2645. };
  2646. const isStaticProperty = (node) => node &&
  2647. (node.type === 'ObjectProperty' || node.type === 'ObjectMethod') &&
  2648. !node.computed;
  2649. /**
  2650. * Copied from https://github.com/babel/babel/blob/main/packages/babel-types/src/validators/isReferenced.ts
  2651. * To avoid runtime dependency on @babel/types (which includes process references)
  2652. * This file should not change very often in babel but we may need to keep it
  2653. * up-to-date from time to time.
  2654. *
  2655. * https://github.com/babel/babel/blob/main/LICENSE
  2656. *
  2657. */
  2658. function isReferenced(node, parent, grandparent) {
  2659. switch (parent.type) {
  2660. // yes: PARENT[NODE]
  2661. // yes: NODE.child
  2662. // no: parent.NODE
  2663. case 'MemberExpression':
  2664. case 'OptionalMemberExpression':
  2665. if (parent.property === node) {
  2666. return !!parent.computed;
  2667. }
  2668. return parent.object === node;
  2669. case 'JSXMemberExpression':
  2670. return parent.object === node;
  2671. // no: let NODE = init;
  2672. // yes: let id = NODE;
  2673. case 'VariableDeclarator':
  2674. return parent.init === node;
  2675. // yes: () => NODE
  2676. // no: (NODE) => {}
  2677. case 'ArrowFunctionExpression':
  2678. return parent.body === node;
  2679. // no: class { #NODE; }
  2680. // no: class { get #NODE() {} }
  2681. // no: class { #NODE() {} }
  2682. // no: class { fn() { return this.#NODE; } }
  2683. case 'PrivateName':
  2684. return false;
  2685. // no: class { NODE() {} }
  2686. // yes: class { [NODE]() {} }
  2687. // no: class { foo(NODE) {} }
  2688. case 'ClassMethod':
  2689. case 'ClassPrivateMethod':
  2690. case 'ObjectMethod':
  2691. if (parent.key === node) {
  2692. return !!parent.computed;
  2693. }
  2694. return false;
  2695. // yes: { [NODE]: "" }
  2696. // no: { NODE: "" }
  2697. // depends: { NODE }
  2698. // depends: { key: NODE }
  2699. case 'ObjectProperty':
  2700. if (parent.key === node) {
  2701. return !!parent.computed;
  2702. }
  2703. // parent.value === node
  2704. return !grandparent || grandparent.type !== 'ObjectPattern';
  2705. // no: class { NODE = value; }
  2706. // yes: class { [NODE] = value; }
  2707. // yes: class { key = NODE; }
  2708. case 'ClassProperty':
  2709. if (parent.key === node) {
  2710. return !!parent.computed;
  2711. }
  2712. return true;
  2713. case 'ClassPrivateProperty':
  2714. return parent.key !== node;
  2715. // no: class NODE {}
  2716. // yes: class Foo extends NODE {}
  2717. case 'ClassDeclaration':
  2718. case 'ClassExpression':
  2719. return parent.superClass === node;
  2720. // yes: left = NODE;
  2721. // no: NODE = right;
  2722. case 'AssignmentExpression':
  2723. return parent.right === node;
  2724. // no: [NODE = foo] = [];
  2725. // yes: [foo = NODE] = [];
  2726. case 'AssignmentPattern':
  2727. return parent.right === node;
  2728. // no: NODE: for (;;) {}
  2729. case 'LabeledStatement':
  2730. return false;
  2731. // no: try {} catch (NODE) {}
  2732. case 'CatchClause':
  2733. return false;
  2734. // no: function foo(...NODE) {}
  2735. case 'RestElement':
  2736. return false;
  2737. case 'BreakStatement':
  2738. case 'ContinueStatement':
  2739. return false;
  2740. // no: function NODE() {}
  2741. // no: function foo(NODE) {}
  2742. case 'FunctionDeclaration':
  2743. case 'FunctionExpression':
  2744. return false;
  2745. // no: export NODE from "foo";
  2746. // no: export * as NODE from "foo";
  2747. case 'ExportNamespaceSpecifier':
  2748. case 'ExportDefaultSpecifier':
  2749. return false;
  2750. // no: export { foo as NODE };
  2751. // yes: export { NODE as foo };
  2752. // no: export { NODE as foo } from "foo";
  2753. case 'ExportSpecifier':
  2754. // @ts-expect-error
  2755. if (grandparent === null || grandparent === void 0 ? void 0 : grandparent.source) {
  2756. return false;
  2757. }
  2758. return parent.local === node;
  2759. // no: import NODE from "foo";
  2760. // no: import * as NODE from "foo";
  2761. // no: import { NODE as foo } from "foo";
  2762. // no: import { foo as NODE } from "foo";
  2763. // no: import NODE from "bar";
  2764. case 'ImportDefaultSpecifier':
  2765. case 'ImportNamespaceSpecifier':
  2766. case 'ImportSpecifier':
  2767. return false;
  2768. // no: import "foo" assert { NODE: "json" }
  2769. case 'ImportAttribute':
  2770. return false;
  2771. // no: <div NODE="foo" />
  2772. case 'JSXAttribute':
  2773. return false;
  2774. // no: [NODE] = [];
  2775. // no: ({ NODE }) = [];
  2776. case 'ObjectPattern':
  2777. case 'ArrayPattern':
  2778. return false;
  2779. // no: new.NODE
  2780. // no: NODE.target
  2781. case 'MetaProperty':
  2782. return false;
  2783. // yes: type X = { someProperty: NODE }
  2784. // no: type X = { NODE: OtherType }
  2785. case 'ObjectTypeProperty':
  2786. return parent.key !== node;
  2787. // yes: enum X { Foo = NODE }
  2788. // no: enum X { NODE }
  2789. case 'TSEnumMember':
  2790. return parent.id !== node;
  2791. // yes: { [NODE]: value }
  2792. // no: { NODE: value }
  2793. case 'TSPropertySignature':
  2794. if (parent.key === node) {
  2795. return !!parent.computed;
  2796. }
  2797. return true;
  2798. }
  2799. return true;
  2800. }
  2801. const range = 2;
  2802. function generateCodeFrame(source, start = 0, end = source.length) {
  2803. const lines = source.split(/\r?\n/);
  2804. let count = 0;
  2805. const res = [];
  2806. for (let i = 0; i < lines.length; i++) {
  2807. count += lines[i].length + 1;
  2808. if (count >= start) {
  2809. for (let j = i - range; j <= i + range || end > count; j++) {
  2810. if (j < 0 || j >= lines.length)
  2811. continue;
  2812. res.push(`${j + 1}${repeat(` `, 3 - String(j + 1).length)}| ${lines[j]}`);
  2813. const lineLength = lines[j].length;
  2814. if (j === i) {
  2815. // push underline
  2816. const pad = start - (count - lineLength) + 1;
  2817. const length = end > count ? lineLength - pad : end - start;
  2818. res.push(` | ` + repeat(` `, pad) + repeat(`^`, length));
  2819. }
  2820. else if (j > i) {
  2821. if (end > count) {
  2822. const length = Math.min(end - count, lineLength);
  2823. res.push(` | ` + repeat(`^`, length));
  2824. }
  2825. count += lineLength + 1;
  2826. }
  2827. }
  2828. break;
  2829. }
  2830. }
  2831. return res.join('\n');
  2832. }
  2833. function repeat(str, n) {
  2834. let result = '';
  2835. if (n > 0) {
  2836. // eslint-disable-next-line no-constant-condition
  2837. while (true) {
  2838. // eslint-disable-line
  2839. if (n & 1)
  2840. result += str;
  2841. n >>>= 1;
  2842. if (n <= 0)
  2843. break;
  2844. str += str;
  2845. }
  2846. }
  2847. return result;
  2848. }
  2849. // can we use __proto__?
  2850. const hasProto = '__proto__' in {};
  2851. // Browser environment sniffing
  2852. const inBrowser = typeof window !== 'undefined';
  2853. const UA = inBrowser && window.navigator.userAgent.toLowerCase();
  2854. const isIE = UA && /msie|trident/.test(UA);
  2855. UA && UA.indexOf('msie 9.0') > 0;
  2856. const isEdge = UA && UA.indexOf('edge/') > 0;
  2857. UA && UA.indexOf('android') > 0;
  2858. UA && /iphone|ipad|ipod|ios/.test(UA);
  2859. UA && /chrome\/\d+/.test(UA) && !isEdge;
  2860. UA && /phantomjs/.test(UA);
  2861. UA && UA.match(/firefox\/(\d+)/);
  2862. // Firefox has a "watch" function on Object.prototype...
  2863. // @ts-expect-error firebox support
  2864. const nativeWatch = {}.watch;
  2865. let supportsPassive = false;
  2866. if (inBrowser) {
  2867. try {
  2868. const opts = {};
  2869. Object.defineProperty(opts, 'passive', {
  2870. get() {
  2871. /* istanbul ignore next */
  2872. supportsPassive = true;
  2873. }
  2874. }); // https://github.com/facebook/flow/issues/285
  2875. window.addEventListener('test-passive', null, opts);
  2876. }
  2877. catch (e) { }
  2878. }
  2879. // this needs to be lazy-evaled because vue may be required before
  2880. // vue-server-renderer can set VUE_ENV
  2881. let _isServer;
  2882. const isServerRendering = () => {
  2883. if (_isServer === undefined) {
  2884. /* istanbul ignore if */
  2885. if (!inBrowser && typeof global !== 'undefined') {
  2886. // detect presence of vue-server-renderer and avoid
  2887. // Webpack shimming the process
  2888. _isServer =
  2889. global['process'] && global['process'].env.VUE_ENV === 'server';
  2890. }
  2891. else {
  2892. _isServer = false;
  2893. }
  2894. }
  2895. return _isServer;
  2896. };
  2897. /* istanbul ignore next */
  2898. function isNative(Ctor) {
  2899. return typeof Ctor === 'function' && /native code/.test(Ctor.toString());
  2900. }
  2901. const hasSymbol = typeof Symbol !== 'undefined' &&
  2902. isNative(Symbol) &&
  2903. typeof Reflect !== 'undefined' &&
  2904. isNative(Reflect.ownKeys);
  2905. let _Set; // $flow-disable-line
  2906. /* istanbul ignore if */ if (typeof Set !== 'undefined' && isNative(Set)) {
  2907. // use native Set when available.
  2908. _Set = Set;
  2909. }
  2910. else {
  2911. // a non-standard Set polyfill that only works with primitive keys.
  2912. _Set = class Set {
  2913. constructor() {
  2914. this.set = Object.create(null);
  2915. }
  2916. has(key) {
  2917. return this.set[key] === true;
  2918. }
  2919. add(key) {
  2920. this.set[key] = true;
  2921. }
  2922. clear() {
  2923. this.set = Object.create(null);
  2924. }
  2925. };
  2926. }
  2927. const ASSET_TYPES = ['component', 'directive', 'filter'];
  2928. const LIFECYCLE_HOOKS = [
  2929. 'beforeCreate',
  2930. 'created',
  2931. 'beforeMount',
  2932. 'mounted',
  2933. 'beforeUpdate',
  2934. 'updated',
  2935. 'beforeDestroy',
  2936. 'destroyed',
  2937. 'activated',
  2938. 'deactivated',
  2939. 'errorCaptured',
  2940. 'serverPrefetch',
  2941. 'renderTracked',
  2942. 'renderTriggered'
  2943. ];
  2944. var config = {
  2945. /**
  2946. * Option merge strategies (used in core/util/options)
  2947. */
  2948. // $flow-disable-line
  2949. optionMergeStrategies: Object.create(null),
  2950. /**
  2951. * Whether to suppress warnings.
  2952. */
  2953. silent: false,
  2954. /**
  2955. * Show production mode tip message on boot?
  2956. */
  2957. productionTip: process.env.NODE_ENV !== 'production',
  2958. /**
  2959. * Whether to enable devtools
  2960. */
  2961. devtools: process.env.NODE_ENV !== 'production',
  2962. /**
  2963. * Whether to record perf
  2964. */
  2965. performance: false,
  2966. /**
  2967. * Error handler for watcher errors
  2968. */
  2969. errorHandler: null,
  2970. /**
  2971. * Warn handler for watcher warns
  2972. */
  2973. warnHandler: null,
  2974. /**
  2975. * Ignore certain custom elements
  2976. */
  2977. ignoredElements: [],
  2978. /**
  2979. * Custom user key aliases for v-on
  2980. */
  2981. // $flow-disable-line
  2982. keyCodes: Object.create(null),
  2983. /**
  2984. * Check if a tag is reserved so that it cannot be registered as a
  2985. * component. This is platform-dependent and may be overwritten.
  2986. */
  2987. isReservedTag: no,
  2988. /**
  2989. * Check if an attribute is reserved so that it cannot be used as a component
  2990. * prop. This is platform-dependent and may be overwritten.
  2991. */
  2992. isReservedAttr: no,
  2993. /**
  2994. * Check if a tag is an unknown element.
  2995. * Platform-dependent.
  2996. */
  2997. isUnknownElement: no,
  2998. /**
  2999. * Get the namespace of an element
  3000. */
  3001. getTagNamespace: noop,
  3002. /**
  3003. * Parse the real tag name for the specific platform.
  3004. */
  3005. parsePlatformTagName: identity,
  3006. /**
  3007. * Check if an attribute must be bound using property, e.g. value
  3008. * Platform-dependent.
  3009. */
  3010. mustUseProp: no,
  3011. /**
  3012. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  3013. * This will significantly reduce performance if set to false.
  3014. */
  3015. async: true,
  3016. /**
  3017. * Exposed for legacy reasons
  3018. */
  3019. _lifecycleHooks: LIFECYCLE_HOOKS
  3020. };
  3021. let currentInstance = null;
  3022. /**
  3023. * @internal
  3024. */
  3025. function setCurrentInstance(vm = null) {
  3026. if (!vm)
  3027. currentInstance && currentInstance._scope.off();
  3028. currentInstance = vm;
  3029. vm && vm._scope.on();
  3030. }
  3031. /**
  3032. * @internal
  3033. */
  3034. class VNode {
  3035. constructor(tag, data, children, text, elm, context, componentOptions, asyncFactory) {
  3036. this.tag = tag;
  3037. this.data = data;
  3038. this.children = children;
  3039. this.text = text;
  3040. this.elm = elm;
  3041. this.ns = undefined;
  3042. this.context = context;
  3043. this.fnContext = undefined;
  3044. this.fnOptions = undefined;
  3045. this.fnScopeId = undefined;
  3046. this.key = data && data.key;
  3047. this.componentOptions = componentOptions;
  3048. this.componentInstance = undefined;
  3049. this.parent = undefined;
  3050. this.raw = false;
  3051. this.isStatic = false;
  3052. this.isRootInsert = true;
  3053. this.isComment = false;
  3054. this.isCloned = false;
  3055. this.isOnce = false;
  3056. this.asyncFactory = asyncFactory;
  3057. this.asyncMeta = undefined;
  3058. this.isAsyncPlaceholder = false;
  3059. }
  3060. // DEPRECATED: alias for componentInstance for backwards compat.
  3061. /* istanbul ignore next */
  3062. get child() {
  3063. return this.componentInstance;
  3064. }
  3065. }
  3066. const createEmptyVNode = (text = '') => {
  3067. const node = new VNode();
  3068. node.text = text;
  3069. node.isComment = true;
  3070. return node;
  3071. };
  3072. function createTextVNode(val) {
  3073. return new VNode(undefined, undefined, undefined, String(val));
  3074. }
  3075. // optimized shallow clone
  3076. // used for static nodes and slot nodes because they may be reused across
  3077. // multiple renders, cloning them avoids errors when DOM manipulations rely
  3078. // on their elm reference.
  3079. function cloneVNode(vnode) {
  3080. const cloned = new VNode(vnode.tag, vnode.data,
  3081. // #7975
  3082. // clone children array to avoid mutating original in case of cloning
  3083. // a child.
  3084. vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, vnode.componentOptions, vnode.asyncFactory);
  3085. cloned.ns = vnode.ns;
  3086. cloned.isStatic = vnode.isStatic;
  3087. cloned.key = vnode.key;
  3088. cloned.isComment = vnode.isComment;
  3089. cloned.fnContext = vnode.fnContext;
  3090. cloned.fnOptions = vnode.fnOptions;
  3091. cloned.fnScopeId = vnode.fnScopeId;
  3092. cloned.asyncMeta = vnode.asyncMeta;
  3093. cloned.isCloned = true;
  3094. return cloned;
  3095. }
  3096. /* not type checking this file because flow doesn't play well with Proxy */
  3097. if (process.env.NODE_ENV !== 'production') {
  3098. makeMap('Infinity,undefined,NaN,isFinite,isNaN,' +
  3099. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  3100. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
  3101. 'require' // for Webpack/Browserify
  3102. );
  3103. const hasProxy = typeof Proxy !== 'undefined' && isNative(Proxy);
  3104. if (hasProxy) {
  3105. const isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  3106. config.keyCodes = new Proxy(config.keyCodes, {
  3107. set(target, key, value) {
  3108. if (isBuiltInModifier(key)) {
  3109. warn$3(`Avoid overwriting built-in modifier in config.keyCodes: .${key}`);
  3110. return false;
  3111. }
  3112. else {
  3113. target[key] = value;
  3114. return true;
  3115. }
  3116. }
  3117. });
  3118. }
  3119. }
  3120. let uid = 0;
  3121. /**
  3122. * A dep is an observable that can have multiple
  3123. * directives subscribing to it.
  3124. * @internal
  3125. */
  3126. class Dep {
  3127. constructor() {
  3128. // pending subs cleanup
  3129. this._pending = false;
  3130. this.id = uid++;
  3131. this.subs = [];
  3132. }
  3133. addSub(sub) {
  3134. this.subs.push(sub);
  3135. }
  3136. removeSub(sub) {
  3137. // #12696 deps with massive amount of subscribers are extremely slow to
  3138. // clean up in Chromium
  3139. // to workaround this, we unset the sub for now, and clear them on
  3140. // next scheduler flush.
  3141. this.subs[this.subs.indexOf(sub)] = null;
  3142. if (!this._pending) {
  3143. this._pending = true;
  3144. }
  3145. }
  3146. depend(info) {
  3147. if (Dep.target) {
  3148. Dep.target.addDep(this);
  3149. if (process.env.NODE_ENV !== 'production' && info && Dep.target.onTrack) {
  3150. Dep.target.onTrack(Object.assign({ effect: Dep.target }, info));
  3151. }
  3152. }
  3153. }
  3154. notify(info) {
  3155. // stabilize the subscriber list first
  3156. const subs = this.subs.filter(s => s);
  3157. if (process.env.NODE_ENV !== 'production' && !config.async) {
  3158. // subs aren't sorted in scheduler if not running async
  3159. // we need to sort them now to make sure they fire in correct
  3160. // order
  3161. subs.sort((a, b) => a.id - b.id);
  3162. }
  3163. for (let i = 0, l = subs.length; i < l; i++) {
  3164. const sub = subs[i];
  3165. if (process.env.NODE_ENV !== 'production' && info) {
  3166. sub.onTrigger &&
  3167. sub.onTrigger(Object.assign({ effect: subs[i] }, info));
  3168. }
  3169. sub.update();
  3170. }
  3171. }
  3172. }
  3173. // The current target watcher being evaluated.
  3174. // This is globally unique because only one watcher
  3175. // can be evaluated at a time.
  3176. Dep.target = null;
  3177. const targetStack = [];
  3178. function pushTarget(target) {
  3179. targetStack.push(target);
  3180. Dep.target = target;
  3181. }
  3182. function popTarget() {
  3183. targetStack.pop();
  3184. Dep.target = targetStack[targetStack.length - 1];
  3185. }
  3186. /*
  3187. * not type checking this file because flow doesn't play well with
  3188. * dynamically accessing methods on Array prototype
  3189. */
  3190. const arrayProto = Array.prototype;
  3191. const arrayMethods = Object.create(arrayProto);
  3192. const methodsToPatch = [
  3193. 'push',
  3194. 'pop',
  3195. 'shift',
  3196. 'unshift',
  3197. 'splice',
  3198. 'sort',
  3199. 'reverse'
  3200. ];
  3201. /**
  3202. * Intercept mutating methods and emit events
  3203. */
  3204. methodsToPatch.forEach(function (method) {
  3205. // cache original method
  3206. const original = arrayProto[method];
  3207. def(arrayMethods, method, function mutator(...args) {
  3208. const result = original.apply(this, args);
  3209. const ob = this.__ob__;
  3210. let inserted;
  3211. switch (method) {
  3212. case 'push':
  3213. case 'unshift':
  3214. inserted = args;
  3215. break;
  3216. case 'splice':
  3217. inserted = args.slice(2);
  3218. break;
  3219. }
  3220. if (inserted)
  3221. ob.observeArray(inserted);
  3222. // notify change
  3223. if (process.env.NODE_ENV !== 'production') {
  3224. ob.dep.notify({
  3225. type: "array mutation" /* TriggerOpTypes.ARRAY_MUTATION */,
  3226. target: this,
  3227. key: method
  3228. });
  3229. }
  3230. else {
  3231. ob.dep.notify();
  3232. }
  3233. return result;
  3234. });
  3235. });
  3236. const rawMap = new WeakMap();
  3237. function isReadonly(value) {
  3238. return !!(value && value.__v_isReadonly);
  3239. }
  3240. const arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  3241. const NO_INIITIAL_VALUE = {};
  3242. /**
  3243. * In some cases we may want to disable observation inside a component's
  3244. * update computation.
  3245. */
  3246. let shouldObserve = true;
  3247. function toggleObserving(value) {
  3248. shouldObserve = value;
  3249. }
  3250. // ssr mock dep
  3251. const mockDep = {
  3252. notify: noop,
  3253. depend: noop,
  3254. addSub: noop,
  3255. removeSub: noop
  3256. };
  3257. /**
  3258. * Observer class that is attached to each observed
  3259. * object. Once attached, the observer converts the target
  3260. * object's property keys into getter/setters that
  3261. * collect dependencies and dispatch updates.
  3262. */
  3263. class Observer {
  3264. constructor(value, shallow = false, mock = false) {
  3265. this.value = value;
  3266. this.shallow = shallow;
  3267. this.mock = mock;
  3268. // this.value = value
  3269. this.dep = mock ? mockDep : new Dep();
  3270. this.vmCount = 0;
  3271. def(value, '__ob__', this);
  3272. if (isArray(value)) {
  3273. if (!mock) {
  3274. if (hasProto) {
  3275. value.__proto__ = arrayMethods;
  3276. /* eslint-enable no-proto */
  3277. }
  3278. else {
  3279. for (let i = 0, l = arrayKeys.length; i < l; i++) {
  3280. const key = arrayKeys[i];
  3281. def(value, key, arrayMethods[key]);
  3282. }
  3283. }
  3284. }
  3285. if (!shallow) {
  3286. this.observeArray(value);
  3287. }
  3288. }
  3289. else {
  3290. /**
  3291. * Walk through all properties and convert them into
  3292. * getter/setters. This method should only be called when
  3293. * value type is Object.
  3294. */
  3295. const keys = Object.keys(value);
  3296. for (let i = 0; i < keys.length; i++) {
  3297. const key = keys[i];
  3298. defineReactive(value, key, NO_INIITIAL_VALUE, undefined, shallow, mock);
  3299. }
  3300. }
  3301. }
  3302. /**
  3303. * Observe a list of Array items.
  3304. */
  3305. observeArray(value) {
  3306. for (let i = 0, l = value.length; i < l; i++) {
  3307. observe(value[i], false, this.mock);
  3308. }
  3309. }
  3310. }
  3311. // helpers
  3312. /**
  3313. * Attempt to create an observer instance for a value,
  3314. * returns the new observer if successfully observed,
  3315. * or the existing observer if the value already has one.
  3316. */
  3317. function observe(value, shallow, ssrMockReactivity) {
  3318. if (value && hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  3319. return value.__ob__;
  3320. }
  3321. if (shouldObserve &&
  3322. (ssrMockReactivity || !isServerRendering()) &&
  3323. (isArray(value) || isPlainObject(value)) &&
  3324. Object.isExtensible(value) &&
  3325. !value.__v_skip /* ReactiveFlags.SKIP */ &&
  3326. !rawMap.has(value) &&
  3327. !isRef(value) &&
  3328. !(value instanceof VNode)) {
  3329. return new Observer(value, shallow, ssrMockReactivity);
  3330. }
  3331. }
  3332. /**
  3333. * Define a reactive property on an Object.
  3334. */
  3335. function defineReactive(obj, key, val, customSetter, shallow, mock) {
  3336. const dep = new Dep();
  3337. const property = Object.getOwnPropertyDescriptor(obj, key);
  3338. if (property && property.configurable === false) {
  3339. return;
  3340. }
  3341. // cater for pre-defined getter/setters
  3342. const getter = property && property.get;
  3343. const setter = property && property.set;
  3344. if ((!getter || setter) &&
  3345. (val === NO_INIITIAL_VALUE || arguments.length === 2)) {
  3346. val = obj[key];
  3347. }
  3348. let childOb = !shallow && observe(val, false, mock);
  3349. Object.defineProperty(obj, key, {
  3350. enumerable: true,
  3351. configurable: true,
  3352. get: function reactiveGetter() {
  3353. const value = getter ? getter.call(obj) : val;
  3354. if (Dep.target) {
  3355. if (process.env.NODE_ENV !== 'production') {
  3356. dep.depend({
  3357. target: obj,
  3358. type: "get" /* TrackOpTypes.GET */,
  3359. key
  3360. });
  3361. }
  3362. else {
  3363. dep.depend();
  3364. }
  3365. if (childOb) {
  3366. childOb.dep.depend();
  3367. if (isArray(value)) {
  3368. dependArray(value);
  3369. }
  3370. }
  3371. }
  3372. return isRef(value) && !shallow ? value.value : value;
  3373. },
  3374. set: function reactiveSetter(newVal) {
  3375. const value = getter ? getter.call(obj) : val;
  3376. if (!hasChanged(value, newVal)) {
  3377. return;
  3378. }
  3379. if (process.env.NODE_ENV !== 'production' && customSetter) {
  3380. customSetter();
  3381. }
  3382. if (setter) {
  3383. setter.call(obj, newVal);
  3384. }
  3385. else if (getter) {
  3386. // #7981: for accessor properties without setter
  3387. return;
  3388. }
  3389. else if (!shallow && isRef(value) && !isRef(newVal)) {
  3390. value.value = newVal;
  3391. return;
  3392. }
  3393. else {
  3394. val = newVal;
  3395. }
  3396. childOb = !shallow && observe(newVal, false, mock);
  3397. if (process.env.NODE_ENV !== 'production') {
  3398. dep.notify({
  3399. type: "set" /* TriggerOpTypes.SET */,
  3400. target: obj,
  3401. key,
  3402. newValue: newVal,
  3403. oldValue: value
  3404. });
  3405. }
  3406. else {
  3407. dep.notify();
  3408. }
  3409. }
  3410. });
  3411. return dep;
  3412. }
  3413. function set(target, key, val) {
  3414. if (process.env.NODE_ENV !== 'production' && (isUndef(target) || isPrimitive(target))) {
  3415. warn$3(`Cannot set reactive property on undefined, null, or primitive value: ${target}`);
  3416. }
  3417. if (isReadonly(target)) {
  3418. process.env.NODE_ENV !== 'production' && warn$3(`Set operation on key "${key}" failed: target is readonly.`);
  3419. return;
  3420. }
  3421. const ob = target.__ob__;
  3422. if (isArray(target) && isValidArrayIndex(key)) {
  3423. target.length = Math.max(target.length, key);
  3424. target.splice(key, 1, val);
  3425. // when mocking for SSR, array methods are not hijacked
  3426. if (ob && !ob.shallow && ob.mock) {
  3427. observe(val, false, true);
  3428. }
  3429. return val;
  3430. }
  3431. if (key in target && !(key in Object.prototype)) {
  3432. target[key] = val;
  3433. return val;
  3434. }
  3435. if (target._isVue || (ob && ob.vmCount)) {
  3436. process.env.NODE_ENV !== 'production' &&
  3437. warn$3('Avoid adding reactive properties to a Vue instance or its root $data ' +
  3438. 'at runtime - declare it upfront in the data option.');
  3439. return val;
  3440. }
  3441. if (!ob) {
  3442. target[key] = val;
  3443. return val;
  3444. }
  3445. defineReactive(ob.value, key, val, undefined, ob.shallow, ob.mock);
  3446. if (process.env.NODE_ENV !== 'production') {
  3447. ob.dep.notify({
  3448. type: "add" /* TriggerOpTypes.ADD */,
  3449. target: target,
  3450. key,
  3451. newValue: val,
  3452. oldValue: undefined
  3453. });
  3454. }
  3455. else {
  3456. ob.dep.notify();
  3457. }
  3458. return val;
  3459. }
  3460. /**
  3461. * Collect dependencies on array elements when the array is touched, since
  3462. * we cannot intercept array element access like property getters.
  3463. */
  3464. function dependArray(value) {
  3465. for (let e, i = 0, l = value.length; i < l; i++) {
  3466. e = value[i];
  3467. if (e && e.__ob__) {
  3468. e.__ob__.dep.depend();
  3469. }
  3470. if (isArray(e)) {
  3471. dependArray(e);
  3472. }
  3473. }
  3474. }
  3475. function isRef(r) {
  3476. return !!(r && r.__v_isRef === true);
  3477. }
  3478. if (process.env.NODE_ENV !== 'production') ;
  3479. const normalizeEvent = cached((name) => {
  3480. const passive = name.charAt(0) === '&';
  3481. name = passive ? name.slice(1) : name;
  3482. const once = name.charAt(0) === '~'; // Prefixed last, checked first
  3483. name = once ? name.slice(1) : name;
  3484. const capture = name.charAt(0) === '!';
  3485. name = capture ? name.slice(1) : name;
  3486. return {
  3487. name,
  3488. once,
  3489. capture,
  3490. passive
  3491. };
  3492. });
  3493. function createFnInvoker(fns, vm) {
  3494. function invoker() {
  3495. const fns = invoker.fns;
  3496. if (isArray(fns)) {
  3497. const cloned = fns.slice();
  3498. for (let i = 0; i < cloned.length; i++) {
  3499. invokeWithErrorHandling(cloned[i], null, arguments, vm, `v-on handler`);
  3500. }
  3501. }
  3502. else {
  3503. // return handler return value for single handlers
  3504. return invokeWithErrorHandling(fns, null, arguments, vm, `v-on handler`);
  3505. }
  3506. }
  3507. invoker.fns = fns;
  3508. return invoker;
  3509. }
  3510. function updateListeners(on, oldOn, add, remove, createOnceHandler, vm) {
  3511. let name, cur, old, event;
  3512. for (name in on) {
  3513. cur = on[name];
  3514. old = oldOn[name];
  3515. event = normalizeEvent(name);
  3516. if (isUndef(cur)) {
  3517. process.env.NODE_ENV !== 'production' &&
  3518. warn$3(`Invalid handler for event "${event.name}": got ` + String(cur), vm);
  3519. }
  3520. else if (isUndef(old)) {
  3521. if (isUndef(cur.fns)) {
  3522. cur = on[name] = createFnInvoker(cur, vm);
  3523. }
  3524. if (isTrue(event.once)) {
  3525. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  3526. }
  3527. add(event.name, cur, event.capture, event.passive, event.params);
  3528. }
  3529. else if (cur !== old) {
  3530. old.fns = cur;
  3531. on[name] = old;
  3532. }
  3533. }
  3534. for (name in oldOn) {
  3535. if (isUndef(on[name])) {
  3536. event = normalizeEvent(name);
  3537. remove(event.name, oldOn[name], event.capture);
  3538. }
  3539. }
  3540. }
  3541. function extractPropsFromVNodeData(data, Ctor, tag) {
  3542. // we are only extracting raw values here.
  3543. // validation and default values are handled in the child
  3544. // component itself.
  3545. const propOptions = Ctor.options.props;
  3546. if (isUndef(propOptions)) {
  3547. return;
  3548. }
  3549. const res = {};
  3550. const { attrs, props } = data;
  3551. if (isDef(attrs) || isDef(props)) {
  3552. for (const key in propOptions) {
  3553. const altKey = hyphenate(key);
  3554. if (process.env.NODE_ENV !== 'production') {
  3555. const keyInLowerCase = key.toLowerCase();
  3556. if (key !== keyInLowerCase && attrs && hasOwn(attrs, keyInLowerCase)) {
  3557. tip(`Prop "${keyInLowerCase}" is passed to component ` +
  3558. `${formatComponentName(
  3559. // @ts-expect-error tag is string
  3560. tag || Ctor)}, but the declared prop name is` +
  3561. ` "${key}". ` +
  3562. `Note that HTML attributes are case-insensitive and camelCased ` +
  3563. `props need to use their kebab-case equivalents when using in-DOM ` +
  3564. `templates. You should probably use "${altKey}" instead of "${key}".`);
  3565. }
  3566. }
  3567. checkProp(res, props, key, altKey, true) ||
  3568. checkProp(res, attrs, key, altKey, false);
  3569. }
  3570. }
  3571. return res;
  3572. }
  3573. function checkProp(res, hash, key, altKey, preserve) {
  3574. if (isDef(hash)) {
  3575. if (hasOwn(hash, key)) {
  3576. res[key] = hash[key];
  3577. if (!preserve) {
  3578. delete hash[key];
  3579. }
  3580. return true;
  3581. }
  3582. else if (hasOwn(hash, altKey)) {
  3583. res[key] = hash[altKey];
  3584. if (!preserve) {
  3585. delete hash[altKey];
  3586. }
  3587. return true;
  3588. }
  3589. }
  3590. return false;
  3591. }
  3592. // The template compiler attempts to minimize the need for normalization by
  3593. // statically analyzing the template at compile time.
  3594. //
  3595. // For plain HTML markup, normalization can be completely skipped because the
  3596. // generated render function is guaranteed to return Array<VNode>. There are
  3597. // two cases where extra normalization is needed:
  3598. // 1. When the children contains components - because a functional component
  3599. // may return an Array instead of a single root. In this case, just a simple
  3600. // normalization is needed - if any child is an Array, we flatten the whole
  3601. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  3602. // because functional components already normalize their own children.
  3603. function simpleNormalizeChildren(children) {
  3604. for (let i = 0; i < children.length; i++) {
  3605. if (isArray(children[i])) {
  3606. return Array.prototype.concat.apply([], children);
  3607. }
  3608. }
  3609. return children;
  3610. }
  3611. // 2. When the children contains constructs that always generated nested Arrays,
  3612. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  3613. // with hand-written render functions / JSX. In such cases a full normalization
  3614. // is needed to cater to all possible types of children values.
  3615. function normalizeChildren(children) {
  3616. return isPrimitive(children)
  3617. ? [createTextVNode(children)]
  3618. : isArray(children)
  3619. ? normalizeArrayChildren(children)
  3620. : undefined;
  3621. }
  3622. function isTextNode(node) {
  3623. return isDef(node) && isDef(node.text) && isFalse(node.isComment);
  3624. }
  3625. function normalizeArrayChildren(children, nestedIndex) {
  3626. const res = [];
  3627. let i, c, lastIndex, last;
  3628. for (i = 0; i < children.length; i++) {
  3629. c = children[i];
  3630. if (isUndef(c) || typeof c === 'boolean')
  3631. continue;
  3632. lastIndex = res.length - 1;
  3633. last = res[lastIndex];
  3634. // nested
  3635. if (isArray(c)) {
  3636. if (c.length > 0) {
  3637. c = normalizeArrayChildren(c, `${nestedIndex || ''}_${i}`);
  3638. // merge adjacent text nodes
  3639. if (isTextNode(c[0]) && isTextNode(last)) {
  3640. res[lastIndex] = createTextVNode(last.text + c[0].text);
  3641. c.shift();
  3642. }
  3643. res.push.apply(res, c);
  3644. }
  3645. }
  3646. else if (isPrimitive(c)) {
  3647. if (isTextNode(last)) {
  3648. // merge adjacent text nodes
  3649. // this is necessary for SSR hydration because text nodes are
  3650. // essentially merged when rendered to HTML strings
  3651. res[lastIndex] = createTextVNode(last.text + c);
  3652. }
  3653. else if (c !== '') {
  3654. // convert primitive to vnode
  3655. res.push(createTextVNode(c));
  3656. }
  3657. }
  3658. else {
  3659. if (isTextNode(c) && isTextNode(last)) {
  3660. // merge adjacent text nodes
  3661. res[lastIndex] = createTextVNode(last.text + c.text);
  3662. }
  3663. else {
  3664. // default key for nested array children (likely generated by v-for)
  3665. if (isTrue(children._isVList) &&
  3666. isDef(c.tag) &&
  3667. isUndef(c.key) &&
  3668. isDef(nestedIndex)) {
  3669. c.key = `__vlist${nestedIndex}_${i}__`;
  3670. }
  3671. res.push(c);
  3672. }
  3673. }
  3674. }
  3675. return res;
  3676. }
  3677. const SIMPLE_NORMALIZE = 1;
  3678. const ALWAYS_NORMALIZE = 2;
  3679. // wrapper function for providing a more flexible interface
  3680. // without getting yelled at by flow
  3681. function createElement(context, tag, data, children, normalizationType, alwaysNormalize) {
  3682. if (isArray(data) || isPrimitive(data)) {
  3683. normalizationType = children;
  3684. children = data;
  3685. data = undefined;
  3686. }
  3687. if (isTrue(alwaysNormalize)) {
  3688. normalizationType = ALWAYS_NORMALIZE;
  3689. }
  3690. return _createElement(context, tag, data, children, normalizationType);
  3691. }
  3692. function _createElement(context, tag, data, children, normalizationType) {
  3693. if (isDef(data) && isDef(data.__ob__)) {
  3694. process.env.NODE_ENV !== 'production' &&
  3695. warn$3(`Avoid using observed data object as vnode data: ${JSON.stringify(data)}\n` + 'Always create fresh vnode data objects in each render!', context);
  3696. return createEmptyVNode();
  3697. }
  3698. // object syntax in v-bind
  3699. if (isDef(data) && isDef(data.is)) {
  3700. tag = data.is;
  3701. }
  3702. if (!tag) {
  3703. // in case of component :is set to falsy value
  3704. return createEmptyVNode();
  3705. }
  3706. // warn against non-primitive key
  3707. if (process.env.NODE_ENV !== 'production' && isDef(data) && isDef(data.key) && !isPrimitive(data.key)) {
  3708. warn$3('Avoid using non-primitive value as key, ' +
  3709. 'use string/number value instead.', context);
  3710. }
  3711. // support single function children as default scoped slot
  3712. if (isArray(children) && isFunction(children[0])) {
  3713. data = data || {};
  3714. data.scopedSlots = { default: children[0] };
  3715. children.length = 0;
  3716. }
  3717. if (normalizationType === ALWAYS_NORMALIZE) {
  3718. children = normalizeChildren(children);
  3719. }
  3720. else if (normalizationType === SIMPLE_NORMALIZE) {
  3721. children = simpleNormalizeChildren(children);
  3722. }
  3723. let vnode, ns;
  3724. if (typeof tag === 'string') {
  3725. let Ctor;
  3726. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  3727. if ((!data || !data.pre) &&
  3728. isDef((Ctor = resolveAsset(context.$options, 'components', tag)))) {
  3729. // component
  3730. vnode = createComponent(Ctor, data, context, children, tag);
  3731. }
  3732. else {
  3733. // unknown or unlisted namespaced elements
  3734. // check at runtime because it may get assigned a namespace when its
  3735. // parent normalizes children
  3736. vnode = new VNode(tag, data, children, undefined, undefined, context);
  3737. }
  3738. }
  3739. else {
  3740. // direct component options / constructor
  3741. vnode = createComponent(tag, data, context, children);
  3742. }
  3743. if (isArray(vnode)) {
  3744. return vnode;
  3745. }
  3746. else if (isDef(vnode)) {
  3747. if (isDef(ns))
  3748. applyNS(vnode, ns);
  3749. if (isDef(data))
  3750. registerDeepBindings(data);
  3751. return vnode;
  3752. }
  3753. else {
  3754. return createEmptyVNode();
  3755. }
  3756. }
  3757. function applyNS(vnode, ns, force) {
  3758. vnode.ns = ns;
  3759. if (vnode.tag === 'foreignObject') {
  3760. // use default namespace inside foreignObject
  3761. ns = undefined;
  3762. force = true;
  3763. }
  3764. if (isDef(vnode.children)) {
  3765. for (let i = 0, l = vnode.children.length; i < l; i++) {
  3766. const child = vnode.children[i];
  3767. if (isDef(child.tag) &&
  3768. (isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  3769. applyNS(child, ns, force);
  3770. }
  3771. }
  3772. }
  3773. }
  3774. // ref #5318
  3775. // necessary to ensure parent re-render when deep bindings like :style and
  3776. // :class are used on slot nodes
  3777. function registerDeepBindings(data) {
  3778. if (isObject$1(data.style)) {
  3779. traverse(data.style);
  3780. }
  3781. if (isObject$1(data.class)) {
  3782. traverse(data.class);
  3783. }
  3784. }
  3785. /**
  3786. * Runtime helper for rendering v-for lists.
  3787. */
  3788. function renderList(val, render) {
  3789. let ret = null, i, l, keys, key;
  3790. if (isArray(val) || typeof val === 'string') {
  3791. ret = new Array(val.length);
  3792. for (i = 0, l = val.length; i < l; i++) {
  3793. ret[i] = render(val[i], i);
  3794. }
  3795. }
  3796. else if (typeof val === 'number') {
  3797. ret = new Array(val);
  3798. for (i = 0; i < val; i++) {
  3799. ret[i] = render(i + 1, i);
  3800. }
  3801. }
  3802. else if (isObject$1(val)) {
  3803. if (hasSymbol && val[Symbol.iterator]) {
  3804. ret = [];
  3805. const iterator = val[Symbol.iterator]();
  3806. let result = iterator.next();
  3807. while (!result.done) {
  3808. ret.push(render(result.value, ret.length));
  3809. result = iterator.next();
  3810. }
  3811. }
  3812. else {
  3813. keys = Object.keys(val);
  3814. ret = new Array(keys.length);
  3815. for (i = 0, l = keys.length; i < l; i++) {
  3816. key = keys[i];
  3817. ret[i] = render(val[key], key, i);
  3818. }
  3819. }
  3820. }
  3821. if (!isDef(ret)) {
  3822. ret = [];
  3823. }
  3824. ret._isVList = true;
  3825. return ret;
  3826. }
  3827. /**
  3828. * Runtime helper for rendering <slot>
  3829. */
  3830. function renderSlot(name, fallbackRender, props, bindObject) {
  3831. const scopedSlotFn = this.$scopedSlots[name];
  3832. let nodes;
  3833. if (scopedSlotFn) {
  3834. // scoped slot
  3835. props = props || {};
  3836. if (bindObject) {
  3837. if (process.env.NODE_ENV !== 'production' && !isObject$1(bindObject)) {
  3838. warn$3('slot v-bind without argument expects an Object', this);
  3839. }
  3840. props = extend(extend({}, bindObject), props);
  3841. }
  3842. nodes =
  3843. scopedSlotFn(props) ||
  3844. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  3845. }
  3846. else {
  3847. nodes =
  3848. this.$slots[name] ||
  3849. (isFunction(fallbackRender) ? fallbackRender() : fallbackRender);
  3850. }
  3851. const target = props && props.slot;
  3852. if (target) {
  3853. return this.$createElement('template', { slot: target }, nodes);
  3854. }
  3855. else {
  3856. return nodes;
  3857. }
  3858. }
  3859. /**
  3860. * Runtime helper for resolving filters
  3861. */
  3862. function resolveFilter(id) {
  3863. return resolveAsset(this.$options, 'filters', id, true) || identity;
  3864. }
  3865. function isKeyNotMatch(expect, actual) {
  3866. if (isArray(expect)) {
  3867. return expect.indexOf(actual) === -1;
  3868. }
  3869. else {
  3870. return expect !== actual;
  3871. }
  3872. }
  3873. /**
  3874. * Runtime helper for checking keyCodes from config.
  3875. * exposed as Vue.prototype._k
  3876. * passing in eventKeyName as last argument separately for backwards compat
  3877. */
  3878. function checkKeyCodes(eventKeyCode, key, builtInKeyCode, eventKeyName, builtInKeyName) {
  3879. const mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  3880. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  3881. return isKeyNotMatch(builtInKeyName, eventKeyName);
  3882. }
  3883. else if (mappedKeyCode) {
  3884. return isKeyNotMatch(mappedKeyCode, eventKeyCode);
  3885. }
  3886. else if (eventKeyName) {
  3887. return hyphenate(eventKeyName) !== key;
  3888. }
  3889. return eventKeyCode === undefined;
  3890. }
  3891. /**
  3892. * Runtime helper for merging v-bind="object" into a VNode's data.
  3893. */
  3894. function bindObjectProps(data, tag, value, asProp, isSync) {
  3895. if (value) {
  3896. if (!isObject$1(value)) {
  3897. process.env.NODE_ENV !== 'production' &&
  3898. warn$3('v-bind without argument expects an Object or Array value', this);
  3899. }
  3900. else {
  3901. if (isArray(value)) {
  3902. value = toObject(value);
  3903. }
  3904. let hash;
  3905. for (const key in value) {
  3906. if (key === 'class' || key === 'style' || isReservedAttribute(key)) {
  3907. hash = data;
  3908. }
  3909. else {
  3910. const type = data.attrs && data.attrs.type;
  3911. hash =
  3912. asProp || config.mustUseProp(tag, type, key)
  3913. ? data.domProps || (data.domProps = {})
  3914. : data.attrs || (data.attrs = {});
  3915. }
  3916. const camelizedKey = camelize(key);
  3917. const hyphenatedKey = hyphenate(key);
  3918. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  3919. hash[key] = value[key];
  3920. if (isSync) {
  3921. const on = data.on || (data.on = {});
  3922. on[`update:${key}`] = function ($event) {
  3923. value[key] = $event;
  3924. };
  3925. }
  3926. }
  3927. }
  3928. }
  3929. }
  3930. return data;
  3931. }
  3932. /**
  3933. * Runtime helper for rendering static trees.
  3934. */
  3935. function renderStatic(index, isInFor) {
  3936. const cached = this._staticTrees || (this._staticTrees = []);
  3937. let tree = cached[index];
  3938. // if has already-rendered static tree and not inside v-for,
  3939. // we can reuse the same tree.
  3940. if (tree && !isInFor) {
  3941. return tree;
  3942. }
  3943. // otherwise, render a fresh tree.
  3944. tree = cached[index] = this.$options.staticRenderFns[index].call(this._renderProxy, this._c, this // for render fns generated for functional component templates
  3945. );
  3946. markStatic$1(tree, `__static__${index}`, false);
  3947. return tree;
  3948. }
  3949. /**
  3950. * Runtime helper for v-once.
  3951. * Effectively it means marking the node as static with a unique key.
  3952. */
  3953. function markOnce(tree, index, key) {
  3954. markStatic$1(tree, `__once__${index}${key ? `_${key}` : ``}`, true);
  3955. return tree;
  3956. }
  3957. function markStatic$1(tree, key, isOnce) {
  3958. if (isArray(tree)) {
  3959. for (let i = 0; i < tree.length; i++) {
  3960. if (tree[i] && typeof tree[i] !== 'string') {
  3961. markStaticNode(tree[i], `${key}_${i}`, isOnce);
  3962. }
  3963. }
  3964. }
  3965. else {
  3966. markStaticNode(tree, key, isOnce);
  3967. }
  3968. }
  3969. function markStaticNode(node, key, isOnce) {
  3970. node.isStatic = true;
  3971. node.key = key;
  3972. node.isOnce = isOnce;
  3973. }
  3974. function bindObjectListeners(data, value) {
  3975. if (value) {
  3976. if (!isPlainObject(value)) {
  3977. process.env.NODE_ENV !== 'production' && warn$3('v-on without argument expects an Object value', this);
  3978. }
  3979. else {
  3980. const on = (data.on = data.on ? extend({}, data.on) : {});
  3981. for (const key in value) {
  3982. const existing = on[key];
  3983. const ours = value[key];
  3984. on[key] = existing ? [].concat(existing, ours) : ours;
  3985. }
  3986. }
  3987. }
  3988. return data;
  3989. }
  3990. function resolveScopedSlots(fns, res,
  3991. // the following are added in 2.6
  3992. hasDynamicKeys, contentHashKey) {
  3993. res = res || { $stable: !hasDynamicKeys };
  3994. for (let i = 0; i < fns.length; i++) {
  3995. const slot = fns[i];
  3996. if (isArray(slot)) {
  3997. resolveScopedSlots(slot, res, hasDynamicKeys);
  3998. }
  3999. else if (slot) {
  4000. // marker for reverse proxying v-slot without scope on this.$slots
  4001. // @ts-expect-error
  4002. if (slot.proxy) {
  4003. // @ts-expect-error
  4004. slot.fn.proxy = true;
  4005. }
  4006. res[slot.key] = slot.fn;
  4007. }
  4008. }
  4009. if (contentHashKey) {
  4010. res.$key = contentHashKey;
  4011. }
  4012. return res;
  4013. }
  4014. // helper to process dynamic keys for dynamic arguments in v-bind and v-on.
  4015. function bindDynamicKeys(baseObj, values) {
  4016. for (let i = 0; i < values.length; i += 2) {
  4017. const key = values[i];
  4018. if (typeof key === 'string' && key) {
  4019. baseObj[values[i]] = values[i + 1];
  4020. }
  4021. else if (process.env.NODE_ENV !== 'production' && key !== '' && key !== null) {
  4022. // null is a special value for explicitly removing a binding
  4023. warn$3(`Invalid value for dynamic directive argument (expected string or null): ${key}`, this);
  4024. }
  4025. }
  4026. return baseObj;
  4027. }
  4028. // helper to dynamically append modifier runtime markers to event names.
  4029. // ensure only append when value is already string, otherwise it will be cast
  4030. // to string and cause the type check to miss.
  4031. function prependModifier(value, symbol) {
  4032. return typeof value === 'string' ? symbol + value : value;
  4033. }
  4034. function installRenderHelpers(target) {
  4035. target._o = markOnce;
  4036. target._n = toNumber;
  4037. target._s = toString$2;
  4038. target._l = renderList;
  4039. target._t = renderSlot;
  4040. target._q = looseEqual;
  4041. target._i = looseIndexOf;
  4042. target._m = renderStatic;
  4043. target._f = resolveFilter;
  4044. target._k = checkKeyCodes;
  4045. target._b = bindObjectProps;
  4046. target._v = createTextVNode;
  4047. target._e = createEmptyVNode;
  4048. target._u = resolveScopedSlots;
  4049. target._g = bindObjectListeners;
  4050. target._d = bindDynamicKeys;
  4051. target._p = prependModifier;
  4052. }
  4053. /**
  4054. * Runtime helper for resolving raw children VNodes into a slot object.
  4055. */
  4056. function resolveSlots(children, context) {
  4057. if (!children || !children.length) {
  4058. return {};
  4059. }
  4060. const slots = {};
  4061. for (let i = 0, l = children.length; i < l; i++) {
  4062. const child = children[i];
  4063. const data = child.data;
  4064. // remove slot attribute if the node is resolved as a Vue slot node
  4065. if (data && data.attrs && data.attrs.slot) {
  4066. delete data.attrs.slot;
  4067. }
  4068. // named slots should only be respected if the vnode was rendered in the
  4069. // same context.
  4070. if ((child.context === context || child.fnContext === context) &&
  4071. data &&
  4072. data.slot != null) {
  4073. const name = data.slot;
  4074. const slot = slots[name] || (slots[name] = []);
  4075. if (child.tag === 'template') {
  4076. slot.push.apply(slot, child.children || []);
  4077. }
  4078. else {
  4079. slot.push(child);
  4080. }
  4081. }
  4082. else {
  4083. (slots.default || (slots.default = [])).push(child);
  4084. }
  4085. }
  4086. // ignore slots that contains only whitespace
  4087. for (const name in slots) {
  4088. if (slots[name].every(isWhitespace)) {
  4089. delete slots[name];
  4090. }
  4091. }
  4092. return slots;
  4093. }
  4094. function isWhitespace(node) {
  4095. return (node.isComment && !node.asyncFactory) || node.text === ' ';
  4096. }
  4097. function isAsyncPlaceholder(node) {
  4098. // @ts-expect-error not really boolean type
  4099. return node.isComment && node.asyncFactory;
  4100. }
  4101. function normalizeScopedSlots(ownerVm, scopedSlots, normalSlots, prevScopedSlots) {
  4102. let res;
  4103. const hasNormalSlots = Object.keys(normalSlots).length > 0;
  4104. const isStable = scopedSlots ? !!scopedSlots.$stable : !hasNormalSlots;
  4105. const key = scopedSlots && scopedSlots.$key;
  4106. if (!scopedSlots) {
  4107. res = {};
  4108. }
  4109. else if (scopedSlots._normalized) {
  4110. // fast path 1: child component re-render only, parent did not change
  4111. return scopedSlots._normalized;
  4112. }
  4113. else if (isStable &&
  4114. prevScopedSlots &&
  4115. prevScopedSlots !== emptyObject &&
  4116. key === prevScopedSlots.$key &&
  4117. !hasNormalSlots &&
  4118. !prevScopedSlots.$hasNormal) {
  4119. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  4120. // only need to normalize once
  4121. return prevScopedSlots;
  4122. }
  4123. else {
  4124. res = {};
  4125. for (const key in scopedSlots) {
  4126. if (scopedSlots[key] && key[0] !== '$') {
  4127. res[key] = normalizeScopedSlot(ownerVm, normalSlots, key, scopedSlots[key]);
  4128. }
  4129. }
  4130. }
  4131. // expose normal slots on scopedSlots
  4132. for (const key in normalSlots) {
  4133. if (!(key in res)) {
  4134. res[key] = proxyNormalSlot(normalSlots, key);
  4135. }
  4136. }
  4137. // avoriaz seems to mock a non-extensible $scopedSlots object
  4138. // and when that is passed down this would cause an error
  4139. if (scopedSlots && Object.isExtensible(scopedSlots)) {
  4140. scopedSlots._normalized = res;
  4141. }
  4142. def(res, '$stable', isStable);
  4143. def(res, '$key', key);
  4144. def(res, '$hasNormal', hasNormalSlots);
  4145. return res;
  4146. }
  4147. function normalizeScopedSlot(vm, normalSlots, key, fn) {
  4148. const normalized = function () {
  4149. const cur = currentInstance;
  4150. setCurrentInstance(vm);
  4151. let res = arguments.length ? fn.apply(null, arguments) : fn({});
  4152. res =
  4153. res && typeof res === 'object' && !isArray(res)
  4154. ? [res] // single vnode
  4155. : normalizeChildren(res);
  4156. const vnode = res && res[0];
  4157. setCurrentInstance(cur);
  4158. return res &&
  4159. (!vnode ||
  4160. (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode))) // #9658, #10391
  4161. ? undefined
  4162. : res;
  4163. };
  4164. // this is a slot using the new v-slot syntax without scope. although it is
  4165. // compiled as a scoped slot, render fn users would expect it to be present
  4166. // on this.$slots because the usage is semantically a normal slot.
  4167. if (fn.proxy) {
  4168. Object.defineProperty(normalSlots, key, {
  4169. get: normalized,
  4170. enumerable: true,
  4171. configurable: true
  4172. });
  4173. }
  4174. return normalized;
  4175. }
  4176. function proxyNormalSlot(slots, key) {
  4177. return () => slots[key];
  4178. }
  4179. function syncSetupProxy(to, from, prev, instance, type) {
  4180. let changed = false;
  4181. for (const key in from) {
  4182. if (!(key in to)) {
  4183. changed = true;
  4184. defineProxyAttr(to, key, instance, type);
  4185. }
  4186. else if (from[key] !== prev[key]) {
  4187. changed = true;
  4188. }
  4189. }
  4190. for (const key in to) {
  4191. if (!(key in from)) {
  4192. changed = true;
  4193. delete to[key];
  4194. }
  4195. }
  4196. return changed;
  4197. }
  4198. function defineProxyAttr(proxy, key, instance, type) {
  4199. Object.defineProperty(proxy, key, {
  4200. enumerable: true,
  4201. configurable: true,
  4202. get() {
  4203. return instance[type][key];
  4204. }
  4205. });
  4206. }
  4207. function createAsyncPlaceholder(factory, data, context, children, tag) {
  4208. const node = createEmptyVNode();
  4209. node.asyncFactory = factory;
  4210. node.asyncMeta = { data, context, children, tag };
  4211. return node;
  4212. }
  4213. function resolveAsyncComponent(factory, baseCtor) {
  4214. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  4215. return factory.errorComp;
  4216. }
  4217. if (isDef(factory.resolved)) {
  4218. return factory.resolved;
  4219. }
  4220. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  4221. return factory.loadingComp;
  4222. }
  4223. }
  4224. let target;
  4225. function add(event, fn) {
  4226. target.$on(event, fn);
  4227. }
  4228. function remove(event, fn) {
  4229. target.$off(event, fn);
  4230. }
  4231. function createOnceHandler(event, fn) {
  4232. const _target = target;
  4233. return function onceHandler() {
  4234. const res = fn.apply(null, arguments);
  4235. if (res !== null) {
  4236. _target.$off(event, onceHandler);
  4237. }
  4238. };
  4239. }
  4240. function updateComponentListeners(vm, listeners, oldListeners) {
  4241. target = vm;
  4242. updateListeners(listeners, oldListeners || {}, add, remove, createOnceHandler, vm);
  4243. target = undefined;
  4244. }
  4245. let activeInstance = null;
  4246. function updateChildComponent(vm, propsData, listeners, parentVnode, renderChildren) {
  4247. if (process.env.NODE_ENV !== 'production') ;
  4248. // determine whether component has slot children
  4249. // we need to do this before overwriting $options._renderChildren.
  4250. // check if there are dynamic scopedSlots (hand-written or compiled but with
  4251. // dynamic slot names). Static scoped slots compiled from template has the
  4252. // "$stable" marker.
  4253. const newScopedSlots = parentVnode.data.scopedSlots;
  4254. const oldScopedSlots = vm.$scopedSlots;
  4255. const hasDynamicScopedSlot = !!((newScopedSlots && !newScopedSlots.$stable) ||
  4256. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  4257. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) ||
  4258. (!newScopedSlots && vm.$scopedSlots.$key));
  4259. // Any static slot children from the parent may have changed during parent's
  4260. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  4261. // update is necessary to ensure correctness.
  4262. let needsForceUpdate = !!(renderChildren || // has new static slots
  4263. vm.$options._renderChildren || // has old static slots
  4264. hasDynamicScopedSlot);
  4265. const prevVNode = vm.$vnode;
  4266. vm.$options._parentVnode = parentVnode;
  4267. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  4268. if (vm._vnode) {
  4269. // update child tree's parent
  4270. vm._vnode.parent = parentVnode;
  4271. }
  4272. vm.$options._renderChildren = renderChildren;
  4273. // update $attrs and $listeners hash
  4274. // these are also reactive so they may trigger child update if the child
  4275. // used them during render
  4276. const attrs = parentVnode.data.attrs || emptyObject;
  4277. if (vm._attrsProxy) {
  4278. // force update if attrs are accessed and has changed since it may be
  4279. // passed to a child component.
  4280. if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
  4281. needsForceUpdate = true;
  4282. }
  4283. }
  4284. vm.$attrs = attrs;
  4285. // update listeners
  4286. listeners = listeners || emptyObject;
  4287. const prevListeners = vm.$options._parentListeners;
  4288. if (vm._listenersProxy) {
  4289. syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
  4290. }
  4291. vm.$listeners = vm.$options._parentListeners = listeners;
  4292. updateComponentListeners(vm, listeners, prevListeners);
  4293. // update props
  4294. if (propsData && vm.$options.props) {
  4295. toggleObserving(false);
  4296. const props = vm._props;
  4297. const propKeys = vm.$options._propKeys || [];
  4298. for (let i = 0; i < propKeys.length; i++) {
  4299. const key = propKeys[i];
  4300. const propOptions = vm.$options.props; // wtf flow?
  4301. props[key] = validateProp(key, propOptions, propsData, vm);
  4302. }
  4303. toggleObserving(true);
  4304. // keep a copy of raw propsData
  4305. vm.$options.propsData = propsData;
  4306. }
  4307. // resolve slots + force update if has children
  4308. if (needsForceUpdate) {
  4309. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  4310. vm.$forceUpdate();
  4311. }
  4312. if (process.env.NODE_ENV !== 'production') ;
  4313. }
  4314. function isInInactiveTree(vm) {
  4315. while (vm && (vm = vm.$parent)) {
  4316. if (vm._inactive)
  4317. return true;
  4318. }
  4319. return false;
  4320. }
  4321. function activateChildComponent(vm, direct) {
  4322. if (direct) {
  4323. vm._directInactive = false;
  4324. if (isInInactiveTree(vm)) {
  4325. return;
  4326. }
  4327. }
  4328. else if (vm._directInactive) {
  4329. return;
  4330. }
  4331. if (vm._inactive || vm._inactive === null) {
  4332. vm._inactive = false;
  4333. for (let i = 0; i < vm.$children.length; i++) {
  4334. activateChildComponent(vm.$children[i]);
  4335. }
  4336. callHook(vm, 'activated');
  4337. }
  4338. }
  4339. function deactivateChildComponent(vm, direct) {
  4340. if (direct) {
  4341. vm._directInactive = true;
  4342. if (isInInactiveTree(vm)) {
  4343. return;
  4344. }
  4345. }
  4346. if (!vm._inactive) {
  4347. vm._inactive = true;
  4348. for (let i = 0; i < vm.$children.length; i++) {
  4349. deactivateChildComponent(vm.$children[i]);
  4350. }
  4351. callHook(vm, 'deactivated');
  4352. }
  4353. }
  4354. function callHook(vm, hook, args, setContext = true) {
  4355. // #7573 disable dep collection when invoking lifecycle hooks
  4356. pushTarget();
  4357. const prev = currentInstance;
  4358. setContext && setCurrentInstance(vm);
  4359. const handlers = vm.$options[hook];
  4360. const info = `${hook} hook`;
  4361. if (handlers) {
  4362. for (let i = 0, j = handlers.length; i < j; i++) {
  4363. invokeWithErrorHandling(handlers[i], vm, args || null, vm, info);
  4364. }
  4365. }
  4366. if (vm._hasHookEvent) {
  4367. vm.$emit('hook:' + hook);
  4368. }
  4369. setContext && setCurrentInstance(prev);
  4370. popTarget();
  4371. }
  4372. // Async edge case fix requires storing an event listener's attach timestamp.
  4373. let getNow = Date.now;
  4374. // Determine what event timestamp the browser is using. Annoyingly, the
  4375. // timestamp can either be hi-res (relative to page load) or low-res
  4376. // (relative to UNIX epoch), so in order to compare time we have to use the
  4377. // same timestamp type when saving the flush timestamp.
  4378. // All IE versions use low-res event timestamps, and have problematic clock
  4379. // implementations (#9632)
  4380. if (inBrowser && !isIE) {
  4381. const performance = window.performance;
  4382. if (performance &&
  4383. typeof performance.now === 'function' &&
  4384. getNow() > document.createEvent('Event').timeStamp) {
  4385. // if the event timestamp, although evaluated AFTER the Date.now(), is
  4386. // smaller than it, it means the event is using a hi-res timestamp,
  4387. // and we need to use the hi-res version for event listener timestamps as
  4388. // well.
  4389. getNow = () => performance.now();
  4390. }
  4391. }
  4392. /**
  4393. * Queue a kept-alive component that was activated during patch.
  4394. * The queue will be processed after the entire tree has been patched.
  4395. */
  4396. function queueActivatedComponent(vm) {
  4397. // setting _inactive to false here so that a render function can
  4398. // rely on checking whether it's in an inactive tree (e.g. router-view)
  4399. vm._inactive = false;
  4400. }
  4401. function handleError(err, vm, info) {
  4402. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  4403. // See: https://github.com/vuejs/vuex/issues/1505
  4404. pushTarget();
  4405. try {
  4406. if (vm) {
  4407. let cur = vm;
  4408. while ((cur = cur.$parent)) {
  4409. const hooks = cur.$options.errorCaptured;
  4410. if (hooks) {
  4411. for (let i = 0; i < hooks.length; i++) {
  4412. try {
  4413. const capture = hooks[i].call(cur, err, vm, info) === false;
  4414. if (capture)
  4415. return;
  4416. }
  4417. catch (e) {
  4418. globalHandleError(e, cur, 'errorCaptured hook');
  4419. }
  4420. }
  4421. }
  4422. }
  4423. }
  4424. globalHandleError(err, vm, info);
  4425. }
  4426. finally {
  4427. popTarget();
  4428. }
  4429. }
  4430. function invokeWithErrorHandling(handler, context, args, vm, info) {
  4431. let res;
  4432. try {
  4433. res = args ? handler.apply(context, args) : handler.call(context);
  4434. if (res && !res._isVue && isPromise(res) && !res._handled) {
  4435. res.catch(e => handleError(e, vm, info + ` (Promise/async)`));
  4436. res._handled = true;
  4437. }
  4438. }
  4439. catch (e) {
  4440. handleError(e, vm, info);
  4441. }
  4442. return res;
  4443. }
  4444. function globalHandleError(err, vm, info) {
  4445. logError(err, vm, info);
  4446. }
  4447. function logError(err, vm, info) {
  4448. if (process.env.NODE_ENV !== 'production') {
  4449. warn$3(`Error in ${info}: "${err.toString()}"`, vm);
  4450. }
  4451. /* istanbul ignore else */
  4452. if (inBrowser && typeof console !== 'undefined') {
  4453. console.error(err);
  4454. }
  4455. else {
  4456. throw err;
  4457. }
  4458. }
  4459. /* globals MutationObserver */
  4460. const callbacks = [];
  4461. function flushCallbacks() {
  4462. const copies = callbacks.slice(0);
  4463. callbacks.length = 0;
  4464. for (let i = 0; i < copies.length; i++) {
  4465. copies[i]();
  4466. }
  4467. }
  4468. // The nextTick behavior leverages the microtask queue, which can be accessed
  4469. // via either native Promise.then or MutationObserver.
  4470. // MutationObserver has wider support, however it is seriously bugged in
  4471. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  4472. // completely stops working after triggering a few times... so, if native
  4473. // Promise is available, we will use it:
  4474. /* istanbul ignore next, $flow-disable-line */
  4475. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  4476. Promise.resolve();
  4477. }
  4478. else if (!isIE &&
  4479. typeof MutationObserver !== 'undefined' &&
  4480. (isNative(MutationObserver) ||
  4481. // PhantomJS and iOS 7.x
  4482. MutationObserver.toString() === '[object MutationObserverConstructor]')) {
  4483. // Use MutationObserver where native Promise is not available,
  4484. // e.g. PhantomJS, iOS7, Android 4.4
  4485. // (#6466 MutationObserver is unreliable in IE11)
  4486. let counter = 1;
  4487. const observer = new MutationObserver(flushCallbacks);
  4488. const textNode = document.createTextNode(String(counter));
  4489. observer.observe(textNode, {
  4490. characterData: true
  4491. });
  4492. }
  4493. else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) ;
  4494. else ;
  4495. const seenObjects = new _Set();
  4496. /**
  4497. * Recursively traverse an object to evoke all converted
  4498. * getters, so that every nested property inside the object
  4499. * is collected as a "deep" dependency.
  4500. */
  4501. function traverse(val) {
  4502. _traverse(val, seenObjects);
  4503. seenObjects.clear();
  4504. return val;
  4505. }
  4506. function _traverse(val, seen) {
  4507. let i, keys;
  4508. const isA = isArray(val);
  4509. if ((!isA && !isObject$1(val)) ||
  4510. val.__v_skip /* ReactiveFlags.SKIP */ ||
  4511. Object.isFrozen(val) ||
  4512. val instanceof VNode) {
  4513. return;
  4514. }
  4515. if (val.__ob__) {
  4516. const depId = val.__ob__.dep.id;
  4517. if (seen.has(depId)) {
  4518. return;
  4519. }
  4520. seen.add(depId);
  4521. }
  4522. if (isA) {
  4523. i = val.length;
  4524. while (i--)
  4525. _traverse(val[i], seen);
  4526. }
  4527. else if (isRef(val)) {
  4528. _traverse(val.value, seen);
  4529. }
  4530. else {
  4531. keys = Object.keys(val);
  4532. i = keys.length;
  4533. while (i--)
  4534. _traverse(val[keys[i]], seen);
  4535. }
  4536. }
  4537. function resolveInject(inject, vm) {
  4538. if (inject) {
  4539. // inject is :any because flow is not smart enough to figure out cached
  4540. const result = Object.create(null);
  4541. const keys = hasSymbol ? Reflect.ownKeys(inject) : Object.keys(inject);
  4542. for (let i = 0; i < keys.length; i++) {
  4543. const key = keys[i];
  4544. // #6574 in case the inject object is observed...
  4545. if (key === '__ob__')
  4546. continue;
  4547. const provideKey = inject[key].from;
  4548. if (provideKey in vm._provided) {
  4549. result[key] = vm._provided[provideKey];
  4550. }
  4551. else if ('default' in inject[key]) {
  4552. const provideDefault = inject[key].default;
  4553. result[key] = isFunction(provideDefault)
  4554. ? provideDefault.call(vm)
  4555. : provideDefault;
  4556. }
  4557. else if (process.env.NODE_ENV !== 'production') {
  4558. warn$3(`Injection "${key}" not found`, vm);
  4559. }
  4560. }
  4561. return result;
  4562. }
  4563. }
  4564. function resolveConstructorOptions(Ctor) {
  4565. let options = Ctor.options;
  4566. if (Ctor.super) {
  4567. const superOptions = resolveConstructorOptions(Ctor.super);
  4568. const cachedSuperOptions = Ctor.superOptions;
  4569. if (superOptions !== cachedSuperOptions) {
  4570. // super option changed,
  4571. // need to resolve new options.
  4572. Ctor.superOptions = superOptions;
  4573. // check if there are any late-modified/attached options (#4976)
  4574. const modifiedOptions = resolveModifiedOptions(Ctor);
  4575. // update base extend options
  4576. if (modifiedOptions) {
  4577. extend(Ctor.extendOptions, modifiedOptions);
  4578. }
  4579. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  4580. if (options.name) {
  4581. options.components[options.name] = Ctor;
  4582. }
  4583. }
  4584. }
  4585. return options;
  4586. }
  4587. function resolveModifiedOptions(Ctor) {
  4588. let modified;
  4589. const latest = Ctor.options;
  4590. const sealed = Ctor.sealedOptions;
  4591. for (const key in latest) {
  4592. if (latest[key] !== sealed[key]) {
  4593. if (!modified)
  4594. modified = {};
  4595. modified[key] = latest[key];
  4596. }
  4597. }
  4598. return modified;
  4599. }
  4600. function FunctionalRenderContext(data, props, children, parent, Ctor) {
  4601. const options = Ctor.options;
  4602. // ensure the createElement function in functional components
  4603. // gets a unique context - this is necessary for correct named slot check
  4604. let contextVm;
  4605. if (hasOwn(parent, '_uid')) {
  4606. contextVm = Object.create(parent);
  4607. contextVm._original = parent;
  4608. }
  4609. else {
  4610. // the context vm passed in is a functional context as well.
  4611. // in this case we want to make sure we are able to get a hold to the
  4612. // real context instance.
  4613. contextVm = parent;
  4614. // @ts-ignore
  4615. parent = parent._original;
  4616. }
  4617. const isCompiled = isTrue(options._compiled);
  4618. const needNormalization = !isCompiled;
  4619. this.data = data;
  4620. this.props = props;
  4621. this.children = children;
  4622. this.parent = parent;
  4623. this.listeners = data.on || emptyObject;
  4624. this.injections = resolveInject(options.inject, parent);
  4625. this.slots = () => {
  4626. if (!this.$slots) {
  4627. normalizeScopedSlots(parent, data.scopedSlots, (this.$slots = resolveSlots(children, parent)));
  4628. }
  4629. return this.$slots;
  4630. };
  4631. Object.defineProperty(this, 'scopedSlots', {
  4632. enumerable: true,
  4633. get() {
  4634. return normalizeScopedSlots(parent, data.scopedSlots, this.slots());
  4635. }
  4636. });
  4637. // support for compiled functional template
  4638. if (isCompiled) {
  4639. // exposing $options for renderStatic()
  4640. this.$options = options;
  4641. // pre-resolve slots for renderSlot()
  4642. this.$slots = this.slots();
  4643. this.$scopedSlots = normalizeScopedSlots(parent, data.scopedSlots, this.$slots);
  4644. }
  4645. if (options._scopeId) {
  4646. this._c = (a, b, c, d) => {
  4647. const vnode = createElement(contextVm, a, b, c, d, needNormalization);
  4648. if (vnode && !isArray(vnode)) {
  4649. vnode.fnScopeId = options._scopeId;
  4650. vnode.fnContext = parent;
  4651. }
  4652. return vnode;
  4653. };
  4654. }
  4655. else {
  4656. this._c = (a, b, c, d) => createElement(contextVm, a, b, c, d, needNormalization);
  4657. }
  4658. }
  4659. installRenderHelpers(FunctionalRenderContext.prototype);
  4660. function createFunctionalComponent(Ctor, propsData, data, contextVm, children) {
  4661. const options = Ctor.options;
  4662. const props = {};
  4663. const propOptions = options.props;
  4664. if (isDef(propOptions)) {
  4665. for (const key in propOptions) {
  4666. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  4667. }
  4668. }
  4669. else {
  4670. if (isDef(data.attrs))
  4671. mergeProps(props, data.attrs);
  4672. if (isDef(data.props))
  4673. mergeProps(props, data.props);
  4674. }
  4675. const renderContext = new FunctionalRenderContext(data, props, children, contextVm, Ctor);
  4676. const vnode = options.render.call(null, renderContext._c, renderContext);
  4677. if (vnode instanceof VNode) {
  4678. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext);
  4679. }
  4680. else if (isArray(vnode)) {
  4681. const vnodes = normalizeChildren(vnode) || [];
  4682. const res = new Array(vnodes.length);
  4683. for (let i = 0; i < vnodes.length; i++) {
  4684. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  4685. }
  4686. return res;
  4687. }
  4688. }
  4689. function cloneAndMarkFunctionalResult(vnode, data, contextVm, options, renderContext) {
  4690. // #7817 clone node before setting fnContext, otherwise if the node is reused
  4691. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  4692. // that should not be matched to match.
  4693. const clone = cloneVNode(vnode);
  4694. clone.fnContext = contextVm;
  4695. clone.fnOptions = options;
  4696. if (process.env.NODE_ENV !== 'production') {
  4697. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext =
  4698. renderContext;
  4699. }
  4700. if (data.slot) {
  4701. (clone.data || (clone.data = {})).slot = data.slot;
  4702. }
  4703. return clone;
  4704. }
  4705. function mergeProps(to, from) {
  4706. for (const key in from) {
  4707. to[camelize(key)] = from[key];
  4708. }
  4709. }
  4710. function getComponentName(options) {
  4711. return options.name || options.__name || options._componentTag;
  4712. }
  4713. // inline hooks to be invoked on component VNodes during patch
  4714. const componentVNodeHooks = {
  4715. init(vnode, hydrating) {
  4716. if (vnode.componentInstance &&
  4717. !vnode.componentInstance._isDestroyed &&
  4718. vnode.data.keepAlive) {
  4719. // kept-alive components, treat as a patch
  4720. const mountedNode = vnode; // work around flow
  4721. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  4722. }
  4723. else {
  4724. const child = (vnode.componentInstance = createComponentInstanceForVnode(vnode, activeInstance));
  4725. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  4726. }
  4727. },
  4728. prepatch(oldVnode, vnode) {
  4729. const options = vnode.componentOptions;
  4730. const child = (vnode.componentInstance = oldVnode.componentInstance);
  4731. updateChildComponent(child, options.propsData, // updated props
  4732. options.listeners, // updated listeners
  4733. vnode, // new parent vnode
  4734. options.children // new children
  4735. );
  4736. },
  4737. insert(vnode) {
  4738. const { context, componentInstance } = vnode;
  4739. if (!componentInstance._isMounted) {
  4740. componentInstance._isMounted = true;
  4741. callHook(componentInstance, 'mounted');
  4742. }
  4743. if (vnode.data.keepAlive) {
  4744. if (context._isMounted) {
  4745. // vue-router#1212
  4746. // During updates, a kept-alive component's child components may
  4747. // change, so directly walking the tree here may call activated hooks
  4748. // on incorrect children. Instead we push them into a queue which will
  4749. // be processed after the whole patch process ended.
  4750. queueActivatedComponent(componentInstance);
  4751. }
  4752. else {
  4753. activateChildComponent(componentInstance, true /* direct */);
  4754. }
  4755. }
  4756. },
  4757. destroy(vnode) {
  4758. const { componentInstance } = vnode;
  4759. if (!componentInstance._isDestroyed) {
  4760. if (!vnode.data.keepAlive) {
  4761. componentInstance.$destroy();
  4762. }
  4763. else {
  4764. deactivateChildComponent(componentInstance, true /* direct */);
  4765. }
  4766. }
  4767. }
  4768. };
  4769. const hooksToMerge = Object.keys(componentVNodeHooks);
  4770. function createComponent(Ctor, data, context, children, tag) {
  4771. if (isUndef(Ctor)) {
  4772. return;
  4773. }
  4774. const baseCtor = context.$options._base;
  4775. // plain options object: turn it into a constructor
  4776. if (isObject$1(Ctor)) {
  4777. Ctor = baseCtor.extend(Ctor);
  4778. }
  4779. // if at this stage it's not a constructor or an async component factory,
  4780. // reject.
  4781. if (typeof Ctor !== 'function') {
  4782. if (process.env.NODE_ENV !== 'production') {
  4783. warn$3(`Invalid Component definition: ${String(Ctor)}`, context);
  4784. }
  4785. return;
  4786. }
  4787. // async component
  4788. let asyncFactory;
  4789. // @ts-expect-error
  4790. if (isUndef(Ctor.cid)) {
  4791. asyncFactory = Ctor;
  4792. Ctor = resolveAsyncComponent(asyncFactory);
  4793. if (Ctor === undefined) {
  4794. // return a placeholder node for async component, which is rendered
  4795. // as a comment node but preserves all the raw information for the node.
  4796. // the information will be used for async server-rendering and hydration.
  4797. return createAsyncPlaceholder(asyncFactory, data, context, children, tag);
  4798. }
  4799. }
  4800. data = data || {};
  4801. // resolve constructor options in case global mixins are applied after
  4802. // component constructor creation
  4803. resolveConstructorOptions(Ctor);
  4804. // transform component v-model data into props & events
  4805. if (isDef(data.model)) {
  4806. // @ts-expect-error
  4807. transformModel(Ctor.options, data);
  4808. }
  4809. // extract props
  4810. // @ts-expect-error
  4811. const propsData = extractPropsFromVNodeData(data, Ctor, tag);
  4812. // functional component
  4813. // @ts-expect-error
  4814. if (isTrue(Ctor.options.functional)) {
  4815. return createFunctionalComponent(Ctor, propsData, data, context, children);
  4816. }
  4817. // extract listeners, since these needs to be treated as
  4818. // child component listeners instead of DOM listeners
  4819. const listeners = data.on;
  4820. // replace with listeners with .native modifier
  4821. // so it gets processed during parent component patch.
  4822. data.on = data.nativeOn;
  4823. // @ts-expect-error
  4824. if (isTrue(Ctor.options.abstract)) {
  4825. // abstract components do not keep anything
  4826. // other than props & listeners & slot
  4827. // work around flow
  4828. const slot = data.slot;
  4829. data = {};
  4830. if (slot) {
  4831. data.slot = slot;
  4832. }
  4833. }
  4834. // install component management hooks onto the placeholder node
  4835. installComponentHooks(data);
  4836. // return a placeholder vnode
  4837. // @ts-expect-error
  4838. const name = getComponentName(Ctor.options) || tag;
  4839. const vnode = new VNode(
  4840. // @ts-expect-error
  4841. `vue-component-${Ctor.cid}${name ? `-${name}` : ''}`, data, undefined, undefined, undefined, context,
  4842. // @ts-expect-error
  4843. { Ctor, propsData, listeners, tag, children }, asyncFactory);
  4844. return vnode;
  4845. }
  4846. function createComponentInstanceForVnode(
  4847. // we know it's MountedComponentVNode but flow doesn't
  4848. vnode,
  4849. // activeInstance in lifecycle state
  4850. parent) {
  4851. const options = {
  4852. _isComponent: true,
  4853. _parentVnode: vnode,
  4854. parent
  4855. };
  4856. // check inline-template render functions
  4857. const inlineTemplate = vnode.data.inlineTemplate;
  4858. if (isDef(inlineTemplate)) {
  4859. options.render = inlineTemplate.render;
  4860. options.staticRenderFns = inlineTemplate.staticRenderFns;
  4861. }
  4862. return new vnode.componentOptions.Ctor(options);
  4863. }
  4864. function installComponentHooks(data) {
  4865. const hooks = data.hook || (data.hook = {});
  4866. for (let i = 0; i < hooksToMerge.length; i++) {
  4867. const key = hooksToMerge[i];
  4868. const existing = hooks[key];
  4869. const toMerge = componentVNodeHooks[key];
  4870. // @ts-expect-error
  4871. if (existing !== toMerge && !(existing && existing._merged)) {
  4872. hooks[key] = existing ? mergeHook(toMerge, existing) : toMerge;
  4873. }
  4874. }
  4875. }
  4876. function mergeHook(f1, f2) {
  4877. const merged = (a, b) => {
  4878. // flow complains about extra args which is why we use any
  4879. f1(a, b);
  4880. f2(a, b);
  4881. };
  4882. merged._merged = true;
  4883. return merged;
  4884. }
  4885. // transform component v-model info (value and callback) into
  4886. // prop and event handler respectively.
  4887. function transformModel(options, data) {
  4888. const prop = (options.model && options.model.prop) || 'value';
  4889. const event = (options.model && options.model.event) || 'input';
  4890. (data.attrs || (data.attrs = {}))[prop] = data.model.value;
  4891. const on = data.on || (data.on = {});
  4892. const existing = on[event];
  4893. const callback = data.model.callback;
  4894. if (isDef(existing)) {
  4895. if (isArray(existing)
  4896. ? existing.indexOf(callback) === -1
  4897. : existing !== callback) {
  4898. on[event] = [callback].concat(existing);
  4899. }
  4900. }
  4901. else {
  4902. on[event] = callback;
  4903. }
  4904. }
  4905. let warn$3 = noop;
  4906. let tip = noop;
  4907. let generateComponentTrace; // work around flow check
  4908. let formatComponentName;
  4909. if (process.env.NODE_ENV !== 'production') {
  4910. const hasConsole = typeof console !== 'undefined';
  4911. const classifyRE = /(?:^|[-_])(\w)/g;
  4912. const classify = str => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
  4913. warn$3 = (msg, vm = currentInstance) => {
  4914. const trace = vm ? generateComponentTrace(vm) : '';
  4915. if (hasConsole && !config.silent) {
  4916. console.error(`[Vue warn]: ${msg}${trace}`);
  4917. }
  4918. };
  4919. tip = (msg, vm) => {
  4920. if (hasConsole && !config.silent) {
  4921. console.warn(`[Vue tip]: ${msg}` + (vm ? generateComponentTrace(vm) : ''));
  4922. }
  4923. };
  4924. formatComponentName = (vm, includeFile) => {
  4925. if (vm.$root === vm) {
  4926. return '<Root>';
  4927. }
  4928. const options = isFunction(vm) && vm.cid != null
  4929. ? vm.options
  4930. : vm._isVue
  4931. ? vm.$options || vm.constructor.options
  4932. : vm;
  4933. let name = getComponentName(options);
  4934. const file = options.__file;
  4935. if (!name && file) {
  4936. const match = file.match(/([^/\\]+)\.vue$/);
  4937. name = match && match[1];
  4938. }
  4939. return ((name ? `<${classify(name)}>` : `<Anonymous>`) +
  4940. (file && includeFile !== false ? ` at ${file}` : ''));
  4941. };
  4942. const repeat = (str, n) => {
  4943. let res = '';
  4944. while (n) {
  4945. if (n % 2 === 1)
  4946. res += str;
  4947. if (n > 1)
  4948. str += str;
  4949. n >>= 1;
  4950. }
  4951. return res;
  4952. };
  4953. generateComponentTrace = (vm) => {
  4954. if (vm._isVue && vm.$parent) {
  4955. const tree = [];
  4956. let currentRecursiveSequence = 0;
  4957. while (vm) {
  4958. if (tree.length > 0) {
  4959. const last = tree[tree.length - 1];
  4960. if (last.constructor === vm.constructor) {
  4961. currentRecursiveSequence++;
  4962. vm = vm.$parent;
  4963. continue;
  4964. }
  4965. else if (currentRecursiveSequence > 0) {
  4966. tree[tree.length - 1] = [last, currentRecursiveSequence];
  4967. currentRecursiveSequence = 0;
  4968. }
  4969. }
  4970. tree.push(vm);
  4971. vm = vm.$parent;
  4972. }
  4973. return ('\n\nfound in\n\n' +
  4974. tree
  4975. .map((vm, i) => `${i === 0 ? '---> ' : repeat(' ', 5 + i * 2)}${isArray(vm)
  4976. ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`
  4977. : formatComponentName(vm)}`)
  4978. .join('\n'));
  4979. }
  4980. else {
  4981. return `\n\n(found in ${formatComponentName(vm)})`;
  4982. }
  4983. };
  4984. }
  4985. /**
  4986. * Option overwriting strategies are functions that handle
  4987. * how to merge a parent option value and a child option
  4988. * value into the final value.
  4989. */
  4990. const strats = config.optionMergeStrategies;
  4991. /**
  4992. * Options with restrictions
  4993. */
  4994. if (process.env.NODE_ENV !== 'production') {
  4995. strats.el = strats.propsData = function (parent, child, vm, key) {
  4996. if (!vm) {
  4997. warn$3(`option "${key}" can only be used during instance ` +
  4998. 'creation with the `new` keyword.');
  4999. }
  5000. return defaultStrat(parent, child);
  5001. };
  5002. }
  5003. /**
  5004. * Helper that recursively merges two data objects together.
  5005. */
  5006. function mergeData(to, from) {
  5007. if (!from)
  5008. return to;
  5009. let key, toVal, fromVal;
  5010. const keys = hasSymbol
  5011. ? Reflect.ownKeys(from)
  5012. : Object.keys(from);
  5013. for (let i = 0; i < keys.length; i++) {
  5014. key = keys[i];
  5015. // in case the object is already observed...
  5016. if (key === '__ob__')
  5017. continue;
  5018. toVal = to[key];
  5019. fromVal = from[key];
  5020. if (!hasOwn(to, key)) {
  5021. set(to, key, fromVal);
  5022. }
  5023. else if (toVal !== fromVal &&
  5024. isPlainObject(toVal) &&
  5025. isPlainObject(fromVal)) {
  5026. mergeData(toVal, fromVal);
  5027. }
  5028. }
  5029. return to;
  5030. }
  5031. /**
  5032. * Data
  5033. */
  5034. function mergeDataOrFn(parentVal, childVal, vm) {
  5035. if (!vm) {
  5036. // in a Vue.extend merge, both should be functions
  5037. if (!childVal) {
  5038. return parentVal;
  5039. }
  5040. if (!parentVal) {
  5041. return childVal;
  5042. }
  5043. // when parentVal & childVal are both present,
  5044. // we need to return a function that returns the
  5045. // merged result of both functions... no need to
  5046. // check if parentVal is a function here because
  5047. // it has to be a function to pass previous merges.
  5048. return function mergedDataFn() {
  5049. return mergeData(isFunction(childVal) ? childVal.call(this, this) : childVal, isFunction(parentVal) ? parentVal.call(this, this) : parentVal);
  5050. };
  5051. }
  5052. else {
  5053. return function mergedInstanceDataFn() {
  5054. // instance merge
  5055. const instanceData = isFunction(childVal)
  5056. ? childVal.call(vm, vm)
  5057. : childVal;
  5058. const defaultData = isFunction(parentVal)
  5059. ? parentVal.call(vm, vm)
  5060. : parentVal;
  5061. if (instanceData) {
  5062. return mergeData(instanceData, defaultData);
  5063. }
  5064. else {
  5065. return defaultData;
  5066. }
  5067. };
  5068. }
  5069. }
  5070. strats.data = function (parentVal, childVal, vm) {
  5071. if (!vm) {
  5072. if (childVal && typeof childVal !== 'function') {
  5073. process.env.NODE_ENV !== 'production' &&
  5074. warn$3('The "data" option should be a function ' +
  5075. 'that returns a per-instance value in component ' +
  5076. 'definitions.', vm);
  5077. return parentVal;
  5078. }
  5079. return mergeDataOrFn(parentVal, childVal);
  5080. }
  5081. return mergeDataOrFn(parentVal, childVal, vm);
  5082. };
  5083. /**
  5084. * Hooks and props are merged as arrays.
  5085. */
  5086. function mergeLifecycleHook(parentVal, childVal) {
  5087. const res = childVal
  5088. ? parentVal
  5089. ? parentVal.concat(childVal)
  5090. : isArray(childVal)
  5091. ? childVal
  5092. : [childVal]
  5093. : parentVal;
  5094. return res ? dedupeHooks(res) : res;
  5095. }
  5096. function dedupeHooks(hooks) {
  5097. const res = [];
  5098. for (let i = 0; i < hooks.length; i++) {
  5099. if (res.indexOf(hooks[i]) === -1) {
  5100. res.push(hooks[i]);
  5101. }
  5102. }
  5103. return res;
  5104. }
  5105. LIFECYCLE_HOOKS.forEach(hook => {
  5106. strats[hook] = mergeLifecycleHook;
  5107. });
  5108. /**
  5109. * Assets
  5110. *
  5111. * When a vm is present (instance creation), we need to do
  5112. * a three-way merge between constructor options, instance
  5113. * options and parent options.
  5114. */
  5115. function mergeAssets(parentVal, childVal, vm, key) {
  5116. const res = Object.create(parentVal || null);
  5117. if (childVal) {
  5118. process.env.NODE_ENV !== 'production' && assertObjectType(key, childVal, vm);
  5119. return extend(res, childVal);
  5120. }
  5121. else {
  5122. return res;
  5123. }
  5124. }
  5125. ASSET_TYPES.forEach(function (type) {
  5126. strats[type + 's'] = mergeAssets;
  5127. });
  5128. /**
  5129. * Watchers.
  5130. *
  5131. * Watchers hashes should not overwrite one
  5132. * another, so we merge them as arrays.
  5133. */
  5134. strats.watch = function (parentVal, childVal, vm, key) {
  5135. // work around Firefox's Object.prototype.watch...
  5136. //@ts-expect-error work around
  5137. if (parentVal === nativeWatch)
  5138. parentVal = undefined;
  5139. //@ts-expect-error work around
  5140. if (childVal === nativeWatch)
  5141. childVal = undefined;
  5142. /* istanbul ignore if */
  5143. if (!childVal)
  5144. return Object.create(parentVal || null);
  5145. if (process.env.NODE_ENV !== 'production') {
  5146. assertObjectType(key, childVal, vm);
  5147. }
  5148. if (!parentVal)
  5149. return childVal;
  5150. const ret = {};
  5151. extend(ret, parentVal);
  5152. for (const key in childVal) {
  5153. let parent = ret[key];
  5154. const child = childVal[key];
  5155. if (parent && !isArray(parent)) {
  5156. parent = [parent];
  5157. }
  5158. ret[key] = parent ? parent.concat(child) : isArray(child) ? child : [child];
  5159. }
  5160. return ret;
  5161. };
  5162. /**
  5163. * Other object hashes.
  5164. */
  5165. strats.props =
  5166. strats.methods =
  5167. strats.inject =
  5168. strats.computed =
  5169. function (parentVal, childVal, vm, key) {
  5170. if (childVal && process.env.NODE_ENV !== 'production') {
  5171. assertObjectType(key, childVal, vm);
  5172. }
  5173. if (!parentVal)
  5174. return childVal;
  5175. const ret = Object.create(null);
  5176. extend(ret, parentVal);
  5177. if (childVal)
  5178. extend(ret, childVal);
  5179. return ret;
  5180. };
  5181. strats.provide = mergeDataOrFn;
  5182. /**
  5183. * Default strategy.
  5184. */
  5185. const defaultStrat = function (parentVal, childVal) {
  5186. return childVal === undefined ? parentVal : childVal;
  5187. };
  5188. /**
  5189. * Validate component names
  5190. */
  5191. function checkComponents(options) {
  5192. for (const key in options.components) {
  5193. validateComponentName(key);
  5194. }
  5195. }
  5196. function validateComponentName(name) {
  5197. if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeRegExp.source}]*$`).test(name)) {
  5198. warn$3('Invalid component name: "' +
  5199. name +
  5200. '". Component names ' +
  5201. 'should conform to valid custom element name in html5 specification.');
  5202. }
  5203. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  5204. warn$3('Do not use built-in or reserved HTML elements as component ' +
  5205. 'id: ' +
  5206. name);
  5207. }
  5208. }
  5209. /**
  5210. * Ensure all props option syntax are normalized into the
  5211. * Object-based format.
  5212. */
  5213. function normalizeProps(options, vm) {
  5214. const props = options.props;
  5215. if (!props)
  5216. return;
  5217. const res = {};
  5218. let i, val, name;
  5219. if (isArray(props)) {
  5220. i = props.length;
  5221. while (i--) {
  5222. val = props[i];
  5223. if (typeof val === 'string') {
  5224. name = camelize(val);
  5225. res[name] = { type: null };
  5226. }
  5227. else if (process.env.NODE_ENV !== 'production') {
  5228. warn$3('props must be strings when using array syntax.');
  5229. }
  5230. }
  5231. }
  5232. else if (isPlainObject(props)) {
  5233. for (const key in props) {
  5234. val = props[key];
  5235. name = camelize(key);
  5236. res[name] = isPlainObject(val) ? val : { type: val };
  5237. }
  5238. }
  5239. else if (process.env.NODE_ENV !== 'production') {
  5240. warn$3(`Invalid value for option "props": expected an Array or an Object, ` +
  5241. `but got ${toRawType(props)}.`, vm);
  5242. }
  5243. options.props = res;
  5244. }
  5245. /**
  5246. * Normalize all injections into Object-based format
  5247. */
  5248. function normalizeInject(options, vm) {
  5249. const inject = options.inject;
  5250. if (!inject)
  5251. return;
  5252. const normalized = (options.inject = {});
  5253. if (isArray(inject)) {
  5254. for (let i = 0; i < inject.length; i++) {
  5255. normalized[inject[i]] = { from: inject[i] };
  5256. }
  5257. }
  5258. else if (isPlainObject(inject)) {
  5259. for (const key in inject) {
  5260. const val = inject[key];
  5261. normalized[key] = isPlainObject(val)
  5262. ? extend({ from: key }, val)
  5263. : { from: val };
  5264. }
  5265. }
  5266. else if (process.env.NODE_ENV !== 'production') {
  5267. warn$3(`Invalid value for option "inject": expected an Array or an Object, ` +
  5268. `but got ${toRawType(inject)}.`, vm);
  5269. }
  5270. }
  5271. /**
  5272. * Normalize raw function directives into object format.
  5273. */
  5274. function normalizeDirectives(options) {
  5275. const dirs = options.directives;
  5276. if (dirs) {
  5277. for (const key in dirs) {
  5278. const def = dirs[key];
  5279. if (isFunction(def)) {
  5280. dirs[key] = { bind: def, update: def };
  5281. }
  5282. }
  5283. }
  5284. }
  5285. function assertObjectType(name, value, vm) {
  5286. if (!isPlainObject(value)) {
  5287. warn$3(`Invalid value for option "${name}": expected an Object, ` +
  5288. `but got ${toRawType(value)}.`, vm);
  5289. }
  5290. }
  5291. /**
  5292. * Merge two option objects into a new one.
  5293. * Core utility used in both instantiation and inheritance.
  5294. */
  5295. function mergeOptions(parent, child, vm) {
  5296. if (process.env.NODE_ENV !== 'production') {
  5297. checkComponents(child);
  5298. }
  5299. if (isFunction(child)) {
  5300. // @ts-expect-error
  5301. child = child.options;
  5302. }
  5303. normalizeProps(child, vm);
  5304. normalizeInject(child, vm);
  5305. normalizeDirectives(child);
  5306. // Apply extends and mixins on the child options,
  5307. // but only if it is a raw options object that isn't
  5308. // the result of another mergeOptions call.
  5309. // Only merged options has the _base property.
  5310. if (!child._base) {
  5311. if (child.extends) {
  5312. parent = mergeOptions(parent, child.extends, vm);
  5313. }
  5314. if (child.mixins) {
  5315. for (let i = 0, l = child.mixins.length; i < l; i++) {
  5316. parent = mergeOptions(parent, child.mixins[i], vm);
  5317. }
  5318. }
  5319. }
  5320. const options = {};
  5321. let key;
  5322. for (key in parent) {
  5323. mergeField(key);
  5324. }
  5325. for (key in child) {
  5326. if (!hasOwn(parent, key)) {
  5327. mergeField(key);
  5328. }
  5329. }
  5330. function mergeField(key) {
  5331. const strat = strats[key] || defaultStrat;
  5332. options[key] = strat(parent[key], child[key], vm, key);
  5333. }
  5334. return options;
  5335. }
  5336. /**
  5337. * Resolve an asset.
  5338. * This function is used because child instances need access
  5339. * to assets defined in its ancestor chain.
  5340. */
  5341. function resolveAsset(options, type, id, warnMissing) {
  5342. /* istanbul ignore if */
  5343. if (typeof id !== 'string') {
  5344. return;
  5345. }
  5346. const assets = options[type];
  5347. // check local registration variations first
  5348. if (hasOwn(assets, id))
  5349. return assets[id];
  5350. const camelizedId = camelize(id);
  5351. if (hasOwn(assets, camelizedId))
  5352. return assets[camelizedId];
  5353. const PascalCaseId = capitalize(camelizedId);
  5354. if (hasOwn(assets, PascalCaseId))
  5355. return assets[PascalCaseId];
  5356. // fallback to prototype chain
  5357. const res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  5358. if (process.env.NODE_ENV !== 'production' && warnMissing && !res) {
  5359. warn$3('Failed to resolve ' + type.slice(0, -1) + ': ' + id);
  5360. }
  5361. return res;
  5362. }
  5363. function validateProp(key, propOptions, propsData, vm) {
  5364. const prop = propOptions[key];
  5365. const absent = !hasOwn(propsData, key);
  5366. let value = propsData[key];
  5367. // boolean casting
  5368. const booleanIndex = getTypeIndex(Boolean, prop.type);
  5369. if (booleanIndex > -1) {
  5370. if (absent && !hasOwn(prop, 'default')) {
  5371. value = false;
  5372. }
  5373. else if (value === '' || value === hyphenate(key)) {
  5374. // only cast empty string / same name to boolean if
  5375. // boolean has higher priority
  5376. const stringIndex = getTypeIndex(String, prop.type);
  5377. if (stringIndex < 0 || booleanIndex < stringIndex) {
  5378. value = true;
  5379. }
  5380. }
  5381. }
  5382. // check default value
  5383. if (value === undefined) {
  5384. value = getPropDefaultValue(vm, prop, key);
  5385. // since the default value is a fresh copy,
  5386. // make sure to observe it.
  5387. const prevShouldObserve = shouldObserve;
  5388. toggleObserving(true);
  5389. observe(value);
  5390. toggleObserving(prevShouldObserve);
  5391. }
  5392. if (process.env.NODE_ENV !== 'production') {
  5393. assertProp(prop, key, value, vm, absent);
  5394. }
  5395. return value;
  5396. }
  5397. /**
  5398. * Get the default value of a prop.
  5399. */
  5400. function getPropDefaultValue(vm, prop, key) {
  5401. // no default, return undefined
  5402. if (!hasOwn(prop, 'default')) {
  5403. return undefined;
  5404. }
  5405. const def = prop.default;
  5406. // warn against non-factory defaults for Object & Array
  5407. if (process.env.NODE_ENV !== 'production' && isObject$1(def)) {
  5408. warn$3('Invalid default value for prop "' +
  5409. key +
  5410. '": ' +
  5411. 'Props with type Object/Array must use a factory function ' +
  5412. 'to return the default value.', vm);
  5413. }
  5414. // the raw prop value was also undefined from previous render,
  5415. // return previous default value to avoid unnecessary watcher trigger
  5416. if (vm &&
  5417. vm.$options.propsData &&
  5418. vm.$options.propsData[key] === undefined &&
  5419. vm._props[key] !== undefined) {
  5420. return vm._props[key];
  5421. }
  5422. // call factory function for non-Function types
  5423. // a value is Function if its prototype is function even across different execution context
  5424. return isFunction(def) && getType(prop.type) !== 'Function'
  5425. ? def.call(vm)
  5426. : def;
  5427. }
  5428. /**
  5429. * Assert whether a prop is valid.
  5430. */
  5431. function assertProp(prop, name, value, vm, absent) {
  5432. if (prop.required && absent) {
  5433. warn$3('Missing required prop: "' + name + '"', vm);
  5434. return;
  5435. }
  5436. if (value == null && !prop.required) {
  5437. return;
  5438. }
  5439. let type = prop.type;
  5440. let valid = !type || type === true;
  5441. const expectedTypes = [];
  5442. if (type) {
  5443. if (!isArray(type)) {
  5444. type = [type];
  5445. }
  5446. for (let i = 0; i < type.length && !valid; i++) {
  5447. const assertedType = assertType(value, type[i], vm);
  5448. expectedTypes.push(assertedType.expectedType || '');
  5449. valid = assertedType.valid;
  5450. }
  5451. }
  5452. const haveExpectedTypes = expectedTypes.some(t => t);
  5453. if (!valid && haveExpectedTypes) {
  5454. warn$3(getInvalidTypeMessage(name, value, expectedTypes), vm);
  5455. return;
  5456. }
  5457. const validator = prop.validator;
  5458. if (validator) {
  5459. if (!validator(value)) {
  5460. warn$3('Invalid prop: custom validator check failed for prop "' + name + '".', vm);
  5461. }
  5462. }
  5463. }
  5464. const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/;
  5465. function assertType(value, type, vm) {
  5466. let valid;
  5467. const expectedType = getType(type);
  5468. if (simpleCheckRE.test(expectedType)) {
  5469. const t = typeof value;
  5470. valid = t === expectedType.toLowerCase();
  5471. // for primitive wrapper objects
  5472. if (!valid && t === 'object') {
  5473. valid = value instanceof type;
  5474. }
  5475. }
  5476. else if (expectedType === 'Object') {
  5477. valid = isPlainObject(value);
  5478. }
  5479. else if (expectedType === 'Array') {
  5480. valid = isArray(value);
  5481. }
  5482. else {
  5483. try {
  5484. valid = value instanceof type;
  5485. }
  5486. catch (e) {
  5487. warn$3('Invalid prop type: "' + String(type) + '" is not a constructor', vm);
  5488. valid = false;
  5489. }
  5490. }
  5491. return {
  5492. valid,
  5493. expectedType
  5494. };
  5495. }
  5496. const functionTypeCheckRE = /^\s*function (\w+)/;
  5497. /**
  5498. * Use function string name to check built-in types,
  5499. * because a simple equality check will fail when running
  5500. * across different vms / iframes.
  5501. */
  5502. function getType(fn) {
  5503. const match = fn && fn.toString().match(functionTypeCheckRE);
  5504. return match ? match[1] : '';
  5505. }
  5506. function isSameType(a, b) {
  5507. return getType(a) === getType(b);
  5508. }
  5509. function getTypeIndex(type, expectedTypes) {
  5510. if (!isArray(expectedTypes)) {
  5511. return isSameType(expectedTypes, type) ? 0 : -1;
  5512. }
  5513. for (let i = 0, len = expectedTypes.length; i < len; i++) {
  5514. if (isSameType(expectedTypes[i], type)) {
  5515. return i;
  5516. }
  5517. }
  5518. return -1;
  5519. }
  5520. function getInvalidTypeMessage(name, value, expectedTypes) {
  5521. let message = `Invalid prop: type check failed for prop "${name}".` +
  5522. ` Expected ${expectedTypes.map(capitalize).join(', ')}`;
  5523. const expectedType = expectedTypes[0];
  5524. const receivedType = toRawType(value);
  5525. // check if we need to specify expected value
  5526. if (expectedTypes.length === 1 &&
  5527. isExplicable(expectedType) &&
  5528. isExplicable(typeof value) &&
  5529. !isBoolean(expectedType, receivedType)) {
  5530. message += ` with value ${styleValue(value, expectedType)}`;
  5531. }
  5532. message += `, got ${receivedType} `;
  5533. // check if we need to specify received value
  5534. if (isExplicable(receivedType)) {
  5535. message += `with value ${styleValue(value, receivedType)}.`;
  5536. }
  5537. return message;
  5538. }
  5539. function styleValue(value, type) {
  5540. if (type === 'String') {
  5541. return `"${value}"`;
  5542. }
  5543. else if (type === 'Number') {
  5544. return `${Number(value)}`;
  5545. }
  5546. else {
  5547. return `${value}`;
  5548. }
  5549. }
  5550. const EXPLICABLE_TYPES = ['string', 'number', 'boolean'];
  5551. function isExplicable(value) {
  5552. return EXPLICABLE_TYPES.some(elem => value.toLowerCase() === elem);
  5553. }
  5554. function isBoolean(...args) {
  5555. return args.some(elem => elem.toLowerCase() === 'boolean');
  5556. }
  5557. // these are reserved for web because they are directly compiled away
  5558. // during template compilation
  5559. makeMap('style,class');
  5560. // attributes that should be using props for binding
  5561. const acceptValue = makeMap('input,textarea,option,select,progress');
  5562. const mustUseProp = (tag, type, attr) => {
  5563. return ((attr === 'value' && acceptValue(tag) && type !== 'button') ||
  5564. (attr === 'selected' && tag === 'option') ||
  5565. (attr === 'checked' && tag === 'input') ||
  5566. (attr === 'muted' && tag === 'video'));
  5567. };
  5568. const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  5569. makeMap('events,caret,typing,plaintext-only');
  5570. const isBooleanAttr = makeMap('allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  5571. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  5572. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  5573. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  5574. 'required,reversed,scoped,seamless,selected,sortable,' +
  5575. 'truespeed,typemustmatch,visible');
  5576. const isHTMLTag = makeMap('html,body,base,head,link,meta,style,title,' +
  5577. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  5578. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  5579. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  5580. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  5581. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  5582. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  5583. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  5584. 'output,progress,select,textarea,' +
  5585. 'details,dialog,menu,menuitem,summary,' +
  5586. 'content,element,shadow,template,blockquote,iframe,tfoot');
  5587. // this map is intentionally selective, only covering SVG elements that may
  5588. // contain child elements.
  5589. const isSVG = makeMap('svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  5590. 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  5591. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', true);
  5592. const isPreTag = (tag) => tag === 'pre';
  5593. const isReservedTag = (tag) => {
  5594. return isHTMLTag(tag) || isSVG(tag);
  5595. };
  5596. function getTagNamespace(tag) {
  5597. if (isSVG(tag)) {
  5598. return 'svg';
  5599. }
  5600. // basic support for MathML
  5601. // note it doesn't support other MathML elements being component roots
  5602. if (tag === 'math') {
  5603. return 'math';
  5604. }
  5605. }
  5606. makeMap('text,number,password,search,email,tel,url');
  5607. const validDivisionCharRE = /[\w).+\-_$\]]/;
  5608. function parseFilters(exp) {
  5609. let inSingle = false;
  5610. let inDouble = false;
  5611. let inTemplateString = false;
  5612. let inRegex = false;
  5613. let curly = 0;
  5614. let square = 0;
  5615. let paren = 0;
  5616. let lastFilterIndex = 0;
  5617. let c, prev, i, expression, filters;
  5618. for (i = 0; i < exp.length; i++) {
  5619. prev = c;
  5620. c = exp.charCodeAt(i);
  5621. if (inSingle) {
  5622. if (c === 0x27 && prev !== 0x5c)
  5623. inSingle = false;
  5624. }
  5625. else if (inDouble) {
  5626. if (c === 0x22 && prev !== 0x5c)
  5627. inDouble = false;
  5628. }
  5629. else if (inTemplateString) {
  5630. if (c === 0x60 && prev !== 0x5c)
  5631. inTemplateString = false;
  5632. }
  5633. else if (inRegex) {
  5634. if (c === 0x2f && prev !== 0x5c)
  5635. inRegex = false;
  5636. }
  5637. else if (c === 0x7c && // pipe
  5638. exp.charCodeAt(i + 1) !== 0x7c &&
  5639. exp.charCodeAt(i - 1) !== 0x7c &&
  5640. !curly &&
  5641. !square &&
  5642. !paren) {
  5643. if (expression === undefined) {
  5644. // first filter, end of expression
  5645. lastFilterIndex = i + 1;
  5646. expression = exp.slice(0, i).trim();
  5647. }
  5648. else {
  5649. pushFilter();
  5650. }
  5651. }
  5652. else {
  5653. switch (c) {
  5654. case 0x22:
  5655. inDouble = true;
  5656. break; // "
  5657. case 0x27:
  5658. inSingle = true;
  5659. break; // '
  5660. case 0x60:
  5661. inTemplateString = true;
  5662. break; // `
  5663. case 0x28:
  5664. paren++;
  5665. break; // (
  5666. case 0x29:
  5667. paren--;
  5668. break; // )
  5669. case 0x5b:
  5670. square++;
  5671. break; // [
  5672. case 0x5d:
  5673. square--;
  5674. break; // ]
  5675. case 0x7b:
  5676. curly++;
  5677. break; // {
  5678. case 0x7d:
  5679. curly--;
  5680. break; // }
  5681. }
  5682. if (c === 0x2f) {
  5683. // /
  5684. let j = i - 1;
  5685. let p;
  5686. // find first non-whitespace prev char
  5687. for (; j >= 0; j--) {
  5688. p = exp.charAt(j);
  5689. if (p !== ' ')
  5690. break;
  5691. }
  5692. if (!p || !validDivisionCharRE.test(p)) {
  5693. inRegex = true;
  5694. }
  5695. }
  5696. }
  5697. }
  5698. if (expression === undefined) {
  5699. expression = exp.slice(0, i).trim();
  5700. }
  5701. else if (lastFilterIndex !== 0) {
  5702. pushFilter();
  5703. }
  5704. function pushFilter() {
  5705. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  5706. lastFilterIndex = i + 1;
  5707. }
  5708. if (filters) {
  5709. for (i = 0; i < filters.length; i++) {
  5710. expression = wrapFilter(expression, filters[i]);
  5711. }
  5712. }
  5713. return expression;
  5714. }
  5715. function wrapFilter(exp, filter) {
  5716. const i = filter.indexOf('(');
  5717. if (i < 0) {
  5718. // _f: resolveFilter
  5719. return `_f("${filter}")(${exp})`;
  5720. }
  5721. else {
  5722. const name = filter.slice(0, i);
  5723. const args = filter.slice(i + 1);
  5724. return `_f("${name}")(${exp}${args !== ')' ? ',' + args : args}`;
  5725. }
  5726. }
  5727. const defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  5728. const regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  5729. const buildRegex = cached(delimiters => {
  5730. const open = delimiters[0].replace(regexEscapeRE, '\\$&');
  5731. const close = delimiters[1].replace(regexEscapeRE, '\\$&');
  5732. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g');
  5733. });
  5734. function parseText(text, delimiters) {
  5735. //@ts-expect-error
  5736. const tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  5737. if (!tagRE.test(text)) {
  5738. return;
  5739. }
  5740. const tokens = [];
  5741. const rawTokens = [];
  5742. let lastIndex = (tagRE.lastIndex = 0);
  5743. let match, index, tokenValue;
  5744. while ((match = tagRE.exec(text))) {
  5745. index = match.index;
  5746. // push text token
  5747. if (index > lastIndex) {
  5748. rawTokens.push((tokenValue = text.slice(lastIndex, index)));
  5749. tokens.push(JSON.stringify(tokenValue));
  5750. }
  5751. // tag token
  5752. const exp = parseFilters(match[1].trim());
  5753. tokens.push(`_s(${exp})`);
  5754. rawTokens.push({ '@binding': exp });
  5755. lastIndex = index + match[0].length;
  5756. }
  5757. if (lastIndex < text.length) {
  5758. rawTokens.push((tokenValue = text.slice(lastIndex)));
  5759. tokens.push(JSON.stringify(tokenValue));
  5760. }
  5761. return {
  5762. expression: tokens.join('+'),
  5763. tokens: rawTokens
  5764. };
  5765. }
  5766. /* eslint-disable no-unused-vars */
  5767. function baseWarn(msg, range) {
  5768. console.error(`[Vue compiler]: ${msg}`);
  5769. }
  5770. /* eslint-enable no-unused-vars */
  5771. function pluckModuleFunction(modules, key) {
  5772. return modules ? modules.map(m => m[key]).filter(_ => _) : [];
  5773. }
  5774. function addProp(el, name, value, range, dynamic) {
  5775. (el.props || (el.props = [])).push(rangeSetItem({ name, value, dynamic }, range));
  5776. el.plain = false;
  5777. }
  5778. function addAttr(el, name, value, range, dynamic) {
  5779. const attrs = dynamic
  5780. ? el.dynamicAttrs || (el.dynamicAttrs = [])
  5781. : el.attrs || (el.attrs = []);
  5782. attrs.push(rangeSetItem({ name, value, dynamic }, range));
  5783. el.plain = false;
  5784. }
  5785. // add a raw attr (use this in preTransforms)
  5786. function addRawAttr(el, name, value, range) {
  5787. el.attrsMap[name] = value;
  5788. el.attrsList.push(rangeSetItem({ name, value }, range));
  5789. }
  5790. function addDirective(el, name, rawName, value, arg, isDynamicArg, modifiers, range) {
  5791. (el.directives || (el.directives = [])).push(rangeSetItem({
  5792. name,
  5793. rawName,
  5794. value,
  5795. arg,
  5796. isDynamicArg,
  5797. modifiers
  5798. }, range));
  5799. el.plain = false;
  5800. }
  5801. function prependModifierMarker(symbol, name, dynamic) {
  5802. return dynamic ? `_p(${name},"${symbol}")` : symbol + name; // mark the event as captured
  5803. }
  5804. function addHandler(el, name, value, modifiers, important, warn, range, dynamic) {
  5805. modifiers = modifiers || emptyObject;
  5806. // warn prevent and passive modifier
  5807. /* istanbul ignore if */
  5808. if (process.env.NODE_ENV !== 'production' && warn && modifiers.prevent && modifiers.passive) {
  5809. warn("passive and prevent can't be used together. " +
  5810. "Passive handler can't prevent default event.", range);
  5811. }
  5812. // normalize click.right and click.middle since they don't actually fire
  5813. // this is technically browser-specific, but at least for now browsers are
  5814. // the only target envs that have right/middle clicks.
  5815. if (modifiers.right) {
  5816. if (dynamic) {
  5817. name = `(${name})==='click'?'contextmenu':(${name})`;
  5818. }
  5819. else if (name === 'click') {
  5820. name = 'contextmenu';
  5821. delete modifiers.right;
  5822. }
  5823. }
  5824. else if (modifiers.middle) {
  5825. if (dynamic) {
  5826. name = `(${name})==='click'?'mouseup':(${name})`;
  5827. }
  5828. else if (name === 'click') {
  5829. name = 'mouseup';
  5830. }
  5831. }
  5832. // check capture modifier
  5833. if (modifiers.capture) {
  5834. delete modifiers.capture;
  5835. name = prependModifierMarker('!', name, dynamic);
  5836. }
  5837. if (modifiers.once) {
  5838. delete modifiers.once;
  5839. name = prependModifierMarker('~', name, dynamic);
  5840. }
  5841. /* istanbul ignore if */
  5842. if (modifiers.passive) {
  5843. delete modifiers.passive;
  5844. name = prependModifierMarker('&', name, dynamic);
  5845. }
  5846. let events;
  5847. if (modifiers.native) {
  5848. delete modifiers.native;
  5849. events = el.nativeEvents || (el.nativeEvents = {});
  5850. }
  5851. else {
  5852. events = el.events || (el.events = {});
  5853. }
  5854. const newHandler = rangeSetItem({ value: value.trim(), dynamic }, range);
  5855. if (modifiers !== emptyObject) {
  5856. newHandler.modifiers = modifiers;
  5857. }
  5858. const handlers = events[name];
  5859. /* istanbul ignore if */
  5860. if (Array.isArray(handlers)) {
  5861. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  5862. }
  5863. else if (handlers) {
  5864. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  5865. }
  5866. else {
  5867. events[name] = newHandler;
  5868. }
  5869. el.plain = false;
  5870. }
  5871. function getRawBindingAttr(el, name) {
  5872. return (el.rawAttrsMap[':' + name] ||
  5873. el.rawAttrsMap['v-bind:' + name] ||
  5874. el.rawAttrsMap[name]);
  5875. }
  5876. function getBindingAttr(el, name, getStatic) {
  5877. const dynamicValue = getAndRemoveAttr(el, ':' + name) || getAndRemoveAttr(el, 'v-bind:' + name);
  5878. if (dynamicValue != null) {
  5879. return parseFilters(dynamicValue);
  5880. }
  5881. else if (getStatic !== false) {
  5882. const staticValue = getAndRemoveAttr(el, name);
  5883. if (staticValue != null) {
  5884. return JSON.stringify(staticValue);
  5885. }
  5886. }
  5887. }
  5888. // note: this only removes the attr from the Array (attrsList) so that it
  5889. // doesn't get processed by processAttrs.
  5890. // By default it does NOT remove it from the map (attrsMap) because the map is
  5891. // needed during codegen.
  5892. function getAndRemoveAttr(el, name, removeFromMap) {
  5893. let val;
  5894. if ((val = el.attrsMap[name]) != null) {
  5895. const list = el.attrsList;
  5896. for (let i = 0, l = list.length; i < l; i++) {
  5897. if (list[i].name === name) {
  5898. list.splice(i, 1);
  5899. break;
  5900. }
  5901. }
  5902. }
  5903. if (removeFromMap) {
  5904. delete el.attrsMap[name];
  5905. }
  5906. return val;
  5907. }
  5908. function getAndRemoveAttrByRegex(el, name) {
  5909. const list = el.attrsList;
  5910. for (let i = 0, l = list.length; i < l; i++) {
  5911. const attr = list[i];
  5912. if (name.test(attr.name)) {
  5913. list.splice(i, 1);
  5914. return attr;
  5915. }
  5916. }
  5917. }
  5918. function rangeSetItem(item, range) {
  5919. if (range) {
  5920. if (range.start != null) {
  5921. item.start = range.start;
  5922. }
  5923. if (range.end != null) {
  5924. item.end = range.end;
  5925. }
  5926. }
  5927. return item;
  5928. }
  5929. function transformNode$1(el, options) {
  5930. const warn = options.warn || baseWarn;
  5931. const staticClass = getAndRemoveAttr(el, 'class');
  5932. if (process.env.NODE_ENV !== 'production' && staticClass) {
  5933. const res = parseText(staticClass, options.delimiters);
  5934. if (res) {
  5935. warn(`class="${staticClass}": ` +
  5936. 'Interpolation inside attributes has been removed. ' +
  5937. 'Use v-bind or the colon shorthand instead. For example, ' +
  5938. 'instead of <div class="{{ val }}">, use <div :class="val">.', el.rawAttrsMap['class']);
  5939. }
  5940. }
  5941. if (staticClass) {
  5942. el.staticClass = JSON.stringify(staticClass.replace(/\s+/g, ' ').trim());
  5943. }
  5944. const classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  5945. if (classBinding) {
  5946. el.classBinding = classBinding;
  5947. }
  5948. }
  5949. function genData$2(el) {
  5950. let data = '';
  5951. if (el.staticClass) {
  5952. data += `staticClass:${el.staticClass},`;
  5953. }
  5954. if (el.classBinding) {
  5955. data += `class:${el.classBinding},`;
  5956. }
  5957. return data;
  5958. }
  5959. var klass = {
  5960. staticKeys: ['staticClass'],
  5961. transformNode: transformNode$1,
  5962. genData: genData$2
  5963. };
  5964. const parseStyleText = cached(function (cssText) {
  5965. const res = {};
  5966. const listDelimiter = /;(?![^(]*\))/g;
  5967. const propertyDelimiter = /:(.+)/;
  5968. cssText.split(listDelimiter).forEach(function (item) {
  5969. if (item) {
  5970. const tmp = item.split(propertyDelimiter);
  5971. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  5972. }
  5973. });
  5974. return res;
  5975. });
  5976. function transformNode(el, options) {
  5977. const warn = options.warn || baseWarn;
  5978. const staticStyle = getAndRemoveAttr(el, 'style');
  5979. if (staticStyle) {
  5980. /* istanbul ignore if */
  5981. if (process.env.NODE_ENV !== 'production') {
  5982. const res = parseText(staticStyle, options.delimiters);
  5983. if (res) {
  5984. warn(`style="${staticStyle}": ` +
  5985. 'Interpolation inside attributes has been removed. ' +
  5986. 'Use v-bind or the colon shorthand instead. For example, ' +
  5987. 'instead of <div style="{{ val }}">, use <div :style="val">.', el.rawAttrsMap['style']);
  5988. }
  5989. }
  5990. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  5991. }
  5992. const styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  5993. if (styleBinding) {
  5994. el.styleBinding = styleBinding;
  5995. }
  5996. }
  5997. function genData$1(el) {
  5998. let data = '';
  5999. if (el.staticStyle) {
  6000. data += `staticStyle:${el.staticStyle},`;
  6001. }
  6002. if (el.styleBinding) {
  6003. data += `style:(${el.styleBinding}),`;
  6004. }
  6005. return data;
  6006. }
  6007. var style = {
  6008. staticKeys: ['staticStyle'],
  6009. transformNode,
  6010. genData: genData$1
  6011. };
  6012. var he$1 = {exports: {}};
  6013. /*! https://mths.be/he v1.2.0 by @mathias | MIT license */
  6014. (function (module, exports) {
  6015. (function(root) {
  6016. // Detect free variables `exports`.
  6017. var freeExports = exports;
  6018. // Detect free variable `module`.
  6019. var freeModule = module &&
  6020. module.exports == freeExports && module;
  6021. // Detect free variable `global`, from Node.js or Browserified code,
  6022. // and use it as `root`.
  6023. var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal;
  6024. if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
  6025. root = freeGlobal;
  6026. }
  6027. /*--------------------------------------------------------------------------*/
  6028. // All astral symbols.
  6029. var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
  6030. // All ASCII symbols (not just printable ASCII) except those listed in the
  6031. // first column of the overrides table.
  6032. // https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides
  6033. var regexAsciiWhitelist = /[\x01-\x7F]/g;
  6034. // All BMP symbols that are not ASCII newlines, printable ASCII symbols, or
  6035. // code points listed in the first column of the overrides table on
  6036. // https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides.
  6037. var regexBmpWhitelist = /[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g;
  6038. var regexEncodeNonAscii = /<\u20D2|=\u20E5|>\u20D2|\u205F\u200A|\u219D\u0338|\u2202\u0338|\u2220\u20D2|\u2229\uFE00|\u222A\uFE00|\u223C\u20D2|\u223D\u0331|\u223E\u0333|\u2242\u0338|\u224B\u0338|\u224D\u20D2|\u224E\u0338|\u224F\u0338|\u2250\u0338|\u2261\u20E5|\u2264\u20D2|\u2265\u20D2|\u2266\u0338|\u2267\u0338|\u2268\uFE00|\u2269\uFE00|\u226A\u0338|\u226A\u20D2|\u226B\u0338|\u226B\u20D2|\u227F\u0338|\u2282\u20D2|\u2283\u20D2|\u228A\uFE00|\u228B\uFE00|\u228F\u0338|\u2290\u0338|\u2293\uFE00|\u2294\uFE00|\u22B4\u20D2|\u22B5\u20D2|\u22D8\u0338|\u22D9\u0338|\u22DA\uFE00|\u22DB\uFE00|\u22F5\u0338|\u22F9\u0338|\u2933\u0338|\u29CF\u0338|\u29D0\u0338|\u2A6D\u0338|\u2A70\u0338|\u2A7D\u0338|\u2A7E\u0338|\u2AA1\u0338|\u2AA2\u0338|\u2AAC\uFE00|\u2AAD\uFE00|\u2AAF\u0338|\u2AB0\u0338|\u2AC5\u0338|\u2AC6\u0338|\u2ACB\uFE00|\u2ACC\uFE00|\u2AFD\u20E5|[\xA0-\u0113\u0116-\u0122\u0124-\u012B\u012E-\u014D\u0150-\u017E\u0192\u01B5\u01F5\u0237\u02C6\u02C7\u02D8-\u02DD\u0311\u0391-\u03A1\u03A3-\u03A9\u03B1-\u03C9\u03D1\u03D2\u03D5\u03D6\u03DC\u03DD\u03F0\u03F1\u03F5\u03F6\u0401-\u040C\u040E-\u044F\u0451-\u045C\u045E\u045F\u2002-\u2005\u2007-\u2010\u2013-\u2016\u2018-\u201A\u201C-\u201E\u2020-\u2022\u2025\u2026\u2030-\u2035\u2039\u203A\u203E\u2041\u2043\u2044\u204F\u2057\u205F-\u2063\u20AC\u20DB\u20DC\u2102\u2105\u210A-\u2113\u2115-\u211E\u2122\u2124\u2127-\u2129\u212C\u212D\u212F-\u2131\u2133-\u2138\u2145-\u2148\u2153-\u215E\u2190-\u219B\u219D-\u21A7\u21A9-\u21AE\u21B0-\u21B3\u21B5-\u21B7\u21BA-\u21DB\u21DD\u21E4\u21E5\u21F5\u21FD-\u2205\u2207-\u2209\u220B\u220C\u220F-\u2214\u2216-\u2218\u221A\u221D-\u2238\u223A-\u2257\u2259\u225A\u225C\u225F-\u2262\u2264-\u228B\u228D-\u229B\u229D-\u22A5\u22A7-\u22B0\u22B2-\u22BB\u22BD-\u22DB\u22DE-\u22E3\u22E6-\u22F7\u22F9-\u22FE\u2305\u2306\u2308-\u2310\u2312\u2313\u2315\u2316\u231C-\u231F\u2322\u2323\u232D\u232E\u2336\u233D\u233F\u237C\u23B0\u23B1\u23B4-\u23B6\u23DC-\u23DF\u23E2\u23E7\u2423\u24C8\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2550-\u256C\u2580\u2584\u2588\u2591-\u2593\u25A1\u25AA\u25AB\u25AD\u25AE\u25B1\u25B3-\u25B5\u25B8\u25B9\u25BD-\u25BF\u25C2\u25C3\u25CA\u25CB\u25EC\u25EF\u25F8-\u25FC\u2605\u2606\u260E\u2640\u2642\u2660\u2663\u2665\u2666\u266A\u266D-\u266F\u2713\u2717\u2720\u2736\u2758\u2772\u2773\u27C8\u27C9\u27E6-\u27ED\u27F5-\u27FA\u27FC\u27FF\u2902-\u2905\u290C-\u2913\u2916\u2919-\u2920\u2923-\u292A\u2933\u2935-\u2939\u293C\u293D\u2945\u2948-\u294B\u294E-\u2976\u2978\u2979\u297B-\u297F\u2985\u2986\u298B-\u2996\u299A\u299C\u299D\u29A4-\u29B7\u29B9\u29BB\u29BC\u29BE-\u29C5\u29C9\u29CD-\u29D0\u29DC-\u29DE\u29E3-\u29E5\u29EB\u29F4\u29F6\u2A00-\u2A02\u2A04\u2A06\u2A0C\u2A0D\u2A10-\u2A17\u2A22-\u2A27\u2A29\u2A2A\u2A2D-\u2A31\u2A33-\u2A3C\u2A3F\u2A40\u2A42-\u2A4D\u2A50\u2A53-\u2A58\u2A5A-\u2A5D\u2A5F\u2A66\u2A6A\u2A6D-\u2A75\u2A77-\u2A9A\u2A9D-\u2AA2\u2AA4-\u2AB0\u2AB3-\u2AC8\u2ACB\u2ACC\u2ACF-\u2ADB\u2AE4\u2AE6-\u2AE9\u2AEB-\u2AF3\u2AFD\uFB00-\uFB04]|\uD835[\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDCCF\uDD04\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDD6B]/g;
  6039. var encodeMap = {'\xAD':'shy','\u200C':'zwnj','\u200D':'zwj','\u200E':'lrm','\u2063':'ic','\u2062':'it','\u2061':'af','\u200F':'rlm','\u200B':'ZeroWidthSpace','\u2060':'NoBreak','\u0311':'DownBreve','\u20DB':'tdot','\u20DC':'DotDot','\t':'Tab','\n':'NewLine','\u2008':'puncsp','\u205F':'MediumSpace','\u2009':'thinsp','\u200A':'hairsp','\u2004':'emsp13','\u2002':'ensp','\u2005':'emsp14','\u2003':'emsp','\u2007':'numsp','\xA0':'nbsp','\u205F\u200A':'ThickSpace','\u203E':'oline','_':'lowbar','\u2010':'dash','\u2013':'ndash','\u2014':'mdash','\u2015':'horbar',',':'comma',';':'semi','\u204F':'bsemi',':':'colon','\u2A74':'Colone','!':'excl','\xA1':'iexcl','?':'quest','\xBF':'iquest','.':'period','\u2025':'nldr','\u2026':'mldr','\xB7':'middot','\'':'apos','\u2018':'lsquo','\u2019':'rsquo','\u201A':'sbquo','\u2039':'lsaquo','\u203A':'rsaquo','"':'quot','\u201C':'ldquo','\u201D':'rdquo','\u201E':'bdquo','\xAB':'laquo','\xBB':'raquo','(':'lpar',')':'rpar','[':'lsqb',']':'rsqb','{':'lcub','}':'rcub','\u2308':'lceil','\u2309':'rceil','\u230A':'lfloor','\u230B':'rfloor','\u2985':'lopar','\u2986':'ropar','\u298B':'lbrke','\u298C':'rbrke','\u298D':'lbrkslu','\u298E':'rbrksld','\u298F':'lbrksld','\u2990':'rbrkslu','\u2991':'langd','\u2992':'rangd','\u2993':'lparlt','\u2994':'rpargt','\u2995':'gtlPar','\u2996':'ltrPar','\u27E6':'lobrk','\u27E7':'robrk','\u27E8':'lang','\u27E9':'rang','\u27EA':'Lang','\u27EB':'Rang','\u27EC':'loang','\u27ED':'roang','\u2772':'lbbrk','\u2773':'rbbrk','\u2016':'Vert','\xA7':'sect','\xB6':'para','@':'commat','*':'ast','/':'sol','undefined':null,'&':'amp','#':'num','%':'percnt','\u2030':'permil','\u2031':'pertenk','\u2020':'dagger','\u2021':'Dagger','\u2022':'bull','\u2043':'hybull','\u2032':'prime','\u2033':'Prime','\u2034':'tprime','\u2057':'qprime','\u2035':'bprime','\u2041':'caret','`':'grave','\xB4':'acute','\u02DC':'tilde','^':'Hat','\xAF':'macr','\u02D8':'breve','\u02D9':'dot','\xA8':'die','\u02DA':'ring','\u02DD':'dblac','\xB8':'cedil','\u02DB':'ogon','\u02C6':'circ','\u02C7':'caron','\xB0':'deg','\xA9':'copy','\xAE':'reg','\u2117':'copysr','\u2118':'wp','\u211E':'rx','\u2127':'mho','\u2129':'iiota','\u2190':'larr','\u219A':'nlarr','\u2192':'rarr','\u219B':'nrarr','\u2191':'uarr','\u2193':'darr','\u2194':'harr','\u21AE':'nharr','\u2195':'varr','\u2196':'nwarr','\u2197':'nearr','\u2198':'searr','\u2199':'swarr','\u219D':'rarrw','\u219D\u0338':'nrarrw','\u219E':'Larr','\u219F':'Uarr','\u21A0':'Rarr','\u21A1':'Darr','\u21A2':'larrtl','\u21A3':'rarrtl','\u21A4':'mapstoleft','\u21A5':'mapstoup','\u21A6':'map','\u21A7':'mapstodown','\u21A9':'larrhk','\u21AA':'rarrhk','\u21AB':'larrlp','\u21AC':'rarrlp','\u21AD':'harrw','\u21B0':'lsh','\u21B1':'rsh','\u21B2':'ldsh','\u21B3':'rdsh','\u21B5':'crarr','\u21B6':'cularr','\u21B7':'curarr','\u21BA':'olarr','\u21BB':'orarr','\u21BC':'lharu','\u21BD':'lhard','\u21BE':'uharr','\u21BF':'uharl','\u21C0':'rharu','\u21C1':'rhard','\u21C2':'dharr','\u21C3':'dharl','\u21C4':'rlarr','\u21C5':'udarr','\u21C6':'lrarr','\u21C7':'llarr','\u21C8':'uuarr','\u21C9':'rrarr','\u21CA':'ddarr','\u21CB':'lrhar','\u21CC':'rlhar','\u21D0':'lArr','\u21CD':'nlArr','\u21D1':'uArr','\u21D2':'rArr','\u21CF':'nrArr','\u21D3':'dArr','\u21D4':'iff','\u21CE':'nhArr','\u21D5':'vArr','\u21D6':'nwArr','\u21D7':'neArr','\u21D8':'seArr','\u21D9':'swArr','\u21DA':'lAarr','\u21DB':'rAarr','\u21DD':'zigrarr','\u21E4':'larrb','\u21E5':'rarrb','\u21F5':'duarr','\u21FD':'loarr','\u21FE':'roarr','\u21FF':'hoarr','\u2200':'forall','\u2201':'comp','\u2202':'part','\u2202\u0338':'npart','\u2203':'exist','\u2204':'nexist','\u2205':'empty','\u2207':'Del','\u2208':'in','\u2209':'notin','\u220B':'ni','\u220C':'notni','\u03F6':'bepsi','\u220F':'prod','\u2210':'coprod','\u2211':'sum','+':'plus','\xB1':'pm','\xF7':'div','\xD7':'times','<':'lt','\u226E':'nlt','<\u20D2':'nvlt','=':'equals','\u2260':'ne','=\u20E5':'bne','\u2A75':'Equal','>':'gt','\u226F':'ngt','>\u20D2':'nvgt','\xAC':'not','|':'vert','\xA6':'brvbar','\u2212':'minus','\u2213':'mp','\u2214':'plusdo','\u2044':'frasl','\u2216':'setmn','\u2217':'lowast','\u2218':'compfn','\u221A':'Sqrt','\u221D':'prop','\u221E':'infin','\u221F':'angrt','\u2220':'ang','\u2220\u20D2':'nang','\u2221':'angmsd','\u2222':'angsph','\u2223':'mid','\u2224':'nmid','\u2225':'par','\u2226':'npar','\u2227':'and','\u2228':'or','\u2229':'cap','\u2229\uFE00':'caps','\u222A':'cup','\u222A\uFE00':'cups','\u222B':'int','\u222C':'Int','\u222D':'tint','\u2A0C':'qint','\u222E':'oint','\u222F':'Conint','\u2230':'Cconint','\u2231':'cwint','\u2232':'cwconint','\u2233':'awconint','\u2234':'there4','\u2235':'becaus','\u2236':'ratio','\u2237':'Colon','\u2238':'minusd','\u223A':'mDDot','\u223B':'homtht','\u223C':'sim','\u2241':'nsim','\u223C\u20D2':'nvsim','\u223D':'bsim','\u223D\u0331':'race','\u223E':'ac','\u223E\u0333':'acE','\u223F':'acd','\u2240':'wr','\u2242':'esim','\u2242\u0338':'nesim','\u2243':'sime','\u2244':'nsime','\u2245':'cong','\u2247':'ncong','\u2246':'simne','\u2248':'ap','\u2249':'nap','\u224A':'ape','\u224B':'apid','\u224B\u0338':'napid','\u224C':'bcong','\u224D':'CupCap','\u226D':'NotCupCap','\u224D\u20D2':'nvap','\u224E':'bump','\u224E\u0338':'nbump','\u224F':'bumpe','\u224F\u0338':'nbumpe','\u2250':'doteq','\u2250\u0338':'nedot','\u2251':'eDot','\u2252':'efDot','\u2253':'erDot','\u2254':'colone','\u2255':'ecolon','\u2256':'ecir','\u2257':'cire','\u2259':'wedgeq','\u225A':'veeeq','\u225C':'trie','\u225F':'equest','\u2261':'equiv','\u2262':'nequiv','\u2261\u20E5':'bnequiv','\u2264':'le','\u2270':'nle','\u2264\u20D2':'nvle','\u2265':'ge','\u2271':'nge','\u2265\u20D2':'nvge','\u2266':'lE','\u2266\u0338':'nlE','\u2267':'gE','\u2267\u0338':'ngE','\u2268\uFE00':'lvnE','\u2268':'lnE','\u2269':'gnE','\u2269\uFE00':'gvnE','\u226A':'ll','\u226A\u0338':'nLtv','\u226A\u20D2':'nLt','\u226B':'gg','\u226B\u0338':'nGtv','\u226B\u20D2':'nGt','\u226C':'twixt','\u2272':'lsim','\u2274':'nlsim','\u2273':'gsim','\u2275':'ngsim','\u2276':'lg','\u2278':'ntlg','\u2277':'gl','\u2279':'ntgl','\u227A':'pr','\u2280':'npr','\u227B':'sc','\u2281':'nsc','\u227C':'prcue','\u22E0':'nprcue','\u227D':'sccue','\u22E1':'nsccue','\u227E':'prsim','\u227F':'scsim','\u227F\u0338':'NotSucceedsTilde','\u2282':'sub','\u2284':'nsub','\u2282\u20D2':'vnsub','\u2283':'sup','\u2285':'nsup','\u2283\u20D2':'vnsup','\u2286':'sube','\u2288':'nsube','\u2287':'supe','\u2289':'nsupe','\u228A\uFE00':'vsubne','\u228A':'subne','\u228B\uFE00':'vsupne','\u228B':'supne','\u228D':'cupdot','\u228E':'uplus','\u228F':'sqsub','\u228F\u0338':'NotSquareSubset','\u2290':'sqsup','\u2290\u0338':'NotSquareSuperset','\u2291':'sqsube','\u22E2':'nsqsube','\u2292':'sqsupe','\u22E3':'nsqsupe','\u2293':'sqcap','\u2293\uFE00':'sqcaps','\u2294':'sqcup','\u2294\uFE00':'sqcups','\u2295':'oplus','\u2296':'ominus','\u2297':'otimes','\u2298':'osol','\u2299':'odot','\u229A':'ocir','\u229B':'oast','\u229D':'odash','\u229E':'plusb','\u229F':'minusb','\u22A0':'timesb','\u22A1':'sdotb','\u22A2':'vdash','\u22AC':'nvdash','\u22A3':'dashv','\u22A4':'top','\u22A5':'bot','\u22A7':'models','\u22A8':'vDash','\u22AD':'nvDash','\u22A9':'Vdash','\u22AE':'nVdash','\u22AA':'Vvdash','\u22AB':'VDash','\u22AF':'nVDash','\u22B0':'prurel','\u22B2':'vltri','\u22EA':'nltri','\u22B3':'vrtri','\u22EB':'nrtri','\u22B4':'ltrie','\u22EC':'nltrie','\u22B4\u20D2':'nvltrie','\u22B5':'rtrie','\u22ED':'nrtrie','\u22B5\u20D2':'nvrtrie','\u22B6':'origof','\u22B7':'imof','\u22B8':'mumap','\u22B9':'hercon','\u22BA':'intcal','\u22BB':'veebar','\u22BD':'barvee','\u22BE':'angrtvb','\u22BF':'lrtri','\u22C0':'Wedge','\u22C1':'Vee','\u22C2':'xcap','\u22C3':'xcup','\u22C4':'diam','\u22C5':'sdot','\u22C6':'Star','\u22C7':'divonx','\u22C8':'bowtie','\u22C9':'ltimes','\u22CA':'rtimes','\u22CB':'lthree','\u22CC':'rthree','\u22CD':'bsime','\u22CE':'cuvee','\u22CF':'cuwed','\u22D0':'Sub','\u22D1':'Sup','\u22D2':'Cap','\u22D3':'Cup','\u22D4':'fork','\u22D5':'epar','\u22D6':'ltdot','\u22D7':'gtdot','\u22D8':'Ll','\u22D8\u0338':'nLl','\u22D9':'Gg','\u22D9\u0338':'nGg','\u22DA\uFE00':'lesg','\u22DA':'leg','\u22DB':'gel','\u22DB\uFE00':'gesl','\u22DE':'cuepr','\u22DF':'cuesc','\u22E6':'lnsim','\u22E7':'gnsim','\u22E8':'prnsim','\u22E9':'scnsim','\u22EE':'vellip','\u22EF':'ctdot','\u22F0':'utdot','\u22F1':'dtdot','\u22F2':'disin','\u22F3':'isinsv','\u22F4':'isins','\u22F5':'isindot','\u22F5\u0338':'notindot','\u22F6':'notinvc','\u22F7':'notinvb','\u22F9':'isinE','\u22F9\u0338':'notinE','\u22FA':'nisd','\u22FB':'xnis','\u22FC':'nis','\u22FD':'notnivc','\u22FE':'notnivb','\u2305':'barwed','\u2306':'Barwed','\u230C':'drcrop','\u230D':'dlcrop','\u230E':'urcrop','\u230F':'ulcrop','\u2310':'bnot','\u2312':'profline','\u2313':'profsurf','\u2315':'telrec','\u2316':'target','\u231C':'ulcorn','\u231D':'urcorn','\u231E':'dlcorn','\u231F':'drcorn','\u2322':'frown','\u2323':'smile','\u232D':'cylcty','\u232E':'profalar','\u2336':'topbot','\u233D':'ovbar','\u233F':'solbar','\u237C':'angzarr','\u23B0':'lmoust','\u23B1':'rmoust','\u23B4':'tbrk','\u23B5':'bbrk','\u23B6':'bbrktbrk','\u23DC':'OverParenthesis','\u23DD':'UnderParenthesis','\u23DE':'OverBrace','\u23DF':'UnderBrace','\u23E2':'trpezium','\u23E7':'elinters','\u2423':'blank','\u2500':'boxh','\u2502':'boxv','\u250C':'boxdr','\u2510':'boxdl','\u2514':'boxur','\u2518':'boxul','\u251C':'boxvr','\u2524':'boxvl','\u252C':'boxhd','\u2534':'boxhu','\u253C':'boxvh','\u2550':'boxH','\u2551':'boxV','\u2552':'boxdR','\u2553':'boxDr','\u2554':'boxDR','\u2555':'boxdL','\u2556':'boxDl','\u2557':'boxDL','\u2558':'boxuR','\u2559':'boxUr','\u255A':'boxUR','\u255B':'boxuL','\u255C':'boxUl','\u255D':'boxUL','\u255E':'boxvR','\u255F':'boxVr','\u2560':'boxVR','\u2561':'boxvL','\u2562':'boxVl','\u2563':'boxVL','\u2564':'boxHd','\u2565':'boxhD','\u2566':'boxHD','\u2567':'boxHu','\u2568':'boxhU','\u2569':'boxHU','\u256A':'boxvH','\u256B':'boxVh','\u256C':'boxVH','\u2580':'uhblk','\u2584':'lhblk','\u2588':'block','\u2591':'blk14','\u2592':'blk12','\u2593':'blk34','\u25A1':'squ','\u25AA':'squf','\u25AB':'EmptyVerySmallSquare','\u25AD':'rect','\u25AE':'marker','\u25B1':'fltns','\u25B3':'xutri','\u25B4':'utrif','\u25B5':'utri','\u25B8':'rtrif','\u25B9':'rtri','\u25BD':'xdtri','\u25BE':'dtrif','\u25BF':'dtri','\u25C2':'ltrif','\u25C3':'ltri','\u25CA':'loz','\u25CB':'cir','\u25EC':'tridot','\u25EF':'xcirc','\u25F8':'ultri','\u25F9':'urtri','\u25FA':'lltri','\u25FB':'EmptySmallSquare','\u25FC':'FilledSmallSquare','\u2605':'starf','\u2606':'star','\u260E':'phone','\u2640':'female','\u2642':'male','\u2660':'spades','\u2663':'clubs','\u2665':'hearts','\u2666':'diams','\u266A':'sung','\u2713':'check','\u2717':'cross','\u2720':'malt','\u2736':'sext','\u2758':'VerticalSeparator','\u27C8':'bsolhsub','\u27C9':'suphsol','\u27F5':'xlarr','\u27F6':'xrarr','\u27F7':'xharr','\u27F8':'xlArr','\u27F9':'xrArr','\u27FA':'xhArr','\u27FC':'xmap','\u27FF':'dzigrarr','\u2902':'nvlArr','\u2903':'nvrArr','\u2904':'nvHarr','\u2905':'Map','\u290C':'lbarr','\u290D':'rbarr','\u290E':'lBarr','\u290F':'rBarr','\u2910':'RBarr','\u2911':'DDotrahd','\u2912':'UpArrowBar','\u2913':'DownArrowBar','\u2916':'Rarrtl','\u2919':'latail','\u291A':'ratail','\u291B':'lAtail','\u291C':'rAtail','\u291D':'larrfs','\u291E':'rarrfs','\u291F':'larrbfs','\u2920':'rarrbfs','\u2923':'nwarhk','\u2924':'nearhk','\u2925':'searhk','\u2926':'swarhk','\u2927':'nwnear','\u2928':'toea','\u2929':'tosa','\u292A':'swnwar','\u2933':'rarrc','\u2933\u0338':'nrarrc','\u2935':'cudarrr','\u2936':'ldca','\u2937':'rdca','\u2938':'cudarrl','\u2939':'larrpl','\u293C':'curarrm','\u293D':'cularrp','\u2945':'rarrpl','\u2948':'harrcir','\u2949':'Uarrocir','\u294A':'lurdshar','\u294B':'ldrushar','\u294E':'LeftRightVector','\u294F':'RightUpDownVector','\u2950':'DownLeftRightVector','\u2951':'LeftUpDownVector','\u2952':'LeftVectorBar','\u2953':'RightVectorBar','\u2954':'RightUpVectorBar','\u2955':'RightDownVectorBar','\u2956':'DownLeftVectorBar','\u2957':'DownRightVectorBar','\u2958':'LeftUpVectorBar','\u2959':'LeftDownVectorBar','\u295A':'LeftTeeVector','\u295B':'RightTeeVector','\u295C':'RightUpTeeVector','\u295D':'RightDownTeeVector','\u295E':'DownLeftTeeVector','\u295F':'DownRightTeeVector','\u2960':'LeftUpTeeVector','\u2961':'LeftDownTeeVector','\u2962':'lHar','\u2963':'uHar','\u2964':'rHar','\u2965':'dHar','\u2966':'luruhar','\u2967':'ldrdhar','\u2968':'ruluhar','\u2969':'rdldhar','\u296A':'lharul','\u296B':'llhard','\u296C':'rharul','\u296D':'lrhard','\u296E':'udhar','\u296F':'duhar','\u2970':'RoundImplies','\u2971':'erarr','\u2972':'simrarr','\u2973':'larrsim','\u2974':'rarrsim','\u2975':'rarrap','\u2976':'ltlarr','\u2978':'gtrarr','\u2979':'subrarr','\u297B':'suplarr','\u297C':'lfisht','\u297D':'rfisht','\u297E':'ufisht','\u297F':'dfisht','\u299A':'vzigzag','\u299C':'vangrt','\u299D':'angrtvbd','\u29A4':'ange','\u29A5':'range','\u29A6':'dwangle','\u29A7':'uwangle','\u29A8':'angmsdaa','\u29A9':'angmsdab','\u29AA':'angmsdac','\u29AB':'angmsdad','\u29AC':'angmsdae','\u29AD':'angmsdaf','\u29AE':'angmsdag','\u29AF':'angmsdah','\u29B0':'bemptyv','\u29B1':'demptyv','\u29B2':'cemptyv','\u29B3':'raemptyv','\u29B4':'laemptyv','\u29B5':'ohbar','\u29B6':'omid','\u29B7':'opar','\u29B9':'operp','\u29BB':'olcross','\u29BC':'odsold','\u29BE':'olcir','\u29BF':'ofcir','\u29C0':'olt','\u29C1':'ogt','\u29C2':'cirscir','\u29C3':'cirE','\u29C4':'solb','\u29C5':'bsolb','\u29C9':'boxbox','\u29CD':'trisb','\u29CE':'rtriltri','\u29CF':'LeftTriangleBar','\u29CF\u0338':'NotLeftTriangleBar','\u29D0':'RightTriangleBar','\u29D0\u0338':'NotRightTriangleBar','\u29DC':'iinfin','\u29DD':'infintie','\u29DE':'nvinfin','\u29E3':'eparsl','\u29E4':'smeparsl','\u29E5':'eqvparsl','\u29EB':'lozf','\u29F4':'RuleDelayed','\u29F6':'dsol','\u2A00':'xodot','\u2A01':'xoplus','\u2A02':'xotime','\u2A04':'xuplus','\u2A06':'xsqcup','\u2A0D':'fpartint','\u2A10':'cirfnint','\u2A11':'awint','\u2A12':'rppolint','\u2A13':'scpolint','\u2A14':'npolint','\u2A15':'pointint','\u2A16':'quatint','\u2A17':'intlarhk','\u2A22':'pluscir','\u2A23':'plusacir','\u2A24':'simplus','\u2A25':'plusdu','\u2A26':'plussim','\u2A27':'plustwo','\u2A29':'mcomma','\u2A2A':'minusdu','\u2A2D':'loplus','\u2A2E':'roplus','\u2A2F':'Cross','\u2A30':'timesd','\u2A31':'timesbar','\u2A33':'smashp','\u2A34':'lotimes','\u2A35':'rotimes','\u2A36':'otimesas','\u2A37':'Otimes','\u2A38':'odiv','\u2A39':'triplus','\u2A3A':'triminus','\u2A3B':'tritime','\u2A3C':'iprod','\u2A3F':'amalg','\u2A40':'capdot','\u2A42':'ncup','\u2A43':'ncap','\u2A44':'capand','\u2A45':'cupor','\u2A46':'cupcap','\u2A47':'capcup','\u2A48':'cupbrcap','\u2A49':'capbrcup','\u2A4A':'cupcup','\u2A4B':'capcap','\u2A4C':'ccups','\u2A4D':'ccaps','\u2A50':'ccupssm','\u2A53':'And','\u2A54':'Or','\u2A55':'andand','\u2A56':'oror','\u2A57':'orslope','\u2A58':'andslope','\u2A5A':'andv','\u2A5B':'orv','\u2A5C':'andd','\u2A5D':'ord','\u2A5F':'wedbar','\u2A66':'sdote','\u2A6A':'simdot','\u2A6D':'congdot','\u2A6D\u0338':'ncongdot','\u2A6E':'easter','\u2A6F':'apacir','\u2A70':'apE','\u2A70\u0338':'napE','\u2A71':'eplus','\u2A72':'pluse','\u2A73':'Esim','\u2A77':'eDDot','\u2A78':'equivDD','\u2A79':'ltcir','\u2A7A':'gtcir','\u2A7B':'ltquest','\u2A7C':'gtquest','\u2A7D':'les','\u2A7D\u0338':'nles','\u2A7E':'ges','\u2A7E\u0338':'nges','\u2A7F':'lesdot','\u2A80':'gesdot','\u2A81':'lesdoto','\u2A82':'gesdoto','\u2A83':'lesdotor','\u2A84':'gesdotol','\u2A85':'lap','\u2A86':'gap','\u2A87':'lne','\u2A88':'gne','\u2A89':'lnap','\u2A8A':'gnap','\u2A8B':'lEg','\u2A8C':'gEl','\u2A8D':'lsime','\u2A8E':'gsime','\u2A8F':'lsimg','\u2A90':'gsiml','\u2A91':'lgE','\u2A92':'glE','\u2A93':'lesges','\u2A94':'gesles','\u2A95':'els','\u2A96':'egs','\u2A97':'elsdot','\u2A98':'egsdot','\u2A99':'el','\u2A9A':'eg','\u2A9D':'siml','\u2A9E':'simg','\u2A9F':'simlE','\u2AA0':'simgE','\u2AA1':'LessLess','\u2AA1\u0338':'NotNestedLessLess','\u2AA2':'GreaterGreater','\u2AA2\u0338':'NotNestedGreaterGreater','\u2AA4':'glj','\u2AA5':'gla','\u2AA6':'ltcc','\u2AA7':'gtcc','\u2AA8':'lescc','\u2AA9':'gescc','\u2AAA':'smt','\u2AAB':'lat','\u2AAC':'smte','\u2AAC\uFE00':'smtes','\u2AAD':'late','\u2AAD\uFE00':'lates','\u2AAE':'bumpE','\u2AAF':'pre','\u2AAF\u0338':'npre','\u2AB0':'sce','\u2AB0\u0338':'nsce','\u2AB3':'prE','\u2AB4':'scE','\u2AB5':'prnE','\u2AB6':'scnE','\u2AB7':'prap','\u2AB8':'scap','\u2AB9':'prnap','\u2ABA':'scnap','\u2ABB':'Pr','\u2ABC':'Sc','\u2ABD':'subdot','\u2ABE':'supdot','\u2ABF':'subplus','\u2AC0':'supplus','\u2AC1':'submult','\u2AC2':'supmult','\u2AC3':'subedot','\u2AC4':'supedot','\u2AC5':'subE','\u2AC5\u0338':'nsubE','\u2AC6':'supE','\u2AC6\u0338':'nsupE','\u2AC7':'subsim','\u2AC8':'supsim','\u2ACB\uFE00':'vsubnE','\u2ACB':'subnE','\u2ACC\uFE00':'vsupnE','\u2ACC':'supnE','\u2ACF':'csub','\u2AD0':'csup','\u2AD1':'csube','\u2AD2':'csupe','\u2AD3':'subsup','\u2AD4':'supsub','\u2AD5':'subsub','\u2AD6':'supsup','\u2AD7':'suphsub','\u2AD8':'supdsub','\u2AD9':'forkv','\u2ADA':'topfork','\u2ADB':'mlcp','\u2AE4':'Dashv','\u2AE6':'Vdashl','\u2AE7':'Barv','\u2AE8':'vBar','\u2AE9':'vBarv','\u2AEB':'Vbar','\u2AEC':'Not','\u2AED':'bNot','\u2AEE':'rnmid','\u2AEF':'cirmid','\u2AF0':'midcir','\u2AF1':'topcir','\u2AF2':'nhpar','\u2AF3':'parsim','\u2AFD':'parsl','\u2AFD\u20E5':'nparsl','\u266D':'flat','\u266E':'natur','\u266F':'sharp','\xA4':'curren','\xA2':'cent','$':'dollar','\xA3':'pound','\xA5':'yen','\u20AC':'euro','\xB9':'sup1','\xBD':'half','\u2153':'frac13','\xBC':'frac14','\u2155':'frac15','\u2159':'frac16','\u215B':'frac18','\xB2':'sup2','\u2154':'frac23','\u2156':'frac25','\xB3':'sup3','\xBE':'frac34','\u2157':'frac35','\u215C':'frac38','\u2158':'frac45','\u215A':'frac56','\u215D':'frac58','\u215E':'frac78','\uD835\uDCB6':'ascr','\uD835\uDD52':'aopf','\uD835\uDD1E':'afr','\uD835\uDD38':'Aopf','\uD835\uDD04':'Afr','\uD835\uDC9C':'Ascr','\xAA':'ordf','\xE1':'aacute','\xC1':'Aacute','\xE0':'agrave','\xC0':'Agrave','\u0103':'abreve','\u0102':'Abreve','\xE2':'acirc','\xC2':'Acirc','\xE5':'aring','\xC5':'angst','\xE4':'auml','\xC4':'Auml','\xE3':'atilde','\xC3':'Atilde','\u0105':'aogon','\u0104':'Aogon','\u0101':'amacr','\u0100':'Amacr','\xE6':'aelig','\xC6':'AElig','\uD835\uDCB7':'bscr','\uD835\uDD53':'bopf','\uD835\uDD1F':'bfr','\uD835\uDD39':'Bopf','\u212C':'Bscr','\uD835\uDD05':'Bfr','\uD835\uDD20':'cfr','\uD835\uDCB8':'cscr','\uD835\uDD54':'copf','\u212D':'Cfr','\uD835\uDC9E':'Cscr','\u2102':'Copf','\u0107':'cacute','\u0106':'Cacute','\u0109':'ccirc','\u0108':'Ccirc','\u010D':'ccaron','\u010C':'Ccaron','\u010B':'cdot','\u010A':'Cdot','\xE7':'ccedil','\xC7':'Ccedil','\u2105':'incare','\uD835\uDD21':'dfr','\u2146':'dd','\uD835\uDD55':'dopf','\uD835\uDCB9':'dscr','\uD835\uDC9F':'Dscr','\uD835\uDD07':'Dfr','\u2145':'DD','\uD835\uDD3B':'Dopf','\u010F':'dcaron','\u010E':'Dcaron','\u0111':'dstrok','\u0110':'Dstrok','\xF0':'eth','\xD0':'ETH','\u2147':'ee','\u212F':'escr','\uD835\uDD22':'efr','\uD835\uDD56':'eopf','\u2130':'Escr','\uD835\uDD08':'Efr','\uD835\uDD3C':'Eopf','\xE9':'eacute','\xC9':'Eacute','\xE8':'egrave','\xC8':'Egrave','\xEA':'ecirc','\xCA':'Ecirc','\u011B':'ecaron','\u011A':'Ecaron','\xEB':'euml','\xCB':'Euml','\u0117':'edot','\u0116':'Edot','\u0119':'eogon','\u0118':'Eogon','\u0113':'emacr','\u0112':'Emacr','\uD835\uDD23':'ffr','\uD835\uDD57':'fopf','\uD835\uDCBB':'fscr','\uD835\uDD09':'Ffr','\uD835\uDD3D':'Fopf','\u2131':'Fscr','\uFB00':'fflig','\uFB03':'ffilig','\uFB04':'ffllig','\uFB01':'filig','fj':'fjlig','\uFB02':'fllig','\u0192':'fnof','\u210A':'gscr','\uD835\uDD58':'gopf','\uD835\uDD24':'gfr','\uD835\uDCA2':'Gscr','\uD835\uDD3E':'Gopf','\uD835\uDD0A':'Gfr','\u01F5':'gacute','\u011F':'gbreve','\u011E':'Gbreve','\u011D':'gcirc','\u011C':'Gcirc','\u0121':'gdot','\u0120':'Gdot','\u0122':'Gcedil','\uD835\uDD25':'hfr','\u210E':'planckh','\uD835\uDCBD':'hscr','\uD835\uDD59':'hopf','\u210B':'Hscr','\u210C':'Hfr','\u210D':'Hopf','\u0125':'hcirc','\u0124':'Hcirc','\u210F':'hbar','\u0127':'hstrok','\u0126':'Hstrok','\uD835\uDD5A':'iopf','\uD835\uDD26':'ifr','\uD835\uDCBE':'iscr','\u2148':'ii','\uD835\uDD40':'Iopf','\u2110':'Iscr','\u2111':'Im','\xED':'iacute','\xCD':'Iacute','\xEC':'igrave','\xCC':'Igrave','\xEE':'icirc','\xCE':'Icirc','\xEF':'iuml','\xCF':'Iuml','\u0129':'itilde','\u0128':'Itilde','\u0130':'Idot','\u012F':'iogon','\u012E':'Iogon','\u012B':'imacr','\u012A':'Imacr','\u0133':'ijlig','\u0132':'IJlig','\u0131':'imath','\uD835\uDCBF':'jscr','\uD835\uDD5B':'jopf','\uD835\uDD27':'jfr','\uD835\uDCA5':'Jscr','\uD835\uDD0D':'Jfr','\uD835\uDD41':'Jopf','\u0135':'jcirc','\u0134':'Jcirc','\u0237':'jmath','\uD835\uDD5C':'kopf','\uD835\uDCC0':'kscr','\uD835\uDD28':'kfr','\uD835\uDCA6':'Kscr','\uD835\uDD42':'Kopf','\uD835\uDD0E':'Kfr','\u0137':'kcedil','\u0136':'Kcedil','\uD835\uDD29':'lfr','\uD835\uDCC1':'lscr','\u2113':'ell','\uD835\uDD5D':'lopf','\u2112':'Lscr','\uD835\uDD0F':'Lfr','\uD835\uDD43':'Lopf','\u013A':'lacute','\u0139':'Lacute','\u013E':'lcaron','\u013D':'Lcaron','\u013C':'lcedil','\u013B':'Lcedil','\u0142':'lstrok','\u0141':'Lstrok','\u0140':'lmidot','\u013F':'Lmidot','\uD835\uDD2A':'mfr','\uD835\uDD5E':'mopf','\uD835\uDCC2':'mscr','\uD835\uDD10':'Mfr','\uD835\uDD44':'Mopf','\u2133':'Mscr','\uD835\uDD2B':'nfr','\uD835\uDD5F':'nopf','\uD835\uDCC3':'nscr','\u2115':'Nopf','\uD835\uDCA9':'Nscr','\uD835\uDD11':'Nfr','\u0144':'nacute','\u0143':'Nacute','\u0148':'ncaron','\u0147':'Ncaron','\xF1':'ntilde','\xD1':'Ntilde','\u0146':'ncedil','\u0145':'Ncedil','\u2116':'numero','\u014B':'eng','\u014A':'ENG','\uD835\uDD60':'oopf','\uD835\uDD2C':'ofr','\u2134':'oscr','\uD835\uDCAA':'Oscr','\uD835\uDD12':'Ofr','\uD835\uDD46':'Oopf','\xBA':'ordm','\xF3':'oacute','\xD3':'Oacute','\xF2':'ograve','\xD2':'Ograve','\xF4':'ocirc','\xD4':'Ocirc','\xF6':'ouml','\xD6':'Ouml','\u0151':'odblac','\u0150':'Odblac','\xF5':'otilde','\xD5':'Otilde','\xF8':'oslash','\xD8':'Oslash','\u014D':'omacr','\u014C':'Omacr','\u0153':'oelig','\u0152':'OElig','\uD835\uDD2D':'pfr','\uD835\uDCC5':'pscr','\uD835\uDD61':'popf','\u2119':'Popf','\uD835\uDD13':'Pfr','\uD835\uDCAB':'Pscr','\uD835\uDD62':'qopf','\uD835\uDD2E':'qfr','\uD835\uDCC6':'qscr','\uD835\uDCAC':'Qscr','\uD835\uDD14':'Qfr','\u211A':'Qopf','\u0138':'kgreen','\uD835\uDD2F':'rfr','\uD835\uDD63':'ropf','\uD835\uDCC7':'rscr','\u211B':'Rscr','\u211C':'Re','\u211D':'Ropf','\u0155':'racute','\u0154':'Racute','\u0159':'rcaron','\u0158':'Rcaron','\u0157':'rcedil','\u0156':'Rcedil','\uD835\uDD64':'sopf','\uD835\uDCC8':'sscr','\uD835\uDD30':'sfr','\uD835\uDD4A':'Sopf','\uD835\uDD16':'Sfr','\uD835\uDCAE':'Sscr','\u24C8':'oS','\u015B':'sacute','\u015A':'Sacute','\u015D':'scirc','\u015C':'Scirc','\u0161':'scaron','\u0160':'Scaron','\u015F':'scedil','\u015E':'Scedil','\xDF':'szlig','\uD835\uDD31':'tfr','\uD835\uDCC9':'tscr','\uD835\uDD65':'topf','\uD835\uDCAF':'Tscr','\uD835\uDD17':'Tfr','\uD835\uDD4B':'Topf','\u0165':'tcaron','\u0164':'Tcaron','\u0163':'tcedil','\u0162':'Tcedil','\u2122':'trade','\u0167':'tstrok','\u0166':'Tstrok','\uD835\uDCCA':'uscr','\uD835\uDD66':'uopf','\uD835\uDD32':'ufr','\uD835\uDD4C':'Uopf','\uD835\uDD18':'Ufr','\uD835\uDCB0':'Uscr','\xFA':'uacute','\xDA':'Uacute','\xF9':'ugrave','\xD9':'Ugrave','\u016D':'ubreve','\u016C':'Ubreve','\xFB':'ucirc','\xDB':'Ucirc','\u016F':'uring','\u016E':'Uring','\xFC':'uuml','\xDC':'Uuml','\u0171':'udblac','\u0170':'Udblac','\u0169':'utilde','\u0168':'Utilde','\u0173':'uogon','\u0172':'Uogon','\u016B':'umacr','\u016A':'Umacr','\uD835\uDD33':'vfr','\uD835\uDD67':'vopf','\uD835\uDCCB':'vscr','\uD835\uDD19':'Vfr','\uD835\uDD4D':'Vopf','\uD835\uDCB1':'Vscr','\uD835\uDD68':'wopf','\uD835\uDCCC':'wscr','\uD835\uDD34':'wfr','\uD835\uDCB2':'Wscr','\uD835\uDD4E':'Wopf','\uD835\uDD1A':'Wfr','\u0175':'wcirc','\u0174':'Wcirc','\uD835\uDD35':'xfr','\uD835\uDCCD':'xscr','\uD835\uDD69':'xopf','\uD835\uDD4F':'Xopf','\uD835\uDD1B':'Xfr','\uD835\uDCB3':'Xscr','\uD835\uDD36':'yfr','\uD835\uDCCE':'yscr','\uD835\uDD6A':'yopf','\uD835\uDCB4':'Yscr','\uD835\uDD1C':'Yfr','\uD835\uDD50':'Yopf','\xFD':'yacute','\xDD':'Yacute','\u0177':'ycirc','\u0176':'Ycirc','\xFF':'yuml','\u0178':'Yuml','\uD835\uDCCF':'zscr','\uD835\uDD37':'zfr','\uD835\uDD6B':'zopf','\u2128':'Zfr','\u2124':'Zopf','\uD835\uDCB5':'Zscr','\u017A':'zacute','\u0179':'Zacute','\u017E':'zcaron','\u017D':'Zcaron','\u017C':'zdot','\u017B':'Zdot','\u01B5':'imped','\xFE':'thorn','\xDE':'THORN','\u0149':'napos','\u03B1':'alpha','\u0391':'Alpha','\u03B2':'beta','\u0392':'Beta','\u03B3':'gamma','\u0393':'Gamma','\u03B4':'delta','\u0394':'Delta','\u03B5':'epsi','\u03F5':'epsiv','\u0395':'Epsilon','\u03DD':'gammad','\u03DC':'Gammad','\u03B6':'zeta','\u0396':'Zeta','\u03B7':'eta','\u0397':'Eta','\u03B8':'theta','\u03D1':'thetav','\u0398':'Theta','\u03B9':'iota','\u0399':'Iota','\u03BA':'kappa','\u03F0':'kappav','\u039A':'Kappa','\u03BB':'lambda','\u039B':'Lambda','\u03BC':'mu','\xB5':'micro','\u039C':'Mu','\u03BD':'nu','\u039D':'Nu','\u03BE':'xi','\u039E':'Xi','\u03BF':'omicron','\u039F':'Omicron','\u03C0':'pi','\u03D6':'piv','\u03A0':'Pi','\u03C1':'rho','\u03F1':'rhov','\u03A1':'Rho','\u03C3':'sigma','\u03A3':'Sigma','\u03C2':'sigmaf','\u03C4':'tau','\u03A4':'Tau','\u03C5':'upsi','\u03A5':'Upsilon','\u03D2':'Upsi','\u03C6':'phi','\u03D5':'phiv','\u03A6':'Phi','\u03C7':'chi','\u03A7':'Chi','\u03C8':'psi','\u03A8':'Psi','\u03C9':'omega','\u03A9':'ohm','\u0430':'acy','\u0410':'Acy','\u0431':'bcy','\u0411':'Bcy','\u0432':'vcy','\u0412':'Vcy','\u0433':'gcy','\u0413':'Gcy','\u0453':'gjcy','\u0403':'GJcy','\u0434':'dcy','\u0414':'Dcy','\u0452':'djcy','\u0402':'DJcy','\u0435':'iecy','\u0415':'IEcy','\u0451':'iocy','\u0401':'IOcy','\u0454':'jukcy','\u0404':'Jukcy','\u0436':'zhcy','\u0416':'ZHcy','\u0437':'zcy','\u0417':'Zcy','\u0455':'dscy','\u0405':'DScy','\u0438':'icy','\u0418':'Icy','\u0456':'iukcy','\u0406':'Iukcy','\u0457':'yicy','\u0407':'YIcy','\u0439':'jcy','\u0419':'Jcy','\u0458':'jsercy','\u0408':'Jsercy','\u043A':'kcy','\u041A':'Kcy','\u045C':'kjcy','\u040C':'KJcy','\u043B':'lcy','\u041B':'Lcy','\u0459':'ljcy','\u0409':'LJcy','\u043C':'mcy','\u041C':'Mcy','\u043D':'ncy','\u041D':'Ncy','\u045A':'njcy','\u040A':'NJcy','\u043E':'ocy','\u041E':'Ocy','\u043F':'pcy','\u041F':'Pcy','\u0440':'rcy','\u0420':'Rcy','\u0441':'scy','\u0421':'Scy','\u0442':'tcy','\u0422':'Tcy','\u045B':'tshcy','\u040B':'TSHcy','\u0443':'ucy','\u0423':'Ucy','\u045E':'ubrcy','\u040E':'Ubrcy','\u0444':'fcy','\u0424':'Fcy','\u0445':'khcy','\u0425':'KHcy','\u0446':'tscy','\u0426':'TScy','\u0447':'chcy','\u0427':'CHcy','\u045F':'dzcy','\u040F':'DZcy','\u0448':'shcy','\u0428':'SHcy','\u0449':'shchcy','\u0429':'SHCHcy','\u044A':'hardcy','\u042A':'HARDcy','\u044B':'ycy','\u042B':'Ycy','\u044C':'softcy','\u042C':'SOFTcy','\u044D':'ecy','\u042D':'Ecy','\u044E':'yucy','\u042E':'YUcy','\u044F':'yacy','\u042F':'YAcy','\u2135':'aleph','\u2136':'beth','\u2137':'gimel','\u2138':'daleth'};
  6040. var regexEscape = /["&'<>`]/g;
  6041. var escapeMap = {
  6042. '"': '&quot;',
  6043. '&': '&amp;',
  6044. '\'': '&#x27;',
  6045. '<': '&lt;',
  6046. // See https://mathiasbynens.be/notes/ambiguous-ampersands: in HTML, the
  6047. // following is not strictly necessary unless it’s part of a tag or an
  6048. // unquoted attribute value. We’re only escaping it to support those
  6049. // situations, and for XML support.
  6050. '>': '&gt;',
  6051. // In Internet Explorer ≤ 8, the backtick character can be used
  6052. // to break out of (un)quoted attribute values or HTML comments.
  6053. // See http://html5sec.org/#102, http://html5sec.org/#108, and
  6054. // http://html5sec.org/#133.
  6055. '`': '&#x60;'
  6056. };
  6057. var regexInvalidEntity = /&#(?:[xX][^a-fA-F0-9]|[^0-9xX])/;
  6058. var regexInvalidRawCodePoint = /[\0-\x08\x0B\x0E-\x1F\x7F-\x9F\uFDD0-\uFDEF\uFFFE\uFFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F\uDBBF\uDBFF][\uDFFE\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
  6059. var regexDecode = /&(CounterClockwiseContourIntegral|DoubleLongLeftRightArrow|ClockwiseContourIntegral|NotNestedGreaterGreater|NotSquareSupersetEqual|DiacriticalDoubleAcute|NotRightTriangleEqual|NotSucceedsSlantEqual|NotPrecedesSlantEqual|CloseCurlyDoubleQuote|NegativeVeryThinSpace|DoubleContourIntegral|FilledVerySmallSquare|CapitalDifferentialD|OpenCurlyDoubleQuote|EmptyVerySmallSquare|NestedGreaterGreater|DoubleLongRightArrow|NotLeftTriangleEqual|NotGreaterSlantEqual|ReverseUpEquilibrium|DoubleLeftRightArrow|NotSquareSubsetEqual|NotDoubleVerticalBar|RightArrowLeftArrow|NotGreaterFullEqual|NotRightTriangleBar|SquareSupersetEqual|DownLeftRightVector|DoubleLongLeftArrow|leftrightsquigarrow|LeftArrowRightArrow|NegativeMediumSpace|blacktriangleright|RightDownVectorBar|PrecedesSlantEqual|RightDoubleBracket|SucceedsSlantEqual|NotLeftTriangleBar|RightTriangleEqual|SquareIntersection|RightDownTeeVector|ReverseEquilibrium|NegativeThickSpace|longleftrightarrow|Longleftrightarrow|LongLeftRightArrow|DownRightTeeVector|DownRightVectorBar|GreaterSlantEqual|SquareSubsetEqual|LeftDownVectorBar|LeftDoubleBracket|VerticalSeparator|rightleftharpoons|NotGreaterGreater|NotSquareSuperset|blacktriangleleft|blacktriangledown|NegativeThinSpace|LeftDownTeeVector|NotLessSlantEqual|leftrightharpoons|DoubleUpDownArrow|DoubleVerticalBar|LeftTriangleEqual|FilledSmallSquare|twoheadrightarrow|NotNestedLessLess|DownLeftTeeVector|DownLeftVectorBar|RightAngleBracket|NotTildeFullEqual|NotReverseElement|RightUpDownVector|DiacriticalTilde|NotSucceedsTilde|circlearrowright|NotPrecedesEqual|rightharpoondown|DoubleRightArrow|NotSucceedsEqual|NonBreakingSpace|NotRightTriangle|LessEqualGreater|RightUpTeeVector|LeftAngleBracket|GreaterFullEqual|DownArrowUpArrow|RightUpVectorBar|twoheadleftarrow|GreaterEqualLess|downharpoonright|RightTriangleBar|ntrianglerighteq|NotSupersetEqual|LeftUpDownVector|DiacriticalAcute|rightrightarrows|vartriangleright|UpArrowDownArrow|DiacriticalGrave|UnderParenthesis|EmptySmallSquare|LeftUpVectorBar|leftrightarrows|DownRightVector|downharpoonleft|trianglerighteq|ShortRightArrow|OverParenthesis|DoubleLeftArrow|DoubleDownArrow|NotSquareSubset|bigtriangledown|ntrianglelefteq|UpperRightArrow|curvearrowright|vartriangleleft|NotLeftTriangle|nleftrightarrow|LowerRightArrow|NotHumpDownHump|NotGreaterTilde|rightthreetimes|LeftUpTeeVector|NotGreaterEqual|straightepsilon|LeftTriangleBar|rightsquigarrow|ContourIntegral|rightleftarrows|CloseCurlyQuote|RightDownVector|LeftRightVector|nLeftrightarrow|leftharpoondown|circlearrowleft|SquareSuperset|OpenCurlyQuote|hookrightarrow|HorizontalLine|DiacriticalDot|NotLessGreater|ntriangleright|DoubleRightTee|InvisibleComma|InvisibleTimes|LowerLeftArrow|DownLeftVector|NotSubsetEqual|curvearrowleft|trianglelefteq|NotVerticalBar|TildeFullEqual|downdownarrows|NotGreaterLess|RightTeeVector|ZeroWidthSpace|looparrowright|LongRightArrow|doublebarwedge|ShortLeftArrow|ShortDownArrow|RightVectorBar|GreaterGreater|ReverseElement|rightharpoonup|LessSlantEqual|leftthreetimes|upharpoonright|rightarrowtail|LeftDownVector|Longrightarrow|NestedLessLess|UpperLeftArrow|nshortparallel|leftleftarrows|leftrightarrow|Leftrightarrow|LeftRightArrow|longrightarrow|upharpoonleft|RightArrowBar|ApplyFunction|LeftTeeVector|leftarrowtail|NotEqualTilde|varsubsetneqq|varsupsetneqq|RightTeeArrow|SucceedsEqual|SucceedsTilde|LeftVectorBar|SupersetEqual|hookleftarrow|DifferentialD|VerticalTilde|VeryThinSpace|blacktriangle|bigtriangleup|LessFullEqual|divideontimes|leftharpoonup|UpEquilibrium|ntriangleleft|RightTriangle|measuredangle|shortparallel|longleftarrow|Longleftarrow|LongLeftArrow|DoubleLeftTee|Poincareplane|PrecedesEqual|triangleright|DoubleUpArrow|RightUpVector|fallingdotseq|looparrowleft|PrecedesTilde|NotTildeEqual|NotTildeTilde|smallsetminus|Proportional|triangleleft|triangledown|UnderBracket|NotHumpEqual|exponentiale|ExponentialE|NotLessTilde|HilbertSpace|RightCeiling|blacklozenge|varsupsetneq|HumpDownHump|GreaterEqual|VerticalLine|LeftTeeArrow|NotLessEqual|DownTeeArrow|LeftTriangle|varsubsetneq|Intersection|NotCongruent|DownArrowBar|LeftUpVector|LeftArrowBar|risingdotseq|GreaterTilde|RoundImplies|SquareSubset|ShortUpArrow|NotSuperset|quaternions|precnapprox|backepsilon|preccurlyeq|OverBracket|blacksquare|MediumSpace|VerticalBar|circledcirc|circleddash|CircleMinus|CircleTimes|LessGreater|curlyeqprec|curlyeqsucc|diamondsuit|UpDownArrow|Updownarrow|RuleDelayed|Rrightarrow|updownarrow|RightVector|nRightarrow|nrightarrow|eqslantless|LeftCeiling|Equilibrium|SmallCircle|expectation|NotSucceeds|thickapprox|GreaterLess|SquareUnion|NotPrecedes|NotLessLess|straightphi|succnapprox|succcurlyeq|SubsetEqual|sqsupseteq|Proportion|Laplacetrf|ImaginaryI|supsetneqq|NotGreater|gtreqqless|NotElement|ThickSpace|TildeEqual|TildeTilde|Fouriertrf|rmoustache|EqualTilde|eqslantgtr|UnderBrace|LeftVector|UpArrowBar|nLeftarrow|nsubseteqq|subsetneqq|nsupseteqq|nleftarrow|succapprox|lessapprox|UpTeeArrow|upuparrows|curlywedge|lesseqqgtr|varepsilon|varnothing|RightFloor|complement|CirclePlus|sqsubseteq|Lleftarrow|circledast|RightArrow|Rightarrow|rightarrow|lmoustache|Bernoullis|precapprox|mapstoleft|mapstodown|longmapsto|dotsquare|downarrow|DoubleDot|nsubseteq|supsetneq|leftarrow|nsupseteq|subsetneq|ThinSpace|ngeqslant|subseteqq|HumpEqual|NotSubset|triangleq|NotCupCap|lesseqgtr|heartsuit|TripleDot|Leftarrow|Coproduct|Congruent|varpropto|complexes|gvertneqq|LeftArrow|LessTilde|supseteqq|MinusPlus|CircleDot|nleqslant|NotExists|gtreqless|nparallel|UnionPlus|LeftFloor|checkmark|CenterDot|centerdot|Mellintrf|gtrapprox|bigotimes|OverBrace|spadesuit|therefore|pitchfork|rationals|PlusMinus|Backslash|Therefore|DownBreve|backsimeq|backprime|DownArrow|nshortmid|Downarrow|lvertneqq|eqvparsl|imagline|imagpart|infintie|integers|Integral|intercal|LessLess|Uarrocir|intlarhk|sqsupset|angmsdaf|sqsubset|llcorner|vartheta|cupbrcap|lnapprox|Superset|SuchThat|succnsim|succneqq|angmsdag|biguplus|curlyvee|trpezium|Succeeds|NotTilde|bigwedge|angmsdah|angrtvbd|triminus|cwconint|fpartint|lrcorner|smeparsl|subseteq|urcorner|lurdshar|laemptyv|DDotrahd|approxeq|ldrushar|awconint|mapstoup|backcong|shortmid|triangle|geqslant|gesdotol|timesbar|circledR|circledS|setminus|multimap|naturals|scpolint|ncongdot|RightTee|boxminus|gnapprox|boxtimes|andslope|thicksim|angmsdaa|varsigma|cirfnint|rtriltri|angmsdab|rppolint|angmsdac|barwedge|drbkarow|clubsuit|thetasym|bsolhsub|capbrcup|dzigrarr|doteqdot|DotEqual|dotminus|UnderBar|NotEqual|realpart|otimesas|ulcorner|hksearow|hkswarow|parallel|PartialD|elinters|emptyset|plusacir|bbrktbrk|angmsdad|pointint|bigoplus|angmsdae|Precedes|bigsqcup|varkappa|notindot|supseteq|precneqq|precnsim|profalar|profline|profsurf|leqslant|lesdotor|raemptyv|subplus|notnivb|notnivc|subrarr|zigrarr|vzigzag|submult|subedot|Element|between|cirscir|larrbfs|larrsim|lotimes|lbrksld|lbrkslu|lozenge|ldrdhar|dbkarow|bigcirc|epsilon|simrarr|simplus|ltquest|Epsilon|luruhar|gtquest|maltese|npolint|eqcolon|npreceq|bigodot|ddagger|gtrless|bnequiv|harrcir|ddotseq|equivDD|backsim|demptyv|nsqsube|nsqsupe|Upsilon|nsubset|upsilon|minusdu|nsucceq|swarrow|nsupset|coloneq|searrow|boxplus|napprox|natural|asympeq|alefsym|congdot|nearrow|bigstar|diamond|supplus|tritime|LeftTee|nvinfin|triplus|NewLine|nvltrie|nvrtrie|nwarrow|nexists|Diamond|ruluhar|Implies|supmult|angzarr|suplarr|suphsub|questeq|because|digamma|Because|olcross|bemptyv|omicron|Omicron|rotimes|NoBreak|intprod|angrtvb|orderof|uwangle|suphsol|lesdoto|orslope|DownTee|realine|cudarrl|rdldhar|OverBar|supedot|lessdot|supdsub|topfork|succsim|rbrkslu|rbrksld|pertenk|cudarrr|isindot|planckh|lessgtr|pluscir|gesdoto|plussim|plustwo|lesssim|cularrp|rarrsim|Cayleys|notinva|notinvb|notinvc|UpArrow|Uparrow|uparrow|NotLess|dwangle|precsim|Product|curarrm|Cconint|dotplus|rarrbfs|ccupssm|Cedilla|cemptyv|notniva|quatint|frac35|frac38|frac45|frac56|frac58|frac78|tridot|xoplus|gacute|gammad|Gammad|lfisht|lfloor|bigcup|sqsupe|gbreve|Gbreve|lharul|sqsube|sqcups|Gcedil|apacir|llhard|lmidot|Lmidot|lmoust|andand|sqcaps|approx|Abreve|spades|circeq|tprime|divide|topcir|Assign|topbot|gesdot|divonx|xuplus|timesd|gesles|atilde|solbar|SOFTcy|loplus|timesb|lowast|lowbar|dlcorn|dlcrop|softcy|dollar|lparlt|thksim|lrhard|Atilde|lsaquo|smashp|bigvee|thinsp|wreath|bkarow|lsquor|lstrok|Lstrok|lthree|ltimes|ltlarr|DotDot|simdot|ltrPar|weierp|xsqcup|angmsd|sigmav|sigmaf|zeetrf|Zcaron|zcaron|mapsto|vsupne|thetav|cirmid|marker|mcomma|Zacute|vsubnE|there4|gtlPar|vsubne|bottom|gtrarr|SHCHcy|shchcy|midast|midcir|middot|minusb|minusd|gtrdot|bowtie|sfrown|mnplus|models|colone|seswar|Colone|mstpos|searhk|gtrsim|nacute|Nacute|boxbox|telrec|hairsp|Tcedil|nbumpe|scnsim|ncaron|Ncaron|ncedil|Ncedil|hamilt|Scedil|nearhk|hardcy|HARDcy|tcedil|Tcaron|commat|nequiv|nesear|tcaron|target|hearts|nexist|varrho|scedil|Scaron|scaron|hellip|Sacute|sacute|hercon|swnwar|compfn|rtimes|rthree|rsquor|rsaquo|zacute|wedgeq|homtht|barvee|barwed|Barwed|rpargt|horbar|conint|swarhk|roplus|nltrie|hslash|hstrok|Hstrok|rmoust|Conint|bprime|hybull|hyphen|iacute|Iacute|supsup|supsub|supsim|varphi|coprod|brvbar|agrave|Supset|supset|igrave|Igrave|notinE|Agrave|iiiint|iinfin|copysr|wedbar|Verbar|vangrt|becaus|incare|verbar|inodot|bullet|drcorn|intcal|drcrop|cularr|vellip|Utilde|bumpeq|cupcap|dstrok|Dstrok|CupCap|cupcup|cupdot|eacute|Eacute|supdot|iquest|easter|ecaron|Ecaron|ecolon|isinsv|utilde|itilde|Itilde|curarr|succeq|Bumpeq|cacute|ulcrop|nparsl|Cacute|nprcue|egrave|Egrave|nrarrc|nrarrw|subsup|subsub|nrtrie|jsercy|nsccue|Jsercy|kappav|kcedil|Kcedil|subsim|ulcorn|nsimeq|egsdot|veebar|kgreen|capand|elsdot|Subset|subset|curren|aacute|lacute|Lacute|emptyv|ntilde|Ntilde|lagran|lambda|Lambda|capcap|Ugrave|langle|subdot|emsp13|numero|emsp14|nvdash|nvDash|nVdash|nVDash|ugrave|ufisht|nvHarr|larrfs|nvlArr|larrhk|larrlp|larrpl|nvrArr|Udblac|nwarhk|larrtl|nwnear|oacute|Oacute|latail|lAtail|sstarf|lbrace|odblac|Odblac|lbrack|udblac|odsold|eparsl|lcaron|Lcaron|ograve|Ograve|lcedil|Lcedil|Aacute|ssmile|ssetmn|squarf|ldquor|capcup|ominus|cylcty|rharul|eqcirc|dagger|rfloor|rfisht|Dagger|daleth|equals|origof|capdot|equest|dcaron|Dcaron|rdquor|oslash|Oslash|otilde|Otilde|otimes|Otimes|urcrop|Ubreve|ubreve|Yacute|Uacute|uacute|Rcedil|rcedil|urcorn|parsim|Rcaron|Vdashl|rcaron|Tstrok|percnt|period|permil|Exists|yacute|rbrack|rbrace|phmmat|ccaron|Ccaron|planck|ccedil|plankv|tstrok|female|plusdo|plusdu|ffilig|plusmn|ffllig|Ccedil|rAtail|dfisht|bernou|ratail|Rarrtl|rarrtl|angsph|rarrpl|rarrlp|rarrhk|xwedge|xotime|forall|ForAll|Vvdash|vsupnE|preceq|bigcap|frac12|frac13|frac14|primes|rarrfs|prnsim|frac15|Square|frac16|square|lesdot|frac18|frac23|propto|prurel|rarrap|rangle|puncsp|frac25|Racute|qprime|racute|lesges|frac34|abreve|AElig|eqsim|utdot|setmn|urtri|Equal|Uring|seArr|uring|searr|dashv|Dashv|mumap|nabla|iogon|Iogon|sdote|sdotb|scsim|napid|napos|equiv|natur|Acirc|dblac|erarr|nbump|iprod|erDot|ucirc|awint|esdot|angrt|ncong|isinE|scnap|Scirc|scirc|ndash|isins|Ubrcy|nearr|neArr|isinv|nedot|ubrcy|acute|Ycirc|iukcy|Iukcy|xutri|nesim|caret|jcirc|Jcirc|caron|twixt|ddarr|sccue|exist|jmath|sbquo|ngeqq|angst|ccaps|lceil|ngsim|UpTee|delta|Delta|rtrif|nharr|nhArr|nhpar|rtrie|jukcy|Jukcy|kappa|rsquo|Kappa|nlarr|nlArr|TSHcy|rrarr|aogon|Aogon|fflig|xrarr|tshcy|ccirc|nleqq|filig|upsih|nless|dharl|nlsim|fjlig|ropar|nltri|dharr|robrk|roarr|fllig|fltns|roang|rnmid|subnE|subne|lAarr|trisb|Ccirc|acirc|ccups|blank|VDash|forkv|Vdash|langd|cedil|blk12|blk14|laquo|strns|diams|notin|vDash|larrb|blk34|block|disin|uplus|vdash|vBarv|aelig|starf|Wedge|check|xrArr|lates|lbarr|lBarr|notni|lbbrk|bcong|frasl|lbrke|frown|vrtri|vprop|vnsup|gamma|Gamma|wedge|xodot|bdquo|srarr|doteq|ldquo|boxdl|boxdL|gcirc|Gcirc|boxDl|boxDL|boxdr|boxdR|boxDr|TRADE|trade|rlhar|boxDR|vnsub|npart|vltri|rlarr|boxhd|boxhD|nprec|gescc|nrarr|nrArr|boxHd|boxHD|boxhu|boxhU|nrtri|boxHu|clubs|boxHU|times|colon|Colon|gimel|xlArr|Tilde|nsime|tilde|nsmid|nspar|THORN|thorn|xlarr|nsube|nsubE|thkap|xhArr|comma|nsucc|boxul|boxuL|nsupe|nsupE|gneqq|gnsim|boxUl|boxUL|grave|boxur|boxuR|boxUr|boxUR|lescc|angle|bepsi|boxvh|varpi|boxvH|numsp|Theta|gsime|gsiml|theta|boxVh|boxVH|boxvl|gtcir|gtdot|boxvL|boxVl|boxVL|crarr|cross|Cross|nvsim|boxvr|nwarr|nwArr|sqsup|dtdot|Uogon|lhard|lharu|dtrif|ocirc|Ocirc|lhblk|duarr|odash|sqsub|Hacek|sqcup|llarr|duhar|oelig|OElig|ofcir|boxvR|uogon|lltri|boxVr|csube|uuarr|ohbar|csupe|ctdot|olarr|olcir|harrw|oline|sqcap|omacr|Omacr|omega|Omega|boxVR|aleph|lneqq|lnsim|loang|loarr|rharu|lobrk|hcirc|operp|oplus|rhard|Hcirc|orarr|Union|order|ecirc|Ecirc|cuepr|szlig|cuesc|breve|reals|eDDot|Breve|hoarr|lopar|utrif|rdquo|Umacr|umacr|efDot|swArr|ultri|alpha|rceil|ovbar|swarr|Wcirc|wcirc|smtes|smile|bsemi|lrarr|aring|parsl|lrhar|bsime|uhblk|lrtri|cupor|Aring|uharr|uharl|slarr|rbrke|bsolb|lsime|rbbrk|RBarr|lsimg|phone|rBarr|rbarr|icirc|lsquo|Icirc|emacr|Emacr|ratio|simne|plusb|simlE|simgE|simeq|pluse|ltcir|ltdot|empty|xharr|xdtri|iexcl|Alpha|ltrie|rarrw|pound|ltrif|xcirc|bumpe|prcue|bumpE|asymp|amacr|cuvee|Sigma|sigma|iiint|udhar|iiota|ijlig|IJlig|supnE|imacr|Imacr|prime|Prime|image|prnap|eogon|Eogon|rarrc|mdash|mDDot|cuwed|imath|supne|imped|Amacr|udarr|prsim|micro|rarrb|cwint|raquo|infin|eplus|range|rangd|Ucirc|radic|minus|amalg|veeeq|rAarr|epsiv|ycirc|quest|sharp|quot|zwnj|Qscr|race|qscr|Qopf|qopf|qint|rang|Rang|Zscr|zscr|Zopf|zopf|rarr|rArr|Rarr|Pscr|pscr|prop|prod|prnE|prec|ZHcy|zhcy|prap|Zeta|zeta|Popf|popf|Zdot|plus|zdot|Yuml|yuml|phiv|YUcy|yucy|Yscr|yscr|perp|Yopf|yopf|part|para|YIcy|Ouml|rcub|yicy|YAcy|rdca|ouml|osol|Oscr|rdsh|yacy|real|oscr|xvee|andd|rect|andv|Xscr|oror|ordm|ordf|xscr|ange|aopf|Aopf|rHar|Xopf|opar|Oopf|xopf|xnis|rhov|oopf|omid|xmap|oint|apid|apos|ogon|ascr|Ascr|odot|odiv|xcup|xcap|ocir|oast|nvlt|nvle|nvgt|nvge|nvap|Wscr|wscr|auml|ntlg|ntgl|nsup|nsub|nsim|Nscr|nscr|nsce|Wopf|ring|npre|wopf|npar|Auml|Barv|bbrk|Nopf|nopf|nmid|nLtv|beta|ropf|Ropf|Beta|beth|nles|rpar|nleq|bnot|bNot|nldr|NJcy|rscr|Rscr|Vscr|vscr|rsqb|njcy|bopf|nisd|Bopf|rtri|Vopf|nGtv|ngtr|vopf|boxh|boxH|boxv|nges|ngeq|boxV|bscr|scap|Bscr|bsim|Vert|vert|bsol|bull|bump|caps|cdot|ncup|scnE|ncap|nbsp|napE|Cdot|cent|sdot|Vbar|nang|vBar|chcy|Mscr|mscr|sect|semi|CHcy|Mopf|mopf|sext|circ|cire|mldr|mlcp|cirE|comp|shcy|SHcy|vArr|varr|cong|copf|Copf|copy|COPY|malt|male|macr|lvnE|cscr|ltri|sime|ltcc|simg|Cscr|siml|csub|Uuml|lsqb|lsim|uuml|csup|Lscr|lscr|utri|smid|lpar|cups|smte|lozf|darr|Lopf|Uscr|solb|lopf|sopf|Sopf|lneq|uscr|spar|dArr|lnap|Darr|dash|Sqrt|LJcy|ljcy|lHar|dHar|Upsi|upsi|diam|lesg|djcy|DJcy|leqq|dopf|Dopf|dscr|Dscr|dscy|ldsh|ldca|squf|DScy|sscr|Sscr|dsol|lcub|late|star|Star|Uopf|Larr|lArr|larr|uopf|dtri|dzcy|sube|subE|Lang|lang|Kscr|kscr|Kopf|kopf|KJcy|kjcy|KHcy|khcy|DZcy|ecir|edot|eDot|Jscr|jscr|succ|Jopf|jopf|Edot|uHar|emsp|ensp|Iuml|iuml|eopf|isin|Iscr|iscr|Eopf|epar|sung|epsi|escr|sup1|sup2|sup3|Iota|iota|supe|supE|Iopf|iopf|IOcy|iocy|Escr|esim|Esim|imof|Uarr|QUOT|uArr|uarr|euml|IEcy|iecy|Idot|Euml|euro|excl|Hscr|hscr|Hopf|hopf|TScy|tscy|Tscr|hbar|tscr|flat|tbrk|fnof|hArr|harr|half|fopf|Fopf|tdot|gvnE|fork|trie|gtcc|fscr|Fscr|gdot|gsim|Gscr|gscr|Gopf|gopf|gneq|Gdot|tosa|gnap|Topf|topf|geqq|toea|GJcy|gjcy|tint|gesl|mid|Sfr|ggg|top|ges|gla|glE|glj|geq|gne|gEl|gel|gnE|Gcy|gcy|gap|Tfr|tfr|Tcy|tcy|Hat|Tau|Ffr|tau|Tab|hfr|Hfr|ffr|Fcy|fcy|icy|Icy|iff|ETH|eth|ifr|Ifr|Eta|eta|int|Int|Sup|sup|ucy|Ucy|Sum|sum|jcy|ENG|ufr|Ufr|eng|Jcy|jfr|els|ell|egs|Efr|efr|Jfr|uml|kcy|Kcy|Ecy|ecy|kfr|Kfr|lap|Sub|sub|lat|lcy|Lcy|leg|Dot|dot|lEg|leq|les|squ|div|die|lfr|Lfr|lgE|Dfr|dfr|Del|deg|Dcy|dcy|lne|lnE|sol|loz|smt|Cup|lrm|cup|lsh|Lsh|sim|shy|map|Map|mcy|Mcy|mfr|Mfr|mho|gfr|Gfr|sfr|cir|Chi|chi|nap|Cfr|vcy|Vcy|cfr|Scy|scy|ncy|Ncy|vee|Vee|Cap|cap|nfr|scE|sce|Nfr|nge|ngE|nGg|vfr|Vfr|ngt|bot|nGt|nis|niv|Rsh|rsh|nle|nlE|bne|Bfr|bfr|nLl|nlt|nLt|Bcy|bcy|not|Not|rlm|wfr|Wfr|npr|nsc|num|ocy|ast|Ocy|ofr|xfr|Xfr|Ofr|ogt|ohm|apE|olt|Rho|ape|rho|Rfr|rfr|ord|REG|ang|reg|orv|And|and|AMP|Rcy|amp|Afr|ycy|Ycy|yen|yfr|Yfr|rcy|par|pcy|Pcy|pfr|Pfr|phi|Phi|afr|Acy|acy|zcy|Zcy|piv|acE|acd|zfr|Zfr|pre|prE|psi|Psi|qfr|Qfr|zwj|Or|ge|Gg|gt|gg|el|oS|lt|Lt|LT|Re|lg|gl|eg|ne|Im|it|le|DD|wp|wr|nu|Nu|dd|lE|Sc|sc|pi|Pi|ee|af|ll|Ll|rx|gE|xi|pm|Xi|ic|pr|Pr|in|ni|mp|mu|ac|Mu|or|ap|Gt|GT|ii);|&(Aacute|Agrave|Atilde|Ccedil|Eacute|Egrave|Iacute|Igrave|Ntilde|Oacute|Ograve|Oslash|Otilde|Uacute|Ugrave|Yacute|aacute|agrave|atilde|brvbar|ccedil|curren|divide|eacute|egrave|frac12|frac14|frac34|iacute|igrave|iquest|middot|ntilde|oacute|ograve|oslash|otilde|plusmn|uacute|ugrave|yacute|AElig|Acirc|Aring|Ecirc|Icirc|Ocirc|THORN|Ucirc|acirc|acute|aelig|aring|cedil|ecirc|icirc|iexcl|laquo|micro|ocirc|pound|raquo|szlig|thorn|times|ucirc|Auml|COPY|Euml|Iuml|Ouml|QUOT|Uuml|auml|cent|copy|euml|iuml|macr|nbsp|ordf|ordm|ouml|para|quot|sect|sup1|sup2|sup3|uuml|yuml|AMP|ETH|REG|amp|deg|eth|not|reg|shy|uml|yen|GT|LT|gt|lt)(?!;)([=a-zA-Z0-9]?)|&#([0-9]+)(;?)|&#[xX]([a-fA-F0-9]+)(;?)|&([0-9a-zA-Z]+)/g;
  6060. var decodeMap = {'aacute':'\xE1','Aacute':'\xC1','abreve':'\u0103','Abreve':'\u0102','ac':'\u223E','acd':'\u223F','acE':'\u223E\u0333','acirc':'\xE2','Acirc':'\xC2','acute':'\xB4','acy':'\u0430','Acy':'\u0410','aelig':'\xE6','AElig':'\xC6','af':'\u2061','afr':'\uD835\uDD1E','Afr':'\uD835\uDD04','agrave':'\xE0','Agrave':'\xC0','alefsym':'\u2135','aleph':'\u2135','alpha':'\u03B1','Alpha':'\u0391','amacr':'\u0101','Amacr':'\u0100','amalg':'\u2A3F','amp':'&','AMP':'&','and':'\u2227','And':'\u2A53','andand':'\u2A55','andd':'\u2A5C','andslope':'\u2A58','andv':'\u2A5A','ang':'\u2220','ange':'\u29A4','angle':'\u2220','angmsd':'\u2221','angmsdaa':'\u29A8','angmsdab':'\u29A9','angmsdac':'\u29AA','angmsdad':'\u29AB','angmsdae':'\u29AC','angmsdaf':'\u29AD','angmsdag':'\u29AE','angmsdah':'\u29AF','angrt':'\u221F','angrtvb':'\u22BE','angrtvbd':'\u299D','angsph':'\u2222','angst':'\xC5','angzarr':'\u237C','aogon':'\u0105','Aogon':'\u0104','aopf':'\uD835\uDD52','Aopf':'\uD835\uDD38','ap':'\u2248','apacir':'\u2A6F','ape':'\u224A','apE':'\u2A70','apid':'\u224B','apos':'\'','ApplyFunction':'\u2061','approx':'\u2248','approxeq':'\u224A','aring':'\xE5','Aring':'\xC5','ascr':'\uD835\uDCB6','Ascr':'\uD835\uDC9C','Assign':'\u2254','ast':'*','asymp':'\u2248','asympeq':'\u224D','atilde':'\xE3','Atilde':'\xC3','auml':'\xE4','Auml':'\xC4','awconint':'\u2233','awint':'\u2A11','backcong':'\u224C','backepsilon':'\u03F6','backprime':'\u2035','backsim':'\u223D','backsimeq':'\u22CD','Backslash':'\u2216','Barv':'\u2AE7','barvee':'\u22BD','barwed':'\u2305','Barwed':'\u2306','barwedge':'\u2305','bbrk':'\u23B5','bbrktbrk':'\u23B6','bcong':'\u224C','bcy':'\u0431','Bcy':'\u0411','bdquo':'\u201E','becaus':'\u2235','because':'\u2235','Because':'\u2235','bemptyv':'\u29B0','bepsi':'\u03F6','bernou':'\u212C','Bernoullis':'\u212C','beta':'\u03B2','Beta':'\u0392','beth':'\u2136','between':'\u226C','bfr':'\uD835\uDD1F','Bfr':'\uD835\uDD05','bigcap':'\u22C2','bigcirc':'\u25EF','bigcup':'\u22C3','bigodot':'\u2A00','bigoplus':'\u2A01','bigotimes':'\u2A02','bigsqcup':'\u2A06','bigstar':'\u2605','bigtriangledown':'\u25BD','bigtriangleup':'\u25B3','biguplus':'\u2A04','bigvee':'\u22C1','bigwedge':'\u22C0','bkarow':'\u290D','blacklozenge':'\u29EB','blacksquare':'\u25AA','blacktriangle':'\u25B4','blacktriangledown':'\u25BE','blacktriangleleft':'\u25C2','blacktriangleright':'\u25B8','blank':'\u2423','blk12':'\u2592','blk14':'\u2591','blk34':'\u2593','block':'\u2588','bne':'=\u20E5','bnequiv':'\u2261\u20E5','bnot':'\u2310','bNot':'\u2AED','bopf':'\uD835\uDD53','Bopf':'\uD835\uDD39','bot':'\u22A5','bottom':'\u22A5','bowtie':'\u22C8','boxbox':'\u29C9','boxdl':'\u2510','boxdL':'\u2555','boxDl':'\u2556','boxDL':'\u2557','boxdr':'\u250C','boxdR':'\u2552','boxDr':'\u2553','boxDR':'\u2554','boxh':'\u2500','boxH':'\u2550','boxhd':'\u252C','boxhD':'\u2565','boxHd':'\u2564','boxHD':'\u2566','boxhu':'\u2534','boxhU':'\u2568','boxHu':'\u2567','boxHU':'\u2569','boxminus':'\u229F','boxplus':'\u229E','boxtimes':'\u22A0','boxul':'\u2518','boxuL':'\u255B','boxUl':'\u255C','boxUL':'\u255D','boxur':'\u2514','boxuR':'\u2558','boxUr':'\u2559','boxUR':'\u255A','boxv':'\u2502','boxV':'\u2551','boxvh':'\u253C','boxvH':'\u256A','boxVh':'\u256B','boxVH':'\u256C','boxvl':'\u2524','boxvL':'\u2561','boxVl':'\u2562','boxVL':'\u2563','boxvr':'\u251C','boxvR':'\u255E','boxVr':'\u255F','boxVR':'\u2560','bprime':'\u2035','breve':'\u02D8','Breve':'\u02D8','brvbar':'\xA6','bscr':'\uD835\uDCB7','Bscr':'\u212C','bsemi':'\u204F','bsim':'\u223D','bsime':'\u22CD','bsol':'\\','bsolb':'\u29C5','bsolhsub':'\u27C8','bull':'\u2022','bullet':'\u2022','bump':'\u224E','bumpe':'\u224F','bumpE':'\u2AAE','bumpeq':'\u224F','Bumpeq':'\u224E','cacute':'\u0107','Cacute':'\u0106','cap':'\u2229','Cap':'\u22D2','capand':'\u2A44','capbrcup':'\u2A49','capcap':'\u2A4B','capcup':'\u2A47','capdot':'\u2A40','CapitalDifferentialD':'\u2145','caps':'\u2229\uFE00','caret':'\u2041','caron':'\u02C7','Cayleys':'\u212D','ccaps':'\u2A4D','ccaron':'\u010D','Ccaron':'\u010C','ccedil':'\xE7','Ccedil':'\xC7','ccirc':'\u0109','Ccirc':'\u0108','Cconint':'\u2230','ccups':'\u2A4C','ccupssm':'\u2A50','cdot':'\u010B','Cdot':'\u010A','cedil':'\xB8','Cedilla':'\xB8','cemptyv':'\u29B2','cent':'\xA2','centerdot':'\xB7','CenterDot':'\xB7','cfr':'\uD835\uDD20','Cfr':'\u212D','chcy':'\u0447','CHcy':'\u0427','check':'\u2713','checkmark':'\u2713','chi':'\u03C7','Chi':'\u03A7','cir':'\u25CB','circ':'\u02C6','circeq':'\u2257','circlearrowleft':'\u21BA','circlearrowright':'\u21BB','circledast':'\u229B','circledcirc':'\u229A','circleddash':'\u229D','CircleDot':'\u2299','circledR':'\xAE','circledS':'\u24C8','CircleMinus':'\u2296','CirclePlus':'\u2295','CircleTimes':'\u2297','cire':'\u2257','cirE':'\u29C3','cirfnint':'\u2A10','cirmid':'\u2AEF','cirscir':'\u29C2','ClockwiseContourIntegral':'\u2232','CloseCurlyDoubleQuote':'\u201D','CloseCurlyQuote':'\u2019','clubs':'\u2663','clubsuit':'\u2663','colon':':','Colon':'\u2237','colone':'\u2254','Colone':'\u2A74','coloneq':'\u2254','comma':',','commat':'@','comp':'\u2201','compfn':'\u2218','complement':'\u2201','complexes':'\u2102','cong':'\u2245','congdot':'\u2A6D','Congruent':'\u2261','conint':'\u222E','Conint':'\u222F','ContourIntegral':'\u222E','copf':'\uD835\uDD54','Copf':'\u2102','coprod':'\u2210','Coproduct':'\u2210','copy':'\xA9','COPY':'\xA9','copysr':'\u2117','CounterClockwiseContourIntegral':'\u2233','crarr':'\u21B5','cross':'\u2717','Cross':'\u2A2F','cscr':'\uD835\uDCB8','Cscr':'\uD835\uDC9E','csub':'\u2ACF','csube':'\u2AD1','csup':'\u2AD0','csupe':'\u2AD2','ctdot':'\u22EF','cudarrl':'\u2938','cudarrr':'\u2935','cuepr':'\u22DE','cuesc':'\u22DF','cularr':'\u21B6','cularrp':'\u293D','cup':'\u222A','Cup':'\u22D3','cupbrcap':'\u2A48','cupcap':'\u2A46','CupCap':'\u224D','cupcup':'\u2A4A','cupdot':'\u228D','cupor':'\u2A45','cups':'\u222A\uFE00','curarr':'\u21B7','curarrm':'\u293C','curlyeqprec':'\u22DE','curlyeqsucc':'\u22DF','curlyvee':'\u22CE','curlywedge':'\u22CF','curren':'\xA4','curvearrowleft':'\u21B6','curvearrowright':'\u21B7','cuvee':'\u22CE','cuwed':'\u22CF','cwconint':'\u2232','cwint':'\u2231','cylcty':'\u232D','dagger':'\u2020','Dagger':'\u2021','daleth':'\u2138','darr':'\u2193','dArr':'\u21D3','Darr':'\u21A1','dash':'\u2010','dashv':'\u22A3','Dashv':'\u2AE4','dbkarow':'\u290F','dblac':'\u02DD','dcaron':'\u010F','Dcaron':'\u010E','dcy':'\u0434','Dcy':'\u0414','dd':'\u2146','DD':'\u2145','ddagger':'\u2021','ddarr':'\u21CA','DDotrahd':'\u2911','ddotseq':'\u2A77','deg':'\xB0','Del':'\u2207','delta':'\u03B4','Delta':'\u0394','demptyv':'\u29B1','dfisht':'\u297F','dfr':'\uD835\uDD21','Dfr':'\uD835\uDD07','dHar':'\u2965','dharl':'\u21C3','dharr':'\u21C2','DiacriticalAcute':'\xB4','DiacriticalDot':'\u02D9','DiacriticalDoubleAcute':'\u02DD','DiacriticalGrave':'`','DiacriticalTilde':'\u02DC','diam':'\u22C4','diamond':'\u22C4','Diamond':'\u22C4','diamondsuit':'\u2666','diams':'\u2666','die':'\xA8','DifferentialD':'\u2146','digamma':'\u03DD','disin':'\u22F2','div':'\xF7','divide':'\xF7','divideontimes':'\u22C7','divonx':'\u22C7','djcy':'\u0452','DJcy':'\u0402','dlcorn':'\u231E','dlcrop':'\u230D','dollar':'$','dopf':'\uD835\uDD55','Dopf':'\uD835\uDD3B','dot':'\u02D9','Dot':'\xA8','DotDot':'\u20DC','doteq':'\u2250','doteqdot':'\u2251','DotEqual':'\u2250','dotminus':'\u2238','dotplus':'\u2214','dotsquare':'\u22A1','doublebarwedge':'\u2306','DoubleContourIntegral':'\u222F','DoubleDot':'\xA8','DoubleDownArrow':'\u21D3','DoubleLeftArrow':'\u21D0','DoubleLeftRightArrow':'\u21D4','DoubleLeftTee':'\u2AE4','DoubleLongLeftArrow':'\u27F8','DoubleLongLeftRightArrow':'\u27FA','DoubleLongRightArrow':'\u27F9','DoubleRightArrow':'\u21D2','DoubleRightTee':'\u22A8','DoubleUpArrow':'\u21D1','DoubleUpDownArrow':'\u21D5','DoubleVerticalBar':'\u2225','downarrow':'\u2193','Downarrow':'\u21D3','DownArrow':'\u2193','DownArrowBar':'\u2913','DownArrowUpArrow':'\u21F5','DownBreve':'\u0311','downdownarrows':'\u21CA','downharpoonleft':'\u21C3','downharpoonright':'\u21C2','DownLeftRightVector':'\u2950','DownLeftTeeVector':'\u295E','DownLeftVector':'\u21BD','DownLeftVectorBar':'\u2956','DownRightTeeVector':'\u295F','DownRightVector':'\u21C1','DownRightVectorBar':'\u2957','DownTee':'\u22A4','DownTeeArrow':'\u21A7','drbkarow':'\u2910','drcorn':'\u231F','drcrop':'\u230C','dscr':'\uD835\uDCB9','Dscr':'\uD835\uDC9F','dscy':'\u0455','DScy':'\u0405','dsol':'\u29F6','dstrok':'\u0111','Dstrok':'\u0110','dtdot':'\u22F1','dtri':'\u25BF','dtrif':'\u25BE','duarr':'\u21F5','duhar':'\u296F','dwangle':'\u29A6','dzcy':'\u045F','DZcy':'\u040F','dzigrarr':'\u27FF','eacute':'\xE9','Eacute':'\xC9','easter':'\u2A6E','ecaron':'\u011B','Ecaron':'\u011A','ecir':'\u2256','ecirc':'\xEA','Ecirc':'\xCA','ecolon':'\u2255','ecy':'\u044D','Ecy':'\u042D','eDDot':'\u2A77','edot':'\u0117','eDot':'\u2251','Edot':'\u0116','ee':'\u2147','efDot':'\u2252','efr':'\uD835\uDD22','Efr':'\uD835\uDD08','eg':'\u2A9A','egrave':'\xE8','Egrave':'\xC8','egs':'\u2A96','egsdot':'\u2A98','el':'\u2A99','Element':'\u2208','elinters':'\u23E7','ell':'\u2113','els':'\u2A95','elsdot':'\u2A97','emacr':'\u0113','Emacr':'\u0112','empty':'\u2205','emptyset':'\u2205','EmptySmallSquare':'\u25FB','emptyv':'\u2205','EmptyVerySmallSquare':'\u25AB','emsp':'\u2003','emsp13':'\u2004','emsp14':'\u2005','eng':'\u014B','ENG':'\u014A','ensp':'\u2002','eogon':'\u0119','Eogon':'\u0118','eopf':'\uD835\uDD56','Eopf':'\uD835\uDD3C','epar':'\u22D5','eparsl':'\u29E3','eplus':'\u2A71','epsi':'\u03B5','epsilon':'\u03B5','Epsilon':'\u0395','epsiv':'\u03F5','eqcirc':'\u2256','eqcolon':'\u2255','eqsim':'\u2242','eqslantgtr':'\u2A96','eqslantless':'\u2A95','Equal':'\u2A75','equals':'=','EqualTilde':'\u2242','equest':'\u225F','Equilibrium':'\u21CC','equiv':'\u2261','equivDD':'\u2A78','eqvparsl':'\u29E5','erarr':'\u2971','erDot':'\u2253','escr':'\u212F','Escr':'\u2130','esdot':'\u2250','esim':'\u2242','Esim':'\u2A73','eta':'\u03B7','Eta':'\u0397','eth':'\xF0','ETH':'\xD0','euml':'\xEB','Euml':'\xCB','euro':'\u20AC','excl':'!','exist':'\u2203','Exists':'\u2203','expectation':'\u2130','exponentiale':'\u2147','ExponentialE':'\u2147','fallingdotseq':'\u2252','fcy':'\u0444','Fcy':'\u0424','female':'\u2640','ffilig':'\uFB03','fflig':'\uFB00','ffllig':'\uFB04','ffr':'\uD835\uDD23','Ffr':'\uD835\uDD09','filig':'\uFB01','FilledSmallSquare':'\u25FC','FilledVerySmallSquare':'\u25AA','fjlig':'fj','flat':'\u266D','fllig':'\uFB02','fltns':'\u25B1','fnof':'\u0192','fopf':'\uD835\uDD57','Fopf':'\uD835\uDD3D','forall':'\u2200','ForAll':'\u2200','fork':'\u22D4','forkv':'\u2AD9','Fouriertrf':'\u2131','fpartint':'\u2A0D','frac12':'\xBD','frac13':'\u2153','frac14':'\xBC','frac15':'\u2155','frac16':'\u2159','frac18':'\u215B','frac23':'\u2154','frac25':'\u2156','frac34':'\xBE','frac35':'\u2157','frac38':'\u215C','frac45':'\u2158','frac56':'\u215A','frac58':'\u215D','frac78':'\u215E','frasl':'\u2044','frown':'\u2322','fscr':'\uD835\uDCBB','Fscr':'\u2131','gacute':'\u01F5','gamma':'\u03B3','Gamma':'\u0393','gammad':'\u03DD','Gammad':'\u03DC','gap':'\u2A86','gbreve':'\u011F','Gbreve':'\u011E','Gcedil':'\u0122','gcirc':'\u011D','Gcirc':'\u011C','gcy':'\u0433','Gcy':'\u0413','gdot':'\u0121','Gdot':'\u0120','ge':'\u2265','gE':'\u2267','gel':'\u22DB','gEl':'\u2A8C','geq':'\u2265','geqq':'\u2267','geqslant':'\u2A7E','ges':'\u2A7E','gescc':'\u2AA9','gesdot':'\u2A80','gesdoto':'\u2A82','gesdotol':'\u2A84','gesl':'\u22DB\uFE00','gesles':'\u2A94','gfr':'\uD835\uDD24','Gfr':'\uD835\uDD0A','gg':'\u226B','Gg':'\u22D9','ggg':'\u22D9','gimel':'\u2137','gjcy':'\u0453','GJcy':'\u0403','gl':'\u2277','gla':'\u2AA5','glE':'\u2A92','glj':'\u2AA4','gnap':'\u2A8A','gnapprox':'\u2A8A','gne':'\u2A88','gnE':'\u2269','gneq':'\u2A88','gneqq':'\u2269','gnsim':'\u22E7','gopf':'\uD835\uDD58','Gopf':'\uD835\uDD3E','grave':'`','GreaterEqual':'\u2265','GreaterEqualLess':'\u22DB','GreaterFullEqual':'\u2267','GreaterGreater':'\u2AA2','GreaterLess':'\u2277','GreaterSlantEqual':'\u2A7E','GreaterTilde':'\u2273','gscr':'\u210A','Gscr':'\uD835\uDCA2','gsim':'\u2273','gsime':'\u2A8E','gsiml':'\u2A90','gt':'>','Gt':'\u226B','GT':'>','gtcc':'\u2AA7','gtcir':'\u2A7A','gtdot':'\u22D7','gtlPar':'\u2995','gtquest':'\u2A7C','gtrapprox':'\u2A86','gtrarr':'\u2978','gtrdot':'\u22D7','gtreqless':'\u22DB','gtreqqless':'\u2A8C','gtrless':'\u2277','gtrsim':'\u2273','gvertneqq':'\u2269\uFE00','gvnE':'\u2269\uFE00','Hacek':'\u02C7','hairsp':'\u200A','half':'\xBD','hamilt':'\u210B','hardcy':'\u044A','HARDcy':'\u042A','harr':'\u2194','hArr':'\u21D4','harrcir':'\u2948','harrw':'\u21AD','Hat':'^','hbar':'\u210F','hcirc':'\u0125','Hcirc':'\u0124','hearts':'\u2665','heartsuit':'\u2665','hellip':'\u2026','hercon':'\u22B9','hfr':'\uD835\uDD25','Hfr':'\u210C','HilbertSpace':'\u210B','hksearow':'\u2925','hkswarow':'\u2926','hoarr':'\u21FF','homtht':'\u223B','hookleftarrow':'\u21A9','hookrightarrow':'\u21AA','hopf':'\uD835\uDD59','Hopf':'\u210D','horbar':'\u2015','HorizontalLine':'\u2500','hscr':'\uD835\uDCBD','Hscr':'\u210B','hslash':'\u210F','hstrok':'\u0127','Hstrok':'\u0126','HumpDownHump':'\u224E','HumpEqual':'\u224F','hybull':'\u2043','hyphen':'\u2010','iacute':'\xED','Iacute':'\xCD','ic':'\u2063','icirc':'\xEE','Icirc':'\xCE','icy':'\u0438','Icy':'\u0418','Idot':'\u0130','iecy':'\u0435','IEcy':'\u0415','iexcl':'\xA1','iff':'\u21D4','ifr':'\uD835\uDD26','Ifr':'\u2111','igrave':'\xEC','Igrave':'\xCC','ii':'\u2148','iiiint':'\u2A0C','iiint':'\u222D','iinfin':'\u29DC','iiota':'\u2129','ijlig':'\u0133','IJlig':'\u0132','Im':'\u2111','imacr':'\u012B','Imacr':'\u012A','image':'\u2111','ImaginaryI':'\u2148','imagline':'\u2110','imagpart':'\u2111','imath':'\u0131','imof':'\u22B7','imped':'\u01B5','Implies':'\u21D2','in':'\u2208','incare':'\u2105','infin':'\u221E','infintie':'\u29DD','inodot':'\u0131','int':'\u222B','Int':'\u222C','intcal':'\u22BA','integers':'\u2124','Integral':'\u222B','intercal':'\u22BA','Intersection':'\u22C2','intlarhk':'\u2A17','intprod':'\u2A3C','InvisibleComma':'\u2063','InvisibleTimes':'\u2062','iocy':'\u0451','IOcy':'\u0401','iogon':'\u012F','Iogon':'\u012E','iopf':'\uD835\uDD5A','Iopf':'\uD835\uDD40','iota':'\u03B9','Iota':'\u0399','iprod':'\u2A3C','iquest':'\xBF','iscr':'\uD835\uDCBE','Iscr':'\u2110','isin':'\u2208','isindot':'\u22F5','isinE':'\u22F9','isins':'\u22F4','isinsv':'\u22F3','isinv':'\u2208','it':'\u2062','itilde':'\u0129','Itilde':'\u0128','iukcy':'\u0456','Iukcy':'\u0406','iuml':'\xEF','Iuml':'\xCF','jcirc':'\u0135','Jcirc':'\u0134','jcy':'\u0439','Jcy':'\u0419','jfr':'\uD835\uDD27','Jfr':'\uD835\uDD0D','jmath':'\u0237','jopf':'\uD835\uDD5B','Jopf':'\uD835\uDD41','jscr':'\uD835\uDCBF','Jscr':'\uD835\uDCA5','jsercy':'\u0458','Jsercy':'\u0408','jukcy':'\u0454','Jukcy':'\u0404','kappa':'\u03BA','Kappa':'\u039A','kappav':'\u03F0','kcedil':'\u0137','Kcedil':'\u0136','kcy':'\u043A','Kcy':'\u041A','kfr':'\uD835\uDD28','Kfr':'\uD835\uDD0E','kgreen':'\u0138','khcy':'\u0445','KHcy':'\u0425','kjcy':'\u045C','KJcy':'\u040C','kopf':'\uD835\uDD5C','Kopf':'\uD835\uDD42','kscr':'\uD835\uDCC0','Kscr':'\uD835\uDCA6','lAarr':'\u21DA','lacute':'\u013A','Lacute':'\u0139','laemptyv':'\u29B4','lagran':'\u2112','lambda':'\u03BB','Lambda':'\u039B','lang':'\u27E8','Lang':'\u27EA','langd':'\u2991','langle':'\u27E8','lap':'\u2A85','Laplacetrf':'\u2112','laquo':'\xAB','larr':'\u2190','lArr':'\u21D0','Larr':'\u219E','larrb':'\u21E4','larrbfs':'\u291F','larrfs':'\u291D','larrhk':'\u21A9','larrlp':'\u21AB','larrpl':'\u2939','larrsim':'\u2973','larrtl':'\u21A2','lat':'\u2AAB','latail':'\u2919','lAtail':'\u291B','late':'\u2AAD','lates':'\u2AAD\uFE00','lbarr':'\u290C','lBarr':'\u290E','lbbrk':'\u2772','lbrace':'{','lbrack':'[','lbrke':'\u298B','lbrksld':'\u298F','lbrkslu':'\u298D','lcaron':'\u013E','Lcaron':'\u013D','lcedil':'\u013C','Lcedil':'\u013B','lceil':'\u2308','lcub':'{','lcy':'\u043B','Lcy':'\u041B','ldca':'\u2936','ldquo':'\u201C','ldquor':'\u201E','ldrdhar':'\u2967','ldrushar':'\u294B','ldsh':'\u21B2','le':'\u2264','lE':'\u2266','LeftAngleBracket':'\u27E8','leftarrow':'\u2190','Leftarrow':'\u21D0','LeftArrow':'\u2190','LeftArrowBar':'\u21E4','LeftArrowRightArrow':'\u21C6','leftarrowtail':'\u21A2','LeftCeiling':'\u2308','LeftDoubleBracket':'\u27E6','LeftDownTeeVector':'\u2961','LeftDownVector':'\u21C3','LeftDownVectorBar':'\u2959','LeftFloor':'\u230A','leftharpoondown':'\u21BD','leftharpoonup':'\u21BC','leftleftarrows':'\u21C7','leftrightarrow':'\u2194','Leftrightarrow':'\u21D4','LeftRightArrow':'\u2194','leftrightarrows':'\u21C6','leftrightharpoons':'\u21CB','leftrightsquigarrow':'\u21AD','LeftRightVector':'\u294E','LeftTee':'\u22A3','LeftTeeArrow':'\u21A4','LeftTeeVector':'\u295A','leftthreetimes':'\u22CB','LeftTriangle':'\u22B2','LeftTriangleBar':'\u29CF','LeftTriangleEqual':'\u22B4','LeftUpDownVector':'\u2951','LeftUpTeeVector':'\u2960','LeftUpVector':'\u21BF','LeftUpVectorBar':'\u2958','LeftVector':'\u21BC','LeftVectorBar':'\u2952','leg':'\u22DA','lEg':'\u2A8B','leq':'\u2264','leqq':'\u2266','leqslant':'\u2A7D','les':'\u2A7D','lescc':'\u2AA8','lesdot':'\u2A7F','lesdoto':'\u2A81','lesdotor':'\u2A83','lesg':'\u22DA\uFE00','lesges':'\u2A93','lessapprox':'\u2A85','lessdot':'\u22D6','lesseqgtr':'\u22DA','lesseqqgtr':'\u2A8B','LessEqualGreater':'\u22DA','LessFullEqual':'\u2266','LessGreater':'\u2276','lessgtr':'\u2276','LessLess':'\u2AA1','lesssim':'\u2272','LessSlantEqual':'\u2A7D','LessTilde':'\u2272','lfisht':'\u297C','lfloor':'\u230A','lfr':'\uD835\uDD29','Lfr':'\uD835\uDD0F','lg':'\u2276','lgE':'\u2A91','lHar':'\u2962','lhard':'\u21BD','lharu':'\u21BC','lharul':'\u296A','lhblk':'\u2584','ljcy':'\u0459','LJcy':'\u0409','ll':'\u226A','Ll':'\u22D8','llarr':'\u21C7','llcorner':'\u231E','Lleftarrow':'\u21DA','llhard':'\u296B','lltri':'\u25FA','lmidot':'\u0140','Lmidot':'\u013F','lmoust':'\u23B0','lmoustache':'\u23B0','lnap':'\u2A89','lnapprox':'\u2A89','lne':'\u2A87','lnE':'\u2268','lneq':'\u2A87','lneqq':'\u2268','lnsim':'\u22E6','loang':'\u27EC','loarr':'\u21FD','lobrk':'\u27E6','longleftarrow':'\u27F5','Longleftarrow':'\u27F8','LongLeftArrow':'\u27F5','longleftrightarrow':'\u27F7','Longleftrightarrow':'\u27FA','LongLeftRightArrow':'\u27F7','longmapsto':'\u27FC','longrightarrow':'\u27F6','Longrightarrow':'\u27F9','LongRightArrow':'\u27F6','looparrowleft':'\u21AB','looparrowright':'\u21AC','lopar':'\u2985','lopf':'\uD835\uDD5D','Lopf':'\uD835\uDD43','loplus':'\u2A2D','lotimes':'\u2A34','lowast':'\u2217','lowbar':'_','LowerLeftArrow':'\u2199','LowerRightArrow':'\u2198','loz':'\u25CA','lozenge':'\u25CA','lozf':'\u29EB','lpar':'(','lparlt':'\u2993','lrarr':'\u21C6','lrcorner':'\u231F','lrhar':'\u21CB','lrhard':'\u296D','lrm':'\u200E','lrtri':'\u22BF','lsaquo':'\u2039','lscr':'\uD835\uDCC1','Lscr':'\u2112','lsh':'\u21B0','Lsh':'\u21B0','lsim':'\u2272','lsime':'\u2A8D','lsimg':'\u2A8F','lsqb':'[','lsquo':'\u2018','lsquor':'\u201A','lstrok':'\u0142','Lstrok':'\u0141','lt':'<','Lt':'\u226A','LT':'<','ltcc':'\u2AA6','ltcir':'\u2A79','ltdot':'\u22D6','lthree':'\u22CB','ltimes':'\u22C9','ltlarr':'\u2976','ltquest':'\u2A7B','ltri':'\u25C3','ltrie':'\u22B4','ltrif':'\u25C2','ltrPar':'\u2996','lurdshar':'\u294A','luruhar':'\u2966','lvertneqq':'\u2268\uFE00','lvnE':'\u2268\uFE00','macr':'\xAF','male':'\u2642','malt':'\u2720','maltese':'\u2720','map':'\u21A6','Map':'\u2905','mapsto':'\u21A6','mapstodown':'\u21A7','mapstoleft':'\u21A4','mapstoup':'\u21A5','marker':'\u25AE','mcomma':'\u2A29','mcy':'\u043C','Mcy':'\u041C','mdash':'\u2014','mDDot':'\u223A','measuredangle':'\u2221','MediumSpace':'\u205F','Mellintrf':'\u2133','mfr':'\uD835\uDD2A','Mfr':'\uD835\uDD10','mho':'\u2127','micro':'\xB5','mid':'\u2223','midast':'*','midcir':'\u2AF0','middot':'\xB7','minus':'\u2212','minusb':'\u229F','minusd':'\u2238','minusdu':'\u2A2A','MinusPlus':'\u2213','mlcp':'\u2ADB','mldr':'\u2026','mnplus':'\u2213','models':'\u22A7','mopf':'\uD835\uDD5E','Mopf':'\uD835\uDD44','mp':'\u2213','mscr':'\uD835\uDCC2','Mscr':'\u2133','mstpos':'\u223E','mu':'\u03BC','Mu':'\u039C','multimap':'\u22B8','mumap':'\u22B8','nabla':'\u2207','nacute':'\u0144','Nacute':'\u0143','nang':'\u2220\u20D2','nap':'\u2249','napE':'\u2A70\u0338','napid':'\u224B\u0338','napos':'\u0149','napprox':'\u2249','natur':'\u266E','natural':'\u266E','naturals':'\u2115','nbsp':'\xA0','nbump':'\u224E\u0338','nbumpe':'\u224F\u0338','ncap':'\u2A43','ncaron':'\u0148','Ncaron':'\u0147','ncedil':'\u0146','Ncedil':'\u0145','ncong':'\u2247','ncongdot':'\u2A6D\u0338','ncup':'\u2A42','ncy':'\u043D','Ncy':'\u041D','ndash':'\u2013','ne':'\u2260','nearhk':'\u2924','nearr':'\u2197','neArr':'\u21D7','nearrow':'\u2197','nedot':'\u2250\u0338','NegativeMediumSpace':'\u200B','NegativeThickSpace':'\u200B','NegativeThinSpace':'\u200B','NegativeVeryThinSpace':'\u200B','nequiv':'\u2262','nesear':'\u2928','nesim':'\u2242\u0338','NestedGreaterGreater':'\u226B','NestedLessLess':'\u226A','NewLine':'\n','nexist':'\u2204','nexists':'\u2204','nfr':'\uD835\uDD2B','Nfr':'\uD835\uDD11','nge':'\u2271','ngE':'\u2267\u0338','ngeq':'\u2271','ngeqq':'\u2267\u0338','ngeqslant':'\u2A7E\u0338','nges':'\u2A7E\u0338','nGg':'\u22D9\u0338','ngsim':'\u2275','ngt':'\u226F','nGt':'\u226B\u20D2','ngtr':'\u226F','nGtv':'\u226B\u0338','nharr':'\u21AE','nhArr':'\u21CE','nhpar':'\u2AF2','ni':'\u220B','nis':'\u22FC','nisd':'\u22FA','niv':'\u220B','njcy':'\u045A','NJcy':'\u040A','nlarr':'\u219A','nlArr':'\u21CD','nldr':'\u2025','nle':'\u2270','nlE':'\u2266\u0338','nleftarrow':'\u219A','nLeftarrow':'\u21CD','nleftrightarrow':'\u21AE','nLeftrightarrow':'\u21CE','nleq':'\u2270','nleqq':'\u2266\u0338','nleqslant':'\u2A7D\u0338','nles':'\u2A7D\u0338','nless':'\u226E','nLl':'\u22D8\u0338','nlsim':'\u2274','nlt':'\u226E','nLt':'\u226A\u20D2','nltri':'\u22EA','nltrie':'\u22EC','nLtv':'\u226A\u0338','nmid':'\u2224','NoBreak':'\u2060','NonBreakingSpace':'\xA0','nopf':'\uD835\uDD5F','Nopf':'\u2115','not':'\xAC','Not':'\u2AEC','NotCongruent':'\u2262','NotCupCap':'\u226D','NotDoubleVerticalBar':'\u2226','NotElement':'\u2209','NotEqual':'\u2260','NotEqualTilde':'\u2242\u0338','NotExists':'\u2204','NotGreater':'\u226F','NotGreaterEqual':'\u2271','NotGreaterFullEqual':'\u2267\u0338','NotGreaterGreater':'\u226B\u0338','NotGreaterLess':'\u2279','NotGreaterSlantEqual':'\u2A7E\u0338','NotGreaterTilde':'\u2275','NotHumpDownHump':'\u224E\u0338','NotHumpEqual':'\u224F\u0338','notin':'\u2209','notindot':'\u22F5\u0338','notinE':'\u22F9\u0338','notinva':'\u2209','notinvb':'\u22F7','notinvc':'\u22F6','NotLeftTriangle':'\u22EA','NotLeftTriangleBar':'\u29CF\u0338','NotLeftTriangleEqual':'\u22EC','NotLess':'\u226E','NotLessEqual':'\u2270','NotLessGreater':'\u2278','NotLessLess':'\u226A\u0338','NotLessSlantEqual':'\u2A7D\u0338','NotLessTilde':'\u2274','NotNestedGreaterGreater':'\u2AA2\u0338','NotNestedLessLess':'\u2AA1\u0338','notni':'\u220C','notniva':'\u220C','notnivb':'\u22FE','notnivc':'\u22FD','NotPrecedes':'\u2280','NotPrecedesEqual':'\u2AAF\u0338','NotPrecedesSlantEqual':'\u22E0','NotReverseElement':'\u220C','NotRightTriangle':'\u22EB','NotRightTriangleBar':'\u29D0\u0338','NotRightTriangleEqual':'\u22ED','NotSquareSubset':'\u228F\u0338','NotSquareSubsetEqual':'\u22E2','NotSquareSuperset':'\u2290\u0338','NotSquareSupersetEqual':'\u22E3','NotSubset':'\u2282\u20D2','NotSubsetEqual':'\u2288','NotSucceeds':'\u2281','NotSucceedsEqual':'\u2AB0\u0338','NotSucceedsSlantEqual':'\u22E1','NotSucceedsTilde':'\u227F\u0338','NotSuperset':'\u2283\u20D2','NotSupersetEqual':'\u2289','NotTilde':'\u2241','NotTildeEqual':'\u2244','NotTildeFullEqual':'\u2247','NotTildeTilde':'\u2249','NotVerticalBar':'\u2224','npar':'\u2226','nparallel':'\u2226','nparsl':'\u2AFD\u20E5','npart':'\u2202\u0338','npolint':'\u2A14','npr':'\u2280','nprcue':'\u22E0','npre':'\u2AAF\u0338','nprec':'\u2280','npreceq':'\u2AAF\u0338','nrarr':'\u219B','nrArr':'\u21CF','nrarrc':'\u2933\u0338','nrarrw':'\u219D\u0338','nrightarrow':'\u219B','nRightarrow':'\u21CF','nrtri':'\u22EB','nrtrie':'\u22ED','nsc':'\u2281','nsccue':'\u22E1','nsce':'\u2AB0\u0338','nscr':'\uD835\uDCC3','Nscr':'\uD835\uDCA9','nshortmid':'\u2224','nshortparallel':'\u2226','nsim':'\u2241','nsime':'\u2244','nsimeq':'\u2244','nsmid':'\u2224','nspar':'\u2226','nsqsube':'\u22E2','nsqsupe':'\u22E3','nsub':'\u2284','nsube':'\u2288','nsubE':'\u2AC5\u0338','nsubset':'\u2282\u20D2','nsubseteq':'\u2288','nsubseteqq':'\u2AC5\u0338','nsucc':'\u2281','nsucceq':'\u2AB0\u0338','nsup':'\u2285','nsupe':'\u2289','nsupE':'\u2AC6\u0338','nsupset':'\u2283\u20D2','nsupseteq':'\u2289','nsupseteqq':'\u2AC6\u0338','ntgl':'\u2279','ntilde':'\xF1','Ntilde':'\xD1','ntlg':'\u2278','ntriangleleft':'\u22EA','ntrianglelefteq':'\u22EC','ntriangleright':'\u22EB','ntrianglerighteq':'\u22ED','nu':'\u03BD','Nu':'\u039D','num':'#','numero':'\u2116','numsp':'\u2007','nvap':'\u224D\u20D2','nvdash':'\u22AC','nvDash':'\u22AD','nVdash':'\u22AE','nVDash':'\u22AF','nvge':'\u2265\u20D2','nvgt':'>\u20D2','nvHarr':'\u2904','nvinfin':'\u29DE','nvlArr':'\u2902','nvle':'\u2264\u20D2','nvlt':'<\u20D2','nvltrie':'\u22B4\u20D2','nvrArr':'\u2903','nvrtrie':'\u22B5\u20D2','nvsim':'\u223C\u20D2','nwarhk':'\u2923','nwarr':'\u2196','nwArr':'\u21D6','nwarrow':'\u2196','nwnear':'\u2927','oacute':'\xF3','Oacute':'\xD3','oast':'\u229B','ocir':'\u229A','ocirc':'\xF4','Ocirc':'\xD4','ocy':'\u043E','Ocy':'\u041E','odash':'\u229D','odblac':'\u0151','Odblac':'\u0150','odiv':'\u2A38','odot':'\u2299','odsold':'\u29BC','oelig':'\u0153','OElig':'\u0152','ofcir':'\u29BF','ofr':'\uD835\uDD2C','Ofr':'\uD835\uDD12','ogon':'\u02DB','ograve':'\xF2','Ograve':'\xD2','ogt':'\u29C1','ohbar':'\u29B5','ohm':'\u03A9','oint':'\u222E','olarr':'\u21BA','olcir':'\u29BE','olcross':'\u29BB','oline':'\u203E','olt':'\u29C0','omacr':'\u014D','Omacr':'\u014C','omega':'\u03C9','Omega':'\u03A9','omicron':'\u03BF','Omicron':'\u039F','omid':'\u29B6','ominus':'\u2296','oopf':'\uD835\uDD60','Oopf':'\uD835\uDD46','opar':'\u29B7','OpenCurlyDoubleQuote':'\u201C','OpenCurlyQuote':'\u2018','operp':'\u29B9','oplus':'\u2295','or':'\u2228','Or':'\u2A54','orarr':'\u21BB','ord':'\u2A5D','order':'\u2134','orderof':'\u2134','ordf':'\xAA','ordm':'\xBA','origof':'\u22B6','oror':'\u2A56','orslope':'\u2A57','orv':'\u2A5B','oS':'\u24C8','oscr':'\u2134','Oscr':'\uD835\uDCAA','oslash':'\xF8','Oslash':'\xD8','osol':'\u2298','otilde':'\xF5','Otilde':'\xD5','otimes':'\u2297','Otimes':'\u2A37','otimesas':'\u2A36','ouml':'\xF6','Ouml':'\xD6','ovbar':'\u233D','OverBar':'\u203E','OverBrace':'\u23DE','OverBracket':'\u23B4','OverParenthesis':'\u23DC','par':'\u2225','para':'\xB6','parallel':'\u2225','parsim':'\u2AF3','parsl':'\u2AFD','part':'\u2202','PartialD':'\u2202','pcy':'\u043F','Pcy':'\u041F','percnt':'%','period':'.','permil':'\u2030','perp':'\u22A5','pertenk':'\u2031','pfr':'\uD835\uDD2D','Pfr':'\uD835\uDD13','phi':'\u03C6','Phi':'\u03A6','phiv':'\u03D5','phmmat':'\u2133','phone':'\u260E','pi':'\u03C0','Pi':'\u03A0','pitchfork':'\u22D4','piv':'\u03D6','planck':'\u210F','planckh':'\u210E','plankv':'\u210F','plus':'+','plusacir':'\u2A23','plusb':'\u229E','pluscir':'\u2A22','plusdo':'\u2214','plusdu':'\u2A25','pluse':'\u2A72','PlusMinus':'\xB1','plusmn':'\xB1','plussim':'\u2A26','plustwo':'\u2A27','pm':'\xB1','Poincareplane':'\u210C','pointint':'\u2A15','popf':'\uD835\uDD61','Popf':'\u2119','pound':'\xA3','pr':'\u227A','Pr':'\u2ABB','prap':'\u2AB7','prcue':'\u227C','pre':'\u2AAF','prE':'\u2AB3','prec':'\u227A','precapprox':'\u2AB7','preccurlyeq':'\u227C','Precedes':'\u227A','PrecedesEqual':'\u2AAF','PrecedesSlantEqual':'\u227C','PrecedesTilde':'\u227E','preceq':'\u2AAF','precnapprox':'\u2AB9','precneqq':'\u2AB5','precnsim':'\u22E8','precsim':'\u227E','prime':'\u2032','Prime':'\u2033','primes':'\u2119','prnap':'\u2AB9','prnE':'\u2AB5','prnsim':'\u22E8','prod':'\u220F','Product':'\u220F','profalar':'\u232E','profline':'\u2312','profsurf':'\u2313','prop':'\u221D','Proportion':'\u2237','Proportional':'\u221D','propto':'\u221D','prsim':'\u227E','prurel':'\u22B0','pscr':'\uD835\uDCC5','Pscr':'\uD835\uDCAB','psi':'\u03C8','Psi':'\u03A8','puncsp':'\u2008','qfr':'\uD835\uDD2E','Qfr':'\uD835\uDD14','qint':'\u2A0C','qopf':'\uD835\uDD62','Qopf':'\u211A','qprime':'\u2057','qscr':'\uD835\uDCC6','Qscr':'\uD835\uDCAC','quaternions':'\u210D','quatint':'\u2A16','quest':'?','questeq':'\u225F','quot':'"','QUOT':'"','rAarr':'\u21DB','race':'\u223D\u0331','racute':'\u0155','Racute':'\u0154','radic':'\u221A','raemptyv':'\u29B3','rang':'\u27E9','Rang':'\u27EB','rangd':'\u2992','range':'\u29A5','rangle':'\u27E9','raquo':'\xBB','rarr':'\u2192','rArr':'\u21D2','Rarr':'\u21A0','rarrap':'\u2975','rarrb':'\u21E5','rarrbfs':'\u2920','rarrc':'\u2933','rarrfs':'\u291E','rarrhk':'\u21AA','rarrlp':'\u21AC','rarrpl':'\u2945','rarrsim':'\u2974','rarrtl':'\u21A3','Rarrtl':'\u2916','rarrw':'\u219D','ratail':'\u291A','rAtail':'\u291C','ratio':'\u2236','rationals':'\u211A','rbarr':'\u290D','rBarr':'\u290F','RBarr':'\u2910','rbbrk':'\u2773','rbrace':'}','rbrack':']','rbrke':'\u298C','rbrksld':'\u298E','rbrkslu':'\u2990','rcaron':'\u0159','Rcaron':'\u0158','rcedil':'\u0157','Rcedil':'\u0156','rceil':'\u2309','rcub':'}','rcy':'\u0440','Rcy':'\u0420','rdca':'\u2937','rdldhar':'\u2969','rdquo':'\u201D','rdquor':'\u201D','rdsh':'\u21B3','Re':'\u211C','real':'\u211C','realine':'\u211B','realpart':'\u211C','reals':'\u211D','rect':'\u25AD','reg':'\xAE','REG':'\xAE','ReverseElement':'\u220B','ReverseEquilibrium':'\u21CB','ReverseUpEquilibrium':'\u296F','rfisht':'\u297D','rfloor':'\u230B','rfr':'\uD835\uDD2F','Rfr':'\u211C','rHar':'\u2964','rhard':'\u21C1','rharu':'\u21C0','rharul':'\u296C','rho':'\u03C1','Rho':'\u03A1','rhov':'\u03F1','RightAngleBracket':'\u27E9','rightarrow':'\u2192','Rightarrow':'\u21D2','RightArrow':'\u2192','RightArrowBar':'\u21E5','RightArrowLeftArrow':'\u21C4','rightarrowtail':'\u21A3','RightCeiling':'\u2309','RightDoubleBracket':'\u27E7','RightDownTeeVector':'\u295D','RightDownVector':'\u21C2','RightDownVectorBar':'\u2955','RightFloor':'\u230B','rightharpoondown':'\u21C1','rightharpoonup':'\u21C0','rightleftarrows':'\u21C4','rightleftharpoons':'\u21CC','rightrightarrows':'\u21C9','rightsquigarrow':'\u219D','RightTee':'\u22A2','RightTeeArrow':'\u21A6','RightTeeVector':'\u295B','rightthreetimes':'\u22CC','RightTriangle':'\u22B3','RightTriangleBar':'\u29D0','RightTriangleEqual':'\u22B5','RightUpDownVector':'\u294F','RightUpTeeVector':'\u295C','RightUpVector':'\u21BE','RightUpVectorBar':'\u2954','RightVector':'\u21C0','RightVectorBar':'\u2953','ring':'\u02DA','risingdotseq':'\u2253','rlarr':'\u21C4','rlhar':'\u21CC','rlm':'\u200F','rmoust':'\u23B1','rmoustache':'\u23B1','rnmid':'\u2AEE','roang':'\u27ED','roarr':'\u21FE','robrk':'\u27E7','ropar':'\u2986','ropf':'\uD835\uDD63','Ropf':'\u211D','roplus':'\u2A2E','rotimes':'\u2A35','RoundImplies':'\u2970','rpar':')','rpargt':'\u2994','rppolint':'\u2A12','rrarr':'\u21C9','Rrightarrow':'\u21DB','rsaquo':'\u203A','rscr':'\uD835\uDCC7','Rscr':'\u211B','rsh':'\u21B1','Rsh':'\u21B1','rsqb':']','rsquo':'\u2019','rsquor':'\u2019','rthree':'\u22CC','rtimes':'\u22CA','rtri':'\u25B9','rtrie':'\u22B5','rtrif':'\u25B8','rtriltri':'\u29CE','RuleDelayed':'\u29F4','ruluhar':'\u2968','rx':'\u211E','sacute':'\u015B','Sacute':'\u015A','sbquo':'\u201A','sc':'\u227B','Sc':'\u2ABC','scap':'\u2AB8','scaron':'\u0161','Scaron':'\u0160','sccue':'\u227D','sce':'\u2AB0','scE':'\u2AB4','scedil':'\u015F','Scedil':'\u015E','scirc':'\u015D','Scirc':'\u015C','scnap':'\u2ABA','scnE':'\u2AB6','scnsim':'\u22E9','scpolint':'\u2A13','scsim':'\u227F','scy':'\u0441','Scy':'\u0421','sdot':'\u22C5','sdotb':'\u22A1','sdote':'\u2A66','searhk':'\u2925','searr':'\u2198','seArr':'\u21D8','searrow':'\u2198','sect':'\xA7','semi':';','seswar':'\u2929','setminus':'\u2216','setmn':'\u2216','sext':'\u2736','sfr':'\uD835\uDD30','Sfr':'\uD835\uDD16','sfrown':'\u2322','sharp':'\u266F','shchcy':'\u0449','SHCHcy':'\u0429','shcy':'\u0448','SHcy':'\u0428','ShortDownArrow':'\u2193','ShortLeftArrow':'\u2190','shortmid':'\u2223','shortparallel':'\u2225','ShortRightArrow':'\u2192','ShortUpArrow':'\u2191','shy':'\xAD','sigma':'\u03C3','Sigma':'\u03A3','sigmaf':'\u03C2','sigmav':'\u03C2','sim':'\u223C','simdot':'\u2A6A','sime':'\u2243','simeq':'\u2243','simg':'\u2A9E','simgE':'\u2AA0','siml':'\u2A9D','simlE':'\u2A9F','simne':'\u2246','simplus':'\u2A24','simrarr':'\u2972','slarr':'\u2190','SmallCircle':'\u2218','smallsetminus':'\u2216','smashp':'\u2A33','smeparsl':'\u29E4','smid':'\u2223','smile':'\u2323','smt':'\u2AAA','smte':'\u2AAC','smtes':'\u2AAC\uFE00','softcy':'\u044C','SOFTcy':'\u042C','sol':'/','solb':'\u29C4','solbar':'\u233F','sopf':'\uD835\uDD64','Sopf':'\uD835\uDD4A','spades':'\u2660','spadesuit':'\u2660','spar':'\u2225','sqcap':'\u2293','sqcaps':'\u2293\uFE00','sqcup':'\u2294','sqcups':'\u2294\uFE00','Sqrt':'\u221A','sqsub':'\u228F','sqsube':'\u2291','sqsubset':'\u228F','sqsubseteq':'\u2291','sqsup':'\u2290','sqsupe':'\u2292','sqsupset':'\u2290','sqsupseteq':'\u2292','squ':'\u25A1','square':'\u25A1','Square':'\u25A1','SquareIntersection':'\u2293','SquareSubset':'\u228F','SquareSubsetEqual':'\u2291','SquareSuperset':'\u2290','SquareSupersetEqual':'\u2292','SquareUnion':'\u2294','squarf':'\u25AA','squf':'\u25AA','srarr':'\u2192','sscr':'\uD835\uDCC8','Sscr':'\uD835\uDCAE','ssetmn':'\u2216','ssmile':'\u2323','sstarf':'\u22C6','star':'\u2606','Star':'\u22C6','starf':'\u2605','straightepsilon':'\u03F5','straightphi':'\u03D5','strns':'\xAF','sub':'\u2282','Sub':'\u22D0','subdot':'\u2ABD','sube':'\u2286','subE':'\u2AC5','subedot':'\u2AC3','submult':'\u2AC1','subne':'\u228A','subnE':'\u2ACB','subplus':'\u2ABF','subrarr':'\u2979','subset':'\u2282','Subset':'\u22D0','subseteq':'\u2286','subseteqq':'\u2AC5','SubsetEqual':'\u2286','subsetneq':'\u228A','subsetneqq':'\u2ACB','subsim':'\u2AC7','subsub':'\u2AD5','subsup':'\u2AD3','succ':'\u227B','succapprox':'\u2AB8','succcurlyeq':'\u227D','Succeeds':'\u227B','SucceedsEqual':'\u2AB0','SucceedsSlantEqual':'\u227D','SucceedsTilde':'\u227F','succeq':'\u2AB0','succnapprox':'\u2ABA','succneqq':'\u2AB6','succnsim':'\u22E9','succsim':'\u227F','SuchThat':'\u220B','sum':'\u2211','Sum':'\u2211','sung':'\u266A','sup':'\u2283','Sup':'\u22D1','sup1':'\xB9','sup2':'\xB2','sup3':'\xB3','supdot':'\u2ABE','supdsub':'\u2AD8','supe':'\u2287','supE':'\u2AC6','supedot':'\u2AC4','Superset':'\u2283','SupersetEqual':'\u2287','suphsol':'\u27C9','suphsub':'\u2AD7','suplarr':'\u297B','supmult':'\u2AC2','supne':'\u228B','supnE':'\u2ACC','supplus':'\u2AC0','supset':'\u2283','Supset':'\u22D1','supseteq':'\u2287','supseteqq':'\u2AC6','supsetneq':'\u228B','supsetneqq':'\u2ACC','supsim':'\u2AC8','supsub':'\u2AD4','supsup':'\u2AD6','swarhk':'\u2926','swarr':'\u2199','swArr':'\u21D9','swarrow':'\u2199','swnwar':'\u292A','szlig':'\xDF','Tab':'\t','target':'\u2316','tau':'\u03C4','Tau':'\u03A4','tbrk':'\u23B4','tcaron':'\u0165','Tcaron':'\u0164','tcedil':'\u0163','Tcedil':'\u0162','tcy':'\u0442','Tcy':'\u0422','tdot':'\u20DB','telrec':'\u2315','tfr':'\uD835\uDD31','Tfr':'\uD835\uDD17','there4':'\u2234','therefore':'\u2234','Therefore':'\u2234','theta':'\u03B8','Theta':'\u0398','thetasym':'\u03D1','thetav':'\u03D1','thickapprox':'\u2248','thicksim':'\u223C','ThickSpace':'\u205F\u200A','thinsp':'\u2009','ThinSpace':'\u2009','thkap':'\u2248','thksim':'\u223C','thorn':'\xFE','THORN':'\xDE','tilde':'\u02DC','Tilde':'\u223C','TildeEqual':'\u2243','TildeFullEqual':'\u2245','TildeTilde':'\u2248','times':'\xD7','timesb':'\u22A0','timesbar':'\u2A31','timesd':'\u2A30','tint':'\u222D','toea':'\u2928','top':'\u22A4','topbot':'\u2336','topcir':'\u2AF1','topf':'\uD835\uDD65','Topf':'\uD835\uDD4B','topfork':'\u2ADA','tosa':'\u2929','tprime':'\u2034','trade':'\u2122','TRADE':'\u2122','triangle':'\u25B5','triangledown':'\u25BF','triangleleft':'\u25C3','trianglelefteq':'\u22B4','triangleq':'\u225C','triangleright':'\u25B9','trianglerighteq':'\u22B5','tridot':'\u25EC','trie':'\u225C','triminus':'\u2A3A','TripleDot':'\u20DB','triplus':'\u2A39','trisb':'\u29CD','tritime':'\u2A3B','trpezium':'\u23E2','tscr':'\uD835\uDCC9','Tscr':'\uD835\uDCAF','tscy':'\u0446','TScy':'\u0426','tshcy':'\u045B','TSHcy':'\u040B','tstrok':'\u0167','Tstrok':'\u0166','twixt':'\u226C','twoheadleftarrow':'\u219E','twoheadrightarrow':'\u21A0','uacute':'\xFA','Uacute':'\xDA','uarr':'\u2191','uArr':'\u21D1','Uarr':'\u219F','Uarrocir':'\u2949','ubrcy':'\u045E','Ubrcy':'\u040E','ubreve':'\u016D','Ubreve':'\u016C','ucirc':'\xFB','Ucirc':'\xDB','ucy':'\u0443','Ucy':'\u0423','udarr':'\u21C5','udblac':'\u0171','Udblac':'\u0170','udhar':'\u296E','ufisht':'\u297E','ufr':'\uD835\uDD32','Ufr':'\uD835\uDD18','ugrave':'\xF9','Ugrave':'\xD9','uHar':'\u2963','uharl':'\u21BF','uharr':'\u21BE','uhblk':'\u2580','ulcorn':'\u231C','ulcorner':'\u231C','ulcrop':'\u230F','ultri':'\u25F8','umacr':'\u016B','Umacr':'\u016A','uml':'\xA8','UnderBar':'_','UnderBrace':'\u23DF','UnderBracket':'\u23B5','UnderParenthesis':'\u23DD','Union':'\u22C3','UnionPlus':'\u228E','uogon':'\u0173','Uogon':'\u0172','uopf':'\uD835\uDD66','Uopf':'\uD835\uDD4C','uparrow':'\u2191','Uparrow':'\u21D1','UpArrow':'\u2191','UpArrowBar':'\u2912','UpArrowDownArrow':'\u21C5','updownarrow':'\u2195','Updownarrow':'\u21D5','UpDownArrow':'\u2195','UpEquilibrium':'\u296E','upharpoonleft':'\u21BF','upharpoonright':'\u21BE','uplus':'\u228E','UpperLeftArrow':'\u2196','UpperRightArrow':'\u2197','upsi':'\u03C5','Upsi':'\u03D2','upsih':'\u03D2','upsilon':'\u03C5','Upsilon':'\u03A5','UpTee':'\u22A5','UpTeeArrow':'\u21A5','upuparrows':'\u21C8','urcorn':'\u231D','urcorner':'\u231D','urcrop':'\u230E','uring':'\u016F','Uring':'\u016E','urtri':'\u25F9','uscr':'\uD835\uDCCA','Uscr':'\uD835\uDCB0','utdot':'\u22F0','utilde':'\u0169','Utilde':'\u0168','utri':'\u25B5','utrif':'\u25B4','uuarr':'\u21C8','uuml':'\xFC','Uuml':'\xDC','uwangle':'\u29A7','vangrt':'\u299C','varepsilon':'\u03F5','varkappa':'\u03F0','varnothing':'\u2205','varphi':'\u03D5','varpi':'\u03D6','varpropto':'\u221D','varr':'\u2195','vArr':'\u21D5','varrho':'\u03F1','varsigma':'\u03C2','varsubsetneq':'\u228A\uFE00','varsubsetneqq':'\u2ACB\uFE00','varsupsetneq':'\u228B\uFE00','varsupsetneqq':'\u2ACC\uFE00','vartheta':'\u03D1','vartriangleleft':'\u22B2','vartriangleright':'\u22B3','vBar':'\u2AE8','Vbar':'\u2AEB','vBarv':'\u2AE9','vcy':'\u0432','Vcy':'\u0412','vdash':'\u22A2','vDash':'\u22A8','Vdash':'\u22A9','VDash':'\u22AB','Vdashl':'\u2AE6','vee':'\u2228','Vee':'\u22C1','veebar':'\u22BB','veeeq':'\u225A','vellip':'\u22EE','verbar':'|','Verbar':'\u2016','vert':'|','Vert':'\u2016','VerticalBar':'\u2223','VerticalLine':'|','VerticalSeparator':'\u2758','VerticalTilde':'\u2240','VeryThinSpace':'\u200A','vfr':'\uD835\uDD33','Vfr':'\uD835\uDD19','vltri':'\u22B2','vnsub':'\u2282\u20D2','vnsup':'\u2283\u20D2','vopf':'\uD835\uDD67','Vopf':'\uD835\uDD4D','vprop':'\u221D','vrtri':'\u22B3','vscr':'\uD835\uDCCB','Vscr':'\uD835\uDCB1','vsubne':'\u228A\uFE00','vsubnE':'\u2ACB\uFE00','vsupne':'\u228B\uFE00','vsupnE':'\u2ACC\uFE00','Vvdash':'\u22AA','vzigzag':'\u299A','wcirc':'\u0175','Wcirc':'\u0174','wedbar':'\u2A5F','wedge':'\u2227','Wedge':'\u22C0','wedgeq':'\u2259','weierp':'\u2118','wfr':'\uD835\uDD34','Wfr':'\uD835\uDD1A','wopf':'\uD835\uDD68','Wopf':'\uD835\uDD4E','wp':'\u2118','wr':'\u2240','wreath':'\u2240','wscr':'\uD835\uDCCC','Wscr':'\uD835\uDCB2','xcap':'\u22C2','xcirc':'\u25EF','xcup':'\u22C3','xdtri':'\u25BD','xfr':'\uD835\uDD35','Xfr':'\uD835\uDD1B','xharr':'\u27F7','xhArr':'\u27FA','xi':'\u03BE','Xi':'\u039E','xlarr':'\u27F5','xlArr':'\u27F8','xmap':'\u27FC','xnis':'\u22FB','xodot':'\u2A00','xopf':'\uD835\uDD69','Xopf':'\uD835\uDD4F','xoplus':'\u2A01','xotime':'\u2A02','xrarr':'\u27F6','xrArr':'\u27F9','xscr':'\uD835\uDCCD','Xscr':'\uD835\uDCB3','xsqcup':'\u2A06','xuplus':'\u2A04','xutri':'\u25B3','xvee':'\u22C1','xwedge':'\u22C0','yacute':'\xFD','Yacute':'\xDD','yacy':'\u044F','YAcy':'\u042F','ycirc':'\u0177','Ycirc':'\u0176','ycy':'\u044B','Ycy':'\u042B','yen':'\xA5','yfr':'\uD835\uDD36','Yfr':'\uD835\uDD1C','yicy':'\u0457','YIcy':'\u0407','yopf':'\uD835\uDD6A','Yopf':'\uD835\uDD50','yscr':'\uD835\uDCCE','Yscr':'\uD835\uDCB4','yucy':'\u044E','YUcy':'\u042E','yuml':'\xFF','Yuml':'\u0178','zacute':'\u017A','Zacute':'\u0179','zcaron':'\u017E','Zcaron':'\u017D','zcy':'\u0437','Zcy':'\u0417','zdot':'\u017C','Zdot':'\u017B','zeetrf':'\u2128','ZeroWidthSpace':'\u200B','zeta':'\u03B6','Zeta':'\u0396','zfr':'\uD835\uDD37','Zfr':'\u2128','zhcy':'\u0436','ZHcy':'\u0416','zigrarr':'\u21DD','zopf':'\uD835\uDD6B','Zopf':'\u2124','zscr':'\uD835\uDCCF','Zscr':'\uD835\uDCB5','zwj':'\u200D','zwnj':'\u200C'};
  6061. var decodeMapLegacy = {'aacute':'\xE1','Aacute':'\xC1','acirc':'\xE2','Acirc':'\xC2','acute':'\xB4','aelig':'\xE6','AElig':'\xC6','agrave':'\xE0','Agrave':'\xC0','amp':'&','AMP':'&','aring':'\xE5','Aring':'\xC5','atilde':'\xE3','Atilde':'\xC3','auml':'\xE4','Auml':'\xC4','brvbar':'\xA6','ccedil':'\xE7','Ccedil':'\xC7','cedil':'\xB8','cent':'\xA2','copy':'\xA9','COPY':'\xA9','curren':'\xA4','deg':'\xB0','divide':'\xF7','eacute':'\xE9','Eacute':'\xC9','ecirc':'\xEA','Ecirc':'\xCA','egrave':'\xE8','Egrave':'\xC8','eth':'\xF0','ETH':'\xD0','euml':'\xEB','Euml':'\xCB','frac12':'\xBD','frac14':'\xBC','frac34':'\xBE','gt':'>','GT':'>','iacute':'\xED','Iacute':'\xCD','icirc':'\xEE','Icirc':'\xCE','iexcl':'\xA1','igrave':'\xEC','Igrave':'\xCC','iquest':'\xBF','iuml':'\xEF','Iuml':'\xCF','laquo':'\xAB','lt':'<','LT':'<','macr':'\xAF','micro':'\xB5','middot':'\xB7','nbsp':'\xA0','not':'\xAC','ntilde':'\xF1','Ntilde':'\xD1','oacute':'\xF3','Oacute':'\xD3','ocirc':'\xF4','Ocirc':'\xD4','ograve':'\xF2','Ograve':'\xD2','ordf':'\xAA','ordm':'\xBA','oslash':'\xF8','Oslash':'\xD8','otilde':'\xF5','Otilde':'\xD5','ouml':'\xF6','Ouml':'\xD6','para':'\xB6','plusmn':'\xB1','pound':'\xA3','quot':'"','QUOT':'"','raquo':'\xBB','reg':'\xAE','REG':'\xAE','sect':'\xA7','shy':'\xAD','sup1':'\xB9','sup2':'\xB2','sup3':'\xB3','szlig':'\xDF','thorn':'\xFE','THORN':'\xDE','times':'\xD7','uacute':'\xFA','Uacute':'\xDA','ucirc':'\xFB','Ucirc':'\xDB','ugrave':'\xF9','Ugrave':'\xD9','uml':'\xA8','uuml':'\xFC','Uuml':'\xDC','yacute':'\xFD','Yacute':'\xDD','yen':'\xA5','yuml':'\xFF'};
  6062. var decodeMapNumeric = {'0':'\uFFFD','128':'\u20AC','130':'\u201A','131':'\u0192','132':'\u201E','133':'\u2026','134':'\u2020','135':'\u2021','136':'\u02C6','137':'\u2030','138':'\u0160','139':'\u2039','140':'\u0152','142':'\u017D','145':'\u2018','146':'\u2019','147':'\u201C','148':'\u201D','149':'\u2022','150':'\u2013','151':'\u2014','152':'\u02DC','153':'\u2122','154':'\u0161','155':'\u203A','156':'\u0153','158':'\u017E','159':'\u0178'};
  6063. var invalidReferenceCodePoints = [1,2,3,4,5,6,7,8,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,64976,64977,64978,64979,64980,64981,64982,64983,64984,64985,64986,64987,64988,64989,64990,64991,64992,64993,64994,64995,64996,64997,64998,64999,65000,65001,65002,65003,65004,65005,65006,65007,65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111];
  6064. /*--------------------------------------------------------------------------*/
  6065. var stringFromCharCode = String.fromCharCode;
  6066. var object = {};
  6067. var hasOwnProperty = object.hasOwnProperty;
  6068. var has = function(object, propertyName) {
  6069. return hasOwnProperty.call(object, propertyName);
  6070. };
  6071. var contains = function(array, value) {
  6072. var index = -1;
  6073. var length = array.length;
  6074. while (++index < length) {
  6075. if (array[index] == value) {
  6076. return true;
  6077. }
  6078. }
  6079. return false;
  6080. };
  6081. var merge = function(options, defaults) {
  6082. if (!options) {
  6083. return defaults;
  6084. }
  6085. var result = {};
  6086. var key;
  6087. for (key in defaults) {
  6088. // A `hasOwnProperty` check is not needed here, since only recognized
  6089. // option names are used anyway. Any others are ignored.
  6090. result[key] = has(options, key) ? options[key] : defaults[key];
  6091. }
  6092. return result;
  6093. };
  6094. // Modified version of `ucs2encode`; see https://mths.be/punycode.
  6095. var codePointToSymbol = function(codePoint, strict) {
  6096. var output = '';
  6097. if ((codePoint >= 0xD800 && codePoint <= 0xDFFF) || codePoint > 0x10FFFF) {
  6098. // See issue #4:
  6099. // “Otherwise, if the number is in the range 0xD800 to 0xDFFF or is
  6100. // greater than 0x10FFFF, then this is a parse error. Return a U+FFFD
  6101. // REPLACEMENT CHARACTER.”
  6102. if (strict) {
  6103. parseError('character reference outside the permissible Unicode range');
  6104. }
  6105. return '\uFFFD';
  6106. }
  6107. if (has(decodeMapNumeric, codePoint)) {
  6108. if (strict) {
  6109. parseError('disallowed character reference');
  6110. }
  6111. return decodeMapNumeric[codePoint];
  6112. }
  6113. if (strict && contains(invalidReferenceCodePoints, codePoint)) {
  6114. parseError('disallowed character reference');
  6115. }
  6116. if (codePoint > 0xFFFF) {
  6117. codePoint -= 0x10000;
  6118. output += stringFromCharCode(codePoint >>> 10 & 0x3FF | 0xD800);
  6119. codePoint = 0xDC00 | codePoint & 0x3FF;
  6120. }
  6121. output += stringFromCharCode(codePoint);
  6122. return output;
  6123. };
  6124. var hexEscape = function(codePoint) {
  6125. return '&#x' + codePoint.toString(16).toUpperCase() + ';';
  6126. };
  6127. var decEscape = function(codePoint) {
  6128. return '&#' + codePoint + ';';
  6129. };
  6130. var parseError = function(message) {
  6131. throw Error('Parse error: ' + message);
  6132. };
  6133. /*--------------------------------------------------------------------------*/
  6134. var encode = function(string, options) {
  6135. options = merge(options, encode.options);
  6136. var strict = options.strict;
  6137. if (strict && regexInvalidRawCodePoint.test(string)) {
  6138. parseError('forbidden code point');
  6139. }
  6140. var encodeEverything = options.encodeEverything;
  6141. var useNamedReferences = options.useNamedReferences;
  6142. var allowUnsafeSymbols = options.allowUnsafeSymbols;
  6143. var escapeCodePoint = options.decimal ? decEscape : hexEscape;
  6144. var escapeBmpSymbol = function(symbol) {
  6145. return escapeCodePoint(symbol.charCodeAt(0));
  6146. };
  6147. if (encodeEverything) {
  6148. // Encode ASCII symbols.
  6149. string = string.replace(regexAsciiWhitelist, function(symbol) {
  6150. // Use named references if requested & possible.
  6151. if (useNamedReferences && has(encodeMap, symbol)) {
  6152. return '&' + encodeMap[symbol] + ';';
  6153. }
  6154. return escapeBmpSymbol(symbol);
  6155. });
  6156. // Shorten a few escapes that represent two symbols, of which at least one
  6157. // is within the ASCII range.
  6158. if (useNamedReferences) {
  6159. string = string
  6160. .replace(/&gt;\u20D2/g, '&nvgt;')
  6161. .replace(/&lt;\u20D2/g, '&nvlt;')
  6162. .replace(/&#x66;&#x6A;/g, '&fjlig;');
  6163. }
  6164. // Encode non-ASCII symbols.
  6165. if (useNamedReferences) {
  6166. // Encode non-ASCII symbols that can be replaced with a named reference.
  6167. string = string.replace(regexEncodeNonAscii, function(string) {
  6168. // Note: there is no need to check `has(encodeMap, string)` here.
  6169. return '&' + encodeMap[string] + ';';
  6170. });
  6171. }
  6172. // Note: any remaining non-ASCII symbols are handled outside of the `if`.
  6173. } else if (useNamedReferences) {
  6174. // Apply named character references.
  6175. // Encode `<>"'&` using named character references.
  6176. if (!allowUnsafeSymbols) {
  6177. string = string.replace(regexEscape, function(string) {
  6178. return '&' + encodeMap[string] + ';'; // no need to check `has()` here
  6179. });
  6180. }
  6181. // Shorten escapes that represent two symbols, of which at least one is
  6182. // `<>"'&`.
  6183. string = string
  6184. .replace(/&gt;\u20D2/g, '&nvgt;')
  6185. .replace(/&lt;\u20D2/g, '&nvlt;');
  6186. // Encode non-ASCII symbols that can be replaced with a named reference.
  6187. string = string.replace(regexEncodeNonAscii, function(string) {
  6188. // Note: there is no need to check `has(encodeMap, string)` here.
  6189. return '&' + encodeMap[string] + ';';
  6190. });
  6191. } else if (!allowUnsafeSymbols) {
  6192. // Encode `<>"'&` using hexadecimal escapes, now that they’re not handled
  6193. // using named character references.
  6194. string = string.replace(regexEscape, escapeBmpSymbol);
  6195. }
  6196. return string
  6197. // Encode astral symbols.
  6198. .replace(regexAstralSymbols, function($0) {
  6199. // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  6200. var high = $0.charCodeAt(0);
  6201. var low = $0.charCodeAt(1);
  6202. var codePoint = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000;
  6203. return escapeCodePoint(codePoint);
  6204. })
  6205. // Encode any remaining BMP symbols that are not printable ASCII symbols
  6206. // using a hexadecimal escape.
  6207. .replace(regexBmpWhitelist, escapeBmpSymbol);
  6208. };
  6209. // Expose default options (so they can be overridden globally).
  6210. encode.options = {
  6211. 'allowUnsafeSymbols': false,
  6212. 'encodeEverything': false,
  6213. 'strict': false,
  6214. 'useNamedReferences': false,
  6215. 'decimal' : false
  6216. };
  6217. var decode = function(html, options) {
  6218. options = merge(options, decode.options);
  6219. var strict = options.strict;
  6220. if (strict && regexInvalidEntity.test(html)) {
  6221. parseError('malformed character reference');
  6222. }
  6223. return html.replace(regexDecode, function($0, $1, $2, $3, $4, $5, $6, $7, $8) {
  6224. var codePoint;
  6225. var semicolon;
  6226. var decDigits;
  6227. var hexDigits;
  6228. var reference;
  6229. var next;
  6230. if ($1) {
  6231. reference = $1;
  6232. // Note: there is no need to check `has(decodeMap, reference)`.
  6233. return decodeMap[reference];
  6234. }
  6235. if ($2) {
  6236. // Decode named character references without trailing `;`, e.g. `&amp`.
  6237. // This is only a parse error if it gets converted to `&`, or if it is
  6238. // followed by `=` in an attribute context.
  6239. reference = $2;
  6240. next = $3;
  6241. if (next && options.isAttributeValue) {
  6242. if (strict && next == '=') {
  6243. parseError('`&` did not start a character reference');
  6244. }
  6245. return $0;
  6246. } else {
  6247. if (strict) {
  6248. parseError(
  6249. 'named character reference was not terminated by a semicolon'
  6250. );
  6251. }
  6252. // Note: there is no need to check `has(decodeMapLegacy, reference)`.
  6253. return decodeMapLegacy[reference] + (next || '');
  6254. }
  6255. }
  6256. if ($4) {
  6257. // Decode decimal escapes, e.g. `&#119558;`.
  6258. decDigits = $4;
  6259. semicolon = $5;
  6260. if (strict && !semicolon) {
  6261. parseError('character reference was not terminated by a semicolon');
  6262. }
  6263. codePoint = parseInt(decDigits, 10);
  6264. return codePointToSymbol(codePoint, strict);
  6265. }
  6266. if ($6) {
  6267. // Decode hexadecimal escapes, e.g. `&#x1D306;`.
  6268. hexDigits = $6;
  6269. semicolon = $7;
  6270. if (strict && !semicolon) {
  6271. parseError('character reference was not terminated by a semicolon');
  6272. }
  6273. codePoint = parseInt(hexDigits, 16);
  6274. return codePointToSymbol(codePoint, strict);
  6275. }
  6276. // If we’re still here, `if ($7)` is implied; it’s an ambiguous
  6277. // ampersand for sure. https://mths.be/notes/ambiguous-ampersands
  6278. if (strict) {
  6279. parseError(
  6280. 'named character reference was not terminated by a semicolon'
  6281. );
  6282. }
  6283. return $0;
  6284. });
  6285. };
  6286. // Expose default options (so they can be overridden globally).
  6287. decode.options = {
  6288. 'isAttributeValue': false,
  6289. 'strict': false
  6290. };
  6291. var escape = function(string) {
  6292. return string.replace(regexEscape, function($0) {
  6293. // Note: there is no need to check `has(escapeMap, $0)` here.
  6294. return escapeMap[$0];
  6295. });
  6296. };
  6297. /*--------------------------------------------------------------------------*/
  6298. var he = {
  6299. 'version': '1.2.0',
  6300. 'encode': encode,
  6301. 'decode': decode,
  6302. 'escape': escape,
  6303. 'unescape': decode
  6304. };
  6305. // Some AMD build optimizers, like r.js, check for specific condition patterns
  6306. // like the following:
  6307. if (freeExports && !freeExports.nodeType) {
  6308. if (freeModule) { // in Node.js, io.js, or RingoJS v0.8.0+
  6309. freeModule.exports = he;
  6310. } else { // in Narwhal or RingoJS v0.7.0-
  6311. for (var key in he) {
  6312. has(he, key) && (freeExports[key] = he[key]);
  6313. }
  6314. }
  6315. } else { // in Rhino or a web browser
  6316. root.he = he;
  6317. }
  6318. }(commonjsGlobal));
  6319. } (he$1, he$1.exports));
  6320. var he = he$1.exports;
  6321. /**
  6322. * Cross-platform code generation for component v-model
  6323. */
  6324. function genComponentModel(el, value, modifiers) {
  6325. const { number, trim } = modifiers || {};
  6326. const baseValueExpression = '$$v';
  6327. let valueExpression = baseValueExpression;
  6328. if (trim) {
  6329. valueExpression =
  6330. `(typeof ${baseValueExpression} === 'string'` +
  6331. `? ${baseValueExpression}.trim()` +
  6332. `: ${baseValueExpression})`;
  6333. }
  6334. if (number) {
  6335. valueExpression = `_n(${valueExpression})`;
  6336. }
  6337. const assignment = genAssignmentCode(value, valueExpression);
  6338. el.model = {
  6339. value: `(${value})`,
  6340. expression: JSON.stringify(value),
  6341. callback: `function (${baseValueExpression}) {${assignment}}`
  6342. };
  6343. }
  6344. /**
  6345. * Cross-platform codegen helper for generating v-model value assignment code.
  6346. */
  6347. function genAssignmentCode(value, assignment) {
  6348. const res = parseModel(value);
  6349. if (res.key === null) {
  6350. return `${value}=${assignment}`;
  6351. }
  6352. else {
  6353. return `$set(${res.exp}, ${res.key}, ${assignment})`;
  6354. }
  6355. }
  6356. /**
  6357. * Parse a v-model expression into a base path and a final key segment.
  6358. * Handles both dot-path and possible square brackets.
  6359. *
  6360. * Possible cases:
  6361. *
  6362. * - test
  6363. * - test[key]
  6364. * - test[test1[key]]
  6365. * - test["a"][key]
  6366. * - xxx.test[a[a].test1[key]]
  6367. * - test.xxx.a["asa"][test1[key]]
  6368. *
  6369. */
  6370. let len, str$1, chr, index, expressionPos, expressionEndPos;
  6371. function parseModel(val) {
  6372. // Fix https://github.com/vuejs/vue/pull/7730
  6373. // allow v-model="obj.val " (trailing whitespace)
  6374. val = val.trim();
  6375. len = val.length;
  6376. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  6377. index = val.lastIndexOf('.');
  6378. if (index > -1) {
  6379. return {
  6380. exp: val.slice(0, index),
  6381. key: '"' + val.slice(index + 1) + '"'
  6382. };
  6383. }
  6384. else {
  6385. return {
  6386. exp: val,
  6387. key: null
  6388. };
  6389. }
  6390. }
  6391. str$1 = val;
  6392. index = expressionPos = expressionEndPos = 0;
  6393. while (!eof()) {
  6394. chr = next();
  6395. /* istanbul ignore if */
  6396. if (isStringStart(chr)) {
  6397. parseString(chr);
  6398. }
  6399. else if (chr === 0x5b) {
  6400. parseBracket(chr);
  6401. }
  6402. }
  6403. return {
  6404. exp: val.slice(0, expressionPos),
  6405. key: val.slice(expressionPos + 1, expressionEndPos)
  6406. };
  6407. }
  6408. function next() {
  6409. return str$1.charCodeAt(++index);
  6410. }
  6411. function eof() {
  6412. return index >= len;
  6413. }
  6414. function isStringStart(chr) {
  6415. return chr === 0x22 || chr === 0x27;
  6416. }
  6417. function parseBracket(chr) {
  6418. let inBracket = 1;
  6419. expressionPos = index;
  6420. while (!eof()) {
  6421. chr = next();
  6422. if (isStringStart(chr)) {
  6423. parseString(chr);
  6424. continue;
  6425. }
  6426. if (chr === 0x5b)
  6427. inBracket++;
  6428. if (chr === 0x5d)
  6429. inBracket--;
  6430. if (inBracket === 0) {
  6431. expressionEndPos = index;
  6432. break;
  6433. }
  6434. }
  6435. }
  6436. function parseString(chr) {
  6437. const stringQuote = chr;
  6438. while (!eof()) {
  6439. chr = next();
  6440. if (chr === stringQuote) {
  6441. break;
  6442. }
  6443. }
  6444. }
  6445. const onRE = /^@|^v-on:/;
  6446. const dirRE = /^v-|^@|^:|^#/;
  6447. const forAliasRE$1 = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  6448. const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  6449. const stripParensRE = /^\(|\)$/g;
  6450. const dynamicArgRE = /^\[.*\]$/;
  6451. const argRE = /:(.*)$/;
  6452. const bindRE = /^:|^\.|^v-bind:/;
  6453. const modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  6454. const slotRE = /^v-slot(:|$)|^#/;
  6455. const lineBreakRE = /[\r\n]/;
  6456. const whitespaceRE = /[ \f\t\r\n]+/g;
  6457. const invalidAttributeRE = /[\s"'<>\/=]/;
  6458. const decodeHTMLCached = cached(he.decode);
  6459. const emptySlotScopeToken = `_empty_`;
  6460. // configurable state
  6461. let warn$2;
  6462. let delimiters;
  6463. let transforms;
  6464. let preTransforms;
  6465. let postTransforms;
  6466. let platformIsPreTag;
  6467. let platformMustUseProp;
  6468. let platformGetTagNamespace;
  6469. let maybeComponent;
  6470. function createASTElement(tag, attrs, parent) {
  6471. return {
  6472. type: 1,
  6473. tag,
  6474. attrsList: attrs,
  6475. attrsMap: makeAttrsMap(attrs),
  6476. rawAttrsMap: {},
  6477. parent,
  6478. children: []
  6479. };
  6480. }
  6481. /**
  6482. * Convert HTML string to AST.
  6483. */
  6484. function parse$1(template, options) {
  6485. warn$2 = options.warn || baseWarn;
  6486. platformIsPreTag = options.isPreTag || no;
  6487. platformMustUseProp = options.mustUseProp || no;
  6488. platformGetTagNamespace = options.getTagNamespace || no;
  6489. const isReservedTag = options.isReservedTag || no;
  6490. maybeComponent = (el) => !!(el.component ||
  6491. el.attrsMap[':is'] ||
  6492. el.attrsMap['v-bind:is'] ||
  6493. !(el.attrsMap.is ? isReservedTag(el.attrsMap.is) : isReservedTag(el.tag)));
  6494. transforms = pluckModuleFunction(options.modules, 'transformNode');
  6495. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  6496. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  6497. delimiters = options.delimiters;
  6498. const stack = [];
  6499. const preserveWhitespace = options.preserveWhitespace !== false;
  6500. const whitespaceOption = options.whitespace;
  6501. let root;
  6502. let currentParent;
  6503. let inVPre = false;
  6504. let inPre = false;
  6505. let warned = false;
  6506. function warnOnce(msg, range) {
  6507. if (!warned) {
  6508. warned = true;
  6509. warn$2(msg, range);
  6510. }
  6511. }
  6512. function closeElement(element) {
  6513. trimEndingWhitespace(element);
  6514. if (!inVPre && !element.processed) {
  6515. element = processElement(element, options);
  6516. }
  6517. // tree management
  6518. if (!stack.length && element !== root) {
  6519. // allow root elements with v-if, v-else-if and v-else
  6520. if (root.if && (element.elseif || element.else)) {
  6521. if (process.env.NODE_ENV !== 'production') {
  6522. checkRootConstraints(element);
  6523. }
  6524. addIfCondition(root, {
  6525. exp: element.elseif,
  6526. block: element
  6527. });
  6528. }
  6529. else if (process.env.NODE_ENV !== 'production') {
  6530. warnOnce(`Component template should contain exactly one root element. ` +
  6531. `If you are using v-if on multiple elements, ` +
  6532. `use v-else-if to chain them instead.`, { start: element.start });
  6533. }
  6534. }
  6535. if (currentParent && !element.forbidden) {
  6536. if (element.elseif || element.else) {
  6537. processIfConditions(element, currentParent);
  6538. }
  6539. else {
  6540. if (element.slotScope) {
  6541. // scoped slot
  6542. // keep it in the children list so that v-else(-if) conditions can
  6543. // find it as the prev node.
  6544. const name = element.slotTarget || '"default"';
  6545. (currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  6546. }
  6547. currentParent.children.push(element);
  6548. element.parent = currentParent;
  6549. }
  6550. }
  6551. // final children cleanup
  6552. // filter out scoped slots
  6553. element.children = element.children.filter(c => !c.slotScope);
  6554. // remove trailing whitespace node again
  6555. trimEndingWhitespace(element);
  6556. // check pre state
  6557. if (element.pre) {
  6558. inVPre = false;
  6559. }
  6560. if (platformIsPreTag(element.tag)) {
  6561. inPre = false;
  6562. }
  6563. // apply post-transforms
  6564. for (let i = 0; i < postTransforms.length; i++) {
  6565. postTransforms[i](element, options);
  6566. }
  6567. }
  6568. function trimEndingWhitespace(el) {
  6569. // remove trailing whitespace node
  6570. if (!inPre) {
  6571. let lastNode;
  6572. while ((lastNode = el.children[el.children.length - 1]) &&
  6573. lastNode.type === 3 &&
  6574. lastNode.text === ' ') {
  6575. el.children.pop();
  6576. }
  6577. }
  6578. }
  6579. function checkRootConstraints(el) {
  6580. if (el.tag === 'slot' || el.tag === 'template') {
  6581. warnOnce(`Cannot use <${el.tag}> as component root element because it may ` +
  6582. 'contain multiple nodes.', { start: el.start });
  6583. }
  6584. if (el.attrsMap.hasOwnProperty('v-for')) {
  6585. warnOnce('Cannot use v-for on stateful component root element because ' +
  6586. 'it renders multiple elements.', el.rawAttrsMap['v-for']);
  6587. }
  6588. }
  6589. parseHTML(template, {
  6590. warn: warn$2,
  6591. expectHTML: options.expectHTML,
  6592. isUnaryTag: options.isUnaryTag,
  6593. canBeLeftOpenTag: options.canBeLeftOpenTag,
  6594. shouldDecodeNewlines: options.shouldDecodeNewlines,
  6595. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  6596. shouldKeepComment: options.comments,
  6597. outputSourceRange: options.outputSourceRange,
  6598. start(tag, attrs, unary, start, end) {
  6599. // check namespace.
  6600. // inherit parent ns if there is one
  6601. const ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  6602. // handle IE svg bug
  6603. /* istanbul ignore if */
  6604. if (isIE && ns === 'svg') {
  6605. attrs = guardIESVGBug(attrs);
  6606. }
  6607. let element = createASTElement(tag, attrs, currentParent);
  6608. if (ns) {
  6609. element.ns = ns;
  6610. }
  6611. if (process.env.NODE_ENV !== 'production') {
  6612. if (options.outputSourceRange) {
  6613. element.start = start;
  6614. element.end = end;
  6615. element.rawAttrsMap = element.attrsList.reduce((cumulated, attr) => {
  6616. cumulated[attr.name] = attr;
  6617. return cumulated;
  6618. }, {});
  6619. }
  6620. attrs.forEach(attr => {
  6621. if (invalidAttributeRE.test(attr.name)) {
  6622. warn$2(`Invalid dynamic argument expression: attribute names cannot contain ` +
  6623. `spaces, quotes, <, >, / or =.`, options.outputSourceRange
  6624. ? {
  6625. start: attr.start + attr.name.indexOf(`[`),
  6626. end: attr.start + attr.name.length
  6627. }
  6628. : undefined);
  6629. }
  6630. });
  6631. }
  6632. if (isForbiddenTag(element) && !isServerRendering()) {
  6633. element.forbidden = true;
  6634. process.env.NODE_ENV !== 'production' &&
  6635. warn$2('Templates should only be responsible for mapping the state to the ' +
  6636. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  6637. `<${tag}>` +
  6638. ', as they will not be parsed.', { start: element.start });
  6639. }
  6640. // apply pre-transforms
  6641. for (let i = 0; i < preTransforms.length; i++) {
  6642. element = preTransforms[i](element, options) || element;
  6643. }
  6644. if (!inVPre) {
  6645. processPre(element);
  6646. if (element.pre) {
  6647. inVPre = true;
  6648. }
  6649. }
  6650. if (platformIsPreTag(element.tag)) {
  6651. inPre = true;
  6652. }
  6653. if (inVPre) {
  6654. processRawAttrs(element);
  6655. }
  6656. else if (!element.processed) {
  6657. // structural directives
  6658. processFor(element);
  6659. processIf(element);
  6660. processOnce(element);
  6661. }
  6662. if (!root) {
  6663. root = element;
  6664. if (process.env.NODE_ENV !== 'production') {
  6665. checkRootConstraints(root);
  6666. }
  6667. }
  6668. if (!unary) {
  6669. currentParent = element;
  6670. stack.push(element);
  6671. }
  6672. else {
  6673. closeElement(element);
  6674. }
  6675. },
  6676. end(tag, start, end) {
  6677. const element = stack[stack.length - 1];
  6678. // pop stack
  6679. stack.length -= 1;
  6680. currentParent = stack[stack.length - 1];
  6681. if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
  6682. element.end = end;
  6683. }
  6684. closeElement(element);
  6685. },
  6686. chars(text, start, end) {
  6687. if (!currentParent) {
  6688. if (process.env.NODE_ENV !== 'production') {
  6689. if (text === template) {
  6690. warnOnce('Component template requires a root element, rather than just text.', { start });
  6691. }
  6692. else if ((text = text.trim())) {
  6693. warnOnce(`text "${text}" outside root element will be ignored.`, {
  6694. start
  6695. });
  6696. }
  6697. }
  6698. return;
  6699. }
  6700. // IE textarea placeholder bug
  6701. /* istanbul ignore if */
  6702. if (isIE &&
  6703. currentParent.tag === 'textarea' &&
  6704. currentParent.attrsMap.placeholder === text) {
  6705. return;
  6706. }
  6707. const children = currentParent.children;
  6708. if (inPre || text.trim()) {
  6709. text = isTextTag(currentParent)
  6710. ? text
  6711. : decodeHTMLCached(text);
  6712. }
  6713. else if (!children.length) {
  6714. // remove the whitespace-only node right after an opening tag
  6715. text = '';
  6716. }
  6717. else if (whitespaceOption) {
  6718. if (whitespaceOption === 'condense') {
  6719. // in condense mode, remove the whitespace node if it contains
  6720. // line break, otherwise condense to a single space
  6721. text = lineBreakRE.test(text) ? '' : ' ';
  6722. }
  6723. else {
  6724. text = ' ';
  6725. }
  6726. }
  6727. else {
  6728. text = preserveWhitespace ? ' ' : '';
  6729. }
  6730. if (text) {
  6731. if (!inPre && whitespaceOption === 'condense') {
  6732. // condense consecutive whitespaces into single space
  6733. text = text.replace(whitespaceRE, ' ');
  6734. }
  6735. let res;
  6736. let child;
  6737. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  6738. child = {
  6739. type: 2,
  6740. expression: res.expression,
  6741. tokens: res.tokens,
  6742. text
  6743. };
  6744. }
  6745. else if (text !== ' ' ||
  6746. !children.length ||
  6747. children[children.length - 1].text !== ' ') {
  6748. child = {
  6749. type: 3,
  6750. text
  6751. };
  6752. }
  6753. if (child) {
  6754. if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
  6755. child.start = start;
  6756. child.end = end;
  6757. }
  6758. children.push(child);
  6759. }
  6760. }
  6761. },
  6762. comment(text, start, end) {
  6763. // adding anything as a sibling to the root node is forbidden
  6764. // comments should still be allowed, but ignored
  6765. if (currentParent) {
  6766. const child = {
  6767. type: 3,
  6768. text,
  6769. isComment: true
  6770. };
  6771. if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
  6772. child.start = start;
  6773. child.end = end;
  6774. }
  6775. currentParent.children.push(child);
  6776. }
  6777. }
  6778. });
  6779. return root;
  6780. }
  6781. function processPre(el) {
  6782. if (getAndRemoveAttr(el, 'v-pre') != null) {
  6783. el.pre = true;
  6784. }
  6785. }
  6786. function processRawAttrs(el) {
  6787. const list = el.attrsList;
  6788. const len = list.length;
  6789. if (len) {
  6790. const attrs = (el.attrs = new Array(len));
  6791. for (let i = 0; i < len; i++) {
  6792. attrs[i] = {
  6793. name: list[i].name,
  6794. value: JSON.stringify(list[i].value)
  6795. };
  6796. if (list[i].start != null) {
  6797. attrs[i].start = list[i].start;
  6798. attrs[i].end = list[i].end;
  6799. }
  6800. }
  6801. }
  6802. else if (!el.pre) {
  6803. // non root node in pre blocks with no attributes
  6804. el.plain = true;
  6805. }
  6806. }
  6807. function processElement(element, options) {
  6808. processKey(element);
  6809. // determine whether this is a plain element after
  6810. // removing structural attributes
  6811. element.plain =
  6812. !element.key && !element.scopedSlots && !element.attrsList.length;
  6813. processRef(element);
  6814. processSlotContent(element);
  6815. processSlotOutlet(element);
  6816. processComponent(element);
  6817. for (let i = 0; i < transforms.length; i++) {
  6818. element = transforms[i](element, options) || element;
  6819. }
  6820. processAttrs(element);
  6821. return element;
  6822. }
  6823. function processKey(el) {
  6824. const exp = getBindingAttr(el, 'key');
  6825. if (exp) {
  6826. if (process.env.NODE_ENV !== 'production') {
  6827. if (el.tag === 'template') {
  6828. warn$2(`<template> cannot be keyed. Place the key on real elements instead.`, getRawBindingAttr(el, 'key'));
  6829. }
  6830. if (el.for) {
  6831. const iterator = el.iterator2 || el.iterator1;
  6832. const parent = el.parent;
  6833. if (iterator &&
  6834. iterator === exp &&
  6835. parent &&
  6836. parent.tag === 'transition-group') {
  6837. warn$2(`Do not use v-for index as key on <transition-group> children, ` +
  6838. `this is the same as not using keys.`, getRawBindingAttr(el, 'key'), true /* tip */);
  6839. }
  6840. }
  6841. }
  6842. el.key = exp;
  6843. }
  6844. }
  6845. function processRef(el) {
  6846. const ref = getBindingAttr(el, 'ref');
  6847. if (ref) {
  6848. el.ref = ref;
  6849. el.refInFor = checkInFor(el);
  6850. }
  6851. }
  6852. function processFor(el) {
  6853. let exp;
  6854. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  6855. const res = parseFor(exp);
  6856. if (res) {
  6857. extend(el, res);
  6858. }
  6859. else if (process.env.NODE_ENV !== 'production') {
  6860. warn$2(`Invalid v-for expression: ${exp}`, el.rawAttrsMap['v-for']);
  6861. }
  6862. }
  6863. }
  6864. function parseFor(exp) {
  6865. const inMatch = exp.match(forAliasRE$1);
  6866. if (!inMatch)
  6867. return;
  6868. const res = {};
  6869. res.for = inMatch[2].trim();
  6870. const alias = inMatch[1].trim().replace(stripParensRE, '');
  6871. const iteratorMatch = alias.match(forIteratorRE);
  6872. if (iteratorMatch) {
  6873. res.alias = alias.replace(forIteratorRE, '').trim();
  6874. res.iterator1 = iteratorMatch[1].trim();
  6875. if (iteratorMatch[2]) {
  6876. res.iterator2 = iteratorMatch[2].trim();
  6877. }
  6878. }
  6879. else {
  6880. res.alias = alias;
  6881. }
  6882. return res;
  6883. }
  6884. function processIf(el) {
  6885. const exp = getAndRemoveAttr(el, 'v-if');
  6886. if (exp) {
  6887. el.if = exp;
  6888. addIfCondition(el, {
  6889. exp: exp,
  6890. block: el
  6891. });
  6892. }
  6893. else {
  6894. if (getAndRemoveAttr(el, 'v-else') != null) {
  6895. el.else = true;
  6896. }
  6897. const elseif = getAndRemoveAttr(el, 'v-else-if');
  6898. if (elseif) {
  6899. el.elseif = elseif;
  6900. }
  6901. }
  6902. }
  6903. function processIfConditions(el, parent) {
  6904. const prev = findPrevElement(parent.children);
  6905. if (prev && prev.if) {
  6906. addIfCondition(prev, {
  6907. exp: el.elseif,
  6908. block: el
  6909. });
  6910. }
  6911. else if (process.env.NODE_ENV !== 'production') {
  6912. warn$2(`v-${el.elseif ? 'else-if="' + el.elseif + '"' : 'else'} ` +
  6913. `used on element <${el.tag}> without corresponding v-if.`, el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']);
  6914. }
  6915. }
  6916. function findPrevElement(children) {
  6917. let i = children.length;
  6918. while (i--) {
  6919. if (children[i].type === 1) {
  6920. return children[i];
  6921. }
  6922. else {
  6923. if (process.env.NODE_ENV !== 'production' && children[i].text !== ' ') {
  6924. warn$2(`text "${children[i].text.trim()}" between v-if and v-else(-if) ` +
  6925. `will be ignored.`, children[i]);
  6926. }
  6927. children.pop();
  6928. }
  6929. }
  6930. }
  6931. function addIfCondition(el, condition) {
  6932. if (!el.ifConditions) {
  6933. el.ifConditions = [];
  6934. }
  6935. el.ifConditions.push(condition);
  6936. }
  6937. function processOnce(el) {
  6938. const once = getAndRemoveAttr(el, 'v-once');
  6939. if (once != null) {
  6940. el.once = true;
  6941. }
  6942. }
  6943. // handle content being passed to a component as slot,
  6944. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  6945. function processSlotContent(el) {
  6946. let slotScope;
  6947. if (el.tag === 'template') {
  6948. slotScope = getAndRemoveAttr(el, 'scope');
  6949. /* istanbul ignore if */
  6950. if (process.env.NODE_ENV !== 'production' && slotScope) {
  6951. warn$2(`the "scope" attribute for scoped slots have been deprecated and ` +
  6952. `replaced by "slot-scope" since 2.5. The new "slot-scope" attribute ` +
  6953. `can also be used on plain elements in addition to <template> to ` +
  6954. `denote scoped slots.`, el.rawAttrsMap['scope'], true);
  6955. }
  6956. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  6957. }
  6958. else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  6959. /* istanbul ignore if */
  6960. if (process.env.NODE_ENV !== 'production' && el.attrsMap['v-for']) {
  6961. warn$2(`Ambiguous combined usage of slot-scope and v-for on <${el.tag}> ` +
  6962. `(v-for takes higher priority). Use a wrapper <template> for the ` +
  6963. `scoped slot to make it clearer.`, el.rawAttrsMap['slot-scope'], true);
  6964. }
  6965. el.slotScope = slotScope;
  6966. }
  6967. // slot="xxx"
  6968. const slotTarget = getBindingAttr(el, 'slot');
  6969. if (slotTarget) {
  6970. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  6971. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  6972. // preserve slot as an attribute for native shadow DOM compat
  6973. // only for non-scoped slots.
  6974. if (el.tag !== 'template' && !el.slotScope) {
  6975. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  6976. }
  6977. }
  6978. // 2.6 v-slot syntax
  6979. {
  6980. if (el.tag === 'template') {
  6981. // v-slot on <template>
  6982. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  6983. if (slotBinding) {
  6984. if (process.env.NODE_ENV !== 'production') {
  6985. if (el.slotTarget || el.slotScope) {
  6986. warn$2(`Unexpected mixed usage of different slot syntaxes.`, el);
  6987. }
  6988. if (el.parent && !maybeComponent(el.parent)) {
  6989. warn$2(`<template v-slot> can only appear at the root level inside ` +
  6990. `the receiving component`, el);
  6991. }
  6992. }
  6993. const { name, dynamic } = getSlotName(slotBinding);
  6994. el.slotTarget = name;
  6995. el.slotTargetDynamic = dynamic;
  6996. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  6997. }
  6998. }
  6999. else {
  7000. // v-slot on component, denotes default slot
  7001. const slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  7002. if (slotBinding) {
  7003. if (process.env.NODE_ENV !== 'production') {
  7004. if (!maybeComponent(el)) {
  7005. warn$2(`v-slot can only be used on components or <template>.`, slotBinding);
  7006. }
  7007. if (el.slotScope || el.slotTarget) {
  7008. warn$2(`Unexpected mixed usage of different slot syntaxes.`, el);
  7009. }
  7010. if (el.scopedSlots) {
  7011. warn$2(`To avoid scope ambiguity, the default slot should also use ` +
  7012. `<template> syntax when there are other named slots.`, slotBinding);
  7013. }
  7014. }
  7015. // add the component's children to its default slot
  7016. const slots = el.scopedSlots || (el.scopedSlots = {});
  7017. const { name, dynamic } = getSlotName(slotBinding);
  7018. const slotContainer = (slots[name] = createASTElement('template', [], el));
  7019. slotContainer.slotTarget = name;
  7020. slotContainer.slotTargetDynamic = dynamic;
  7021. slotContainer.children = el.children.filter((c) => {
  7022. if (!c.slotScope) {
  7023. c.parent = slotContainer;
  7024. return true;
  7025. }
  7026. });
  7027. slotContainer.slotScope = slotBinding.value || emptySlotScopeToken;
  7028. // remove children as they are returned from scopedSlots now
  7029. el.children = [];
  7030. // mark el non-plain so data gets generated
  7031. el.plain = false;
  7032. }
  7033. }
  7034. }
  7035. }
  7036. function getSlotName(binding) {
  7037. let name = binding.name.replace(slotRE, '');
  7038. if (!name) {
  7039. if (binding.name[0] !== '#') {
  7040. name = 'default';
  7041. }
  7042. else if (process.env.NODE_ENV !== 'production') {
  7043. warn$2(`v-slot shorthand syntax requires a slot name.`, binding);
  7044. }
  7045. }
  7046. return dynamicArgRE.test(name)
  7047. ? // dynamic [name]
  7048. { name: name.slice(1, -1), dynamic: true }
  7049. : // static name
  7050. { name: `"${name}"`, dynamic: false };
  7051. }
  7052. // handle <slot/> outlets
  7053. function processSlotOutlet(el) {
  7054. if (el.tag === 'slot') {
  7055. el.slotName = getBindingAttr(el, 'name');
  7056. if (process.env.NODE_ENV !== 'production' && el.key) {
  7057. warn$2(`\`key\` does not work on <slot> because slots are abstract outlets ` +
  7058. `and can possibly expand into multiple elements. ` +
  7059. `Use the key on a wrapping element instead.`, getRawBindingAttr(el, 'key'));
  7060. }
  7061. }
  7062. }
  7063. function processComponent(el) {
  7064. let binding;
  7065. if ((binding = getBindingAttr(el, 'is'))) {
  7066. el.component = binding;
  7067. }
  7068. if (getAndRemoveAttr(el, 'inline-template') != null) {
  7069. el.inlineTemplate = true;
  7070. }
  7071. }
  7072. function processAttrs(el) {
  7073. const list = el.attrsList;
  7074. let i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  7075. for (i = 0, l = list.length; i < l; i++) {
  7076. name = rawName = list[i].name;
  7077. value = list[i].value;
  7078. if (dirRE.test(name)) {
  7079. // mark element as dynamic
  7080. el.hasBindings = true;
  7081. // modifiers
  7082. modifiers = parseModifiers(name.replace(dirRE, ''));
  7083. // support .foo shorthand syntax for the .prop modifier
  7084. if (modifiers) {
  7085. name = name.replace(modifierRE, '');
  7086. }
  7087. if (bindRE.test(name)) {
  7088. // v-bind
  7089. name = name.replace(bindRE, '');
  7090. value = parseFilters(value);
  7091. isDynamic = dynamicArgRE.test(name);
  7092. if (isDynamic) {
  7093. name = name.slice(1, -1);
  7094. }
  7095. if (process.env.NODE_ENV !== 'production' && value.trim().length === 0) {
  7096. warn$2(`The value for a v-bind expression cannot be empty. Found in "v-bind:${name}"`);
  7097. }
  7098. if (modifiers) {
  7099. if (modifiers.prop && !isDynamic) {
  7100. name = camelize(name);
  7101. if (name === 'innerHtml')
  7102. name = 'innerHTML';
  7103. }
  7104. if (modifiers.camel && !isDynamic) {
  7105. name = camelize(name);
  7106. }
  7107. if (modifiers.sync) {
  7108. syncGen = genAssignmentCode(value, `$event`);
  7109. if (!isDynamic) {
  7110. addHandler(el, `update:${camelize(name)}`, syncGen, null, false, warn$2, list[i]);
  7111. if (hyphenate(name) !== camelize(name)) {
  7112. addHandler(el, `update:${hyphenate(name)}`, syncGen, null, false, warn$2, list[i]);
  7113. }
  7114. }
  7115. else {
  7116. // handler w/ dynamic event name
  7117. addHandler(el, `"update:"+(${name})`, syncGen, null, false, warn$2, list[i], true // dynamic
  7118. );
  7119. }
  7120. }
  7121. }
  7122. if ((modifiers && modifiers.prop) ||
  7123. (!el.component && platformMustUseProp(el.tag, el.attrsMap.type, name))) {
  7124. addProp(el, name, value, list[i], isDynamic);
  7125. }
  7126. else {
  7127. addAttr(el, name, value, list[i], isDynamic);
  7128. }
  7129. }
  7130. else if (onRE.test(name)) {
  7131. // v-on
  7132. name = name.replace(onRE, '');
  7133. isDynamic = dynamicArgRE.test(name);
  7134. if (isDynamic) {
  7135. name = name.slice(1, -1);
  7136. }
  7137. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  7138. }
  7139. else {
  7140. // normal directives
  7141. name = name.replace(dirRE, '');
  7142. // parse arg
  7143. const argMatch = name.match(argRE);
  7144. let arg = argMatch && argMatch[1];
  7145. isDynamic = false;
  7146. if (arg) {
  7147. name = name.slice(0, -(arg.length + 1));
  7148. if (dynamicArgRE.test(arg)) {
  7149. arg = arg.slice(1, -1);
  7150. isDynamic = true;
  7151. }
  7152. }
  7153. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  7154. if (process.env.NODE_ENV !== 'production' && name === 'model') {
  7155. checkForAliasModel(el, value);
  7156. }
  7157. }
  7158. }
  7159. else {
  7160. // literal attribute
  7161. if (process.env.NODE_ENV !== 'production') {
  7162. const res = parseText(value, delimiters);
  7163. if (res) {
  7164. warn$2(`${name}="${value}": ` +
  7165. 'Interpolation inside attributes has been removed. ' +
  7166. 'Use v-bind or the colon shorthand instead. For example, ' +
  7167. 'instead of <div id="{{ val }}">, use <div :id="val">.', list[i]);
  7168. }
  7169. }
  7170. addAttr(el, name, JSON.stringify(value), list[i]);
  7171. // #6887 firefox doesn't update muted state if set via attribute
  7172. // even immediately after element creation
  7173. if (!el.component &&
  7174. name === 'muted' &&
  7175. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  7176. addProp(el, name, 'true', list[i]);
  7177. }
  7178. }
  7179. }
  7180. }
  7181. function checkInFor(el) {
  7182. let parent = el;
  7183. while (parent) {
  7184. if (parent.for !== undefined) {
  7185. return true;
  7186. }
  7187. parent = parent.parent;
  7188. }
  7189. return false;
  7190. }
  7191. function parseModifiers(name) {
  7192. const match = name.match(modifierRE);
  7193. if (match) {
  7194. const ret = {};
  7195. match.forEach(m => {
  7196. ret[m.slice(1)] = true;
  7197. });
  7198. return ret;
  7199. }
  7200. }
  7201. function makeAttrsMap(attrs) {
  7202. const map = {};
  7203. for (let i = 0, l = attrs.length; i < l; i++) {
  7204. if (process.env.NODE_ENV !== 'production' && map[attrs[i].name] && !isIE && !isEdge) {
  7205. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  7206. }
  7207. map[attrs[i].name] = attrs[i].value;
  7208. }
  7209. return map;
  7210. }
  7211. // for script (e.g. type="x/template") or style, do not decode content
  7212. function isTextTag(el) {
  7213. return el.tag === 'script' || el.tag === 'style';
  7214. }
  7215. function isForbiddenTag(el) {
  7216. return (el.tag === 'style' ||
  7217. (el.tag === 'script' &&
  7218. (!el.attrsMap.type || el.attrsMap.type === 'text/javascript')));
  7219. }
  7220. const ieNSBug = /^xmlns:NS\d+/;
  7221. const ieNSPrefix = /^NS\d+:/;
  7222. /* istanbul ignore next */
  7223. function guardIESVGBug(attrs) {
  7224. const res = [];
  7225. for (let i = 0; i < attrs.length; i++) {
  7226. const attr = attrs[i];
  7227. if (!ieNSBug.test(attr.name)) {
  7228. attr.name = attr.name.replace(ieNSPrefix, '');
  7229. res.push(attr);
  7230. }
  7231. }
  7232. return res;
  7233. }
  7234. function checkForAliasModel(el, value) {
  7235. let _el = el;
  7236. while (_el) {
  7237. if (_el.for && _el.alias === value) {
  7238. warn$2(`<${el.tag} v-model="${value}">: ` +
  7239. `You are binding v-model directly to a v-for iteration alias. ` +
  7240. `This will not be able to modify the v-for source array because ` +
  7241. `writing to the alias is like modifying a function local variable. ` +
  7242. `Consider using an array of objects and use v-model on an object property instead.`, el.rawAttrsMap['v-model']);
  7243. }
  7244. _el = _el.parent;
  7245. }
  7246. }
  7247. /**
  7248. * Expand input[v-model] with dynamic type bindings into v-if-else chains
  7249. * Turn this:
  7250. * <input v-model="data[type]" :type="type">
  7251. * into this:
  7252. * <input v-if="type === 'checkbox'" type="checkbox" v-model="data[type]">
  7253. * <input v-else-if="type === 'radio'" type="radio" v-model="data[type]">
  7254. * <input v-else :type="type" v-model="data[type]">
  7255. */
  7256. function preTransformNode(el, options) {
  7257. if (el.tag === 'input') {
  7258. const map = el.attrsMap;
  7259. if (!map['v-model']) {
  7260. return;
  7261. }
  7262. let typeBinding;
  7263. if (map[':type'] || map['v-bind:type']) {
  7264. typeBinding = getBindingAttr(el, 'type');
  7265. }
  7266. if (!map.type && !typeBinding && map['v-bind']) {
  7267. typeBinding = `(${map['v-bind']}).type`;
  7268. }
  7269. if (typeBinding) {
  7270. const ifCondition = getAndRemoveAttr(el, 'v-if', true);
  7271. const ifConditionExtra = ifCondition ? `&&(${ifCondition})` : ``;
  7272. const hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  7273. const elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  7274. // 1. checkbox
  7275. const branch0 = cloneASTElement(el);
  7276. // process for on the main node
  7277. processFor(branch0);
  7278. addRawAttr(branch0, 'type', 'checkbox');
  7279. processElement(branch0, options);
  7280. branch0.processed = true; // prevent it from double-processed
  7281. branch0.if = `(${typeBinding})==='checkbox'` + ifConditionExtra;
  7282. addIfCondition(branch0, {
  7283. exp: branch0.if,
  7284. block: branch0
  7285. });
  7286. // 2. add radio else-if condition
  7287. const branch1 = cloneASTElement(el);
  7288. getAndRemoveAttr(branch1, 'v-for', true);
  7289. addRawAttr(branch1, 'type', 'radio');
  7290. processElement(branch1, options);
  7291. addIfCondition(branch0, {
  7292. exp: `(${typeBinding})==='radio'` + ifConditionExtra,
  7293. block: branch1
  7294. });
  7295. // 3. other
  7296. const branch2 = cloneASTElement(el);
  7297. getAndRemoveAttr(branch2, 'v-for', true);
  7298. addRawAttr(branch2, ':type', typeBinding);
  7299. processElement(branch2, options);
  7300. addIfCondition(branch0, {
  7301. exp: ifCondition,
  7302. block: branch2
  7303. });
  7304. if (hasElse) {
  7305. branch0.else = true;
  7306. }
  7307. else if (elseIfCondition) {
  7308. branch0.elseif = elseIfCondition;
  7309. }
  7310. return branch0;
  7311. }
  7312. }
  7313. }
  7314. function cloneASTElement(el) {
  7315. return createASTElement(el.tag, el.attrsList.slice(), el.parent);
  7316. }
  7317. var model$1 = {
  7318. preTransformNode
  7319. };
  7320. var modules = [klass, style, model$1];
  7321. let warn$1;
  7322. // in some cases, the event used has to be determined at runtime
  7323. // so we used some reserved tokens during compile.
  7324. const RANGE_TOKEN = '__r';
  7325. function model(el, dir, _warn) {
  7326. warn$1 = _warn;
  7327. const value = dir.value;
  7328. const modifiers = dir.modifiers;
  7329. const tag = el.tag;
  7330. const type = el.attrsMap.type;
  7331. if (process.env.NODE_ENV !== 'production') {
  7332. // inputs with type="file" are read only and setting the input's
  7333. // value will throw an error.
  7334. if (tag === 'input' && type === 'file') {
  7335. warn$1(`<${el.tag} v-model="${value}" type="file">:\n` +
  7336. `File inputs are read only. Use a v-on:change listener instead.`, el.rawAttrsMap['v-model']);
  7337. }
  7338. }
  7339. if (el.component) {
  7340. genComponentModel(el, value, modifiers);
  7341. // component v-model doesn't need extra runtime
  7342. return false;
  7343. }
  7344. else if (tag === 'select') {
  7345. genSelect(el, value, modifiers);
  7346. }
  7347. else if (tag === 'input' && type === 'checkbox') {
  7348. genCheckboxModel(el, value, modifiers);
  7349. }
  7350. else if (tag === 'input' && type === 'radio') {
  7351. genRadioModel(el, value, modifiers);
  7352. }
  7353. else if (tag === 'input' || tag === 'textarea') {
  7354. genDefaultModel(el, value, modifiers);
  7355. }
  7356. else {
  7357. genComponentModel(el, value, modifiers);
  7358. // component v-model doesn't need extra runtime
  7359. return false;
  7360. }
  7361. // ensure runtime directive metadata
  7362. return true;
  7363. }
  7364. function genCheckboxModel(el, value, modifiers) {
  7365. const number = modifiers && modifiers.number;
  7366. const valueBinding = getBindingAttr(el, 'value') || 'null';
  7367. const trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  7368. const falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  7369. addProp(el, 'checked', `Array.isArray(${value})` +
  7370. `?_i(${value},${valueBinding})>-1` +
  7371. (trueValueBinding === 'true'
  7372. ? `:(${value})`
  7373. : `:_q(${value},${trueValueBinding})`));
  7374. addHandler(el, 'change', `var $$a=${value},` +
  7375. '$$el=$event.target,' +
  7376. `$$c=$$el.checked?(${trueValueBinding}):(${falseValueBinding});` +
  7377. 'if(Array.isArray($$a)){' +
  7378. `var $$v=${number ? '_n(' + valueBinding + ')' : valueBinding},` +
  7379. '$$i=_i($$a,$$v);' +
  7380. `if($$el.checked){$$i<0&&(${genAssignmentCode(value, '$$a.concat([$$v])')})}` +
  7381. `else{$$i>-1&&(${genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')})}` +
  7382. `}else{${genAssignmentCode(value, '$$c')}}`, null, true);
  7383. }
  7384. function genRadioModel(el, value, modifiers) {
  7385. const number = modifiers && modifiers.number;
  7386. let valueBinding = getBindingAttr(el, 'value') || 'null';
  7387. valueBinding = number ? `_n(${valueBinding})` : valueBinding;
  7388. addProp(el, 'checked', `_q(${value},${valueBinding})`);
  7389. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  7390. }
  7391. function genSelect(el, value, modifiers) {
  7392. const number = modifiers && modifiers.number;
  7393. const selectedVal = `Array.prototype.filter` +
  7394. `.call($event.target.options,function(o){return o.selected})` +
  7395. `.map(function(o){var val = "_value" in o ? o._value : o.value;` +
  7396. `return ${number ? '_n(val)' : 'val'}})`;
  7397. const assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  7398. let code = `var $$selectedVal = ${selectedVal};`;
  7399. code = `${code} ${genAssignmentCode(value, assignment)}`;
  7400. addHandler(el, 'change', code, null, true);
  7401. }
  7402. function genDefaultModel(el, value, modifiers) {
  7403. const type = el.attrsMap.type;
  7404. // warn if v-bind:value conflicts with v-model
  7405. // except for inputs with v-bind:type
  7406. if (process.env.NODE_ENV !== 'production') {
  7407. const value = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  7408. const typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  7409. if (value && !typeBinding) {
  7410. const binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  7411. warn$1(`${binding}="${value}" conflicts with v-model on the same element ` +
  7412. 'because the latter already expands to a value binding internally', el.rawAttrsMap[binding]);
  7413. }
  7414. }
  7415. const { lazy, number, trim } = modifiers || {};
  7416. const needCompositionGuard = !lazy && type !== 'range';
  7417. const event = lazy ? 'change' : type === 'range' ? RANGE_TOKEN : 'input';
  7418. let valueExpression = '$event.target.value';
  7419. if (trim) {
  7420. valueExpression = `$event.target.value.trim()`;
  7421. }
  7422. if (number) {
  7423. valueExpression = `_n(${valueExpression})`;
  7424. }
  7425. let code = genAssignmentCode(value, valueExpression);
  7426. if (needCompositionGuard) {
  7427. code = `if($event.target.composing)return;${code}`;
  7428. }
  7429. addProp(el, 'value', `(${value})`);
  7430. addHandler(el, event, code, null, true);
  7431. if (trim || number) {
  7432. addHandler(el, 'blur', '$forceUpdate()');
  7433. }
  7434. }
  7435. function text(el, dir) {
  7436. if (dir.value) {
  7437. addProp(el, 'textContent', `_s(${dir.value})`, dir);
  7438. }
  7439. }
  7440. function html(el, dir) {
  7441. if (dir.value) {
  7442. addProp(el, 'innerHTML', `_s(${dir.value})`, dir);
  7443. }
  7444. }
  7445. var directives = {
  7446. model,
  7447. text,
  7448. html
  7449. };
  7450. const baseOptions = {
  7451. expectHTML: true,
  7452. modules,
  7453. directives,
  7454. isPreTag,
  7455. isUnaryTag,
  7456. mustUseProp,
  7457. canBeLeftOpenTag,
  7458. isReservedTag,
  7459. getTagNamespace,
  7460. staticKeys: genStaticKeys$1(modules)
  7461. };
  7462. const hasWarned = {};
  7463. function warnOnce(msg) {
  7464. const isNodeProd = typeof process !== 'undefined' && process.env.NODE_ENV === 'production';
  7465. if (!isNodeProd && !hasWarned[msg]) {
  7466. hasWarned[msg] = true;
  7467. warn(msg);
  7468. }
  7469. }
  7470. function warn(msg) {
  7471. console.warn(`\x1b[1m\x1b[33m[@vue/compiler-sfc]\x1b[0m\x1b[33m ${msg}\x1b[0m\n`);
  7472. }
  7473. const doNotPrefix = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' +
  7474. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  7475. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  7476. 'require,' + // for webpack
  7477. 'arguments,' + // parsed as identifier but is a special keyword...
  7478. '_c' // cached to save property access
  7479. );
  7480. /**
  7481. * The input is expected to be a valid expression.
  7482. */
  7483. function prefixIdentifiers(source, isFunctional = false, isTS = false, babelOptions = {}, bindings) {
  7484. const s = new MagicString(source);
  7485. const plugins = [
  7486. ...(isTS ? ['typescript'] : []),
  7487. ...((babelOptions === null || babelOptions === void 0 ? void 0 : babelOptions.plugins) || [])
  7488. ];
  7489. const ast = parser$1.parseExpression(source, Object.assign(Object.assign({}, babelOptions), { plugins }));
  7490. const isScriptSetup = bindings && bindings.__isScriptSetup !== false;
  7491. walkIdentifiers(ast, (ident, parent) => {
  7492. const { name } = ident;
  7493. if (doNotPrefix(name)) {
  7494. return;
  7495. }
  7496. let prefix = `_vm.`;
  7497. if (isScriptSetup) {
  7498. const type = bindings[name];
  7499. if (type && type.startsWith('setup')) {
  7500. prefix = `_setup.`;
  7501. }
  7502. }
  7503. if (isStaticProperty(parent) && parent.shorthand) {
  7504. // property shorthand like { foo }, we need to add the key since
  7505. // we rewrite the value
  7506. // { foo } -> { foo: _vm.foo }
  7507. s.appendLeft(ident.end, `: ${prefix}${name}`);
  7508. }
  7509. else {
  7510. s.prependRight(ident.start, prefix);
  7511. }
  7512. }, node => {
  7513. if (node.type === 'WithStatement') {
  7514. s.remove(node.start, node.body.start + 1);
  7515. s.remove(node.end - 1, node.end);
  7516. if (!isFunctional) {
  7517. s.prependRight(node.start, `var _vm=this,_c=_vm._self._c${isScriptSetup ? `,_setup=_vm._self._setupProxy;` : `;`}`);
  7518. }
  7519. }
  7520. });
  7521. return s.toString();
  7522. }
  7523. const CSS_VARS_HELPER = `useCssVars`;
  7524. function genCssVarsFromList(vars, id, isProd, isSSR = false) {
  7525. return `{\n ${vars
  7526. .map(key => `"${isSSR ? `--` : ``}${genVarName(id, key, isProd)}": (${key})`)
  7527. .join(',\n ')}\n}`;
  7528. }
  7529. function genVarName(id, raw, isProd) {
  7530. if (isProd) {
  7531. return hashSum(id + raw);
  7532. }
  7533. else {
  7534. return `${id}-${raw.replace(/([^\w-])/g, '_')}`;
  7535. }
  7536. }
  7537. function normalizeExpression(exp) {
  7538. exp = exp.trim();
  7539. if ((exp[0] === `'` && exp[exp.length - 1] === `'`) ||
  7540. (exp[0] === `"` && exp[exp.length - 1] === `"`)) {
  7541. return exp.slice(1, -1);
  7542. }
  7543. return exp;
  7544. }
  7545. const vBindRE = /v-bind\s*\(/g;
  7546. function parseCssVars(sfc) {
  7547. const vars = [];
  7548. sfc.styles.forEach(style => {
  7549. let match;
  7550. // ignore v-bind() in comments /* ... */
  7551. const content = style.content.replace(/\/\*([\s\S]*?)\*\//g, '');
  7552. while ((match = vBindRE.exec(content))) {
  7553. const start = match.index + match[0].length;
  7554. const end = lexBinding(content, start);
  7555. if (end !== null) {
  7556. const variable = normalizeExpression(content.slice(start, end));
  7557. if (!vars.includes(variable)) {
  7558. vars.push(variable);
  7559. }
  7560. }
  7561. }
  7562. });
  7563. return vars;
  7564. }
  7565. function lexBinding(content, start) {
  7566. let state = 0 /* LexerState.inParens */;
  7567. let parenDepth = 0;
  7568. for (let i = start; i < content.length; i++) {
  7569. const char = content.charAt(i);
  7570. switch (state) {
  7571. case 0 /* LexerState.inParens */:
  7572. if (char === `'`) {
  7573. state = 1 /* LexerState.inSingleQuoteString */;
  7574. }
  7575. else if (char === `"`) {
  7576. state = 2 /* LexerState.inDoubleQuoteString */;
  7577. }
  7578. else if (char === `(`) {
  7579. parenDepth++;
  7580. }
  7581. else if (char === `)`) {
  7582. if (parenDepth > 0) {
  7583. parenDepth--;
  7584. }
  7585. else {
  7586. return i;
  7587. }
  7588. }
  7589. break;
  7590. case 1 /* LexerState.inSingleQuoteString */:
  7591. if (char === `'`) {
  7592. state = 0 /* LexerState.inParens */;
  7593. }
  7594. break;
  7595. case 2 /* LexerState.inDoubleQuoteString */:
  7596. if (char === `"`) {
  7597. state = 0 /* LexerState.inParens */;
  7598. }
  7599. break;
  7600. }
  7601. }
  7602. return null;
  7603. }
  7604. const cssVarsPlugin = opts => {
  7605. const { id, isProd } = opts;
  7606. return {
  7607. postcssPlugin: 'vue-sfc-vars',
  7608. Declaration(decl) {
  7609. // rewrite CSS variables
  7610. const value = decl.value;
  7611. if (vBindRE.test(value)) {
  7612. vBindRE.lastIndex = 0;
  7613. let transformed = '';
  7614. let lastIndex = 0;
  7615. let match;
  7616. while ((match = vBindRE.exec(value))) {
  7617. const start = match.index + match[0].length;
  7618. const end = lexBinding(value, start);
  7619. if (end !== null) {
  7620. const variable = normalizeExpression(value.slice(start, end));
  7621. transformed +=
  7622. value.slice(lastIndex, match.index) +
  7623. `var(--${genVarName(id, variable, isProd)})`;
  7624. lastIndex = end + 1;
  7625. }
  7626. }
  7627. decl.value = transformed + value.slice(lastIndex);
  7628. }
  7629. }
  7630. };
  7631. };
  7632. cssVarsPlugin.postcss = true;
  7633. function genCssVarsCode(vars, bindings, id, isProd) {
  7634. const varsExp = genCssVarsFromList(vars, id, isProd);
  7635. return `_${CSS_VARS_HELPER}((_vm, _setup) => ${prefixIdentifiers(`(${varsExp})`, false, false, undefined, bindings)})`;
  7636. }
  7637. // <script setup> already gets the calls injected as part of the transform
  7638. // this is only for single normal <script>
  7639. function genNormalScriptCssVarsCode(cssVars, bindings, id, isProd) {
  7640. return (`\nimport { ${CSS_VARS_HELPER} as _${CSS_VARS_HELPER} } from 'vue'\n` +
  7641. `const __injectCSSVars__ = () => {\n${genCssVarsCode(cssVars, bindings, id, isProd)}}\n` +
  7642. `const __setup__ = __default__.setup\n` +
  7643. `__default__.setup = __setup__\n` +
  7644. ` ? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) }\n` +
  7645. ` : __injectCSSVars__\n`);
  7646. }
  7647. const defaultExportRE = /((?:^|\n|;)\s*)export(\s*)default/;
  7648. const namedDefaultExportRE = /((?:^|\n|;)\s*)export(.+)(?:as)?(\s*)default/s;
  7649. const exportDefaultClassRE = /((?:^|\n|;)\s*)export\s+default\s+class\s+([\w$]+)/;
  7650. /**
  7651. * Utility for rewriting `export default` in a script block into a variable
  7652. * declaration so that we can inject things into it
  7653. */
  7654. function rewriteDefault(input, as, parserPlugins) {
  7655. if (!hasDefaultExport(input)) {
  7656. return input + `\nconst ${as} = {}`;
  7657. }
  7658. let replaced;
  7659. const classMatch = input.match(exportDefaultClassRE);
  7660. if (classMatch) {
  7661. replaced =
  7662. input.replace(exportDefaultClassRE, '$1class $2') +
  7663. `\nconst ${as} = ${classMatch[2]}`;
  7664. }
  7665. else {
  7666. replaced = input.replace(defaultExportRE, `$1const ${as} =`);
  7667. }
  7668. if (!hasDefaultExport(replaced)) {
  7669. return replaced;
  7670. }
  7671. // if the script somehow still contains `default export`, it probably has
  7672. // multi-line comments or template strings. fallback to a full parse.
  7673. const s = new MagicString(input);
  7674. const ast = parser$1.parse(input, {
  7675. sourceType: 'module',
  7676. plugins: parserPlugins
  7677. }).program.body;
  7678. ast.forEach(node => {
  7679. if (node.type === 'ExportDefaultDeclaration') {
  7680. if (node.declaration.type === 'ClassDeclaration') {
  7681. s.overwrite(node.start, node.declaration.id.start, `class `);
  7682. s.append(`\nconst ${as} = ${node.declaration.id.name}`);
  7683. }
  7684. else {
  7685. s.overwrite(node.start, node.declaration.start, `const ${as} = `);
  7686. }
  7687. }
  7688. if (node.type === 'ExportNamedDeclaration') {
  7689. for (const specifier of node.specifiers) {
  7690. if (specifier.type === 'ExportSpecifier' &&
  7691. specifier.exported.type === 'Identifier' &&
  7692. specifier.exported.name === 'default') {
  7693. if (node.source) {
  7694. if (specifier.local.name === 'default') {
  7695. const end = specifierEnd(input, specifier.local.end, node.end);
  7696. s.prepend(`import { default as __VUE_DEFAULT__ } from '${node.source.value}'\n`);
  7697. s.overwrite(specifier.start, end, ``);
  7698. s.append(`\nconst ${as} = __VUE_DEFAULT__`);
  7699. continue;
  7700. }
  7701. else {
  7702. const end = specifierEnd(input, specifier.exported.end, node.end);
  7703. s.prepend(`import { ${input.slice(specifier.local.start, specifier.local.end)} } from '${node.source.value}'\n`);
  7704. s.overwrite(specifier.start, end, ``);
  7705. s.append(`\nconst ${as} = ${specifier.local.name}`);
  7706. continue;
  7707. }
  7708. }
  7709. const end = specifierEnd(input, specifier.end, node.end);
  7710. s.overwrite(specifier.start, end, ``);
  7711. s.append(`\nconst ${as} = ${specifier.local.name}`);
  7712. }
  7713. }
  7714. }
  7715. });
  7716. return s.toString();
  7717. }
  7718. function hasDefaultExport(input) {
  7719. return defaultExportRE.test(input) || namedDefaultExportRE.test(input);
  7720. }
  7721. function specifierEnd(input, end, nodeEnd) {
  7722. // export { default , foo } ...
  7723. let hasCommas = false;
  7724. let oldEnd = end;
  7725. while (end < nodeEnd) {
  7726. if (/\s/.test(input.charAt(end))) {
  7727. end++;
  7728. }
  7729. else if (input.charAt(end) === ',') {
  7730. end++;
  7731. hasCommas = true;
  7732. break;
  7733. }
  7734. else if (input.charAt(end) === '}') {
  7735. break;
  7736. }
  7737. }
  7738. return hasCommas ? end : oldEnd;
  7739. }
  7740. // Special compiler macros
  7741. const DEFINE_PROPS = 'defineProps';
  7742. const DEFINE_EMITS = 'defineEmits';
  7743. const DEFINE_EXPOSE = 'defineExpose';
  7744. const WITH_DEFAULTS = 'withDefaults';
  7745. // constants
  7746. const DEFAULT_VAR = `__default__`;
  7747. const isBuiltInDir$1 = makeMap(`once,memo,if,for,else,else-if,slot,text,html,on,bind,model,show,cloak,is`);
  7748. /**
  7749. * Compile `<script setup>`
  7750. * It requires the whole SFC descriptor because we need to handle and merge
  7751. * normal `<script>` + `<script setup>` if both are present.
  7752. */
  7753. function compileScript(sfc, options = { id: '' }) {
  7754. let { filename, script, scriptSetup, source } = sfc;
  7755. const isProd = !!options.isProd;
  7756. const genSourceMap = options.sourceMap !== false;
  7757. const cssVars = sfc.cssVars;
  7758. const scopeId = options.id ? options.id.replace(/^data-v-/, '') : '';
  7759. const scriptLang = script && script.lang;
  7760. const scriptSetupLang = scriptSetup && scriptSetup.lang;
  7761. const isTS = scriptLang === 'ts' ||
  7762. scriptLang === 'tsx' ||
  7763. scriptSetupLang === 'ts' ||
  7764. scriptSetupLang === 'tsx';
  7765. // resolve parser plugins
  7766. const plugins = [];
  7767. if (!isTS || scriptLang === 'tsx' || scriptSetupLang === 'tsx') {
  7768. plugins.push('jsx');
  7769. }
  7770. else {
  7771. // If don't match the case of adding jsx, should remove the jsx from the babelParserPlugins
  7772. if (options.babelParserPlugins)
  7773. options.babelParserPlugins = options.babelParserPlugins.filter(n => n !== 'jsx');
  7774. }
  7775. if (options.babelParserPlugins)
  7776. plugins.push(...options.babelParserPlugins);
  7777. if (isTS) {
  7778. plugins.push('typescript');
  7779. if (!plugins.includes('decorators')) {
  7780. plugins.push('decorators-legacy');
  7781. }
  7782. }
  7783. if (!scriptSetup) {
  7784. if (!script) {
  7785. throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`);
  7786. }
  7787. if (scriptLang && !isTS && scriptLang !== 'jsx') {
  7788. // do not process non js/ts script blocks
  7789. return script;
  7790. }
  7791. try {
  7792. let content = script.content;
  7793. let map = script.map;
  7794. const scriptAst = parser$1.parse(content, {
  7795. plugins,
  7796. sourceType: 'module'
  7797. }).program;
  7798. const bindings = analyzeScriptBindings(scriptAst.body);
  7799. if (cssVars.length) {
  7800. content = rewriteDefault(content, DEFAULT_VAR, plugins);
  7801. content += genNormalScriptCssVarsCode(cssVars, bindings, scopeId, isProd);
  7802. content += `\nexport default ${DEFAULT_VAR}`;
  7803. }
  7804. return Object.assign(Object.assign({}, script), { content,
  7805. map,
  7806. bindings, scriptAst: scriptAst.body });
  7807. }
  7808. catch (e) {
  7809. // silently fallback if parse fails since user may be using custom
  7810. // babel syntax
  7811. return script;
  7812. }
  7813. }
  7814. if (script && scriptLang !== scriptSetupLang) {
  7815. throw new Error(`[@vue/compiler-sfc] <script> and <script setup> must have the same ` +
  7816. `language type.`);
  7817. }
  7818. if (scriptSetupLang && !isTS && scriptSetupLang !== 'jsx') {
  7819. // do not process non js/ts script blocks
  7820. return scriptSetup;
  7821. }
  7822. // metadata that needs to be returned
  7823. const bindingMetadata = {};
  7824. const helperImports = new Set();
  7825. const userImports = Object.create(null);
  7826. const userImportAlias = Object.create(null);
  7827. const scriptBindings = Object.create(null);
  7828. const setupBindings = Object.create(null);
  7829. let defaultExport;
  7830. let hasDefinePropsCall = false;
  7831. let hasDefineEmitCall = false;
  7832. let hasDefineExposeCall = false;
  7833. let hasDefaultExportName = false;
  7834. let propsRuntimeDecl;
  7835. let propsRuntimeDefaults;
  7836. let propsDestructureDecl;
  7837. let propsTypeDecl;
  7838. let propsTypeDeclRaw;
  7839. let propsIdentifier;
  7840. let emitsRuntimeDecl;
  7841. let emitsTypeDecl;
  7842. let emitsTypeDeclRaw;
  7843. let emitIdentifier;
  7844. // props/emits declared via types
  7845. const typeDeclaredProps = {};
  7846. const typeDeclaredEmits = new Set();
  7847. // record declared types for runtime props type generation
  7848. const declaredTypes = {};
  7849. // props destructure data
  7850. const propsDestructuredBindings = Object.create(null);
  7851. // magic-string state
  7852. const s = new MagicString(source);
  7853. const startOffset = scriptSetup.start;
  7854. const endOffset = scriptSetup.end;
  7855. const scriptStartOffset = script && script.start;
  7856. const scriptEndOffset = script && script.end;
  7857. function helper(key) {
  7858. helperImports.add(key);
  7859. return `_${key}`;
  7860. }
  7861. function parse(input, options, offset) {
  7862. try {
  7863. return parser$1.parse(input, options).program;
  7864. }
  7865. catch (e) {
  7866. e.message = `[@vue/compiler-sfc] ${e.message}\n\n${filename}\n${generateCodeFrame(source, e.pos + offset, e.pos + offset + 1)}`;
  7867. throw e;
  7868. }
  7869. }
  7870. function error(msg, node, end = node.end + startOffset) {
  7871. throw new Error(`[@vue/compiler-sfc] ${msg}\n\n${filename}\n${generateCodeFrame(source, node.start + startOffset, end)}`);
  7872. }
  7873. function registerUserImport(source, local, imported, isType, isFromSetup) {
  7874. if (source === 'vue' && imported) {
  7875. userImportAlias[imported] = local;
  7876. }
  7877. let isUsedInTemplate = true;
  7878. if (sfc.template && !sfc.template.src && !sfc.template.lang) {
  7879. isUsedInTemplate = isImportUsed(local, sfc, isTS);
  7880. }
  7881. userImports[local] = {
  7882. isType,
  7883. imported: imported || 'default',
  7884. source,
  7885. isFromSetup,
  7886. isUsedInTemplate
  7887. };
  7888. }
  7889. function processDefineProps(node, declId) {
  7890. if (!isCallOf(node, DEFINE_PROPS)) {
  7891. return false;
  7892. }
  7893. if (hasDefinePropsCall) {
  7894. error(`duplicate ${DEFINE_PROPS}() call`, node);
  7895. }
  7896. hasDefinePropsCall = true;
  7897. propsRuntimeDecl = node.arguments[0];
  7898. // call has type parameters - infer runtime types from it
  7899. if (node.typeParameters) {
  7900. if (propsRuntimeDecl) {
  7901. error(`${DEFINE_PROPS}() cannot accept both type and non-type arguments ` +
  7902. `at the same time. Use one or the other.`, node);
  7903. }
  7904. propsTypeDeclRaw = node.typeParameters.params[0];
  7905. propsTypeDecl = resolveQualifiedType(propsTypeDeclRaw, node => node.type === 'TSTypeLiteral');
  7906. if (!propsTypeDecl) {
  7907. error(`type argument passed to ${DEFINE_PROPS}() must be a literal type, ` +
  7908. `or a reference to an interface or literal type.`, propsTypeDeclRaw);
  7909. }
  7910. }
  7911. if (declId) {
  7912. propsIdentifier = scriptSetup.content.slice(declId.start, declId.end);
  7913. }
  7914. return true;
  7915. }
  7916. function processWithDefaults(node, declId) {
  7917. if (!isCallOf(node, WITH_DEFAULTS)) {
  7918. return false;
  7919. }
  7920. if (processDefineProps(node.arguments[0], declId)) {
  7921. if (propsRuntimeDecl) {
  7922. error(`${WITH_DEFAULTS} can only be used with type-based ` +
  7923. `${DEFINE_PROPS} declaration.`, node);
  7924. }
  7925. propsRuntimeDefaults = node.arguments[1];
  7926. if (!propsRuntimeDefaults ||
  7927. propsRuntimeDefaults.type !== 'ObjectExpression') {
  7928. error(`The 2nd argument of ${WITH_DEFAULTS} must be an object literal.`, propsRuntimeDefaults || node);
  7929. }
  7930. }
  7931. else {
  7932. error(`${WITH_DEFAULTS}' first argument must be a ${DEFINE_PROPS} call.`, node.arguments[0] || node);
  7933. }
  7934. return true;
  7935. }
  7936. function processDefineEmits(node, declId) {
  7937. if (!isCallOf(node, DEFINE_EMITS)) {
  7938. return false;
  7939. }
  7940. if (hasDefineEmitCall) {
  7941. error(`duplicate ${DEFINE_EMITS}() call`, node);
  7942. }
  7943. hasDefineEmitCall = true;
  7944. emitsRuntimeDecl = node.arguments[0];
  7945. if (node.typeParameters) {
  7946. if (emitsRuntimeDecl) {
  7947. error(`${DEFINE_EMITS}() cannot accept both type and non-type arguments ` +
  7948. `at the same time. Use one or the other.`, node);
  7949. }
  7950. emitsTypeDeclRaw = node.typeParameters.params[0];
  7951. emitsTypeDecl = resolveQualifiedType(emitsTypeDeclRaw, node => node.type === 'TSFunctionType' || node.type === 'TSTypeLiteral');
  7952. if (!emitsTypeDecl) {
  7953. error(`type argument passed to ${DEFINE_EMITS}() must be a function type, ` +
  7954. `a literal type with call signatures, or a reference to the above types.`, emitsTypeDeclRaw);
  7955. }
  7956. }
  7957. if (declId) {
  7958. emitIdentifier = scriptSetup.content.slice(declId.start, declId.end);
  7959. }
  7960. return true;
  7961. }
  7962. function resolveQualifiedType(node, qualifier) {
  7963. if (qualifier(node)) {
  7964. return node;
  7965. }
  7966. if (node.type === 'TSTypeReference' &&
  7967. node.typeName.type === 'Identifier') {
  7968. const refName = node.typeName.name;
  7969. const isQualifiedType = (node) => {
  7970. if (node.type === 'TSInterfaceDeclaration' &&
  7971. node.id.name === refName) {
  7972. return node.body;
  7973. }
  7974. else if (node.type === 'TSTypeAliasDeclaration' &&
  7975. node.id.name === refName &&
  7976. qualifier(node.typeAnnotation)) {
  7977. return node.typeAnnotation;
  7978. }
  7979. else if (node.type === 'ExportNamedDeclaration' && node.declaration) {
  7980. return isQualifiedType(node.declaration);
  7981. }
  7982. };
  7983. const body = scriptAst
  7984. ? [...scriptSetupAst.body, ...scriptAst.body]
  7985. : scriptSetupAst.body;
  7986. for (const node of body) {
  7987. const qualified = isQualifiedType(node);
  7988. if (qualified) {
  7989. return qualified;
  7990. }
  7991. }
  7992. }
  7993. }
  7994. function processDefineExpose(node) {
  7995. if (isCallOf(node, DEFINE_EXPOSE)) {
  7996. if (hasDefineExposeCall) {
  7997. error(`duplicate ${DEFINE_EXPOSE}() call`, node);
  7998. }
  7999. hasDefineExposeCall = true;
  8000. return true;
  8001. }
  8002. return false;
  8003. }
  8004. function checkInvalidScopeReference(node, method) {
  8005. if (!node)
  8006. return;
  8007. walkIdentifiers(node, id => {
  8008. if (setupBindings[id.name]) {
  8009. error(`\`${method}()\` in <script setup> cannot reference locally ` +
  8010. `declared variables because it will be hoisted outside of the ` +
  8011. `setup() function. If your component options require initialization ` +
  8012. `in the module scope, use a separate normal <script> to export ` +
  8013. `the options instead.`, id);
  8014. }
  8015. });
  8016. }
  8017. /**
  8018. * check defaults. If the default object is an object literal with only
  8019. * static properties, we can directly generate more optimized default
  8020. * declarations. Otherwise we will have to fallback to runtime merging.
  8021. */
  8022. function hasStaticWithDefaults() {
  8023. return (propsRuntimeDefaults &&
  8024. propsRuntimeDefaults.type === 'ObjectExpression' &&
  8025. propsRuntimeDefaults.properties.every(node => (node.type === 'ObjectProperty' && !node.computed) ||
  8026. node.type === 'ObjectMethod'));
  8027. }
  8028. function genRuntimeProps(props) {
  8029. const keys = Object.keys(props);
  8030. if (!keys.length) {
  8031. return ``;
  8032. }
  8033. const hasStaticDefaults = hasStaticWithDefaults();
  8034. const scriptSetupSource = scriptSetup.content;
  8035. let propsDecls = `{
  8036. ${keys
  8037. .map(key => {
  8038. let defaultString;
  8039. const destructured = genDestructuredDefaultValue(key);
  8040. if (destructured) {
  8041. defaultString = `default: ${destructured}`;
  8042. }
  8043. else if (hasStaticDefaults) {
  8044. const prop = propsRuntimeDefaults.properties.find((node) => node.key.name === key);
  8045. if (prop) {
  8046. if (prop.type === 'ObjectProperty') {
  8047. // prop has corresponding static default value
  8048. defaultString = `default: ${scriptSetupSource.slice(prop.value.start, prop.value.end)}`;
  8049. }
  8050. else {
  8051. defaultString = `default() ${scriptSetupSource.slice(prop.body.start, prop.body.end)}`;
  8052. }
  8053. }
  8054. }
  8055. const { type, required } = props[key];
  8056. if (!isProd) {
  8057. return `${key}: { type: ${toRuntimeTypeString(type)}, required: ${required}${defaultString ? `, ${defaultString}` : ``} }`;
  8058. }
  8059. else if (type.some(el => el === 'Boolean' || (defaultString && el === 'Function'))) {
  8060. // #4783 production: if boolean or defaultString and function exists, should keep the type.
  8061. return `${key}: { type: ${toRuntimeTypeString(type)}${defaultString ? `, ${defaultString}` : ``} }`;
  8062. }
  8063. else {
  8064. // production: checks are useless
  8065. return `${key}: ${defaultString ? `{ ${defaultString} }` : 'null'}`;
  8066. }
  8067. })
  8068. .join(',\n ')}\n }`;
  8069. if (propsRuntimeDefaults && !hasStaticDefaults) {
  8070. propsDecls = `${helper('mergeDefaults')}(${propsDecls}, ${source.slice(propsRuntimeDefaults.start + startOffset, propsRuntimeDefaults.end + startOffset)})`;
  8071. }
  8072. return `\n props: ${propsDecls},`;
  8073. }
  8074. function genDestructuredDefaultValue(key) {
  8075. const destructured = propsDestructuredBindings[key];
  8076. if (destructured && destructured.default) {
  8077. const value = scriptSetup.content.slice(destructured.default.start, destructured.default.end);
  8078. const isLiteral = destructured.default.type.endsWith('Literal');
  8079. return isLiteral ? value : `() => (${value})`;
  8080. }
  8081. }
  8082. function genSetupPropsType(node) {
  8083. const scriptSetupSource = scriptSetup.content;
  8084. if (hasStaticWithDefaults()) {
  8085. // if withDefaults() is used, we need to remove the optional flags
  8086. // on props that have default values
  8087. let res = `{ `;
  8088. const members = node.type === 'TSTypeLiteral' ? node.members : node.body;
  8089. for (const m of members) {
  8090. if ((m.type === 'TSPropertySignature' ||
  8091. m.type === 'TSMethodSignature') &&
  8092. m.typeAnnotation &&
  8093. m.key.type === 'Identifier') {
  8094. if (propsRuntimeDefaults.properties.some((p) => p.key.name === m.key.name)) {
  8095. res +=
  8096. m.key.name +
  8097. (m.type === 'TSMethodSignature' ? '()' : '') +
  8098. scriptSetupSource.slice(m.typeAnnotation.start, m.typeAnnotation.end) +
  8099. ', ';
  8100. }
  8101. else {
  8102. res +=
  8103. scriptSetupSource.slice(m.start, m.typeAnnotation.end) + `, `;
  8104. }
  8105. }
  8106. }
  8107. return (res.length ? res.slice(0, -2) : res) + ` }`;
  8108. }
  8109. else {
  8110. return scriptSetupSource.slice(node.start, node.end);
  8111. }
  8112. }
  8113. // 1. process normal <script> first if it exists
  8114. let scriptAst;
  8115. if (script) {
  8116. scriptAst = parse(script.content, {
  8117. plugins,
  8118. sourceType: 'module'
  8119. }, scriptStartOffset);
  8120. for (const node of scriptAst.body) {
  8121. if (node.type === 'ImportDeclaration') {
  8122. // record imports for dedupe
  8123. for (const specifier of node.specifiers) {
  8124. const imported = specifier.type === 'ImportSpecifier' &&
  8125. specifier.imported.type === 'Identifier' &&
  8126. specifier.imported.name;
  8127. registerUserImport(node.source.value, specifier.local.name, imported, node.importKind === 'type' ||
  8128. (specifier.type === 'ImportSpecifier' &&
  8129. specifier.importKind === 'type'), false);
  8130. }
  8131. }
  8132. else if (node.type === 'ExportDefaultDeclaration') {
  8133. // export default
  8134. defaultExport = node;
  8135. // check if user has manually specified `name` or 'render` option in
  8136. // export default
  8137. // if has name, skip name inference
  8138. // if has render and no template, generate return object instead of
  8139. // empty render function (#4980)
  8140. let optionProperties;
  8141. if (defaultExport.declaration.type === 'ObjectExpression') {
  8142. optionProperties = defaultExport.declaration.properties;
  8143. }
  8144. else if (defaultExport.declaration.type === 'CallExpression' &&
  8145. defaultExport.declaration.arguments[0].type === 'ObjectExpression') {
  8146. optionProperties = defaultExport.declaration.arguments[0].properties;
  8147. }
  8148. if (optionProperties) {
  8149. for (const s of optionProperties) {
  8150. if (s.type === 'ObjectProperty' &&
  8151. s.key.type === 'Identifier' &&
  8152. s.key.name === 'name') {
  8153. hasDefaultExportName = true;
  8154. }
  8155. }
  8156. }
  8157. // export default { ... } --> const __default__ = { ... }
  8158. const start = node.start + scriptStartOffset;
  8159. const end = node.declaration.start + scriptStartOffset;
  8160. s.overwrite(start, end, `const ${DEFAULT_VAR} = `);
  8161. }
  8162. else if (node.type === 'ExportNamedDeclaration') {
  8163. const defaultSpecifier = node.specifiers.find(s => s.exported.type === 'Identifier' && s.exported.name === 'default');
  8164. if (defaultSpecifier) {
  8165. defaultExport = node;
  8166. // 1. remove specifier
  8167. if (node.specifiers.length > 1) {
  8168. s.remove(defaultSpecifier.start + scriptStartOffset, defaultSpecifier.end + scriptStartOffset);
  8169. }
  8170. else {
  8171. s.remove(node.start + scriptStartOffset, node.end + scriptStartOffset);
  8172. }
  8173. if (node.source) {
  8174. // export { x as default } from './x'
  8175. // rewrite to `import { x as __default__ } from './x'` and
  8176. // add to top
  8177. s.prepend(`import { ${defaultSpecifier.local.name} as ${DEFAULT_VAR} } from '${node.source.value}'\n`);
  8178. }
  8179. else {
  8180. // export { x as default }
  8181. // rewrite to `const __default__ = x` and move to end
  8182. s.appendLeft(scriptEndOffset, `\nconst ${DEFAULT_VAR} = ${defaultSpecifier.local.name}\n`);
  8183. }
  8184. }
  8185. if (node.declaration) {
  8186. walkDeclaration(node.declaration, scriptBindings, userImportAlias);
  8187. }
  8188. }
  8189. else if ((node.type === 'VariableDeclaration' ||
  8190. node.type === 'FunctionDeclaration' ||
  8191. node.type === 'ClassDeclaration' ||
  8192. node.type === 'TSEnumDeclaration') &&
  8193. !node.declare) {
  8194. walkDeclaration(node, scriptBindings, userImportAlias);
  8195. }
  8196. }
  8197. // apply reactivity transform
  8198. // if (enableReactivityTransform && shouldTransform(script.content)) {
  8199. // const { rootRefs, importedHelpers } = transformAST(
  8200. // scriptAst,
  8201. // s,
  8202. // scriptStartOffset!
  8203. // )
  8204. // refBindings = rootRefs
  8205. // for (const h of importedHelpers) {
  8206. // helperImports.add(h)
  8207. // }
  8208. // }
  8209. // <script> after <script setup>
  8210. // we need to move the block up so that `const __default__` is
  8211. // declared before being used in the actual component definition
  8212. if (scriptStartOffset > startOffset) {
  8213. // if content doesn't end with newline, add one
  8214. if (!/\n$/.test(script.content.trim())) {
  8215. s.appendLeft(scriptEndOffset, `\n`);
  8216. }
  8217. s.move(scriptStartOffset, scriptEndOffset, 0);
  8218. }
  8219. }
  8220. // 2. parse <script setup> and walk over top level statements
  8221. const scriptSetupAst = parse(scriptSetup.content, {
  8222. plugins: [
  8223. ...plugins,
  8224. // allow top level await but only inside <script setup>
  8225. 'topLevelAwait'
  8226. ],
  8227. sourceType: 'module'
  8228. }, startOffset);
  8229. for (const node of scriptSetupAst.body) {
  8230. const start = node.start + startOffset;
  8231. let end = node.end + startOffset;
  8232. // locate comment
  8233. if (node.trailingComments && node.trailingComments.length > 0) {
  8234. const lastCommentNode = node.trailingComments[node.trailingComments.length - 1];
  8235. end = lastCommentNode.end + startOffset;
  8236. }
  8237. // locate the end of whitespace between this statement and the next
  8238. while (end <= source.length) {
  8239. if (!/\s/.test(source.charAt(end))) {
  8240. break;
  8241. }
  8242. end++;
  8243. }
  8244. // (Dropped) `ref: x` bindings
  8245. if (node.type === 'LabeledStatement' &&
  8246. node.label.name === 'ref' &&
  8247. node.body.type === 'ExpressionStatement') {
  8248. error(`ref sugar using the label syntax was an experimental proposal and ` +
  8249. `has been dropped based on community feedback. Please check out ` +
  8250. `the new proposal at https://github.com/vuejs/rfcs/discussions/369`, node);
  8251. }
  8252. if (node.type === 'ImportDeclaration') {
  8253. // import declarations are moved to top
  8254. s.move(start, end, 0);
  8255. // dedupe imports
  8256. let removed = 0;
  8257. const removeSpecifier = (i) => {
  8258. const removeLeft = i > removed;
  8259. removed++;
  8260. const current = node.specifiers[i];
  8261. const next = node.specifiers[i + 1];
  8262. s.remove(removeLeft
  8263. ? node.specifiers[i - 1].end + startOffset
  8264. : current.start + startOffset, next && !removeLeft
  8265. ? next.start + startOffset
  8266. : current.end + startOffset);
  8267. };
  8268. for (let i = 0; i < node.specifiers.length; i++) {
  8269. const specifier = node.specifiers[i];
  8270. const local = specifier.local.name;
  8271. let imported = specifier.type === 'ImportSpecifier' &&
  8272. specifier.imported.type === 'Identifier' &&
  8273. specifier.imported.name;
  8274. if (specifier.type === 'ImportNamespaceSpecifier') {
  8275. imported = '*';
  8276. }
  8277. const source = node.source.value;
  8278. const existing = userImports[local];
  8279. if (source === 'vue' &&
  8280. (imported === DEFINE_PROPS ||
  8281. imported === DEFINE_EMITS ||
  8282. imported === DEFINE_EXPOSE)) {
  8283. warnOnce(`\`${imported}\` is a compiler macro and no longer needs to be imported.`);
  8284. removeSpecifier(i);
  8285. }
  8286. else if (existing) {
  8287. if (existing.source === source && existing.imported === imported) {
  8288. // already imported in <script setup>, dedupe
  8289. removeSpecifier(i);
  8290. }
  8291. else {
  8292. error(`different imports aliased to same local name.`, specifier);
  8293. }
  8294. }
  8295. else {
  8296. registerUserImport(source, local, imported, node.importKind === 'type' ||
  8297. (specifier.type === 'ImportSpecifier' &&
  8298. specifier.importKind === 'type'), true);
  8299. }
  8300. }
  8301. if (node.specifiers.length && removed === node.specifiers.length) {
  8302. s.remove(node.start + startOffset, node.end + startOffset);
  8303. }
  8304. }
  8305. if (node.type === 'ExpressionStatement') {
  8306. // process `defineProps` and `defineEmit(s)` calls
  8307. if (processDefineProps(node.expression) ||
  8308. processDefineEmits(node.expression) ||
  8309. processWithDefaults(node.expression)) {
  8310. s.remove(node.start + startOffset, node.end + startOffset);
  8311. }
  8312. else if (processDefineExpose(node.expression)) {
  8313. // defineExpose({}) -> expose({})
  8314. const callee = node.expression.callee;
  8315. s.overwrite(callee.start + startOffset, callee.end + startOffset, 'expose');
  8316. }
  8317. }
  8318. if (node.type === 'VariableDeclaration' && !node.declare) {
  8319. const total = node.declarations.length;
  8320. let left = total;
  8321. for (let i = 0; i < total; i++) {
  8322. const decl = node.declarations[i];
  8323. if (decl.init) {
  8324. // defineProps / defineEmits
  8325. const isDefineProps = processDefineProps(decl.init, decl.id) ||
  8326. processWithDefaults(decl.init, decl.id);
  8327. const isDefineEmits = processDefineEmits(decl.init, decl.id);
  8328. if (isDefineProps || isDefineEmits) {
  8329. if (left === 1) {
  8330. s.remove(node.start + startOffset, node.end + startOffset);
  8331. }
  8332. else {
  8333. let start = decl.start + startOffset;
  8334. let end = decl.end + startOffset;
  8335. if (i < total - 1) {
  8336. // not the last one, locate the start of the next
  8337. end = node.declarations[i + 1].start + startOffset;
  8338. }
  8339. else {
  8340. // last one, locate the end of the prev
  8341. start = node.declarations[i - 1].end + startOffset;
  8342. }
  8343. s.remove(start, end);
  8344. left--;
  8345. }
  8346. }
  8347. }
  8348. }
  8349. }
  8350. // walk declarations to record declared bindings
  8351. if ((node.type === 'VariableDeclaration' ||
  8352. node.type === 'FunctionDeclaration' ||
  8353. node.type === 'ClassDeclaration') &&
  8354. !node.declare) {
  8355. walkDeclaration(node, setupBindings, userImportAlias);
  8356. }
  8357. // walk statements & named exports / variable declarations for top level
  8358. // await
  8359. if ((node.type === 'VariableDeclaration' && !node.declare) ||
  8360. node.type.endsWith('Statement')) {
  8361. const scope = [scriptSetupAst.body];
  8362. walk$1(node, {
  8363. enter(child, parent) {
  8364. if (isFunctionType(child)) {
  8365. this.skip();
  8366. }
  8367. if (child.type === 'BlockStatement') {
  8368. scope.push(child.body);
  8369. }
  8370. if (child.type === 'AwaitExpression') {
  8371. error(`Vue 2 does not support top level await in <script setup>.`, child);
  8372. }
  8373. },
  8374. exit(node) {
  8375. if (node.type === 'BlockStatement')
  8376. scope.pop();
  8377. }
  8378. });
  8379. }
  8380. if ((node.type === 'ExportNamedDeclaration' && node.exportKind !== 'type') ||
  8381. node.type === 'ExportAllDeclaration' ||
  8382. node.type === 'ExportDefaultDeclaration') {
  8383. error(`<script setup> cannot contain ES module exports. ` +
  8384. `If you are using a previous version of <script setup>, please ` +
  8385. `consult the updated RFC at https://github.com/vuejs/rfcs/pull/227.`, node);
  8386. }
  8387. if (isTS) {
  8388. // runtime enum
  8389. if (node.type === 'TSEnumDeclaration') {
  8390. registerBinding(setupBindings, node.id, "setup-const" /* BindingTypes.SETUP_CONST */);
  8391. }
  8392. // move all Type declarations to outer scope
  8393. if (node.type.startsWith('TS') ||
  8394. (node.type === 'ExportNamedDeclaration' &&
  8395. node.exportKind === 'type') ||
  8396. (node.type === 'VariableDeclaration' && node.declare)) {
  8397. recordType(node, declaredTypes);
  8398. s.move(start, end, 0);
  8399. }
  8400. }
  8401. }
  8402. // 3. Apply reactivity transform
  8403. // if (
  8404. // (enableReactivityTransform &&
  8405. // // normal <script> had ref bindings that maybe used in <script setup>
  8406. // (refBindings || shouldTransform(scriptSetup.content))) ||
  8407. // propsDestructureDecl
  8408. // ) {
  8409. // const { rootRefs, importedHelpers } = transformAST(
  8410. // scriptSetupAst,
  8411. // s,
  8412. // startOffset,
  8413. // refBindings,
  8414. // propsDestructuredBindings
  8415. // )
  8416. // refBindings = refBindings ? [...refBindings, ...rootRefs] : rootRefs
  8417. // for (const h of importedHelpers) {
  8418. // helperImports.add(h)
  8419. // }
  8420. // }
  8421. // 4. extract runtime props/emits code from setup context type
  8422. if (propsTypeDecl) {
  8423. extractRuntimeProps(propsTypeDecl, typeDeclaredProps, declaredTypes);
  8424. }
  8425. if (emitsTypeDecl) {
  8426. extractRuntimeEmits(emitsTypeDecl, typeDeclaredEmits);
  8427. }
  8428. // 5. check useOptions args to make sure it doesn't reference setup scope
  8429. // variables
  8430. checkInvalidScopeReference(propsRuntimeDecl, DEFINE_PROPS);
  8431. checkInvalidScopeReference(propsRuntimeDefaults, DEFINE_PROPS);
  8432. checkInvalidScopeReference(propsDestructureDecl, DEFINE_PROPS);
  8433. checkInvalidScopeReference(emitsRuntimeDecl, DEFINE_EMITS);
  8434. // 6. remove non-script content
  8435. if (script) {
  8436. if (startOffset < scriptStartOffset) {
  8437. // <script setup> before <script>
  8438. s.remove(0, startOffset);
  8439. s.remove(endOffset, scriptStartOffset);
  8440. s.remove(scriptEndOffset, source.length);
  8441. }
  8442. else {
  8443. // <script> before <script setup>
  8444. s.remove(0, scriptStartOffset);
  8445. s.remove(scriptEndOffset, startOffset);
  8446. s.remove(endOffset, source.length);
  8447. }
  8448. }
  8449. else {
  8450. // only <script setup>
  8451. s.remove(0, startOffset);
  8452. s.remove(endOffset, source.length);
  8453. }
  8454. // 7. analyze binding metadata
  8455. if (scriptAst) {
  8456. Object.assign(bindingMetadata, analyzeScriptBindings(scriptAst.body));
  8457. }
  8458. if (propsRuntimeDecl) {
  8459. for (const key of getObjectOrArrayExpressionKeys(propsRuntimeDecl)) {
  8460. bindingMetadata[key] = "props" /* BindingTypes.PROPS */;
  8461. }
  8462. }
  8463. for (const key in typeDeclaredProps) {
  8464. bindingMetadata[key] = "props" /* BindingTypes.PROPS */;
  8465. }
  8466. // props aliases
  8467. // if (propsDestructureDecl) {
  8468. // if (propsDestructureRestId) {
  8469. // bindingMetadata[propsDestructureRestId] =
  8470. // BindingTypes.SETUP_REACTIVE_CONST
  8471. // }
  8472. // for (const key in propsDestructuredBindings) {
  8473. // const { local } = propsDestructuredBindings[key]
  8474. // if (local !== key) {
  8475. // bindingMetadata[local] = BindingTypes.PROPS_ALIASED
  8476. // ;(bindingMetadata.__propsAliases ||
  8477. // (bindingMetadata.__propsAliases = {}))[local] = key
  8478. // }
  8479. // }
  8480. // }
  8481. for (const [key, { isType, imported, source }] of Object.entries(userImports)) {
  8482. if (isType)
  8483. continue;
  8484. bindingMetadata[key] =
  8485. imported === '*' ||
  8486. (imported === 'default' && source.endsWith('.vue')) ||
  8487. source === 'vue'
  8488. ? "setup-const" /* BindingTypes.SETUP_CONST */
  8489. : "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */;
  8490. }
  8491. for (const key in scriptBindings) {
  8492. bindingMetadata[key] = scriptBindings[key];
  8493. }
  8494. for (const key in setupBindings) {
  8495. bindingMetadata[key] = setupBindings[key];
  8496. }
  8497. // 8. inject `useCssVars` calls
  8498. if (cssVars.length) {
  8499. helperImports.add(CSS_VARS_HELPER);
  8500. s.prependRight(startOffset, `\n${genCssVarsCode(cssVars, bindingMetadata, scopeId, isProd)}\n`);
  8501. }
  8502. // 9. finalize setup() argument signature
  8503. let args = `__props`;
  8504. if (propsTypeDecl) {
  8505. // mark as any and only cast on assignment
  8506. // since the user defined complex types may be incompatible with the
  8507. // inferred type from generated runtime declarations
  8508. args += `: any`;
  8509. }
  8510. // inject user assignment of props
  8511. // we use a default __props so that template expressions referencing props
  8512. // can use it directly
  8513. if (propsIdentifier) {
  8514. s.prependLeft(startOffset, `\nconst ${propsIdentifier} = __props${propsTypeDecl ? ` as ${genSetupPropsType(propsTypeDecl)}` : ``}\n`);
  8515. }
  8516. const destructureElements = hasDefineExposeCall ? [`expose`] : [];
  8517. if (emitIdentifier) {
  8518. destructureElements.push(emitIdentifier === `emit` ? `emit` : `emit: ${emitIdentifier}`);
  8519. }
  8520. if (destructureElements.length) {
  8521. args += `, { ${destructureElements.join(', ')} }`;
  8522. if (emitsTypeDecl) {
  8523. args += `: { emit: (${scriptSetup.content.slice(emitsTypeDecl.start, emitsTypeDecl.end)}), expose: any, slots: any, attrs: any }`;
  8524. }
  8525. }
  8526. // 10. generate return statement
  8527. const allBindings = Object.assign(Object.assign({}, scriptBindings), setupBindings);
  8528. for (const key in userImports) {
  8529. if (!userImports[key].isType && userImports[key].isUsedInTemplate) {
  8530. allBindings[key] = true;
  8531. }
  8532. }
  8533. // __sfc marker indicates these bindings are compiled from <script setup>
  8534. // and should not be proxied on `this`
  8535. const returned = `{ ${`__sfc: true,`}${Object.keys(allBindings).join(', ')} }`;
  8536. s.appendRight(endOffset, `\nreturn ${returned}\n}\n\n`);
  8537. // 11. finalize default export
  8538. let runtimeOptions = ``;
  8539. if (!hasDefaultExportName && filename && filename !== DEFAULT_FILENAME) {
  8540. const match = filename.match(/([^/\\]+)\.\w+$/);
  8541. if (match) {
  8542. runtimeOptions += `\n __name: '${match[1]}',`;
  8543. }
  8544. }
  8545. if (propsRuntimeDecl) {
  8546. let declCode = scriptSetup.content
  8547. .slice(propsRuntimeDecl.start, propsRuntimeDecl.end)
  8548. .trim();
  8549. runtimeOptions += `\n props: ${declCode},`;
  8550. }
  8551. else if (propsTypeDecl) {
  8552. runtimeOptions += genRuntimeProps(typeDeclaredProps);
  8553. }
  8554. if (emitsRuntimeDecl) {
  8555. runtimeOptions += `\n emits: ${scriptSetup.content
  8556. .slice(emitsRuntimeDecl.start, emitsRuntimeDecl.end)
  8557. .trim()},`;
  8558. }
  8559. else if (emitsTypeDecl) {
  8560. runtimeOptions += genRuntimeEmits(typeDeclaredEmits);
  8561. }
  8562. // wrap setup code with function.
  8563. if (isTS) {
  8564. // for TS, make sure the exported type is still valid type with
  8565. // correct props information
  8566. // we have to use object spread for types to be merged properly
  8567. // user's TS setting should compile it down to proper targets
  8568. // export default defineComponent({ ...__default__, ... })
  8569. const def = defaultExport ? `\n ...${DEFAULT_VAR},` : ``;
  8570. s.prependLeft(startOffset, `\nexport default /*#__PURE__*/${helper(`defineComponent`)}({${def}${runtimeOptions}\n setup(${args}) {\n`);
  8571. s.appendRight(endOffset, `})`);
  8572. }
  8573. else {
  8574. if (defaultExport) {
  8575. // without TS, can't rely on rest spread, so we use Object.assign
  8576. // export default Object.assign(__default__, { ... })
  8577. s.prependLeft(startOffset, `\nexport default /*#__PURE__*/Object.assign(${DEFAULT_VAR}, {${runtimeOptions}\n ` +
  8578. `setup(${args}) {\n`);
  8579. s.appendRight(endOffset, `})`);
  8580. }
  8581. else {
  8582. s.prependLeft(startOffset, `\nexport default {${runtimeOptions}\n setup(${args}) {\n`);
  8583. s.appendRight(endOffset, `}`);
  8584. }
  8585. }
  8586. // 12. finalize Vue helper imports
  8587. if (helperImports.size > 0) {
  8588. s.prepend(`import { ${[...helperImports]
  8589. .map(h => `${h} as _${h}`)
  8590. .join(', ')} } from 'vue'\n`);
  8591. }
  8592. s.trim();
  8593. return Object.assign(Object.assign({}, scriptSetup), { bindings: bindingMetadata, imports: userImports, content: s.toString(), map: genSourceMap
  8594. ? s.generateMap({
  8595. source: filename,
  8596. hires: true,
  8597. includeContent: true
  8598. })
  8599. : undefined, scriptAst: scriptAst === null || scriptAst === void 0 ? void 0 : scriptAst.body, scriptSetupAst: scriptSetupAst === null || scriptSetupAst === void 0 ? void 0 : scriptSetupAst.body });
  8600. }
  8601. function registerBinding(bindings, node, type) {
  8602. bindings[node.name] = type;
  8603. }
  8604. function walkDeclaration(node, bindings, userImportAlias) {
  8605. if (node.type === 'VariableDeclaration') {
  8606. const isConst = node.kind === 'const';
  8607. // export const foo = ...
  8608. for (const { id, init } of node.declarations) {
  8609. const isDefineCall = !!(isConst &&
  8610. isCallOf(init, c => c === DEFINE_PROPS || c === DEFINE_EMITS || c === WITH_DEFAULTS));
  8611. if (id.type === 'Identifier') {
  8612. let bindingType;
  8613. const userReactiveBinding = userImportAlias['reactive'] || 'reactive';
  8614. if (isCallOf(init, userReactiveBinding)) {
  8615. // treat reactive() calls as let since it's meant to be mutable
  8616. bindingType = isConst
  8617. ? "setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */
  8618. : "setup-let" /* BindingTypes.SETUP_LET */;
  8619. }
  8620. else if (
  8621. // if a declaration is a const literal, we can mark it so that
  8622. // the generated render fn code doesn't need to unref() it
  8623. isDefineCall ||
  8624. (isConst && canNeverBeRef(init, userReactiveBinding))) {
  8625. bindingType = isCallOf(init, DEFINE_PROPS)
  8626. ? "setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */
  8627. : "setup-const" /* BindingTypes.SETUP_CONST */;
  8628. }
  8629. else if (isConst) {
  8630. if (isCallOf(init, userImportAlias['ref'] || 'ref')) {
  8631. bindingType = "setup-ref" /* BindingTypes.SETUP_REF */;
  8632. }
  8633. else {
  8634. bindingType = "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */;
  8635. }
  8636. }
  8637. else {
  8638. bindingType = "setup-let" /* BindingTypes.SETUP_LET */;
  8639. }
  8640. registerBinding(bindings, id, bindingType);
  8641. }
  8642. else {
  8643. if (isCallOf(init, DEFINE_PROPS)) {
  8644. // skip walking props destructure
  8645. return;
  8646. }
  8647. if (id.type === 'ObjectPattern') {
  8648. walkObjectPattern(id, bindings, isConst, isDefineCall);
  8649. }
  8650. else if (id.type === 'ArrayPattern') {
  8651. walkArrayPattern(id, bindings, isConst, isDefineCall);
  8652. }
  8653. }
  8654. }
  8655. }
  8656. else if (node.type === 'TSEnumDeclaration' ||
  8657. node.type === 'FunctionDeclaration' ||
  8658. node.type === 'ClassDeclaration') {
  8659. // export function foo() {} / export class Foo {}
  8660. // export declarations must be named.
  8661. bindings[node.id.name] = "setup-const" /* BindingTypes.SETUP_CONST */;
  8662. }
  8663. }
  8664. function walkObjectPattern(node, bindings, isConst, isDefineCall = false) {
  8665. for (const p of node.properties) {
  8666. if (p.type === 'ObjectProperty') {
  8667. if (p.key.type === 'Identifier' && p.key === p.value) {
  8668. // shorthand: const { x } = ...
  8669. const type = isDefineCall
  8670. ? "setup-const" /* BindingTypes.SETUP_CONST */
  8671. : isConst
  8672. ? "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */
  8673. : "setup-let" /* BindingTypes.SETUP_LET */;
  8674. registerBinding(bindings, p.key, type);
  8675. }
  8676. else {
  8677. walkPattern(p.value, bindings, isConst, isDefineCall);
  8678. }
  8679. }
  8680. else {
  8681. // ...rest
  8682. // argument can only be identifier when destructuring
  8683. const type = isConst ? "setup-const" /* BindingTypes.SETUP_CONST */ : "setup-let" /* BindingTypes.SETUP_LET */;
  8684. registerBinding(bindings, p.argument, type);
  8685. }
  8686. }
  8687. }
  8688. function walkArrayPattern(node, bindings, isConst, isDefineCall = false) {
  8689. for (const e of node.elements) {
  8690. e && walkPattern(e, bindings, isConst, isDefineCall);
  8691. }
  8692. }
  8693. function walkPattern(node, bindings, isConst, isDefineCall = false) {
  8694. if (node.type === 'Identifier') {
  8695. const type = isDefineCall
  8696. ? "setup-const" /* BindingTypes.SETUP_CONST */
  8697. : isConst
  8698. ? "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */
  8699. : "setup-let" /* BindingTypes.SETUP_LET */;
  8700. registerBinding(bindings, node, type);
  8701. }
  8702. else if (node.type === 'RestElement') {
  8703. // argument can only be identifier when destructuring
  8704. const type = isConst ? "setup-const" /* BindingTypes.SETUP_CONST */ : "setup-let" /* BindingTypes.SETUP_LET */;
  8705. registerBinding(bindings, node.argument, type);
  8706. }
  8707. else if (node.type === 'ObjectPattern') {
  8708. walkObjectPattern(node, bindings, isConst);
  8709. }
  8710. else if (node.type === 'ArrayPattern') {
  8711. walkArrayPattern(node, bindings, isConst);
  8712. }
  8713. else if (node.type === 'AssignmentPattern') {
  8714. if (node.left.type === 'Identifier') {
  8715. const type = isDefineCall
  8716. ? "setup-const" /* BindingTypes.SETUP_CONST */
  8717. : isConst
  8718. ? "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */
  8719. : "setup-let" /* BindingTypes.SETUP_LET */;
  8720. registerBinding(bindings, node.left, type);
  8721. }
  8722. else {
  8723. walkPattern(node.left, bindings, isConst);
  8724. }
  8725. }
  8726. }
  8727. function recordType(node, declaredTypes) {
  8728. if (node.type === 'TSInterfaceDeclaration') {
  8729. declaredTypes[node.id.name] = [`Object`];
  8730. }
  8731. else if (node.type === 'TSTypeAliasDeclaration') {
  8732. declaredTypes[node.id.name] = inferRuntimeType(node.typeAnnotation, declaredTypes);
  8733. }
  8734. else if (node.type === 'ExportNamedDeclaration' && node.declaration) {
  8735. recordType(node.declaration, declaredTypes);
  8736. }
  8737. }
  8738. function extractRuntimeProps(node, props, declaredTypes, isProd) {
  8739. const members = node.type === 'TSTypeLiteral' ? node.members : node.body;
  8740. for (const m of members) {
  8741. if ((m.type === 'TSPropertySignature' || m.type === 'TSMethodSignature') &&
  8742. m.key.type === 'Identifier') {
  8743. let type;
  8744. if (m.type === 'TSMethodSignature') {
  8745. type = ['Function'];
  8746. }
  8747. else if (m.typeAnnotation) {
  8748. type = inferRuntimeType(m.typeAnnotation.typeAnnotation, declaredTypes);
  8749. }
  8750. props[m.key.name] = {
  8751. key: m.key.name,
  8752. required: !m.optional,
  8753. type: type || [`null`]
  8754. };
  8755. }
  8756. }
  8757. }
  8758. function inferRuntimeType(node, declaredTypes) {
  8759. switch (node.type) {
  8760. case 'TSStringKeyword':
  8761. return ['String'];
  8762. case 'TSNumberKeyword':
  8763. return ['Number'];
  8764. case 'TSBooleanKeyword':
  8765. return ['Boolean'];
  8766. case 'TSObjectKeyword':
  8767. return ['Object'];
  8768. case 'TSTypeLiteral':
  8769. // TODO (nice to have) generate runtime property validation
  8770. return ['Object'];
  8771. case 'TSFunctionType':
  8772. return ['Function'];
  8773. case 'TSArrayType':
  8774. case 'TSTupleType':
  8775. // TODO (nice to have) generate runtime element type/length checks
  8776. return ['Array'];
  8777. case 'TSLiteralType':
  8778. switch (node.literal.type) {
  8779. case 'StringLiteral':
  8780. return ['String'];
  8781. case 'BooleanLiteral':
  8782. return ['Boolean'];
  8783. case 'NumericLiteral':
  8784. case 'BigIntLiteral':
  8785. return ['Number'];
  8786. default:
  8787. return [`null`];
  8788. }
  8789. case 'TSTypeReference':
  8790. if (node.typeName.type === 'Identifier') {
  8791. if (declaredTypes[node.typeName.name]) {
  8792. return declaredTypes[node.typeName.name];
  8793. }
  8794. switch (node.typeName.name) {
  8795. case 'Array':
  8796. case 'Function':
  8797. case 'Object':
  8798. case 'Set':
  8799. case 'Map':
  8800. case 'WeakSet':
  8801. case 'WeakMap':
  8802. case 'Date':
  8803. case 'Promise':
  8804. return [node.typeName.name];
  8805. case 'Record':
  8806. case 'Partial':
  8807. case 'Readonly':
  8808. case 'Pick':
  8809. case 'Omit':
  8810. case 'Exclude':
  8811. case 'Extract':
  8812. case 'Required':
  8813. case 'InstanceType':
  8814. return ['Object'];
  8815. }
  8816. }
  8817. return [`null`];
  8818. case 'TSParenthesizedType':
  8819. return inferRuntimeType(node.typeAnnotation, declaredTypes);
  8820. case 'TSUnionType':
  8821. return [
  8822. ...new Set([].concat(...node.types.map(t => inferRuntimeType(t, declaredTypes))))
  8823. ];
  8824. case 'TSIntersectionType':
  8825. return ['Object'];
  8826. case 'TSSymbolKeyword':
  8827. return ['Symbol'];
  8828. default:
  8829. return [`null`]; // no runtime check
  8830. }
  8831. }
  8832. function toRuntimeTypeString(types) {
  8833. return types.length > 1 ? `[${types.join(', ')}]` : types[0];
  8834. }
  8835. function extractRuntimeEmits(node, emits) {
  8836. if (node.type === 'TSTypeLiteral' || node.type === 'TSInterfaceBody') {
  8837. const members = node.type === 'TSTypeLiteral' ? node.members : node.body;
  8838. for (let t of members) {
  8839. if (t.type === 'TSCallSignatureDeclaration') {
  8840. extractEventNames(t.parameters[0], emits);
  8841. }
  8842. }
  8843. return;
  8844. }
  8845. else {
  8846. extractEventNames(node.parameters[0], emits);
  8847. }
  8848. }
  8849. function extractEventNames(eventName, emits) {
  8850. if (eventName.type === 'Identifier' &&
  8851. eventName.typeAnnotation &&
  8852. eventName.typeAnnotation.type === 'TSTypeAnnotation') {
  8853. const typeNode = eventName.typeAnnotation.typeAnnotation;
  8854. if (typeNode.type === 'TSLiteralType') {
  8855. if (typeNode.literal.type !== 'UnaryExpression' &&
  8856. typeNode.literal.type !== 'TemplateLiteral') {
  8857. emits.add(String(typeNode.literal.value));
  8858. }
  8859. }
  8860. else if (typeNode.type === 'TSUnionType') {
  8861. for (const t of typeNode.types) {
  8862. if (t.type === 'TSLiteralType' &&
  8863. t.literal.type !== 'UnaryExpression' &&
  8864. t.literal.type !== 'TemplateLiteral') {
  8865. emits.add(String(t.literal.value));
  8866. }
  8867. }
  8868. }
  8869. }
  8870. }
  8871. function genRuntimeEmits(emits) {
  8872. return emits.size
  8873. ? `\n emits: [${Array.from(emits)
  8874. .map(p => JSON.stringify(p))
  8875. .join(', ')}],`
  8876. : ``;
  8877. }
  8878. function isCallOf(node, test) {
  8879. return !!(node &&
  8880. node.type === 'CallExpression' &&
  8881. node.callee.type === 'Identifier' &&
  8882. (typeof test === 'string'
  8883. ? node.callee.name === test
  8884. : test(node.callee.name)));
  8885. }
  8886. function canNeverBeRef(node, userReactiveImport) {
  8887. if (isCallOf(node, userReactiveImport)) {
  8888. return true;
  8889. }
  8890. switch (node.type) {
  8891. case 'UnaryExpression':
  8892. case 'BinaryExpression':
  8893. case 'ArrayExpression':
  8894. case 'ObjectExpression':
  8895. case 'FunctionExpression':
  8896. case 'ArrowFunctionExpression':
  8897. case 'UpdateExpression':
  8898. case 'ClassExpression':
  8899. case 'TaggedTemplateExpression':
  8900. return true;
  8901. case 'SequenceExpression':
  8902. return canNeverBeRef(node.expressions[node.expressions.length - 1], userReactiveImport);
  8903. default:
  8904. if (node.type.endsWith('Literal')) {
  8905. return true;
  8906. }
  8907. return false;
  8908. }
  8909. }
  8910. /**
  8911. * Analyze bindings in normal `<script>`
  8912. * Note that `compileScriptSetup` already analyzes bindings as part of its
  8913. * compilation process so this should only be used on single `<script>` SFCs.
  8914. */
  8915. function analyzeScriptBindings(ast) {
  8916. for (const node of ast) {
  8917. if (node.type === 'ExportDefaultDeclaration' &&
  8918. node.declaration.type === 'ObjectExpression') {
  8919. return analyzeBindingsFromOptions(node.declaration);
  8920. }
  8921. }
  8922. return {};
  8923. }
  8924. function analyzeBindingsFromOptions(node) {
  8925. const bindings = {};
  8926. // #3270, #3275
  8927. // mark non-script-setup so we don't resolve components/directives from these
  8928. Object.defineProperty(bindings, '__isScriptSetup', {
  8929. enumerable: false,
  8930. value: false
  8931. });
  8932. for (const property of node.properties) {
  8933. if (property.type === 'ObjectProperty' &&
  8934. !property.computed &&
  8935. property.key.type === 'Identifier') {
  8936. // props
  8937. if (property.key.name === 'props') {
  8938. // props: ['foo']
  8939. // props: { foo: ... }
  8940. for (const key of getObjectOrArrayExpressionKeys(property.value)) {
  8941. bindings[key] = "props" /* BindingTypes.PROPS */;
  8942. }
  8943. }
  8944. // inject
  8945. else if (property.key.name === 'inject') {
  8946. // inject: ['foo']
  8947. // inject: { foo: {} }
  8948. for (const key of getObjectOrArrayExpressionKeys(property.value)) {
  8949. bindings[key] = "options" /* BindingTypes.OPTIONS */;
  8950. }
  8951. }
  8952. // computed & methods
  8953. else if (property.value.type === 'ObjectExpression' &&
  8954. (property.key.name === 'computed' || property.key.name === 'methods')) {
  8955. // methods: { foo() {} }
  8956. // computed: { foo() {} }
  8957. for (const key of getObjectExpressionKeys(property.value)) {
  8958. bindings[key] = "options" /* BindingTypes.OPTIONS */;
  8959. }
  8960. }
  8961. }
  8962. // setup & data
  8963. else if (property.type === 'ObjectMethod' &&
  8964. property.key.type === 'Identifier' &&
  8965. (property.key.name === 'setup' || property.key.name === 'data')) {
  8966. for (const bodyItem of property.body.body) {
  8967. // setup() {
  8968. // return {
  8969. // foo: null
  8970. // }
  8971. // }
  8972. if (bodyItem.type === 'ReturnStatement' &&
  8973. bodyItem.argument &&
  8974. bodyItem.argument.type === 'ObjectExpression') {
  8975. for (const key of getObjectExpressionKeys(bodyItem.argument)) {
  8976. bindings[key] =
  8977. property.key.name === 'setup'
  8978. ? "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */
  8979. : "data" /* BindingTypes.DATA */;
  8980. }
  8981. }
  8982. }
  8983. }
  8984. }
  8985. return bindings;
  8986. }
  8987. function getObjectExpressionKeys(node) {
  8988. const keys = [];
  8989. for (const prop of node.properties) {
  8990. if ((prop.type === 'ObjectProperty' || prop.type === 'ObjectMethod') &&
  8991. !prop.computed) {
  8992. if (prop.key.type === 'Identifier') {
  8993. keys.push(prop.key.name);
  8994. }
  8995. else if (prop.key.type === 'StringLiteral') {
  8996. keys.push(prop.key.value);
  8997. }
  8998. }
  8999. }
  9000. return keys;
  9001. }
  9002. function getArrayExpressionKeys(node) {
  9003. const keys = [];
  9004. for (const element of node.elements) {
  9005. if (element && element.type === 'StringLiteral') {
  9006. keys.push(element.value);
  9007. }
  9008. }
  9009. return keys;
  9010. }
  9011. function getObjectOrArrayExpressionKeys(value) {
  9012. if (value.type === 'ArrayExpression') {
  9013. return getArrayExpressionKeys(value);
  9014. }
  9015. if (value.type === 'ObjectExpression') {
  9016. return getObjectExpressionKeys(value);
  9017. }
  9018. return [];
  9019. }
  9020. const templateUsageCheckCache = new lruCache(512);
  9021. function resolveTemplateUsageCheckString(sfc, isTS) {
  9022. const { content } = sfc.template;
  9023. const cached = templateUsageCheckCache.get(content);
  9024. if (cached) {
  9025. return cached;
  9026. }
  9027. let code = '';
  9028. parseHTML(content, Object.assign(Object.assign({}, baseOptions), { start(tag, attrs) {
  9029. if (!isBuiltInTag(tag) && !isReservedTag(tag)) {
  9030. code += `,${camelize(tag)},${capitalize(camelize(tag))}`;
  9031. }
  9032. for (let i = 0; i < attrs.length; i++) {
  9033. const { name, value } = attrs[i];
  9034. if (dirRE.test(name)) {
  9035. const baseName = onRE.test(name)
  9036. ? 'on'
  9037. : bindRE.test(name)
  9038. ? 'bind'
  9039. : name.replace(dirRE, '');
  9040. if (!isBuiltInDir$1(baseName)) {
  9041. code += `,v${capitalize(camelize(baseName))}`;
  9042. }
  9043. if (value) {
  9044. code += `,${processExp(value, isTS, baseName)}`;
  9045. }
  9046. }
  9047. }
  9048. },
  9049. chars(text) {
  9050. const res = parseText(text);
  9051. if (res) {
  9052. code += `,${processExp(res.expression, isTS)}`;
  9053. }
  9054. } }));
  9055. code += ';';
  9056. templateUsageCheckCache.set(content, code);
  9057. return code;
  9058. }
  9059. const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  9060. function processExp(exp, isTS, dir) {
  9061. if (isTS && / as\s+\w|<.*>|:/.test(exp)) {
  9062. if (dir === 'slot') {
  9063. exp = `(${exp})=>{}`;
  9064. }
  9065. else if (dir === 'on') {
  9066. exp = `()=>{${exp}}`;
  9067. }
  9068. else if (dir === 'for') {
  9069. const inMatch = exp.match(forAliasRE);
  9070. if (inMatch) {
  9071. const [, LHS, RHS] = inMatch;
  9072. return processExp(`(${LHS})=>{}`, true) + processExp(RHS, true);
  9073. }
  9074. }
  9075. let ret = '';
  9076. // has potential type cast or generic arguments that uses types
  9077. const ast = parser$1.parseExpression(exp, { plugins: ['typescript'] });
  9078. walkIdentifiers(ast, node => {
  9079. ret += `,` + node.name;
  9080. });
  9081. return ret;
  9082. }
  9083. return stripStrings(exp);
  9084. }
  9085. function stripStrings(exp) {
  9086. return exp
  9087. .replace(/'[^']*'|"[^"]*"/g, '')
  9088. .replace(/`[^`]+`/g, stripTemplateString);
  9089. }
  9090. function stripTemplateString(str) {
  9091. const interpMatch = str.match(/\${[^}]+}/g);
  9092. if (interpMatch) {
  9093. return interpMatch.map(m => m.slice(2, -1)).join(',');
  9094. }
  9095. return '';
  9096. }
  9097. function isImportUsed(local, sfc, isTS) {
  9098. return new RegExp(
  9099. // #4274 escape $ since it's a special char in regex
  9100. // (and is the only regex special char that is valid in identifiers)
  9101. `[^\\w$_]${local.replace(/\$/g, '\\$')}[^\\w$_]`).test(resolveTemplateUsageCheckString(sfc, isTS));
  9102. }
  9103. /**
  9104. * Note: this comparison assumes the prev/next script are already identical,
  9105. * and only checks the special case where <script setup> unused import
  9106. * pruning result changes due to template changes.
  9107. */
  9108. function hmrShouldReload(prevImports, next) {
  9109. if (!next.scriptSetup) {
  9110. return false;
  9111. }
  9112. const isTS = next.scriptSetup.lang === 'ts' || next.scriptSetup.lang === 'tsx';
  9113. // for each previous import, check if its used status remain the same based on
  9114. // the next descriptor's template
  9115. for (const key in prevImports) {
  9116. // if an import was previous unused, but now is used, we need to force
  9117. // reload so that the script now includes that import.
  9118. if (!prevImports[key].isUsedInTemplate && isImportUsed(key, next, isTS)) {
  9119. return true;
  9120. }
  9121. }
  9122. return false;
  9123. }
  9124. const cache = new lruCache(100);
  9125. const splitRE = /\r?\n/g;
  9126. const emptyRE = /^(?:\/\/)?\s*$/;
  9127. function parse(options) {
  9128. const { source, filename = DEFAULT_FILENAME, compiler, compilerParseOptions = { pad: false }, sourceRoot = '', needMap = true, sourceMap = needMap } = options;
  9129. const cacheKey = hashSum(filename + source + JSON.stringify(compilerParseOptions));
  9130. let output = cache.get(cacheKey);
  9131. if (output) {
  9132. return output;
  9133. }
  9134. if (compiler) {
  9135. // user-provided compiler
  9136. output = compiler.parseComponent(source, compilerParseOptions);
  9137. }
  9138. else {
  9139. // use built-in compiler
  9140. output = parseComponent(source, compilerParseOptions);
  9141. }
  9142. output.filename = filename;
  9143. // parse CSS vars
  9144. output.cssVars = parseCssVars(output);
  9145. output.shouldForceReload = prevImports => hmrShouldReload(prevImports, output);
  9146. if (sourceMap) {
  9147. if (output.script && !output.script.src) {
  9148. output.script.map = generateSourceMap(filename, source, output.script.content, sourceRoot, compilerParseOptions.pad);
  9149. }
  9150. if (output.styles) {
  9151. output.styles.forEach(style => {
  9152. if (!style.src) {
  9153. style.map = generateSourceMap(filename, source, style.content, sourceRoot, compilerParseOptions.pad);
  9154. }
  9155. });
  9156. }
  9157. }
  9158. cache.set(cacheKey, output);
  9159. return output;
  9160. }
  9161. function generateSourceMap(filename, source, generated, sourceRoot, pad) {
  9162. const map = new require$$0.SourceMapGenerator({
  9163. file: filename.replace(/\\/g, '/'),
  9164. sourceRoot: sourceRoot.replace(/\\/g, '/')
  9165. });
  9166. let offset = 0;
  9167. if (!pad) {
  9168. offset = source.split(generated).shift().split(splitRE).length - 1;
  9169. }
  9170. map.setSourceContent(filename, source);
  9171. generated.split(splitRE).forEach((line, index) => {
  9172. if (!emptyRE.test(line)) {
  9173. map.addMapping({
  9174. source: filename,
  9175. original: {
  9176. line: index + 1 + offset,
  9177. column: 0
  9178. },
  9179. generated: {
  9180. line: index + 1,
  9181. column: 0
  9182. }
  9183. });
  9184. }
  9185. });
  9186. return JSON.parse(map.toString());
  9187. }
  9188. function urlToRequire(url, transformAssetUrlsOption = {}) {
  9189. const returnValue = `"${url}"`;
  9190. // same logic as in transform-require.js
  9191. const firstChar = url.charAt(0);
  9192. if (firstChar === '~') {
  9193. const secondChar = url.charAt(1);
  9194. url = url.slice(secondChar === '/' ? 2 : 1);
  9195. }
  9196. if (isExternalUrl(url) || isDataUrl(url) || firstChar === '#') {
  9197. return returnValue;
  9198. }
  9199. const uriParts = parseUriParts(url);
  9200. if (transformAssetUrlsOption.base) {
  9201. // explicit base - directly rewrite the url into absolute url
  9202. // does not apply to absolute urls or urls that start with `@`
  9203. // since they are aliases
  9204. if (firstChar === '.' || firstChar === '~') {
  9205. // Allow for full hostnames provided in options.base
  9206. const base = parseUriParts(transformAssetUrlsOption.base);
  9207. const protocol = base.protocol || '';
  9208. const host = base.host ? protocol + '//' + base.host : '';
  9209. const basePath = base.path || '/';
  9210. // when packaged in the browser, path will be using the posix-
  9211. // only version provided by rollup-plugin-node-builtins.
  9212. return `"${host}${(path__default["default"].posix || path__default["default"]).join(basePath, uriParts.path + (uriParts.hash || ''))}"`;
  9213. }
  9214. }
  9215. if (transformAssetUrlsOption.includeAbsolute ||
  9216. firstChar === '.' ||
  9217. firstChar === '~' ||
  9218. firstChar === '@') {
  9219. if (!uriParts.hash) {
  9220. return `require("${url}")`;
  9221. }
  9222. else {
  9223. // support uri fragment case by excluding it from
  9224. // the require and instead appending it as string;
  9225. // assuming that the path part is sufficient according to
  9226. // the above caseing(t.i. no protocol-auth-host parts expected)
  9227. return `require("${uriParts.path}") + "${uriParts.hash}"`;
  9228. }
  9229. }
  9230. return returnValue;
  9231. }
  9232. /**
  9233. * vuejs/component-compiler-utils#22 Support uri fragment in transformed require
  9234. * @param urlString an url as a string
  9235. */
  9236. function parseUriParts(urlString) {
  9237. // initialize return value
  9238. const returnValue = url.parse('');
  9239. if (urlString) {
  9240. // A TypeError is thrown if urlString is not a string
  9241. // @see https://nodejs.org/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost
  9242. if ('string' === typeof urlString) {
  9243. // check is an uri
  9244. return url.parse(urlString, false, true); // take apart the uri
  9245. }
  9246. }
  9247. return returnValue;
  9248. }
  9249. const externalRE = /^(https?:)?\/\//;
  9250. function isExternalUrl(url) {
  9251. return externalRE.test(url);
  9252. }
  9253. const dataUrlRE = /^\s*data:/i;
  9254. function isDataUrl(url) {
  9255. return dataUrlRE.test(url);
  9256. }
  9257. // vue compiler module for transforming `<tag>:<attribute>` to `require`
  9258. const defaultOptions = {
  9259. audio: 'src',
  9260. video: ['src', 'poster'],
  9261. source: 'src',
  9262. img: 'src',
  9263. image: ['xlink:href', 'href'],
  9264. use: ['xlink:href', 'href']
  9265. };
  9266. var assetUrlsModule = (userOptions, transformAssetUrlsOption) => {
  9267. const options = userOptions
  9268. ? Object.assign({}, defaultOptions, userOptions)
  9269. : defaultOptions;
  9270. return {
  9271. postTransformNode: (node) => {
  9272. transform$1(node, options, transformAssetUrlsOption);
  9273. }
  9274. };
  9275. };
  9276. function transform$1(node, options, transformAssetUrlsOption) {
  9277. if (node.type !== 1 || !node.attrs)
  9278. return;
  9279. for (const tag in options) {
  9280. if (tag === '*' || node.tag === tag) {
  9281. const attributes = options[tag];
  9282. if (typeof attributes === 'string') {
  9283. node.attrs.some(attr => rewrite(attr, attributes, transformAssetUrlsOption));
  9284. }
  9285. else if (Array.isArray(attributes)) {
  9286. attributes.forEach(item => node.attrs.some(attr => rewrite(attr, item, transformAssetUrlsOption)));
  9287. }
  9288. }
  9289. }
  9290. }
  9291. function rewrite(attr, name, transformAssetUrlsOption) {
  9292. if (attr.name === name) {
  9293. const value = attr.value;
  9294. // only transform static URLs
  9295. if (value.charAt(0) === '"' && value.charAt(value.length - 1) === '"') {
  9296. attr.value = urlToRequire(value.slice(1, -1), transformAssetUrlsOption);
  9297. return true;
  9298. }
  9299. }
  9300. return false;
  9301. }
  9302. // vue compiler module for transforming `img:srcset` to a number of `require`s
  9303. var srcsetModule = (transformAssetUrlsOptions) => ({
  9304. postTransformNode: (node) => {
  9305. transform(node, transformAssetUrlsOptions);
  9306. }
  9307. });
  9308. // http://w3c.github.io/html/semantics-embedded-content.html#ref-for-image-candidate-string-5
  9309. const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g;
  9310. function transform(node, transformAssetUrlsOptions) {
  9311. if (node.type !== 1 || !node.attrs) {
  9312. return;
  9313. }
  9314. if (node.tag === 'img' || node.tag === 'source') {
  9315. node.attrs.forEach(attr => {
  9316. if (attr.name === 'srcset') {
  9317. // same logic as in transform-require.js
  9318. const value = attr.value;
  9319. const isStatic = value.charAt(0) === '"' && value.charAt(value.length - 1) === '"';
  9320. if (!isStatic) {
  9321. return;
  9322. }
  9323. const imageCandidates = value
  9324. .slice(1, -1)
  9325. .split(',')
  9326. .map(s => {
  9327. // The attribute value arrives here with all whitespace, except
  9328. // normal spaces, represented by escape sequences
  9329. const [url, descriptor] = s
  9330. .replace(escapedSpaceCharacters, ' ')
  9331. .trim()
  9332. .split(' ', 2);
  9333. return {
  9334. require: urlToRequire(url, transformAssetUrlsOptions),
  9335. descriptor
  9336. };
  9337. });
  9338. // "require(url1)"
  9339. // "require(url1) 1x"
  9340. // "require(url1), require(url2)"
  9341. // "require(url1), require(url2) 2x"
  9342. // "require(url1) 1x, require(url2)"
  9343. // "require(url1) 1x, require(url2) 2x"
  9344. const code = imageCandidates
  9345. .map(({ require, descriptor }) => `${require} + "${descriptor ? ' ' + descriptor : ''}, " + `)
  9346. .join('')
  9347. .slice(0, -6)
  9348. .concat('"')
  9349. .replace(/ \+ ""$/, '');
  9350. attr.value = code;
  9351. }
  9352. });
  9353. }
  9354. }
  9355. var consolidate$2 = {exports: {}};
  9356. function commonjsRequire(path) {
  9357. throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
  9358. }
  9359. var consolidate$1 = {exports: {}};
  9360. (function (module, exports) {
  9361. /*
  9362. * Engines which do not support caching of their file contents
  9363. * should use the `read()` function defined in consolidate.js
  9364. * On top of this, when an engine compiles to a `Function`,
  9365. * these functions should either be cached within consolidate.js
  9366. * or the engine itself via `options.cache`. This will allow
  9367. * users and frameworks to pass `options.cache = true` for
  9368. * `NODE_ENV=production`, however edit the file(s) without
  9369. * re-loading the application in development.
  9370. */
  9371. /**
  9372. * Module dependencies.
  9373. */
  9374. var fs = require$$0__default["default"];
  9375. var path = path__default["default"];
  9376. var util = require$$2__default["default"];
  9377. var join = path.join;
  9378. var resolve = path.resolve;
  9379. var extname = path.extname;
  9380. var dirname = path.dirname;
  9381. var isAbsolute = path.isAbsolute;
  9382. var readCache = {};
  9383. /**
  9384. * Require cache.
  9385. */
  9386. var cacheStore = {};
  9387. /**
  9388. * Require cache.
  9389. */
  9390. var requires = {};
  9391. /**
  9392. * Clear the cache.
  9393. *
  9394. * @api public
  9395. */
  9396. exports.clearCache = function() {
  9397. readCache = {};
  9398. cacheStore = {};
  9399. };
  9400. /**
  9401. * Conditionally cache `compiled` template based
  9402. * on the `options` filename and `.cache` boolean.
  9403. *
  9404. * @param {Object} options
  9405. * @param {Function} compiled
  9406. * @return {Function}
  9407. * @api private
  9408. */
  9409. function cache(options, compiled) {
  9410. // cachable
  9411. if (compiled && options.filename && options.cache) {
  9412. delete readCache[options.filename];
  9413. cacheStore[options.filename] = compiled;
  9414. return compiled;
  9415. }
  9416. // check cache
  9417. if (options.filename && options.cache) {
  9418. return cacheStore[options.filename];
  9419. }
  9420. return compiled;
  9421. }
  9422. /**
  9423. * Read `path` with `options` with
  9424. * callback `(err, str)`. When `options.cache`
  9425. * is true the template string will be cached.
  9426. *
  9427. * @param {String} options
  9428. * @param {Function} cb
  9429. * @api private
  9430. */
  9431. function read(path, options, cb) {
  9432. var str = readCache[path];
  9433. var cached = options.cache && str && typeof str === 'string';
  9434. // cached (only if cached is a string and not a compiled template function)
  9435. if (cached) return cb(null, str);
  9436. // read
  9437. fs.readFile(path, 'utf8', function(err, str) {
  9438. if (err) return cb(err);
  9439. // remove extraneous utf8 BOM marker
  9440. str = str.replace(/^\uFEFF/, '');
  9441. if (options.cache) readCache[path] = str;
  9442. cb(null, str);
  9443. });
  9444. }
  9445. /**
  9446. * Read `path` with `options` with
  9447. * callback `(err, str)`. When `options.cache`
  9448. * is true the partial string will be cached.
  9449. *
  9450. * @param {String} options
  9451. * @param {Function} fn
  9452. * @api private
  9453. */
  9454. function readPartials(path, options, cb) {
  9455. if (!options.partials) return cb();
  9456. var keys = Object.keys(options.partials);
  9457. var partials = {};
  9458. function next(index) {
  9459. if (index === keys.length) return cb(null, partials);
  9460. var key = keys[index];
  9461. var partialPath = options.partials[key];
  9462. if (partialPath === undefined || partialPath === null || partialPath === false) {
  9463. return next(++index);
  9464. }
  9465. var file;
  9466. if (isAbsolute(partialPath)) {
  9467. if (extname(partialPath) !== '') {
  9468. file = partialPath;
  9469. } else {
  9470. file = join(partialPath + extname(path));
  9471. }
  9472. } else {
  9473. file = join(dirname(path), partialPath + extname(path));
  9474. }
  9475. read(file, options, function(err, str) {
  9476. if (err) return cb(err);
  9477. partials[key] = str;
  9478. next(++index);
  9479. });
  9480. }
  9481. next(0);
  9482. }
  9483. /**
  9484. * promisify
  9485. */
  9486. function promisify(cb, fn) {
  9487. return new Promise(function(resolve, reject) {
  9488. cb = cb || function(err, html) {
  9489. if (err) {
  9490. return reject(err);
  9491. }
  9492. resolve(html);
  9493. };
  9494. fn(cb);
  9495. });
  9496. }
  9497. /**
  9498. * fromStringRenderer
  9499. */
  9500. function fromStringRenderer(name) {
  9501. return function(path, options, cb) {
  9502. options.filename = path;
  9503. return promisify(cb, function(cb) {
  9504. readPartials(path, options, function(err, partials) {
  9505. var extend = (requires.extend || (requires.extend = require$$2__default["default"]._extend));
  9506. var opts = extend({}, options);
  9507. opts.partials = partials;
  9508. if (err) return cb(err);
  9509. if (cache(opts)) {
  9510. exports[name].render('', opts, cb);
  9511. } else {
  9512. read(path, opts, function(err, str) {
  9513. if (err) return cb(err);
  9514. exports[name].render(str, opts, cb);
  9515. });
  9516. }
  9517. });
  9518. });
  9519. };
  9520. }
  9521. /**
  9522. * velocity support.
  9523. */
  9524. exports.velocityjs = fromStringRenderer('velocityjs');
  9525. /**
  9526. * velocity string support.
  9527. */
  9528. exports.velocityjs.render = function(str, options, cb) {
  9529. return promisify(cb, function(cb) {
  9530. var engine = requires.velocityjs || (requires.velocityjs = require('velocityjs'));
  9531. try {
  9532. options.locals = options;
  9533. cb(null, engine.render(str, options).trimLeft());
  9534. } catch (err) {
  9535. cb(err);
  9536. }
  9537. });
  9538. };
  9539. /**
  9540. * Liquid support.
  9541. */
  9542. exports.liquid = fromStringRenderer('liquid');
  9543. /**
  9544. * Liquid string support.
  9545. */
  9546. /**
  9547. * Note that in order to get filters and custom tags we've had to push
  9548. * all user-defined locals down into @locals. However, just to make things
  9549. * backwards-compatible, any property of `options` that is left after
  9550. * processing and removing `locals`, `meta`, `filters`, `customTags` and
  9551. * `includeDir` will also become a local.
  9552. */
  9553. function _renderTinyliquid(engine, str, options, cb) {
  9554. var context = engine.newContext();
  9555. var k;
  9556. /**
  9557. * Note that there's a bug in the library that doesn't allow us to pass
  9558. * the locals to newContext(), hence looping through the keys:
  9559. */
  9560. if (options.locals) {
  9561. for (k in options.locals) {
  9562. context.setLocals(k, options.locals[k]);
  9563. }
  9564. delete options.locals;
  9565. }
  9566. if (options.meta) {
  9567. context.setLocals('page', options.meta);
  9568. delete options.meta;
  9569. }
  9570. /**
  9571. * Add any defined filters:
  9572. */
  9573. if (options.filters) {
  9574. for (k in options.filters) {
  9575. context.setFilter(k, options.filters[k]);
  9576. }
  9577. delete options.filters;
  9578. }
  9579. /**
  9580. * Set up a callback for the include directory:
  9581. */
  9582. var includeDir = options.includeDir || process.cwd();
  9583. context.onInclude(function(name, callback) {
  9584. var extname = path.extname(name) ? '' : '.liquid';
  9585. var filename = path.resolve(includeDir, name + extname);
  9586. fs.readFile(filename, {encoding: 'utf8'}, function(err, data) {
  9587. if (err) return callback(err);
  9588. callback(null, engine.parse(data));
  9589. });
  9590. });
  9591. delete options.includeDir;
  9592. /**
  9593. * The custom tag functions need to have their results pushed back
  9594. * through the parser, so set up a shim before calling the provided
  9595. * callback:
  9596. */
  9597. var compileOptions = {
  9598. customTags: {}
  9599. };
  9600. if (options.customTags) {
  9601. var tagFunctions = options.customTags;
  9602. for (k in options.customTags) {
  9603. /*Tell jshint there's no problem with having this function in the loop */
  9604. /*jshint -W083 */
  9605. compileOptions.customTags[k] = function(context, name, body) {
  9606. var tpl = tagFunctions[name](body.trim());
  9607. context.astStack.push(engine.parse(tpl));
  9608. };
  9609. /*jshint +W083 */
  9610. }
  9611. delete options.customTags;
  9612. }
  9613. /**
  9614. * Now anything left in `options` becomes a local:
  9615. */
  9616. for (k in options) {
  9617. context.setLocals(k, options[k]);
  9618. }
  9619. /**
  9620. * Finally, execute the template:
  9621. */
  9622. var tmpl = cache(context) || cache(context, engine.compile(str, compileOptions));
  9623. tmpl(context, cb);
  9624. }
  9625. exports.liquid.render = function(str, options, cb) {
  9626. return promisify(cb, function(cb) {
  9627. var engine = requires.liquid;
  9628. var Liquid;
  9629. try {
  9630. // set up tinyliquid engine
  9631. engine = requires.liquid = require('tinyliquid');
  9632. // use tinyliquid engine
  9633. _renderTinyliquid(engine, str, options, cb);
  9634. return;
  9635. } catch (err) {
  9636. // set up liquid-node engine
  9637. try {
  9638. Liquid = requires.liquid = require('liquid-node');
  9639. engine = new Liquid.Engine();
  9640. } catch (err) {
  9641. throw err;
  9642. }
  9643. }
  9644. // use liquid-node engine
  9645. try {
  9646. var locals = options.locals || {};
  9647. if (options.meta) {
  9648. locals.pages = options.meta;
  9649. delete options.meta;
  9650. }
  9651. /**
  9652. * Add any defined filters:
  9653. */
  9654. if (options.filters) {
  9655. engine.registerFilters(options.filters);
  9656. delete options.filters;
  9657. }
  9658. /**
  9659. * Set up a callback for the include directory:
  9660. */
  9661. var includeDir = options.includeDir || process.cwd();
  9662. engine.fileSystem = new Liquid.LocalFileSystem(includeDir, 'liquid');
  9663. delete options.includeDir;
  9664. /**
  9665. * The custom tag functions need to have their results pushed back
  9666. * through the parser, so set up a shim before calling the provided
  9667. * callback:
  9668. */
  9669. if (options.customTags) {
  9670. var tagFunctions = options.customTags;
  9671. for (k in options.customTags) {
  9672. engine.registerTag(k, tagFunctions[k]);
  9673. }
  9674. delete options.customTags;
  9675. }
  9676. /**
  9677. * Now anything left in `options` becomes a local:
  9678. */
  9679. for (var k in options) {
  9680. locals[k] = options[k];
  9681. }
  9682. /**
  9683. * Finally, execute the template:
  9684. */
  9685. return engine
  9686. .parseAndRender(str, locals)
  9687. .nodeify(function(err, result) {
  9688. if (err) {
  9689. throw new Error(err);
  9690. } else {
  9691. return cb(null, result);
  9692. }
  9693. });
  9694. } catch (err) {
  9695. cb(err);
  9696. }
  9697. });
  9698. };
  9699. /**
  9700. * Jade support.
  9701. */
  9702. exports.jade = function(path, options, cb) {
  9703. return promisify(cb, function(cb) {
  9704. var engine = requires.jade;
  9705. if (!engine) {
  9706. try {
  9707. engine = requires.jade = require('jade');
  9708. } catch (err) {
  9709. try {
  9710. engine = requires.jade = require('then-jade');
  9711. } catch (otherError) {
  9712. throw err;
  9713. }
  9714. }
  9715. }
  9716. try {
  9717. var tmpl = cache(options) || cache(options, engine.compileFile(path, options));
  9718. cb(null, tmpl(options));
  9719. } catch (err) {
  9720. cb(err);
  9721. }
  9722. });
  9723. };
  9724. /**
  9725. * Jade string support.
  9726. */
  9727. exports.jade.render = function(str, options, cb) {
  9728. return promisify(cb, function(cb) {
  9729. var engine = requires.jade;
  9730. if (!engine) {
  9731. try {
  9732. engine = requires.jade = require('jade');
  9733. } catch (err) {
  9734. try {
  9735. engine = requires.jade = require('then-jade');
  9736. } catch (otherError) {
  9737. throw err;
  9738. }
  9739. }
  9740. }
  9741. try {
  9742. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  9743. cb(null, tmpl(options));
  9744. } catch (err) {
  9745. cb(err);
  9746. }
  9747. });
  9748. };
  9749. /**
  9750. * Dust support.
  9751. */
  9752. exports.dust = fromStringRenderer('dust');
  9753. /**
  9754. * Dust string support.
  9755. */
  9756. exports.dust.render = function(str, options, cb) {
  9757. return promisify(cb, function(cb) {
  9758. var engine = requires.dust;
  9759. if (!engine) {
  9760. try {
  9761. engine = requires.dust = require('dust');
  9762. } catch (err) {
  9763. try {
  9764. engine = requires.dust = require('dustjs-helpers');
  9765. } catch (err) {
  9766. engine = requires.dust = require('dustjs-linkedin');
  9767. }
  9768. }
  9769. }
  9770. var ext = 'dust';
  9771. var views = '.';
  9772. if (options) {
  9773. if (options.ext) ext = options.ext;
  9774. if (options.views) views = options.views;
  9775. if (options.settings && options.settings.views) views = options.settings.views;
  9776. }
  9777. if (!options || (options && !options.cache)) engine.cache = {};
  9778. engine.onLoad = function(path, callback) {
  9779. if (extname(path) === '') path += '.' + ext;
  9780. if (path[0] !== '/') path = views + '/' + path;
  9781. read(path, options, callback);
  9782. };
  9783. try {
  9784. var templateName;
  9785. if (options.filename) {
  9786. templateName = options.filename.replace(new RegExp('^' + views + '/'), '').replace(new RegExp('\\.' + ext), '');
  9787. }
  9788. var tmpl = cache(options) || cache(options, engine.compileFn(str, templateName));
  9789. tmpl(options, cb);
  9790. } catch (err) {
  9791. cb(err);
  9792. }
  9793. });
  9794. };
  9795. /**
  9796. * Swig support.
  9797. */
  9798. exports.swig = fromStringRenderer('swig');
  9799. /**
  9800. * Swig string support.
  9801. */
  9802. exports.swig.render = function(str, options, cb) {
  9803. return promisify(cb, function(cb) {
  9804. var engine = requires.swig;
  9805. if (!engine) {
  9806. try {
  9807. engine = requires.swig = require('swig');
  9808. } catch (err) {
  9809. try {
  9810. engine = requires.swig = require('swig-templates');
  9811. } catch (otherError) {
  9812. throw err;
  9813. }
  9814. }
  9815. }
  9816. try {
  9817. if (options.cache === true) options.cache = 'memory';
  9818. engine.setDefaults({ cache: options.cache });
  9819. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  9820. cb(null, tmpl(options));
  9821. } catch (err) {
  9822. cb(err);
  9823. }
  9824. });
  9825. };
  9826. /**
  9827. * Razor support.
  9828. */
  9829. exports.razor = function(path, options, cb) {
  9830. return promisify(cb, function(cb) {
  9831. var engine = requires.razor;
  9832. if (!engine) {
  9833. try {
  9834. engine = requires.razor = require('razor-tmpl');
  9835. } catch (err) {
  9836. throw err;
  9837. }
  9838. }
  9839. try {
  9840. var tmpl = cache(options) || cache(options, (locals) => {
  9841. console.log('Rendering razor file', path);
  9842. return engine.renderFileSync(path, locals);
  9843. });
  9844. cb(null, tmpl(options));
  9845. } catch (err) {
  9846. cb(err);
  9847. }
  9848. });
  9849. };
  9850. /**
  9851. * razor string support.
  9852. */
  9853. exports.razor.render = function(str, options, cb) {
  9854. return promisify(cb, function(cb) {
  9855. try {
  9856. var engine = requires.razor = require('razor-tmpl');
  9857. } catch (err) {
  9858. throw err;
  9859. }
  9860. try {
  9861. var tf = engine.compile(str);
  9862. var tmpl = cache(options) || cache(options, tf);
  9863. cb(null, tmpl(options));
  9864. } catch (err) {
  9865. cb(err);
  9866. }
  9867. });
  9868. };
  9869. /**
  9870. * Atpl support.
  9871. */
  9872. exports.atpl = fromStringRenderer('atpl');
  9873. /**
  9874. * Atpl string support.
  9875. */
  9876. exports.atpl.render = function(str, options, cb) {
  9877. return promisify(cb, function(cb) {
  9878. var engine = requires.atpl || (requires.atpl = require('atpl'));
  9879. try {
  9880. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  9881. cb(null, tmpl(options));
  9882. } catch (err) {
  9883. cb(err);
  9884. }
  9885. });
  9886. };
  9887. /**
  9888. * Liquor support,
  9889. */
  9890. exports.liquor = fromStringRenderer('liquor');
  9891. /**
  9892. * Liquor string support.
  9893. */
  9894. exports.liquor.render = function(str, options, cb) {
  9895. return promisify(cb, function(cb) {
  9896. var engine = requires.liquor || (requires.liquor = require('liquor'));
  9897. try {
  9898. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  9899. cb(null, tmpl(options));
  9900. } catch (err) {
  9901. cb(err);
  9902. }
  9903. });
  9904. };
  9905. /**
  9906. * Twig support.
  9907. */
  9908. exports.twig = fromStringRenderer('twig');
  9909. /**
  9910. * Twig string support.
  9911. */
  9912. exports.twig.render = function(str, options, cb) {
  9913. return promisify(cb, function(cb) {
  9914. var engine = requires.twig || (requires.twig = require('twig').twig);
  9915. var templateData = {
  9916. data: str,
  9917. allowInlineIncludes: options.allowInlineIncludes,
  9918. namespaces: options.namespaces,
  9919. path: options.path
  9920. };
  9921. try {
  9922. var tmpl = cache(templateData) || cache(templateData, engine(templateData));
  9923. cb(null, tmpl.render(options));
  9924. } catch (err) {
  9925. cb(err);
  9926. }
  9927. });
  9928. };
  9929. /**
  9930. * EJS support.
  9931. */
  9932. exports.ejs = fromStringRenderer('ejs');
  9933. /**
  9934. * EJS string support.
  9935. */
  9936. exports.ejs.render = function(str, options, cb) {
  9937. return promisify(cb, function(cb) {
  9938. var engine = requires.ejs || (requires.ejs = require('ejs'));
  9939. try {
  9940. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  9941. cb(null, tmpl(options));
  9942. } catch (err) {
  9943. cb(err);
  9944. }
  9945. });
  9946. };
  9947. /**
  9948. * Eco support.
  9949. */
  9950. exports.eco = fromStringRenderer('eco');
  9951. /**
  9952. * Eco string support.
  9953. */
  9954. exports.eco.render = function(str, options, cb) {
  9955. return promisify(cb, function(cb) {
  9956. var engine = requires.eco || (requires.eco = require('eco'));
  9957. try {
  9958. cb(null, engine.render(str, options));
  9959. } catch (err) {
  9960. cb(err);
  9961. }
  9962. });
  9963. };
  9964. /**
  9965. * Jazz support.
  9966. */
  9967. exports.jazz = fromStringRenderer('jazz');
  9968. /**
  9969. * Jazz string support.
  9970. */
  9971. exports.jazz.render = function(str, options, cb) {
  9972. return promisify(cb, function(cb) {
  9973. var engine = requires.jazz || (requires.jazz = require('jazz'));
  9974. try {
  9975. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  9976. tmpl.eval(options, function(str) {
  9977. cb(null, str);
  9978. });
  9979. } catch (err) {
  9980. cb(err);
  9981. }
  9982. });
  9983. };
  9984. /**
  9985. * JQTPL support.
  9986. */
  9987. exports.jqtpl = fromStringRenderer('jqtpl');
  9988. /**
  9989. * JQTPL string support.
  9990. */
  9991. exports.jqtpl.render = function(str, options, cb) {
  9992. return promisify(cb, function(cb) {
  9993. var engine = requires.jqtpl || (requires.jqtpl = require('jqtpl'));
  9994. try {
  9995. engine.template(str, str);
  9996. cb(null, engine.tmpl(str, options));
  9997. } catch (err) {
  9998. cb(err);
  9999. }
  10000. });
  10001. };
  10002. /**
  10003. * Haml support.
  10004. */
  10005. exports.haml = fromStringRenderer('haml');
  10006. /**
  10007. * Haml string support.
  10008. */
  10009. exports.haml.render = function(str, options, cb) {
  10010. return promisify(cb, function(cb) {
  10011. var engine = requires.haml || (requires.haml = require('hamljs'));
  10012. try {
  10013. options.locals = options;
  10014. cb(null, engine.render(str, options).trimLeft());
  10015. } catch (err) {
  10016. cb(err);
  10017. }
  10018. });
  10019. };
  10020. /**
  10021. * Hamlet support.
  10022. */
  10023. exports.hamlet = fromStringRenderer('hamlet');
  10024. /**
  10025. * Hamlet string support.
  10026. */
  10027. exports.hamlet.render = function(str, options, cb) {
  10028. return promisify(cb, function(cb) {
  10029. var engine = requires.hamlet || (requires.hamlet = require('hamlet'));
  10030. try {
  10031. options.locals = options;
  10032. cb(null, engine.render(str, options).trimLeft());
  10033. } catch (err) {
  10034. cb(err);
  10035. }
  10036. });
  10037. };
  10038. /**
  10039. * Whiskers support.
  10040. */
  10041. exports.whiskers = function(path, options, cb) {
  10042. return promisify(cb, function(cb) {
  10043. var engine = requires.whiskers || (requires.whiskers = require('whiskers'));
  10044. engine.__express(path, options, cb);
  10045. });
  10046. };
  10047. /**
  10048. * Whiskers string support.
  10049. */
  10050. exports.whiskers.render = function(str, options, cb) {
  10051. return promisify(cb, function(cb) {
  10052. var engine = requires.whiskers || (requires.whiskers = require('whiskers'));
  10053. try {
  10054. cb(null, engine.render(str, options));
  10055. } catch (err) {
  10056. cb(err);
  10057. }
  10058. });
  10059. };
  10060. /**
  10061. * Coffee-HAML support.
  10062. */
  10063. exports['haml-coffee'] = fromStringRenderer('haml-coffee');
  10064. /**
  10065. * Coffee-HAML string support.
  10066. */
  10067. exports['haml-coffee'].render = function(str, options, cb) {
  10068. return promisify(cb, function(cb) {
  10069. var engine = requires['haml-coffee'] || (requires['haml-coffee'] = require('haml-coffee'));
  10070. try {
  10071. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  10072. cb(null, tmpl(options));
  10073. } catch (err) {
  10074. cb(err);
  10075. }
  10076. });
  10077. };
  10078. /**
  10079. * Hogan support.
  10080. */
  10081. exports.hogan = fromStringRenderer('hogan');
  10082. /**
  10083. * Hogan string support.
  10084. */
  10085. exports.hogan.render = function(str, options, cb) {
  10086. return promisify(cb, function(cb) {
  10087. var engine = requires.hogan || (requires.hogan = require('hogan.js'));
  10088. try {
  10089. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  10090. cb(null, tmpl.render(options, options.partials));
  10091. } catch (err) {
  10092. cb(err);
  10093. }
  10094. });
  10095. };
  10096. /**
  10097. * templayed.js support.
  10098. */
  10099. exports.templayed = fromStringRenderer('templayed');
  10100. /**
  10101. * templayed.js string support.
  10102. */
  10103. exports.templayed.render = function(str, options, cb) {
  10104. return promisify(cb, function(cb) {
  10105. var engine = requires.templayed || (requires.templayed = require('templayed'));
  10106. try {
  10107. var tmpl = cache(options) || cache(options, engine(str));
  10108. cb(null, tmpl(options));
  10109. } catch (err) {
  10110. cb(err);
  10111. }
  10112. });
  10113. };
  10114. /**
  10115. * Handlebars support.
  10116. */
  10117. exports.handlebars = fromStringRenderer('handlebars');
  10118. /**
  10119. * Handlebars string support.
  10120. */
  10121. exports.handlebars.render = function(str, options, cb) {
  10122. return promisify(cb, function(cb) {
  10123. var engine = requires.handlebars || (requires.handlebars = require('handlebars'));
  10124. try {
  10125. for (var partial in options.partials) {
  10126. engine.registerPartial(partial, options.partials[partial]);
  10127. }
  10128. for (var helper in options.helpers) {
  10129. engine.registerHelper(helper, options.helpers[helper]);
  10130. }
  10131. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  10132. cb(null, tmpl(options));
  10133. } catch (err) {
  10134. cb(err);
  10135. }
  10136. });
  10137. };
  10138. /**
  10139. * Underscore support.
  10140. */
  10141. exports.underscore = fromStringRenderer('underscore');
  10142. /**
  10143. * Underscore string support.
  10144. */
  10145. exports.underscore.render = function(str, options, cb) {
  10146. return promisify(cb, function(cb) {
  10147. var engine = requires.underscore || (requires.underscore = require('underscore'));
  10148. try {
  10149. const partials = {};
  10150. for (var partial in options.partials) {
  10151. partials[partial] = engine.template(options.partials[partial]);
  10152. }
  10153. options.partials = partials;
  10154. var tmpl = cache(options) || cache(options, engine.template(str, null, options));
  10155. cb(null, tmpl(options).replace(/\n$/, ''));
  10156. } catch (err) {
  10157. cb(err);
  10158. }
  10159. });
  10160. };
  10161. /**
  10162. * Lodash support.
  10163. */
  10164. exports.lodash = fromStringRenderer('lodash');
  10165. /**
  10166. * Lodash string support.
  10167. */
  10168. exports.lodash.render = function(str, options, cb) {
  10169. return promisify(cb, function(cb) {
  10170. var engine = requires.lodash || (requires.lodash = require('lodash'));
  10171. try {
  10172. var tmpl = cache(options) || cache(options, engine.template(str, options));
  10173. cb(null, tmpl(options).replace(/\n$/, ''));
  10174. } catch (err) {
  10175. cb(err);
  10176. }
  10177. });
  10178. };
  10179. /**
  10180. * Pug support. (formerly Jade)
  10181. */
  10182. exports.pug = function(path, options, cb) {
  10183. return promisify(cb, function(cb) {
  10184. var engine = requires.pug;
  10185. if (!engine) {
  10186. try {
  10187. engine = requires.pug = require('pug');
  10188. } catch (err) {
  10189. try {
  10190. engine = requires.pug = require('then-pug');
  10191. } catch (otherError) {
  10192. throw err;
  10193. }
  10194. }
  10195. }
  10196. try {
  10197. var tmpl = cache(options) || cache(options, engine.compileFile(path, options));
  10198. cb(null, tmpl(options));
  10199. } catch (err) {
  10200. cb(err);
  10201. }
  10202. });
  10203. };
  10204. /**
  10205. * Pug string support.
  10206. */
  10207. exports.pug.render = function(str, options, cb) {
  10208. return promisify(cb, function(cb) {
  10209. var engine = requires.pug;
  10210. if (!engine) {
  10211. try {
  10212. engine = requires.pug = require('pug');
  10213. } catch (err) {
  10214. try {
  10215. engine = requires.pug = require('then-pug');
  10216. } catch (otherError) {
  10217. throw err;
  10218. }
  10219. }
  10220. }
  10221. try {
  10222. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  10223. cb(null, tmpl(options));
  10224. } catch (err) {
  10225. cb(err);
  10226. }
  10227. });
  10228. };
  10229. /**
  10230. * QEJS support.
  10231. */
  10232. exports.qejs = fromStringRenderer('qejs');
  10233. /**
  10234. * QEJS string support.
  10235. */
  10236. exports.qejs.render = function(str, options, cb) {
  10237. return promisify(cb, function(cb) {
  10238. try {
  10239. var engine = requires.qejs || (requires.qejs = require('qejs'));
  10240. engine.render(str, options).then(function(result) {
  10241. cb(null, result);
  10242. }, function(err) {
  10243. cb(err);
  10244. }).done();
  10245. } catch (err) {
  10246. cb(err);
  10247. }
  10248. });
  10249. };
  10250. /**
  10251. * Walrus support.
  10252. */
  10253. exports.walrus = fromStringRenderer('walrus');
  10254. /**
  10255. * Walrus string support.
  10256. */
  10257. exports.walrus.render = function(str, options, cb) {
  10258. return promisify(cb, function(cb) {
  10259. var engine = requires.walrus || (requires.walrus = require('walrus'));
  10260. try {
  10261. var tmpl = cache(options) || cache(options, engine.parse(str));
  10262. cb(null, tmpl.compile(options));
  10263. } catch (err) {
  10264. cb(err);
  10265. }
  10266. });
  10267. };
  10268. /**
  10269. * Mustache support.
  10270. */
  10271. exports.mustache = fromStringRenderer('mustache');
  10272. /**
  10273. * Mustache string support.
  10274. */
  10275. exports.mustache.render = function(str, options, cb) {
  10276. return promisify(cb, function(cb) {
  10277. var engine = requires.mustache || (requires.mustache = require('mustache'));
  10278. try {
  10279. cb(null, engine.render(str, options, options.partials));
  10280. } catch (err) {
  10281. cb(err);
  10282. }
  10283. });
  10284. };
  10285. /**
  10286. * Just support.
  10287. */
  10288. exports.just = function(path, options, cb) {
  10289. return promisify(cb, function(cb) {
  10290. var engine = requires.just;
  10291. if (!engine) {
  10292. var JUST = require('just');
  10293. engine = requires.just = new JUST();
  10294. }
  10295. engine.configure({ useCache: options.cache });
  10296. engine.render(path, options, cb);
  10297. });
  10298. };
  10299. /**
  10300. * Just string support.
  10301. */
  10302. exports.just.render = function(str, options, cb) {
  10303. return promisify(cb, function(cb) {
  10304. var JUST = require('just');
  10305. var engine = new JUST({ root: { page: str }});
  10306. engine.render('page', options, cb);
  10307. });
  10308. };
  10309. /**
  10310. * ECT support.
  10311. */
  10312. exports.ect = function(path, options, cb) {
  10313. return promisify(cb, function(cb) {
  10314. var engine = requires.ect;
  10315. if (!engine) {
  10316. var ECT = require('ect');
  10317. engine = requires.ect = new ECT(options);
  10318. }
  10319. engine.configure({ cache: options.cache });
  10320. engine.render(path, options, cb);
  10321. });
  10322. };
  10323. /**
  10324. * ECT string support.
  10325. */
  10326. exports.ect.render = function(str, options, cb) {
  10327. return promisify(cb, function(cb) {
  10328. var ECT = require('ect');
  10329. var engine = new ECT({ root: { page: str }});
  10330. engine.render('page', options, cb);
  10331. });
  10332. };
  10333. /**
  10334. * mote support.
  10335. */
  10336. exports.mote = fromStringRenderer('mote');
  10337. /**
  10338. * mote string support.
  10339. */
  10340. exports.mote.render = function(str, options, cb) {
  10341. return promisify(cb, function(cb) {
  10342. var engine = requires.mote || (requires.mote = require('mote'));
  10343. try {
  10344. var tmpl = cache(options) || cache(options, engine.compile(str));
  10345. cb(null, tmpl(options));
  10346. } catch (err) {
  10347. cb(err);
  10348. }
  10349. });
  10350. };
  10351. /**
  10352. * Toffee support.
  10353. */
  10354. exports.toffee = function(path, options, cb) {
  10355. return promisify(cb, function(cb) {
  10356. var toffee = requires.toffee || (requires.toffee = require('toffee'));
  10357. toffee.__consolidate_engine_render(path, options, cb);
  10358. });
  10359. };
  10360. /**
  10361. * Toffee string support.
  10362. */
  10363. exports.toffee.render = function(str, options, cb) {
  10364. return promisify(cb, function(cb) {
  10365. var engine = requires.toffee || (requires.toffee = require('toffee'));
  10366. try {
  10367. engine.str_render(str, options, cb);
  10368. } catch (err) {
  10369. cb(err);
  10370. }
  10371. });
  10372. };
  10373. /**
  10374. * doT support.
  10375. */
  10376. exports.dot = fromStringRenderer('dot');
  10377. /**
  10378. * doT string support.
  10379. */
  10380. exports.dot.render = function(str, options, cb) {
  10381. return promisify(cb, function(cb) {
  10382. var engine = requires.dot || (requires.dot = require('dot'));
  10383. var extend = (requires.extend || (requires.extend = require$$2__default["default"]._extend));
  10384. try {
  10385. var settings = {};
  10386. settings = extend(settings, engine.templateSettings);
  10387. settings = extend(settings, options ? options.dot : {});
  10388. var tmpl = cache(options) || cache(options, engine.template(str, settings, options));
  10389. cb(null, tmpl(options));
  10390. } catch (err) {
  10391. cb(err);
  10392. }
  10393. });
  10394. };
  10395. /**
  10396. * bracket support.
  10397. */
  10398. exports.bracket = fromStringRenderer('bracket');
  10399. /**
  10400. * bracket string support.
  10401. */
  10402. exports.bracket.render = function(str, options, cb) {
  10403. return promisify(cb, function(cb) {
  10404. var engine = requires.bracket || (requires.bracket = require('bracket-template'));
  10405. try {
  10406. var tmpl = cache(options) || cache(options, engine.default.compile(str, options));
  10407. cb(null, tmpl(options));
  10408. } catch (err) {
  10409. cb(err);
  10410. }
  10411. });
  10412. };
  10413. /**
  10414. * Ractive support.
  10415. */
  10416. exports.ractive = fromStringRenderer('ractive');
  10417. /**
  10418. * Ractive string support.
  10419. */
  10420. exports.ractive.render = function(str, options, cb) {
  10421. return promisify(cb, function(cb) {
  10422. var Engine = requires.ractive || (requires.ractive = require('ractive'));
  10423. var template = cache(options) || cache(options, Engine.parse(str));
  10424. options.template = template;
  10425. if (options.data === null || options.data === undefined) {
  10426. var extend = (requires.extend || (requires.extend = require$$2__default["default"]._extend));
  10427. // Shallow clone the options object
  10428. options.data = extend({}, options);
  10429. // Remove consolidate-specific properties from the clone
  10430. var i;
  10431. var length;
  10432. var properties = ['template', 'filename', 'cache', 'partials'];
  10433. for (i = 0, length = properties.length; i < length; i++) {
  10434. var property = properties[i];
  10435. delete options.data[property];
  10436. }
  10437. }
  10438. try {
  10439. cb(null, new Engine(options).toHTML());
  10440. } catch (err) {
  10441. cb(err);
  10442. }
  10443. });
  10444. };
  10445. /**
  10446. * Nunjucks support.
  10447. */
  10448. exports.nunjucks = fromStringRenderer('nunjucks');
  10449. /**
  10450. * Nunjucks string support.
  10451. */
  10452. exports.nunjucks.render = function(str, options, cb) {
  10453. return promisify(cb, function(cb) {
  10454. try {
  10455. var engine = options.nunjucksEnv || requires.nunjucks || (requires.nunjucks = require('nunjucks'));
  10456. var env = engine;
  10457. // deprecated fallback support for express
  10458. // <https://github.com/tj/consolidate.js/pull/152>
  10459. // <https://github.com/tj/consolidate.js/pull/224>
  10460. if (options.settings && options.settings.views) {
  10461. env = engine.configure(options.settings.views);
  10462. } else if (options.nunjucks && options.nunjucks.configure) {
  10463. env = engine.configure.apply(engine, options.nunjucks.configure);
  10464. }
  10465. //
  10466. // because `renderString` does not initiate loaders
  10467. // we must manually create a loader for it based off
  10468. // either `options.settings.views` or `options.nunjucks` or `options.nunjucks.root`
  10469. //
  10470. // <https://github.com/mozilla/nunjucks/issues/730>
  10471. // <https://github.com/crocodilejs/node-email-templates/issues/182>
  10472. //
  10473. // so instead we simply check if we passed a custom loader
  10474. // otherwise we create a simple file based loader
  10475. if (options.loader) {
  10476. env = new engine.Environment(options.loader);
  10477. } else if (options.settings && options.settings.views) {
  10478. env = new engine.Environment(
  10479. new engine.FileSystemLoader(options.settings.views)
  10480. );
  10481. } else if (options.nunjucks && options.nunjucks.loader) {
  10482. if (typeof options.nunjucks.loader === 'string') {
  10483. env = new engine.Environment(new engine.FileSystemLoader(options.nunjucks.loader));
  10484. } else {
  10485. env = new engine.Environment(
  10486. new engine.FileSystemLoader(
  10487. options.nunjucks.loader[0],
  10488. options.nunjucks.loader[1]
  10489. )
  10490. );
  10491. }
  10492. }
  10493. env.renderString(str, options, cb);
  10494. } catch (err) {
  10495. throw cb(err);
  10496. }
  10497. });
  10498. };
  10499. /**
  10500. * HTMLing support.
  10501. */
  10502. exports.htmling = fromStringRenderer('htmling');
  10503. /**
  10504. * HTMLing string support.
  10505. */
  10506. exports.htmling.render = function(str, options, cb) {
  10507. return promisify(cb, function(cb) {
  10508. var engine = requires.htmling || (requires.htmling = require('htmling'));
  10509. try {
  10510. var tmpl = cache(options) || cache(options, engine.string(str));
  10511. cb(null, tmpl.render(options));
  10512. } catch (err) {
  10513. cb(err);
  10514. }
  10515. });
  10516. };
  10517. /**
  10518. * Rendering function
  10519. */
  10520. function requireReact(module, filename) {
  10521. var babel = requires.babel || (requires.babel = require('babel-core'));
  10522. var compiled = babel.transformFileSync(filename, { presets: [ 'react' ] }).code;
  10523. return module._compile(compiled, filename);
  10524. }
  10525. exports.requireReact = requireReact;
  10526. /**
  10527. * Converting a string into a node module.
  10528. */
  10529. function requireReactString(src, filename) {
  10530. var babel = requires.babel || (requires.babel = require('babel-core'));
  10531. if (!filename) filename = '';
  10532. var m = new module.constructor();
  10533. filename = filename || '';
  10534. // Compile Using React
  10535. var compiled = babel.transform(src, { presets: [ 'react' ] }).code;
  10536. // Compile as a module
  10537. m.paths = module.paths;
  10538. m._compile(compiled, filename);
  10539. return m.exports;
  10540. }
  10541. /**
  10542. * A naive helper to replace {{tags}} with options.tags content
  10543. */
  10544. function reactBaseTmpl(data, options) {
  10545. var exp;
  10546. var regex;
  10547. // Iterates through the keys in file object
  10548. // and interpolate / replace {{key}} with it's value
  10549. for (var k in options) {
  10550. if (options.hasOwnProperty(k)) {
  10551. exp = '{{' + k + '}}';
  10552. regex = new RegExp(exp, 'g');
  10553. if (data.match(regex)) {
  10554. data = data.replace(regex, options[k]);
  10555. }
  10556. }
  10557. }
  10558. return data;
  10559. }
  10560. /**
  10561. * Plates Support.
  10562. */
  10563. exports.plates = fromStringRenderer('plates');
  10564. /**
  10565. * Plates string support.
  10566. */
  10567. exports.plates.render = function(str, options, cb) {
  10568. return promisify(cb, function(cb) {
  10569. var engine = requires.plates || (requires.plates = require('plates'));
  10570. var map = options.map || undefined;
  10571. try {
  10572. var tmpl = engine.bind(str, options, map);
  10573. cb(null, tmpl);
  10574. } catch (err) {
  10575. cb(err);
  10576. }
  10577. });
  10578. };
  10579. /**
  10580. * The main render parser for React bsaed templates
  10581. */
  10582. function reactRenderer(type) {
  10583. if (commonjsRequire.extensions) {
  10584. // Ensure JSX is transformed on require
  10585. if (!commonjsRequire.extensions['.jsx']) {
  10586. commonjsRequire.extensions['.jsx'] = requireReact;
  10587. }
  10588. // Supporting .react extension as well as test cases
  10589. // Using .react extension is not recommended.
  10590. if (!commonjsRequire.extensions['.react']) {
  10591. commonjsRequire.extensions['.react'] = requireReact;
  10592. }
  10593. }
  10594. // Return rendering fx
  10595. return function(str, options, cb) {
  10596. return promisify(cb, function(cb) {
  10597. // React Import
  10598. var ReactDOM = requires.ReactDOM || (requires.ReactDOM = require('react-dom/server'));
  10599. var react = requires.react || (requires.react = require('react'));
  10600. // Assign HTML Base
  10601. var base = options.base;
  10602. delete options.base;
  10603. var enableCache = options.cache;
  10604. delete options.cache;
  10605. var isNonStatic = options.isNonStatic;
  10606. delete options.isNonStatic;
  10607. // Start Conversion
  10608. try {
  10609. var Code;
  10610. var Factory;
  10611. var baseStr;
  10612. var content;
  10613. var parsed;
  10614. if (!cache(options)) {
  10615. // Parsing
  10616. if (type === 'path') {
  10617. var path = resolve(str);
  10618. delete require.cache[path];
  10619. Code = commonjsRequire(path);
  10620. } else {
  10621. Code = requireReactString(str);
  10622. }
  10623. Factory = cache(options, react.createFactory(Code));
  10624. } else {
  10625. Factory = cache(options);
  10626. }
  10627. parsed = new Factory(options);
  10628. content = (isNonStatic) ? ReactDOM.renderToString(parsed) : ReactDOM.renderToStaticMarkup(parsed);
  10629. if (base) {
  10630. baseStr = readCache[str] || fs.readFileSync(resolve(base), 'utf8');
  10631. if (enableCache) {
  10632. readCache[str] = baseStr;
  10633. }
  10634. options.content = content;
  10635. content = reactBaseTmpl(baseStr, options);
  10636. }
  10637. cb(null, content);
  10638. } catch (err) {
  10639. cb(err);
  10640. }
  10641. });
  10642. };
  10643. }
  10644. /**
  10645. * React JS Support
  10646. */
  10647. exports.react = reactRenderer('path');
  10648. /**
  10649. * React JS string support.
  10650. */
  10651. exports.react.render = reactRenderer('string');
  10652. /**
  10653. * ARC-templates support.
  10654. */
  10655. exports['arc-templates'] = fromStringRenderer('arc-templates');
  10656. /**
  10657. * ARC-templates string support.
  10658. */
  10659. exports['arc-templates'].render = function(str, options, cb) {
  10660. var readFileWithOptions = util.promisify(read);
  10661. var consolidateFileSystem = {};
  10662. consolidateFileSystem.readFile = function(path) {
  10663. return readFileWithOptions(path, options);
  10664. };
  10665. return promisify(cb, function(cb) {
  10666. try {
  10667. var engine = requires['arc-templates'];
  10668. if (!engine) {
  10669. var Engine = require('arc-templates/dist/es5');
  10670. engine = requires['arc-templates'] = new Engine({ filesystem: consolidateFileSystem });
  10671. }
  10672. var compiler = cache(options) || cache(options, engine.compileString(str, options.filename));
  10673. compiler.then(function(func) { return func(options); })
  10674. .then(function(result) { cb(null, result.content); })
  10675. .catch(cb);
  10676. } catch (err) {
  10677. cb(err);
  10678. }
  10679. });
  10680. };
  10681. /**
  10682. * Vash support
  10683. */
  10684. exports.vash = fromStringRenderer('vash');
  10685. /**
  10686. * Vash string support
  10687. */
  10688. exports.vash.render = function(str, options, cb) {
  10689. return promisify(cb, function(cb) {
  10690. var engine = requires.vash || (requires.vash = require('vash'));
  10691. try {
  10692. // helper system : https://github.com/kirbysayshi/vash#helper-system
  10693. if (options.helpers) {
  10694. for (var key in options.helpers) {
  10695. if (!options.helpers.hasOwnProperty(key) || typeof options.helpers[key] !== 'function') {
  10696. continue;
  10697. }
  10698. engine.helpers[key] = options.helpers[key];
  10699. }
  10700. }
  10701. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  10702. tmpl(options, function sealLayout(err, ctx) {
  10703. if (err) cb(err);
  10704. ctx.finishLayout();
  10705. cb(null, ctx.toString().replace(/\n$/, ''));
  10706. });
  10707. } catch (err) {
  10708. cb(err);
  10709. }
  10710. });
  10711. };
  10712. /**
  10713. * Slm support.
  10714. */
  10715. exports.slm = fromStringRenderer('slm');
  10716. /**
  10717. * Slm string support.
  10718. */
  10719. exports.slm.render = function(str, options, cb) {
  10720. return promisify(cb, function(cb) {
  10721. var engine = requires.slm || (requires.slm = require('slm'));
  10722. try {
  10723. var tmpl = cache(options) || cache(options, engine.compile(str, options));
  10724. cb(null, tmpl(options));
  10725. } catch (err) {
  10726. cb(err);
  10727. }
  10728. });
  10729. };
  10730. /**
  10731. * Marko support.
  10732. */
  10733. exports.marko = function(path, options, cb) {
  10734. return promisify(cb, function(cb) {
  10735. var engine = requires.marko || (requires.marko = require('marko'));
  10736. options.writeToDisk = !!options.cache;
  10737. try {
  10738. var tmpl = cache(options) || cache(options, engine.load(path, options));
  10739. tmpl.renderToString(options, cb);
  10740. } catch (err) {
  10741. cb(err);
  10742. }
  10743. });
  10744. };
  10745. /**
  10746. * Marko string support.
  10747. */
  10748. exports.marko.render = function(str, options, cb) {
  10749. return promisify(cb, function(cb) {
  10750. var engine = requires.marko || (requires.marko = require('marko'));
  10751. options.writeToDisk = !!options.cache;
  10752. options.filename = options.filename || 'string.marko';
  10753. try {
  10754. var tmpl = cache(options) || cache(options, engine.load(options.filename, str, options));
  10755. tmpl.renderToString(options, cb);
  10756. } catch (err) {
  10757. cb(err);
  10758. }
  10759. });
  10760. };
  10761. /**
  10762. * Teacup support.
  10763. */
  10764. exports.teacup = function(path, options, cb) {
  10765. return promisify(cb, function(cb) {
  10766. var engine = requires.teacup || (requires.teacup = require('teacup/lib/express'));
  10767. commonjsRequire.extensions['.teacup'] = commonjsRequire.extensions['.coffee'];
  10768. if (path[0] !== '/') {
  10769. path = join(process.cwd(), path);
  10770. }
  10771. if (!options.cache) {
  10772. var callback = cb;
  10773. cb = function() {
  10774. delete require.cache[path];
  10775. callback.apply(this, arguments);
  10776. };
  10777. }
  10778. engine.renderFile(path, options, cb);
  10779. });
  10780. };
  10781. /**
  10782. * Teacup string support.
  10783. */
  10784. exports.teacup.render = function(str, options, cb) {
  10785. var coffee = require('coffee-script');
  10786. var vm = require('vm');
  10787. var sandbox = {
  10788. module: {exports: {}},
  10789. require: commonjsRequire
  10790. };
  10791. return promisify(cb, function(cb) {
  10792. vm.runInNewContext(coffee.compile(str), sandbox);
  10793. var tmpl = sandbox.module.exports;
  10794. cb(null, tmpl(options));
  10795. });
  10796. };
  10797. /**
  10798. * Squirrelly support.
  10799. */
  10800. exports.squirrelly = fromStringRenderer('squirrelly');
  10801. /**
  10802. * Squirrelly string support.
  10803. */
  10804. exports.squirrelly.render = function(str, options, cb) {
  10805. return promisify(cb, function(cb) {
  10806. var engine = requires.squirrelly || (requires.squirrelly = require('squirrelly'));
  10807. try {
  10808. for (var partial in options.partials) {
  10809. engine.definePartial(partial, options.partials[partial]);
  10810. }
  10811. for (var helper in options.helpers) {
  10812. engine.defineHelper(helper, options.helpers[helper]);
  10813. }
  10814. var tmpl = cache(options) || cache(options, engine.Compile(str, options));
  10815. cb(null, tmpl(options, engine));
  10816. } catch (err) {
  10817. cb(err);
  10818. }
  10819. });
  10820. };
  10821. /**
  10822. * Twing support.
  10823. */
  10824. exports.twing = fromStringRenderer('twing');
  10825. /**
  10826. * Twing string support.
  10827. */
  10828. exports.twing.render = function(str, options, cb) {
  10829. return promisify(cb, function(cb) {
  10830. var engine = requires.twing || (requires.twing = require('twing'));
  10831. try {
  10832. new engine.TwingEnvironment(new engine.TwingLoaderNull()).createTemplate(str).then((twingTemplate) => {
  10833. twingTemplate.render(options).then((rendTmpl) => {
  10834. var tmpl = cache(options) || cache(options, rendTmpl);
  10835. cb(null, tmpl);
  10836. });
  10837. });
  10838. } catch (err) {
  10839. cb(err);
  10840. }
  10841. });
  10842. };
  10843. /**
  10844. * expose the instance of the engine
  10845. */
  10846. exports.requires = requires;
  10847. } (consolidate$1, consolidate$1.exports));
  10848. (function (module) {
  10849. module.exports = consolidate$1.exports;
  10850. } (consolidate$2));
  10851. var consolidate = /*@__PURE__*/getDefaultExportFromCjs(consolidate$2.exports);
  10852. let isStaticKey;
  10853. let isPlatformReservedTag$1;
  10854. const genStaticKeysCached = cached(genStaticKeys);
  10855. /**
  10856. * Goal of the optimizer: walk the generated template AST tree
  10857. * and detect sub-trees that are purely static, i.e. parts of
  10858. * the DOM that never needs to change.
  10859. *
  10860. * Once we detect these sub-trees, we can:
  10861. *
  10862. * 1. Hoist them into constants, so that we no longer need to
  10863. * create fresh nodes for them on each re-render;
  10864. * 2. Completely skip them in the patching process.
  10865. */
  10866. function optimize$1(root, options) {
  10867. if (!root)
  10868. return;
  10869. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  10870. isPlatformReservedTag$1 = options.isReservedTag || no;
  10871. // first pass: mark all non-static nodes.
  10872. markStatic(root);
  10873. // second pass: mark static roots.
  10874. markStaticRoots(root, false);
  10875. }
  10876. function genStaticKeys(keys) {
  10877. return makeMap('type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  10878. (keys ? ',' + keys : ''));
  10879. }
  10880. function markStatic(node) {
  10881. node.static = isStatic(node);
  10882. if (node.type === 1) {
  10883. // do not make component slot content static. this avoids
  10884. // 1. components not able to mutate slot nodes
  10885. // 2. static slot content fails for hot-reloading
  10886. if (!isPlatformReservedTag$1(node.tag) &&
  10887. node.tag !== 'slot' &&
  10888. node.attrsMap['inline-template'] == null) {
  10889. return;
  10890. }
  10891. for (let i = 0, l = node.children.length; i < l; i++) {
  10892. const child = node.children[i];
  10893. markStatic(child);
  10894. if (!child.static) {
  10895. node.static = false;
  10896. }
  10897. }
  10898. if (node.ifConditions) {
  10899. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10900. const block = node.ifConditions[i].block;
  10901. markStatic(block);
  10902. if (!block.static) {
  10903. node.static = false;
  10904. }
  10905. }
  10906. }
  10907. }
  10908. }
  10909. function markStaticRoots(node, isInFor) {
  10910. if (node.type === 1) {
  10911. if (node.static || node.once) {
  10912. node.staticInFor = isInFor;
  10913. }
  10914. // For a node to qualify as a static root, it should have children that
  10915. // are not just static text. Otherwise the cost of hoisting out will
  10916. // outweigh the benefits and it's better off to just always render it fresh.
  10917. if (node.static &&
  10918. node.children.length &&
  10919. !(node.children.length === 1 && node.children[0].type === 3)) {
  10920. node.staticRoot = true;
  10921. return;
  10922. }
  10923. else {
  10924. node.staticRoot = false;
  10925. }
  10926. if (node.children) {
  10927. for (let i = 0, l = node.children.length; i < l; i++) {
  10928. markStaticRoots(node.children[i], isInFor || !!node.for);
  10929. }
  10930. }
  10931. if (node.ifConditions) {
  10932. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  10933. markStaticRoots(node.ifConditions[i].block, isInFor);
  10934. }
  10935. }
  10936. }
  10937. }
  10938. function isStatic(node) {
  10939. if (node.type === 2) {
  10940. // expression
  10941. return false;
  10942. }
  10943. if (node.type === 3) {
  10944. // text
  10945. return true;
  10946. }
  10947. return !!(node.pre ||
  10948. (!node.hasBindings && // no dynamic bindings
  10949. !node.if &&
  10950. !node.for && // not v-if or v-for or v-else
  10951. !isBuiltInTag(node.tag) && // not a built-in
  10952. isPlatformReservedTag$1(node.tag) && // not a component
  10953. !isDirectChildOfTemplateFor(node) &&
  10954. Object.keys(node).every(isStaticKey)));
  10955. }
  10956. function isDirectChildOfTemplateFor(node) {
  10957. while (node.parent) {
  10958. node = node.parent;
  10959. if (node.tag !== 'template') {
  10960. return false;
  10961. }
  10962. if (node.for) {
  10963. return true;
  10964. }
  10965. }
  10966. return false;
  10967. }
  10968. const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  10969. const fnInvokeRE = /\([^)]*?\);*$/;
  10970. const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  10971. // KeyboardEvent.keyCode aliases
  10972. const keyCodes = {
  10973. esc: 27,
  10974. tab: 9,
  10975. enter: 13,
  10976. space: 32,
  10977. up: 38,
  10978. left: 37,
  10979. right: 39,
  10980. down: 40,
  10981. delete: [8, 46]
  10982. };
  10983. // KeyboardEvent.key aliases
  10984. const keyNames = {
  10985. // #7880: IE11 and Edge use `Esc` for Escape key name.
  10986. esc: ['Esc', 'Escape'],
  10987. tab: 'Tab',
  10988. enter: 'Enter',
  10989. // #9112: IE11 uses `Spacebar` for Space key name.
  10990. space: [' ', 'Spacebar'],
  10991. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  10992. up: ['Up', 'ArrowUp'],
  10993. left: ['Left', 'ArrowLeft'],
  10994. right: ['Right', 'ArrowRight'],
  10995. down: ['Down', 'ArrowDown'],
  10996. // #9112: IE11 uses `Del` for Delete key name.
  10997. delete: ['Backspace', 'Delete', 'Del']
  10998. };
  10999. // #4868: modifiers that prevent the execution of the listener
  11000. // need to explicitly return null so that we can determine whether to remove
  11001. // the listener for .once
  11002. const genGuard = condition => `if(${condition})return null;`;
  11003. const modifierCode = {
  11004. stop: '$event.stopPropagation();',
  11005. prevent: '$event.preventDefault();',
  11006. self: genGuard(`$event.target !== $event.currentTarget`),
  11007. ctrl: genGuard(`!$event.ctrlKey`),
  11008. shift: genGuard(`!$event.shiftKey`),
  11009. alt: genGuard(`!$event.altKey`),
  11010. meta: genGuard(`!$event.metaKey`),
  11011. left: genGuard(`'button' in $event && $event.button !== 0`),
  11012. middle: genGuard(`'button' in $event && $event.button !== 1`),
  11013. right: genGuard(`'button' in $event && $event.button !== 2`)
  11014. };
  11015. function genHandlers(events, isNative) {
  11016. const prefix = isNative ? 'nativeOn:' : 'on:';
  11017. let staticHandlers = ``;
  11018. let dynamicHandlers = ``;
  11019. for (const name in events) {
  11020. const handlerCode = genHandler(events[name]);
  11021. //@ts-expect-error
  11022. if (events[name] && events[name].dynamic) {
  11023. dynamicHandlers += `${name},${handlerCode},`;
  11024. }
  11025. else {
  11026. staticHandlers += `"${name}":${handlerCode},`;
  11027. }
  11028. }
  11029. staticHandlers = `{${staticHandlers.slice(0, -1)}}`;
  11030. if (dynamicHandlers) {
  11031. return prefix + `_d(${staticHandlers},[${dynamicHandlers.slice(0, -1)}])`;
  11032. }
  11033. else {
  11034. return prefix + staticHandlers;
  11035. }
  11036. }
  11037. function genHandler(handler) {
  11038. if (!handler) {
  11039. return 'function(){}';
  11040. }
  11041. if (Array.isArray(handler)) {
  11042. return `[${handler.map(handler => genHandler(handler)).join(',')}]`;
  11043. }
  11044. const isMethodPath = simplePathRE.test(handler.value);
  11045. const isFunctionExpression = fnExpRE.test(handler.value);
  11046. const isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  11047. if (!handler.modifiers) {
  11048. if (isMethodPath || isFunctionExpression) {
  11049. return handler.value;
  11050. }
  11051. return `function($event){${isFunctionInvocation ? `return ${handler.value}` : handler.value}}`; // inline statement
  11052. }
  11053. else {
  11054. let code = '';
  11055. let genModifierCode = '';
  11056. const keys = [];
  11057. for (const key in handler.modifiers) {
  11058. if (modifierCode[key]) {
  11059. genModifierCode += modifierCode[key];
  11060. // left/right
  11061. if (keyCodes[key]) {
  11062. keys.push(key);
  11063. }
  11064. }
  11065. else if (key === 'exact') {
  11066. const modifiers = handler.modifiers;
  11067. genModifierCode += genGuard(['ctrl', 'shift', 'alt', 'meta']
  11068. .filter(keyModifier => !modifiers[keyModifier])
  11069. .map(keyModifier => `$event.${keyModifier}Key`)
  11070. .join('||'));
  11071. }
  11072. else {
  11073. keys.push(key);
  11074. }
  11075. }
  11076. if (keys.length) {
  11077. code += genKeyFilter(keys);
  11078. }
  11079. // Make sure modifiers like prevent and stop get executed after key filtering
  11080. if (genModifierCode) {
  11081. code += genModifierCode;
  11082. }
  11083. const handlerCode = isMethodPath
  11084. ? `return ${handler.value}.apply(null, arguments)`
  11085. : isFunctionExpression
  11086. ? `return (${handler.value}).apply(null, arguments)`
  11087. : isFunctionInvocation
  11088. ? `return ${handler.value}`
  11089. : handler.value;
  11090. return `function($event){${code}${handlerCode}}`;
  11091. }
  11092. }
  11093. function genKeyFilter(keys) {
  11094. return (
  11095. // make sure the key filters only apply to KeyboardEvents
  11096. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  11097. // key events that do not have keyCode property...
  11098. `if(!$event.type.indexOf('key')&&` +
  11099. `${keys.map(genFilterCode).join('&&')})return null;`);
  11100. }
  11101. function genFilterCode(key) {
  11102. const keyVal = parseInt(key, 10);
  11103. if (keyVal) {
  11104. return `$event.keyCode!==${keyVal}`;
  11105. }
  11106. const keyCode = keyCodes[key];
  11107. const keyName = keyNames[key];
  11108. return (`_k($event.keyCode,` +
  11109. `${JSON.stringify(key)},` +
  11110. `${JSON.stringify(keyCode)},` +
  11111. `$event.key,` +
  11112. `${JSON.stringify(keyName)}` +
  11113. `)`);
  11114. }
  11115. function on(el, dir) {
  11116. if (process.env.NODE_ENV !== 'production' && dir.modifiers) {
  11117. warn$3(`v-on without argument does not support modifiers.`);
  11118. }
  11119. el.wrapListeners = (code) => `_g(${code},${dir.value})`;
  11120. }
  11121. function bind(el, dir) {
  11122. el.wrapData = (code) => {
  11123. return `_b(${code},'${el.tag}',${dir.value},${dir.modifiers && dir.modifiers.prop ? 'true' : 'false'}${dir.modifiers && dir.modifiers.sync ? ',true' : ''})`;
  11124. };
  11125. }
  11126. var baseDirectives = {
  11127. on,
  11128. bind,
  11129. cloak: noop
  11130. };
  11131. class CodegenState {
  11132. constructor(options) {
  11133. this.options = options;
  11134. this.warn = options.warn || baseWarn;
  11135. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  11136. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  11137. this.directives = extend(extend({}, baseDirectives), options.directives);
  11138. const isReservedTag = options.isReservedTag || no;
  11139. this.maybeComponent = (el) => !!el.component || !isReservedTag(el.tag);
  11140. this.onceId = 0;
  11141. this.staticRenderFns = [];
  11142. this.pre = false;
  11143. }
  11144. }
  11145. function generate$1(ast, options) {
  11146. const state = new CodegenState(options);
  11147. // fix #11483, Root level <script> tags should not be rendered.
  11148. const code = ast
  11149. ? ast.tag === 'script'
  11150. ? 'null'
  11151. : genElement(ast, state)
  11152. : '_c("div")';
  11153. return {
  11154. render: `with(this){return ${code}}`,
  11155. staticRenderFns: state.staticRenderFns
  11156. };
  11157. }
  11158. function genElement(el, state) {
  11159. if (el.parent) {
  11160. el.pre = el.pre || el.parent.pre;
  11161. }
  11162. if (el.staticRoot && !el.staticProcessed) {
  11163. return genStatic(el, state);
  11164. }
  11165. else if (el.once && !el.onceProcessed) {
  11166. return genOnce(el, state);
  11167. }
  11168. else if (el.for && !el.forProcessed) {
  11169. return genFor(el, state);
  11170. }
  11171. else if (el.if && !el.ifProcessed) {
  11172. return genIf(el, state);
  11173. }
  11174. else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  11175. return genChildren(el, state) || 'void 0';
  11176. }
  11177. else if (el.tag === 'slot') {
  11178. return genSlot(el, state);
  11179. }
  11180. else {
  11181. // component or element
  11182. let code;
  11183. if (el.component) {
  11184. code = genComponent(el.component, el, state);
  11185. }
  11186. else {
  11187. let data;
  11188. const maybeComponent = state.maybeComponent(el);
  11189. if (!el.plain || (el.pre && maybeComponent)) {
  11190. data = genData(el, state);
  11191. }
  11192. let tag;
  11193. // check if this is a component in <script setup>
  11194. const bindings = state.options.bindings;
  11195. if (maybeComponent && bindings && bindings.__isScriptSetup !== false) {
  11196. tag = checkBindingType(bindings, el.tag);
  11197. }
  11198. if (!tag)
  11199. tag = `'${el.tag}'`;
  11200. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  11201. code = `_c(${tag}${data ? `,${data}` : '' // data
  11202. }${children ? `,${children}` : '' // children
  11203. })`;
  11204. }
  11205. // module transforms
  11206. for (let i = 0; i < state.transforms.length; i++) {
  11207. code = state.transforms[i](el, code);
  11208. }
  11209. return code;
  11210. }
  11211. }
  11212. function checkBindingType(bindings, key) {
  11213. const camelName = camelize(key);
  11214. const PascalName = capitalize(camelName);
  11215. const checkType = (type) => {
  11216. if (bindings[key] === type) {
  11217. return key;
  11218. }
  11219. if (bindings[camelName] === type) {
  11220. return camelName;
  11221. }
  11222. if (bindings[PascalName] === type) {
  11223. return PascalName;
  11224. }
  11225. };
  11226. const fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) ||
  11227. checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */);
  11228. if (fromConst) {
  11229. return fromConst;
  11230. }
  11231. const fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) ||
  11232. checkType("setup-ref" /* BindingTypes.SETUP_REF */) ||
  11233. checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
  11234. if (fromMaybeRef) {
  11235. return fromMaybeRef;
  11236. }
  11237. }
  11238. // hoist static sub-trees out
  11239. function genStatic(el, state) {
  11240. el.staticProcessed = true;
  11241. // Some elements (templates) need to behave differently inside of a v-pre
  11242. // node. All pre nodes are static roots, so we can use this as a location to
  11243. // wrap a state change and reset it upon exiting the pre node.
  11244. const originalPreState = state.pre;
  11245. if (el.pre) {
  11246. state.pre = el.pre;
  11247. }
  11248. state.staticRenderFns.push(`with(this){return ${genElement(el, state)}}`);
  11249. state.pre = originalPreState;
  11250. return `_m(${state.staticRenderFns.length - 1}${el.staticInFor ? ',true' : ''})`;
  11251. }
  11252. // v-once
  11253. function genOnce(el, state) {
  11254. el.onceProcessed = true;
  11255. if (el.if && !el.ifProcessed) {
  11256. return genIf(el, state);
  11257. }
  11258. else if (el.staticInFor) {
  11259. let key = '';
  11260. let parent = el.parent;
  11261. while (parent) {
  11262. if (parent.for) {
  11263. key = parent.key;
  11264. break;
  11265. }
  11266. parent = parent.parent;
  11267. }
  11268. if (!key) {
  11269. process.env.NODE_ENV !== 'production' &&
  11270. state.warn(`v-once can only be used inside v-for that is keyed. `, el.rawAttrsMap['v-once']);
  11271. return genElement(el, state);
  11272. }
  11273. return `_o(${genElement(el, state)},${state.onceId++},${key})`;
  11274. }
  11275. else {
  11276. return genStatic(el, state);
  11277. }
  11278. }
  11279. function genIf(el, state, altGen, altEmpty) {
  11280. el.ifProcessed = true; // avoid recursion
  11281. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty);
  11282. }
  11283. function genIfConditions(conditions, state, altGen, altEmpty) {
  11284. if (!conditions.length) {
  11285. return altEmpty || '_e()';
  11286. }
  11287. const condition = conditions.shift();
  11288. if (condition.exp) {
  11289. return `(${condition.exp})?${genTernaryExp(condition.block)}:${genIfConditions(conditions, state, altGen, altEmpty)}`;
  11290. }
  11291. else {
  11292. return `${genTernaryExp(condition.block)}`;
  11293. }
  11294. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  11295. function genTernaryExp(el) {
  11296. return altGen
  11297. ? altGen(el, state)
  11298. : el.once
  11299. ? genOnce(el, state)
  11300. : genElement(el, state);
  11301. }
  11302. }
  11303. function genFor(el, state, altGen, altHelper) {
  11304. const exp = el.for;
  11305. const alias = el.alias;
  11306. const iterator1 = el.iterator1 ? `,${el.iterator1}` : '';
  11307. const iterator2 = el.iterator2 ? `,${el.iterator2}` : '';
  11308. if (process.env.NODE_ENV !== 'production' &&
  11309. state.maybeComponent(el) &&
  11310. el.tag !== 'slot' &&
  11311. el.tag !== 'template' &&
  11312. !el.key) {
  11313. state.warn(`<${el.tag} v-for="${alias} in ${exp}">: component lists rendered with ` +
  11314. `v-for should have explicit keys. ` +
  11315. `See https://vuejs.org/guide/list.html#key for more info.`, el.rawAttrsMap['v-for'], true /* tip */);
  11316. }
  11317. el.forProcessed = true; // avoid recursion
  11318. return (`${altHelper || '_l'}((${exp}),` +
  11319. `function(${alias}${iterator1}${iterator2}){` +
  11320. `return ${(altGen || genElement)(el, state)}` +
  11321. '})');
  11322. }
  11323. function genData(el, state) {
  11324. let data = '{';
  11325. // directives first.
  11326. // directives may mutate the el's other properties before they are generated.
  11327. const dirs = genDirectives(el, state);
  11328. if (dirs)
  11329. data += dirs + ',';
  11330. // key
  11331. if (el.key) {
  11332. data += `key:${el.key},`;
  11333. }
  11334. // ref
  11335. if (el.ref) {
  11336. data += `ref:${el.ref},`;
  11337. }
  11338. if (el.refInFor) {
  11339. data += `refInFor:true,`;
  11340. }
  11341. // pre
  11342. if (el.pre) {
  11343. data += `pre:true,`;
  11344. }
  11345. // record original tag name for components using "is" attribute
  11346. if (el.component) {
  11347. data += `tag:"${el.tag}",`;
  11348. }
  11349. // module data generation functions
  11350. for (let i = 0; i < state.dataGenFns.length; i++) {
  11351. data += state.dataGenFns[i](el);
  11352. }
  11353. // attributes
  11354. if (el.attrs) {
  11355. data += `attrs:${genProps(el.attrs)},`;
  11356. }
  11357. // DOM props
  11358. if (el.props) {
  11359. data += `domProps:${genProps(el.props)},`;
  11360. }
  11361. // event handlers
  11362. if (el.events) {
  11363. data += `${genHandlers(el.events, false)},`;
  11364. }
  11365. if (el.nativeEvents) {
  11366. data += `${genHandlers(el.nativeEvents, true)},`;
  11367. }
  11368. // slot target
  11369. // only for non-scoped slots
  11370. if (el.slotTarget && !el.slotScope) {
  11371. data += `slot:${el.slotTarget},`;
  11372. }
  11373. // scoped slots
  11374. if (el.scopedSlots) {
  11375. data += `${genScopedSlots(el, el.scopedSlots, state)},`;
  11376. }
  11377. // component v-model
  11378. if (el.model) {
  11379. data += `model:{value:${el.model.value},callback:${el.model.callback},expression:${el.model.expression}},`;
  11380. }
  11381. // inline-template
  11382. if (el.inlineTemplate) {
  11383. const inlineTemplate = genInlineTemplate(el, state);
  11384. if (inlineTemplate) {
  11385. data += `${inlineTemplate},`;
  11386. }
  11387. }
  11388. data = data.replace(/,$/, '') + '}';
  11389. // v-bind dynamic argument wrap
  11390. // v-bind with dynamic arguments must be applied using the same v-bind object
  11391. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  11392. if (el.dynamicAttrs) {
  11393. data = `_b(${data},"${el.tag}",${genProps(el.dynamicAttrs)})`;
  11394. }
  11395. // v-bind data wrap
  11396. if (el.wrapData) {
  11397. data = el.wrapData(data);
  11398. }
  11399. // v-on data wrap
  11400. if (el.wrapListeners) {
  11401. data = el.wrapListeners(data);
  11402. }
  11403. return data;
  11404. }
  11405. function genDirectives(el, state) {
  11406. const dirs = el.directives;
  11407. if (!dirs)
  11408. return;
  11409. let res = 'directives:[';
  11410. let hasRuntime = false;
  11411. let i, l, dir, needRuntime;
  11412. for (i = 0, l = dirs.length; i < l; i++) {
  11413. dir = dirs[i];
  11414. needRuntime = true;
  11415. const gen = state.directives[dir.name];
  11416. if (gen) {
  11417. // compile-time directive that manipulates AST.
  11418. // returns true if it also needs a runtime counterpart.
  11419. needRuntime = !!gen(el, dir, state.warn);
  11420. }
  11421. if (needRuntime) {
  11422. hasRuntime = true;
  11423. res += `{name:"${dir.name}",rawName:"${dir.rawName}"${dir.value
  11424. ? `,value:(${dir.value}),expression:${JSON.stringify(dir.value)}`
  11425. : ''}${dir.arg ? `,arg:${dir.isDynamicArg ? dir.arg : `"${dir.arg}"`}` : ''}${dir.modifiers ? `,modifiers:${JSON.stringify(dir.modifiers)}` : ''}},`;
  11426. }
  11427. }
  11428. if (hasRuntime) {
  11429. return res.slice(0, -1) + ']';
  11430. }
  11431. }
  11432. function genInlineTemplate(el, state) {
  11433. const ast = el.children[0];
  11434. if (process.env.NODE_ENV !== 'production' && (el.children.length !== 1 || ast.type !== 1)) {
  11435. state.warn('Inline-template components must have exactly one child element.', { start: el.start });
  11436. }
  11437. if (ast && ast.type === 1) {
  11438. const inlineRenderFns = generate$1(ast, state.options);
  11439. return `inlineTemplate:{render:function(){${inlineRenderFns.render}},staticRenderFns:[${inlineRenderFns.staticRenderFns
  11440. .map(code => `function(){${code}}`)
  11441. .join(',')}]}`;
  11442. }
  11443. }
  11444. function genScopedSlots(el, slots, state) {
  11445. // by default scoped slots are considered "stable", this allows child
  11446. // components with only scoped slots to skip forced updates from parent.
  11447. // but in some cases we have to bail-out of this optimization
  11448. // for example if the slot contains dynamic names, has v-if or v-for on them...
  11449. let needsForceUpdate = el.for ||
  11450. Object.keys(slots).some(key => {
  11451. const slot = slots[key];
  11452. return (slot.slotTargetDynamic || slot.if || slot.for || containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  11453. );
  11454. });
  11455. // #9534: if a component with scoped slots is inside a conditional branch,
  11456. // it's possible for the same component to be reused but with different
  11457. // compiled slot content. To avoid that, we generate a unique key based on
  11458. // the generated code of all the slot contents.
  11459. let needsKey = !!el.if;
  11460. // OR when it is inside another scoped slot or v-for (the reactivity may be
  11461. // disconnected due to the intermediate scope variable)
  11462. // #9438, #9506
  11463. // TODO: this can be further optimized by properly analyzing in-scope bindings
  11464. // and skip force updating ones that do not actually use scope variables.
  11465. if (!needsForceUpdate) {
  11466. let parent = el.parent;
  11467. while (parent) {
  11468. if ((parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  11469. parent.for) {
  11470. needsForceUpdate = true;
  11471. break;
  11472. }
  11473. if (parent.if) {
  11474. needsKey = true;
  11475. }
  11476. parent = parent.parent;
  11477. }
  11478. }
  11479. const generatedSlots = Object.keys(slots)
  11480. .map(key => genScopedSlot(slots[key], state))
  11481. .join(',');
  11482. return `scopedSlots:_u([${generatedSlots}]${needsForceUpdate ? `,null,true` : ``}${!needsForceUpdate && needsKey ? `,null,false,${hash(generatedSlots)}` : ``})`;
  11483. }
  11484. function hash(str) {
  11485. let hash = 5381;
  11486. let i = str.length;
  11487. while (i) {
  11488. hash = (hash * 33) ^ str.charCodeAt(--i);
  11489. }
  11490. return hash >>> 0;
  11491. }
  11492. function containsSlotChild(el) {
  11493. if (el.type === 1) {
  11494. if (el.tag === 'slot') {
  11495. return true;
  11496. }
  11497. return el.children.some(containsSlotChild);
  11498. }
  11499. return false;
  11500. }
  11501. function genScopedSlot(el, state) {
  11502. const isLegacySyntax = el.attrsMap['slot-scope'];
  11503. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  11504. return genIf(el, state, genScopedSlot, `null`);
  11505. }
  11506. if (el.for && !el.forProcessed) {
  11507. return genFor(el, state, genScopedSlot);
  11508. }
  11509. const slotScope = el.slotScope === emptySlotScopeToken ? `` : String(el.slotScope);
  11510. const fn = `function(${slotScope}){` +
  11511. `return ${el.tag === 'template'
  11512. ? el.if && isLegacySyntax
  11513. ? `(${el.if})?${genChildren(el, state) || 'undefined'}:undefined`
  11514. : genChildren(el, state) || 'undefined'
  11515. : genElement(el, state)}}`;
  11516. // reverse proxy v-slot without scope on this.$slots
  11517. const reverseProxy = slotScope ? `` : `,proxy:true`;
  11518. return `{key:${el.slotTarget || `"default"`},fn:${fn}${reverseProxy}}`;
  11519. }
  11520. function genChildren(el, state, checkSkip, altGenElement, altGenNode) {
  11521. const children = el.children;
  11522. if (children.length) {
  11523. const el = children[0];
  11524. // optimize single v-for
  11525. if (children.length === 1 &&
  11526. el.for &&
  11527. el.tag !== 'template' &&
  11528. el.tag !== 'slot') {
  11529. const normalizationType = checkSkip
  11530. ? state.maybeComponent(el)
  11531. ? `,1`
  11532. : `,0`
  11533. : ``;
  11534. return `${(altGenElement || genElement)(el, state)}${normalizationType}`;
  11535. }
  11536. const normalizationType = checkSkip
  11537. ? getNormalizationType(children, state.maybeComponent)
  11538. : 0;
  11539. const gen = altGenNode || genNode;
  11540. return `[${children.map(c => gen(c, state)).join(',')}]${normalizationType ? `,${normalizationType}` : ''}`;
  11541. }
  11542. }
  11543. // determine the normalization needed for the children array.
  11544. // 0: no normalization needed
  11545. // 1: simple normalization needed (possible 1-level deep nested array)
  11546. // 2: full normalization needed
  11547. function getNormalizationType(children, maybeComponent) {
  11548. let res = 0;
  11549. for (let i = 0; i < children.length; i++) {
  11550. const el = children[i];
  11551. if (el.type !== 1) {
  11552. continue;
  11553. }
  11554. if (needsNormalization(el) ||
  11555. (el.ifConditions &&
  11556. el.ifConditions.some(c => needsNormalization(c.block)))) {
  11557. res = 2;
  11558. break;
  11559. }
  11560. if (maybeComponent(el) ||
  11561. (el.ifConditions && el.ifConditions.some(c => maybeComponent(c.block)))) {
  11562. res = 1;
  11563. }
  11564. }
  11565. return res;
  11566. }
  11567. function needsNormalization(el) {
  11568. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot';
  11569. }
  11570. function genNode(node, state) {
  11571. if (node.type === 1) {
  11572. return genElement(node, state);
  11573. }
  11574. else if (node.type === 3 && node.isComment) {
  11575. return genComment(node);
  11576. }
  11577. else {
  11578. return genText(node);
  11579. }
  11580. }
  11581. function genText(text) {
  11582. return `_v(${text.type === 2
  11583. ? text.expression // no need for () because already wrapped in _s()
  11584. : transformSpecialNewlines(JSON.stringify(text.text))})`;
  11585. }
  11586. function genComment(comment) {
  11587. return `_e(${JSON.stringify(comment.text)})`;
  11588. }
  11589. function genSlot(el, state) {
  11590. const slotName = el.slotName || '"default"';
  11591. const children = genChildren(el, state);
  11592. let res = `_t(${slotName}${children ? `,function(){return ${children}}` : ''}`;
  11593. const attrs = el.attrs || el.dynamicAttrs
  11594. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(attr => ({
  11595. // slot props are camelized
  11596. name: camelize(attr.name),
  11597. value: attr.value,
  11598. dynamic: attr.dynamic
  11599. })))
  11600. : null;
  11601. const bind = el.attrsMap['v-bind'];
  11602. if ((attrs || bind) && !children) {
  11603. res += `,null`;
  11604. }
  11605. if (attrs) {
  11606. res += `,${attrs}`;
  11607. }
  11608. if (bind) {
  11609. res += `${attrs ? '' : ',null'},${bind}`;
  11610. }
  11611. return res + ')';
  11612. }
  11613. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  11614. function genComponent(componentName, el, state) {
  11615. const children = el.inlineTemplate ? null : genChildren(el, state, true);
  11616. return `_c(${componentName},${genData(el, state)}${children ? `,${children}` : ''})`;
  11617. }
  11618. function genProps(props) {
  11619. let staticProps = ``;
  11620. let dynamicProps = ``;
  11621. for (let i = 0; i < props.length; i++) {
  11622. const prop = props[i];
  11623. const value = transformSpecialNewlines(prop.value);
  11624. if (prop.dynamic) {
  11625. dynamicProps += `${prop.name},${value},`;
  11626. }
  11627. else {
  11628. staticProps += `"${prop.name}":${value},`;
  11629. }
  11630. }
  11631. staticProps = `{${staticProps.slice(0, -1)}}`;
  11632. if (dynamicProps) {
  11633. return `_d(${staticProps},[${dynamicProps.slice(0, -1)}])`;
  11634. }
  11635. else {
  11636. return staticProps;
  11637. }
  11638. }
  11639. // #3895, #4268
  11640. function transformSpecialNewlines(text) {
  11641. return text.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
  11642. }
  11643. // these keywords should not appear inside expressions, but operators like
  11644. // typeof, instanceof and in are allowed
  11645. const prohibitedKeywordRE = new RegExp('\\b' +
  11646. ('do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  11647. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  11648. 'extends,finally,continue,debugger,function,arguments')
  11649. .split(',')
  11650. .join('\\b|\\b') +
  11651. '\\b');
  11652. // these unary operators should not be used as property/method names
  11653. const unaryOperatorsRE = new RegExp('\\b' +
  11654. 'delete,typeof,void'.split(',').join('\\s*\\([^\\)]*\\)|\\b') +
  11655. '\\s*\\([^\\)]*\\)');
  11656. // strip strings in expressions
  11657. const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  11658. // detect problematic expressions in a template
  11659. function detectErrors(ast, warn) {
  11660. if (ast) {
  11661. checkNode(ast, warn);
  11662. }
  11663. }
  11664. function checkNode(node, warn) {
  11665. if (node.type === 1) {
  11666. for (const name in node.attrsMap) {
  11667. if (dirRE.test(name)) {
  11668. const value = node.attrsMap[name];
  11669. if (value) {
  11670. const range = node.rawAttrsMap[name];
  11671. if (name === 'v-for') {
  11672. checkFor(node, `v-for="${value}"`, warn, range);
  11673. }
  11674. else if (name === 'v-slot' || name[0] === '#') {
  11675. checkFunctionParameterExpression(value, `${name}="${value}"`, warn, range);
  11676. }
  11677. else if (onRE.test(name)) {
  11678. checkEvent(value, `${name}="${value}"`, warn, range);
  11679. }
  11680. else {
  11681. checkExpression(value, `${name}="${value}"`, warn, range);
  11682. }
  11683. }
  11684. }
  11685. }
  11686. if (node.children) {
  11687. for (let i = 0; i < node.children.length; i++) {
  11688. checkNode(node.children[i], warn);
  11689. }
  11690. }
  11691. }
  11692. else if (node.type === 2) {
  11693. checkExpression(node.expression, node.text, warn, node);
  11694. }
  11695. }
  11696. function checkEvent(exp, text, warn, range) {
  11697. const stripped = exp.replace(stripStringRE, '');
  11698. const keywordMatch = stripped.match(unaryOperatorsRE);
  11699. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  11700. warn(`avoid using JavaScript unary operator as property name: ` +
  11701. `"${keywordMatch[0]}" in expression ${text.trim()}`, range);
  11702. }
  11703. checkExpression(exp, text, warn, range);
  11704. }
  11705. function checkFor(node, text, warn, range) {
  11706. checkExpression(node.for || '', text, warn, range);
  11707. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  11708. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  11709. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  11710. }
  11711. function checkIdentifier(ident, type, text, warn, range) {
  11712. if (typeof ident === 'string') {
  11713. try {
  11714. new Function(`var ${ident}=_`);
  11715. }
  11716. catch (e) {
  11717. warn(`invalid ${type} "${ident}" in expression: ${text.trim()}`, range);
  11718. }
  11719. }
  11720. }
  11721. function checkExpression(exp, text, warn, range) {
  11722. try {
  11723. new Function(`return ${exp}`);
  11724. }
  11725. catch (e) {
  11726. const keywordMatch = exp
  11727. .replace(stripStringRE, '')
  11728. .match(prohibitedKeywordRE);
  11729. if (keywordMatch) {
  11730. warn(`avoid using JavaScript keyword as property name: ` +
  11731. `"${keywordMatch[0]}"\n Raw expression: ${text.trim()}`, range);
  11732. }
  11733. else {
  11734. warn(`invalid expression: ${e.message} in\n\n` +
  11735. ` ${exp}\n\n` +
  11736. ` Raw expression: ${text.trim()}\n`, range);
  11737. }
  11738. }
  11739. }
  11740. function checkFunctionParameterExpression(exp, text, warn, range) {
  11741. try {
  11742. new Function(exp, '');
  11743. }
  11744. catch (e) {
  11745. warn(`invalid function parameter expression: ${e.message} in\n\n` +
  11746. ` ${exp}\n\n` +
  11747. ` Raw expression: ${text.trim()}\n`, range);
  11748. }
  11749. }
  11750. function createFunction(code, errors) {
  11751. try {
  11752. return new Function(code);
  11753. }
  11754. catch (err) {
  11755. errors.push({ err, code });
  11756. return noop;
  11757. }
  11758. }
  11759. function createCompileToFunctionFn(compile) {
  11760. const cache = Object.create(null);
  11761. return function compileToFunctions(template, options, vm) {
  11762. options = extend({}, options);
  11763. const warn = options.warn || warn$3;
  11764. delete options.warn;
  11765. /* istanbul ignore if */
  11766. if (process.env.NODE_ENV !== 'production') {
  11767. // detect possible CSP restriction
  11768. try {
  11769. new Function('return 1');
  11770. }
  11771. catch (e) {
  11772. if (e.toString().match(/unsafe-eval|CSP/)) {
  11773. warn('It seems you are using the standalone build of Vue.js in an ' +
  11774. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  11775. 'The template compiler cannot work in this environment. Consider ' +
  11776. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  11777. 'templates into render functions.');
  11778. }
  11779. }
  11780. }
  11781. // check cache
  11782. const key = options.delimiters
  11783. ? String(options.delimiters) + template
  11784. : template;
  11785. if (cache[key]) {
  11786. return cache[key];
  11787. }
  11788. // compile
  11789. const compiled = compile(template, options);
  11790. // check compilation errors/tips
  11791. if (process.env.NODE_ENV !== 'production') {
  11792. if (compiled.errors && compiled.errors.length) {
  11793. if (options.outputSourceRange) {
  11794. compiled.errors.forEach(e => {
  11795. warn(`Error compiling template:\n\n${e.msg}\n\n` +
  11796. generateCodeFrame(template, e.start, e.end), vm);
  11797. });
  11798. }
  11799. else {
  11800. warn(`Error compiling template:\n\n${template}\n\n` +
  11801. compiled.errors.map(e => `- ${e}`).join('\n') +
  11802. '\n', vm);
  11803. }
  11804. }
  11805. if (compiled.tips && compiled.tips.length) {
  11806. if (options.outputSourceRange) {
  11807. compiled.tips.forEach(e => tip(e.msg, vm));
  11808. }
  11809. else {
  11810. compiled.tips.forEach(msg => tip(msg, vm));
  11811. }
  11812. }
  11813. }
  11814. // turn code into functions
  11815. const res = {};
  11816. const fnGenErrors = [];
  11817. res.render = createFunction(compiled.render, fnGenErrors);
  11818. res.staticRenderFns = compiled.staticRenderFns.map(code => {
  11819. return createFunction(code, fnGenErrors);
  11820. });
  11821. // check function generation errors.
  11822. // this should only happen if there is a bug in the compiler itself.
  11823. // mostly for codegen development use
  11824. /* istanbul ignore if */
  11825. if (process.env.NODE_ENV !== 'production') {
  11826. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  11827. warn(`Failed to generate render function:\n\n` +
  11828. fnGenErrors
  11829. .map(({ err, code }) => `${err.toString()} in\n\n${code}\n`)
  11830. .join('\n'), vm);
  11831. }
  11832. }
  11833. return (cache[key] = res);
  11834. };
  11835. }
  11836. function createCompilerCreator(baseCompile) {
  11837. return function createCompiler(baseOptions) {
  11838. function compile(template, options) {
  11839. const finalOptions = Object.create(baseOptions);
  11840. const errors = [];
  11841. const tips = [];
  11842. let warn = (msg, range, tip) => {
  11843. (tip ? tips : errors).push(msg);
  11844. };
  11845. if (options) {
  11846. if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
  11847. // $flow-disable-line
  11848. const leadingSpaceLength = template.match(/^\s*/)[0].length;
  11849. warn = (msg, range, tip) => {
  11850. const data = typeof msg === 'string' ? { msg } : msg;
  11851. if (range) {
  11852. if (range.start != null) {
  11853. data.start = range.start + leadingSpaceLength;
  11854. }
  11855. if (range.end != null) {
  11856. data.end = range.end + leadingSpaceLength;
  11857. }
  11858. }
  11859. (tip ? tips : errors).push(data);
  11860. };
  11861. }
  11862. // merge custom modules
  11863. if (options.modules) {
  11864. finalOptions.modules = (baseOptions.modules || []).concat(options.modules);
  11865. }
  11866. // merge custom directives
  11867. if (options.directives) {
  11868. finalOptions.directives = extend(Object.create(baseOptions.directives || null), options.directives);
  11869. }
  11870. // copy other options
  11871. for (const key in options) {
  11872. if (key !== 'modules' && key !== 'directives') {
  11873. finalOptions[key] = options[key];
  11874. }
  11875. }
  11876. }
  11877. finalOptions.warn = warn;
  11878. const compiled = baseCompile(template.trim(), finalOptions);
  11879. if (process.env.NODE_ENV !== 'production') {
  11880. detectErrors(compiled.ast, warn);
  11881. }
  11882. compiled.errors = errors;
  11883. compiled.tips = tips;
  11884. return compiled;
  11885. }
  11886. return {
  11887. compile,
  11888. compileToFunctions: createCompileToFunctionFn(compile)
  11889. };
  11890. };
  11891. }
  11892. // `createCompilerCreator` allows creating compilers that use alternative
  11893. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  11894. // Here we just export a default compiler using the default parts.
  11895. const createCompiler$1 = createCompilerCreator(function baseCompile(template, options) {
  11896. const ast = parse$1(template.trim(), options);
  11897. if (options.optimize !== false) {
  11898. optimize$1(ast, options);
  11899. }
  11900. const code = generate$1(ast, options);
  11901. return {
  11902. ast,
  11903. render: code.render,
  11904. staticRenderFns: code.staticRenderFns
  11905. };
  11906. });
  11907. const { compile: compile$1, compileToFunctions: compileToFunctions$1 } = createCompiler$1(baseOptions);
  11908. const isAttr = makeMap('accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' +
  11909. 'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' +
  11910. 'checked,cite,class,code,codebase,color,cols,colspan,content,' +
  11911. 'contenteditable,contextmenu,controls,coords,data,datetime,default,' +
  11912. 'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,for,' +
  11913. 'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,' +
  11914. 'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' +
  11915. 'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' +
  11916. 'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' +
  11917. 'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' +
  11918. 'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' +
  11919. 'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' +
  11920. 'target,title,usemap,value,width,wrap');
  11921. /* istanbul ignore next */
  11922. const isRenderableAttr = (name) => {
  11923. return (isAttr(name) || name.indexOf('data-') === 0 || name.indexOf('aria-') === 0);
  11924. };
  11925. const propsToAttrMap = {
  11926. acceptCharset: 'accept-charset',
  11927. className: 'class',
  11928. htmlFor: 'for',
  11929. httpEquiv: 'http-equiv'
  11930. };
  11931. const ESC = {
  11932. '<': '&lt;',
  11933. '>': '&gt;',
  11934. '"': '&quot;',
  11935. '&': '&amp;'
  11936. };
  11937. function escape(s) {
  11938. return s.replace(/[<>"&]/g, escapeChar);
  11939. }
  11940. function escapeChar(a) {
  11941. return ESC[a] || a;
  11942. }
  11943. const plainStringRE = /^"(?:[^"\\]|\\.)*"$|^'(?:[^'\\]|\\.)*'$/;
  11944. // let the model AST transform translate v-model into appropriate
  11945. // props bindings
  11946. function applyModelTransform(el, state) {
  11947. if (el.directives) {
  11948. for (let i = 0; i < el.directives.length; i++) {
  11949. const dir = el.directives[i];
  11950. if (dir.name === 'model') {
  11951. state.directives.model(el, dir, state.warn);
  11952. // remove value for textarea as its converted to text
  11953. if (el.tag === 'textarea' && el.props) {
  11954. el.props = el.props.filter(p => p.name !== 'value');
  11955. }
  11956. break;
  11957. }
  11958. }
  11959. }
  11960. }
  11961. function genAttrSegments(attrs) {
  11962. return attrs.map(({ name, value }) => genAttrSegment(name, value));
  11963. }
  11964. function genDOMPropSegments(props, attrs) {
  11965. const segments = [];
  11966. props.forEach(({ name, value }) => {
  11967. name = propsToAttrMap[name] || name.toLowerCase();
  11968. if (isRenderableAttr(name) &&
  11969. !(attrs && attrs.some(a => a.name === name))) {
  11970. segments.push(genAttrSegment(name, value));
  11971. }
  11972. });
  11973. return segments;
  11974. }
  11975. function genAttrSegment(name, value) {
  11976. if (plainStringRE.test(value)) {
  11977. // force double quote
  11978. value = value.replace(/^'|'$/g, '"');
  11979. // force enumerated attr to "true"
  11980. if (isEnumeratedAttr(name) && value !== `"false"`) {
  11981. value = `"true"`;
  11982. }
  11983. return {
  11984. type: RAW,
  11985. value: isBooleanAttr(name)
  11986. ? ` ${name}="${name}"`
  11987. : value === '""'
  11988. ? ` ${name}`
  11989. : ` ${name}="${JSON.parse(value)}"`
  11990. };
  11991. }
  11992. else {
  11993. return {
  11994. type: EXPRESSION,
  11995. value: `_ssrAttr(${JSON.stringify(name)},${value})`
  11996. };
  11997. }
  11998. }
  11999. function genClassSegments(staticClass, classBinding) {
  12000. if (staticClass && !classBinding) {
  12001. return [{ type: RAW, value: ` class="${JSON.parse(staticClass)}"` }];
  12002. }
  12003. else {
  12004. return [
  12005. {
  12006. type: EXPRESSION,
  12007. value: `_ssrClass(${staticClass || 'null'},${classBinding || 'null'})`
  12008. }
  12009. ];
  12010. }
  12011. }
  12012. function genStyleSegments(staticStyle, parsedStaticStyle, styleBinding, vShowExpression) {
  12013. if (staticStyle && !styleBinding && !vShowExpression) {
  12014. return [{ type: RAW, value: ` style=${JSON.stringify(staticStyle)}` }];
  12015. }
  12016. else {
  12017. return [
  12018. {
  12019. type: EXPRESSION,
  12020. value: `_ssrStyle(${parsedStaticStyle || 'null'},${styleBinding || 'null'}, ${vShowExpression
  12021. ? `{ display: (${vShowExpression}) ? '' : 'none' }`
  12022. : 'null'})`
  12023. }
  12024. ];
  12025. }
  12026. }
  12027. /**
  12028. * In SSR, the vdom tree is generated only once and never patched, so
  12029. * we can optimize most element / trees into plain string render functions.
  12030. * The SSR optimizer walks the AST tree to detect optimizable elements and trees.
  12031. *
  12032. * The criteria for SSR optimizability is quite a bit looser than static tree
  12033. * detection (which is designed for client re-render). In SSR we bail only for
  12034. * components/slots/custom directives.
  12035. */
  12036. // optimizability constants
  12037. const optimizability = {
  12038. FALSE: 0,
  12039. FULL: 1,
  12040. SELF: 2,
  12041. CHILDREN: 3,
  12042. PARTIAL: 4 // self un-optimizable with some un-optimizable children
  12043. };
  12044. let isPlatformReservedTag;
  12045. function optimize(root, options) {
  12046. if (!root)
  12047. return;
  12048. isPlatformReservedTag = options.isReservedTag || no;
  12049. walk(root, true);
  12050. }
  12051. function walk(node, isRoot) {
  12052. if (isUnOptimizableTree(node)) {
  12053. node.ssrOptimizability = optimizability.FALSE;
  12054. return;
  12055. }
  12056. // root node or nodes with custom directives should always be a VNode
  12057. const selfUnoptimizable = isRoot || hasCustomDirective(node);
  12058. const check = child => {
  12059. if (child.ssrOptimizability !== optimizability.FULL) {
  12060. node.ssrOptimizability = selfUnoptimizable
  12061. ? optimizability.PARTIAL
  12062. : optimizability.SELF;
  12063. }
  12064. };
  12065. if (selfUnoptimizable) {
  12066. node.ssrOptimizability = optimizability.CHILDREN;
  12067. }
  12068. if (node.type === 1) {
  12069. for (let i = 0, l = node.children.length; i < l; i++) {
  12070. const child = node.children[i];
  12071. walk(child);
  12072. check(child);
  12073. }
  12074. if (node.ifConditions) {
  12075. for (let i = 1, l = node.ifConditions.length; i < l; i++) {
  12076. const block = node.ifConditions[i].block;
  12077. walk(block, isRoot);
  12078. check(block);
  12079. }
  12080. }
  12081. if (node.ssrOptimizability == null ||
  12082. (!isRoot && (node.attrsMap['v-html'] || node.attrsMap['v-text']))) {
  12083. node.ssrOptimizability = optimizability.FULL;
  12084. }
  12085. else {
  12086. node.children = optimizeSiblings(node);
  12087. }
  12088. }
  12089. else {
  12090. node.ssrOptimizability = optimizability.FULL;
  12091. }
  12092. }
  12093. function optimizeSiblings(el) {
  12094. const children = el.children;
  12095. const optimizedChildren = [];
  12096. let currentOptimizableGroup = [];
  12097. const pushGroup = () => {
  12098. if (currentOptimizableGroup.length) {
  12099. optimizedChildren.push({
  12100. type: 1,
  12101. parent: el,
  12102. tag: 'template',
  12103. attrsList: [],
  12104. attrsMap: {},
  12105. rawAttrsMap: {},
  12106. children: currentOptimizableGroup,
  12107. ssrOptimizability: optimizability.FULL
  12108. });
  12109. }
  12110. currentOptimizableGroup = [];
  12111. };
  12112. for (let i = 0; i < children.length; i++) {
  12113. const c = children[i];
  12114. if (c.ssrOptimizability === optimizability.FULL) {
  12115. currentOptimizableGroup.push(c);
  12116. }
  12117. else {
  12118. // wrap fully-optimizable adjacent siblings inside a template tag
  12119. // so that they can be optimized into a single ssrNode by codegen
  12120. pushGroup();
  12121. optimizedChildren.push(c);
  12122. }
  12123. }
  12124. pushGroup();
  12125. return optimizedChildren;
  12126. }
  12127. function isUnOptimizableTree(node) {
  12128. if (node.type === 2 || node.type === 3) {
  12129. // text or expression
  12130. return false;
  12131. }
  12132. return (isBuiltInTag(node.tag) || // built-in (slot, component)
  12133. !isPlatformReservedTag(node.tag) || // custom component
  12134. !!node.component || // "is" component
  12135. isSelectWithModel(node) // <select v-model> requires runtime inspection
  12136. );
  12137. }
  12138. const isBuiltInDir = makeMap('text,html,show,on,bind,model,pre,cloak,once');
  12139. function hasCustomDirective(node) {
  12140. return (node.type === 1 &&
  12141. node.directives &&
  12142. node.directives.some(d => !isBuiltInDir(d.name)));
  12143. }
  12144. // <select v-model> cannot be optimized because it requires a runtime check
  12145. // to determine proper selected option
  12146. function isSelectWithModel(node) {
  12147. return (node.type === 1 &&
  12148. node.tag === 'select' &&
  12149. node.directives != null &&
  12150. node.directives.some(d => d.name === 'model'));
  12151. }
  12152. // The SSR codegen is essentially extending the default codegen to handle
  12153. // segment types
  12154. const RAW = 0;
  12155. const INTERPOLATION = 1;
  12156. const EXPRESSION = 2;
  12157. function generate(ast, options) {
  12158. const state = new CodegenState(options);
  12159. const code = ast ? genSSRElement(ast, state) : '_c("div")';
  12160. return {
  12161. render: `with(this){return ${code}}`,
  12162. staticRenderFns: state.staticRenderFns
  12163. };
  12164. }
  12165. function genSSRElement(el, state) {
  12166. if (el.for && !el.forProcessed) {
  12167. return genFor(el, state, genSSRElement);
  12168. }
  12169. else if (el.if && !el.ifProcessed) {
  12170. return genIf(el, state, genSSRElement);
  12171. }
  12172. else if (el.tag === 'template' && !el.slotTarget) {
  12173. return el.ssrOptimizability === optimizability.FULL
  12174. ? genChildrenAsStringNode(el, state)
  12175. : genSSRChildren(el, state) || 'void 0';
  12176. }
  12177. switch (el.ssrOptimizability) {
  12178. case optimizability.FULL:
  12179. // stringify whole tree
  12180. return genStringElement(el, state);
  12181. case optimizability.SELF:
  12182. // stringify self and check children
  12183. return genStringElementWithChildren(el, state);
  12184. case optimizability.CHILDREN:
  12185. // generate self as VNode and stringify children
  12186. return genNormalElement(el, state, true);
  12187. case optimizability.PARTIAL:
  12188. // generate self as VNode and check children
  12189. return genNormalElement(el, state, false);
  12190. default:
  12191. // bail whole tree
  12192. return genElement(el, state);
  12193. }
  12194. }
  12195. function genNormalElement(el, state, stringifyChildren) {
  12196. const data = el.plain ? undefined : genData(el, state);
  12197. const children = stringifyChildren
  12198. ? `[${genChildrenAsStringNode(el, state)}]`
  12199. : genSSRChildren(el, state, true);
  12200. return `_c('${el.tag}'${data ? `,${data}` : ''}${children ? `,${children}` : ''})`;
  12201. }
  12202. function genSSRChildren(el, state, checkSkip) {
  12203. return genChildren(el, state, checkSkip, genSSRElement, genSSRNode);
  12204. }
  12205. function genSSRNode(el, state) {
  12206. return el.type === 1 ? genSSRElement(el, state) : genText(el);
  12207. }
  12208. function genChildrenAsStringNode(el, state) {
  12209. return el.children.length
  12210. ? `_ssrNode(${flattenSegments(childrenToSegments(el, state))})`
  12211. : '';
  12212. }
  12213. function genStringElement(el, state) {
  12214. return `_ssrNode(${elementToString(el, state)})`;
  12215. }
  12216. function genStringElementWithChildren(el, state) {
  12217. const children = genSSRChildren(el, state, true);
  12218. return `_ssrNode(${flattenSegments(elementToOpenTagSegments(el, state))},"</${el.tag}>"${children ? `,${children}` : ''})`;
  12219. }
  12220. function elementToString(el, state) {
  12221. return `(${flattenSegments(elementToSegments(el, state))})`;
  12222. }
  12223. function elementToSegments(el, state) {
  12224. // v-for / v-if
  12225. if (el.for && !el.forProcessed) {
  12226. el.forProcessed = true;
  12227. return [
  12228. {
  12229. type: EXPRESSION,
  12230. value: genFor(el, state, elementToString, '_ssrList')
  12231. }
  12232. ];
  12233. }
  12234. else if (el.if && !el.ifProcessed) {
  12235. el.ifProcessed = true;
  12236. return [
  12237. {
  12238. type: EXPRESSION,
  12239. value: genIf(el, state, elementToString, '"<!---->"')
  12240. }
  12241. ];
  12242. }
  12243. else if (el.tag === 'template') {
  12244. return childrenToSegments(el, state);
  12245. }
  12246. const openSegments = elementToOpenTagSegments(el, state);
  12247. const childrenSegments = childrenToSegments(el, state);
  12248. const { isUnaryTag } = state.options;
  12249. const close = isUnaryTag && isUnaryTag(el.tag)
  12250. ? []
  12251. : [{ type: RAW, value: `</${el.tag}>` }];
  12252. return openSegments.concat(childrenSegments, close);
  12253. }
  12254. function elementToOpenTagSegments(el, state) {
  12255. applyModelTransform(el, state);
  12256. let binding;
  12257. const segments = [{ type: RAW, value: `<${el.tag}` }];
  12258. // attrs
  12259. if (el.attrs) {
  12260. segments.push.apply(segments, genAttrSegments(el.attrs));
  12261. }
  12262. // domProps
  12263. if (el.props) {
  12264. segments.push.apply(segments, genDOMPropSegments(el.props, el.attrs));
  12265. }
  12266. // v-bind="object"
  12267. if ((binding = el.attrsMap['v-bind'])) {
  12268. segments.push({ type: EXPRESSION, value: `_ssrAttrs(${binding})` });
  12269. }
  12270. // v-bind.prop="object"
  12271. if ((binding = el.attrsMap['v-bind.prop'])) {
  12272. segments.push({ type: EXPRESSION, value: `_ssrDOMProps(${binding})` });
  12273. }
  12274. // class
  12275. if (el.staticClass || el.classBinding) {
  12276. segments.push.apply(segments, genClassSegments(el.staticClass, el.classBinding));
  12277. }
  12278. // style & v-show
  12279. if (el.staticStyle || el.styleBinding || el.attrsMap['v-show']) {
  12280. segments.push.apply(segments, genStyleSegments(el.attrsMap.style, el.staticStyle, el.styleBinding, el.attrsMap['v-show']));
  12281. }
  12282. // _scopedId
  12283. if (state.options.scopeId) {
  12284. segments.push({ type: RAW, value: ` ${state.options.scopeId}` });
  12285. }
  12286. segments.push({ type: RAW, value: `>` });
  12287. return segments;
  12288. }
  12289. function childrenToSegments(el, state) {
  12290. let binding;
  12291. if ((binding = el.attrsMap['v-html'])) {
  12292. return [{ type: EXPRESSION, value: `_s(${binding})` }];
  12293. }
  12294. if ((binding = el.attrsMap['v-text'])) {
  12295. return [{ type: INTERPOLATION, value: `_s(${binding})` }];
  12296. }
  12297. if (el.tag === 'textarea' && (binding = el.attrsMap['v-model'])) {
  12298. return [{ type: INTERPOLATION, value: `_s(${binding})` }];
  12299. }
  12300. return el.children ? nodesToSegments(el.children, state) : [];
  12301. }
  12302. function nodesToSegments(children, state) {
  12303. const segments = [];
  12304. for (let i = 0; i < children.length; i++) {
  12305. const c = children[i];
  12306. if (c.type === 1) {
  12307. segments.push.apply(segments, elementToSegments(c, state));
  12308. }
  12309. else if (c.type === 2) {
  12310. segments.push({ type: INTERPOLATION, value: c.expression });
  12311. }
  12312. else if (c.type === 3) {
  12313. let text = escape(c.text);
  12314. if (c.isComment) {
  12315. text = '<!--' + text + '-->';
  12316. }
  12317. segments.push({ type: RAW, value: text });
  12318. }
  12319. }
  12320. return segments;
  12321. }
  12322. function flattenSegments(segments) {
  12323. const mergedSegments = [];
  12324. let textBuffer = '';
  12325. const pushBuffer = () => {
  12326. if (textBuffer) {
  12327. mergedSegments.push(JSON.stringify(textBuffer));
  12328. textBuffer = '';
  12329. }
  12330. };
  12331. for (let i = 0; i < segments.length; i++) {
  12332. const s = segments[i];
  12333. if (s.type === RAW) {
  12334. textBuffer += s.value;
  12335. }
  12336. else if (s.type === INTERPOLATION) {
  12337. pushBuffer();
  12338. mergedSegments.push(`_ssrEscape(${s.value})`);
  12339. }
  12340. else if (s.type === EXPRESSION) {
  12341. pushBuffer();
  12342. mergedSegments.push(`(${s.value})`);
  12343. }
  12344. }
  12345. pushBuffer();
  12346. return mergedSegments.join('+');
  12347. }
  12348. const createCompiler = createCompilerCreator(function baseCompile(template, options) {
  12349. const ast = parse$1(template.trim(), options);
  12350. optimize(ast, options);
  12351. const code = generate(ast, options);
  12352. return {
  12353. ast,
  12354. render: code.render,
  12355. staticRenderFns: code.staticRenderFns
  12356. };
  12357. });
  12358. const { compile, compileToFunctions } = createCompiler(baseOptions);
  12359. var _compiler = /*#__PURE__*/Object.freeze({
  12360. __proto__: null,
  12361. parseComponent: parseComponent,
  12362. compile: compile$1,
  12363. compileToFunctions: compileToFunctions$1,
  12364. ssrCompile: compile,
  12365. ssrCompileToFunctions: compileToFunctions,
  12366. generateCodeFrame: generateCodeFrame
  12367. });
  12368. function compileTemplate(options) {
  12369. const { preprocessLang } = options;
  12370. const preprocessor = preprocessLang && consolidate[preprocessLang];
  12371. if (preprocessor) {
  12372. return actuallyCompile(Object.assign({}, options, {
  12373. source: preprocess$1(options, preprocessor)
  12374. }));
  12375. }
  12376. else if (preprocessLang) {
  12377. return {
  12378. ast: {},
  12379. code: `var render = function () {}\n` + `var staticRenderFns = []\n`,
  12380. source: options.source,
  12381. tips: [
  12382. `Component ${options.filename} uses lang ${preprocessLang} for template. Please install the language preprocessor.`
  12383. ],
  12384. errors: [
  12385. `Component ${options.filename} uses lang ${preprocessLang} for template, however it is not installed.`
  12386. ]
  12387. };
  12388. }
  12389. else {
  12390. return actuallyCompile(options);
  12391. }
  12392. }
  12393. function preprocess$1(options, preprocessor) {
  12394. const { source, filename, preprocessOptions } = options;
  12395. const finalPreprocessOptions = Object.assign({
  12396. filename
  12397. }, preprocessOptions);
  12398. // Consolidate exposes a callback based API, but the callback is in fact
  12399. // called synchronously for most templating engines. In our case, we have to
  12400. // expose a synchronous API so that it is usable in Jest transforms (which
  12401. // have to be sync because they are applied via Node.js require hooks)
  12402. let res, err;
  12403. preprocessor.render(source, finalPreprocessOptions, (_err, _res) => {
  12404. if (_err)
  12405. err = _err;
  12406. res = _res;
  12407. });
  12408. if (err)
  12409. throw err;
  12410. return res;
  12411. }
  12412. function actuallyCompile(options) {
  12413. const { source, compiler = _compiler, compilerOptions = {}, transpileOptions = {}, transformAssetUrls, transformAssetUrlsOptions, isProduction = process.env.NODE_ENV === 'production', isFunctional = false, optimizeSSR = false, prettify = true, isTS = false, bindings } = options;
  12414. const compile = optimizeSSR && compiler.ssrCompile ? compiler.ssrCompile : compiler.compile;
  12415. let finalCompilerOptions = compilerOptions;
  12416. if (transformAssetUrls) {
  12417. const builtInModules = [
  12418. transformAssetUrls === true
  12419. ? assetUrlsModule(undefined, transformAssetUrlsOptions)
  12420. : assetUrlsModule(transformAssetUrls, transformAssetUrlsOptions),
  12421. srcsetModule(transformAssetUrlsOptions)
  12422. ];
  12423. finalCompilerOptions = Object.assign({}, compilerOptions, {
  12424. modules: [...builtInModules, ...(compilerOptions.modules || [])],
  12425. filename: options.filename
  12426. });
  12427. }
  12428. finalCompilerOptions.bindings = bindings;
  12429. const { ast, render, staticRenderFns, tips, errors } = compile(source, finalCompilerOptions);
  12430. if (errors && errors.length) {
  12431. return {
  12432. ast,
  12433. code: `var render = function () {}\n` + `var staticRenderFns = []\n`,
  12434. source,
  12435. tips,
  12436. errors
  12437. };
  12438. }
  12439. else {
  12440. // stripping `with` usage
  12441. let code = `var __render__ = ${prefixIdentifiers(`function render(${isFunctional ? `_c,_vm` : ``}){${render}\n}`, isFunctional, isTS, transpileOptions, bindings)}\n` +
  12442. `var __staticRenderFns__ = [${staticRenderFns.map(code => prefixIdentifiers(`function (${isFunctional ? `_c,_vm` : ``}){${code}\n}`, isFunctional, isTS, transpileOptions, bindings))}]` +
  12443. `\n`;
  12444. // #23 we use __render__ to avoid `render` not being prefixed by the
  12445. // transpiler when stripping with, but revert it back to `render` to
  12446. // maintain backwards compat
  12447. code = code.replace(/\s__(render|staticRenderFns)__\s/g, ' $1 ');
  12448. if (!isProduction) {
  12449. // mark with stripped (this enables Vue to use correct runtime proxy
  12450. // detection)
  12451. code += `render._withStripped = true`;
  12452. if (prettify) {
  12453. try {
  12454. code = require('prettier').format(code, {
  12455. semi: false,
  12456. parser: 'babel'
  12457. });
  12458. }
  12459. catch (e) {
  12460. if (e.code === 'MODULE_NOT_FOUND') {
  12461. tips.push('The `prettify` option is on, but the dependency `prettier` is not found.\n' +
  12462. 'Please either turn off `prettify` or manually install `prettier`.');
  12463. }
  12464. tips.push(`Failed to prettify component ${options.filename} template source after compilation.`);
  12465. }
  12466. }
  12467. }
  12468. return {
  12469. ast,
  12470. code,
  12471. source,
  12472. tips,
  12473. errors
  12474. };
  12475. }
  12476. }
  12477. const trimPlugin = () => {
  12478. return {
  12479. postcssPlugin: 'vue-sfc-trim',
  12480. Once(root) {
  12481. root.walk(({ type, raws }) => {
  12482. if (type === 'rule' || type === 'atrule') {
  12483. if (raws.before)
  12484. raws.before = '\n';
  12485. if ('after' in raws && raws.after)
  12486. raws.after = '\n';
  12487. }
  12488. });
  12489. }
  12490. };
  12491. };
  12492. trimPlugin.postcss = true;
  12493. var dist = {exports: {}};
  12494. var processor = {exports: {}};
  12495. var parser = {exports: {}};
  12496. var root$1 = {exports: {}};
  12497. var container = {exports: {}};
  12498. var node$1 = {exports: {}};
  12499. var util = {};
  12500. var unesc = {exports: {}};
  12501. (function (module, exports) {
  12502. exports.__esModule = true;
  12503. exports["default"] = unesc;
  12504. // Many thanks for this post which made this migration much easier.
  12505. // https://mathiasbynens.be/notes/css-escapes
  12506. /**
  12507. *
  12508. * @param {string} str
  12509. * @returns {[string, number]|undefined}
  12510. */
  12511. function gobbleHex(str) {
  12512. var lower = str.toLowerCase();
  12513. var hex = '';
  12514. var spaceTerminated = false;
  12515. for (var i = 0; i < 6 && lower[i] !== undefined; i++) {
  12516. var code = lower.charCodeAt(i); // check to see if we are dealing with a valid hex char [a-f|0-9]
  12517. var valid = code >= 97 && code <= 102 || code >= 48 && code <= 57; // https://drafts.csswg.org/css-syntax/#consume-escaped-code-point
  12518. spaceTerminated = code === 32;
  12519. if (!valid) {
  12520. break;
  12521. }
  12522. hex += lower[i];
  12523. }
  12524. if (hex.length === 0) {
  12525. return undefined;
  12526. }
  12527. var codePoint = parseInt(hex, 16);
  12528. var isSurrogate = codePoint >= 0xD800 && codePoint <= 0xDFFF; // Add special case for
  12529. // "If this number is zero, or is for a surrogate, or is greater than the maximum allowed code point"
  12530. // https://drafts.csswg.org/css-syntax/#maximum-allowed-code-point
  12531. if (isSurrogate || codePoint === 0x0000 || codePoint > 0x10FFFF) {
  12532. return ["\uFFFD", hex.length + (spaceTerminated ? 1 : 0)];
  12533. }
  12534. return [String.fromCodePoint(codePoint), hex.length + (spaceTerminated ? 1 : 0)];
  12535. }
  12536. var CONTAINS_ESCAPE = /\\/;
  12537. function unesc(str) {
  12538. var needToProcess = CONTAINS_ESCAPE.test(str);
  12539. if (!needToProcess) {
  12540. return str;
  12541. }
  12542. var ret = "";
  12543. for (var i = 0; i < str.length; i++) {
  12544. if (str[i] === "\\") {
  12545. var gobbled = gobbleHex(str.slice(i + 1, i + 7));
  12546. if (gobbled !== undefined) {
  12547. ret += gobbled[0];
  12548. i += gobbled[1];
  12549. continue;
  12550. } // Retain a pair of \\ if double escaped `\\\\`
  12551. // https://github.com/postcss/postcss-selector-parser/commit/268c9a7656fb53f543dc620aa5b73a30ec3ff20e
  12552. if (str[i + 1] === "\\") {
  12553. ret += "\\";
  12554. i++;
  12555. continue;
  12556. } // if \\ is at the end of the string retain it
  12557. // https://github.com/postcss/postcss-selector-parser/commit/01a6b346e3612ce1ab20219acc26abdc259ccefb
  12558. if (str.length === i + 1) {
  12559. ret += str[i];
  12560. }
  12561. continue;
  12562. }
  12563. ret += str[i];
  12564. }
  12565. return ret;
  12566. }
  12567. module.exports = exports.default;
  12568. } (unesc, unesc.exports));
  12569. var getProp = {exports: {}};
  12570. (function (module, exports) {
  12571. exports.__esModule = true;
  12572. exports["default"] = getProp;
  12573. function getProp(obj) {
  12574. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  12575. props[_key - 1] = arguments[_key];
  12576. }
  12577. while (props.length > 0) {
  12578. var prop = props.shift();
  12579. if (!obj[prop]) {
  12580. return undefined;
  12581. }
  12582. obj = obj[prop];
  12583. }
  12584. return obj;
  12585. }
  12586. module.exports = exports.default;
  12587. } (getProp, getProp.exports));
  12588. var ensureObject = {exports: {}};
  12589. (function (module, exports) {
  12590. exports.__esModule = true;
  12591. exports["default"] = ensureObject;
  12592. function ensureObject(obj) {
  12593. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  12594. props[_key - 1] = arguments[_key];
  12595. }
  12596. while (props.length > 0) {
  12597. var prop = props.shift();
  12598. if (!obj[prop]) {
  12599. obj[prop] = {};
  12600. }
  12601. obj = obj[prop];
  12602. }
  12603. }
  12604. module.exports = exports.default;
  12605. } (ensureObject, ensureObject.exports));
  12606. var stripComments = {exports: {}};
  12607. (function (module, exports) {
  12608. exports.__esModule = true;
  12609. exports["default"] = stripComments;
  12610. function stripComments(str) {
  12611. var s = "";
  12612. var commentStart = str.indexOf("/*");
  12613. var lastEnd = 0;
  12614. while (commentStart >= 0) {
  12615. s = s + str.slice(lastEnd, commentStart);
  12616. var commentEnd = str.indexOf("*/", commentStart + 2);
  12617. if (commentEnd < 0) {
  12618. return s;
  12619. }
  12620. lastEnd = commentEnd + 2;
  12621. commentStart = str.indexOf("/*", lastEnd);
  12622. }
  12623. s = s + str.slice(lastEnd);
  12624. return s;
  12625. }
  12626. module.exports = exports.default;
  12627. } (stripComments, stripComments.exports));
  12628. util.__esModule = true;
  12629. util.stripComments = util.ensureObject = util.getProp = util.unesc = void 0;
  12630. var _unesc = _interopRequireDefault$1(unesc.exports);
  12631. util.unesc = _unesc["default"];
  12632. var _getProp = _interopRequireDefault$1(getProp.exports);
  12633. util.getProp = _getProp["default"];
  12634. var _ensureObject = _interopRequireDefault$1(ensureObject.exports);
  12635. util.ensureObject = _ensureObject["default"];
  12636. var _stripComments = _interopRequireDefault$1(stripComments.exports);
  12637. util.stripComments = _stripComments["default"];
  12638. function _interopRequireDefault$1(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12639. (function (module, exports) {
  12640. exports.__esModule = true;
  12641. exports["default"] = void 0;
  12642. var _util = util;
  12643. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12644. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12645. var cloneNode = function cloneNode(obj, parent) {
  12646. if (typeof obj !== 'object' || obj === null) {
  12647. return obj;
  12648. }
  12649. var cloned = new obj.constructor();
  12650. for (var i in obj) {
  12651. if (!obj.hasOwnProperty(i)) {
  12652. continue;
  12653. }
  12654. var value = obj[i];
  12655. var type = typeof value;
  12656. if (i === 'parent' && type === 'object') {
  12657. if (parent) {
  12658. cloned[i] = parent;
  12659. }
  12660. } else if (value instanceof Array) {
  12661. cloned[i] = value.map(function (j) {
  12662. return cloneNode(j, cloned);
  12663. });
  12664. } else {
  12665. cloned[i] = cloneNode(value, cloned);
  12666. }
  12667. }
  12668. return cloned;
  12669. };
  12670. var Node = /*#__PURE__*/function () {
  12671. function Node(opts) {
  12672. if (opts === void 0) {
  12673. opts = {};
  12674. }
  12675. Object.assign(this, opts);
  12676. this.spaces = this.spaces || {};
  12677. this.spaces.before = this.spaces.before || '';
  12678. this.spaces.after = this.spaces.after || '';
  12679. }
  12680. var _proto = Node.prototype;
  12681. _proto.remove = function remove() {
  12682. if (this.parent) {
  12683. this.parent.removeChild(this);
  12684. }
  12685. this.parent = undefined;
  12686. return this;
  12687. };
  12688. _proto.replaceWith = function replaceWith() {
  12689. if (this.parent) {
  12690. for (var index in arguments) {
  12691. this.parent.insertBefore(this, arguments[index]);
  12692. }
  12693. this.remove();
  12694. }
  12695. return this;
  12696. };
  12697. _proto.next = function next() {
  12698. return this.parent.at(this.parent.index(this) + 1);
  12699. };
  12700. _proto.prev = function prev() {
  12701. return this.parent.at(this.parent.index(this) - 1);
  12702. };
  12703. _proto.clone = function clone(overrides) {
  12704. if (overrides === void 0) {
  12705. overrides = {};
  12706. }
  12707. var cloned = cloneNode(this);
  12708. for (var name in overrides) {
  12709. cloned[name] = overrides[name];
  12710. }
  12711. return cloned;
  12712. }
  12713. /**
  12714. * Some non-standard syntax doesn't follow normal escaping rules for css.
  12715. * This allows non standard syntax to be appended to an existing property
  12716. * by specifying the escaped value. By specifying the escaped value,
  12717. * illegal characters are allowed to be directly inserted into css output.
  12718. * @param {string} name the property to set
  12719. * @param {any} value the unescaped value of the property
  12720. * @param {string} valueEscaped optional. the escaped value of the property.
  12721. */
  12722. ;
  12723. _proto.appendToPropertyAndEscape = function appendToPropertyAndEscape(name, value, valueEscaped) {
  12724. if (!this.raws) {
  12725. this.raws = {};
  12726. }
  12727. var originalValue = this[name];
  12728. var originalEscaped = this.raws[name];
  12729. this[name] = originalValue + value; // this may trigger a setter that updates raws, so it has to be set first.
  12730. if (originalEscaped || valueEscaped !== value) {
  12731. this.raws[name] = (originalEscaped || originalValue) + valueEscaped;
  12732. } else {
  12733. delete this.raws[name]; // delete any escaped value that was created by the setter.
  12734. }
  12735. }
  12736. /**
  12737. * Some non-standard syntax doesn't follow normal escaping rules for css.
  12738. * This allows the escaped value to be specified directly, allowing illegal
  12739. * characters to be directly inserted into css output.
  12740. * @param {string} name the property to set
  12741. * @param {any} value the unescaped value of the property
  12742. * @param {string} valueEscaped the escaped value of the property.
  12743. */
  12744. ;
  12745. _proto.setPropertyAndEscape = function setPropertyAndEscape(name, value, valueEscaped) {
  12746. if (!this.raws) {
  12747. this.raws = {};
  12748. }
  12749. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  12750. this.raws[name] = valueEscaped;
  12751. }
  12752. /**
  12753. * When you want a value to passed through to CSS directly. This method
  12754. * deletes the corresponding raw value causing the stringifier to fallback
  12755. * to the unescaped value.
  12756. * @param {string} name the property to set.
  12757. * @param {any} value The value that is both escaped and unescaped.
  12758. */
  12759. ;
  12760. _proto.setPropertyWithoutEscape = function setPropertyWithoutEscape(name, value) {
  12761. this[name] = value; // this may trigger a setter that updates raws, so it has to be set first.
  12762. if (this.raws) {
  12763. delete this.raws[name];
  12764. }
  12765. }
  12766. /**
  12767. *
  12768. * @param {number} line The number (starting with 1)
  12769. * @param {number} column The column number (starting with 1)
  12770. */
  12771. ;
  12772. _proto.isAtPosition = function isAtPosition(line, column) {
  12773. if (this.source && this.source.start && this.source.end) {
  12774. if (this.source.start.line > line) {
  12775. return false;
  12776. }
  12777. if (this.source.end.line < line) {
  12778. return false;
  12779. }
  12780. if (this.source.start.line === line && this.source.start.column > column) {
  12781. return false;
  12782. }
  12783. if (this.source.end.line === line && this.source.end.column < column) {
  12784. return false;
  12785. }
  12786. return true;
  12787. }
  12788. return undefined;
  12789. };
  12790. _proto.stringifyProperty = function stringifyProperty(name) {
  12791. return this.raws && this.raws[name] || this[name];
  12792. };
  12793. _proto.valueToString = function valueToString() {
  12794. return String(this.stringifyProperty("value"));
  12795. };
  12796. _proto.toString = function toString() {
  12797. return [this.rawSpaceBefore, this.valueToString(), this.rawSpaceAfter].join('');
  12798. };
  12799. _createClass(Node, [{
  12800. key: "rawSpaceBefore",
  12801. get: function get() {
  12802. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.before;
  12803. if (rawSpace === undefined) {
  12804. rawSpace = this.spaces && this.spaces.before;
  12805. }
  12806. return rawSpace || "";
  12807. },
  12808. set: function set(raw) {
  12809. (0, _util.ensureObject)(this, "raws", "spaces");
  12810. this.raws.spaces.before = raw;
  12811. }
  12812. }, {
  12813. key: "rawSpaceAfter",
  12814. get: function get() {
  12815. var rawSpace = this.raws && this.raws.spaces && this.raws.spaces.after;
  12816. if (rawSpace === undefined) {
  12817. rawSpace = this.spaces.after;
  12818. }
  12819. return rawSpace || "";
  12820. },
  12821. set: function set(raw) {
  12822. (0, _util.ensureObject)(this, "raws", "spaces");
  12823. this.raws.spaces.after = raw;
  12824. }
  12825. }]);
  12826. return Node;
  12827. }();
  12828. exports["default"] = Node;
  12829. module.exports = exports.default;
  12830. } (node$1, node$1.exports));
  12831. var types = {};
  12832. types.__esModule = true;
  12833. types.UNIVERSAL = types.ATTRIBUTE = types.CLASS = types.COMBINATOR = types.COMMENT = types.ID = types.NESTING = types.PSEUDO = types.ROOT = types.SELECTOR = types.STRING = types.TAG = void 0;
  12834. var TAG = 'tag';
  12835. types.TAG = TAG;
  12836. var STRING = 'string';
  12837. types.STRING = STRING;
  12838. var SELECTOR = 'selector';
  12839. types.SELECTOR = SELECTOR;
  12840. var ROOT = 'root';
  12841. types.ROOT = ROOT;
  12842. var PSEUDO = 'pseudo';
  12843. types.PSEUDO = PSEUDO;
  12844. var NESTING = 'nesting';
  12845. types.NESTING = NESTING;
  12846. var ID = 'id';
  12847. types.ID = ID;
  12848. var COMMENT = 'comment';
  12849. types.COMMENT = COMMENT;
  12850. var COMBINATOR = 'combinator';
  12851. types.COMBINATOR = COMBINATOR;
  12852. var CLASS = 'class';
  12853. types.CLASS = CLASS;
  12854. var ATTRIBUTE = 'attribute';
  12855. types.ATTRIBUTE = ATTRIBUTE;
  12856. var UNIVERSAL = 'universal';
  12857. types.UNIVERSAL = UNIVERSAL;
  12858. (function (module, exports) {
  12859. exports.__esModule = true;
  12860. exports["default"] = void 0;
  12861. var _node = _interopRequireDefault(node$1.exports);
  12862. var types$1 = _interopRequireWildcard(types);
  12863. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  12864. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  12865. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12866. function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); }
  12867. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  12868. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  12869. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  12870. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  12871. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  12872. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  12873. var Container = /*#__PURE__*/function (_Node) {
  12874. _inheritsLoose(Container, _Node);
  12875. function Container(opts) {
  12876. var _this;
  12877. _this = _Node.call(this, opts) || this;
  12878. if (!_this.nodes) {
  12879. _this.nodes = [];
  12880. }
  12881. return _this;
  12882. }
  12883. var _proto = Container.prototype;
  12884. _proto.append = function append(selector) {
  12885. selector.parent = this;
  12886. this.nodes.push(selector);
  12887. return this;
  12888. };
  12889. _proto.prepend = function prepend(selector) {
  12890. selector.parent = this;
  12891. this.nodes.unshift(selector);
  12892. return this;
  12893. };
  12894. _proto.at = function at(index) {
  12895. return this.nodes[index];
  12896. };
  12897. _proto.index = function index(child) {
  12898. if (typeof child === 'number') {
  12899. return child;
  12900. }
  12901. return this.nodes.indexOf(child);
  12902. };
  12903. _proto.removeChild = function removeChild(child) {
  12904. child = this.index(child);
  12905. this.at(child).parent = undefined;
  12906. this.nodes.splice(child, 1);
  12907. var index;
  12908. for (var id in this.indexes) {
  12909. index = this.indexes[id];
  12910. if (index >= child) {
  12911. this.indexes[id] = index - 1;
  12912. }
  12913. }
  12914. return this;
  12915. };
  12916. _proto.removeAll = function removeAll() {
  12917. for (var _iterator = _createForOfIteratorHelperLoose(this.nodes), _step; !(_step = _iterator()).done;) {
  12918. var node = _step.value;
  12919. node.parent = undefined;
  12920. }
  12921. this.nodes = [];
  12922. return this;
  12923. };
  12924. _proto.empty = function empty() {
  12925. return this.removeAll();
  12926. };
  12927. _proto.insertAfter = function insertAfter(oldNode, newNode) {
  12928. newNode.parent = this;
  12929. var oldIndex = this.index(oldNode);
  12930. this.nodes.splice(oldIndex + 1, 0, newNode);
  12931. newNode.parent = this;
  12932. var index;
  12933. for (var id in this.indexes) {
  12934. index = this.indexes[id];
  12935. if (oldIndex <= index) {
  12936. this.indexes[id] = index + 1;
  12937. }
  12938. }
  12939. return this;
  12940. };
  12941. _proto.insertBefore = function insertBefore(oldNode, newNode) {
  12942. newNode.parent = this;
  12943. var oldIndex = this.index(oldNode);
  12944. this.nodes.splice(oldIndex, 0, newNode);
  12945. newNode.parent = this;
  12946. var index;
  12947. for (var id in this.indexes) {
  12948. index = this.indexes[id];
  12949. if (index <= oldIndex) {
  12950. this.indexes[id] = index + 1;
  12951. }
  12952. }
  12953. return this;
  12954. };
  12955. _proto._findChildAtPosition = function _findChildAtPosition(line, col) {
  12956. var found = undefined;
  12957. this.each(function (node) {
  12958. if (node.atPosition) {
  12959. var foundChild = node.atPosition(line, col);
  12960. if (foundChild) {
  12961. found = foundChild;
  12962. return false;
  12963. }
  12964. } else if (node.isAtPosition(line, col)) {
  12965. found = node;
  12966. return false;
  12967. }
  12968. });
  12969. return found;
  12970. }
  12971. /**
  12972. * Return the most specific node at the line and column number given.
  12973. * The source location is based on the original parsed location, locations aren't
  12974. * updated as selector nodes are mutated.
  12975. *
  12976. * Note that this location is relative to the location of the first character
  12977. * of the selector, and not the location of the selector in the overall document
  12978. * when used in conjunction with postcss.
  12979. *
  12980. * If not found, returns undefined.
  12981. * @param {number} line The line number of the node to find. (1-based index)
  12982. * @param {number} col The column number of the node to find. (1-based index)
  12983. */
  12984. ;
  12985. _proto.atPosition = function atPosition(line, col) {
  12986. if (this.isAtPosition(line, col)) {
  12987. return this._findChildAtPosition(line, col) || this;
  12988. } else {
  12989. return undefined;
  12990. }
  12991. };
  12992. _proto._inferEndPosition = function _inferEndPosition() {
  12993. if (this.last && this.last.source && this.last.source.end) {
  12994. this.source = this.source || {};
  12995. this.source.end = this.source.end || {};
  12996. Object.assign(this.source.end, this.last.source.end);
  12997. }
  12998. };
  12999. _proto.each = function each(callback) {
  13000. if (!this.lastEach) {
  13001. this.lastEach = 0;
  13002. }
  13003. if (!this.indexes) {
  13004. this.indexes = {};
  13005. }
  13006. this.lastEach++;
  13007. var id = this.lastEach;
  13008. this.indexes[id] = 0;
  13009. if (!this.length) {
  13010. return undefined;
  13011. }
  13012. var index, result;
  13013. while (this.indexes[id] < this.length) {
  13014. index = this.indexes[id];
  13015. result = callback(this.at(index), index);
  13016. if (result === false) {
  13017. break;
  13018. }
  13019. this.indexes[id] += 1;
  13020. }
  13021. delete this.indexes[id];
  13022. if (result === false) {
  13023. return false;
  13024. }
  13025. };
  13026. _proto.walk = function walk(callback) {
  13027. return this.each(function (node, i) {
  13028. var result = callback(node, i);
  13029. if (result !== false && node.length) {
  13030. result = node.walk(callback);
  13031. }
  13032. if (result === false) {
  13033. return false;
  13034. }
  13035. });
  13036. };
  13037. _proto.walkAttributes = function walkAttributes(callback) {
  13038. var _this2 = this;
  13039. return this.walk(function (selector) {
  13040. if (selector.type === types$1.ATTRIBUTE) {
  13041. return callback.call(_this2, selector);
  13042. }
  13043. });
  13044. };
  13045. _proto.walkClasses = function walkClasses(callback) {
  13046. var _this3 = this;
  13047. return this.walk(function (selector) {
  13048. if (selector.type === types$1.CLASS) {
  13049. return callback.call(_this3, selector);
  13050. }
  13051. });
  13052. };
  13053. _proto.walkCombinators = function walkCombinators(callback) {
  13054. var _this4 = this;
  13055. return this.walk(function (selector) {
  13056. if (selector.type === types$1.COMBINATOR) {
  13057. return callback.call(_this4, selector);
  13058. }
  13059. });
  13060. };
  13061. _proto.walkComments = function walkComments(callback) {
  13062. var _this5 = this;
  13063. return this.walk(function (selector) {
  13064. if (selector.type === types$1.COMMENT) {
  13065. return callback.call(_this5, selector);
  13066. }
  13067. });
  13068. };
  13069. _proto.walkIds = function walkIds(callback) {
  13070. var _this6 = this;
  13071. return this.walk(function (selector) {
  13072. if (selector.type === types$1.ID) {
  13073. return callback.call(_this6, selector);
  13074. }
  13075. });
  13076. };
  13077. _proto.walkNesting = function walkNesting(callback) {
  13078. var _this7 = this;
  13079. return this.walk(function (selector) {
  13080. if (selector.type === types$1.NESTING) {
  13081. return callback.call(_this7, selector);
  13082. }
  13083. });
  13084. };
  13085. _proto.walkPseudos = function walkPseudos(callback) {
  13086. var _this8 = this;
  13087. return this.walk(function (selector) {
  13088. if (selector.type === types$1.PSEUDO) {
  13089. return callback.call(_this8, selector);
  13090. }
  13091. });
  13092. };
  13093. _proto.walkTags = function walkTags(callback) {
  13094. var _this9 = this;
  13095. return this.walk(function (selector) {
  13096. if (selector.type === types$1.TAG) {
  13097. return callback.call(_this9, selector);
  13098. }
  13099. });
  13100. };
  13101. _proto.walkUniversals = function walkUniversals(callback) {
  13102. var _this10 = this;
  13103. return this.walk(function (selector) {
  13104. if (selector.type === types$1.UNIVERSAL) {
  13105. return callback.call(_this10, selector);
  13106. }
  13107. });
  13108. };
  13109. _proto.split = function split(callback) {
  13110. var _this11 = this;
  13111. var current = [];
  13112. return this.reduce(function (memo, node, index) {
  13113. var split = callback.call(_this11, node);
  13114. current.push(node);
  13115. if (split) {
  13116. memo.push(current);
  13117. current = [];
  13118. } else if (index === _this11.length - 1) {
  13119. memo.push(current);
  13120. }
  13121. return memo;
  13122. }, []);
  13123. };
  13124. _proto.map = function map(callback) {
  13125. return this.nodes.map(callback);
  13126. };
  13127. _proto.reduce = function reduce(callback, memo) {
  13128. return this.nodes.reduce(callback, memo);
  13129. };
  13130. _proto.every = function every(callback) {
  13131. return this.nodes.every(callback);
  13132. };
  13133. _proto.some = function some(callback) {
  13134. return this.nodes.some(callback);
  13135. };
  13136. _proto.filter = function filter(callback) {
  13137. return this.nodes.filter(callback);
  13138. };
  13139. _proto.sort = function sort(callback) {
  13140. return this.nodes.sort(callback);
  13141. };
  13142. _proto.toString = function toString() {
  13143. return this.map(String).join('');
  13144. };
  13145. _createClass(Container, [{
  13146. key: "first",
  13147. get: function get() {
  13148. return this.at(0);
  13149. }
  13150. }, {
  13151. key: "last",
  13152. get: function get() {
  13153. return this.at(this.length - 1);
  13154. }
  13155. }, {
  13156. key: "length",
  13157. get: function get() {
  13158. return this.nodes.length;
  13159. }
  13160. }]);
  13161. return Container;
  13162. }(_node["default"]);
  13163. exports["default"] = Container;
  13164. module.exports = exports.default;
  13165. } (container, container.exports));
  13166. (function (module, exports) {
  13167. exports.__esModule = true;
  13168. exports["default"] = void 0;
  13169. var _container = _interopRequireDefault(container.exports);
  13170. var _types = types;
  13171. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13172. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13173. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13174. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13175. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13176. var Root = /*#__PURE__*/function (_Container) {
  13177. _inheritsLoose(Root, _Container);
  13178. function Root(opts) {
  13179. var _this;
  13180. _this = _Container.call(this, opts) || this;
  13181. _this.type = _types.ROOT;
  13182. return _this;
  13183. }
  13184. var _proto = Root.prototype;
  13185. _proto.toString = function toString() {
  13186. var str = this.reduce(function (memo, selector) {
  13187. memo.push(String(selector));
  13188. return memo;
  13189. }, []).join(',');
  13190. return this.trailingComma ? str + ',' : str;
  13191. };
  13192. _proto.error = function error(message, options) {
  13193. if (this._error) {
  13194. return this._error(message, options);
  13195. } else {
  13196. return new Error(message);
  13197. }
  13198. };
  13199. _createClass(Root, [{
  13200. key: "errorGenerator",
  13201. set: function set(handler) {
  13202. this._error = handler;
  13203. }
  13204. }]);
  13205. return Root;
  13206. }(_container["default"]);
  13207. exports["default"] = Root;
  13208. module.exports = exports.default;
  13209. } (root$1, root$1.exports));
  13210. var selector$1 = {exports: {}};
  13211. (function (module, exports) {
  13212. exports.__esModule = true;
  13213. exports["default"] = void 0;
  13214. var _container = _interopRequireDefault(container.exports);
  13215. var _types = types;
  13216. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13217. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13218. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13219. var Selector = /*#__PURE__*/function (_Container) {
  13220. _inheritsLoose(Selector, _Container);
  13221. function Selector(opts) {
  13222. var _this;
  13223. _this = _Container.call(this, opts) || this;
  13224. _this.type = _types.SELECTOR;
  13225. return _this;
  13226. }
  13227. return Selector;
  13228. }(_container["default"]);
  13229. exports["default"] = Selector;
  13230. module.exports = exports.default;
  13231. } (selector$1, selector$1.exports));
  13232. var className$1 = {exports: {}};
  13233. /*! https://mths.be/cssesc v3.0.0 by @mathias */
  13234. var object = {};
  13235. var hasOwnProperty = object.hasOwnProperty;
  13236. var merge$1 = function merge(options, defaults) {
  13237. if (!options) {
  13238. return defaults;
  13239. }
  13240. var result = {};
  13241. for (var key in defaults) {
  13242. // `if (defaults.hasOwnProperty(key) { … }` is not needed here, since
  13243. // only recognized option names are used.
  13244. result[key] = hasOwnProperty.call(options, key) ? options[key] : defaults[key];
  13245. }
  13246. return result;
  13247. };
  13248. var regexAnySingleEscape = /[ -,\.\/:-@\[-\^`\{-~]/;
  13249. var regexSingleEscape = /[ -,\.\/:-@\[\]\^`\{-~]/;
  13250. var regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
  13251. // https://mathiasbynens.be/notes/css-escapes#css
  13252. var cssesc = function cssesc(string, options) {
  13253. options = merge$1(options, cssesc.options);
  13254. if (options.quotes != 'single' && options.quotes != 'double') {
  13255. options.quotes = 'single';
  13256. }
  13257. var quote = options.quotes == 'double' ? '"' : '\'';
  13258. var isIdentifier = options.isIdentifier;
  13259. var firstChar = string.charAt(0);
  13260. var output = '';
  13261. var counter = 0;
  13262. var length = string.length;
  13263. while (counter < length) {
  13264. var character = string.charAt(counter++);
  13265. var codePoint = character.charCodeAt();
  13266. var value = void 0;
  13267. // If it’s not a printable ASCII character…
  13268. if (codePoint < 0x20 || codePoint > 0x7E) {
  13269. if (codePoint >= 0xD800 && codePoint <= 0xDBFF && counter < length) {
  13270. // It’s a high surrogate, and there is a next character.
  13271. var extra = string.charCodeAt(counter++);
  13272. if ((extra & 0xFC00) == 0xDC00) {
  13273. // next character is low surrogate
  13274. codePoint = ((codePoint & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000;
  13275. } else {
  13276. // It’s an unmatched surrogate; only append this code unit, in case
  13277. // the next code unit is the high surrogate of a surrogate pair.
  13278. counter--;
  13279. }
  13280. }
  13281. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  13282. } else {
  13283. if (options.escapeEverything) {
  13284. if (regexAnySingleEscape.test(character)) {
  13285. value = '\\' + character;
  13286. } else {
  13287. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  13288. }
  13289. } else if (/[\t\n\f\r\x0B]/.test(character)) {
  13290. value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
  13291. } else if (character == '\\' || !isIdentifier && (character == '"' && quote == character || character == '\'' && quote == character) || isIdentifier && regexSingleEscape.test(character)) {
  13292. value = '\\' + character;
  13293. } else {
  13294. value = character;
  13295. }
  13296. }
  13297. output += value;
  13298. }
  13299. if (isIdentifier) {
  13300. if (/^-[-\d]/.test(output)) {
  13301. output = '\\-' + output.slice(1);
  13302. } else if (/\d/.test(firstChar)) {
  13303. output = '\\3' + firstChar + ' ' + output.slice(1);
  13304. }
  13305. }
  13306. // Remove spaces after `\HEX` escapes that are not followed by a hex digit,
  13307. // since they’re redundant. Note that this is only possible if the escape
  13308. // sequence isn’t preceded by an odd number of backslashes.
  13309. output = output.replace(regexExcessiveSpaces, function ($0, $1, $2) {
  13310. if ($1 && $1.length % 2) {
  13311. // It’s not safe to remove the space, so don’t.
  13312. return $0;
  13313. }
  13314. // Strip the space.
  13315. return ($1 || '') + $2;
  13316. });
  13317. if (!isIdentifier && options.wrap) {
  13318. return quote + output + quote;
  13319. }
  13320. return output;
  13321. };
  13322. // Expose default options (so they can be overridden globally).
  13323. cssesc.options = {
  13324. 'escapeEverything': false,
  13325. 'isIdentifier': false,
  13326. 'quotes': 'single',
  13327. 'wrap': false
  13328. };
  13329. cssesc.version = '3.0.0';
  13330. var cssesc_1 = cssesc;
  13331. (function (module, exports) {
  13332. exports.__esModule = true;
  13333. exports["default"] = void 0;
  13334. var _cssesc = _interopRequireDefault(cssesc_1);
  13335. var _util = util;
  13336. var _node = _interopRequireDefault(node$1.exports);
  13337. var _types = types;
  13338. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13339. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13340. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13341. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13342. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13343. var ClassName = /*#__PURE__*/function (_Node) {
  13344. _inheritsLoose(ClassName, _Node);
  13345. function ClassName(opts) {
  13346. var _this;
  13347. _this = _Node.call(this, opts) || this;
  13348. _this.type = _types.CLASS;
  13349. _this._constructed = true;
  13350. return _this;
  13351. }
  13352. var _proto = ClassName.prototype;
  13353. _proto.valueToString = function valueToString() {
  13354. return '.' + _Node.prototype.valueToString.call(this);
  13355. };
  13356. _createClass(ClassName, [{
  13357. key: "value",
  13358. get: function get() {
  13359. return this._value;
  13360. },
  13361. set: function set(v) {
  13362. if (this._constructed) {
  13363. var escaped = (0, _cssesc["default"])(v, {
  13364. isIdentifier: true
  13365. });
  13366. if (escaped !== v) {
  13367. (0, _util.ensureObject)(this, "raws");
  13368. this.raws.value = escaped;
  13369. } else if (this.raws) {
  13370. delete this.raws.value;
  13371. }
  13372. }
  13373. this._value = v;
  13374. }
  13375. }]);
  13376. return ClassName;
  13377. }(_node["default"]);
  13378. exports["default"] = ClassName;
  13379. module.exports = exports.default;
  13380. } (className$1, className$1.exports));
  13381. var comment$2 = {exports: {}};
  13382. (function (module, exports) {
  13383. exports.__esModule = true;
  13384. exports["default"] = void 0;
  13385. var _node = _interopRequireDefault(node$1.exports);
  13386. var _types = types;
  13387. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13388. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13389. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13390. var Comment = /*#__PURE__*/function (_Node) {
  13391. _inheritsLoose(Comment, _Node);
  13392. function Comment(opts) {
  13393. var _this;
  13394. _this = _Node.call(this, opts) || this;
  13395. _this.type = _types.COMMENT;
  13396. return _this;
  13397. }
  13398. return Comment;
  13399. }(_node["default"]);
  13400. exports["default"] = Comment;
  13401. module.exports = exports.default;
  13402. } (comment$2, comment$2.exports));
  13403. var id$1 = {exports: {}};
  13404. (function (module, exports) {
  13405. exports.__esModule = true;
  13406. exports["default"] = void 0;
  13407. var _node = _interopRequireDefault(node$1.exports);
  13408. var _types = types;
  13409. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13410. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13411. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13412. var ID = /*#__PURE__*/function (_Node) {
  13413. _inheritsLoose(ID, _Node);
  13414. function ID(opts) {
  13415. var _this;
  13416. _this = _Node.call(this, opts) || this;
  13417. _this.type = _types.ID;
  13418. return _this;
  13419. }
  13420. var _proto = ID.prototype;
  13421. _proto.valueToString = function valueToString() {
  13422. return '#' + _Node.prototype.valueToString.call(this);
  13423. };
  13424. return ID;
  13425. }(_node["default"]);
  13426. exports["default"] = ID;
  13427. module.exports = exports.default;
  13428. } (id$1, id$1.exports));
  13429. var tag$1 = {exports: {}};
  13430. var namespace = {exports: {}};
  13431. (function (module, exports) {
  13432. exports.__esModule = true;
  13433. exports["default"] = void 0;
  13434. var _cssesc = _interopRequireDefault(cssesc_1);
  13435. var _util = util;
  13436. var _node = _interopRequireDefault(node$1.exports);
  13437. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13438. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13439. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13440. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13441. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13442. var Namespace = /*#__PURE__*/function (_Node) {
  13443. _inheritsLoose(Namespace, _Node);
  13444. function Namespace() {
  13445. return _Node.apply(this, arguments) || this;
  13446. }
  13447. var _proto = Namespace.prototype;
  13448. _proto.qualifiedName = function qualifiedName(value) {
  13449. if (this.namespace) {
  13450. return this.namespaceString + "|" + value;
  13451. } else {
  13452. return value;
  13453. }
  13454. };
  13455. _proto.valueToString = function valueToString() {
  13456. return this.qualifiedName(_Node.prototype.valueToString.call(this));
  13457. };
  13458. _createClass(Namespace, [{
  13459. key: "namespace",
  13460. get: function get() {
  13461. return this._namespace;
  13462. },
  13463. set: function set(namespace) {
  13464. if (namespace === true || namespace === "*" || namespace === "&") {
  13465. this._namespace = namespace;
  13466. if (this.raws) {
  13467. delete this.raws.namespace;
  13468. }
  13469. return;
  13470. }
  13471. var escaped = (0, _cssesc["default"])(namespace, {
  13472. isIdentifier: true
  13473. });
  13474. this._namespace = namespace;
  13475. if (escaped !== namespace) {
  13476. (0, _util.ensureObject)(this, "raws");
  13477. this.raws.namespace = escaped;
  13478. } else if (this.raws) {
  13479. delete this.raws.namespace;
  13480. }
  13481. }
  13482. }, {
  13483. key: "ns",
  13484. get: function get() {
  13485. return this._namespace;
  13486. },
  13487. set: function set(namespace) {
  13488. this.namespace = namespace;
  13489. }
  13490. }, {
  13491. key: "namespaceString",
  13492. get: function get() {
  13493. if (this.namespace) {
  13494. var ns = this.stringifyProperty("namespace");
  13495. if (ns === true) {
  13496. return '';
  13497. } else {
  13498. return ns;
  13499. }
  13500. } else {
  13501. return '';
  13502. }
  13503. }
  13504. }]);
  13505. return Namespace;
  13506. }(_node["default"]);
  13507. exports["default"] = Namespace;
  13508. module.exports = exports.default;
  13509. } (namespace, namespace.exports));
  13510. (function (module, exports) {
  13511. exports.__esModule = true;
  13512. exports["default"] = void 0;
  13513. var _namespace = _interopRequireDefault(namespace.exports);
  13514. var _types = types;
  13515. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13516. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13517. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13518. var Tag = /*#__PURE__*/function (_Namespace) {
  13519. _inheritsLoose(Tag, _Namespace);
  13520. function Tag(opts) {
  13521. var _this;
  13522. _this = _Namespace.call(this, opts) || this;
  13523. _this.type = _types.TAG;
  13524. return _this;
  13525. }
  13526. return Tag;
  13527. }(_namespace["default"]);
  13528. exports["default"] = Tag;
  13529. module.exports = exports.default;
  13530. } (tag$1, tag$1.exports));
  13531. var string$1 = {exports: {}};
  13532. (function (module, exports) {
  13533. exports.__esModule = true;
  13534. exports["default"] = void 0;
  13535. var _node = _interopRequireDefault(node$1.exports);
  13536. var _types = types;
  13537. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13538. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13539. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13540. var String = /*#__PURE__*/function (_Node) {
  13541. _inheritsLoose(String, _Node);
  13542. function String(opts) {
  13543. var _this;
  13544. _this = _Node.call(this, opts) || this;
  13545. _this.type = _types.STRING;
  13546. return _this;
  13547. }
  13548. return String;
  13549. }(_node["default"]);
  13550. exports["default"] = String;
  13551. module.exports = exports.default;
  13552. } (string$1, string$1.exports));
  13553. var pseudo$1 = {exports: {}};
  13554. (function (module, exports) {
  13555. exports.__esModule = true;
  13556. exports["default"] = void 0;
  13557. var _container = _interopRequireDefault(container.exports);
  13558. var _types = types;
  13559. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13560. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13561. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13562. var Pseudo = /*#__PURE__*/function (_Container) {
  13563. _inheritsLoose(Pseudo, _Container);
  13564. function Pseudo(opts) {
  13565. var _this;
  13566. _this = _Container.call(this, opts) || this;
  13567. _this.type = _types.PSEUDO;
  13568. return _this;
  13569. }
  13570. var _proto = Pseudo.prototype;
  13571. _proto.toString = function toString() {
  13572. var params = this.length ? '(' + this.map(String).join(',') + ')' : '';
  13573. return [this.rawSpaceBefore, this.stringifyProperty("value"), params, this.rawSpaceAfter].join('');
  13574. };
  13575. return Pseudo;
  13576. }(_container["default"]);
  13577. exports["default"] = Pseudo;
  13578. module.exports = exports.default;
  13579. } (pseudo$1, pseudo$1.exports));
  13580. var attribute$1 = {};
  13581. /**
  13582. * For Node.js, simply re-export the core `util.deprecate` function.
  13583. */
  13584. var node = require$$2__default["default"].deprecate;
  13585. (function (exports) {
  13586. exports.__esModule = true;
  13587. exports.unescapeValue = unescapeValue;
  13588. exports["default"] = void 0;
  13589. var _cssesc = _interopRequireDefault(cssesc_1);
  13590. var _unesc = _interopRequireDefault(unesc.exports);
  13591. var _namespace = _interopRequireDefault(namespace.exports);
  13592. var _types = types;
  13593. var _CSSESC_QUOTE_OPTIONS;
  13594. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  13595. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13596. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13597. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  13598. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13599. var deprecate = node;
  13600. var WRAPPED_IN_QUOTES = /^('|")([^]*)\1$/;
  13601. var warnOfDeprecatedValueAssignment = deprecate(function () {}, "Assigning an attribute a value containing characters that might need to be escaped is deprecated. " + "Call attribute.setValue() instead.");
  13602. var warnOfDeprecatedQuotedAssignment = deprecate(function () {}, "Assigning attr.quoted is deprecated and has no effect. Assign to attr.quoteMark instead.");
  13603. var warnOfDeprecatedConstructor = deprecate(function () {}, "Constructing an Attribute selector with a value without specifying quoteMark is deprecated. Note: The value should be unescaped now.");
  13604. function unescapeValue(value) {
  13605. var deprecatedUsage = false;
  13606. var quoteMark = null;
  13607. var unescaped = value;
  13608. var m = unescaped.match(WRAPPED_IN_QUOTES);
  13609. if (m) {
  13610. quoteMark = m[1];
  13611. unescaped = m[2];
  13612. }
  13613. unescaped = (0, _unesc["default"])(unescaped);
  13614. if (unescaped !== value) {
  13615. deprecatedUsage = true;
  13616. }
  13617. return {
  13618. deprecatedUsage: deprecatedUsage,
  13619. unescaped: unescaped,
  13620. quoteMark: quoteMark
  13621. };
  13622. }
  13623. function handleDeprecatedContructorOpts(opts) {
  13624. if (opts.quoteMark !== undefined) {
  13625. return opts;
  13626. }
  13627. if (opts.value === undefined) {
  13628. return opts;
  13629. }
  13630. warnOfDeprecatedConstructor();
  13631. var _unescapeValue = unescapeValue(opts.value),
  13632. quoteMark = _unescapeValue.quoteMark,
  13633. unescaped = _unescapeValue.unescaped;
  13634. if (!opts.raws) {
  13635. opts.raws = {};
  13636. }
  13637. if (opts.raws.value === undefined) {
  13638. opts.raws.value = opts.value;
  13639. }
  13640. opts.value = unescaped;
  13641. opts.quoteMark = quoteMark;
  13642. return opts;
  13643. }
  13644. var Attribute = /*#__PURE__*/function (_Namespace) {
  13645. _inheritsLoose(Attribute, _Namespace);
  13646. function Attribute(opts) {
  13647. var _this;
  13648. if (opts === void 0) {
  13649. opts = {};
  13650. }
  13651. _this = _Namespace.call(this, handleDeprecatedContructorOpts(opts)) || this;
  13652. _this.type = _types.ATTRIBUTE;
  13653. _this.raws = _this.raws || {};
  13654. Object.defineProperty(_this.raws, 'unquoted', {
  13655. get: deprecate(function () {
  13656. return _this.value;
  13657. }, "attr.raws.unquoted is deprecated. Call attr.value instead."),
  13658. set: deprecate(function () {
  13659. return _this.value;
  13660. }, "Setting attr.raws.unquoted is deprecated and has no effect. attr.value is unescaped by default now.")
  13661. });
  13662. _this._constructed = true;
  13663. return _this;
  13664. }
  13665. /**
  13666. * Returns the Attribute's value quoted such that it would be legal to use
  13667. * in the value of a css file. The original value's quotation setting
  13668. * used for stringification is left unchanged. See `setValue(value, options)`
  13669. * if you want to control the quote settings of a new value for the attribute.
  13670. *
  13671. * You can also change the quotation used for the current value by setting quoteMark.
  13672. *
  13673. * Options:
  13674. * * quoteMark {'"' | "'" | null} - Use this value to quote the value. If this
  13675. * option is not set, the original value for quoteMark will be used. If
  13676. * indeterminate, a double quote is used. The legal values are:
  13677. * * `null` - the value will be unquoted and characters will be escaped as necessary.
  13678. * * `'` - the value will be quoted with a single quote and single quotes are escaped.
  13679. * * `"` - the value will be quoted with a double quote and double quotes are escaped.
  13680. * * preferCurrentQuoteMark {boolean} - if true, prefer the source quote mark
  13681. * over the quoteMark option value.
  13682. * * smart {boolean} - if true, will select a quote mark based on the value
  13683. * and the other options specified here. See the `smartQuoteMark()`
  13684. * method.
  13685. **/
  13686. var _proto = Attribute.prototype;
  13687. _proto.getQuotedValue = function getQuotedValue(options) {
  13688. if (options === void 0) {
  13689. options = {};
  13690. }
  13691. var quoteMark = this._determineQuoteMark(options);
  13692. var cssescopts = CSSESC_QUOTE_OPTIONS[quoteMark];
  13693. var escaped = (0, _cssesc["default"])(this._value, cssescopts);
  13694. return escaped;
  13695. };
  13696. _proto._determineQuoteMark = function _determineQuoteMark(options) {
  13697. return options.smart ? this.smartQuoteMark(options) : this.preferredQuoteMark(options);
  13698. }
  13699. /**
  13700. * Set the unescaped value with the specified quotation options. The value
  13701. * provided must not include any wrapping quote marks -- those quotes will
  13702. * be interpreted as part of the value and escaped accordingly.
  13703. */
  13704. ;
  13705. _proto.setValue = function setValue(value, options) {
  13706. if (options === void 0) {
  13707. options = {};
  13708. }
  13709. this._value = value;
  13710. this._quoteMark = this._determineQuoteMark(options);
  13711. this._syncRawValue();
  13712. }
  13713. /**
  13714. * Intelligently select a quoteMark value based on the value's contents. If
  13715. * the value is a legal CSS ident, it will not be quoted. Otherwise a quote
  13716. * mark will be picked that minimizes the number of escapes.
  13717. *
  13718. * If there's no clear winner, the quote mark from these options is used,
  13719. * then the source quote mark (this is inverted if `preferCurrentQuoteMark` is
  13720. * true). If the quoteMark is unspecified, a double quote is used.
  13721. *
  13722. * @param options This takes the quoteMark and preferCurrentQuoteMark options
  13723. * from the quoteValue method.
  13724. */
  13725. ;
  13726. _proto.smartQuoteMark = function smartQuoteMark(options) {
  13727. var v = this.value;
  13728. var numSingleQuotes = v.replace(/[^']/g, '').length;
  13729. var numDoubleQuotes = v.replace(/[^"]/g, '').length;
  13730. if (numSingleQuotes + numDoubleQuotes === 0) {
  13731. var escaped = (0, _cssesc["default"])(v, {
  13732. isIdentifier: true
  13733. });
  13734. if (escaped === v) {
  13735. return Attribute.NO_QUOTE;
  13736. } else {
  13737. var pref = this.preferredQuoteMark(options);
  13738. if (pref === Attribute.NO_QUOTE) {
  13739. // pick a quote mark that isn't none and see if it's smaller
  13740. var quote = this.quoteMark || options.quoteMark || Attribute.DOUBLE_QUOTE;
  13741. var opts = CSSESC_QUOTE_OPTIONS[quote];
  13742. var quoteValue = (0, _cssesc["default"])(v, opts);
  13743. if (quoteValue.length < escaped.length) {
  13744. return quote;
  13745. }
  13746. }
  13747. return pref;
  13748. }
  13749. } else if (numDoubleQuotes === numSingleQuotes) {
  13750. return this.preferredQuoteMark(options);
  13751. } else if (numDoubleQuotes < numSingleQuotes) {
  13752. return Attribute.DOUBLE_QUOTE;
  13753. } else {
  13754. return Attribute.SINGLE_QUOTE;
  13755. }
  13756. }
  13757. /**
  13758. * Selects the preferred quote mark based on the options and the current quote mark value.
  13759. * If you want the quote mark to depend on the attribute value, call `smartQuoteMark(opts)`
  13760. * instead.
  13761. */
  13762. ;
  13763. _proto.preferredQuoteMark = function preferredQuoteMark(options) {
  13764. var quoteMark = options.preferCurrentQuoteMark ? this.quoteMark : options.quoteMark;
  13765. if (quoteMark === undefined) {
  13766. quoteMark = options.preferCurrentQuoteMark ? options.quoteMark : this.quoteMark;
  13767. }
  13768. if (quoteMark === undefined) {
  13769. quoteMark = Attribute.DOUBLE_QUOTE;
  13770. }
  13771. return quoteMark;
  13772. };
  13773. _proto._syncRawValue = function _syncRawValue() {
  13774. var rawValue = (0, _cssesc["default"])(this._value, CSSESC_QUOTE_OPTIONS[this.quoteMark]);
  13775. if (rawValue === this._value) {
  13776. if (this.raws) {
  13777. delete this.raws.value;
  13778. }
  13779. } else {
  13780. this.raws.value = rawValue;
  13781. }
  13782. };
  13783. _proto._handleEscapes = function _handleEscapes(prop, value) {
  13784. if (this._constructed) {
  13785. var escaped = (0, _cssesc["default"])(value, {
  13786. isIdentifier: true
  13787. });
  13788. if (escaped !== value) {
  13789. this.raws[prop] = escaped;
  13790. } else {
  13791. delete this.raws[prop];
  13792. }
  13793. }
  13794. };
  13795. _proto._spacesFor = function _spacesFor(name) {
  13796. var attrSpaces = {
  13797. before: '',
  13798. after: ''
  13799. };
  13800. var spaces = this.spaces[name] || {};
  13801. var rawSpaces = this.raws.spaces && this.raws.spaces[name] || {};
  13802. return Object.assign(attrSpaces, spaces, rawSpaces);
  13803. };
  13804. _proto._stringFor = function _stringFor(name, spaceName, concat) {
  13805. if (spaceName === void 0) {
  13806. spaceName = name;
  13807. }
  13808. if (concat === void 0) {
  13809. concat = defaultAttrConcat;
  13810. }
  13811. var attrSpaces = this._spacesFor(spaceName);
  13812. return concat(this.stringifyProperty(name), attrSpaces);
  13813. }
  13814. /**
  13815. * returns the offset of the attribute part specified relative to the
  13816. * start of the node of the output string.
  13817. *
  13818. * * "ns" - alias for "namespace"
  13819. * * "namespace" - the namespace if it exists.
  13820. * * "attribute" - the attribute name
  13821. * * "attributeNS" - the start of the attribute or its namespace
  13822. * * "operator" - the match operator of the attribute
  13823. * * "value" - The value (string or identifier)
  13824. * * "insensitive" - the case insensitivity flag;
  13825. * @param part One of the possible values inside an attribute.
  13826. * @returns -1 if the name is invalid or the value doesn't exist in this attribute.
  13827. */
  13828. ;
  13829. _proto.offsetOf = function offsetOf(name) {
  13830. var count = 1;
  13831. var attributeSpaces = this._spacesFor("attribute");
  13832. count += attributeSpaces.before.length;
  13833. if (name === "namespace" || name === "ns") {
  13834. return this.namespace ? count : -1;
  13835. }
  13836. if (name === "attributeNS") {
  13837. return count;
  13838. }
  13839. count += this.namespaceString.length;
  13840. if (this.namespace) {
  13841. count += 1;
  13842. }
  13843. if (name === "attribute") {
  13844. return count;
  13845. }
  13846. count += this.stringifyProperty("attribute").length;
  13847. count += attributeSpaces.after.length;
  13848. var operatorSpaces = this._spacesFor("operator");
  13849. count += operatorSpaces.before.length;
  13850. var operator = this.stringifyProperty("operator");
  13851. if (name === "operator") {
  13852. return operator ? count : -1;
  13853. }
  13854. count += operator.length;
  13855. count += operatorSpaces.after.length;
  13856. var valueSpaces = this._spacesFor("value");
  13857. count += valueSpaces.before.length;
  13858. var value = this.stringifyProperty("value");
  13859. if (name === "value") {
  13860. return value ? count : -1;
  13861. }
  13862. count += value.length;
  13863. count += valueSpaces.after.length;
  13864. var insensitiveSpaces = this._spacesFor("insensitive");
  13865. count += insensitiveSpaces.before.length;
  13866. if (name === "insensitive") {
  13867. return this.insensitive ? count : -1;
  13868. }
  13869. return -1;
  13870. };
  13871. _proto.toString = function toString() {
  13872. var _this2 = this;
  13873. var selector = [this.rawSpaceBefore, '['];
  13874. selector.push(this._stringFor('qualifiedAttribute', 'attribute'));
  13875. if (this.operator && (this.value || this.value === '')) {
  13876. selector.push(this._stringFor('operator'));
  13877. selector.push(this._stringFor('value'));
  13878. selector.push(this._stringFor('insensitiveFlag', 'insensitive', function (attrValue, attrSpaces) {
  13879. if (attrValue.length > 0 && !_this2.quoted && attrSpaces.before.length === 0 && !(_this2.spaces.value && _this2.spaces.value.after)) {
  13880. attrSpaces.before = " ";
  13881. }
  13882. return defaultAttrConcat(attrValue, attrSpaces);
  13883. }));
  13884. }
  13885. selector.push(']');
  13886. selector.push(this.rawSpaceAfter);
  13887. return selector.join('');
  13888. };
  13889. _createClass(Attribute, [{
  13890. key: "quoted",
  13891. get: function get() {
  13892. var qm = this.quoteMark;
  13893. return qm === "'" || qm === '"';
  13894. },
  13895. set: function set(value) {
  13896. warnOfDeprecatedQuotedAssignment();
  13897. }
  13898. /**
  13899. * returns a single (`'`) or double (`"`) quote character if the value is quoted.
  13900. * returns `null` if the value is not quoted.
  13901. * returns `undefined` if the quotation state is unknown (this can happen when
  13902. * the attribute is constructed without specifying a quote mark.)
  13903. */
  13904. }, {
  13905. key: "quoteMark",
  13906. get: function get() {
  13907. return this._quoteMark;
  13908. }
  13909. /**
  13910. * Set the quote mark to be used by this attribute's value.
  13911. * If the quote mark changes, the raw (escaped) value at `attr.raws.value` of the attribute
  13912. * value is updated accordingly.
  13913. *
  13914. * @param {"'" | '"' | null} quoteMark The quote mark or `null` if the value should be unquoted.
  13915. */
  13916. ,
  13917. set: function set(quoteMark) {
  13918. if (!this._constructed) {
  13919. this._quoteMark = quoteMark;
  13920. return;
  13921. }
  13922. if (this._quoteMark !== quoteMark) {
  13923. this._quoteMark = quoteMark;
  13924. this._syncRawValue();
  13925. }
  13926. }
  13927. }, {
  13928. key: "qualifiedAttribute",
  13929. get: function get() {
  13930. return this.qualifiedName(this.raws.attribute || this.attribute);
  13931. }
  13932. }, {
  13933. key: "insensitiveFlag",
  13934. get: function get() {
  13935. return this.insensitive ? 'i' : '';
  13936. }
  13937. }, {
  13938. key: "value",
  13939. get: function get() {
  13940. return this._value;
  13941. }
  13942. /**
  13943. * Before 3.0, the value had to be set to an escaped value including any wrapped
  13944. * quote marks. In 3.0, the semantics of `Attribute.value` changed so that the value
  13945. * is unescaped during parsing and any quote marks are removed.
  13946. *
  13947. * Because the ambiguity of this semantic change, if you set `attr.value = newValue`,
  13948. * a deprecation warning is raised when the new value contains any characters that would
  13949. * require escaping (including if it contains wrapped quotes).
  13950. *
  13951. * Instead, you should call `attr.setValue(newValue, opts)` and pass options that describe
  13952. * how the new value is quoted.
  13953. */
  13954. ,
  13955. set: function set(v) {
  13956. if (this._constructed) {
  13957. var _unescapeValue2 = unescapeValue(v),
  13958. deprecatedUsage = _unescapeValue2.deprecatedUsage,
  13959. unescaped = _unescapeValue2.unescaped,
  13960. quoteMark = _unescapeValue2.quoteMark;
  13961. if (deprecatedUsage) {
  13962. warnOfDeprecatedValueAssignment();
  13963. }
  13964. if (unescaped === this._value && quoteMark === this._quoteMark) {
  13965. return;
  13966. }
  13967. this._value = unescaped;
  13968. this._quoteMark = quoteMark;
  13969. this._syncRawValue();
  13970. } else {
  13971. this._value = v;
  13972. }
  13973. }
  13974. }, {
  13975. key: "attribute",
  13976. get: function get() {
  13977. return this._attribute;
  13978. },
  13979. set: function set(name) {
  13980. this._handleEscapes("attribute", name);
  13981. this._attribute = name;
  13982. }
  13983. }]);
  13984. return Attribute;
  13985. }(_namespace["default"]);
  13986. exports["default"] = Attribute;
  13987. Attribute.NO_QUOTE = null;
  13988. Attribute.SINGLE_QUOTE = "'";
  13989. Attribute.DOUBLE_QUOTE = '"';
  13990. var CSSESC_QUOTE_OPTIONS = (_CSSESC_QUOTE_OPTIONS = {
  13991. "'": {
  13992. quotes: 'single',
  13993. wrap: true
  13994. },
  13995. '"': {
  13996. quotes: 'double',
  13997. wrap: true
  13998. }
  13999. }, _CSSESC_QUOTE_OPTIONS[null] = {
  14000. isIdentifier: true
  14001. }, _CSSESC_QUOTE_OPTIONS);
  14002. function defaultAttrConcat(attrValue, attrSpaces) {
  14003. return "" + attrSpaces.before + attrValue + attrSpaces.after;
  14004. }
  14005. } (attribute$1));
  14006. var universal$1 = {exports: {}};
  14007. (function (module, exports) {
  14008. exports.__esModule = true;
  14009. exports["default"] = void 0;
  14010. var _namespace = _interopRequireDefault(namespace.exports);
  14011. var _types = types;
  14012. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14013. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  14014. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14015. var Universal = /*#__PURE__*/function (_Namespace) {
  14016. _inheritsLoose(Universal, _Namespace);
  14017. function Universal(opts) {
  14018. var _this;
  14019. _this = _Namespace.call(this, opts) || this;
  14020. _this.type = _types.UNIVERSAL;
  14021. _this.value = '*';
  14022. return _this;
  14023. }
  14024. return Universal;
  14025. }(_namespace["default"]);
  14026. exports["default"] = Universal;
  14027. module.exports = exports.default;
  14028. } (universal$1, universal$1.exports));
  14029. var combinator$2 = {exports: {}};
  14030. (function (module, exports) {
  14031. exports.__esModule = true;
  14032. exports["default"] = void 0;
  14033. var _node = _interopRequireDefault(node$1.exports);
  14034. var _types = types;
  14035. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14036. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  14037. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14038. var Combinator = /*#__PURE__*/function (_Node) {
  14039. _inheritsLoose(Combinator, _Node);
  14040. function Combinator(opts) {
  14041. var _this;
  14042. _this = _Node.call(this, opts) || this;
  14043. _this.type = _types.COMBINATOR;
  14044. return _this;
  14045. }
  14046. return Combinator;
  14047. }(_node["default"]);
  14048. exports["default"] = Combinator;
  14049. module.exports = exports.default;
  14050. } (combinator$2, combinator$2.exports));
  14051. var nesting$1 = {exports: {}};
  14052. (function (module, exports) {
  14053. exports.__esModule = true;
  14054. exports["default"] = void 0;
  14055. var _node = _interopRequireDefault(node$1.exports);
  14056. var _types = types;
  14057. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14058. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  14059. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14060. var Nesting = /*#__PURE__*/function (_Node) {
  14061. _inheritsLoose(Nesting, _Node);
  14062. function Nesting(opts) {
  14063. var _this;
  14064. _this = _Node.call(this, opts) || this;
  14065. _this.type = _types.NESTING;
  14066. _this.value = '&';
  14067. return _this;
  14068. }
  14069. return Nesting;
  14070. }(_node["default"]);
  14071. exports["default"] = Nesting;
  14072. module.exports = exports.default;
  14073. } (nesting$1, nesting$1.exports));
  14074. var sortAscending = {exports: {}};
  14075. (function (module, exports) {
  14076. exports.__esModule = true;
  14077. exports["default"] = sortAscending;
  14078. function sortAscending(list) {
  14079. return list.sort(function (a, b) {
  14080. return a - b;
  14081. });
  14082. }
  14083. module.exports = exports.default;
  14084. } (sortAscending, sortAscending.exports));
  14085. var tokenize = {};
  14086. var tokenTypes = {};
  14087. tokenTypes.__esModule = true;
  14088. tokenTypes.combinator = tokenTypes.word = tokenTypes.comment = tokenTypes.str = tokenTypes.tab = tokenTypes.newline = tokenTypes.feed = tokenTypes.cr = tokenTypes.backslash = tokenTypes.bang = tokenTypes.slash = tokenTypes.doubleQuote = tokenTypes.singleQuote = tokenTypes.space = tokenTypes.greaterThan = tokenTypes.pipe = tokenTypes.equals = tokenTypes.plus = tokenTypes.caret = tokenTypes.tilde = tokenTypes.dollar = tokenTypes.closeSquare = tokenTypes.openSquare = tokenTypes.closeParenthesis = tokenTypes.openParenthesis = tokenTypes.semicolon = tokenTypes.colon = tokenTypes.comma = tokenTypes.at = tokenTypes.asterisk = tokenTypes.ampersand = void 0;
  14089. var ampersand = 38; // `&`.charCodeAt(0);
  14090. tokenTypes.ampersand = ampersand;
  14091. var asterisk = 42; // `*`.charCodeAt(0);
  14092. tokenTypes.asterisk = asterisk;
  14093. var at = 64; // `@`.charCodeAt(0);
  14094. tokenTypes.at = at;
  14095. var comma = 44; // `,`.charCodeAt(0);
  14096. tokenTypes.comma = comma;
  14097. var colon = 58; // `:`.charCodeAt(0);
  14098. tokenTypes.colon = colon;
  14099. var semicolon = 59; // `;`.charCodeAt(0);
  14100. tokenTypes.semicolon = semicolon;
  14101. var openParenthesis = 40; // `(`.charCodeAt(0);
  14102. tokenTypes.openParenthesis = openParenthesis;
  14103. var closeParenthesis = 41; // `)`.charCodeAt(0);
  14104. tokenTypes.closeParenthesis = closeParenthesis;
  14105. var openSquare = 91; // `[`.charCodeAt(0);
  14106. tokenTypes.openSquare = openSquare;
  14107. var closeSquare = 93; // `]`.charCodeAt(0);
  14108. tokenTypes.closeSquare = closeSquare;
  14109. var dollar = 36; // `$`.charCodeAt(0);
  14110. tokenTypes.dollar = dollar;
  14111. var tilde = 126; // `~`.charCodeAt(0);
  14112. tokenTypes.tilde = tilde;
  14113. var caret = 94; // `^`.charCodeAt(0);
  14114. tokenTypes.caret = caret;
  14115. var plus = 43; // `+`.charCodeAt(0);
  14116. tokenTypes.plus = plus;
  14117. var equals = 61; // `=`.charCodeAt(0);
  14118. tokenTypes.equals = equals;
  14119. var pipe = 124; // `|`.charCodeAt(0);
  14120. tokenTypes.pipe = pipe;
  14121. var greaterThan = 62; // `>`.charCodeAt(0);
  14122. tokenTypes.greaterThan = greaterThan;
  14123. var space = 32; // ` `.charCodeAt(0);
  14124. tokenTypes.space = space;
  14125. var singleQuote = 39; // `'`.charCodeAt(0);
  14126. tokenTypes.singleQuote = singleQuote;
  14127. var doubleQuote = 34; // `"`.charCodeAt(0);
  14128. tokenTypes.doubleQuote = doubleQuote;
  14129. var slash = 47; // `/`.charCodeAt(0);
  14130. tokenTypes.slash = slash;
  14131. var bang = 33; // `!`.charCodeAt(0);
  14132. tokenTypes.bang = bang;
  14133. var backslash = 92; // '\\'.charCodeAt(0);
  14134. tokenTypes.backslash = backslash;
  14135. var cr = 13; // '\r'.charCodeAt(0);
  14136. tokenTypes.cr = cr;
  14137. var feed = 12; // '\f'.charCodeAt(0);
  14138. tokenTypes.feed = feed;
  14139. var newline = 10; // '\n'.charCodeAt(0);
  14140. tokenTypes.newline = newline;
  14141. var tab = 9; // '\t'.charCodeAt(0);
  14142. // Expose aliases primarily for readability.
  14143. tokenTypes.tab = tab;
  14144. var str = singleQuote; // No good single character representation!
  14145. tokenTypes.str = str;
  14146. var comment$1 = -1;
  14147. tokenTypes.comment = comment$1;
  14148. var word = -2;
  14149. tokenTypes.word = word;
  14150. var combinator$1 = -3;
  14151. tokenTypes.combinator = combinator$1;
  14152. (function (exports) {
  14153. exports.__esModule = true;
  14154. exports["default"] = tokenize;
  14155. exports.FIELDS = void 0;
  14156. var t = _interopRequireWildcard(tokenTypes);
  14157. var _unescapable, _wordDelimiters;
  14158. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  14159. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  14160. var unescapable = (_unescapable = {}, _unescapable[t.tab] = true, _unescapable[t.newline] = true, _unescapable[t.cr] = true, _unescapable[t.feed] = true, _unescapable);
  14161. var wordDelimiters = (_wordDelimiters = {}, _wordDelimiters[t.space] = true, _wordDelimiters[t.tab] = true, _wordDelimiters[t.newline] = true, _wordDelimiters[t.cr] = true, _wordDelimiters[t.feed] = true, _wordDelimiters[t.ampersand] = true, _wordDelimiters[t.asterisk] = true, _wordDelimiters[t.bang] = true, _wordDelimiters[t.comma] = true, _wordDelimiters[t.colon] = true, _wordDelimiters[t.semicolon] = true, _wordDelimiters[t.openParenthesis] = true, _wordDelimiters[t.closeParenthesis] = true, _wordDelimiters[t.openSquare] = true, _wordDelimiters[t.closeSquare] = true, _wordDelimiters[t.singleQuote] = true, _wordDelimiters[t.doubleQuote] = true, _wordDelimiters[t.plus] = true, _wordDelimiters[t.pipe] = true, _wordDelimiters[t.tilde] = true, _wordDelimiters[t.greaterThan] = true, _wordDelimiters[t.equals] = true, _wordDelimiters[t.dollar] = true, _wordDelimiters[t.caret] = true, _wordDelimiters[t.slash] = true, _wordDelimiters);
  14162. var hex = {};
  14163. var hexChars = "0123456789abcdefABCDEF";
  14164. for (var i = 0; i < hexChars.length; i++) {
  14165. hex[hexChars.charCodeAt(i)] = true;
  14166. }
  14167. /**
  14168. * Returns the last index of the bar css word
  14169. * @param {string} css The string in which the word begins
  14170. * @param {number} start The index into the string where word's first letter occurs
  14171. */
  14172. function consumeWord(css, start) {
  14173. var next = start;
  14174. var code;
  14175. do {
  14176. code = css.charCodeAt(next);
  14177. if (wordDelimiters[code]) {
  14178. return next - 1;
  14179. } else if (code === t.backslash) {
  14180. next = consumeEscape(css, next) + 1;
  14181. } else {
  14182. // All other characters are part of the word
  14183. next++;
  14184. }
  14185. } while (next < css.length);
  14186. return next - 1;
  14187. }
  14188. /**
  14189. * Returns the last index of the escape sequence
  14190. * @param {string} css The string in which the sequence begins
  14191. * @param {number} start The index into the string where escape character (`\`) occurs.
  14192. */
  14193. function consumeEscape(css, start) {
  14194. var next = start;
  14195. var code = css.charCodeAt(next + 1);
  14196. if (unescapable[code]) ; else if (hex[code]) {
  14197. var hexDigits = 0; // consume up to 6 hex chars
  14198. do {
  14199. next++;
  14200. hexDigits++;
  14201. code = css.charCodeAt(next + 1);
  14202. } while (hex[code] && hexDigits < 6); // if fewer than 6 hex chars, a trailing space ends the escape
  14203. if (hexDigits < 6 && code === t.space) {
  14204. next++;
  14205. }
  14206. } else {
  14207. // the next char is part of the current word
  14208. next++;
  14209. }
  14210. return next;
  14211. }
  14212. var FIELDS = {
  14213. TYPE: 0,
  14214. START_LINE: 1,
  14215. START_COL: 2,
  14216. END_LINE: 3,
  14217. END_COL: 4,
  14218. START_POS: 5,
  14219. END_POS: 6
  14220. };
  14221. exports.FIELDS = FIELDS;
  14222. function tokenize(input) {
  14223. var tokens = [];
  14224. var css = input.css.valueOf();
  14225. var _css = css,
  14226. length = _css.length;
  14227. var offset = -1;
  14228. var line = 1;
  14229. var start = 0;
  14230. var end = 0;
  14231. var code, content, endColumn, endLine, escaped, escapePos, last, lines, next, nextLine, nextOffset, quote, tokenType;
  14232. function unclosed(what, fix) {
  14233. if (input.safe) {
  14234. // fyi: this is never set to true.
  14235. css += fix;
  14236. next = css.length - 1;
  14237. } else {
  14238. throw input.error('Unclosed ' + what, line, start - offset, start);
  14239. }
  14240. }
  14241. while (start < length) {
  14242. code = css.charCodeAt(start);
  14243. if (code === t.newline) {
  14244. offset = start;
  14245. line += 1;
  14246. }
  14247. switch (code) {
  14248. case t.space:
  14249. case t.tab:
  14250. case t.newline:
  14251. case t.cr:
  14252. case t.feed:
  14253. next = start;
  14254. do {
  14255. next += 1;
  14256. code = css.charCodeAt(next);
  14257. if (code === t.newline) {
  14258. offset = next;
  14259. line += 1;
  14260. }
  14261. } while (code === t.space || code === t.newline || code === t.tab || code === t.cr || code === t.feed);
  14262. tokenType = t.space;
  14263. endLine = line;
  14264. endColumn = next - offset - 1;
  14265. end = next;
  14266. break;
  14267. case t.plus:
  14268. case t.greaterThan:
  14269. case t.tilde:
  14270. case t.pipe:
  14271. next = start;
  14272. do {
  14273. next += 1;
  14274. code = css.charCodeAt(next);
  14275. } while (code === t.plus || code === t.greaterThan || code === t.tilde || code === t.pipe);
  14276. tokenType = t.combinator;
  14277. endLine = line;
  14278. endColumn = start - offset;
  14279. end = next;
  14280. break;
  14281. // Consume these characters as single tokens.
  14282. case t.asterisk:
  14283. case t.ampersand:
  14284. case t.bang:
  14285. case t.comma:
  14286. case t.equals:
  14287. case t.dollar:
  14288. case t.caret:
  14289. case t.openSquare:
  14290. case t.closeSquare:
  14291. case t.colon:
  14292. case t.semicolon:
  14293. case t.openParenthesis:
  14294. case t.closeParenthesis:
  14295. next = start;
  14296. tokenType = code;
  14297. endLine = line;
  14298. endColumn = start - offset;
  14299. end = next + 1;
  14300. break;
  14301. case t.singleQuote:
  14302. case t.doubleQuote:
  14303. quote = code === t.singleQuote ? "'" : '"';
  14304. next = start;
  14305. do {
  14306. escaped = false;
  14307. next = css.indexOf(quote, next + 1);
  14308. if (next === -1) {
  14309. unclosed('quote', quote);
  14310. }
  14311. escapePos = next;
  14312. while (css.charCodeAt(escapePos - 1) === t.backslash) {
  14313. escapePos -= 1;
  14314. escaped = !escaped;
  14315. }
  14316. } while (escaped);
  14317. tokenType = t.str;
  14318. endLine = line;
  14319. endColumn = start - offset;
  14320. end = next + 1;
  14321. break;
  14322. default:
  14323. if (code === t.slash && css.charCodeAt(start + 1) === t.asterisk) {
  14324. next = css.indexOf('*/', start + 2) + 1;
  14325. if (next === 0) {
  14326. unclosed('comment', '*/');
  14327. }
  14328. content = css.slice(start, next + 1);
  14329. lines = content.split('\n');
  14330. last = lines.length - 1;
  14331. if (last > 0) {
  14332. nextLine = line + last;
  14333. nextOffset = next - lines[last].length;
  14334. } else {
  14335. nextLine = line;
  14336. nextOffset = offset;
  14337. }
  14338. tokenType = t.comment;
  14339. line = nextLine;
  14340. endLine = nextLine;
  14341. endColumn = next - nextOffset;
  14342. } else if (code === t.slash) {
  14343. next = start;
  14344. tokenType = code;
  14345. endLine = line;
  14346. endColumn = start - offset;
  14347. end = next + 1;
  14348. } else {
  14349. next = consumeWord(css, start);
  14350. tokenType = t.word;
  14351. endLine = line;
  14352. endColumn = next - offset;
  14353. }
  14354. end = next + 1;
  14355. break;
  14356. } // Ensure that the token structure remains consistent
  14357. tokens.push([tokenType, // [0] Token type
  14358. line, // [1] Starting line
  14359. start - offset, // [2] Starting column
  14360. endLine, // [3] Ending line
  14361. endColumn, // [4] Ending column
  14362. start, // [5] Start position / Source index
  14363. end // [6] End position
  14364. ]); // Reset offset for the next token
  14365. if (nextOffset) {
  14366. offset = nextOffset;
  14367. nextOffset = null;
  14368. }
  14369. start = end;
  14370. }
  14371. return tokens;
  14372. }
  14373. } (tokenize));
  14374. (function (module, exports) {
  14375. exports.__esModule = true;
  14376. exports["default"] = void 0;
  14377. var _root = _interopRequireDefault(root$1.exports);
  14378. var _selector = _interopRequireDefault(selector$1.exports);
  14379. var _className = _interopRequireDefault(className$1.exports);
  14380. var _comment = _interopRequireDefault(comment$2.exports);
  14381. var _id = _interopRequireDefault(id$1.exports);
  14382. var _tag = _interopRequireDefault(tag$1.exports);
  14383. var _string = _interopRequireDefault(string$1.exports);
  14384. var _pseudo = _interopRequireDefault(pseudo$1.exports);
  14385. var _attribute = _interopRequireWildcard(attribute$1);
  14386. var _universal = _interopRequireDefault(universal$1.exports);
  14387. var _combinator = _interopRequireDefault(combinator$2.exports);
  14388. var _nesting = _interopRequireDefault(nesting$1.exports);
  14389. var _sortAscending = _interopRequireDefault(sortAscending.exports);
  14390. var _tokenize = _interopRequireWildcard(tokenize);
  14391. var tokens = _interopRequireWildcard(tokenTypes);
  14392. var types$1 = _interopRequireWildcard(types);
  14393. var _util = util;
  14394. var _WHITESPACE_TOKENS, _Object$assign;
  14395. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  14396. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  14397. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  14398. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  14399. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14400. var WHITESPACE_TOKENS = (_WHITESPACE_TOKENS = {}, _WHITESPACE_TOKENS[tokens.space] = true, _WHITESPACE_TOKENS[tokens.cr] = true, _WHITESPACE_TOKENS[tokens.feed] = true, _WHITESPACE_TOKENS[tokens.newline] = true, _WHITESPACE_TOKENS[tokens.tab] = true, _WHITESPACE_TOKENS);
  14401. var WHITESPACE_EQUIV_TOKENS = Object.assign({}, WHITESPACE_TOKENS, (_Object$assign = {}, _Object$assign[tokens.comment] = true, _Object$assign));
  14402. function tokenStart(token) {
  14403. return {
  14404. line: token[_tokenize.FIELDS.START_LINE],
  14405. column: token[_tokenize.FIELDS.START_COL]
  14406. };
  14407. }
  14408. function tokenEnd(token) {
  14409. return {
  14410. line: token[_tokenize.FIELDS.END_LINE],
  14411. column: token[_tokenize.FIELDS.END_COL]
  14412. };
  14413. }
  14414. function getSource(startLine, startColumn, endLine, endColumn) {
  14415. return {
  14416. start: {
  14417. line: startLine,
  14418. column: startColumn
  14419. },
  14420. end: {
  14421. line: endLine,
  14422. column: endColumn
  14423. }
  14424. };
  14425. }
  14426. function getTokenSource(token) {
  14427. return getSource(token[_tokenize.FIELDS.START_LINE], token[_tokenize.FIELDS.START_COL], token[_tokenize.FIELDS.END_LINE], token[_tokenize.FIELDS.END_COL]);
  14428. }
  14429. function getTokenSourceSpan(startToken, endToken) {
  14430. if (!startToken) {
  14431. return undefined;
  14432. }
  14433. return getSource(startToken[_tokenize.FIELDS.START_LINE], startToken[_tokenize.FIELDS.START_COL], endToken[_tokenize.FIELDS.END_LINE], endToken[_tokenize.FIELDS.END_COL]);
  14434. }
  14435. function unescapeProp(node, prop) {
  14436. var value = node[prop];
  14437. if (typeof value !== "string") {
  14438. return;
  14439. }
  14440. if (value.indexOf("\\") !== -1) {
  14441. (0, _util.ensureObject)(node, 'raws');
  14442. node[prop] = (0, _util.unesc)(value);
  14443. if (node.raws[prop] === undefined) {
  14444. node.raws[prop] = value;
  14445. }
  14446. }
  14447. return node;
  14448. }
  14449. function indexesOf(array, item) {
  14450. var i = -1;
  14451. var indexes = [];
  14452. while ((i = array.indexOf(item, i + 1)) !== -1) {
  14453. indexes.push(i);
  14454. }
  14455. return indexes;
  14456. }
  14457. function uniqs() {
  14458. var list = Array.prototype.concat.apply([], arguments);
  14459. return list.filter(function (item, i) {
  14460. return i === list.indexOf(item);
  14461. });
  14462. }
  14463. var Parser = /*#__PURE__*/function () {
  14464. function Parser(rule, options) {
  14465. if (options === void 0) {
  14466. options = {};
  14467. }
  14468. this.rule = rule;
  14469. this.options = Object.assign({
  14470. lossy: false,
  14471. safe: false
  14472. }, options);
  14473. this.position = 0;
  14474. this.css = typeof this.rule === 'string' ? this.rule : this.rule.selector;
  14475. this.tokens = (0, _tokenize["default"])({
  14476. css: this.css,
  14477. error: this._errorGenerator(),
  14478. safe: this.options.safe
  14479. });
  14480. var rootSource = getTokenSourceSpan(this.tokens[0], this.tokens[this.tokens.length - 1]);
  14481. this.root = new _root["default"]({
  14482. source: rootSource
  14483. });
  14484. this.root.errorGenerator = this._errorGenerator();
  14485. var selector = new _selector["default"]({
  14486. source: {
  14487. start: {
  14488. line: 1,
  14489. column: 1
  14490. }
  14491. }
  14492. });
  14493. this.root.append(selector);
  14494. this.current = selector;
  14495. this.loop();
  14496. }
  14497. var _proto = Parser.prototype;
  14498. _proto._errorGenerator = function _errorGenerator() {
  14499. var _this = this;
  14500. return function (message, errorOptions) {
  14501. if (typeof _this.rule === 'string') {
  14502. return new Error(message);
  14503. }
  14504. return _this.rule.error(message, errorOptions);
  14505. };
  14506. };
  14507. _proto.attribute = function attribute() {
  14508. var attr = [];
  14509. var startingToken = this.currToken;
  14510. this.position++;
  14511. while (this.position < this.tokens.length && this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  14512. attr.push(this.currToken);
  14513. this.position++;
  14514. }
  14515. if (this.currToken[_tokenize.FIELDS.TYPE] !== tokens.closeSquare) {
  14516. return this.expected('closing square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  14517. }
  14518. var len = attr.length;
  14519. var node = {
  14520. source: getSource(startingToken[1], startingToken[2], this.currToken[3], this.currToken[4]),
  14521. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  14522. };
  14523. if (len === 1 && !~[tokens.word].indexOf(attr[0][_tokenize.FIELDS.TYPE])) {
  14524. return this.expected('attribute', attr[0][_tokenize.FIELDS.START_POS]);
  14525. }
  14526. var pos = 0;
  14527. var spaceBefore = '';
  14528. var commentBefore = '';
  14529. var lastAdded = null;
  14530. var spaceAfterMeaningfulToken = false;
  14531. while (pos < len) {
  14532. var token = attr[pos];
  14533. var content = this.content(token);
  14534. var next = attr[pos + 1];
  14535. switch (token[_tokenize.FIELDS.TYPE]) {
  14536. case tokens.space:
  14537. // if (
  14538. // len === 1 ||
  14539. // pos === 0 && this.content(next) === '|'
  14540. // ) {
  14541. // return this.expected('attribute', token[TOKEN.START_POS], content);
  14542. // }
  14543. spaceAfterMeaningfulToken = true;
  14544. if (this.options.lossy) {
  14545. break;
  14546. }
  14547. if (lastAdded) {
  14548. (0, _util.ensureObject)(node, 'spaces', lastAdded);
  14549. var prevContent = node.spaces[lastAdded].after || '';
  14550. node.spaces[lastAdded].after = prevContent + content;
  14551. var existingComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || null;
  14552. if (existingComment) {
  14553. node.raws.spaces[lastAdded].after = existingComment + content;
  14554. }
  14555. } else {
  14556. spaceBefore = spaceBefore + content;
  14557. commentBefore = commentBefore + content;
  14558. }
  14559. break;
  14560. case tokens.asterisk:
  14561. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  14562. node.operator = content;
  14563. lastAdded = 'operator';
  14564. } else if ((!node.namespace || lastAdded === "namespace" && !spaceAfterMeaningfulToken) && next) {
  14565. if (spaceBefore) {
  14566. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  14567. node.spaces.attribute.before = spaceBefore;
  14568. spaceBefore = '';
  14569. }
  14570. if (commentBefore) {
  14571. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  14572. node.raws.spaces.attribute.before = spaceBefore;
  14573. commentBefore = '';
  14574. }
  14575. node.namespace = (node.namespace || "") + content;
  14576. var rawValue = (0, _util.getProp)(node, 'raws', 'namespace') || null;
  14577. if (rawValue) {
  14578. node.raws.namespace += content;
  14579. }
  14580. lastAdded = 'namespace';
  14581. }
  14582. spaceAfterMeaningfulToken = false;
  14583. break;
  14584. case tokens.dollar:
  14585. if (lastAdded === "value") {
  14586. var oldRawValue = (0, _util.getProp)(node, 'raws', 'value');
  14587. node.value += "$";
  14588. if (oldRawValue) {
  14589. node.raws.value = oldRawValue + "$";
  14590. }
  14591. break;
  14592. }
  14593. // Falls through
  14594. case tokens.caret:
  14595. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  14596. node.operator = content;
  14597. lastAdded = 'operator';
  14598. }
  14599. spaceAfterMeaningfulToken = false;
  14600. break;
  14601. case tokens.combinator:
  14602. if (content === '~' && next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  14603. node.operator = content;
  14604. lastAdded = 'operator';
  14605. }
  14606. if (content !== '|') {
  14607. spaceAfterMeaningfulToken = false;
  14608. break;
  14609. }
  14610. if (next[_tokenize.FIELDS.TYPE] === tokens.equals) {
  14611. node.operator = content;
  14612. lastAdded = 'operator';
  14613. } else if (!node.namespace && !node.attribute) {
  14614. node.namespace = true;
  14615. }
  14616. spaceAfterMeaningfulToken = false;
  14617. break;
  14618. case tokens.word:
  14619. if (next && this.content(next) === '|' && attr[pos + 2] && attr[pos + 2][_tokenize.FIELDS.TYPE] !== tokens.equals && // this look-ahead probably fails with comment nodes involved.
  14620. !node.operator && !node.namespace) {
  14621. node.namespace = content;
  14622. lastAdded = 'namespace';
  14623. } else if (!node.attribute || lastAdded === "attribute" && !spaceAfterMeaningfulToken) {
  14624. if (spaceBefore) {
  14625. (0, _util.ensureObject)(node, 'spaces', 'attribute');
  14626. node.spaces.attribute.before = spaceBefore;
  14627. spaceBefore = '';
  14628. }
  14629. if (commentBefore) {
  14630. (0, _util.ensureObject)(node, 'raws', 'spaces', 'attribute');
  14631. node.raws.spaces.attribute.before = commentBefore;
  14632. commentBefore = '';
  14633. }
  14634. node.attribute = (node.attribute || "") + content;
  14635. var _rawValue = (0, _util.getProp)(node, 'raws', 'attribute') || null;
  14636. if (_rawValue) {
  14637. node.raws.attribute += content;
  14638. }
  14639. lastAdded = 'attribute';
  14640. } else if (!node.value && node.value !== "" || lastAdded === "value" && !spaceAfterMeaningfulToken) {
  14641. var _unescaped = (0, _util.unesc)(content);
  14642. var _oldRawValue = (0, _util.getProp)(node, 'raws', 'value') || '';
  14643. var oldValue = node.value || '';
  14644. node.value = oldValue + _unescaped;
  14645. node.quoteMark = null;
  14646. if (_unescaped !== content || _oldRawValue) {
  14647. (0, _util.ensureObject)(node, 'raws');
  14648. node.raws.value = (_oldRawValue || oldValue) + content;
  14649. }
  14650. lastAdded = 'value';
  14651. } else {
  14652. var insensitive = content === 'i' || content === "I";
  14653. if ((node.value || node.value === '') && (node.quoteMark || spaceAfterMeaningfulToken)) {
  14654. node.insensitive = insensitive;
  14655. if (!insensitive || content === "I") {
  14656. (0, _util.ensureObject)(node, 'raws');
  14657. node.raws.insensitiveFlag = content;
  14658. }
  14659. lastAdded = 'insensitive';
  14660. if (spaceBefore) {
  14661. (0, _util.ensureObject)(node, 'spaces', 'insensitive');
  14662. node.spaces.insensitive.before = spaceBefore;
  14663. spaceBefore = '';
  14664. }
  14665. if (commentBefore) {
  14666. (0, _util.ensureObject)(node, 'raws', 'spaces', 'insensitive');
  14667. node.raws.spaces.insensitive.before = commentBefore;
  14668. commentBefore = '';
  14669. }
  14670. } else if (node.value || node.value === '') {
  14671. lastAdded = 'value';
  14672. node.value += content;
  14673. if (node.raws.value) {
  14674. node.raws.value += content;
  14675. }
  14676. }
  14677. }
  14678. spaceAfterMeaningfulToken = false;
  14679. break;
  14680. case tokens.str:
  14681. if (!node.attribute || !node.operator) {
  14682. return this.error("Expected an attribute followed by an operator preceding the string.", {
  14683. index: token[_tokenize.FIELDS.START_POS]
  14684. });
  14685. }
  14686. var _unescapeValue = (0, _attribute.unescapeValue)(content),
  14687. unescaped = _unescapeValue.unescaped,
  14688. quoteMark = _unescapeValue.quoteMark;
  14689. node.value = unescaped;
  14690. node.quoteMark = quoteMark;
  14691. lastAdded = 'value';
  14692. (0, _util.ensureObject)(node, 'raws');
  14693. node.raws.value = content;
  14694. spaceAfterMeaningfulToken = false;
  14695. break;
  14696. case tokens.equals:
  14697. if (!node.attribute) {
  14698. return this.expected('attribute', token[_tokenize.FIELDS.START_POS], content);
  14699. }
  14700. if (node.value) {
  14701. return this.error('Unexpected "=" found; an operator was already defined.', {
  14702. index: token[_tokenize.FIELDS.START_POS]
  14703. });
  14704. }
  14705. node.operator = node.operator ? node.operator + content : content;
  14706. lastAdded = 'operator';
  14707. spaceAfterMeaningfulToken = false;
  14708. break;
  14709. case tokens.comment:
  14710. if (lastAdded) {
  14711. if (spaceAfterMeaningfulToken || next && next[_tokenize.FIELDS.TYPE] === tokens.space || lastAdded === 'insensitive') {
  14712. var lastComment = (0, _util.getProp)(node, 'spaces', lastAdded, 'after') || '';
  14713. var rawLastComment = (0, _util.getProp)(node, 'raws', 'spaces', lastAdded, 'after') || lastComment;
  14714. (0, _util.ensureObject)(node, 'raws', 'spaces', lastAdded);
  14715. node.raws.spaces[lastAdded].after = rawLastComment + content;
  14716. } else {
  14717. var lastValue = node[lastAdded] || '';
  14718. var rawLastValue = (0, _util.getProp)(node, 'raws', lastAdded) || lastValue;
  14719. (0, _util.ensureObject)(node, 'raws');
  14720. node.raws[lastAdded] = rawLastValue + content;
  14721. }
  14722. } else {
  14723. commentBefore = commentBefore + content;
  14724. }
  14725. break;
  14726. default:
  14727. return this.error("Unexpected \"" + content + "\" found.", {
  14728. index: token[_tokenize.FIELDS.START_POS]
  14729. });
  14730. }
  14731. pos++;
  14732. }
  14733. unescapeProp(node, "attribute");
  14734. unescapeProp(node, "namespace");
  14735. this.newNode(new _attribute["default"](node));
  14736. this.position++;
  14737. }
  14738. /**
  14739. * return a node containing meaningless garbage up to (but not including) the specified token position.
  14740. * if the token position is negative, all remaining tokens are consumed.
  14741. *
  14742. * This returns an array containing a single string node if all whitespace,
  14743. * otherwise an array of comment nodes with space before and after.
  14744. *
  14745. * These tokens are not added to the current selector, the caller can add them or use them to amend
  14746. * a previous node's space metadata.
  14747. *
  14748. * In lossy mode, this returns only comments.
  14749. */
  14750. ;
  14751. _proto.parseWhitespaceEquivalentTokens = function parseWhitespaceEquivalentTokens(stopPosition) {
  14752. if (stopPosition < 0) {
  14753. stopPosition = this.tokens.length;
  14754. }
  14755. var startPosition = this.position;
  14756. var nodes = [];
  14757. var space = "";
  14758. var lastComment = undefined;
  14759. do {
  14760. if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) {
  14761. if (!this.options.lossy) {
  14762. space += this.content();
  14763. }
  14764. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.comment) {
  14765. var spaces = {};
  14766. if (space) {
  14767. spaces.before = space;
  14768. space = "";
  14769. }
  14770. lastComment = new _comment["default"]({
  14771. value: this.content(),
  14772. source: getTokenSource(this.currToken),
  14773. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  14774. spaces: spaces
  14775. });
  14776. nodes.push(lastComment);
  14777. }
  14778. } while (++this.position < stopPosition);
  14779. if (space) {
  14780. if (lastComment) {
  14781. lastComment.spaces.after = space;
  14782. } else if (!this.options.lossy) {
  14783. var firstToken = this.tokens[startPosition];
  14784. var lastToken = this.tokens[this.position - 1];
  14785. nodes.push(new _string["default"]({
  14786. value: '',
  14787. source: getSource(firstToken[_tokenize.FIELDS.START_LINE], firstToken[_tokenize.FIELDS.START_COL], lastToken[_tokenize.FIELDS.END_LINE], lastToken[_tokenize.FIELDS.END_COL]),
  14788. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  14789. spaces: {
  14790. before: space,
  14791. after: ''
  14792. }
  14793. }));
  14794. }
  14795. }
  14796. return nodes;
  14797. }
  14798. /**
  14799. *
  14800. * @param {*} nodes
  14801. */
  14802. ;
  14803. _proto.convertWhitespaceNodesToSpace = function convertWhitespaceNodesToSpace(nodes, requiredSpace) {
  14804. var _this2 = this;
  14805. if (requiredSpace === void 0) {
  14806. requiredSpace = false;
  14807. }
  14808. var space = "";
  14809. var rawSpace = "";
  14810. nodes.forEach(function (n) {
  14811. var spaceBefore = _this2.lossySpace(n.spaces.before, requiredSpace);
  14812. var rawSpaceBefore = _this2.lossySpace(n.rawSpaceBefore, requiredSpace);
  14813. space += spaceBefore + _this2.lossySpace(n.spaces.after, requiredSpace && spaceBefore.length === 0);
  14814. rawSpace += spaceBefore + n.value + _this2.lossySpace(n.rawSpaceAfter, requiredSpace && rawSpaceBefore.length === 0);
  14815. });
  14816. if (rawSpace === space) {
  14817. rawSpace = undefined;
  14818. }
  14819. var result = {
  14820. space: space,
  14821. rawSpace: rawSpace
  14822. };
  14823. return result;
  14824. };
  14825. _proto.isNamedCombinator = function isNamedCombinator(position) {
  14826. if (position === void 0) {
  14827. position = this.position;
  14828. }
  14829. return this.tokens[position + 0] && this.tokens[position + 0][_tokenize.FIELDS.TYPE] === tokens.slash && this.tokens[position + 1] && this.tokens[position + 1][_tokenize.FIELDS.TYPE] === tokens.word && this.tokens[position + 2] && this.tokens[position + 2][_tokenize.FIELDS.TYPE] === tokens.slash;
  14830. };
  14831. _proto.namedCombinator = function namedCombinator() {
  14832. if (this.isNamedCombinator()) {
  14833. var nameRaw = this.content(this.tokens[this.position + 1]);
  14834. var name = (0, _util.unesc)(nameRaw).toLowerCase();
  14835. var raws = {};
  14836. if (name !== nameRaw) {
  14837. raws.value = "/" + nameRaw + "/";
  14838. }
  14839. var node = new _combinator["default"]({
  14840. value: "/" + name + "/",
  14841. source: getSource(this.currToken[_tokenize.FIELDS.START_LINE], this.currToken[_tokenize.FIELDS.START_COL], this.tokens[this.position + 2][_tokenize.FIELDS.END_LINE], this.tokens[this.position + 2][_tokenize.FIELDS.END_COL]),
  14842. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS],
  14843. raws: raws
  14844. });
  14845. this.position = this.position + 3;
  14846. return node;
  14847. } else {
  14848. this.unexpected();
  14849. }
  14850. };
  14851. _proto.combinator = function combinator() {
  14852. var _this3 = this;
  14853. if (this.content() === '|') {
  14854. return this.namespace();
  14855. } // We need to decide between a space that's a descendant combinator and meaningless whitespace at the end of a selector.
  14856. var nextSigTokenPos = this.locateNextMeaningfulToken(this.position);
  14857. if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.comma) {
  14858. var nodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  14859. if (nodes.length > 0) {
  14860. var last = this.current.last;
  14861. if (last) {
  14862. var _this$convertWhitespa = this.convertWhitespaceNodesToSpace(nodes),
  14863. space = _this$convertWhitespa.space,
  14864. rawSpace = _this$convertWhitespa.rawSpace;
  14865. if (rawSpace !== undefined) {
  14866. last.rawSpaceAfter += rawSpace;
  14867. }
  14868. last.spaces.after += space;
  14869. } else {
  14870. nodes.forEach(function (n) {
  14871. return _this3.newNode(n);
  14872. });
  14873. }
  14874. }
  14875. return;
  14876. }
  14877. var firstToken = this.currToken;
  14878. var spaceOrDescendantSelectorNodes = undefined;
  14879. if (nextSigTokenPos > this.position) {
  14880. spaceOrDescendantSelectorNodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
  14881. }
  14882. var node;
  14883. if (this.isNamedCombinator()) {
  14884. node = this.namedCombinator();
  14885. } else if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.combinator) {
  14886. node = new _combinator["default"]({
  14887. value: this.content(),
  14888. source: getTokenSource(this.currToken),
  14889. sourceIndex: this.currToken[_tokenize.FIELDS.START_POS]
  14890. });
  14891. this.position++;
  14892. } else if (WHITESPACE_TOKENS[this.currToken[_tokenize.FIELDS.TYPE]]) ; else if (!spaceOrDescendantSelectorNodes) {
  14893. this.unexpected();
  14894. }
  14895. if (node) {
  14896. if (spaceOrDescendantSelectorNodes) {
  14897. var _this$convertWhitespa2 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes),
  14898. _space = _this$convertWhitespa2.space,
  14899. _rawSpace = _this$convertWhitespa2.rawSpace;
  14900. node.spaces.before = _space;
  14901. node.rawSpaceBefore = _rawSpace;
  14902. }
  14903. } else {
  14904. // descendant combinator
  14905. var _this$convertWhitespa3 = this.convertWhitespaceNodesToSpace(spaceOrDescendantSelectorNodes, true),
  14906. _space2 = _this$convertWhitespa3.space,
  14907. _rawSpace2 = _this$convertWhitespa3.rawSpace;
  14908. if (!_rawSpace2) {
  14909. _rawSpace2 = _space2;
  14910. }
  14911. var spaces = {};
  14912. var raws = {
  14913. spaces: {}
  14914. };
  14915. if (_space2.endsWith(' ') && _rawSpace2.endsWith(' ')) {
  14916. spaces.before = _space2.slice(0, _space2.length - 1);
  14917. raws.spaces.before = _rawSpace2.slice(0, _rawSpace2.length - 1);
  14918. } else if (_space2.startsWith(' ') && _rawSpace2.startsWith(' ')) {
  14919. spaces.after = _space2.slice(1);
  14920. raws.spaces.after = _rawSpace2.slice(1);
  14921. } else {
  14922. raws.value = _rawSpace2;
  14923. }
  14924. node = new _combinator["default"]({
  14925. value: ' ',
  14926. source: getTokenSourceSpan(firstToken, this.tokens[this.position - 1]),
  14927. sourceIndex: firstToken[_tokenize.FIELDS.START_POS],
  14928. spaces: spaces,
  14929. raws: raws
  14930. });
  14931. }
  14932. if (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.space) {
  14933. node.spaces.after = this.optionalSpace(this.content());
  14934. this.position++;
  14935. }
  14936. return this.newNode(node);
  14937. };
  14938. _proto.comma = function comma() {
  14939. if (this.position === this.tokens.length - 1) {
  14940. this.root.trailingComma = true;
  14941. this.position++;
  14942. return;
  14943. }
  14944. this.current._inferEndPosition();
  14945. var selector = new _selector["default"]({
  14946. source: {
  14947. start: tokenStart(this.tokens[this.position + 1])
  14948. }
  14949. });
  14950. this.current.parent.append(selector);
  14951. this.current = selector;
  14952. this.position++;
  14953. };
  14954. _proto.comment = function comment() {
  14955. var current = this.currToken;
  14956. this.newNode(new _comment["default"]({
  14957. value: this.content(),
  14958. source: getTokenSource(current),
  14959. sourceIndex: current[_tokenize.FIELDS.START_POS]
  14960. }));
  14961. this.position++;
  14962. };
  14963. _proto.error = function error(message, opts) {
  14964. throw this.root.error(message, opts);
  14965. };
  14966. _proto.missingBackslash = function missingBackslash() {
  14967. return this.error('Expected a backslash preceding the semicolon.', {
  14968. index: this.currToken[_tokenize.FIELDS.START_POS]
  14969. });
  14970. };
  14971. _proto.missingParenthesis = function missingParenthesis() {
  14972. return this.expected('opening parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  14973. };
  14974. _proto.missingSquareBracket = function missingSquareBracket() {
  14975. return this.expected('opening square bracket', this.currToken[_tokenize.FIELDS.START_POS]);
  14976. };
  14977. _proto.unexpected = function unexpected() {
  14978. return this.error("Unexpected '" + this.content() + "'. Escaping special characters with \\ may help.", this.currToken[_tokenize.FIELDS.START_POS]);
  14979. };
  14980. _proto.namespace = function namespace() {
  14981. var before = this.prevToken && this.content(this.prevToken) || true;
  14982. if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  14983. this.position++;
  14984. return this.word(before);
  14985. } else if (this.nextToken[_tokenize.FIELDS.TYPE] === tokens.asterisk) {
  14986. this.position++;
  14987. return this.universal(before);
  14988. }
  14989. };
  14990. _proto.nesting = function nesting() {
  14991. if (this.nextToken) {
  14992. var nextContent = this.content(this.nextToken);
  14993. if (nextContent === "|") {
  14994. this.position++;
  14995. return;
  14996. }
  14997. }
  14998. var current = this.currToken;
  14999. this.newNode(new _nesting["default"]({
  15000. value: this.content(),
  15001. source: getTokenSource(current),
  15002. sourceIndex: current[_tokenize.FIELDS.START_POS]
  15003. }));
  15004. this.position++;
  15005. };
  15006. _proto.parentheses = function parentheses() {
  15007. var last = this.current.last;
  15008. var unbalanced = 1;
  15009. this.position++;
  15010. if (last && last.type === types$1.PSEUDO) {
  15011. var selector = new _selector["default"]({
  15012. source: {
  15013. start: tokenStart(this.tokens[this.position - 1])
  15014. }
  15015. });
  15016. var cache = this.current;
  15017. last.append(selector);
  15018. this.current = selector;
  15019. while (this.position < this.tokens.length && unbalanced) {
  15020. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  15021. unbalanced++;
  15022. }
  15023. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  15024. unbalanced--;
  15025. }
  15026. if (unbalanced) {
  15027. this.parse();
  15028. } else {
  15029. this.current.source.end = tokenEnd(this.currToken);
  15030. this.current.parent.source.end = tokenEnd(this.currToken);
  15031. this.position++;
  15032. }
  15033. }
  15034. this.current = cache;
  15035. } else {
  15036. // I think this case should be an error. It's used to implement a basic parse of media queries
  15037. // but I don't think it's a good idea.
  15038. var parenStart = this.currToken;
  15039. var parenValue = "(";
  15040. var parenEnd;
  15041. while (this.position < this.tokens.length && unbalanced) {
  15042. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  15043. unbalanced++;
  15044. }
  15045. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  15046. unbalanced--;
  15047. }
  15048. parenEnd = this.currToken;
  15049. parenValue += this.parseParenthesisToken(this.currToken);
  15050. this.position++;
  15051. }
  15052. if (last) {
  15053. last.appendToPropertyAndEscape("value", parenValue, parenValue);
  15054. } else {
  15055. this.newNode(new _string["default"]({
  15056. value: parenValue,
  15057. source: getSource(parenStart[_tokenize.FIELDS.START_LINE], parenStart[_tokenize.FIELDS.START_COL], parenEnd[_tokenize.FIELDS.END_LINE], parenEnd[_tokenize.FIELDS.END_COL]),
  15058. sourceIndex: parenStart[_tokenize.FIELDS.START_POS]
  15059. }));
  15060. }
  15061. }
  15062. if (unbalanced) {
  15063. return this.expected('closing parenthesis', this.currToken[_tokenize.FIELDS.START_POS]);
  15064. }
  15065. };
  15066. _proto.pseudo = function pseudo() {
  15067. var _this4 = this;
  15068. var pseudoStr = '';
  15069. var startingToken = this.currToken;
  15070. while (this.currToken && this.currToken[_tokenize.FIELDS.TYPE] === tokens.colon) {
  15071. pseudoStr += this.content();
  15072. this.position++;
  15073. }
  15074. if (!this.currToken) {
  15075. return this.expected(['pseudo-class', 'pseudo-element'], this.position - 1);
  15076. }
  15077. if (this.currToken[_tokenize.FIELDS.TYPE] === tokens.word) {
  15078. this.splitWord(false, function (first, length) {
  15079. pseudoStr += first;
  15080. _this4.newNode(new _pseudo["default"]({
  15081. value: pseudoStr,
  15082. source: getTokenSourceSpan(startingToken, _this4.currToken),
  15083. sourceIndex: startingToken[_tokenize.FIELDS.START_POS]
  15084. }));
  15085. if (length > 1 && _this4.nextToken && _this4.nextToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis) {
  15086. _this4.error('Misplaced parenthesis.', {
  15087. index: _this4.nextToken[_tokenize.FIELDS.START_POS]
  15088. });
  15089. }
  15090. });
  15091. } else {
  15092. return this.expected(['pseudo-class', 'pseudo-element'], this.currToken[_tokenize.FIELDS.START_POS]);
  15093. }
  15094. };
  15095. _proto.space = function space() {
  15096. var content = this.content(); // Handle space before and after the selector
  15097. if (this.position === 0 || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.prevToken[_tokenize.FIELDS.TYPE] === tokens.openParenthesis || this.current.nodes.every(function (node) {
  15098. return node.type === 'comment';
  15099. })) {
  15100. this.spaces = this.optionalSpace(content);
  15101. this.position++;
  15102. } else if (this.position === this.tokens.length - 1 || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.comma || this.nextToken[_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
  15103. this.current.last.spaces.after = this.optionalSpace(content);
  15104. this.position++;
  15105. } else {
  15106. this.combinator();
  15107. }
  15108. };
  15109. _proto.string = function string() {
  15110. var current = this.currToken;
  15111. this.newNode(new _string["default"]({
  15112. value: this.content(),
  15113. source: getTokenSource(current),
  15114. sourceIndex: current[_tokenize.FIELDS.START_POS]
  15115. }));
  15116. this.position++;
  15117. };
  15118. _proto.universal = function universal(namespace) {
  15119. var nextToken = this.nextToken;
  15120. if (nextToken && this.content(nextToken) === '|') {
  15121. this.position++;
  15122. return this.namespace();
  15123. }
  15124. var current = this.currToken;
  15125. this.newNode(new _universal["default"]({
  15126. value: this.content(),
  15127. source: getTokenSource(current),
  15128. sourceIndex: current[_tokenize.FIELDS.START_POS]
  15129. }), namespace);
  15130. this.position++;
  15131. };
  15132. _proto.splitWord = function splitWord(namespace, firstCallback) {
  15133. var _this5 = this;
  15134. var nextToken = this.nextToken;
  15135. var word = this.content();
  15136. while (nextToken && ~[tokens.dollar, tokens.caret, tokens.equals, tokens.word].indexOf(nextToken[_tokenize.FIELDS.TYPE])) {
  15137. this.position++;
  15138. var current = this.content();
  15139. word += current;
  15140. if (current.lastIndexOf('\\') === current.length - 1) {
  15141. var next = this.nextToken;
  15142. if (next && next[_tokenize.FIELDS.TYPE] === tokens.space) {
  15143. word += this.requiredSpace(this.content(next));
  15144. this.position++;
  15145. }
  15146. }
  15147. nextToken = this.nextToken;
  15148. }
  15149. var hasClass = indexesOf(word, '.').filter(function (i) {
  15150. // Allow escaped dot within class name
  15151. var escapedDot = word[i - 1] === '\\'; // Allow decimal numbers percent in @keyframes
  15152. var isKeyframesPercent = /^\d+\.\d+%$/.test(word);
  15153. return !escapedDot && !isKeyframesPercent;
  15154. });
  15155. var hasId = indexesOf(word, '#').filter(function (i) {
  15156. return word[i - 1] !== '\\';
  15157. }); // Eliminate Sass interpolations from the list of id indexes
  15158. var interpolations = indexesOf(word, '#{');
  15159. if (interpolations.length) {
  15160. hasId = hasId.filter(function (hashIndex) {
  15161. return !~interpolations.indexOf(hashIndex);
  15162. });
  15163. }
  15164. var indices = (0, _sortAscending["default"])(uniqs([0].concat(hasClass, hasId)));
  15165. indices.forEach(function (ind, i) {
  15166. var index = indices[i + 1] || word.length;
  15167. var value = word.slice(ind, index);
  15168. if (i === 0 && firstCallback) {
  15169. return firstCallback.call(_this5, value, indices.length);
  15170. }
  15171. var node;
  15172. var current = _this5.currToken;
  15173. var sourceIndex = current[_tokenize.FIELDS.START_POS] + indices[i];
  15174. var source = getSource(current[1], current[2] + ind, current[3], current[2] + (index - 1));
  15175. if (~hasClass.indexOf(ind)) {
  15176. var classNameOpts = {
  15177. value: value.slice(1),
  15178. source: source,
  15179. sourceIndex: sourceIndex
  15180. };
  15181. node = new _className["default"](unescapeProp(classNameOpts, "value"));
  15182. } else if (~hasId.indexOf(ind)) {
  15183. var idOpts = {
  15184. value: value.slice(1),
  15185. source: source,
  15186. sourceIndex: sourceIndex
  15187. };
  15188. node = new _id["default"](unescapeProp(idOpts, "value"));
  15189. } else {
  15190. var tagOpts = {
  15191. value: value,
  15192. source: source,
  15193. sourceIndex: sourceIndex
  15194. };
  15195. unescapeProp(tagOpts, "value");
  15196. node = new _tag["default"](tagOpts);
  15197. }
  15198. _this5.newNode(node, namespace); // Ensure that the namespace is used only once
  15199. namespace = null;
  15200. });
  15201. this.position++;
  15202. };
  15203. _proto.word = function word(namespace) {
  15204. var nextToken = this.nextToken;
  15205. if (nextToken && this.content(nextToken) === '|') {
  15206. this.position++;
  15207. return this.namespace();
  15208. }
  15209. return this.splitWord(namespace);
  15210. };
  15211. _proto.loop = function loop() {
  15212. while (this.position < this.tokens.length) {
  15213. this.parse(true);
  15214. }
  15215. this.current._inferEndPosition();
  15216. return this.root;
  15217. };
  15218. _proto.parse = function parse(throwOnParenthesis) {
  15219. switch (this.currToken[_tokenize.FIELDS.TYPE]) {
  15220. case tokens.space:
  15221. this.space();
  15222. break;
  15223. case tokens.comment:
  15224. this.comment();
  15225. break;
  15226. case tokens.openParenthesis:
  15227. this.parentheses();
  15228. break;
  15229. case tokens.closeParenthesis:
  15230. if (throwOnParenthesis) {
  15231. this.missingParenthesis();
  15232. }
  15233. break;
  15234. case tokens.openSquare:
  15235. this.attribute();
  15236. break;
  15237. case tokens.dollar:
  15238. case tokens.caret:
  15239. case tokens.equals:
  15240. case tokens.word:
  15241. this.word();
  15242. break;
  15243. case tokens.colon:
  15244. this.pseudo();
  15245. break;
  15246. case tokens.comma:
  15247. this.comma();
  15248. break;
  15249. case tokens.asterisk:
  15250. this.universal();
  15251. break;
  15252. case tokens.ampersand:
  15253. this.nesting();
  15254. break;
  15255. case tokens.slash:
  15256. case tokens.combinator:
  15257. this.combinator();
  15258. break;
  15259. case tokens.str:
  15260. this.string();
  15261. break;
  15262. // These cases throw; no break needed.
  15263. case tokens.closeSquare:
  15264. this.missingSquareBracket();
  15265. case tokens.semicolon:
  15266. this.missingBackslash();
  15267. default:
  15268. this.unexpected();
  15269. }
  15270. }
  15271. /**
  15272. * Helpers
  15273. */
  15274. ;
  15275. _proto.expected = function expected(description, index, found) {
  15276. if (Array.isArray(description)) {
  15277. var last = description.pop();
  15278. description = description.join(', ') + " or " + last;
  15279. }
  15280. var an = /^[aeiou]/.test(description[0]) ? 'an' : 'a';
  15281. if (!found) {
  15282. return this.error("Expected " + an + " " + description + ".", {
  15283. index: index
  15284. });
  15285. }
  15286. return this.error("Expected " + an + " " + description + ", found \"" + found + "\" instead.", {
  15287. index: index
  15288. });
  15289. };
  15290. _proto.requiredSpace = function requiredSpace(space) {
  15291. return this.options.lossy ? ' ' : space;
  15292. };
  15293. _proto.optionalSpace = function optionalSpace(space) {
  15294. return this.options.lossy ? '' : space;
  15295. };
  15296. _proto.lossySpace = function lossySpace(space, required) {
  15297. if (this.options.lossy) {
  15298. return required ? ' ' : '';
  15299. } else {
  15300. return space;
  15301. }
  15302. };
  15303. _proto.parseParenthesisToken = function parseParenthesisToken(token) {
  15304. var content = this.content(token);
  15305. if (token[_tokenize.FIELDS.TYPE] === tokens.space) {
  15306. return this.requiredSpace(content);
  15307. } else {
  15308. return content;
  15309. }
  15310. };
  15311. _proto.newNode = function newNode(node, namespace) {
  15312. if (namespace) {
  15313. if (/^ +$/.test(namespace)) {
  15314. if (!this.options.lossy) {
  15315. this.spaces = (this.spaces || '') + namespace;
  15316. }
  15317. namespace = true;
  15318. }
  15319. node.namespace = namespace;
  15320. unescapeProp(node, "namespace");
  15321. }
  15322. if (this.spaces) {
  15323. node.spaces.before = this.spaces;
  15324. this.spaces = '';
  15325. }
  15326. return this.current.append(node);
  15327. };
  15328. _proto.content = function content(token) {
  15329. if (token === void 0) {
  15330. token = this.currToken;
  15331. }
  15332. return this.css.slice(token[_tokenize.FIELDS.START_POS], token[_tokenize.FIELDS.END_POS]);
  15333. };
  15334. /**
  15335. * returns the index of the next non-whitespace, non-comment token.
  15336. * returns -1 if no meaningful token is found.
  15337. */
  15338. _proto.locateNextMeaningfulToken = function locateNextMeaningfulToken(startPosition) {
  15339. if (startPosition === void 0) {
  15340. startPosition = this.position + 1;
  15341. }
  15342. var searchPosition = startPosition;
  15343. while (searchPosition < this.tokens.length) {
  15344. if (WHITESPACE_EQUIV_TOKENS[this.tokens[searchPosition][_tokenize.FIELDS.TYPE]]) {
  15345. searchPosition++;
  15346. continue;
  15347. } else {
  15348. return searchPosition;
  15349. }
  15350. }
  15351. return -1;
  15352. };
  15353. _createClass(Parser, [{
  15354. key: "currToken",
  15355. get: function get() {
  15356. return this.tokens[this.position];
  15357. }
  15358. }, {
  15359. key: "nextToken",
  15360. get: function get() {
  15361. return this.tokens[this.position + 1];
  15362. }
  15363. }, {
  15364. key: "prevToken",
  15365. get: function get() {
  15366. return this.tokens[this.position - 1];
  15367. }
  15368. }]);
  15369. return Parser;
  15370. }();
  15371. exports["default"] = Parser;
  15372. module.exports = exports.default;
  15373. } (parser, parser.exports));
  15374. (function (module, exports) {
  15375. exports.__esModule = true;
  15376. exports["default"] = void 0;
  15377. var _parser = _interopRequireDefault(parser.exports);
  15378. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  15379. var Processor = /*#__PURE__*/function () {
  15380. function Processor(func, options) {
  15381. this.func = func || function noop() {};
  15382. this.funcRes = null;
  15383. this.options = options;
  15384. }
  15385. var _proto = Processor.prototype;
  15386. _proto._shouldUpdateSelector = function _shouldUpdateSelector(rule, options) {
  15387. if (options === void 0) {
  15388. options = {};
  15389. }
  15390. var merged = Object.assign({}, this.options, options);
  15391. if (merged.updateSelector === false) {
  15392. return false;
  15393. } else {
  15394. return typeof rule !== "string";
  15395. }
  15396. };
  15397. _proto._isLossy = function _isLossy(options) {
  15398. if (options === void 0) {
  15399. options = {};
  15400. }
  15401. var merged = Object.assign({}, this.options, options);
  15402. if (merged.lossless === false) {
  15403. return true;
  15404. } else {
  15405. return false;
  15406. }
  15407. };
  15408. _proto._root = function _root(rule, options) {
  15409. if (options === void 0) {
  15410. options = {};
  15411. }
  15412. var parser = new _parser["default"](rule, this._parseOptions(options));
  15413. return parser.root;
  15414. };
  15415. _proto._parseOptions = function _parseOptions(options) {
  15416. return {
  15417. lossy: this._isLossy(options)
  15418. };
  15419. };
  15420. _proto._run = function _run(rule, options) {
  15421. var _this = this;
  15422. if (options === void 0) {
  15423. options = {};
  15424. }
  15425. return new Promise(function (resolve, reject) {
  15426. try {
  15427. var root = _this._root(rule, options);
  15428. Promise.resolve(_this.func(root)).then(function (transform) {
  15429. var string = undefined;
  15430. if (_this._shouldUpdateSelector(rule, options)) {
  15431. string = root.toString();
  15432. rule.selector = string;
  15433. }
  15434. return {
  15435. transform: transform,
  15436. root: root,
  15437. string: string
  15438. };
  15439. }).then(resolve, reject);
  15440. } catch (e) {
  15441. reject(e);
  15442. return;
  15443. }
  15444. });
  15445. };
  15446. _proto._runSync = function _runSync(rule, options) {
  15447. if (options === void 0) {
  15448. options = {};
  15449. }
  15450. var root = this._root(rule, options);
  15451. var transform = this.func(root);
  15452. if (transform && typeof transform.then === "function") {
  15453. throw new Error("Selector processor returned a promise to a synchronous call.");
  15454. }
  15455. var string = undefined;
  15456. if (options.updateSelector && typeof rule !== "string") {
  15457. string = root.toString();
  15458. rule.selector = string;
  15459. }
  15460. return {
  15461. transform: transform,
  15462. root: root,
  15463. string: string
  15464. };
  15465. }
  15466. /**
  15467. * Process rule into a selector AST.
  15468. *
  15469. * @param rule {postcss.Rule | string} The css selector to be processed
  15470. * @param options The options for processing
  15471. * @returns {Promise<parser.Root>} The AST of the selector after processing it.
  15472. */
  15473. ;
  15474. _proto.ast = function ast(rule, options) {
  15475. return this._run(rule, options).then(function (result) {
  15476. return result.root;
  15477. });
  15478. }
  15479. /**
  15480. * Process rule into a selector AST synchronously.
  15481. *
  15482. * @param rule {postcss.Rule | string} The css selector to be processed
  15483. * @param options The options for processing
  15484. * @returns {parser.Root} The AST of the selector after processing it.
  15485. */
  15486. ;
  15487. _proto.astSync = function astSync(rule, options) {
  15488. return this._runSync(rule, options).root;
  15489. }
  15490. /**
  15491. * Process a selector into a transformed value asynchronously
  15492. *
  15493. * @param rule {postcss.Rule | string} The css selector to be processed
  15494. * @param options The options for processing
  15495. * @returns {Promise<any>} The value returned by the processor.
  15496. */
  15497. ;
  15498. _proto.transform = function transform(rule, options) {
  15499. return this._run(rule, options).then(function (result) {
  15500. return result.transform;
  15501. });
  15502. }
  15503. /**
  15504. * Process a selector into a transformed value synchronously.
  15505. *
  15506. * @param rule {postcss.Rule | string} The css selector to be processed
  15507. * @param options The options for processing
  15508. * @returns {any} The value returned by the processor.
  15509. */
  15510. ;
  15511. _proto.transformSync = function transformSync(rule, options) {
  15512. return this._runSync(rule, options).transform;
  15513. }
  15514. /**
  15515. * Process a selector into a new selector string asynchronously.
  15516. *
  15517. * @param rule {postcss.Rule | string} The css selector to be processed
  15518. * @param options The options for processing
  15519. * @returns {string} the selector after processing.
  15520. */
  15521. ;
  15522. _proto.process = function process(rule, options) {
  15523. return this._run(rule, options).then(function (result) {
  15524. return result.string || result.root.toString();
  15525. });
  15526. }
  15527. /**
  15528. * Process a selector into a new selector string synchronously.
  15529. *
  15530. * @param rule {postcss.Rule | string} The css selector to be processed
  15531. * @param options The options for processing
  15532. * @returns {string} the selector after processing.
  15533. */
  15534. ;
  15535. _proto.processSync = function processSync(rule, options) {
  15536. var result = this._runSync(rule, options);
  15537. return result.string || result.root.toString();
  15538. };
  15539. return Processor;
  15540. }();
  15541. exports["default"] = Processor;
  15542. module.exports = exports.default;
  15543. } (processor, processor.exports));
  15544. var selectors = {};
  15545. var constructors = {};
  15546. constructors.__esModule = true;
  15547. constructors.universal = constructors.tag = constructors.string = constructors.selector = constructors.root = constructors.pseudo = constructors.nesting = constructors.id = constructors.comment = constructors.combinator = constructors.className = constructors.attribute = void 0;
  15548. var _attribute = _interopRequireDefault(attribute$1);
  15549. var _className = _interopRequireDefault(className$1.exports);
  15550. var _combinator = _interopRequireDefault(combinator$2.exports);
  15551. var _comment = _interopRequireDefault(comment$2.exports);
  15552. var _id = _interopRequireDefault(id$1.exports);
  15553. var _nesting = _interopRequireDefault(nesting$1.exports);
  15554. var _pseudo = _interopRequireDefault(pseudo$1.exports);
  15555. var _root = _interopRequireDefault(root$1.exports);
  15556. var _selector = _interopRequireDefault(selector$1.exports);
  15557. var _string = _interopRequireDefault(string$1.exports);
  15558. var _tag = _interopRequireDefault(tag$1.exports);
  15559. var _universal = _interopRequireDefault(universal$1.exports);
  15560. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  15561. var attribute = function attribute(opts) {
  15562. return new _attribute["default"](opts);
  15563. };
  15564. constructors.attribute = attribute;
  15565. var className = function className(opts) {
  15566. return new _className["default"](opts);
  15567. };
  15568. constructors.className = className;
  15569. var combinator = function combinator(opts) {
  15570. return new _combinator["default"](opts);
  15571. };
  15572. constructors.combinator = combinator;
  15573. var comment = function comment(opts) {
  15574. return new _comment["default"](opts);
  15575. };
  15576. constructors.comment = comment;
  15577. var id = function id(opts) {
  15578. return new _id["default"](opts);
  15579. };
  15580. constructors.id = id;
  15581. var nesting = function nesting(opts) {
  15582. return new _nesting["default"](opts);
  15583. };
  15584. constructors.nesting = nesting;
  15585. var pseudo = function pseudo(opts) {
  15586. return new _pseudo["default"](opts);
  15587. };
  15588. constructors.pseudo = pseudo;
  15589. var root = function root(opts) {
  15590. return new _root["default"](opts);
  15591. };
  15592. constructors.root = root;
  15593. var selector = function selector(opts) {
  15594. return new _selector["default"](opts);
  15595. };
  15596. constructors.selector = selector;
  15597. var string = function string(opts) {
  15598. return new _string["default"](opts);
  15599. };
  15600. constructors.string = string;
  15601. var tag = function tag(opts) {
  15602. return new _tag["default"](opts);
  15603. };
  15604. constructors.tag = tag;
  15605. var universal = function universal(opts) {
  15606. return new _universal["default"](opts);
  15607. };
  15608. constructors.universal = universal;
  15609. var guards = {};
  15610. guards.__esModule = true;
  15611. guards.isNode = isNode;
  15612. guards.isPseudoElement = isPseudoElement;
  15613. guards.isPseudoClass = isPseudoClass;
  15614. guards.isContainer = isContainer;
  15615. guards.isNamespace = isNamespace;
  15616. guards.isUniversal = guards.isTag = guards.isString = guards.isSelector = guards.isRoot = guards.isPseudo = guards.isNesting = guards.isIdentifier = guards.isComment = guards.isCombinator = guards.isClassName = guards.isAttribute = void 0;
  15617. var _types = types;
  15618. var _IS_TYPE;
  15619. var IS_TYPE = (_IS_TYPE = {}, _IS_TYPE[_types.ATTRIBUTE] = true, _IS_TYPE[_types.CLASS] = true, _IS_TYPE[_types.COMBINATOR] = true, _IS_TYPE[_types.COMMENT] = true, _IS_TYPE[_types.ID] = true, _IS_TYPE[_types.NESTING] = true, _IS_TYPE[_types.PSEUDO] = true, _IS_TYPE[_types.ROOT] = true, _IS_TYPE[_types.SELECTOR] = true, _IS_TYPE[_types.STRING] = true, _IS_TYPE[_types.TAG] = true, _IS_TYPE[_types.UNIVERSAL] = true, _IS_TYPE);
  15620. function isNode(node) {
  15621. return typeof node === "object" && IS_TYPE[node.type];
  15622. }
  15623. function isNodeType(type, node) {
  15624. return isNode(node) && node.type === type;
  15625. }
  15626. var isAttribute = isNodeType.bind(null, _types.ATTRIBUTE);
  15627. guards.isAttribute = isAttribute;
  15628. var isClassName = isNodeType.bind(null, _types.CLASS);
  15629. guards.isClassName = isClassName;
  15630. var isCombinator = isNodeType.bind(null, _types.COMBINATOR);
  15631. guards.isCombinator = isCombinator;
  15632. var isComment = isNodeType.bind(null, _types.COMMENT);
  15633. guards.isComment = isComment;
  15634. var isIdentifier = isNodeType.bind(null, _types.ID);
  15635. guards.isIdentifier = isIdentifier;
  15636. var isNesting = isNodeType.bind(null, _types.NESTING);
  15637. guards.isNesting = isNesting;
  15638. var isPseudo = isNodeType.bind(null, _types.PSEUDO);
  15639. guards.isPseudo = isPseudo;
  15640. var isRoot = isNodeType.bind(null, _types.ROOT);
  15641. guards.isRoot = isRoot;
  15642. var isSelector = isNodeType.bind(null, _types.SELECTOR);
  15643. guards.isSelector = isSelector;
  15644. var isString = isNodeType.bind(null, _types.STRING);
  15645. guards.isString = isString;
  15646. var isTag = isNodeType.bind(null, _types.TAG);
  15647. guards.isTag = isTag;
  15648. var isUniversal = isNodeType.bind(null, _types.UNIVERSAL);
  15649. guards.isUniversal = isUniversal;
  15650. function isPseudoElement(node) {
  15651. return isPseudo(node) && node.value && (node.value.startsWith("::") || node.value.toLowerCase() === ":before" || node.value.toLowerCase() === ":after" || node.value.toLowerCase() === ":first-letter" || node.value.toLowerCase() === ":first-line");
  15652. }
  15653. function isPseudoClass(node) {
  15654. return isPseudo(node) && !isPseudoElement(node);
  15655. }
  15656. function isContainer(node) {
  15657. return !!(isNode(node) && node.walk);
  15658. }
  15659. function isNamespace(node) {
  15660. return isAttribute(node) || isTag(node);
  15661. }
  15662. (function (exports) {
  15663. exports.__esModule = true;
  15664. var _types = types;
  15665. Object.keys(_types).forEach(function (key) {
  15666. if (key === "default" || key === "__esModule") return;
  15667. if (key in exports && exports[key] === _types[key]) return;
  15668. exports[key] = _types[key];
  15669. });
  15670. var _constructors = constructors;
  15671. Object.keys(_constructors).forEach(function (key) {
  15672. if (key === "default" || key === "__esModule") return;
  15673. if (key in exports && exports[key] === _constructors[key]) return;
  15674. exports[key] = _constructors[key];
  15675. });
  15676. var _guards = guards;
  15677. Object.keys(_guards).forEach(function (key) {
  15678. if (key === "default" || key === "__esModule") return;
  15679. if (key in exports && exports[key] === _guards[key]) return;
  15680. exports[key] = _guards[key];
  15681. });
  15682. } (selectors));
  15683. (function (module, exports) {
  15684. exports.__esModule = true;
  15685. exports["default"] = void 0;
  15686. var _processor = _interopRequireDefault(processor.exports);
  15687. var selectors$1 = _interopRequireWildcard(selectors);
  15688. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  15689. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  15690. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  15691. var parser = function parser(processor) {
  15692. return new _processor["default"](processor);
  15693. };
  15694. Object.assign(parser, selectors$1);
  15695. delete parser.__esModule;
  15696. var _default = parser;
  15697. exports["default"] = _default;
  15698. module.exports = exports.default;
  15699. } (dist, dist.exports));
  15700. var selectorParser = /*@__PURE__*/getDefaultExportFromCjs(dist.exports);
  15701. const animationNameRE = /^(-\w+-)?animation-name$/;
  15702. const animationRE = /^(-\w+-)?animation$/;
  15703. const scopedPlugin = (id = '') => {
  15704. const keyframes = Object.create(null);
  15705. const shortId = id.replace(/^data-v-/, '');
  15706. return {
  15707. postcssPlugin: 'vue-sfc-scoped',
  15708. Rule(rule) {
  15709. processRule(id, rule);
  15710. },
  15711. AtRule(node) {
  15712. if (/-?keyframes$/.test(node.name) &&
  15713. !node.params.endsWith(`-${shortId}`)) {
  15714. // register keyframes
  15715. keyframes[node.params] = node.params = node.params + '-' + shortId;
  15716. }
  15717. },
  15718. OnceExit(root) {
  15719. if (Object.keys(keyframes).length) {
  15720. // If keyframes are found in this <style>, find and rewrite animation names
  15721. // in declarations.
  15722. // Caveat: this only works for keyframes and animation rules in the same
  15723. // <style> element.
  15724. // individual animation-name declaration
  15725. root.walkDecls(decl => {
  15726. if (animationNameRE.test(decl.prop)) {
  15727. decl.value = decl.value
  15728. .split(',')
  15729. .map(v => keyframes[v.trim()] || v.trim())
  15730. .join(',');
  15731. }
  15732. // shorthand
  15733. if (animationRE.test(decl.prop)) {
  15734. decl.value = decl.value
  15735. .split(',')
  15736. .map(v => {
  15737. const vals = v.trim().split(/\s+/);
  15738. const i = vals.findIndex(val => keyframes[val]);
  15739. if (i !== -1) {
  15740. vals.splice(i, 1, keyframes[vals[i]]);
  15741. return vals.join(' ');
  15742. }
  15743. else {
  15744. return v;
  15745. }
  15746. })
  15747. .join(',');
  15748. }
  15749. });
  15750. }
  15751. }
  15752. };
  15753. };
  15754. const processedRules = new WeakSet();
  15755. function processRule(id, rule) {
  15756. if (processedRules.has(rule) ||
  15757. (rule.parent &&
  15758. rule.parent.type === 'atrule' &&
  15759. /-?keyframes$/.test(rule.parent.name))) {
  15760. return;
  15761. }
  15762. processedRules.add(rule);
  15763. rule.selector = selectorParser(selectorRoot => {
  15764. selectorRoot.each(selector => {
  15765. rewriteSelector(id, selector, selectorRoot);
  15766. });
  15767. }).processSync(rule.selector);
  15768. }
  15769. function rewriteSelector(id, selector, selectorRoot) {
  15770. let node = null;
  15771. // find the last child node to insert attribute selector
  15772. selector.each(n => {
  15773. // DEPRECATED ">>>" and "/deep/" combinator
  15774. if (n.type === 'combinator' &&
  15775. (n.value === '>>>' || n.value === '/deep/')) {
  15776. n.value = ' ';
  15777. n.spaces.before = n.spaces.after = '';
  15778. // warn(
  15779. // `the >>> and /deep/ combinators have been deprecated. ` +
  15780. // `Use :deep() instead.`
  15781. // )
  15782. return false;
  15783. }
  15784. if (n.type === 'pseudo') {
  15785. const { value } = n;
  15786. // deep: inject [id] attribute at the node before the ::v-deep
  15787. // combinator.
  15788. if (value === ':deep' || value === '::v-deep') {
  15789. if (n.nodes.length) {
  15790. // .foo ::v-deep(.bar) -> .foo[xxxxxxx] .bar
  15791. // replace the current node with ::v-deep's inner selector
  15792. let last = n;
  15793. n.nodes[0].each(ss => {
  15794. selector.insertAfter(last, ss);
  15795. last = ss;
  15796. });
  15797. // insert a space combinator before if it doesn't already have one
  15798. const prev = selector.at(selector.index(n) - 1);
  15799. if (!prev || !isSpaceCombinator(prev)) {
  15800. selector.insertAfter(n, selectorParser.combinator({
  15801. value: ' '
  15802. }));
  15803. }
  15804. selector.removeChild(n);
  15805. }
  15806. else {
  15807. // DEPRECATED usage in v3
  15808. // .foo ::v-deep .bar -> .foo[xxxxxxx] .bar
  15809. // warn(
  15810. // `::v-deep usage as a combinator has ` +
  15811. // `been deprecated. Use :deep(<inner-selector>) instead.`
  15812. // )
  15813. const prev = selector.at(selector.index(n) - 1);
  15814. if (prev && isSpaceCombinator(prev)) {
  15815. selector.removeChild(prev);
  15816. }
  15817. selector.removeChild(n);
  15818. }
  15819. return false;
  15820. }
  15821. // !!! Vue 2 does not have :slotted support
  15822. // ::v-slotted(.foo) -> .foo[xxxxxxx-s]
  15823. // if (value === ':slotted' || value === '::v-slotted') {
  15824. // rewriteSelector(id, n.nodes[0], selectorRoot, true /* slotted */)
  15825. // let last: selectorParser.Selector['nodes'][0] = n
  15826. // n.nodes[0].each(ss => {
  15827. // selector.insertAfter(last, ss)
  15828. // last = ss
  15829. // })
  15830. // // selector.insertAfter(n, n.nodes[0])
  15831. // selector.removeChild(n)
  15832. // // since slotted attribute already scopes the selector there's no
  15833. // // need for the non-slot attribute.
  15834. // shouldInject = false
  15835. // return false
  15836. // }
  15837. // global: replace with inner selector and do not inject [id].
  15838. // ::v-global(.foo) -> .foo
  15839. if (value === ':global' || value === '::v-global') {
  15840. selectorRoot.insertAfter(selector, n.nodes[0]);
  15841. selectorRoot.removeChild(selector);
  15842. return false;
  15843. }
  15844. }
  15845. if (n.type !== 'pseudo' && n.type !== 'combinator') {
  15846. node = n;
  15847. }
  15848. });
  15849. if (node) {
  15850. node.spaces.after = '';
  15851. }
  15852. else {
  15853. // For deep selectors & standalone pseudo selectors,
  15854. // the attribute selectors are prepended rather than appended.
  15855. // So all leading spaces must be eliminated to avoid problems.
  15856. selector.first.spaces.before = '';
  15857. }
  15858. {
  15859. selector.insertAfter(
  15860. // If node is null it means we need to inject [id] at the start
  15861. // insertAfter can handle `null` here
  15862. node, selectorParser.attribute({
  15863. attribute: id,
  15864. value: id,
  15865. raws: {},
  15866. quoteMark: `"`
  15867. }));
  15868. }
  15869. }
  15870. function isSpaceCombinator(node) {
  15871. return node.type === 'combinator' && /^\s+$/.test(node.value);
  15872. }
  15873. scopedPlugin.postcss = true;
  15874. var sourceMap = require$$0__default$1["default"];
  15875. var SourceMapConsumer = sourceMap.SourceMapConsumer;
  15876. var SourceMapGenerator = sourceMap.SourceMapGenerator;
  15877. var mergeSourceMap = merge;
  15878. /**
  15879. * Merge old source map and new source map and return merged.
  15880. * If old or new source map value is falsy, return another one as it is.
  15881. *
  15882. * @param {object|string} [oldMap] old source map object
  15883. * @param {object|string} [newmap] new source map object
  15884. * @return {object|undefined} merged source map object, or undefined when both old and new source map are undefined
  15885. */
  15886. function merge(oldMap, newMap) {
  15887. if (!oldMap) return newMap
  15888. if (!newMap) return oldMap
  15889. var oldMapConsumer = new SourceMapConsumer(oldMap);
  15890. var newMapConsumer = new SourceMapConsumer(newMap);
  15891. var mergedMapGenerator = new SourceMapGenerator();
  15892. // iterate on new map and overwrite original position of new map with one of old map
  15893. newMapConsumer.eachMapping(function(m) {
  15894. // pass when `originalLine` is null.
  15895. // It occurs in case that the node does not have origin in original code.
  15896. if (m.originalLine == null) return
  15897. var origPosInOldMap = oldMapConsumer.originalPositionFor({
  15898. line: m.originalLine,
  15899. column: m.originalColumn
  15900. });
  15901. if (origPosInOldMap.source == null) return
  15902. mergedMapGenerator.addMapping({
  15903. original: {
  15904. line: origPosInOldMap.line,
  15905. column: origPosInOldMap.column
  15906. },
  15907. generated: {
  15908. line: m.generatedLine,
  15909. column: m.generatedColumn
  15910. },
  15911. source: origPosInOldMap.source,
  15912. name: origPosInOldMap.name
  15913. });
  15914. });
  15915. var consumers = [oldMapConsumer, newMapConsumer];
  15916. consumers.forEach(function(consumer) {
  15917. consumer.sources.forEach(function(sourceFile) {
  15918. mergedMapGenerator._sources.add(sourceFile);
  15919. var sourceContent = consumer.sourceContentFor(sourceFile);
  15920. if (sourceContent != null) {
  15921. mergedMapGenerator.setSourceContent(sourceFile, sourceContent);
  15922. }
  15923. });
  15924. });
  15925. mergedMapGenerator._sourceRoot = oldMap.sourceRoot;
  15926. mergedMapGenerator._file = oldMap.file;
  15927. return JSON.parse(mergedMapGenerator.toString())
  15928. }
  15929. // .scss/.sass processor
  15930. const scss = (source, map, options) => {
  15931. const nodeSass = require('sass');
  15932. const finalOptions = Object.assign(Object.assign({}, options), { data: getSource(source, options.filename, options.additionalData), file: options.filename, outFile: options.filename, sourceMap: !!map });
  15933. try {
  15934. const result = nodeSass.renderSync(finalOptions);
  15935. const dependencies = result.stats.includedFiles;
  15936. if (map) {
  15937. return {
  15938. code: result.css.toString(),
  15939. map: mergeSourceMap(map, JSON.parse(result.map.toString())),
  15940. errors: [],
  15941. dependencies
  15942. };
  15943. }
  15944. return { code: result.css.toString(), errors: [], dependencies };
  15945. }
  15946. catch (e) {
  15947. return { code: '', errors: [e], dependencies: [] };
  15948. }
  15949. };
  15950. const sass = (source, map, options) => scss(source, map, Object.assign(Object.assign({}, options), { indentedSyntax: true }));
  15951. // .less
  15952. const less = (source, map, options) => {
  15953. const nodeLess = require('less');
  15954. let result;
  15955. let error = null;
  15956. nodeLess.render(getSource(source, options.filename, options.additionalData), Object.assign(Object.assign({}, options), { syncImport: true }), (err, output) => {
  15957. error = err;
  15958. result = output;
  15959. });
  15960. if (error)
  15961. return { code: '', errors: [error], dependencies: [] };
  15962. const dependencies = result.imports;
  15963. if (map) {
  15964. return {
  15965. code: result.css.toString(),
  15966. map: mergeSourceMap(map, result.map),
  15967. errors: [],
  15968. dependencies: dependencies
  15969. };
  15970. }
  15971. return {
  15972. code: result.css.toString(),
  15973. errors: [],
  15974. dependencies: dependencies
  15975. };
  15976. };
  15977. // .styl
  15978. const styl = (source, map, options) => {
  15979. const nodeStylus = require('stylus');
  15980. try {
  15981. const ref = nodeStylus(source);
  15982. Object.keys(options).forEach(key => ref.set(key, options[key]));
  15983. if (map)
  15984. ref.set('sourcemap', { inline: false, comment: false });
  15985. const result = ref.render();
  15986. const dependencies = ref.deps();
  15987. if (map) {
  15988. return {
  15989. code: result,
  15990. map: mergeSourceMap(map, ref.sourcemap),
  15991. errors: [],
  15992. dependencies
  15993. };
  15994. }
  15995. return { code: result, errors: [], dependencies };
  15996. }
  15997. catch (e) {
  15998. return { code: '', errors: [e], dependencies: [] };
  15999. }
  16000. };
  16001. function getSource(source, filename, additionalData) {
  16002. if (!additionalData)
  16003. return source;
  16004. if (isFunction(additionalData)) {
  16005. return additionalData(source, filename);
  16006. }
  16007. return additionalData + source;
  16008. }
  16009. const processors = {
  16010. less,
  16011. sass,
  16012. scss,
  16013. styl,
  16014. stylus: styl
  16015. };
  16016. const postcss = require('postcss');
  16017. function compileStyle(options) {
  16018. return doCompileStyle(Object.assign(Object.assign({}, options), { isAsync: false }));
  16019. }
  16020. function compileStyleAsync(options) {
  16021. return Promise.resolve(doCompileStyle(Object.assign(Object.assign({}, options), { isAsync: true })));
  16022. }
  16023. function doCompileStyle(options) {
  16024. const { filename, id, scoped = true, trim = true, isProd = false, preprocessLang, postcssOptions, postcssPlugins } = options;
  16025. const preprocessor = preprocessLang && processors[preprocessLang];
  16026. const preProcessedSource = preprocessor && preprocess(options, preprocessor);
  16027. const map = preProcessedSource ? preProcessedSource.map : options.map;
  16028. const source = preProcessedSource ? preProcessedSource.code : options.source;
  16029. const plugins = (postcssPlugins || []).slice();
  16030. plugins.unshift(cssVarsPlugin({ id: id.replace(/^data-v-/, ''), isProd }));
  16031. if (trim) {
  16032. plugins.push(trimPlugin());
  16033. }
  16034. if (scoped) {
  16035. plugins.push(scopedPlugin(id));
  16036. }
  16037. const postCSSOptions = Object.assign(Object.assign({}, postcssOptions), { to: filename, from: filename });
  16038. if (map) {
  16039. postCSSOptions.map = {
  16040. inline: false,
  16041. annotation: false,
  16042. prev: map
  16043. };
  16044. }
  16045. let result, code, outMap;
  16046. const errors = [];
  16047. if (preProcessedSource && preProcessedSource.errors.length) {
  16048. errors.push(...preProcessedSource.errors);
  16049. }
  16050. try {
  16051. result = postcss(plugins).process(source, postCSSOptions);
  16052. // In async mode, return a promise.
  16053. if (options.isAsync) {
  16054. return result
  16055. .then((result) => ({
  16056. code: result.css || '',
  16057. map: result.map && result.map.toJSON(),
  16058. errors,
  16059. rawResult: result
  16060. }))
  16061. .catch((error) => ({
  16062. code: '',
  16063. map: undefined,
  16064. errors: [...errors, error.message],
  16065. rawResult: undefined
  16066. }));
  16067. }
  16068. // force synchronous transform (we know we only have sync plugins)
  16069. code = result.css;
  16070. outMap = result.map;
  16071. }
  16072. catch (e) {
  16073. errors.push(e);
  16074. }
  16075. return {
  16076. code: code || ``,
  16077. map: outMap && outMap.toJSON(),
  16078. errors,
  16079. rawResult: result
  16080. };
  16081. }
  16082. function preprocess(options, preprocessor) {
  16083. return preprocessor(options.source, options.map, Object.assign({
  16084. filename: options.filename
  16085. }, options.preprocessOptions));
  16086. }
  16087. exports.compileScript = compileScript;
  16088. exports.compileStyle = compileStyle;
  16089. exports.compileStyleAsync = compileStyleAsync;
  16090. exports.compileTemplate = compileTemplate;
  16091. exports.generateCodeFrame = generateCodeFrame;
  16092. exports.parse = parse;
  16093. exports.parseComponent = parseComponent;
  16094. exports.rewriteDefault = rewriteDefault;